<?php
/**
 * Maintenance page
 *
 * @package 	CSVIVirtueMart
 * @subpackage 	Maintenance
 * @todo
 * @author 		Roland Dalmulder
 * @link 		http://www.csvimproved.com
 * @copyright 	Copyright (C) 2006 - 2012 RolandD Cyber Produksi
 * @license 	GNU/GPLv3 http://www.gnu.org/licenses/gpl-3.0.html
 * @version 	$Id: default_database.php 1892 2012-02-11 11:01:09Z RolandD $
 */
 
defined( '_JEXEC' ) or die( 'Direct Access to this location is not allowed.' );
?>
<fieldset class="adminform">
<legend><?php echo JText::_('COM_CSVIVIRTUEMART_MAINTENANCE_DATABASE'); ?></legend>
<table class="admintable">
<tbody>
	<!-- Optimize tables -->
	<tr>
		<td class="key">
			<span class="hasTip" title="<?php echo JText::_('COM_CSVIVIRTUEMART_OPTIMIZETABLES_LABEL'); ?> :: <?php echo JText::_('COM_CSVIVIRTUEMART_OPTIMIZETABLES_DESC'); ?>"><?php echo JText::_('COM_CSVIVIRTUEMART_OPTIMIZETABLES_LABEL'); ?></span>
		</td>
		<td>
			<input type="radio" name="operation[]" value="optimizetables" onclick="setTask('optimizetables');" />
		</td>
	</tr>
	<!-- Unpublish products in unpublished categories -->
	<tr>
		<td class="key">
			<span class="hasTip" title="<?php echo JText::_('COM_CSVIVIRTUEMART_UNPUBLISHPRODUCTBYCATEGORY_LABEL'); ?> :: <?php echo JText::_('COM_CSVIVIRTUEMART_UNPUBLISHPRODUCTBYCATEGORY_DESC'); ?>"><?php echo JText::_('COM_CSVIVIRTUEMART_UNPUBLISHPRODUCTBYCATEGORY_LABEL'); ?></span>
		</td>
		<td>
			<input type="radio" name="operation[]" value="unpublishproductbycategory" onclick="setTask('unpublishproductbycategory');" />
		</td>
	</tr>
	<!-- Resize product title -->
	<tr id="resizeproducttitle">
		<td class="key">
			<span class="hasTip" title="<?php echo JText::_('COM_CSVIVIRTUEMART_RESIZEPRODUCTNAME_LABEL'); ?> :: <?php echo JText::_('COM_CSVIVIRTUEMART_RESIZEPRODUCTNAME_DESC'); ?>"><?php echo JText::_('COM_CSVIVIRTUEMART_RESIZEPRODUCTNAME_LABEL'); ?></span>
		</td>
		<td>
			<input type="radio" name="operation[]" value="resizeproductname" onclick="getFieldLength();" />
			<input type="hidden" id="productnamefieldlength" name="productnamefieldlength" value="" readonly="readonly"/>
		</td>
	</tr>
	<!-- Remove CSVI VirtueMart backup tables -->
	<tr>
		<td class="key">
			<span class="hasTip" title="<?php echo JText::_('COM_CSVIVIRTUEMART_REMOVECSVITABLES_LABEL'); ?> :: <?php echo JText::_('COM_CSVIVIRTUEMART_REMOVECSVITABLES_DESC'); ?>"><?php echo JText::_('COM_CSVIVIRTUEMART_REMOVECSVITABLES_LABEL'); ?></span>
		</td>
		<td>
			<input type="radio" name="operation[]" value="removecsvitables" onclick="confirmDelete(this, '<?php echo JText::_('COM_CSVIVIRTUEMART_CONFIRM_CSVITABLES_DELETE'); ?>', '<?php echo JText::_('COM_CSVIVIRTUEMART_REMOVECSVITABLES_LABEL'); ?>', 'removecsvitables');" />
		</td>
	</tr>
	<!-- Backup VM Database -->
	<tr id="backup_vm">
		<td class="key">
			<span class="hasTip" title="<?php echo JText::_('COM_CSVIVIRTUEMART_BACKUPVM_LABEL'); ?> :: <?php echo JText::_('COM_CSVIVIRTUEMART_BACKUPVM_DESC'); ?>"><?php echo JText::_('COM_CSVIVIRTUEMART_BACKUPVM_LABEL'); ?></span>
		</td>
		<td>
			<input type="radio" name="operation[]" value="backupvm" onclick="setTask('backupvm');" />
		</td>
	</tr>
	<!-- Empty database -->
	<tr>
		<td class="key">
			<span class="hasTip" title="<?php echo JText::_('COM_CSVIVIRTUEMART_EMPTYDATABASE_LABEL'); ?> :: <?php echo JText::_('COM_CSVIVIRTUEMART_EMPTYDATABASE_DESC'); ?>"><?php echo JText::_('COM_CSVIVIRTUEMART_EMPTYDATABASE_LABEL'); ?></span>
		</td>
		<td>
			<input type="radio" name="operation[]" value="emptydatabase" onclick="confirmDelete(this, '<?php echo JText::_('COM_CSVIVIRTUEMART_CONFIRM_DB_DELETE'); ?>', '<?php echo JText::_('COM_CSVIVIRTUEMART_EMPTYDATABASE_LABEL'); ?>', 'emptydatabase');" />
		</td>
	</tr>
</tbody>
</table>
</fieldset>

<script type="text/javascript">
	function getFieldLength() {
		jPrompt('<?php echo JText::sprintf('COM_CSVIVIRTUEMART_CURRENT_NAME_LENGTH', $this->sizeproductname);?><br /><br /><?php echo JText::_('COM_CSVIVIRTUEMART_NAME_LENGTH')?>', '', '<?php echo JText::_('COM_CSVIVIRTUEMART_RESIZE_PRODUCTTITLE_LABEL'); ?>', function(r) {
			if( r ) {
				if (r > 255) r = 255;
				document.adminForm.productnamefieldlength.value = r;
				jQuery('#resizeproducttitle td:nth-child(2)').append('<span><?php echo JText::_('COM_CSVIVIRTUEMART_SET_PRODUCTNAME_LENGTH'); ?>'+r+'</span>');
				setTask('resizeproductname');
			}
			else {
				setTask('maintenance');
				jQuery('#resizeproducttitle td:nth-child(2) span').remove();
			}
		}) 
	}
</script>
