. ***********************************************************************/ $page_security = 'SA_PRINTPROFILE'; $path_to_root = ".."; include($path_to_root . "/includes/session.inc"); include($path_to_root . "/admin/db/printers_db.inc"); include($path_to_root . "/includes/ui.inc"); page(_($help_context = "Printing Profiles")); $selected_id = get_post('profile_id',''); //------------------------------------------------------------------------------------------------- // Returns array of defined reports // function get_reports() { global $path_to_root, $SysPrefs; if ($SysPrefs->go_debug || !isset($_SESSION['reports'])) { // to save time, store in session. $paths = array ( $path_to_root.'/reporting/', company_path(). '/reporting/'); $reports = array( '' => _('Default printing destination')); foreach($paths as $dirno => $path) { $repdir = opendir($path); while(false !== ($fname = readdir($repdir))) { // reports have filenames in form rep(repid).php // where repid must contain at least one digit (reports_main.php is not ;) if (is_file($path.$fname) && preg_match('/rep(.*[0-9]+.*)[.]php/', $fname, $match)) { $repno = $match[1]; $title = ''; $line = file_get_contents($path.$fname); if (preg_match('/.*(FrontReport\()\s*_\([\'"]([^\'"]*)/', $line, $match)) { $title = trim($match[2]); } else // for any 3rd party printouts without FrontReport() class use if (preg_match('/.*(\$Title).*[\'"](.*)[\'"].+/', $line, $match)) { $title = trim($match[2]); } $reports[$repno] = $title; } } closedir(); } ksort($reports); $_SESSION['reports'] = $reports; } return $_SESSION['reports']; } function clear_form() { global $selected_id, $Ajax; $selected_id = ''; $_POST['name'] = ''; $Ajax->activate('_page_body'); } function check_delete($name) { // check if selected profile is used by any user if ($name=='') return 0; // cannot delete system default profile return key_in_foreign_table($name, 'users', 'print_profile'); } //------------------------------------------------------------------------------------------- if ( get_post('submit')) { $error = 0; if ($_POST['profile_id'] == '' && empty($_POST['name'])) { $error = 1; display_error( _("Printing profile name cannot be empty.")); set_focus('name'); } if (!$error) { $prof = array('' => get_post('Prn')); // store default value/profile name foreach (get_reports() as $rep => $descr) { $val = get_post('Prn'.$rep); $prof[$rep] = $val; } if ($_POST['profile_id']=='') $_POST['profile_id'] = get_post('name'); update_printer_profile($_POST['profile_id'], $prof); if ($selected_id == '') { display_notification_centered(_('New printing profile has been created')); clear_form($selected_id); } else { display_notification_centered(_('Printing profile has been updated')); } } } if(get_post('delete')) { if (!check_delete(get_post('name'))) { delete_printer_profile($selected_id); display_notification(_('Selected printing profile has been deleted')); clear_form(); } } if(get_post('_profile_id_update')) { $Ajax->activate('_page_body'); } start_form(); start_table(); print_profiles_list_row(_('Select printing profile'). ':', 'profile_id', null, _('New printing profile'), true); end_table(); echo '