$default_option ) { if( !isset($options[$key]) ) $options[$key] = $default_option; } return $options; } /** * Print (tiny) inline button * (private function; use 'print_tiny_button()' to add a stand-alone button to a form) * * Inputs: * - button Array with * - icon Icon to show, mutex with 'text' * - text Text to display * - url URL (href) * - action Code for the "onclick" event handler * - in_table Place the button in a table cell (CSS class "action_button") */ function print_inline_button($button, $in_table = FALSE) { global $_PAGE_INFO; if( $in_table ) echo ""; if( $button['href'] ) echo ""; echo ""; if( $button['icon'] ) echo ""; else if( $button['text'] ) echo "

" . $button['text'] . "

"; echo ""; if( $button['href'] ) echo "
"; if( $in_table ) echo ""; } /** * Test to check if printing to a form */ function must_start_form_row() { global $_PAGE_INFO; return !isset($_SESSION[$_PAGE_INFO['id']]['extended_menu']) && ( isset($_PAGE_INFO['form']) && $_PAGE_INFO['form']['active'] && ( isset($_PAGE_INFO['form']['scrollable_div']) || $_PAGE_INFO['form']['row'] == 0 ) ) && !isset($_PAGE_INFO['embedded_table']) && !isset($_PAGE_INFO['div']); } /** * Print prologue and epilogue to a printable item * Checks if the item is on a form * (private function) * * Inputs * - title * - form Stricly old style (for pages that do not yet use * 'print_form_start()') */ function print_prologue($title = NULL) { global $_PAGE_INFO; if( !isset($_PAGE_INFO['form']) && func_num_args() > 1 ) { $args = func_get_args(); $form = $args[1]; } else { $form = must_start_form_row(); } // sort out the title $form_only = FALSE; $sep = "
\n"; if( is_array($title) ) { if( isset($title['form']) ) { $_title = $title['form']['title']; $form_only = TRUE; } else $_title = $title['title']; if( $title['sep'] ) $sep = $title['sep']; } else { $_title = $title; $title = array(); // basically, unset... } // print the title and start a table row on a form if( isset($_SESSION[$_PAGE_INFO['id']]['extended_menu']) ) { if( $title && !$form_only ) print_text($_title); $form = TRUE; } if( $form ) { echo "\n"; echo "\n"; echo ""; if( $_title ) echo "

" . $_title . "

\n"; echo "\n"; echo ""; } else { // in a paragraph? print a line break if( isset($_PAGE_INFO['p']) && $_PAGE_INFO['p']['line']++ > 0 ) echo "
\n"; // print the title, unless this is disabled (i.e. the title // in that case will only be printed if there is a "col2" column if( $_title && !$form_only ) { if( $title['css_class'] || $title['style'] ) { echo ""; echo $_title . $sep; echo ""; } else echo $_title . $sep; } } // each pair of 'print_prologue()' and 'print_epilogue()' must be matched if( isset($_PAGE_INFO['form']) ) $_PAGE_INFO['form']['row']++; return $form; } function print_epilogue() { global $_PAGE_INFO; if( !isset($_PAGE_INFO['form']) && func_num_args() > 0 ) { $args = func_get_args(); $form = $args[0]; } else { $form = ($_PAGE_INFO['form']['row'] > 0); } if( $form && (!isset($_PAGE_INFO['form']) || --$_PAGE_INFO['form']['row'] == 0) ) { echo "\n"; echo "\n"; } } /** * Form */ function print_form_start($name, $action) { global $_PAGE_INFO; echo "
\n"; echo "\n"; $_PAGE_INFO['form']['active'] = array('name' => $name); $_PAGE_INFO['form']['row'] = 0; // reference counter } function print_form_end() { global $_PAGE_INFO; echo "
\n"; echo "
\n"; unset($_PAGE_INFO['form']); } /** * Create menu (matrix or list) * * Inputs: * - header: Menu header * - menuitems: Button text * - menulinks: Button links * - menurights: Button rights (1=enabled, 0=disabled) * - matrix: Use matrix when more then 4 items? * - form: form? add row * - extra_info Add extra icon/info * - text_length Maximum text length */ function print_menu($header, $menuitems, $menulinks, $menurights, $matrix = 1, $form = 0, $extra_info = "", $text_length = 25) { GLOBAL $_PAGE_INFO; if ($form) { echo "\n"; echo "\n"; echo "\n"; echo ""; } else { echo "
\n"; } if (strlen($header)) { echo "

" . _($header) . "

"; } echo "\n"; // Display matrix or row if ((sizeof($menuitems) > 5) && ($matrix)) { // 3x? matrix for ($i = 0; $i < (sizeof($menuitems)/3); $i++) { if ($form) { echo "\n"; } else { echo "\n"; } for ($j = 0; $j < 3; $j++) { if (($i*3 + $j) < sizeof($menuitems)) { echo "\n"; } } echo "\n"; } } else { // Retrieve main items and check for the rights for ($i = 0; $i < sizeof($menuitems); $i++) { echo "\n"; if ($form) { echo "\n"; echo "\n"; } } echo "
\n"; echo "\n"; } echo "\n"; echo "
\n"; } else { echo "\n"; } echo "\n"; } echo "\n"; echo "
\n"; if ($form) { echo "\n"; echo "\n"; echo "\n"; } else { echo "
"; } } /** * Print title */ function print_title($title, $options = 0, $form = 1 /* strictly old style */) { if( is_array($options) ) { print_merge_default_options($options, array('center' => FALSE, 'form' => TRUE)); } else { // old style parameters $options = array('center' => $options, 'form' => $form); } $need_div = $options['buttons'] || $options['style'] || $options['action']; if( $options['form'] ) { echo "\n"; echo "\n"; echo "\n"; echo "\n"; } if( $options['url'] ) echo ""; if( $need_div ) { echo "
"; } if( $options['buttons'] ) { echo ""; foreach( $options['buttons'] as $button ) print_inline_button($button, TRUE); echo "
"; } if ($options['center']) { echo "
"; } if (strlen($title)) { echo "

" . htmlspecialchars(strip_tags(_($title))) . "

\n"; } if ($options['center']) { echo "
"; } if( $options['buttons'] ) { echo "
"; } if( $need_div ) { echo "
"; } if( $options['url'] ) echo "
"; if( $options['form'] ) { echo "\n"; echo "\n"; } } /** * Print subtitle */ function print_subtitle($subtitle, $options = 0, $form = 1 /* strictly old style */) { if( is_array($options) ) { print_merge_default_options($options, array('center' => FALSE, 'form' => TRUE)); } else { // old style parameters $options = array('center' => $options, 'form' => $form); } $need_div = $options['buttons'] || $options['style'] || $options['action']; if( $options['form'] ) { echo "\n"; echo "\n"; echo "\n"; echo "\n"; } if( $options['url'] ) echo ""; if( $need_div ) { echo "
"; } if( $options['buttons'] ) { echo ""; foreach( $options['buttons'] as $button ) print_inline_button($button, TRUE); echo "
"; } if ($options['center']) { echo "
"; } if (strlen($subtitle)) { echo "

" . _($subtitle) . "

\n"; } if ($options['center']) { echo "
"; } if( $options['buttons'] ) { echo "
"; } if( $need_div ) { echo "
"; } if( $options['url'] ) echo "
"; if( $options['form'] ) { echo "\n"; echo "\n"; } } function print_subsubtitle($subtitle, $options = 0, $form = 1 /* strictly old style */) { if( is_array($options) ) { print_merge_default_options($options, array('center' => FALSE, 'form' => TRUE)); } else { // old style parameters $options = array('center' => $options, 'form' => $form); } $need_div = $options['buttons'] || $options['style'] || $options['action']; if( $options['form'] ) { echo "\n"; echo "\n"; echo "\n"; echo "\n"; } if( $options['url'] ) echo ""; if( $need_div ) { echo "
"; } if( $options['buttons'] ) { echo ""; foreach( $options['buttons'] as $button ) print_inline_button($button, TRUE); echo "
"; } if ($options['center']) { echo "
"; } if (strlen($subtitle)) { echo "

" . htmlspecialchars(strip_tags(_($subtitle))) . "

\n"; } if (strlen($options['center'])) { echo "
"; } if( $options['buttons'] ) { echo "
"; } if( $need_div ) { echo "
"; } if( $options['url'] ) echo "
"; if( $options['form'] ) { echo "\n"; echo "\n"; } } /** * Print text */ function print_text($text, $options = 0, $form = 1 /* strictly old style */) { if( is_array($options) ) { print_merge_default_options($options, array('css_class' => NULL, 'form' => TRUE)); } else { // old style parameters $options = array('css_class' => $options, 'form' => $form); } $need_div = $options['buttons'] || $options['style'] || $options['action']; if( $options['form'] ) { echo "\n"; echo "\n"; echo "\n"; echo "\n"; } if( $options['url'] ) echo ""; if( $need_div ) { echo "
"; } if( $options['buttons'] ) { echo ""; foreach( $options['buttons'] as $button ) print_inline_button($button, TRUE); echo "
"; } echo ""; if( strlen($text) ) echo _($text); echo "

\n"; if( $options['buttons'] ) { echo "
"; } if( $need_div ) { echo "
"; } if( $options['url'] ) echo "
"; if( $options['form'] ) { echo "\n"; echo "\n"; } } /** * Print Filter & search button */ function print_filter_search($title, $name, $value, $onkeyup = "") { echo "\n"; echo "\n"; echo "

" . _($title) . "

\n"; echo ""; if (strlen($onkeyup)) { echo "\n"; echo "\n"; } else { echo "\n"; echo "\n"; } echo "\n"; echo "\n"; echo "\n"; } /** * Print input * * Inputs: * - Title Title * - name name * - value session value * - ro_action Read only actions (array) * - info info message * - onkeyup onkey up event * - extra_info_style extra info style options * - center center control */ function print_input($title, $name, $value, $ro_actions, $info = "", $bold = 1, $onkeyup = "", $extra_info_style = "", $center = "") { global $_PAGE_INFO; if (isset($_SESSION[$_PAGE_INFO['id']]['extended_menu'])) { print_text(_($title)); } echo "\n"; echo "\n"; echo ""; if (strlen($onkeyup)) { echo "\n"; } if (!isset($_SESSION[$_PAGE_INFO['id']]['extended_menu'])) { echo "

" . _($title) . "

\n"; } echo "\n"; echo ""; // Alignment if (strlen($center)) { echo "
"; } echo "\n"; // Alignment if (strlen($center)) { echo "
"; } // Display message? if (strlen($info)) { echo "\n"; } echo "\n"; echo "\n"; // Disabled control => create hidden control if (is_ro($ro_actions)) { print_hidden_input($name, $value); } } /** * Print info * * Inputs: * - name name + _info * - info info message * - bold Bold text */ function print_info($name, $info = "", $bold=1) { // Display message? if (strlen($info)) { echo "\n"; } } /** * Print textarea * * Inputs: * - Title Title * - name name * - value session value * - height text area height * - ro_action Read only actions (array) * - action Add action button (array with 'button_text' and 'action') * - bold Display bold info text * - strip_tags Strip html tags from textarea */ function print_textarea($title, $name, $value, $height, $ro_actions, $info = "", $action = NULL, $bold = 1, $strip_tags = TRUE) { global $_PAGE_INFO; if (isset($_SESSION[$_PAGE_INFO['id']]['extended_menu'])) { print_text(_($title)); } echo "\n"; echo "\n"; echo ""; if (!isset($_SESSION[$_PAGE_INFO['id']]['extended_menu'])) { echo "

" . _($title) . "

\n"; } echo "\n"; echo ""; echo "\n"; // Display message? if (strlen($info)) { echo "\n"; } // action? if( $action && is_array($action)) { echo "
"; echo "\n"; echo "
"; } echo "\n"; echo "\n"; // Disabled control => create hidden control if (is_ro($ro_actions)) { print_hidden_input($name, $value); } } /** * Print table * * Inputs: * - Title Title * - Name Name * - value Array filled with data * - id Select id * - per Percentage of listbox * - align Alignment ("L" left ,"C" center) * - ro_actions Read only actions (array) * - on_change on change event * - size listbox sizeof * - sel_val selected value * - skip_table_end do not print last column * - width width of listbox (default 303px) */ function print_table($title, $name, $value, $opt, $id, $per = "", $align = "", $ro_actions, $on_change = "", $size = "", $sel_val = "", $skip_table_end = 0, $table_large = 0, $truetype = TRUE) { global $_PAGE_INFO; // Determine listbox width (retrieved from css file $lwidth = (!$table_large) ? $_SESSION[$_PAGE_INFO['id']]['print_table_width'] : $_SESSION[$_PAGE_INFO['id']]['print_table_large_width']; // Determine listbox width $total = $lwidth/8; if (is_array($per)) { if (is_array($value[0])) { $one = ($total/100); for ($i = 0; $i < sizeof($value[0]); $i++) { $width[$i] = round($one * $per[$i]); } } } else { if (is_array($value[0])) { for ($i = 0; $i < sizeof($value[0]); $i++) { $width[$i] = round($total/sizeof($value[0])); } } else { $width[0] = $total; } } echo "\n"; echo "\n"; echo "

" . _($title) . "

\n"; echo "\n"; // Create header if (strlen($value[0][0])) { $table = ($table_large) ? "table_input_large" : "table_input"; echo "= $width[$i]) { $val = substr($val, 0, $width[$i]-3+$offset) . ".. "; } // determine length => for fill $val_len = strlen($val); // Replace html entities echo specialchars($val); // Fill rest $fill = ($width[$i] - $val_len - $align_size); if ($fill) { for ($j = 0; $j < $fill; $j++) { echo " "; } } } echo "\">
"; } if (!strlen($size)) { $size = ((sizeof($value) > 2) || (is_ro($ro_actions))) ? (sizeof($value)-1) : 2; } $table = ($table_large) ? "table_select_large" : "table_select"; echo "\n"; if (!$skip_table_end) { echo "\n"; echo "\n"; } } /** * Print file upload (etc) control * * Inputs: * - Title Title * - name name * - Upload Upload button? * - onuploadsumbit Upload button submit event * - onchange Browse change event * - info Info message */ function print_input_file($title, $name, $upload = 0, $onuploadsumbit = "", $onchange = "", $info = "", $bold = 1, $hidden_input = FALSE, $multiple_files = FALSE, $browse_caption = "Browse", $upload_caption = "Upload") { global $_PAGE_INFO; // Multiple files supported? $multiple_addon = ""; $multiple_name = ""; if ($multiple_files) { $multiple_addon = "multiple=\"multiple\""; $multiple_name = "[]"; } echo "\n"; echo "\n"; echo "

" . _($title) . "

\n"; echo ""; if (browser() != "IE") { if (!$hidden_input) { echo ""; echo ""; echo ""; if ($upload) { echo "\n"; } } else { echo ""; echo ""; echo ""; } } else { echo ""; if ($upload) { echo "\n"; } } // Display message? if (strlen($info)) { // add extra white space echo " "; echo "\n"; } echo "\n"; echo "\n"; } /** * Print file open button * * Inputs: * - title Title (colum to the left of the control) * - name Identifier for the control * - value Text to print in the control's content * - link URL to call when the control is clicked * - options Options: * - buttons: Array with buttons (with an 'icon' and 'href' or 'action') * - new_window (boolean), default TRUE * - bold Print text in bold font */ function print_file_open($title, $name, $value, $ro_actions, $link, $options = NULL, $bold = 1) { global $_PAGE_INFO; if( !is_array($options) ) $options = array(); if( is_array($options[0]) && isset($options[0]['icon']) ) { // old style (buttons) $options['buttons'] = $options; } print_merge_default_options($options, array('new_window' => TRUE, 'form' => TRUE, 'text_length' => 40)); // // NB: button sizes and text lengths are best guesses and the are not necessarily perfect // // width of the button (override CSS) $button_width = 300; // compensate text width for the embedded buttons if( isset($options['button_width']) ) { $embedded_buttons_width = $options['button_width']; $options['text_length'] -= $embedded_buttons_width / 8; // wild guess: characters are on average 8px wide } else if( is_array($options['buttons']) ) { $embedded_buttons_width = count($options['buttons']) * 20; $options['text_length'] -= count($options['buttons']) * 2; } else $embedded_buttons_width = 0; // disable the link when this button is read-only if( is_ro($ro_actions) ) $link = FALSE; print_prologue(_($title), TRUE); // NB: translation echo "
"; echo ""; echo ""; echo ""; if( is_array($options['buttons']) ) foreach( $options['buttons'] as $button ) print_inline_button($button, TRUE); echo ""; echo "
"; if( $link ) { echo ""; } echo " 0 /* TBD? */ ) { echo " onmouseover=\"Tip('" . htmlspecialchars(addslashes(strip_tags($value))) . "',BGCOLOR,'" . $_PAGE_INFO['ini']['tooltip']['background'] . "',BORDERCOLOR, '" . $_PAGE_INFO['ini']['tooltip']['border'] . "');\""; echo " onmouseout=\"UnTip();\""; } $style = ""; if( $options['style'] ) $style .= $options['style']; echo " style=\"" . $style . ";max-width:" . ($button_width - 6 - $embedded_buttons_width) . "px;\""; echo ">"; $button_text = strip_tags($value); $button_text = shorten_text($button_text, $options['text_length'], SHORTEN_NARROW); echo $button_text; echo ""; if( $link ) echo ""; echo "
"; echo "
"; print_epilogue(TRUE); } /** * Print date control * * Inputs: * - Title Title * - name name * - value session value * - ro_action Read only actions (array) */ function print_date($title, $name, $value, $ro_actions, $info = "", $bold = 1) { global $_PAGE_INFO; if (isset($_SESSION[$_PAGE_INFO['id']]['extended_menu'])) { print_text(_($title)); } echo "\n"; echo "\n"; echo ""; if (!isset($_SESSION[$_PAGE_INFO['id']]['extended_menu'])) { echo "

" . _($title) . "

\n"; } echo "\n"; echo ""; echo "
"; echo ""; } else { echo $name . "\">"; } echo "\n"; // Display message? if (strlen($info)) { echo "\n"; } echo "
"; echo "\n"; echo "\n"; // Disabled control => create hidden control if (is_ro($ro_actions)) { print_hidden_input($name, $value); } } /** * Print time control * * Inputs: * - Title Title * - time_name time name * - time_value time value * - ro_action Read only actions (array) * - info info which must be displayed * - bold info bold */ function print_time($title, $time_name, $time_value, $ro_actions, $info = "", $bold = 1) { global $_PAGE_INFO; if (isset($_SESSION[$_PAGE_INFO['id']]['extended_menu'])) { print_text(_($title)); } echo "\n"; echo "\n"; echo ""; if (isset($_SESSION[$_PAGE_INFO['id']]['extended_menu'])) { echo "

" . _($title) . "

\n"; } echo "\n"; echo ""; // Time control echo "\n"; // Display message? if (strlen($info)) { echo "\n"; } echo "\n"; echo "\n"; // Disabled control => create hidden control if (is_ro($ro_actions)) { print_hidden_input($date_name, $date_value); } } /** * Print date time control * * Inputs: * - Title Title * - date_name date name * - date_value date value * - time_name time name * - time_value time value * - ro_action Read only actions (array) * - info info which must be displayed * - bold info bold * - extra_info_style extra info style options */ function print_datetime($title, $date_name, $date_value, $time_name, $time_value, $ro_actions, $info = "", $bold = 1, $extra_info_style = "") { global $_PAGE_INFO; if (isset($_SESSION[$_PAGE_INFO['id']]['extended_menu'])) { print_text(_($title)); } echo "\n"; echo "\n"; echo ""; if (!isset($_SESSION[$_PAGE_INFO['id']]['extended_menu'])) { echo "

" . _($title) . "

\n"; } echo "\n"; echo ""; echo "
"; echo ""; } else { echo $date_name . "\">"; } echo "\n"; // Time control echo ""; if (strlen($date_value)) { if (is_ro($ro_actions)) { echo "\n"; if (!strlen($date_value)) { echo "disabled"; } echo ">\n"; for ($i = 0; $i < 24; $i++) { for ($j = 0; $j < 4; $j++) { $value = ($i < 10) ? "0" . $i : $i; $value .= ":"; $value .= (!$j) ? "00" : $j*15; echo "
"; echo "\n"; echo "\n"; // Disabled control => create hidden control if (is_ro($ro_actions)) { print_hidden_input($date_name, $date_value); } } /** * Print day time control * * Inputs: * - Title Title * - name name * - value session value * - ro_action Read only actions (array) */ function print_daytime($title, $day_name, $day_value, $time_name, $time_value, $ro_actions, $info = "", $bold = 1, $skip_table_end = 0) { echo "\n"; echo "\n"; echo "

" . _($title) . "

\n"; echo ""; echo "
"; // day control $days = array("", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday", "Sunday"); echo "\n"; // Time control if ($day_value) { if (is_ro($ro_actions)) { echo "\n"; for ($i = 0; $i < 24; $i++) { for ($j = 0; $j < 4; $j++) { $value = ($i < 10) ? "0" . $i : $i; $value .= ":"; $value .= (!$j) ? "00" : $j*15; echo "
"; echo "\n"; echo "\n"; } // Disabled control => create hidden control if (is_ro($ro_actions)) { print_hidden_input($day_name, $day_value); } } /** * Print password * * Inputs: * - Title Title * - name name * - value session value * - info info message * - extra_info_style extra info style options * - center center control */ function print_password($title, $name, $value, $info = "", $bold = 1, $extra_info_style = "", $center = "") { echo "\n"; echo "\n"; echo "

" . _($title) . "

\n"; echo ""; // Alignment if (strlen($center)) { echo "
"; } if( !isset($value) || strlen($value) == 0 ) { // show some dummy characters $value = addcslashes(PASSWD_DISPLAY_TEXT, "\"\'\n\r\f\t"); } else $value = strip_tags($value); echo ""; echo "\n"; // Alignment if (strlen($center)) { echo "
"; } if (strlen($info)) { echo "\n"; } echo "\n"; echo "\n"; } /** * Print checkbox * * Inputs: * - Title Title * - name name * - value session value * - value_checked value checked * - ro_action Read only actions (array) * - info info message" * - label Add label */ function print_checkbox($title, $name, $value, $value_checked, $ro_actions, $options = NULL, $on_change = NULL) { global $_PAGE_INFO; if( !is_array($options) ) { // old style parameters $options = array('label' => _($options), 'onchange' => $on_change); } print_merge_default_options($options, array('css_class' => NULL, 'form' => !isset($_SESSION[$_PAGE_INFO['id']]['extended_menu']))); $on_form = print_prologue( array('form' => array('title' => _($title))), // NB: translation $options['form'] ); $need_div = $options['buttons'] || $options['style'] || $options['action']; if( $options['url'] ) echo ""; if( $need_div ) { echo "
"; } if ($options['center']) { echo "
"; } if( $options['buttons'] ) { echo ""; foreach( $options['buttons'] as $button ) print_inline_button($button, TRUE); echo "
"; } echo "
"; } if( $need_div ) { echo "
"; } if( $options['url'] ) echo "
"; if( $options['form'] ) { echo "\n"; echo "\n"; } echo "\n"; if( $options['center'] ) echo ""; print_epilogue($options['form']); } /** * Print radiobutton * * Inputs: * - Title Title * - name name * - value session value * - value_checked value checked * - ro_action Read only actions (array) * - info info message" * - label Add label * - skip_table_end Skip table end */ function print_radiobutton($title, $name, $value, $value_checked, $ro_actions, $label = "", $on_change = "", $skip_table_end = 0) { global $_PAGE_INFO; if (isset($_SESSION[$_PAGE_INFO['id']]['extended_menu'])) { print_text(_($title)); } echo "\n"; echo "\n"; echo ""; if (!isset($_SESSION[$_PAGE_INFO['id']]['extended_menu'])) { $title = (!strlen($title)) ? " " : $title; echo "

" . _($title) . "

\n"; } echo "\n"; echo "\n"; if (strlen($label)) { echo "\n"; } if ($skip_table_end) { echo "\n"; echo "\n"; } } /** * Print tel/fax/mob input * * Inputs: * - Title Title * - name name * - value session value * - ro_actions Read only actions (array) * - rc_actions Recall actions on which this input must react (array) * - actions Valid actions (array) * - old_info Old info value * - required 0 (nothing)/1 (required)/2 (checking) */ function print_tel_input($title, $name, $value, $ro_actions, $rc_actions, $actions, $old_info = "", $req = 0) { // Check for correct action if (($req == 1) && (!is_ro($ro_actions))) { $info = "*"; } else { $info = ""; } // Check recall action $result = 0; if (is_array($rc_actions)) { foreach ($rc_actions as $rc) { if (is_valid_recall($rc)) { $result = 1; } } } if ($result) { // Check for correct action $result = 0; if (is_array($actions)) { foreach ($actions as $action) { if (is_valid_action($action)) { $result = 1; } } } if ($result) { // Check if this value is required if ($req == 1) { if (!strlen($value)) { $info = "Required field!"; $result = 0; } else { $info = "*"; } } } if (($result) || ($req == 2)) { // Check number if (!valid_fax_tel($value)) { $info = "Invalid number!"; } } } else if (is_valid_recall()) { // Different recall => restore old value $info = $old_info; } print_input($title, $name, $value, $ro_actions, $info); } /** * Print email input * * Inputs: * - Title Title * - name name * - value session value * - ro_actions Read only actions (array) * - rc_actions Recall actions (array) * - actions Valid actions (array) * - old_info Old info value * - required 0 (nothing)/1 (required)/2 (checking) */ function print_email_input($title, $name, $value, $ro_actions, $rc_actions, $actions, $old_info = "", $req = 0) { // Check for correct action if (($req == 1) && (!is_ro($ro_actions))) { $info = "*"; } else { $info = ""; } // Check recall action $result = 0; if (is_array($rc_actions)) { foreach ($rc_actions as $rc) { if (is_valid_recall($rc)) { $result = 1; } } } if ($result) { // Check for correct action $result = 0; if (is_array($actions)) { foreach ($actions as $action) { if (is_valid_action($action)) { $result = 1; } } } if ($result) { // Check if this value is required if ($req == 1) { if (!strlen($value)) { $info = "Required field!"; $result = 0; } else { $info = "*"; } } } if (($result) || ($req == 2)) { // Check email if (!valid_email($value)) { $info = "Invalid email!"; } } } else if (is_valid_recall()) { // Different recall => restore old value $info = $old_info; } print_input($title, $name, $value, $ro_actions, $info); } /** * Print geo input * * Inputs: * - Title Title * - name name * - value session value * - ro_actions Read only actions (array) * - rc_actions Recall actions (array) * - actions Valid actions (array) * - old_info Old info value * - required 0 (nothing)/1 (required)/2 (checking) */ function print_geo_input($title, $name, $value, $ro_actions, $rc_actions, $actions, $old_info = "", $req = 0) { // Check for correct action if (($req == 1) && (!is_ro($ro_actions))) { $info = "*"; } else { $info = ""; } // Check recall action $result = 0; if (is_array($rc_actions)) { foreach ($rc_actions as $rc) { if (is_valid_recall($rc)) { $result = 1; } } } if ($result) { // Check for correct action $result = 0; if (is_array($actions)) { foreach ($actions as $action) { if (is_valid_action($action)) { $result = 1; } } } if ($result) { // Check if this value is required if ($req == 1) { if (!strlen($value)) { $info = "Required field!"; $result = 0; } else { $info = "*"; } } } if (($result) || ($req == 2)) { // Check geo if (!valid_geo($value)) { $info = "Invalid geo-value!"; } } } else if (is_valid_recall()) { // Different recall => restore old value $info = $old_info; } print_input($title, $name, $value, $ro_actions, $info); } /** * Print hidden input * * Inputs: * - name name * - value session value */ function print_hidden_input($name, $value) { echo ""; } /** * Print email input * * Inputs: * - title Title * - name Name for the checkboxes (will put an array in the form data) * - rights All available rights * - rights_enabled All enabled rights * - rights_checked All checked rights */ function print_rights_overview($title, $name, $rights, $rights_enabled, $rights_checked) { global $_PAGE_INFO; // User right translation table global $user_right_translation; // Skip these rights $skip_rights = array( "menu:lansen:wijzigen", "menu:projecten:wijzigen", "menu:projecten:verwijderen", "menu:service:magazijnbeheer", "zkl 3000 rc", "google_maps", "trillingssensor", "schakelen", "productie", "administratie", "magazijnbeheer", // replaced by menu:service rights; will be removed "menu:faq" // TO DO: will be removed from the database once the 'rechten' field is up-to-date ); // The LHS rights below are automatically checked when the user has the RHS right $include_rights = array( "menu:service:wijzigen" => "menu:service:manager" ); echo "\n"; echo "\n"; echo "

" . _($title) . "

\n"; echo ""; echo "\n"; // Determine all menu items (menu:sub_menu:menu_item or menu:menu_item or General when no ':') $menu_items = array(); if (is_array($rights)) { foreach($rights as $right) { if (!in_array($right, $skip_rights)) { // Check user right translations if( isset($user_right_translation[$right]) ) $right = $user_right_translation[$right]; // Find ":" char in string $pos1 = strpos($right, ":"); if ($pos1 !== false) { // Find next ":" char in string $pos2 = strpos($right, ":", ($pos1 + strlen(":"))); if ($pos2 !== false) { // Add administrator menu if (substr($right, $pos2 + strlen(":")) == "root") { $menu = "root"; } else { $menu = substr($right, 0, $pos2); } } else { $menu = $right; } // Put menu item in array when not empty if (strlen($menu)) { array_push($menu_items, $menu); } } else { array_push($menu_items, "general"); } } } } // Add psuedo-menus $menu_items[] = "menu:app"; // Remove duplicated array values $menu_items = array_unique($menu_items); // Move general items to the top of the menu; the root menu items will be place on top of this below $value = array_search("general", $menu_items); if ($value !== FALSE) { unset($menu_items[$value]); array_unshift($menu_items, "general"); } // Move administrator to the top of the menu $value = array_search("root", $menu_items); if ($value !== FALSE) { unset($menu_items[$value]); array_unshift($menu_items, "root"); } // Display checkbox table with header if (is_array($menu_items)) { foreach ($menu_items as $menu_item) { if (!empty($menu_item)) { // Reset counter $i = 0; // Find ":" char in menu item $pos1 = strpos($menu_item, ":"); echo "\n"; echo ""; } echo "\n"; // Number 3 => end of row if (($i % 3) == 2) { echo "\n"; } $i++; $j++; } } } } } // JW20141003: needed for IE11 to print top and right borders while( ($i++ % 3) ) echo ""; echo "\n"; // End of row when less then 3 items if (($i % 3) != 0) { echo "\n"; } } } } echo "
"; echo ""; echo _("right:" . $menu_item); echo ""; //Display checkboxes if (is_array($rights)) { foreach ($rights as $right) { if (!in_array($right, $skip_rights)) { $right_menu = $right; // Translate the user right in order to put it in the right menu if( isset($user_right_translation[$right_menu]) ) $right_menu = $user_right_translation[$right_menu]; $pos1 = strpos($right_menu, $menu_item); // Check if this menu item is a part of the right => this right must be put in this menu // Exception: when the menu item is General and no ':' available in the right if ((($pos1 !== false) || ((strpos($right_menu, ":") === false) && ($menu_item == "general")))) { // Double check if this is realy the correct menu_item and if this is an admin right if ((((strlen($right_menu) == strlen($menu_item)) || ($right_menu[($pos1 + strlen($menu_item))] == ":") || ($pos1 === false)) && (strpos($right_menu, "root") === false)) || ((strpos($right_menu, "root") !== false) && ($menu_item == "root"))) { // Number 1 => start of new row if (($i % 3) == 0) { if( $i != 0 ) echo "
"; // Strip menu:,status:,etc: of user right $pos1 = strpos($right_menu, ":"); $pos2 = strpos($right_menu, ":", $pos1 + strlen(":")); if (($pos1 !== false) && ($pos2 !== false)) { if (substr($right_menu, $pos2 + strlen(":")) == "root") { // 2 x ":" available and admin right => remove menu and right part (menu:menu_item:right) $sright = substr($right_menu, ($pos1 + strlen(":")), $pos2 - ($pos1 + strlen(":"))); } else { // 2 x ":" available => remove two parts for example (menu:menu_item:right) $sright = substr($right_menu, ($pos2 + strlen(":"))); } } else if ($pos1 !== false) { // 1 x ":" available => right for accessing menu $sright = "toegang"; } else { // 0 x ":" available => General item $sright = $right_menu; } // Skip "current" customer when editing customer $skip_rights_current = (is_valid_action("cust_change","cust_new")); // Verify rights => check/unchecked and enable/disable checkbox echo ""; echo "\n"; // Save all values which are checked but now are disabled if ((is_array($rights_checked)) && (is_array($rights_enabled))) { if ((!in_array($right_menu, $rights_enabled)) && (in_array($right_menu, $rights_checked))) { // Store hidden input print_hidden_input($right_menu,$right_menu); } } echo "
\n"; echo "\n"; echo "\n"; } /** * Print left right control * * Inputs: * - title control title * - name name * - object page object (project_info for example) * - labels labels for above the listboxes * - all_items array containing (id, value, color) * - initial_left_items array containing (id, value, color) => also used for ro actions * - ro_actions Read only actions (array) * - height Number of entries * - all Handle all items at once? */ function print_left_right_control($title, $name, $object, $labels, $all_items, $initial_left_items, $ro_actions, $height = 10, $all = FALSE) { GLOBAL $_PAGE_INFO; // Define layout if (isset($_SESSION[$_PAGE_INFO['id']]['extended_menu'])) { print_text(_($title)); } echo "\n"; echo "\n"; echo ""; if (!isset($_SESSION[$_PAGE_INFO['id']]['extended_menu'])) { echo "

" . _($title) . "

\n"; } echo ""; echo ""; // Initial values $left_ids = array(); $left_values = array(); $left_colors = array(); // Read only? if (is_ro($ro_actions)) { echo ""; // Select size (tooltip won't work at size 1) switch(sizeof($initial_left_items)) { case 0: $size = 1; break; case 1: $size = 2; break; default: $size = sizeof($initial_left_items); break; } echo "\n"; echo ""; // Store intial items if (is_array($initial_left_items)) { foreach ($initial_left_items as $item) { array_push($left_ids, $item['id']); array_push($left_values, $item['value']); array_push($left_colors, $item['color']); } } // Store left ids print_hidden_input($name . "_left_ids", implode(",", $left_ids)); // Update/store session variables if (!is_array($object)) { $_SESSION[$_PAGE_INFO['id']][$object][$name . "_left_ids"] = implode(",", $left_ids); } else { $_SESSION[$_PAGE_INFO['id']][$object[0]][$object[1]][$name . "_left_ids"] = implode(",", $left_ids); } } else { echo "\n"; echo "\n"; echo "\n"; echo "\n"; echo "\n"; echo "\n"; echo "
\n"; // Store all items in an array $all_ids = array(); $all_values = array(); $all_colors = array(); if (is_array($all_items)) { foreach($all_items as $item) { array_push($all_ids, $item['id']); array_push($all_values, $item['value']); array_push($all_colors, $item['color']); } } if (!is_array($object)) { // First time? => assign initial left items if (!isset($_SESSION[$_PAGE_INFO['id']][$object][$name . "_left_ids"])) { $left_items = (is_array($initial_left_items)) ? $initial_left_items : array(); } else { // Restore old values (ids, values and color) if (strlen($_SESSION[$_PAGE_INFO['id']][$object][$name . "_left_ids"])) { $ids = split(",", $_SESSION[$_PAGE_INFO['id']][$object][$name . "_left_ids"]); $values = array(); $colors = array(); if (is_array($ids)) { foreach($ids as $id) { $pos = array_search($id, $all_ids); array_push($values, $all_values[$pos]); array_push($colors, $all_colors[$pos]); } } $left_items = array(); if ((is_array($ids)) && (is_array($values)) && (is_array($colors))) { for ($i=0; $i < sizeof($ids); $i++) { // Check if left items is still in all items if (in_array($ids[$i], $all_ids)) { array_push($left_items, array(id => $ids[$i], value => $values[$i], color => $colors[$i])); } } } } else { $left_items = array(); } } // Check for valid recalls (Clear filter) if ((is_valid_recall("reset_filter_" . $name))) { $_SESSION[$_PAGE_INFO['id']][$object][$name . "_filter"] = ""; } // Check for valid recalls if ((is_valid_recall("but_" . $name . "_left_right", "but_dbl_" . $name . "_left_right"))) { // All item option enabled and button pushed/or double clicked? if (($all) && (is_array($all_ids))) { $_SESSION[$_PAGE_INFO['id']][$object][$name . "_left"] = $all_ids; } // Where some items selected? if (isset($_SESSION[$_PAGE_INFO['id']][$object][$name . "_left"])) { if (is_array($left_items)) { // Backup and clear left_items $backup_left_items = $left_items; $left_items = array(); // Remove from the left foreach($backup_left_items as $item) { if (!in_array($item['id'], $_SESSION[$_PAGE_INFO['id']][$object][$name . "_left"])) { array_push($left_items, $item); } } // Clear session info unset($_SESSION[$_PAGE_INFO['id']][$object][$name . "_left"]); } } } else if ((is_valid_recall("but_" . $name . "_right_left","but_dbl_" . $name . "_right_left"))) { // All item option enabled and button pushed? if (($all) && (is_array($all_ids))) { $_SESSION[$_PAGE_INFO['id']][$object][$name . "_right"] = $all_ids; } // Where some items selected? if (isset($_SESSION[$_PAGE_INFO['id']][$object][$name . "_right"])) { $left_items = (is_array($left_items)) ? $left_items : array(); if ((is_array($all_items)) && (is_array($_SESSION[$_PAGE_INFO['id']][$object][$name . "_right"]))) { foreach($_SESSION[$_PAGE_INFO['id']][$object][$name . "_right"] as $item) { // Find value by id $pos = array_search($item, $all_ids); array_push($left_items, array(id => $item, value => $all_values[$pos], color => $all_colors[$pos])); } // Clear session info unset($_SESSION[$_PAGE_INFO['id']][$object][$name . "_right"]); } } } } else { // First time? => assign initial left items if (!isset($_SESSION[$_PAGE_INFO['id']][$object[0]][$object[1]][$name . "_left_ids"])) { $left_items = (is_array($initial_left_items)) ? $initial_left_items : array(); } else { // Restore old values if (strlen($_SESSION[$_PAGE_INFO['id']][$object[0]][$object[1]][$name . "_left_ids"])) { $ids = split(",", $_SESSION[$_PAGE_INFO['id']][$object[0]][$object[1]][$name . "_left_ids"]); $values = array(); $colors = array(); if (is_array($ids)) { foreach($ids as $id) { $pos = array_search($id, $all_ids); array_push($values, $all_values[$pos]); array_push($colors, $all_colors[$pos]); } } $left_items = array(); if ((is_array($ids)) && (is_array($values)) && (is_array($colors))) { for ($i=0; $i < sizeof($ids); $i++) { // Check if left items is still in all items if (in_array($ids[$i], $all_ids)) { array_push($left_items, array(id => $ids[$i], value => $values[$i], color => $colors[$i])); } } } } else { $left_items = array(); } } // Check for valid recalls (Clear filter) if ((is_valid_recall("reset_filter_" . $name))) { $_SESSION[$_PAGE_INFO['id']][$object[0]][$object[1]][$name . "_filter"] = ""; } // Check for valid recalls if ((is_valid_recall("but_" . $name . "_left_right","but_dbl_" . $name . "_left_right"))) { // All item option enabled and button pushed? if (($all) && (is_array($all_ids))) { $_SESSION[$_PAGE_INFO['id']][$object[0]][$object[1]][$name . "_left"] = $all_ids; } // Where some items selected? if (isset($_SESSION[$_PAGE_INFO['id']][$object[0]][$object[1]][$name . "_left"])) { if (is_array($left_items)) { // Backup and clear left_items $backup_left_items = $left_items; $left_items = array(); // Remove from the left foreach($backup_left_items as $item) { if (!in_array($item['id'], $_SESSION[$_PAGE_INFO['id']][$object[0]][$object[1]][$name . "_left"])) { array_push($left_items, $item); } } // Clear session info unset($_SESSION[$_PAGE_INFO['id']][$object[0]][$object[1]][$name . "_left"]); } } } else if ((is_valid_recall("but_" . $name . "_right_left","but_dbl_" . $name . "_right_left"))) { // All item option enabled and button pushed? if (($all) && (is_array($all_ids))) { $_SESSION[$_PAGE_INFO['id']][$object[0]][$object[1]][$name . "_right"] = $all_id; } // Where some items selected? if (isset($_SESSION[$_PAGE_INFO['id']][$object[0]][$object[1]][$name . "_right"])) { $left_items = (is_array($left_items)) ? $left_items : array(); if ((is_array($all_items)) && (is_array($_SESSION[$_PAGE_INFO['id']][$object[0]][$object[1]][$name . "_right"]))) { foreach($_SESSION[$_PAGE_INFO['id']][$object[0]][$object[1]][$name . "_right"] as $item) { // Find value by id $pos = array_search($item, $all_ids); array_push($left_items, array(id => $item, value => $all_values[$pos], color => $all_colors[$pos])); } // Clear session info unset($_SESSION[$_PAGE_INFO['id']][$object[0]][$object[1]][$name . "_right"]);// = array(); } } } } // Removed duplicated entries $left_items = arrayUnique($left_items); // Sort left items alphabetic $left_items = array_sort($left_items, "value"); // Left lisbox echo ""; echo ""; echo "\n"; echo ""; // Store all left values print_hidden_input($name . "_left_ids", implode(",", $left_ids)); // Update/store session variables if (!is_array($object)) { $_SESSION[$_PAGE_INFO['id']][$object][$name . "_left_ids"] = implode(",", $left_ids); } else { $_SESSION[$_PAGE_INFO['id']][$object[0]][$object[1]][$name . "_left_ids"] = implode(",", $left_ids); } echo "\n"; // Table for buttons echo "\n"; echo "\n"; echo "\n"; echo "\n"; echo "\n"; echo "\n"; echo "\n"; echo "\n"; echo "\n"; echo "
\n"; $icon = ($all) ? "<<" : "<"; echo "\n"; echo "
\n"; $icon = ($all) ? ">>" : ">"; echo "\n"; echo "
\n"; echo "
\n"; // Sort right items alphabetic $all_items = array_sort($all_items, "value"); // Filter value if (!is_array($object)) { $filter_value = htmlspecialchars($_SESSION[$_PAGE_INFO['id']][$object][$name . "_filter"]); } else { $filter_value = htmlspecialchars($_SESSION[$_PAGE_INFO['id']][$object[0]][$object[1]][$name . "_filter"]); } // right listbox echo "
"; echo ""; echo ""; echo "\n"; echo "\n"; echo ""; echo "
"; if (!$all) { // Filter right box! echo "\n"; echo ""; echo "\n"; echo "\n"; } echo "
\n"; } echo "\n"; echo "\n"; } /** * Start and end a scroll area (scrollable div) * * Inputs: * - options Options array with (all optional) * - 'form' Part of the form (default TRUE) * - 'max-height' Override default height from CSS * - 'style' Other styles */ function print_scrollarea_start($options = FALSE) { if( is_array($options) ) { print_merge_default_options($options, array('form' => TRUE)); } else { // old style parameters $options = array('form' => TRUE); } if( $options['form'] ) { echo "\n"; echo "\n"; echo "\n"; echo "\n"; } echo "
"; echo ""; } function print_scrollarea_end($options = FALSE) { if( is_array($options) ) { print_merge_default_options($options, array('form' => TRUE)); } else { // old style parameters $options = array('form' => TRUE); } echo "
"; echo "
"; if( $options['form'] ) { echo "\n"; echo "\n"; } } /** * Print image * * Inputs: * - src Image source */ function print_image($title = "", $src) { echo "\n"; echo "\n"; echo "\n"; if (strlen($title)) { echo "

" . _($title) . "

\n"; } echo "\n"; echo ""; echo "\"\"\n"; echo "\n"; echo "\n"; } /** * Store result in session info * * Inputs: * - data Data which must be stored */ function result_store($data) { if (!empty($data)) { $result = ""; for ($i = 0; $i