} $query .= "ORDER BY {$order_by} {$order_by_asc} "; // Set selected option in template for Job order and Job order asc (ascendant order) $view->assign('result_order_field', $order_by); $view->assign('result_order_asc_checked', $result_order_asc_checked); // Jobs per page options $jobs_per_page = 25; $view->assign('jobs_per_page', array(25 => '25', 50 => '50', 75 => '75', 100 => '100', 150 => '150')); // Determine how many jobs per page // From config file if (FileConfig::get_Value('jobs_per_page') != false) { $jobs_per_page = FileConfig::get_Value('jobs_per_page'); } // From $_POST form if (!is_null(CHttpRequest::get_Value('jobs_per_page'))) { $jobs_per_page = CHttpRequest::get_Value('jobs_per_page'); } $query .= "LIMIT {$jobs_per_page}"; $view->assign('jobs_per_page_selected', $jobs_per_page); // Parsing jobs result $jobsresult = CDBUtils::runQuery($query, $dbSql->db_link); foreach ($jobsresult as $job) { // Determine icon for job status switch ($job['jobstatus']) { case J_RUNNING: $job['Job_icon'] = "play"; break; case J_COMPLETED: $job['Job_icon'] = "ok"; break; case J_CANCELED:
$client = ''; $period = ''; $client_jobs = array(); $backup_jobs = array(); $days_stored_bytes = array(); $days_stored_files = array(); $job_levels = array('D' => 'Differential', 'I' => 'Incremental', 'F' => 'Full'); try { if (!is_null(CHttpRequest::get_Value('client_id'))) { $clientid = CHttpRequest::get_Value('client_id'); } else { throw new Exception("Application error: client ID not specified as expected in Client report page"); } // Check time period if (!is_null(CHttpRequest::get_Value('period'))) { $period = CHttpRequest::get_Value('period'); } else { throw new Exception("Application error: the period hasn't been provided as expected"); } // Client informations $client = Clients_Model::getClientInfos($dbSql->db_link, $clientid); // Get job names for the client foreach (Jobs_Model::get_Jobs_List($dbSql->db_link, $clientid) as $jobname) { // Last good client's for each backup jobs $query = 'SELECT Job.Name, Job.Jobid, Job.Level, Job.Endtime, Job.Jobbytes, Job.Jobfiles, Status.JobStatusLong FROM Job '; $query .= "LEFT JOIN Status ON Job.JobStatus = Status.JobStatus "; $query .= "WHERE Job.Name = '{$jobname}' AND Job.JobStatus = 'T' AND Job.Type = 'B' "; $query .= 'ORDER BY Job.EndTime DESC '; $query .= 'LIMIT 1'; $jobs_result = CDBUtils::runQuery($query, $dbSql->db_link); foreach ($jobs_result->fetchAll() as $job) {
public function __construct(&$view) { // Loading configuration file parameters try { if (!FileConfig::open(CONFIG_FILE)) { throw new Exception("The configuration file is missing"); } else { $this->catalog_nb = FileConfig::count_Catalogs(); } } catch (Exception $e) { CErrorHandler::displayError($e); } // Template engine initalization $this->view = $view; // Checking template cache permissions if (!is_writable(VIEW_CACHE_DIR)) { throw new Exception("The template cache folder <b>" . VIEW_CACHE_DIR . "</b> must be writable by Apache user"); } // Initialize smarty gettext function $language = FileConfig::get_Value('language'); if (!$language) { throw new Exception("Language translation problem"); } $this->translate = new CTranslation($language); $this->translate->set_Language($this->view); // Get catalog_id from http $_GET request if (!is_null(CHttpRequest::get_Value('catalog_id'))) { if (FileConfig::catalogExist(CHttpRequest::get_Value('catalog_id'))) { $this->catalog_current_id = CHttpRequest::get_Value('catalog_id'); $_SESSION['catalog_id'] = $this->catalog_current_id; } else { $_SESSION['catalog_id'] = 0; $this->catalog_current_id = 0; throw new Exception('The catalog_id value provided does not correspond to a valid catalog, please verify the config.php file'); } } else { if (isset($_SESSION['catalog_id'])) { // Stick with previously selected catalog_id $this->catalog_current_id = $_SESSION['catalog_id']; } } // Define catalog id and catalog label $this->view->assign('catalog_current_id', $this->catalog_current_id); $this->view->assign('catalog_label', FileConfig::get_Value('label', $this->catalog_current_id)); // Getting database connection paremeter from configuration file $dsn = FileConfig::get_DataSourceName($this->catalog_current_id); $driver = FileConfig::get_Value('db_type', $this->catalog_current_id); $user = ''; $pwd = ''; if ($driver != 'sqlite') { $user = FileConfig::get_Value('login', $this->catalog_current_id); $pwd = FileConfig::get_Value('password', $this->catalog_current_id); } switch ($driver) { case 'mysql': case 'pgsql': $this->db_link = CDB::connect($dsn, $user, $pwd); break; case 'sqlite': $this->db_link = CDB::connect($dsn); break; } // Getting driver name from PDO connection $this->db_driver = CDB::getDriverName(); // Set PDO connection options $this->db_link->setAttribute(PDO::ATTR_CASE, PDO::CASE_LOWER); $this->db_link->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION); $this->db_link->setAttribute(PDO::ATTR_STATEMENT_CLASS, array('CDBResult', array($this))); // MySQL connection specific parameter if ($driver == 'mysql') { $this->db_link->setAttribute(PDO::MYSQL_ATTR_USE_BUFFERED_QUERY, true); } // Bacula catalog selection if ($this->catalog_nb > 1) { // Catalogs list $this->view->assign('catalogs', FileConfig::get_Catalogs()); // Catalogs count $this->view->assign('catalog_nb', $this->catalog_nb); } }
session_start(); include_once 'core/global.inc.php'; // Initialise view and model $view = new CView(); $dbSql = null; try { $dbSql = new Bweb($view); require_once 'core/const.inc.php'; // Custom period for dashboard $no_period = array(FIRST_DAY, NOW); $last_day = array(LAST_DAY, NOW); // Default period (last day) $custom_period = $last_day; $selected_period = 'last_day'; if (isset($_POST['period_selector'])) { $selected_period = CHttpRequest::get_Value('period_selector'); $view->assign('custom_period_list_selected', $selected_period); switch ($selected_period) { case 'last_day': $custom_period = array(LAST_DAY, NOW); break; case 'last_week': $custom_period = array(LAST_WEEK, NOW); break; case 'last_month': $custom_period = array(LAST_MONTH, NOW); break; case 'since_bot': $custom_period = $no_period; break; }
| as published by the Free Software Foundation; either version 2 | | of the License, or (at your option) any later version. | | | | This program is distributed in the hope that it will be useful, | | but WITHOUT ANY WARRANTY; without even the implied warranty of | | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | | GNU General Public License for more details. | +-------------------------------------------------------------------------+ */ session_start(); include_once 'core/global.inc.php'; try { $view = new CView(); $dbSql = new Bweb($view); $joblogs = array(); $jobid = CHttpRequest::get_Value('jobid'); // If $_GET['jobid'] is null and is not a number, throw an Exception if (is_null($jobid) or !is_numeric($jobid)) { throw new Exception('Invalid job id (invalid or null) provided in Job logs report'); } // Prepare and execute SQL statment $statment = array('table' => 'Log', 'where' => array("JobId = '{$jobid}'"), 'orderby' => 'Time'); $result = CDBUtils::runQuery(CDBQuery::get_Select($statment), $dbSql->db_link); // Processing result foreach ($result->fetchAll() as $log) { $log['logtext'] = nl2br($log['logtext']); $joblogs[] = $log; } $view->assign('jobid', $jobid); $view->assign('joblogs', $joblogs); // Set page name