<?php
/**
 * Cron view
 *
 * @package 	CSVIVirtueMart
 * @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: view.html.php 1892 2012-02-11 11:01:09Z RolandD $
 */

defined( '_JEXEC' ) or die( 'Direct Access to this location is not allowed.' );

jimport( 'joomla.application.component.view' );

/**
 * Cron View
 *
 * @package CSVIVirtueMart
 */
class CsvivirtuemartViewCron extends JView {
	
	/**
	 * Cron features 
	 * 
	 * @copyright 
	 * @author 		RolandD
	 * @todo 
	 * @see 
	 * @access 		public
	 * @param 
	 * @return 
	 * @since 		3.0
	 */
	public function display($tpl = null) {
		
		// Load the posted data
		$option = JRequest::getVar('option');
		$data = JRequest::getVar($option.'.data');
		$from = JRequest::getWord('from');
		
		// The basics of the cronline
		$this->cronline = 'php "'.JPATH_COMPONENT_ADMINISTRATOR.'/helpers/cron.php" username="" passwd="" ';
		
		// Construct the correct cron
		switch ($from) {
			case 'import':
			case 'export':
				if (!empty($data)) {
					// Load the form handler
					$this->loadHelper('template');
					$this->template = new CsviTemplate($data);
					JRequest::setVar('template', $this->template);
					
					// Construct the cronline
					$this->cronline .= $this->get('CronLine');
				}
				else $this->cronline = JText::_('COM_CSVIVIRTUEMART_NO_CRON_DATA_FOUND');
				break;
			case 'maintenance':
				// Construct the cronline
				$this->cronline .= $this->get('CronLineMaintenance');
				break;
		}
		
		
		// Show the toolbar
		JToolBarHelper::title(JText::_('COM_CSVIVIRTUEMART_CRON'), 'csvivirtuemart_cron_48');
		
		// Display it all
		parent::display($tpl);
	}
}
?>