<?php
require_once('../../system/configuration.php');
require(PATH_SYSTEM.'core.php');
try 
{
  $cron = new cron();
  
	$_SESSION['user']->userCheckAccess(LEVEL_CUSTOMER);
	$_SESSION['hosting']->userCheckAccess();
	
	
	if ( $_SESSION['hosting']->information_hosting->offer_crons_number == 0 ) $base_tpl = 'error/not_in_offer';
	else {
		
		// Crons specific menu
		$crons_menu = array();
		$crons_menu['hosting/crons.xhtml'] = 'mnu_list_crons';
		$crons_menu['hosting/crons-add.xhtml'] = "mnu_add_cron";
		$_SESSION['template']->addMenu('crons', $crons_menu);
	  
		if ( isset($_GET['action']) and $_GET['action'] == 'add') {
			$base_tpl = 'hosting/crons/add';
			$_SESSION['template']->getWords(array('CRON_MIN_TIME' => CRON_MIN_TIME));
		} else {
			$base_tpl = 'hosting/crons/list';	    
			$pages_count = $cron->userCountTotalPages();
			$_SESSION['template']->getWords(array('pages_count' => $pages_count));
		} // End of listing    
	
 }
  
	// Template
	$_SESSION['template']->loadCSS(array('crons.css'));
	$_SESSION['template']->loadTemplate('_contentbegin');
	$_SESSION['template']->loadTemplate($base_tpl);
	$_SESSION['template']->loadTemplate('_contentend');
	$_SESSION['template']->getWords(array('sql' => $_SESSION['database']->executed_req));
	$_SESSION['template']->parseTemplate();
} catch (myException $error) {
	$error->displayErrorMessage();
}
?>