2834 lines
92 KiB
PHP
2834 lines
92 KiB
PHP
<?php
|
|
/** \file include\form_elements.php
|
|
* \brief DI webinterface form elements
|
|
* \author Rob Schalken, Core|Vision
|
|
* \version 1.0
|
|
* \date 17-10-2008
|
|
*
|
|
* This file contains the form elements
|
|
*/
|
|
|
|
/**
|
|
* Merge default options, by key, into option array
|
|
* (private function)
|
|
*
|
|
* Inputs:
|
|
* - options Options (arguments for the calling function)
|
|
* by reference
|
|
* - defaults Default options
|
|
*
|
|
* Returns:
|
|
* - options Modified option array
|
|
*/
|
|
function print_merge_default_options(&$options, $defaults)
|
|
{
|
|
if( $defaults && is_array($defaults) ) foreach( $defaults as $key => $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 "<td class=\"action_button\" ";
|
|
if( $button['style'] ) echo " style=\"" . $button['style'] . "\"";
|
|
echo ">";
|
|
if( $button['href'] ) echo "<a href=\"" . $button['href'] . "\">";
|
|
echo "<div";
|
|
if( $button['action'] ) echo " class=\"action_button\"";
|
|
|
|
else echo " class=\"no_button\"";
|
|
if( $button['id'] ) echo " id=\"" . $button['id'] . "\"";
|
|
if( $button['action'] ) echo " onclick=\"" . $button['action'] . "\"";
|
|
if( $button['tip'] ) {
|
|
echo " onmouseover=\"Tip('" . htmlspecialchars(addslashes(strip_tags(_($button['tip'])))) . "',BGCOLOR,'" . $_PAGE_INFO['ini']['tooltip']['background'] . "',BORDERCOLOR, '" . $_PAGE_INFO['ini']['tooltip']['border'] . "');\"";
|
|
echo " onmouseout=\"UnTip();\"";
|
|
}
|
|
echo ">";
|
|
if( $button['icon'] ) echo "<img src=\"" . $button['icon'] . "\">";
|
|
else if( $button['text'] ) echo "<p>" . $button['text'] . "</p>";
|
|
echo "</div>";
|
|
if( $button['href'] ) echo "</a>";
|
|
if( $in_table ) echo "</td>";
|
|
}
|
|
|
|
|
|
/**
|
|
* 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 = "<br>\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 "<tr>\n";
|
|
echo "<td id=\"col0\"></td>\n";
|
|
echo "<td id=\"col1\">";
|
|
if( $_title ) echo "<p>" . $_title . "</p>\n";
|
|
echo "</td>\n";
|
|
echo "<td id=\"col2\">";
|
|
}
|
|
else {
|
|
// in a paragraph? print a line break
|
|
if( isset($_PAGE_INFO['p']) && $_PAGE_INFO['p']['line']++ > 0 ) echo "<br>\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 "<div";
|
|
if( $title['css_class'] ) echo " class=\"" . $title['css_class'] . "\"";
|
|
if( $title['style'] ) echo " style=\"display: inline-block;" . $title['style'] . "\"";
|
|
echo ">";
|
|
|
|
echo $_title . $sep;
|
|
|
|
echo "</div>";
|
|
}
|
|
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 "</td>\n";
|
|
echo "</tr>\n";
|
|
}
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
* Form
|
|
*/
|
|
function print_form_start($name, $action)
|
|
{
|
|
global $_PAGE_INFO;
|
|
|
|
echo "<form id=\"form\" name=\"" . $name . "\" action=\"" . $action . "\" method=\"POST\" enctype=\"multipart/form-data\">\n";
|
|
echo "<table class=\"form_table\" align=\"center\">\n";
|
|
|
|
$_PAGE_INFO['form']['active'] = array('name' => $name);
|
|
$_PAGE_INFO['form']['row'] = 0; // reference counter
|
|
}
|
|
|
|
function print_form_end()
|
|
{
|
|
global $_PAGE_INFO;
|
|
|
|
echo "</table>\n";
|
|
echo "</form>\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 "<tr>\n";
|
|
echo "<td></td>\n";
|
|
echo "<td></td>\n";
|
|
echo "<td>";
|
|
}
|
|
else {
|
|
echo "<center>\n";
|
|
}
|
|
if (strlen($header)) {
|
|
echo "<h1>" . _($header) . "</h1>";
|
|
}
|
|
echo "<table width=\"100%\">\n";
|
|
|
|
// Display matrix or row
|
|
if ((sizeof($menuitems) > 5) && ($matrix)) {
|
|
// 3x? matrix
|
|
for ($i = 0; $i < (sizeof($menuitems)/3); $i++) {
|
|
if ($form) {
|
|
echo "<tr>\n";
|
|
}
|
|
else {
|
|
echo "<tr align=\"center\">\n";
|
|
}
|
|
for ($j = 0; $j < 3; $j++) {
|
|
if (($i*3 + $j) < sizeof($menuitems)) {
|
|
echo "<td>\n";
|
|
echo "<div class=\"sub_menu_matrix\">\n";
|
|
// Extra info?
|
|
if (is_array($extra_info)) {
|
|
// Text?
|
|
if (strlen($extra_info[$i*3 + $j]['text'])) {
|
|
echo "<div class=\"sub_menu_matrix_info\">";
|
|
echo " ";
|
|
echo $extra_info[$i*3 + $j]['text'];
|
|
echo " ";
|
|
echo "</div>";
|
|
}
|
|
// Icon?
|
|
if (strlen($extra_info[$i*3 + $j]['icon'])) {
|
|
echo "<div class=\"sub_menu_matrix_icon\">";
|
|
echo "<!--[if lte IE 6]>";
|
|
echo "<span style=\"display:inline-block;filter:progid:DXImageTransform.Microsoft.AlphaImageLoader(src='" . IMAGE_DIR . $extra_info[$i*3 + $j]['icon'] . "');\">";
|
|
echo "<![endif]-->";
|
|
echo "<img id=\"menu_image\" src=\"" . IMAGE_DIR . $extra_info[$i*3 + $j]['icon'] . "\">\n";
|
|
echo "<!--[if lte IE 6]>";
|
|
echo "</span>";
|
|
echo "<![endif]-->";
|
|
echo "</div>";
|
|
}
|
|
}
|
|
// Rights?
|
|
if ($menurights[$i*3 + $j]) {
|
|
echo "<a href=\"" . htmlspecialchars($menulinks[$i*3 + $j]) . "\" oncontextmenu=\"javascript:ShowPopup(this);\"";
|
|
}
|
|
else {
|
|
if (strlen($menuitems[$i*3 + $j])) {
|
|
echo "<div class=\"nolink\"";
|
|
}
|
|
}
|
|
|
|
$adapted_menuitems = shorten_text(_($menuitems[$i*3 + $j]),$text_length);
|
|
|
|
// Tooltip? => When value was too long
|
|
if (($adapted_menuitems != _($menuitems[$i*3 + $j])) || (stristr($adapted_menuitems, "..") !== FALSE)) {
|
|
echo " onmouseover=\"Tip('" . htmlspecialchars(addslashes(_($menuitems[$i*3 + $j]))) . "',BGCOLOR,'" . $_PAGE_INFO['ini']['tooltip']['background'] . "',BORDERCOLOR, '" . $_PAGE_INFO['ini']['tooltip']['border'] . "');\" onmouseout=\"UnTip();\" ";
|
|
}
|
|
|
|
if (($menurights[$i*3 + $j]) || (strlen($menuitems[$i*3 + $j]))) {
|
|
echo ">\n";
|
|
}
|
|
|
|
echo htmlspecialchars($adapted_menuitems);
|
|
|
|
// Rights?
|
|
if ($menurights[$i*3 + $j]) {
|
|
echo "</a>\n";
|
|
}
|
|
else {
|
|
echo "</div>\n";
|
|
}
|
|
|
|
echo "</div>\n";
|
|
echo "</td>\n";
|
|
}
|
|
}
|
|
echo "</tr>\n";
|
|
}
|
|
}
|
|
else {
|
|
// Retrieve main items and check for the rights
|
|
for ($i = 0; $i < sizeof($menuitems); $i++) {
|
|
echo "<tr>\n";
|
|
if ($form) {
|
|
echo "<td>\n";
|
|
}
|
|
else {
|
|
echo "<td align=\"center\">\n";
|
|
}
|
|
echo "<div class=\"sub_menu\">\n";
|
|
// Extra info?
|
|
if (is_array($extra_info)) {
|
|
if (strlen($extra_info[$i]['text'])) {
|
|
echo "<div class=\"sub_menu_matrix_info\">";
|
|
echo " ";
|
|
echo $extra_info[$i]['text'];
|
|
echo " ";
|
|
echo "</div>";
|
|
}
|
|
if (strlen($extra_info[$i]['icon'])) {
|
|
echo "<div class=\"sub_menu_matrix_icon\">";
|
|
echo "<!--[if lte IE 6]>";
|
|
echo "<span style=\"display:inline-block;filter:progid:DXImageTransform.Microsoft.AlphaImageLoader(src='" . IMAGE_DIR . $extra_info[$i]['icon'] . "');\">";
|
|
echo "<![endif]-->";
|
|
echo "<img id=\"menu_image\" src=\"" . IMAGE_DIR . $extra_info[$i]['icon'] . "\">\n";
|
|
echo "<!--[if lte IE 6]>";
|
|
echo "</span>";
|
|
echo "<![endif]-->";
|
|
echo "</div>";
|
|
}
|
|
}
|
|
|
|
// Rights?
|
|
if ($menurights[$i]) {
|
|
echo "<a href=\"" . htmlspecialchars($menulinks[$i]) . "\" oncontextmenu=\"javascript:ShowPopup(this);\"";
|
|
}
|
|
else {
|
|
if (strlen($menuitems[$i])) {
|
|
echo "<div class=\"nolink\"";
|
|
}
|
|
}
|
|
|
|
$adapted_menuitems = shorten_text(_($menuitems[$i]),$text_length);
|
|
|
|
// Tooltip? => When value was too long
|
|
if (($adapted_menuitems != _($menuitems[$i])) || (stristr($adapted_menuitems, "..") !== FALSE)) {
|
|
echo " onmouseover=\"Tip('" . htmlspecialchars(addslashes(_($menuitems[$i]))) . "',BGCOLOR,'" . $_PAGE_INFO['ini']['tooltip']['background'] . "',BORDERCOLOR, '" . $_PAGE_INFO['ini']['tooltip']['border'] . "');\" onmouseout=\"UnTip();\" ";
|
|
}
|
|
|
|
if (($menurights[$i]) || (strlen($menuitems[$i]))) {
|
|
echo ">\n";
|
|
}
|
|
|
|
echo htmlspecialchars($adapted_menuitems);
|
|
|
|
// Rights?
|
|
if ($menurights[$i]) {
|
|
echo "</a>\n";
|
|
}
|
|
else {
|
|
echo "</div>\n";
|
|
}
|
|
|
|
echo "</div>\n";
|
|
echo "</td>\n";
|
|
echo "</tr>\n";
|
|
}
|
|
}
|
|
echo "</table>\n";
|
|
if ($form) {
|
|
echo "</td>\n";
|
|
echo "</td>\n";
|
|
echo "</tr>\n";
|
|
}
|
|
else {
|
|
echo "</center>";
|
|
}
|
|
}
|
|
|
|
|
|
/**
|
|
* 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 "<tr>\n";
|
|
echo "<td id=\"col0\"></td>\n";
|
|
echo "<td id=\"col1\"></td>\n";
|
|
echo "<td id=\"col2\">\n";
|
|
}
|
|
if( $options['url'] ) echo "<a href=\"" . $options['url'] . "\">";
|
|
if( $need_div ) {
|
|
echo "<div class=\"" . ($options['class'] ? $options['class'] : "button_div") . "\"";
|
|
if( $options['id'] ) echo " id=\"" . $options['id'] . "\"";
|
|
if( $options['style'] ) echo " style=\"" . $options['style'] . "\"";
|
|
if( $options['action'] ) echo " onclick=\"" . $options['action'] . "\" style=\"cursor:pointer;\"";
|
|
echo ">";
|
|
}
|
|
if( $options['buttons'] ) {
|
|
echo "<table><tr><td class=\"text\">";
|
|
}
|
|
if ($options['center']) {
|
|
echo "<center>";
|
|
}
|
|
if (strlen($title)) {
|
|
echo "<h1>" . htmlspecialchars(strip_tags(_($title))) . "</h1>\n";
|
|
}
|
|
if ($options['center']) {
|
|
echo "</center>";
|
|
}
|
|
if( $options['buttons'] ) {
|
|
echo "</td>";
|
|
foreach( $options['buttons'] as $button ) print_inline_button($button, TRUE);
|
|
echo "</tr></table>";
|
|
}
|
|
if( $need_div ) {
|
|
echo "</div>";
|
|
}
|
|
if( $options['url'] ) echo "</a>";
|
|
if( $options['form'] ) {
|
|
echo "</td>\n";
|
|
echo "</tr>\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 "<tr>\n";
|
|
echo "<td id=\"col0\"></td>\n";
|
|
echo "<td id=\"col1\"></td>\n";
|
|
echo "<td id=\"col2\">\n";
|
|
}
|
|
if( $options['url'] ) echo "<a href=\"" . $options['url'] . "\">";
|
|
if( $need_div ) {
|
|
echo "<div class=\"" . ($options['class'] ? $options['class'] : "button_div") . "\"";
|
|
if( $options['id'] ) echo " id=\"" . $options['id'] . "\"";
|
|
if( $options['style'] ) echo " style=\"" . $options['style'] . "\"";
|
|
if( $options['action'] ) echo " onclick=\"" . $options['action'] . "\" style=\"cursor:pointer;\"";
|
|
echo ">";
|
|
}
|
|
if( $options['buttons'] ) {
|
|
echo "<table><tr><td class=\"text\">";
|
|
}
|
|
if ($options['center']) {
|
|
echo "<center>";
|
|
}
|
|
if (strlen($subtitle)) {
|
|
echo "<h2>" . _($subtitle) . "</h2>\n";
|
|
}
|
|
if ($options['center']) {
|
|
echo "</center>";
|
|
}
|
|
if( $options['buttons'] ) {
|
|
echo "</td>";
|
|
foreach( $options['buttons'] as $button ) print_inline_button($button, TRUE);
|
|
echo "</tr></table>";
|
|
}
|
|
if( $need_div ) {
|
|
echo "</div>";
|
|
}
|
|
if( $options['url'] ) echo "</a>";
|
|
if( $options['form'] ) {
|
|
echo "</td>\n";
|
|
echo "</tr>\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 "<tr>\n";
|
|
echo "<td id=\"col0\"></td>\n";
|
|
echo "<td id=\"col1\"></td>\n";
|
|
echo "<td id=\"col2\">\n";
|
|
}
|
|
if( $options['url'] ) echo "<a href=\"" . $options['url'] . "\">";
|
|
if( $need_div ) {
|
|
echo "<div class=\"" . ($options['class'] ? $options['class'] : "button_div") . "\"";
|
|
if( $options['id'] ) echo " id=\"" . $options['id'] . "\"";
|
|
if( $options['style'] ) echo " style=\"" . $options['style'] . "\"";
|
|
if( $options['action'] ) echo " onclick=\"" . $options['action'] . "\" style=\"cursor:pointer;\"";
|
|
echo ">";
|
|
}
|
|
if( $options['buttons'] ) {
|
|
echo "<table><tr><td class=\"text\">";
|
|
}
|
|
if ($options['center']) {
|
|
echo "<center>";
|
|
}
|
|
if (strlen($subtitle)) {
|
|
echo "<h3>" . htmlspecialchars(strip_tags(_($subtitle))) . "</h3>\n";
|
|
}
|
|
if (strlen($options['center'])) {
|
|
echo "</center>";
|
|
}
|
|
if( $options['buttons'] ) {
|
|
echo "</td>";
|
|
foreach( $options['buttons'] as $button ) print_inline_button($button, TRUE);
|
|
echo "</tr></table>";
|
|
}
|
|
if( $need_div ) {
|
|
echo "</div>";
|
|
}
|
|
if( $options['url'] ) echo "</a>";
|
|
if( $options['form'] ) {
|
|
echo "</td>\n";
|
|
echo "</tr>\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 "<tr>\n";
|
|
echo "<td id=\"col0\"></td>\n";
|
|
echo "<td id=\"col1\"></td>\n";
|
|
echo "<td id=\"col2\">\n";
|
|
}
|
|
if( $options['url'] ) echo "<a href=\"" . $options['url'] . "\">";
|
|
if( $need_div ) {
|
|
echo "<div class=\"" . ($options['class'] ? $options['class'] : "button_div") . "\"";
|
|
if( $options['id'] ) echo " id=\"" . $options['id'] . "\"";
|
|
if( $options['style'] ) echo " style=\"" . $options['style'] . "\"";
|
|
if( $options['action'] ) echo " onclick=\"" . $options['action'] . "\" style=\"cursor:pointer;\"";
|
|
echo ">";
|
|
}
|
|
if( $options['buttons'] ) {
|
|
echo "<table><tr><td class=\"text\">";
|
|
}
|
|
|
|
echo "<p";
|
|
if( $options['css_class'] ) echo " class=\"" . $options['css_class'] . "\"";
|
|
echo ">";
|
|
if( strlen($text) ) echo _($text);
|
|
echo "</p>\n";
|
|
|
|
if( $options['buttons'] ) {
|
|
echo "</td>";
|
|
foreach( $options['buttons'] as $button ) print_inline_button($button, TRUE);
|
|
echo "</tr></table>";
|
|
}
|
|
if( $need_div ) {
|
|
echo "</div>";
|
|
}
|
|
if( $options['url'] ) echo "</a>";
|
|
if( $options['form'] ) {
|
|
echo "</td>\n";
|
|
echo "</tr>\n";
|
|
}
|
|
}
|
|
|
|
|
|
/**
|
|
* Print Filter & search button
|
|
*/
|
|
function print_filter_search($title, $name, $value, $onkeyup = "")
|
|
{
|
|
echo "<tr>\n";
|
|
echo "<td></td>\n";
|
|
echo "<td><p>" . _($title) . "</p></td>\n";
|
|
echo "<td>";
|
|
if (strlen($onkeyup)) {
|
|
echo "<script type=\"text/javascript\">\n";
|
|
echo "var func_filter = function onkeyup () {\n";
|
|
echo $onkeyup;
|
|
echo "}\n";
|
|
echo "</script>\n";
|
|
echo "<input type=\"text\" autofocus id=\"filter_element\" name=\"" . $name . "\" value=\"" . htmlspecialchars($value) . "\" autocomplete=\"off\" onkeypress=\"return noenter(event,this)\" onkeyup=\"new_value('" . $name . "',func_filter);\" onfocus=\"current_value('" . $name . "');\">\n";
|
|
}
|
|
else {
|
|
echo "<input type=\"text\" autofocus name=\"" . $name . "\" value=\"" . htmlspecialchars($value) . "\" autocomplete=\"off\" onkeypress=\"return noenter(event,this)\">\n";
|
|
echo "<input type=\"button\" id=\"searchbutton\" class=\"button\" value=\"" . _("Search") . "\" onClick=\"onSubmit('but_search', '', 1);\">\n";
|
|
}
|
|
echo "<input type=\"button\" id=\"resetbutton\" class=\"button\" value=\"" . _("Reset") . "\" onClick=\"onSubmit('but_reset', '', 1);\">\n";
|
|
echo "</td>\n";
|
|
echo "</tr>\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 "<tr>\n";
|
|
echo "<td id=\"col0\"></td>\n";
|
|
echo "<td id=\"col1\">";
|
|
|
|
if (strlen($onkeyup)) {
|
|
echo "<script type=\"text/javascript\">\n";
|
|
echo "var func_" . $name ." = function onkeyup () {\n";
|
|
echo $onkeyup;
|
|
echo "}\n";
|
|
echo "</script>\n";
|
|
}
|
|
|
|
if (!isset($_SESSION[$_PAGE_INFO['id']]['extended_menu'])) {
|
|
echo "<p>" . _($title) . "</p>\n";
|
|
}
|
|
echo "</td>\n";
|
|
echo "<td id=\"col2\">";
|
|
// Alignment
|
|
if (strlen($center)) {
|
|
echo "<center>";
|
|
}
|
|
echo "<input type=\"text\" id=\"text_element\" name=\"";
|
|
if (is_ro($ro_actions)) {
|
|
echo "\" disabled ";
|
|
}
|
|
else {
|
|
echo $name . "\" ";
|
|
}
|
|
echo " value=\"" . htmlspecialchars(strip_tags($value)) . "\" onkeypress=\"return noenter(event,this)\"";
|
|
if (strlen($onkeyup)) {
|
|
echo " onkeyup=\"new_value('" . $name . "',func_" . $name . ");\" onfocus=\"current_value('" . $name . "');\"\n";
|
|
}
|
|
echo ">\n";
|
|
// Alignment
|
|
if (strlen($center)) {
|
|
echo "</center>";
|
|
}
|
|
|
|
// Display message?
|
|
if (strlen($info)) {
|
|
echo "<input id=\"input_info\" type=\"text\" name=\"" . $name . "_info\" value=\"" . _($info) . "\" readonly tabindex=\"-1\"";
|
|
if ($bold) {
|
|
echo " style=\"font-weight:bold;" . $extra_info_style . "\"";
|
|
}
|
|
else if ((!$bold) && (strlen($extra_info_style))) {
|
|
echo " style=\"" . $extra_info_style . "\"";
|
|
}
|
|
echo ">\n";
|
|
}
|
|
echo "</td>\n";
|
|
echo "</tr>\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 "<input id=\"input_info\" type=\"text\" name=\"" . $name . "_info\" value=\"" . _($info) . "\" readonly tabindex=\"-1\"";
|
|
if ($bold) {
|
|
echo " style=\"font-weight:bold\"";
|
|
}
|
|
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 "<tr>\n";
|
|
echo "<td id=\"col0\"></td>\n";
|
|
echo "<td id=\"col1\">";
|
|
if (!isset($_SESSION[$_PAGE_INFO['id']]['extended_menu'])) {
|
|
echo "<p>" . _($title) . "</p>\n";
|
|
}
|
|
echo "</td>\n";
|
|
echo "<td id=\"col2\">";
|
|
echo "<textarea rows=\"" . $height . "\" name=\"";
|
|
if (is_ro($ro_actions)) {
|
|
echo "\" disabled>";
|
|
}
|
|
else {
|
|
echo $name . "\">";
|
|
}
|
|
|
|
echo ($strip_tags) ? strip_tags($value) : htmlspecialchars($value);
|
|
echo "</textarea>\n";
|
|
// Display message?
|
|
if (strlen($info)) {
|
|
echo "<input id=\"input_info\" type=\"text\" name=\"" . $name . "_info\" value=\"" . _($info) . "\" readonly tabindex=\"-1\"";
|
|
if ($bold) {
|
|
echo " style=\"font-weight:bold;vertical-align:top\"";
|
|
}
|
|
echo ">\n";
|
|
}
|
|
// action?
|
|
if( $action && is_array($action)) {
|
|
echo "<div class=\"tiny_button\">";
|
|
echo "<input type=\"button\" class=\"tiny_button\" value=\"" . _($action['button_text']) . "\" onclick=\"" . $action['action'] . "\">\n";
|
|
echo "</div>";
|
|
}
|
|
echo "</td>\n";
|
|
echo "</tr>\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 "<tr>\n";
|
|
echo "<td></td>\n";
|
|
echo "<td><p>" . _($title) . "</p></td>\n";
|
|
echo "<td>\n";
|
|
|
|
// Create header
|
|
if (strlen($value[0][0])) {
|
|
$table = ($table_large) ? "table_input_large" : "table_input";
|
|
echo "<input id=\"" . $table . "\" type=\"text\" disabled tabindex=\"-1\"";
|
|
if ($truetype) {
|
|
echo " style=\"font-family:courier new;font-size:8pt;\" ";
|
|
}
|
|
echo " value=\"";
|
|
for ($i = 0; $i < sizeof($value[0]); $i++) {
|
|
// optgroup offset?
|
|
if (!$i) {
|
|
if (is_array($opt)) {
|
|
// Determine IE or not!
|
|
$max = (browser() == "IE") ? 6 : 3;
|
|
for ($j = 0; $j < $max; $j++) {
|
|
echo " ";
|
|
}
|
|
}
|
|
}
|
|
|
|
// Alignment
|
|
$align_size = 0;
|
|
if (is_array($align)) {
|
|
if ($align[$i] == "C") {
|
|
// Determine empty space (width - string length - 1)
|
|
$empty = ($width[$i] - strlen(_($value[0][$i])) - 1);
|
|
|
|
if ($empty) {
|
|
$align_size = round($empty/2);
|
|
for ($j = 0; $j < $align_size; $j++) {
|
|
echo " ";
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
// Text
|
|
$val = _($value[0][$i]);
|
|
if (strlen($val) >= $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 "\"><br>";
|
|
}
|
|
if (!strlen($size)) {
|
|
$size = ((sizeof($value) > 2) || (is_ro($ro_actions))) ? (sizeof($value)-1) : 2;
|
|
}
|
|
$table = ($table_large) ? "table_select_large" : "table_select";
|
|
echo "<select id=\"" . $table . "\" name=\"" . $name . "\" size=\"" . $size . "\" ";
|
|
if ($truetype) {
|
|
echo "style=\"font-family:courier new;font-size:8pt;\" ";
|
|
}
|
|
if (is_ro($ro_actions)) {
|
|
echo "disabled ";
|
|
}
|
|
if (strlen($on_change)) {
|
|
// Catch empty table
|
|
if (sizeof($value) > 1) {
|
|
echo "onClick=\"" . $on_change . "\" ";
|
|
}
|
|
}
|
|
echo ">\n";
|
|
for ($k = 1; $k < sizeof($value); $k++) {
|
|
if (!$opt[$k]) {
|
|
echo "<option value=\"" . $id[$k] . "\" ";
|
|
if (strlen($value[$k]['color'])) {
|
|
echo "id=\"" . $value[$k]['color'] . "\" ";
|
|
}
|
|
else {
|
|
echo "id=\"" . $table . "\" ";
|
|
}
|
|
|
|
echo "style=\"";
|
|
if ((strlen($value[$k]['bold'])) && ($value[$k]['bold'])) {
|
|
echo "font-weight:bold;";
|
|
}
|
|
if ($truetype) {
|
|
echo "font-family:courier new;font-size:8pt;";
|
|
}
|
|
echo "\"";
|
|
if ($sel_val && $id) {
|
|
if ($sel_val == $id[$k]) {
|
|
echo " selected=\"selected\" ";
|
|
}
|
|
}
|
|
echo ">";
|
|
for($i = 0; $i < sizeof($value[0]); $i++) {
|
|
// Alignment
|
|
$align_size = 0;
|
|
if (is_array($align)) {
|
|
if ($align[$i] == "C") {
|
|
// Determine empty space (width - string length - 1)
|
|
$empty = ($width[$i] - strlen(_($value[$k][$i])) - 2);
|
|
|
|
if ($empty) {
|
|
$align_size = round($empty/2);
|
|
for ($j = 0; $j < $align_size; $j++) {
|
|
echo " ";
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
// Text
|
|
$val = htmlspecialchars(strip_tags(_($value[$k][$i])));
|
|
if (strlen($val) >= $width[$i]) {
|
|
$val = substr($val, 0, $width[$i]-3+$offset) . ".. ";
|
|
}
|
|
// determine length => for fill
|
|
$val_len = strlen($val);
|
|
|
|
// Replace html entities
|
|
echo $val;
|
|
|
|
// Fill rest
|
|
$fill = ($width[$i] - $val_len - $align_size);
|
|
|
|
if ($fill) {
|
|
for ($j = 0; $j < $fill; $j++) {
|
|
echo " ";
|
|
}
|
|
}
|
|
}
|
|
}
|
|
else {
|
|
echo "<optgroup label=\"" . $value[$k][0] . "\">\n";
|
|
}
|
|
}
|
|
echo "</select>\n";
|
|
|
|
if (!$skip_table_end) {
|
|
echo "</td>\n";
|
|
echo "</tr>\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 "<tr>\n";
|
|
echo "<td id=\"col0\"></td>\n";
|
|
echo "<td id=\"col1\"><p>" . _($title) . "</p></td>\n";
|
|
echo "<td id=\"col2\">";
|
|
if (browser() != "IE") {
|
|
if (!$hidden_input) {
|
|
echo "<input style=\"position:absolute; visibility:hidden;\" id=\"" . $name . "_file_element\" name=\"" . $name . $multiple_name . "\" " . $multiple_addon . " type=\"file\" value=\"\" onChange=\"getElement('" . $name . "_filename').value=this.value; " . $onchange . "\" onsubmit='return false'>";
|
|
echo "<input id=\"" . $name . "_filename\" name=\"" . $name . "_file_element_text_overrule\" type=\"text\">";
|
|
echo "<input id=\"filebutton\" type=\"button\" name=\"" . $name . "_file_element_overrule\" value=\"" . _($browse_caption) . "\" class=\"button\" onClick=\"getElement('" . $name . "_file_element').click();\">";
|
|
if ($upload) {
|
|
echo "<input id=\"filebutton\" type=\"submit\" class=\"button\" value=\"" . _($upload_caption) . "\" onClick=\"" . $onuploadsumbit . "\">\n";
|
|
}
|
|
}
|
|
else {
|
|
echo "<input id=\"footer_button\" type=\"button\" name=\"" . $name . "_file_element_overrule\" value=\"" . _($upload_caption) . "...\" onClick=\"getElement('" . $name . "_file_element').click();\">";
|
|
echo "<input style=\"position:absolute;visibility:hidden;height:0px;\" id=\"" . $name . "_file_element\" name=\"" . $name . $multiple_name . "\" " . $multiple_addon . " type=\"file\" value=\"\" onChange=\"getElement('" . $name . "_filename').value=this.value; " . $onchange . "\" onsubmit='return false'>";
|
|
echo "<input style=\"position:absolute;visibility:hidden;height:0px;\" id=\"" . $name . "_filename\" name=\"" . $name . "_file_element_text_overrule\" type=\"text\">";
|
|
}
|
|
}
|
|
else {
|
|
echo "<input type=\"file\" id=\"file_element\" name=\"" . $name . $multiple_name . "\" " . $multiple_addon . " value=\"test\"";
|
|
if (strlen($onchange)) {
|
|
echo " onChange=\"" . $onchange . "\"";
|
|
}
|
|
echo ">";
|
|
if ($upload) {
|
|
echo "<input type=\"button\" class=\"\" value=\"" . _($upload_caption) . "\" onClick=\"" . $onuploadsumbit . "\">\n";
|
|
}
|
|
}
|
|
|
|
// Display message?
|
|
if (strlen($info)) {
|
|
// add extra white space
|
|
echo " ";
|
|
echo "<input id=\"input_info_file\" type=\"text\" name=\"" . $name . "_info\" value=\"" . _($info) . "\" readonly tabindex=\"-1\"";
|
|
if ($bold) {
|
|
echo " style=\"font-weight:bold\"";
|
|
}
|
|
echo ">\n";
|
|
}
|
|
echo "</td>\n";
|
|
echo "</tr>\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 "<div class=\"";
|
|
if( $link ) echo "file_open_button";
|
|
else echo "inactive_button";
|
|
echo "\" id=\"" . $name . "\"";
|
|
if( $bold ) echo " style=\"font-weight:bold;\"";
|
|
echo ">";
|
|
echo "<table>";
|
|
echo "<tr>";
|
|
|
|
echo "<td class=\"button_text\">";
|
|
if( $link ) {
|
|
echo "<a id=\"" . $name . "\" href=\"" . $link . "\"";
|
|
if( $options['new_window'] ) echo " target=\"_blank\"";
|
|
echo ">";
|
|
}
|
|
echo "<div";
|
|
if( strlen($value) > 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 "</div>";
|
|
if( $link ) echo "</a>";
|
|
echo "</td>";
|
|
|
|
if( is_array($options['buttons']) )
|
|
foreach( $options['buttons'] as $button )
|
|
print_inline_button($button, TRUE);
|
|
|
|
echo "</tr>";
|
|
echo "</table>";
|
|
echo "</div>";
|
|
|
|
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 "<tr>\n";
|
|
echo "<td id=\"col0\"></td>\n";
|
|
echo "<td id=\"col1\">";
|
|
if (!isset($_SESSION[$_PAGE_INFO['id']]['extended_menu'])) {
|
|
echo "<p>" . _($title) . "</p>\n";
|
|
}
|
|
echo "</td>\n";
|
|
echo "<td id=\"col2\">";
|
|
echo "<div class=\"date\">";
|
|
echo "<input type=\"text\" id=\"date_element\" value=\"" . $value . "\" readonly onkeypress=\"return noenter(event,this)\" name=\"";
|
|
if (is_ro($ro_actions)) {
|
|
echo "\" disabled>";
|
|
}
|
|
else {
|
|
echo $name . "\">";
|
|
}
|
|
echo "<img src=\"" . IMAGE_DIR . "calender.gif\" ";
|
|
|
|
if (!is_ro($ro_actions)) {
|
|
echo "onclick=\"JACS.show(getElement('" . $name . "'),event, '" . $name . "_id');JACS.next('" . $name . "_id',onSubmit,'other', '', 1);\"";
|
|
}
|
|
echo ">\n";
|
|
|
|
// Display message?
|
|
if (strlen($info)) {
|
|
echo "<input id=\"input_info\" type=\"text\" name=\"" . $name . "_info\" value=\"" . _($info) . "\" readonly tabindex=\"-1\"";
|
|
if ($bold) {
|
|
echo " style=\"font-weight:bold\"";
|
|
}
|
|
echo ">\n";
|
|
}
|
|
echo "</div>";
|
|
echo "</td>\n";
|
|
echo "</tr>\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 "<tr>\n";
|
|
echo "<td id=\"col0\"></td>\n";
|
|
echo "<td id=\"col1\">";
|
|
if (isset($_SESSION[$_PAGE_INFO['id']]['extended_menu'])) {
|
|
echo "<p>" . _($title) . "</p>\n";
|
|
}
|
|
echo "</td>\n";
|
|
echo "<td id=\"col2\">";
|
|
|
|
// Time control
|
|
echo "<select name=\"" . $time_name . "\"";
|
|
if (is_ro($ro_actions)) {
|
|
echo "disabled";
|
|
}
|
|
echo " onChange=\"onSubmit('other', '', 1);\" ";
|
|
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 "<option value=\"" . $value . "\"";
|
|
if ($time_value == $value) {
|
|
echo " selected=\"selected\" ";
|
|
}
|
|
echo ">" . $value;
|
|
}
|
|
}
|
|
echo "</select>\n";
|
|
|
|
// Display message?
|
|
if (strlen($info)) {
|
|
echo "<input id=\"input_info\" type=\"text\" name=\"" . $date_name . "_info\" value=\"" . _($info) . "\" readonly tabindex=\"-1\"";
|
|
if ($bold) {
|
|
echo " style=\"font-weight:bold\"";
|
|
}
|
|
echo ">\n";
|
|
}
|
|
echo "</td>\n";
|
|
echo "</tr>\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 "<tr>\n";
|
|
echo "<td id=\"col0\"></td>\n";
|
|
echo "<td id=\"col1\">";
|
|
if (!isset($_SESSION[$_PAGE_INFO['id']]['extended_menu'])) {
|
|
echo "<p>" . _($title) . "</p>\n";
|
|
}
|
|
echo "</td>\n";
|
|
echo "<td id=\"col2\">";
|
|
echo "<div class=\"datetime\">";
|
|
echo "<input type=\"text\" id=\"datetime_element\" value=\"" . $date_value . "\" readonly onkeypress=\"return noenter(event,this)\" name=\"";
|
|
if (is_ro($ro_actions)) {
|
|
echo "\" disabled>";
|
|
}
|
|
else {
|
|
echo $date_name . "\">";
|
|
}
|
|
|
|
echo "<img src=\"" . IMAGE_DIR . "calender.gif\" ";
|
|
|
|
if (!is_ro($ro_actions)) {
|
|
echo "onclick=\"JACS.show(getElement('" . $date_name . "'),event, '" . $date_name . "_id');JACS.next('" . $date_name . "_id',onSubmit,'other', '', 1);\"";
|
|
}
|
|
echo ">\n";
|
|
|
|
// Time control
|
|
echo "<!--[if lte IE 6]>";
|
|
echo "<span class=\"select_element\"";
|
|
if (($_SESSION[$_PAGE_INFO['id']]['sts']['finished'] != 10) && (isset($_SESSION[$_PAGE_INFO['id']]['sts']['finished']))) {
|
|
echo " style=\"visibility:hidden\"";
|
|
}
|
|
echo ">\n";
|
|
echo "<![endif]-->";
|
|
|
|
if (strlen($date_value)) {
|
|
if (is_ro($ro_actions)) {
|
|
echo "<select id=\"time\" disabled>";
|
|
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 "<option value=\"" . $value . "\"";
|
|
if ($time_value == $value) {
|
|
echo " selected=\"selected\" ";
|
|
}
|
|
echo ">" . $value;
|
|
}
|
|
}
|
|
print_hidden_input($time_name, $time_value);
|
|
}
|
|
else {
|
|
echo "<select id=\"time\" name=\"" . $time_name . "\" onChange=\"onSubmit('other', '', 1);\">\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 "<option value=\"" . $value . "\"";
|
|
if ($time_value == $value) {
|
|
echo " selected=\"selected\" ";
|
|
}
|
|
echo ">" . $value;
|
|
}
|
|
}
|
|
}
|
|
}
|
|
else {
|
|
echo "<select disabled>\n";
|
|
print_hidden_input($time_name, $time_value);
|
|
}
|
|
echo "</select>\n";
|
|
echo "<!--[if lte IE 6]>";
|
|
echo "</span>";
|
|
echo "<![endif]-->";
|
|
|
|
// Display message?
|
|
if (strlen($info)) {
|
|
echo "<input id=\"input_info\" type=\"text\" name=\"" . $date_name . "_info\" value=\"" . _($info) . "\" readonly tabindex=\"-1\"";
|
|
if ($bold) {
|
|
echo "style=\"font-weight:bold;" . $extra_info_style . "\"";
|
|
}
|
|
else if ((!$bold) && (strlen($extra_info_style))) {
|
|
echo "style=\"" . $extra_info_style . "\"";
|
|
}
|
|
echo ">\n";
|
|
}
|
|
echo "</div>";
|
|
echo "</td>\n";
|
|
echo "</tr>\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 "<tr>\n"; echo "<td></td>\n";
|
|
echo "<td><p>" . _($title) . "</p></td>\n";
|
|
echo "<td>";
|
|
echo "<div class=\"daytime\">";
|
|
|
|
// day control
|
|
$days = array("", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday", "Sunday");
|
|
echo "<select id=\"day\" value=\"". $day_value . "\" onChange=\"onSubmit('other', '', 1);\" name=\"";
|
|
if (is_ro($ro_actions)) {
|
|
echo "\" disabled>";
|
|
}
|
|
else {
|
|
echo $day_name . "\">";
|
|
}
|
|
if (is_array($days)) {
|
|
for ($i = 0; $i< sizeof($days); $i++) {
|
|
echo "<option value=\"" . $i . "\"";
|
|
if ($day_value == $i) {
|
|
echo " selected=\"selected\" ";
|
|
}
|
|
echo ">" . _($days[$i]);
|
|
}
|
|
}
|
|
echo "</select>\n";
|
|
|
|
// Time control
|
|
if ($day_value) {
|
|
if (is_ro($ro_actions)) {
|
|
echo "<select id=\"time\" disabled>";
|
|
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 "<option value=\"" . $value . "\"";
|
|
if ($time_value == $value) {
|
|
echo " selected=\"selected\" ";
|
|
}
|
|
echo ">" . $value;
|
|
}
|
|
}
|
|
print_hidden_input($time_name, $time_value);
|
|
}
|
|
else {
|
|
echo "<select id=\"time\" name=\"" . $time_name . "\"";
|
|
if (!strlen($day_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 "<option value=\"" . $value . "\"";
|
|
if ($time_value == $value) {
|
|
echo " selected=\"selected\" ";
|
|
}
|
|
echo ">" . $value;
|
|
}
|
|
}
|
|
}
|
|
}
|
|
else {
|
|
print_hidden_input($time_name, $time_value);
|
|
echo "<select id=\"time\" disabled>\n";
|
|
}
|
|
echo "</select>\n";
|
|
|
|
// Display message?
|
|
if (strlen($info)) {
|
|
echo "<input id=\"input_info\" type=\"text\" name=\"" . $day_name . "_info\" value=\"" . _($info) . "\" readonly tabindex=\"-1\"";
|
|
if ($bold) {
|
|
echo " style=\"font-weight:bold\"";
|
|
}
|
|
echo ">\n";
|
|
}
|
|
|
|
if (!$skip_table_end) {
|
|
echo "</div>";
|
|
echo "</td>\n";
|
|
echo "</tr>\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 "<tr>\n";
|
|
echo "<td id=\"col0\"></td>\n";
|
|
echo "<td id=\"col1\"><p>" . _($title) . "</p></td>\n";
|
|
echo "<td id=\"col2\">";
|
|
// Alignment
|
|
if (strlen($center)) {
|
|
echo "<center>";
|
|
}
|
|
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 "<input type=\"password\" id=\"password_element\" name=\"" . $name . "\" value=\"" . $value . "\"";
|
|
echo " onkeypress=\"return noenter(event,this)\"";
|
|
echo " onchange=\"document.form." . $name . "_changed.value = 1; return true;\"";
|
|
echo " onfocus=\"if( !document.form." . $name . "_changed.value && document.form." . $name . ".value=='" . addcslashes(PASSWD_DISPLAY_TEXT, "\"\'\n\r\f\t") . "' ) document.form." . $name . ".value = ''; return true;\"";
|
|
echo " onblur=\"if( !document.form." . $name . "_changed.value && document.form." . $name . ".value=='' ) document.form." . $name . ".value = '" . addcslashes(PASSWD_DISPLAY_TEXT, "\"\'\n\r\f\t") . "'; return true;\"";
|
|
echo ">";
|
|
echo "<input type=\"hidden\" name=\"" . $name . "_changed\" value=\"" . $_POST[$name . "_changed"] . "\">\n";
|
|
// Alignment
|
|
if (strlen($center)) {
|
|
echo "</center>";
|
|
}
|
|
|
|
if (strlen($info)) {
|
|
echo "<input id=\"input_info\" type=\"text\" name=\"" . $name . "_info\" value=\"" . _($info) . "\" readonly tabindex=\"-1\" onkeypress=\"return noenter(event,this)\"";
|
|
if ($bold) {
|
|
echo " style=\"font-weight:bold;" . $extra_info_style . "\"";
|
|
}
|
|
else if ((!$bold) && (strlen($extra_info_style))) {
|
|
echo " style=\"" . $extra_info_style . "\"";
|
|
}
|
|
echo ">\n";
|
|
}
|
|
echo "</td>\n";
|
|
echo "</tr>\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 "<a href=\"" . $options['url'] . "\">";
|
|
if( $need_div ) {
|
|
echo "<div class=\"" . ($options['class'] ? $options['class'] : "button_div") . "\"";
|
|
if( $options['id'] ) echo " id=\"" . $options['id'] . "\"";
|
|
if( $options['style'] ) echo " style=\"" . $options['style'] . "\"";
|
|
if( $options['action'] ) echo " onclick=\"" . $options['action'] . "\" style=\"cursor:pointer;\"";
|
|
echo ">";
|
|
}
|
|
if ($options['center']) {
|
|
echo "<center>";
|
|
}
|
|
if( $options['buttons'] ) {
|
|
echo "<table ";
|
|
if( $options['table_style'] ) echo " style=\"" . $options['table_style'] . "\"";
|
|
echo "><tr><td class=\"text\">";
|
|
}
|
|
|
|
echo "<label ";
|
|
echo "onmouseover=\"Tip('" . $options['label'] . "',BGCOLOR,'" . $_PAGE_INFO['ini']['tooltip']['background'] . "',BORDERCOLOR, '" . $_PAGE_INFO['ini']['tooltip']['border'] . "');\" onmouseout=\"UnTip();\" ";
|
|
echo ">";
|
|
echo "<input type=\"checkbox\" class=\"checkbox_element\" name=\"" . $name . "\" value=\"" . $value_checked . "\" ";
|
|
if (is_ro($ro_actions)) {
|
|
echo "disabled ";
|
|
}
|
|
foreach( $options as $event => $action )
|
|
if( strtolower(substr($event, 0, 2)) == "on" )
|
|
echo " " . $event . "=\"" . $action . "\"";
|
|
if ($value == $value_checked) {
|
|
echo " checked";
|
|
}
|
|
echo " onkeypress=\"return noenter(event,this)\"";
|
|
echo ">\n";
|
|
if( $options['label'] ) {
|
|
echo $options['label'];
|
|
}
|
|
else if( !$on_form ) {
|
|
echo _($title); // NB: translation
|
|
}
|
|
|
|
if( $options['buttons'] ) {
|
|
echo "</td>";
|
|
foreach( $options['buttons'] as $button ) print_inline_button($button, TRUE);
|
|
echo "</tr></table>";
|
|
}
|
|
if( $need_div ) {
|
|
echo "</div>";
|
|
}
|
|
if( $options['url'] ) echo "</a>";
|
|
if( $options['form'] ) {
|
|
echo "</td>\n";
|
|
echo "</tr>\n";
|
|
}
|
|
|
|
echo "</label>\n";
|
|
|
|
if( $options['center'] ) echo "</center>";
|
|
|
|
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 "<tr>\n";
|
|
echo "<td id=\"col0\"></td>\n";
|
|
echo "<td id=\"col1\">";
|
|
if (!isset($_SESSION[$_PAGE_INFO['id']]['extended_menu'])) {
|
|
$title = (!strlen($title)) ? " " : $title;
|
|
echo "<p>" . _($title) . "</p>\n";
|
|
}
|
|
echo "</td>\n";
|
|
echo "<td id=\"col2\"><input type=\"radio\" class=\"radio_element\" name=\"" . $name . "\" value=\"" . $value_checked . "\"";
|
|
if (is_ro($ro_actions)) {
|
|
echo " disabled";
|
|
}
|
|
|
|
if (strlen($on_change)) {
|
|
echo " onClick=\"" . $on_change . "\" ";
|
|
}
|
|
|
|
if ($value == $value_checked) {
|
|
echo " checked";
|
|
}
|
|
echo " onkeypress=\"return noenter(event,this)\">\n";
|
|
if (strlen($label)) {
|
|
echo "<label for=\"" . $name . "\" >" . _($label) . "</label>\n";
|
|
}
|
|
|
|
if ($skip_table_end) {
|
|
echo "</td>\n";
|
|
echo "</tr>\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 "<input type=\"hidden\" name=\"" . $name . "\" value=\"" . htmlspecialchars(strip_tags($value)) . "\">";
|
|
}
|
|
|
|
|
|
/**
|
|
* 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 "<tr>\n";
|
|
echo "<td></td>\n";
|
|
echo "<td><p>" . _($title) . "</p></td>\n";
|
|
echo "<td>";
|
|
echo "<table class=\"checkbox_table\" width=\"100%\">\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 "<tr><td colspan=\"3\">";
|
|
echo "<h2";
|
|
if ($menu_item == "root") {
|
|
echo " style=\"color:#002F4C\"";
|
|
}
|
|
echo ">";
|
|
echo _("right:" . $menu_item);
|
|
echo "</h2>";
|
|
|
|
//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 "</tr>\n";
|
|
echo "<tr>";
|
|
}
|
|
echo "<td>";
|
|
|
|
// 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 "<input id=\"" . $name . ":" . $j . "\" type=\"checkbox\" name=\"" . $name ."[]\"";
|
|
|
|
// Disable items or root right for this menu?
|
|
if (is_array($rights_enabled)) {
|
|
if(
|
|
!in_array($right, $rights_enabled) ||
|
|
(in_array($menu_item . ":" . "root", $rights_checked) && db_ver_right_cust($_SESSION[$_PAGE_INFO['id']]['search']['customer']['id'], $menu_item . ":" . "root", $skip_rights_current)) ||
|
|
($include_rights[$right] && in_array($include_rights[$right], $rights_checked))
|
|
) {
|
|
echo " disabled";
|
|
}
|
|
}
|
|
// Checked items?
|
|
echo " value=\"" . $right . "\"";
|
|
if (is_array($rights_checked)) {
|
|
if(
|
|
in_array($right, $rights_checked) ||
|
|
(in_array($menu_item . ":" . "root", $rights_checked) && db_ver_right_cust($_SESSION[$_PAGE_INFO['id']]['search']['customer']['id'], $menu_item . ":" . "root", $skip_rights_current)) ||
|
|
($include_rights[$right] && in_array($include_rights[$right], $rights_checked))
|
|
) {
|
|
echo " checked";
|
|
}
|
|
}
|
|
// Onchange event (only for the admin)
|
|
echo " onClick=\"onSubmit('" . $right . "', '', 1);\"";
|
|
|
|
echo " onkeypress=\"return noenter(event,this)\"";
|
|
echo ">";
|
|
echo "<label for=\"" . $name . ":" . $j . "\"";
|
|
echo " style=\"";
|
|
if ($menu_item == "root") {
|
|
echo "color:#002F4C;";
|
|
}
|
|
|
|
// Line through when up the pyramid the rights are no longer there (exceptions are only user rights)
|
|
if ((is_valid_action("cust_info")) || ((is_valid_action("cust_change")) && ($_SESSION[$_PAGE_INFO['id']]['MTinfo_menu'] == "menu:klanten:wijzigen"))) {
|
|
if (is_array($rights_checked)) {
|
|
// Skip own right check?
|
|
$skip_rights_current = (is_valid_action("cust_change")) ? 1 : 0;
|
|
if ((in_array($right_menu, $rights_checked)) && (!db_ver_right_cust($_SESSION[$_PAGE_INFO['id']]['search']['customer']['id'], $right_menu, $skip_rights_current))) {
|
|
echo "text-decoration:line-through;";
|
|
}
|
|
}
|
|
}
|
|
else if (is_valid_action("user_info","user_change","cust_change")) {
|
|
// user rights? => Skip
|
|
if (is_array($rights_checked)) {
|
|
// Skip own right check?
|
|
$skip_rights_current = is_valid_action("user_change","cust_change");
|
|
if ((in_array($right, $rights_checked)) && (!db_ver_right_user($_SESSION[$_PAGE_INFO['id']]['search']['user']['id'], $right, 1, $skip_rights_current))) {
|
|
echo "text-decoration:line-through;";
|
|
}
|
|
}
|
|
}
|
|
echo "\"";
|
|
echo ">";
|
|
|
|
if( $sright == "toegang" ) {
|
|
echo _("right:" . $sright);
|
|
}
|
|
else {
|
|
echo _("right:" . $right);
|
|
}
|
|
echo "</label>\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 "</td>\n";
|
|
|
|
// Number 3 => end of row
|
|
if (($i % 3) == 2) {
|
|
echo "</tr>\n";
|
|
}
|
|
$i++;
|
|
$j++;
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
// JW20141003: needed for IE11 to print top and right borders
|
|
while( ($i++ % 3) ) echo "<td></td>";
|
|
echo "</tr>\n";
|
|
|
|
// End of row when less then 3 items
|
|
if (($i % 3) != 0) {
|
|
echo "</tr>\n";
|
|
}
|
|
}
|
|
}
|
|
}
|
|
echo "</table>\n";
|
|
echo "</td>\n";
|
|
echo "</tr>\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 "<tr>\n";
|
|
echo "<td id=\"col0\"></td>\n";
|
|
echo "<td id=\"col1\">";
|
|
if (!isset($_SESSION[$_PAGE_INFO['id']]['extended_menu'])) {
|
|
echo "<p>" . _($title) . "</p>\n";
|
|
}
|
|
echo "</td>";
|
|
echo "<td id=\"col2\">";
|
|
|
|
// Initial values
|
|
$left_ids = array();
|
|
$left_values = array();
|
|
$left_colors = array();
|
|
|
|
// Read only?
|
|
if (is_ro($ro_actions)) {
|
|
echo "<!--[if lte IE 6]>";
|
|
echo "<span class=\"select_element\"";
|
|
if (($_SESSION[$_PAGE_INFO['id']]['sts']['finished'] != 10) && (isset($_SESSION[$_PAGE_INFO['id']]['sts']['finished']))) {
|
|
echo " style=\"visibility:hidden\"";
|
|
}
|
|
echo ">\n";
|
|
echo "<![endif]-->";
|
|
// 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 "<select size=\"" . $size . "\" disabled>\n";
|
|
|
|
// Fill listbox
|
|
if (is_array($initial_left_items)) {
|
|
foreach($initial_left_items as $item) {
|
|
echo "<option ";
|
|
echo "onmouseover=\"Tip('" . htmlspecialchars(addslashes(strip_tags($item['value']))) . "',BGCOLOR,'" . $_PAGE_INFO['ini']['tooltip']['background'] . "',BORDERCOLOR, '" . $_PAGE_INFO['ini']['tooltip']['border'] . "');\" onmouseout=\"UnTip();\" ";
|
|
// Styling option?
|
|
if (strlen($item['styling_options'])) {
|
|
echo "style=\"" . $item['styling_options'] . "\" ";
|
|
}
|
|
echo "value=\"" . $item['id'] . "\" ";
|
|
if (strlen($item['color'])) {
|
|
echo "id=\"" . $item['color'] . "\"";
|
|
}
|
|
echo ">" . htmlspecialchars(strip_tags($item['value']));
|
|
}
|
|
}
|
|
|
|
echo "</select>\n";
|
|
echo "<!--[if lte IE 6]>";
|
|
echo "</span>";
|
|
echo "<![endif]-->";
|
|
|
|
// 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 "<table width=\"100%\" class=\"user_control\" align=\"left\">\n";
|
|
echo "<tr>\n";
|
|
echo "<td>\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 "<label for=\"" . $name . "_left[]\" style=\"text-align:left\">" . _($labels[0]) . ":<br>" . "</label>";
|
|
echo "<!--[if lte IE 6]>";
|
|
echo "<span class=\"select_element\"";
|
|
if (($_SESSION[$_PAGE_INFO['id']]['sts']['finished'] != 10) && (isset($_SESSION[$_PAGE_INFO['id']]['sts']['finished']))) {
|
|
echo " style=\"visibility:hidden\"";
|
|
}
|
|
echo ">\n";
|
|
echo "<![endif]-->";
|
|
echo "<select multiple=\"multiple\" id=\"left_right_select\" style=\"height:" . ($height*15) . "px\" name=\"" . $name . "_left[]\" size=\"" . $height . "\" ondblclick=\"onSubmit('but_dbl_" . $name . "_left_right', '', 1);\">\n";
|
|
// Fill left listbox
|
|
if (is_array($left_items)) {
|
|
foreach ($left_items as $item) {
|
|
echo "<option value=\"" . $item['id'] . "\" ";
|
|
echo "onmouseover=\"Tip('" . htmlspecialchars(addslashes(strip_tags($item['value']))) . "',BGCOLOR,'" . $_PAGE_INFO['ini']['tooltip']['background'] . "',BORDERCOLOR, '" . $_PAGE_INFO['ini']['tooltip']['border'] . "');\" onmouseout=\"UnTip();\" ";
|
|
// Styling option?
|
|
if (strlen($item['styling_options'])) {
|
|
echo "style=\"" . $item['styling_options'] . "\" ";
|
|
}
|
|
// Color?
|
|
if (strlen($item['color'])) {
|
|
echo "id=\"" . $item['color'] . "\"";
|
|
}
|
|
echo ">" . strip_tags($item['value']);
|
|
array_push($left_ids, $item['id']);
|
|
}
|
|
}
|
|
echo "</select>\n";
|
|
echo "<!--[if lte IE 6]>";
|
|
echo "</span>";
|
|
echo "<![endif]-->";
|
|
|
|
// 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 "</td>\n";
|
|
echo "<td>\n";
|
|
|
|
// Table for buttons
|
|
echo "<table width=\"100%\" style=\"margin:0px\">\n";
|
|
echo "<tr style=\"height:" . (($height-1) * 5) . "px\">\n";
|
|
echo "</tr>\n";
|
|
echo "<tr>\n";
|
|
echo "<td align=\"center\">\n";
|
|
$icon = ($all) ? "<<" : "<";
|
|
echo "<input type=\"button\" class=\"button\" id=\"leftright_button\" value=\"" . $icon . "\" onclick=\"onSubmit('but_" . $name . "_right_left', '', 1);\">\n";
|
|
echo "</td>\n";
|
|
echo "</tr>\n";
|
|
echo "<tr>\n";
|
|
echo "<td align=\"center\">\n";
|
|
$icon = ($all) ? ">>" : ">";
|
|
echo "<input type=\"button\" class=\"button\" id=\"leftright_button\" value=\"" . $icon . "\" onclick=\"onSubmit('but_" . $name . "_left_right', '', 1);\">\n";
|
|
echo "</td>\n";
|
|
echo "</tr>\n";
|
|
echo "</table>\n";
|
|
echo "</td>\n";
|
|
echo "<td>\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 "<div id=\"" . $name . "_right_list\">";
|
|
echo "<label for=\"" . $name . "_right[]\" style=\"text-align:left\">" . _($labels[1]) . ":<br>" . "</label>";
|
|
echo "<!--[if lte IE 6]>";
|
|
echo "<span class=\"select_element\"";
|
|
if (($_SESSION[$_PAGE_INFO['id']]['sts']['finished'] != 10) && (isset($_SESSION[$_PAGE_INFO['id']]['sts']['finished']))) {
|
|
echo " style=\"visibility:hidden\"";
|
|
}
|
|
echo ">\n";
|
|
echo "<![endif]-->";
|
|
echo "<select multiple=\"multiple\" id=\"left_right_select\" style=\"height:" . ($height*15) . "px\" name=\"" . $name . "_right[]\" size=\"" . $height . "\" ondblclick=\"onSubmit('but_dbl_" . $name . "_right_left', '', 1);\">";
|
|
// Fill right listbox
|
|
if (is_array($all_items)) {
|
|
foreach ($all_items as $item) {
|
|
if ((is_array($left_ids)) && (!in_array($item['id'],$left_ids))) {
|
|
if ((!strlen($filter_value)) || (strlen(stristr($item['value'],$filter_value)))) {
|
|
echo "<option value=\"" . $item['id'] . "\" ";
|
|
echo "onmouseover=\"Tip('" . htmlspecialchars(addslashes(strip_tags($item['value']))) . "',BGCOLOR,'" . $_PAGE_INFO['ini']['tooltip']['background'] . "',BORDERCOLOR, '" . $_PAGE_INFO['ini']['tooltip']['border'] . "');\" onmouseout=\"UnTip();\" ";
|
|
// Styling option?
|
|
if (strlen($item['styling_options'])) {
|
|
echo "style=\"" . $item['styling_options'] . "\" ";
|
|
}
|
|
// Color?
|
|
if (strlen($item['color'])) {
|
|
echo "id=\"" . $item['color'] . "\"";
|
|
}
|
|
echo ">" . strip_tags($item['value']);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
echo "</select>\n";
|
|
|
|
echo "<select multiple=\"multiple\" id=\"left_right_select\" style=\"height:" . ($height*15) . "px;display:none;\" name=\"" . $name . "_right_hidden[]\" size=\"" . $height . "\" ondblclick=\"onSubmit('but_dbl_" . $name . "_right_left', '', 1);\">";
|
|
// Fill hidden right listbox (this one is used for the filtering)
|
|
if (is_array($all_items)) {
|
|
foreach ($all_items as $item) {
|
|
if ((is_array($left_ids)) && (!in_array($item['id'],$left_ids))) {
|
|
echo "<option value=\"" . $item['id'] . "\" ";
|
|
echo "onmouseover=\"Tip('" . htmlspecialchars(addslashes(strip_tags($item['value']))) . "',BGCOLOR,'" . $_PAGE_INFO['ini']['tooltip']['background'] . "',BORDERCOLOR, '" . $_PAGE_INFO['ini']['tooltip']['border'] . "');\" onmouseout=\"UnTip();\" ";
|
|
// Styling option
|
|
if (strlen($item['styling_options'])) {
|
|
echo "style=\"" . $item['styling_options'] . "\" ";
|
|
}
|
|
// Color?
|
|
if (strlen($item['color'])) {
|
|
echo "id=\"" . $item['color'] . "\"";
|
|
}
|
|
echo ">" . strip_tags($item['value']);
|
|
}
|
|
}
|
|
}
|
|
echo "</select>\n";
|
|
|
|
|
|
echo "<!--[if lte IE 6]>";
|
|
echo "</span>";
|
|
echo "<![endif]-->";
|
|
echo "</div>";
|
|
|
|
if (!$all) {
|
|
// Filter right box!
|
|
echo "<script type=\"text/javascript\">\n";
|
|
echo "var func_" . $name . " = function onkeyup() {\n";
|
|
echo "getElement('" . $name . "_right[]').options.length = 0;";
|
|
echo "var x = getElement('" . $name . "_right_hidden[]');";
|
|
echo "for (var i = 0; i < x.options.length; i++) {";
|
|
echo "if (x.options[i].text.toLowerCase().search(getElement('" . $name . "_filter').value.toLowerCase()) != -1) {";
|
|
echo "var option = x.options[i];";
|
|
echo "var index = getElement('" . $name . "_right[]').options.length;";
|
|
echo "getElement('" . $name . "_right[]').options[index] = new Option(option.text, option.value);";
|
|
echo "getElement('" . $name . "_right[]').options[index].id = option.id;";
|
|
echo "getElement('" . $name . "_right[]').options[index].onmouseover = option.onmouseover;";
|
|
echo "getElement('" . $name . "_right[]').options[index].onmouseout = option.onmouseout;";
|
|
echo "}";
|
|
echo "}";
|
|
echo "}\n";
|
|
// Reset button!
|
|
echo "function reset_filter_" . $name . "() {\n";
|
|
echo "getElement('" . $name . "_filter').value = '';";
|
|
echo "getElement('" . $name . "_right[]').options.length = 0;";
|
|
echo "var x = getElement('" . $name . "_right_hidden[]');";
|
|
echo "for (var i = 0; i < x.options.length; i++) {";
|
|
echo "var option = x.options[i];";
|
|
echo "var index = getElement('" . $name . "_right[]').options.length;";
|
|
echo "getElement('" . $name . "_right[]').options[index] = new Option(option.text, option.value);";
|
|
echo "getElement('" . $name . "_right[]').options[index].id = option.id;";
|
|
echo "getElement('" . $name . "_right[]').options[index].onmouseover = option.onmouseover;";
|
|
echo "getElement('" . $name . "_right[]').options[index].onmouseout = option.onmouseout;";
|
|
echo "}";
|
|
echo "}\n";
|
|
echo "</script>\n";
|
|
echo "<label for=\"" . $name . "_filter\" style=\"text-align:left\">" . _("Filter") . ":<br>" . "</label>";
|
|
echo "<input id=\"filter_input\" type=\"text\" name=\"" . $name . "_filter\" value=\"" . $filter_value . "\" autocomplete=\"off\" onkeypress=\"return noenter(event,this)\" onkeyup=\"new_value('" . $name . "_filter',func_" . $name . ");\" onfocus=\"current_value('" . $name . "_filter');\">\n";
|
|
echo "<input id=\"resetbutton\" type=\"button\" class=\"button\" value=\"" . _("Reset") . "\" onClick=\"reset_filter_" . $name . "();\">\n";
|
|
}
|
|
|
|
echo "</td>\n";
|
|
echo "</tr>\n";
|
|
echo "</table>\n";
|
|
}
|
|
echo "</td>\n";
|
|
echo "</tr>\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 "<tr>\n";
|
|
echo "<td id=\"col0\"></td>\n";
|
|
echo "<td id=\"col1\"></td>\n";
|
|
echo "<td id=\"col2\">\n";
|
|
}
|
|
echo "<div class=\"scrollable_div\"";
|
|
$style = array();
|
|
if( $options['style'] ) $style[] = $options['style'];
|
|
if( $options['max-height'] ) {
|
|
$max_height = "max-height:";
|
|
$max_height .= $options['max-height'];
|
|
if( is_numeric($options['max-height']) ) $max_height .= "px";
|
|
$style[] = $max_height;
|
|
}
|
|
if( !empty($style) ) {
|
|
echo " style=\"";
|
|
echo implode(";", $style);
|
|
echo "\"";
|
|
}
|
|
echo ">";
|
|
echo "<table>";
|
|
}
|
|
|
|
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 "</table>";
|
|
echo "</div>";
|
|
if( $options['form'] ) {
|
|
echo "</td>\n";
|
|
echo "</tr>\n";
|
|
}
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
* Print image
|
|
*
|
|
* Inputs:
|
|
* - src Image source
|
|
*/
|
|
function print_image($title = "", $src)
|
|
{
|
|
echo "<tr>\n";
|
|
echo "<td></td>\n";
|
|
echo "<td>\n";
|
|
if (strlen($title)) {
|
|
echo "<p>" . _($title) . "</p>\n";
|
|
}
|
|
echo "</td>\n";
|
|
echo "<td>";
|
|
echo "<img src=\"" . $src . "\" alt=\"\">\n";
|
|
echo "</td>\n";
|
|
echo "</tr>\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 <sizeof($data); $i++) {
|
|
if ($i) {
|
|
$result .= "//";
|
|
}
|
|
$result .= $data[$i]['id'];
|
|
}
|
|
}
|
|
else {
|
|
$result = "//No Result//";
|
|
}
|
|
|
|
// Hidden control
|
|
echo "<input type=\"hidden\" name=\"result\" value=\"" . $result . "\">";
|
|
|
|
return $result;
|
|
}
|
|
|
|
/**
|
|
* Recall stored result from session info
|
|
*
|
|
* Inputs:
|
|
* - session_key Place where data was stored
|
|
*/
|
|
function result_recall($session_key)
|
|
{
|
|
$result = "";
|
|
|
|
if ($session_key != "//No Result//") {
|
|
$result = split("//", $session_key);
|
|
}
|
|
|
|
return $result;
|
|
}
|
|
|
|
/**
|
|
* Function to insert some empty space
|
|
*/
|
|
function print_empty_space($height = 10)
|
|
{
|
|
echo "<tr height=\"" . $height . "px\">\n";
|
|
echo "</tr>\n";
|
|
}
|
|
|
|
/**
|
|
* Function to insert button padding
|
|
*/
|
|
function print_button_padding()
|
|
{
|
|
echo "<td id=\"col2\" style=\"padding-left:0px\">\n";
|
|
}
|
|
?>
|