. */ /** * @defgroup list Lists */ /** * @brief Lists : * * * @file * @author Yves Christian Kpakpo * @date $date$ * @version $Revision$ * @ingroup list */ /** * @brief Parameters * * Parameters for lists array [bool_modeReturn] boolean Return or echo mode (default: true) [divListId] string Id of the div used to contain ajax return of list (default: divList) [moduleName] string Name of the module where the page is [pageName] string The calling page [bool_pageInModule] boolean The calling page is part of a module [urlParameters] string Extra parameters for url to page [pageTitle] string Title of the page to be displayed over the list [bool_bigPageTitle] boolean Size of the title. If false small size [pagePicto] string Image to be displayed near title [bool_showIconDetails] boolean Show the detail icon and link [viewDetailsLink] string Default details link [bool_showIconDocument] boolean Show the icon view document [bool_showAddButton] boolean Show the Add Button [bool_showBottomToolbar] boolean Show bottom toolbar (default: true) [bool_showSmallToolbar] boolean Show toolbar in small mode (default: false) [addButtonLabel] string Label of the Add Button, (default: _ADD) [addButtonLink] string Url of the Add Button link [addButtonScript] string Action or function executed on click to Add Button [listCss] string Css used in the list (default: listing spec) [bool_sortColumn] boolean Show the order icons or not (default: true) [linesToShow] string Number of rows to show in the list [bool_changeLinesToShow] boolean Show dropdown list to change number of rows to show in the list (default: true) [listHeight] string Height of the list [bool_showSearchTools] boolean If true : show list letters filter [bool_showSearchBox] boolean If true : show search box [searchBoxAutoCompletionUrl] string Autocompletion url used by search box [searchBoxAutoCompletionMinChars] integer Number minimum of charactere to activate show autocompletion list (default: 1) [searchBoxAutoCompletionParamName] string Name of the parameter passed in autocompletion url (default: what) [searchBoxAutoCompletionUpdate] boolean Search on ID after autocompletion select [bool_checkBox] boolean Add checkbox to row (checkbox name : field[]) [bool_radioButton] boolean Add radio button to row (radio name : field) [bool_standaloneForm] boolean Add standalone form (no MEP actions needed) [formId] string Id of the list form (default: formList) [formName] string Name of the list form (default: formList) [formMethod] string Method of the list form (default: POST) [formAction] string Action of the list form (default: #) [formClass] string Class of the list form (default: forms) [disabledRules] string Rules to verify to disabled a line in list (must return boolean) Use generic @@field@@ format parameter [hiddenFormFields] array Hidden fields in the form (format: array( 'ID' => "the_id", 'NAME' => "the_name", 'VALUE'=> "the_value")) [bool_actionOnLineClick] boolean Action on line click [defaultAction] string Id of the default action [collId] string Id of the collection (used in actions management) [tableName] string Name of the table or view (used in actions management) [actions] array List of actions in actions dropdown list (format: array('ID' => "the_id", 'LABEL' => "the_label")) [filters] array List of filters (format: array('filter_id', 'filter_id', 'filter_id')) [templates] array List of tempkates (format: array('template_id', 'template_id', 'template_id')) [defaultTemplate] string Template used by default (default: first in aray) [bool_showTemplateDefaultList] boolean Show icon and link of the default lists in template list (default: false) [buttons] array List of form buttons (format: array('TYPE' => "the_type_or_default", 'ID' => "the_id", 'LABEL' => "the_label", 'ACTION'=> "the_onclick_action")) [processInstructions] string Process instructions text (default: _CLICK_LINE_TO_PROCESS) [bool_showSublist] boolean Show sublist icon and action (default: false) [sublistUrl] string Sublist content url (used in ajax function) (*)[actionIcons] array Array of action icons in list (format: array( 'type' => 'the_type', 'href' => 'the_href_link', (**) 'script' => 'the_javascript_action', (**) 'class' => 'the_icon_class', 'icon' => 'the_icon', 'label' => 'the_label', 'tooltip' => 'the_tooltip', 'alertText' => 'the_text_alert', 'disabledRules' => 'the_disabled_rules' 'alwaysVisible' => true/false ) ) * Parameters for actions array [type] string Type of the action Icon (switch, button, image or link) [on] array Details of action button ON. (only for switch action) (***) [off] array Details of action button OFF. (only for switch action) (***) [switchRules] string Rule to active switch action (must return boolean). Use @@field_name@@ parameter. (only for switch action) *** Details of action button [href] string Link for action (** can't use it with [script]) [script] string javascript for action (** can't use it with [href]) [tooltip] string Tooltip for action [class] string Css style for action link [icon] string Icon for action link [label] string Label of the link [alertText] string Text displayed in the alert box. Can use @@field_name@@ parameter [disabledRules] string To disabled action link (must return boolean). Use @@field_name@@ parameter */ require_once 'core' . DIRECTORY_SEPARATOR . 'class' . DIRECTORY_SEPARATOR . 'class_security.php'; abstract class lists_Abstract extends Database { protected $countResult; protected $countTd; protected $link; protected $start; protected $lines; protected $end; protected $order; protected $orderField; protected $params ; protected $actionButtons; protected $withForm; protected $formId; protected $whatSearch; protected $haveAction; protected $currentBasket; protected $template; protected $tmplt_CurrentCssLine; protected $modeReturn; protected $divListId; protected $collId; function __construct(){ $this->order = $_REQUEST['order']; $this->orderField = $_REQUEST['order_field']; $this->start = $_REQUEST['start']; $this->whatSearch = $_REQUEST['what']; $this->_manageFilters(); if (isset($_REQUEST['template'])) $this->template = $_REQUEST['template']; if (isset($_REQUEST['coll_id'])) $this->collId = $_REQUEST['coll_id']; if(!isset($_SESSION['previous_basket']['id'])){ $_SESSION['previous_basket']['id'] = $_SESSION['current_basket']['id']; } } protected function _buildFilter($filter) { //Reset some values $filters = $filtersClause = $where = $options = ''; //Db query $db = new Database(); //var_dump($_SESSION['filters']['contact']); //Load filter's data switch ($filter) { case 'status': $stmt = $db->query( "SELECT * FROM " . STATUS_TABLE . " WHERE can_be_searched = 'Y' order by label_status" ); while ($res = $stmt->fetchObject()) { if (isset($_SESSION['filters']['status']['VALUE']) && $_SESSION['filters']['status']['VALUE'] == $res->id ) $selected = 'selected="selected"'; else $selected = ''; $options .=''; } $filters .=' '; break; case 'entity': require_once "modules" . DIRECTORY_SEPARATOR . "entities" . DIRECTORY_SEPARATOR . "class" . DIRECTORY_SEPARATOR . "class_manage_entities.php"; require_once "modules" . DIRECTORY_SEPARATOR . "entities" . DIRECTORY_SEPARATOR . "entities_tables.php"; $ent = new entity(); $sec = new security(); $view = $sec->retrieve_view_from_table($this->params['tableName']); if (empty($view)) { $view = $this->params['tableName']; } if (!empty($view)) { if (! empty($this->params['basketClause'])) { $this->params['basketClause'] = str_replace('res_view_letterbox.', 'r.', $this->params['basketClause']); $where = 'where (' . $this->params['basketClause'] . ')'; } $stmt = $db->query( "SELECT distinct(r.destination) as entity_id, count(distinct r.res_id)" . " as total, e.entity_label , e.short_label FROM " . $view. " r left join " . ENT_ENTITIES . " e on e.entity_id = r.destination " .$where . " and entity_id <> ''" . " group by e.entity_label, e.short_label, r.destination order by e.entity_label" ); while ($res = $stmt->fetchObject()) { if ((isset($_SESSION['filters']['entity']['VALUE']) || isset($_SESSION['filters']['entity_subentities'])) && $_SESSION['filters']['entity']['VALUE'] == $res->entity_id ) $selected = 'selected="selected"'; else $selected = ''; if ($ent->is_user_in_entity($_SESSION['user']['UserId'], $res->entity_id)) $style = 'style="font-weight:bold;"'; else $style = ''; $options .=''; } } $filters .=''; $filters .= ''; break; case 'entity_subentities': require_once "modules" . DIRECTORY_SEPARATOR . "entities" . DIRECTORY_SEPARATOR . "class" . DIRECTORY_SEPARATOR . "class_manage_entities.php"; require_once "modules" . DIRECTORY_SEPARATOR . "entities" . DIRECTORY_SEPARATOR . "entities_tables.php"; $ent = new entity(); $sec = new security(); $view = $sec->retrieve_view_from_table($this->params['tableName']); if (empty($view)) { $view = $this->params['tableName']; } if (!empty($view)) { if (! empty($this->params['basketClause'])) { $this->params['basketClause'] = str_replace('res_view_letterbox.', 'r.', $this->params['basketClause']); $where = 'where (' . $this->params['basketClause'] . ')'; } $stmt = $db->query( "SELECT distinct(r.destination) as entity_id, count(distinct r.res_id)" . " as total, e.entity_label , e.short_label FROM " . $view. " r left join " . ENT_ENTITIES . " e on e.entity_id = r.destination " .$where . " and entity_id <> ''" . " group by e.entity_label, e.short_label, r.destination order by e.entity_label" ); while ($res = $stmt->fetchObject()) { if (isset($_SESSION['filters']['entity_subentities']['VALUE']) && $_SESSION['filters']['entity_subentities']['VALUE'] == $res->entity_id ) $selected = 'selected="selected"'; else $selected = ''; if ($ent->is_user_in_entity($_SESSION['user']['UserId'], $res->entity_id)) $style = 'style="font-weight:bold;"'; else $style = ''; $subEntities_tmp = array(); $subEntities = array(); $subEntities_tmp = $ent->getEntityChildrenTree($subEntities_tmp, $res->entity_id); for($iSubEntities=0;$iSubEntitiesentity_id . "'"); if(isset($_SESSION['current_basket']['view']) && $_SESSION['current_basket']['view'] <> ""){ $view = $_SESSION['current_basket']['view']; } $this->params['basketClause'] = str_replace('r.', 'res_view_letterbox.', $this->params['basketClause']); $stmt2 = $db->query("SELECT count(res_id) as total FROM ".$view." WHERE (".$this->params['basketClause'].") and destination in (" . implode(",",$subEntities) . ")"); $res2 = $stmt2->fetchObject(); $options .=''; } } if (isset($_SESSION['filters']['entity']['VALUE']) && $_SESSION['filters']['entity_subentities']['checked'] == true && $_SESSION['filters']['entity']['VALUE'] != ''){ $checked = 'checked="checked"'; }else{ $checked = ''; } $filters .=' '; /*$filters .=' ';*/ break; case 'typist': $sec = new security(); $view = $sec->retrieve_view_from_table($this->params['tableName']); if (empty($view)) { $view = $this->params['tableName']; } if (!empty($view)) { if (! empty($this->params['basketClause'])) $where = 'where '.$this->params['basketClause']; $stmt = $db->query( "SELECT distinct(typist) as typist, count(distinct res_id)" . " as total FROM res_view_letterbox r" . $view. " r " .$where . " group by typist order by typist" ); while ($res = $stmt->fetchObject()) { if (isset($_SESSION['filters']['typist']['VALUE']) && $_SESSION['filters']['typist']['VALUE'] == $res->typist ) $selected = 'selected="selected"'; else $selected = ''; if ($_SESSION['user']['UserId'] == $res->typist) $style = 'style="font-weight:bold;"'; else $style = ''; $options .=''; } } $filters .=' '; break; case 'category': $filters .=' '; $filters .= ''; break; case 'priority': $filters .=' '; $filters .= ''; break; case 'isViewed': $isViewedArray = array('yes' =>_YES, 'no' => _NO); $filters .=' '; $filters .= ''; break; case 'folder': if(isset($_SESSION['filters']['folder']['VALUE']) && !empty($_SESSION['filters']['folder']['VALUE'])) { $folder = $_SESSION['filters']['folder']['VALUE']; } else { $folder = '['._FOLDER.']'; } $filters .='link .'&filter=folder&value=\' + this.value, \''.$this->divListId.'\', ' .$this->modeReturn.');" /> '; //Autocompletion script and div $filters .='
'; $filters .=''; break; case 'contact': //if(isset($_SESSION['filters']['contact']['VALUE']) && !empty($_SESSION['filters']['contact']['VALUE'])) { require_once("core".DIRECTORY_SEPARATOR."class".DIRECTORY_SEPARATOR."class_request.php"); $sec = new security(); $pos = strpos($this->params['basketClause'], 'r.'); if($pos){ $ext = 'r'; $view = 'res_view_letterbox r'; }else { $ext = 'res_view_letterbox'; $view = 'res_view_letterbox'; } $query = "SELECT distinct(".$ext.".contact_id),society, firstname, lastname FROM " . $_SESSION['tablename']['contacts_v2'] . " c, ".$view." WHERE c.contact_id = ".$ext.".contact_id and ".$this->params['basketClause']; $stmt = $db->query($query, array()); $filters .=' '; $filters .= ''; /*if (is_numeric($_SESSION['filters']['contact']['VALUE'])) { $query = "SELECT society, lastname, firstname, is_corporate_person, society_short FROM " . $_SESSION['tablename']['contacts_v2'] . " WHERE contact_id = ?"; $stmt = $db->query($query, array($_SESSION['filters']['contact']['VALUE'])); $line = $stmt->fetchObject(); if($line->is_corporate_person == 'N'){ $contact = functions::show_string($line->lastname)." ".functions::show_string($line->firstname); if($line->society <> ''){ $contact .= ' ('.$line->society.')'; } } else { $contact .= $line->society; if($line->society_short <> ''){ $contact .= ' ('.$line->society_short.')'; } } } else { $query = "SELECT lastname, firstname FROM users WHERE user_id = ?"; $stmt = $db->query($query, array($_SESSION['filters']['contact']['VALUE'])); $line = $stmt->fetchObject(); $contact .= functions::show_string($line->firstname) . " " . functions::show_string($line->lastname); } } else { $contact = '['._CONTACT.']'; } $filters .=' '; //Autocompletion script and div $filters .='
'; $filters .=''; $filters .= ' '; //Autocompletion script and div $filters .=''; $filters .= 'params['basketClause'], 'r.'); if($pos){ $ext = 'r'; $view = 'res_view_letterbox r'; }else { $ext = 'res_view_letterbox'; $view = 'res_view_letterbox'; } $query = "SELECT distinct(".$ext.".subject), res_id FROM " . $view . " WHERE ".$this->params['basketClause'] . " ORDER BY subject ASC"; $stmt = $db->query($query, array()); $filters .=' '; $filters .= ''; /*$subject = '['._SUBJECT.']'; $filters .=' '; //Autocompletion script and div $filters .=''; $filters .= 'params['basketClause'])) $where = 'where '.$this->params['basketClause']; $stmt = $db->query( "SELECT distinct(r.type_id), t.description FROM " .$this->params['tableName']. " r left join " . DOCTYPES_TABLE . " t on t.type_id = r.type_id " .$where . " group by t.description, r.type_id order by t.description" ); while ($res = $stmt->fetchObject()) { if (isset($_SESSION['filters']['type']['VALUE']) && $_SESSION['filters']['type']['VALUE'] == $res->type_id ) $selected = 'selected="selected"'; else $selected = ''; $options .= ''; } $filters .=' '; break; case 'user': if(isset($_SESSION['filters']['user']['VALUE']) && !empty($_SESSION['filters']['user']['VALUE'])) { $user = $_SESSION['filters']['user']['VALUE']; } else { $user = '['._USER.']'; } $filters .=' '; //Autocompletion script and div $filters .='
'; $filters .=''; break; case 'action': $stmt = $db->query( "SELECT id, label_action FROM " . $_SESSION['tablename']['actions'] . " WHERE origin = 'folder' and enabled = 'Y' and history = 'Y'" ); while ($res = $stmt->fetchObject()) { $id = 'ACTION#' . $res->id; if (isset($_SESSION['filters']['action']['VALUE']) && $_SESSION['filters']['action']['VALUE'] == $id ) $selected = 'selected="selected"'; else $selected = ''; $options .=''; } $filters .=' '; break; case 'history_action': for ($i=0;$i'.$_SESSION['history_keywords'][$i]['label'].''; } $filters .=' '; break; case 'history_date': if(isset($_SESSION['filters']['history_date_start']['VALUE']) && !empty($_SESSION['filters']['history_date_start']['VALUE'])) { $date_start = $_SESSION['filters']['history_date_start']['VALUE']; } $filters .= '  '._SINCE.': '; if(isset($_SESSION['filters']['history_date_end']['VALUE']) && !empty($_SESSION['filters']['history_date_end']['VALUE'])) { $date_end = $_SESSION['filters']['history_date_end']['VALUE']; } $filters .= '  '._FOR.':  '; break; case 'creation_date': if(isset($_SESSION['filters']['creation_date_start']['VALUE']) && !empty($_SESSION['filters']['creation_date_start']['VALUE'])) { $date_start = $_SESSION['filters']['creation_date_start']['VALUE']; } $filters .= '  '._SINCE.': '; if(isset($_SESSION['filters']['creation_date_end']['VALUE']) && !empty($_SESSION['filters']['creation_date_end']['VALUE'])) { $date_end = $_SESSION['filters']['creation_date_end']['VALUE']; } $filters .= '  '._FOR.':  '; break; case 'identifier': if(isset($_SESSION['filters']['identifier']['VALUE']) && !empty($_SESSION['filters']['identifier']['VALUE'])) { $identifier = $_SESSION['filters']['identifier']['VALUE']; } else { $identifier = '['._CHRONO_NUMBER.']'; } $filters .=' '; break; } return $filters; } protected function _haveFilter() { $haveFilter = false; foreach ($_SESSION['filters'] as $key => $val) { if (!empty($_SESSION['filters'][$key]['VALUE'])) { $haveFilter = true; break; } } return $haveFilter; } protected function _resetFilter() { if($_SESSION['previous_basket']['id'] != $_SESSION['current_basket']['id']){ foreach ($_SESSION['filters'] as $key => $val) { $_SESSION['filters'][$key]['VALUE'] = ''; $_SESSION['filters'][$key]['CLAUSE'] = ''; } }/*elseif($_SESSION['basket_used'] == $_GET['baskets']){ foreach ($_SESSION['filters'] as $key => $val) { $_SESSION['filters'][$key]['VALUE'] = ''; $_SESSION['filters'][$key]['CLAUSE'] = ''; } }*/ } protected function _resetFilter2() { foreach ($_SESSION['filters'] as $key => $val) { $_SESSION['filters'][$key]['VALUE'] = ''; $_SESSION['filters'][$key]['CLAUSE'] = ''; } } protected function _manageFilters() { //Reset all filters if ($_REQUEST['filter'] == 'reset'){ $this->_resetFilter2(); } else { //Init filter value and clause if(isset($_REQUEST['value']) && !empty($_REQUEST['value'])) { if ($_REQUEST['value'] == 'none') { //Reset if none $_SESSION['filters'][$_REQUEST['filter']]['VALUE'] = ''; $_SESSION['filters'][$_REQUEST['filter']]['CLAUSE'] = ''; } else { //Keep value $_SESSION['filters'][$_REQUEST['filter']]['VALUE'] = $_REQUEST['value']; //var_dump($_REQUEST['filter']); //Build where clause if ($_REQUEST['filter'] == 'status') { if ($_SESSION['filters']['status']['VALUE'] == 'late') { require_once("core".DIRECTORY_SEPARATOR."class".DIRECTORY_SEPARATOR."class_request.php"); $request = new request(); $_SESSION['filters']['status']['CLAUSE'] = "(process_limit_date is not null and " .$request->current_datetime()." > " .$request->extract_date('process_limit_date')." ) and status <> 'END'"; } else { $_SESSION['filters']['status']['CLAUSE'] = "status = '".$_SESSION['filters']['status']['VALUE']."'"; } } else if ($_REQUEST['filter'] == 'entity') { $_SESSION['filters']['entity_subentities']['VALUE'] = ''; $_SESSION['filters']['entity_subentities']['CLAUSE'] = ''; $_SESSION['filters']['entity_subentities']['checked'] = false; $_SESSION['filters']['entity']['CLAUSE'] = "destination = '".$_SESSION['filters']['entity']['VALUE']."'"; } else if ($_REQUEST['filter'] == 'entity_subentities') { //$_SESSION['filters']['entity']['VALUE'] = ''; $_SESSION['filters']['entity']['CLAUSE'] = ''; $_SESSION['filters']['entity_subentities']['checked'] = true; require_once "modules" . DIRECTORY_SEPARATOR . "entities" . DIRECTORY_SEPARATOR . "class" . DIRECTORY_SEPARATOR . "class_manage_entities.php"; $entities = new entity(); $subEntities_tmp = array(); $subEntities = array(); $subEntities_tmp = $entities->getEntityChildrenTree($subEntities_tmp, $_SESSION['filters']['entity_subentities']['VALUE']); for($iSubEntities=0;$iSubEntitiesprotect_string_db(str_replace(')', '', substr($_SESSION['filters']['folder']['VALUE'], strrpos($_SESSION['filters']['folder']['VALUE'], '(') + 1))); $_SESSION['filters']['folder']['CLAUSE'] = "folder_id = '".$folderId."'"; } else if ($_REQUEST['filter'] == 'identifier') { $_SESSION['filters']['identifier']['CLAUSE'] = "alt_identifier ilike ('%".$_SESSION['filters']['identifier']['VALUE']."%')"; } else if ($_REQUEST['filter'] == 'type') { $_SESSION['filters']['type']['CLAUSE'] = "type_id = '".$_SESSION['filters']['type']['VALUE']."'"; } else if ($_REQUEST['filter'] == 'res_id') { /*Permet de filtrer sur le res_id*/ if(is_numeric($_SESSION['filters']['res_id']['VALUE'])){ $_SESSION['filters']['res_id']['CLAUSE'] = "res_id = '".$_SESSION['filters']['res_id']['VALUE']."'"; } } else if ($_REQUEST['filter'] == 'subject') { /*Permet de filtrer sur le l'objet du courrier et si la valeur saisi est un numérique va rechercher sur le res_id*/ $_SESSION['filters']['subject']['CLAUSE'] = "upper(subject) like '%".strtoupper($_SESSION['filters']['subject']['VALUE'])."%'"; if(is_numeric($_SESSION['filters']['subject']['VALUE'])){ $_SESSION['filters']['subject']['CLAUSE'] .= "or res_id = '".$_SESSION['filters']['subject']['VALUE']."'"; } } else if ($_REQUEST['filter'] == 'isViewed') { if ($_SESSION['filters']['isViewed']['VALUE'] == 'yes') { $_SESSION['filters']['isViewed']['CLAUSE'] = "res_id in (select res_id from listinstance WHERE coll_id = '".$_SESSION['collection_id_choice']."' and item_type = 'user_id' and item_id = '".$_SESSION['user']['UserId']."' and item_mode = 'cc' and viewed > 0)"; } else if ($_SESSION['filters']['isViewed']['VALUE'] == 'no') { $_SESSION['filters']['isViewed']['CLAUSE'] = "res_id in (select res_id from listinstance WHERE coll_id = '".$_SESSION['collection_id_choice']."' and item_type = 'user_id' and item_id = '".$_SESSION['user']['UserId']."' and item_mode = 'cc' and viewed = 0 or viewed is null)"; } } else if ($_REQUEST['filter'] == 'user') { $userId = $this->protect_string_db(str_replace(')', '', substr($_SESSION['filters']['user']['VALUE'], strrpos($_SESSION['filters']['user']['VALUE'], '(') + 1))); $_SESSION['filters']['user']['CLAUSE'] = $_SESSION['tablename']['users'].".user_id = '".$userId."'"; } else if ($_REQUEST['filter'] == 'action') { $_SESSION['filters']['action']['CLAUSE'] = "event_type = '".$_SESSION['filters']['action']['VALUE']."'"; } else if ($_REQUEST['filter'] == 'history_action') { $_SESSION['filters']['history_action']['CLAUSE'] = "event_type = '".$_SESSION['filters']['history_action']['VALUE']."'"; } else if ($_REQUEST['filter'] == 'history_date_start' || $_REQUEST['filter'] == 'history_date_end') { //Pattern $pattern = "/^[0-3][0-9]-[0-1][0-9]-[1-2][0-9][0-9][0-9]$/"; //Keep the date $history_date = array(); //date start if (preg_match($pattern, $_SESSION['filters']['history_date_start']['VALUE']) == false) { $_SESSION['error'] = _DATE.' '._WRONG_FORMAT; } else { $history_date['start'] = "(date(event_date) >= '" .$_SESSION['filters']['history_date_start']['VALUE']."')"; } //date end if (preg_match($pattern, $_SESSION['filters']['history_date_end']['VALUE']) == false) { $_SESSION['error'] = _DATE.' '._WRONG_FORMAT; } else { $history_date['end'] = "(date(event_date) <= '" .$_SESSION['filters']['history_date_end']['VALUE']."')"; } $_SESSION['filters']['history_date']['CLAUSE'] = join(' and ', $history_date); } else if ($_REQUEST['filter'] == 'creation_date_start' || $_REQUEST['filter'] == 'creation_date_end') { //Pattern $pattern = "/^[0-3][0-9]-[0-1][0-9]-[1-2][0-9][0-9][0-9]$/"; //Keep the date $creation_date = array(); //date start if (preg_match($pattern, $_SESSION['filters']['creation_date_start']['VALUE']) == false) { $_SESSION['error'] = _DATE.' '._WRONG_FORMAT; } else { $creation_date['start'] = "(creation_date >= '" .$_SESSION['filters']['creation_date_start']['VALUE']."')"; } //date end if (preg_match($pattern, $_SESSION['filters']['creation_date_end']['VALUE']) == false) { $_SESSION['error'] = _DATE.' '._WRONG_FORMAT; } else { $creation_date['end'] = "(creation_date <= '" .$_SESSION['filters']['creation_date_end']['VALUE']."')"; } $_SESSION['filters']['creation_date']['CLAUSE'] = join(' and ', $creation_date); } else if($_REQUEST['filter'] == 'priority' && isset($_REQUEST['value']) && $_REQUEST['value'] != 0) { $_SESSION['filters']['priority']['CLAUSE'] = "priority = '".$_REQUEST['value']."'"; } } } elseif($_REQUEST['filter'] == 'priority' && isset($_REQUEST['value']) && $_REQUEST['value'] == 0) { //j'ai créé cette condition pour le filtre des priorités parce que lorsque la valeur de $_request[value] est égale à 0, on ne rentre pas dans la condition et donc le filtre ne fonctionne pas lorsque c'est égale à 0. $_SESSION['filters']['priority']['VALUE'] = '0'; $_SESSION['filters']['priority']['CLAUSE'] = "priority = '".$_REQUEST['value']."'"; } } } protected function _resetUrlTemplates() { unset($_SESSION['url_templates']); $_SESSION['url_templates'] = array(); } protected function _getTemplates() { $templates = ''; //Check the selected template //Show the templates if (isset($this->params['templates']) && count($this->params['templates']) > 0) { //Default list (no template) if ($this->params['bool_showTemplateDefaultList'] === true) { //Put none in template array if (!in_array('none', $this->params['templates'])) array_unshift($this->params['templates'], 'none'); } else { //Unset none from template array if (isset($this->params['templates']['none'])) unset($this->params['templates']['none']); } // $this->show_array($_SESSION['html_templates']); //Build templates icon and link for($i=0; $i < count($this->params['templates']); $i++) { //Template is defined? if (isset($_SESSION['html_templates'][$this->params['templates'][$i]])) { //Selected template if ($this->template == $_SESSION['html_templates'][$this->params['templates'][$i]]['ID']) { $selected = 'color: #FBC110'; } else { $selected = ''; } //Template link if (empty($_SESSION['url_templates'][$this->params['templates'][$i]])) { if (!empty($_SESSION['html_templates'][$this->params['templates'][$i]]['GOTOLIST'])) { //link from template parameters $_SESSION['url_templates'][$this->params['templates'][$i]] = $_SESSION['html_templates'][$this->params['templates'][$i]]['GOTOLIST'] .'&template='.$_SESSION['html_templates'][$this->params['templates'][$i]]['ID']; } else { // // $this->link = $this->_removeUrlVar($this->link, 'template'); $_SESSION['url_templates'][$this->params['templates'][$i]] = $this->link.'&template='.$_SESSION['html_templates'][$this->params['templates'][$i]]['ID']; } } //Templates $templates .= '' . '  '; } } } // $this->show_array($_SESSION['url_templates']); return $templates; } protected function _loadTemplate($templateFile) { $templateContent = ''; //Get tge filecontent $templateContent = file_get_contents ($templateFile); //Delete all comments $templateContent = preg_replace("/()/s","", $templateContent); return $templateContent; } protected function _tmplt_defineLang($parameter) { $my_explode= explode ("|", $parameter); if (!$my_explode[1]) { return _WRONG_PARAM_FOR_LOAD_VALUE; } else { if (defined($my_explode[1]) && constant($my_explode[1]) <> NULL) return constant($my_explode[1]); else return $my_explode[1]; } } protected function _tmplt_sortColumn($parameter) { $my_explode= explode ("|", $parameter); if (!isset($my_explode[1])) { return _WRONG_PARAM_FOR_LOAD_VALUE; } else { $column = $my_explode[1]; ($this->order == 'desc' && (strpos($this->orderField, $column) !== false))? $sortImgDown = 'mCdarkOrange' : $sortImgDown = 'mCdarkBlue'; ($this->order == 'asc' && (strpos($this->orderField, $column) !== false))? $sortImgUp = 'mCdarkOrange' : $sortImgUp = 'mCdarkBlue'; $return .= ''; $return .= ''; } return $return; } protected function _tmplt_cssLineReload() { //Get last css parameter defined for the result list return $this->tmplt_CurrentCssLine; } protected function _tmplt_cssLine($parameter) { $my_explode= explode ("|", $parameter); if (!$my_explode[1]) { return _WRONG_PARAM_FOR_LOAD_VALUE; } else { //Treat if (count($my_explode) == 2 ) { return $my_explode[1]; } else if (count($my_explode) == 3) { if ($this->tmplt_CurrentCssLine == '') { $this->tmplt_CurrentCssLine = $my_explode[1]; return $this->tmplt_CurrentCssLine; } else if ($this->tmplt_CurrentCssLine == $my_explode[1]) { $this->tmplt_CurrentCssLine = $my_explode[2]; return $this->tmplt_CurrentCssLine; } else if ($this->tmplt_CurrentCssLine == $my_explode[2]) { $this->tmplt_CurrentCssLine = $my_explode[1]; return $this->tmplt_CurrentCssLine; } else { return _WRONG_PARAM_FOR_LOAD_VALUE; } } else { return _WRONG_PARAM_FOR_LOAD_VALUE; } } } protected function _tmplt_loadImage($parameter) { $my_explode= explode ("|", $parameter); if (!$my_explode[1]) { return _WRONG_PARAM_FOR_LOAD_VALUE; } else { if (count($my_explode) == 2 ) { return ''; } else if (count($my_explode) >= 3) { return ''; } else { return _WRONG_PARAM_FOR_LOAD_VALUE; } } } protected function _tmplt_loadValue($parameter, $resultTheLine) { $my_explode= explode ("|", $parameter); if (!$my_explode[1]){ return _WRONG_PARAM_FOR_LOAD_VALUE; } else { $column = $my_explode[1]; for($i= 0; $i <= count($resultTheLine); $i++ ) { if($resultTheLine[$i]['column'] == $column) { if(is_bool($resultTheLine[$i]['value'])) { //If boolean (convert to string) if ($resultTheLine[$i]['value']) return "true"; else return "false"; } else { // return $this->_highlightWords($resultTheLine[$i]['value'], $this->whatSearch); //highlight mode return $resultTheLine[$i]['value']; } } } } } protected function _tmplt_showSmallToolbar () { $this->params['bool_showSmallToolbar'] = true; return $this->_createSmallToolbar(); } protected function _tmplt_checkBox($resultTheLine, $listKey, $lineIsDisabled) { //Get the ListKey value $keyValue = ''; for($i= 0; $i <= count($resultTheLine); $i++ ) { if($resultTheLine[$i]['column'] == $listKey) { $keyValue = $resultTheLine[$i]['value']; } } //If checkbox is activated (is it important if template???) if ($this->params['bool_checkBox'] === true) { if($_SESSION['stockCheckbox'] != null){ $key = in_array($keyValue, $_SESSION['stockCheckbox']); //If disable or checkbox if($key == true){ if ($lineIsDisabled === true || empty($keyValue)) { $return .= '
'; } else { $return .= '
'; } }else{ if ($lineIsDisabled === true || empty($keyValue)) { $return .= '
'; } else { $return .= '
'; } } }else{ //If disable or checkbox if ($lineIsDisabled === true || empty($keyValue)) { $return .= '
'; } else { $return .= '
'; } } } return $return; } protected function _tmplt_checkUncheckAll() { //If checkbox is activated if ($this->params['bool_checkBox'] === true) { return ''; } } protected function _tmplt_radioButton($resultTheLine, $listKey, $lineIsDisabled) { $return = ''; //Get the ListKey value $keyValue = ''; for($i= 0; $i <= count($resultTheLine); $i++ ) { if($resultTheLine[$i]['column'] == $listKey) { $keyValue = $resultTheLine[$i]['value']; } } //If radio button is activated (is it important if template???) if ($this->params['bool_radioButton'] === true) { //If disable or radio button if ($lineIsDisabled === true || empty($keyValue)) { $return .= '
'; } else { $return .= '
'; } } return $return; } protected function _tmplt_showIconProcessDocument($resultTheLine, $listKey) { $return = ''; //Show document icon $href = $this->_buildMyLink('index.php?page=view_baskets&module=basket&baskets=MyBasket&directLinkToAction', $resultTheLine, $listKey); $return .= '
'; return $return; } protected function _tmplt_showIconDocument($resultTheLine, $listKey) { $core = new core_tools(); $return = ''; //Show document icon foreach($resultTheLine as $r){ if (isset($r['res_id'])) { $res_id = $r['res_id']; break; } } $isAttachment = false; foreach($resultTheLine as $r){ if ($r['column'] === 'attachment_type') { $isAttachment = true; break; } } $href = $this->_buildMyLink($this->params['viewDocumentLink'], $resultTheLine, $listKey); if ($core->is_module_loaded('thumbnails') === true && !$isAttachment){ $return .= '
'; } else $return .= '
'; return $return; } protected function _tmplt_showIconDetails($resultTheLine, $listKey) { $return = ''; //Show details button $href = $this->_buildMyLink($this->params['viewDetailsLink'], $resultTheLine, $listKey); $return .= '
'; return $return; } protected function _tmplt_showActionIcon($parameter, $resultTheLine) { $my_explode= explode ("|", $parameter); if (!$my_explode[1]) { return _WRONG_PARAM_FOR_LOAD_VALUE; } else { if (count($my_explode) >= 4 ) { //Init $actionIsDisabled = false; //Check if action is disabled if (isset($my_explode[4]) && !empty($my_explode[4])) { $actionIsDisabled = $this->_checkDisabledRules($my_explode[4], $resultTheLine); } //If disabled, return blank if ($actionIsDisabled) { return ' '; } else { //return action icon return ''.$my_explode[2].''; } } else { return _WRONG_PARAM_FOR_LOAD_VALUE; } } } protected function _tmplt_showActionFA($parameter, $resultTheLine) { //var_dump($parameter);exit; $my_explode= explode ("|", $parameter); if (!$my_explode[1]) { return _WRONG_PARAM_FOR_LOAD_VALUE; } else { if (count($my_explode) >= 4 ) { //Init $actionIsDisabled = false; //Check if action is disabled if (isset($my_explode[4]) && !empty($my_explode[4])) { $actionIsDisabled = $this->_checkDisabledRules($my_explode[4], $resultTheLine); } //If disabled, return blank if ($actionIsDisabled) { return ' '; } else { //return action icon return ''; } } else { return _WRONG_PARAM_FOR_LOAD_VALUE; } } } protected function _tmplt_showActionBasketsFA($parameter, $resultTheLine) { $my_explode= explode ("|", $parameter); if (!$my_explode[1]) { return _WRONG_PARAM_FOR_LOAD_VALUE; } else { if (count($my_explode) >= 4 ) { //Init $actionIsDisabled = false; //Check if action is disabled if (isset($my_explode[4]) && !empty($my_explode[4])) { $actionIsDisabled = $this->_checkDisabledRules($my_explode[4], $resultTheLine); } //If disabled, return blank if ($actionIsDisabled) { return ' '; } else { $db = new Database(); $stmt = $db->query("SELECT res_id_master FROM res_view_attachments WHERE status = 'EXP_RTURN' AND validation_date < CURRENT_TIMESTAMP AND res_id_master = ?", [$resultTheLine[0]['res_id']]); $color = ''; if ($stmt->rowCount() >= 1) { $color = 'style="color: red"'; } //return action icon return ''; } } else { return _WRONG_PARAM_FOR_LOAD_VALUE; } } } protected function _tmplt_func_isConfidential($resultTheLine) { $db = new Database(); $stmt = $db->query("SELECT confidentiality FROM res_view_letterbox WHERE res_id = ?", [$resultTheLine[0]['res_id']]); $color = ''; $result = $stmt->fetchObject(); if ($result->confidentiality == 'Y') { return ''.strtoupper (_CONFIDENTIAL).''; } } protected function _tmplt_func_load_case_status($resultTheLine) { $db = new Database(); $stmt = $db->query("SELECT count(*) as total FROM cases WHERE case_closing_date is not NULL and case_id = ?", [$resultTheLine[0]['case_id']]); $result = $stmt->fetchObject(); if($result->total > 0){ return ' '; }else{ return ''; } var_dump($resultTheLine[0]); } protected function _tmplt_showActionAdvResultFA($parameter, $resultTheLine) { $my_explode= explode ("|", $parameter); if (!$my_explode[1]) { return _WRONG_PARAM_FOR_LOAD_VALUE; } else { if (count($my_explode) >= 4 ) { //Init $actionIsDisabled = false; //Check if action is disabled if (isset($my_explode[4]) && !empty($my_explode[4])) { $actionIsDisabled = $this->_checkDisabledRules($my_explode[4], $resultTheLine); } //If disabled, return blank if ($actionIsDisabled) { return ' '; } else { //return action icon $color = ''; if (!empty($_SESSION['fullTextAttachments']['letterbox']) && in_array($resultTheLine[0]['res_id'], $_SESSION['fullTextAttachments']['letterbox'])) { $color = 'style="color: #009dc5;"'; } $db = new Database(); $stmt = $db->query( "SELECT count(*) as total FROM res_view_attachments WHERE res_id_master = ? and status not in ('DEL','OBS','TMP') and lower(translate(title,'ÀÁÂÃÄÅÆÇÈÉÊËÌÍÎÏÐÑÒÓÔÕÖØÙÚÛÜÝÞßàáâãäåæçèéêëìíîïðñòóôõöøùúûýýþÿŔŕ','aaaaaaaceeeeiiiidnoooooouuuuybsaaaaaaaceeeeiiiidnoooooouuuyybyRr')) like lower(?)", array($resultTheLine[0]['res_id'],$_SESSION['searching']['where_request_parameters'][':subject']) ); $res_attach = $stmt->fetchObject(); if($res_attach->total > 0){ $color = 'style="color: #009dc5;"'; } return ''; } } else { return _WRONG_PARAM_FOR_LOAD_VALUE; } } } protected function _tmplt_clickOnLine($resultTheLine, $listKey, $lineIsDisabled) { $return = ''; //If there is action on line click if($this->params['bool_actionOnLineClick'] && isset($this->params['defaultAction']) && !empty($this->params['defaultAction']) && $lineIsDisabled === false ) { //Get the ListKey value $keyValue = ''; for($i= 0; $i <= count($resultTheLine); $i++ ) { if($resultTheLine[$i]['column'] == $listKey) { $keyValue = $resultTheLine[$i]['value']; } } $return = 'onmouseover="this.style.cursor=\'pointer\';" onClick="validForm( \'page\', \'' .$keyValue.'\', \''.$this->params['defaultAction'].'\');" '; } return $return; } protected function _tmplt_includeFile($parameter) { $my_explode= explode ("|", $parameter); if (!$my_explode[1]){ return _WRONG_PARAM_FOR_LOAD_VALUE; } else { //File $file = $my_explode[1]; if (count($my_explode) == 3 && isset($my_explode[2]) && !empty($my_explode[2])) { $module = $my_explode[2]; include "modules".DIRECTORY_SEPARATOR.$module.DIRECTORY_SEPARATOR.$file; } else { include "apps".DIRECTORY_SEPARATOR.$_SESSION['config']['app_id'].DIRECTORY_SEPARATOR.$file; } } } protected function _tmplt_getBusinessAppUrl() { return $_SESSION['config']['businessappurl']; } protected function _tmplt_getListParameter($parameter) { $my_explode= explode ("|", $parameter); if (!$my_explode[1]) { return _WRONG_PARAM_FOR_LOAD_VALUE; } else { return $this->params[$my_explode[1]]; } } protected function _tmplt_setListParameter($parameter) { $my_explode= explode ("|", $parameter); if (!$my_explode[1]) { return _WRONG_PARAM_FOR_LOAD_VALUE; } else { if (count($my_explode) == 3) { if ($my_explode[2] == 'true') { $this->params[$my_explode[1]] = true; } else if ($my_explode[2] == 'false') { $this->params[$my_explode[1]] = false; } else { $this->params[$my_explode[1]] = $my_explode[2]; } } else { return _WRONG_PARAM_FOR_LOAD_VALUE; } } } protected function _tmplt_ifStatement($parameter) { $my_explode= explode ("|", $parameter); if (!$my_explode[1]) { return _WRONG_PARAM_FOR_LOAD_VALUE; } else { if (count($my_explode) >= 4) { $condition = "return($my_explode[1]);"; // $debug .='condition: '.$condition."
"; if(@eval($condition)) { return $my_explode[2]; } else { return $my_explode[3]; } } else { return _WRONG_PARAM_FOR_LOAD_VALUE; } } } protected function _tmplt_isModuleLoaded($parameter) { $my_explode= explode ("|", $parameter); if (!$my_explode[1]) { return _WRONG_PARAM_FOR_LOAD_VALUE; } else { $core_tools = new core_tools(); if($core_tools->is_module_loaded($my_explode[1]) === true) { return "true"; } else { return "false"; } } } public function tmplt_func_bool_see_notes($resultTheLine) { $return = ''; if ($resultTheLine[0]['hasNotes'] || $resultTheLine[1]['hasNotes']) { $return .= ''; } return $return; } public function tmplt_func_delete($resultTheLine) { $return = ""; $nbresult_I = count($resultTheLine); for($iresults=0;$iresults<$nbresult_I;$iresults++){ if($resultTheLine[$iresults]['typist_id']){ $typist = $resultTheLine[$iresults]['typist_id']; } if($resultTheLine[$iresults]['fromDetail']){ $fromDetail = $resultTheLine[$iresults]['fromDetail']; } } $core_tools = new core_tools(); if ($core_tools->test_service('delete_attachments', 'attachments', false) || $typist == $_SESSION['user']['UserId']) { $return = ''; }else{ $return = ''; } return $return; } public function tmplt_func_modify($resultTheLine) { $return = ""; $nbresult_I = count($resultTheLine); for($iresults=0;$iresults<$nbresult_I;$iresults++){ if($resultTheLine[$iresults]['typist_id']){ $typist = $resultTheLine[$iresults]['typist_id']; } if($resultTheLine[$iresults]['relation']){ $relation = $resultTheLine[$iresults]['relation']; } if($resultTheLine[$iresults]['fromDetail']){ $fromDetail = $resultTheLine[$iresults]['fromDetail']; } if($resultTheLine[$iresults]['value_bis']){ $status = $resultTheLine[$iresults]['value_bis']; } } $core_tools = new core_tools(); if (($core_tools->test_service('modify_attachments', 'attachments', false) || $typist == $_SESSION['user']['UserId']) && $status <> "TRA") { $return = ' '; }else{ $return = ''; } return $return; } public function tmplt_func_previous_version($resultTheLine) { $return = ""; if ((int)$resultTheLine[1]['value'] > 1) { $return .= ''; } return $return; } public function tmplt_func_final_version($resultTheLine) { $nbresult_I = count($resultTheLine); for($iresults=0;$iresults<$nbresult_I;$iresults++){ if($resultTheLine[$iresults]['relation']){ $relation = $resultTheLine[$iresults]['relation']; } if($resultTheLine[$iresults]['fromDetail']){ $fromDetail = $resultTheLine[$iresults]['fromDetail']; } } $return = '' . _FINAL_VERSION; return $return; } public function tmplt_func_bool_see_multi_contacts($resultTheLine) { $return = ''; $nbresult_I = count($resultTheLine); for($iresults=0;$iresults<$nbresult_I;$iresults++){ if($resultTheLine[$iresults]['is_multi_contacts']){ $isMultiContacts = $resultTheLine[$iresults]['is_multi_contacts']; } if($resultTheLine[$iresults]['res_multi_contacts']){ $resMultiContacts = $resultTheLine[$iresults]['res_multi_contacts']; } } if ($isMultiContacts == 'Y') { $return .= ''; } return $return; } public function tmplt_func_cadenas($parameter) { $my_explode= explode ("|", $parameter); $now = date("Y-m-d H:i:s"); $my_explode[2] = str_replace("'","",$my_explode[2]); $my_explode[1] = str_replace("'","",$my_explode[1]); if (!isset($my_explode[2])) { return ''; } else if ($my_explode[2] == null || $my_explode[2] == '' || empty($my_explode[2])) { return ''; } else if ($my_explode[1] == $_SESSION['user']['UserId'] ) { return ''; } else if ($my_explode[2] > $now ) { return ''; } else { return ''; } } public function tmplt_showDefaultAction($parameter) { $db = new Database(); if($_SESSION['current_basket']['default_action'] != ""){ //Load action name $stmt = $db->query( "SELECT label_action FROM actions WHERE id = ?", array($_SESSION['current_basket']['default_action']) ); $res = $stmt->fetchObject(); return $res->label_action; } } public function tmplt_nbNoteAvis($parameter) { $my_explode = explode ("|", $parameter); $res_id = str_replace("'","",$my_explode[1]); $db = new Database(); //Load action name $stmt = $db->query( "SELECT count(*) as total FROM notes WHERE identifier = ? and note_text like '[avis%'", array($res_id) ); $note = $stmt->fetchObject(); return $note->total; } protected function _tmplt_loadVarSys($parameter, $resultTheLine=array(), $listKey='', $lineIsDisabled=false) { ##loadValue|arg1##: load value in the db; arg1= column's value identifier if (preg_match("/^loadValue\|/", $parameter)){ $var = $this->_tmplt_loadValue($parameter, $resultTheLine); ##sortColumn|arg1## : cretate sort in header; arg1 = name of the column } else if (preg_match("/^sortColumn\|/", $parameter)) { $var = $this->_tmplt_sortColumn($parameter); ##defineLang|arg1## : define constant by the lang file; arg1 = constant of lang.php } else if (preg_match("/^defineLang\|/", $parameter)){ $var = $this->_tmplt_defineLang($parameter); ##cssLineReload## : reload css style for next line } else if (preg_match("/^cssLineReload$/", $parameter)) { $var = $this->_tmplt_cssLineReload($parameter); ##cssLine|coll|nonecoll## : load css style for line arg1,arg2 : switch beetwin style on line one or line two } else if (preg_match("/^cssLine\|/", $parameter)) { $var = $this->_tmplt_cssLine($parameter); ##loadImage|arg1|arg2## :load image; arg1= image name, arg2 = module name (if image in module) } else if (preg_match("/^loadImage\|/", $parameter)) { $var = $this->_tmplt_loadImage($parameter); ##showSmallToolbar: swhow small bar for navigation } else if (preg_match("/^showSmallToolbar$/", $parameter)) { $var = $this->_tmplt_showSmallToolbar(); ##checkBox## : show checkbox } elseif (preg_match("/^checkBox$/", $parameter)) { $var = $this->_tmplt_checkBox($resultTheLine, $listKey, $lineIsDisabled); ##checkUncheckAll## : show checkbox check All /uncheck All } elseif (preg_match("/^checkUncheckAll$/", $parameter)) { $var = $this->_tmplt_checkUncheckAll(); ##radioButton## : show radio button } elseif (preg_match("/^radioButton$/", $parameter)) { $var = $this->_tmplt_radioButton($resultTheLine, $listKey, $lineIsDisabled); ##showIconProcessDocument## : show process document icon and link } elseif (preg_match("/^showIconProcessDocument$/", $parameter)) { $var = $this->_tmplt_showIconProcessDocument($resultTheLine, $listKey); ##showIconDocument## : show document icon and link } elseif (preg_match("/^showIconDocument$/", $parameter)) { $var = $this->_tmplt_showIconDocument($resultTheLine, $listKey); ##showIconDetails## : show details icon and link } elseif (preg_match("/^showIconDetails$/", $parameter)) { $var = $this->_tmplt_showIconDetails($resultTheLine, $listKey); } elseif (preg_match("/^showActionIcon\|/", $parameter)) { $var = $this->_tmplt_showActionIcon($parameter, $resultTheLine); ##showActionFA## : show action Font Awesome } elseif (preg_match("/^showActionFA\|/", $parameter)) { $var = $this->_tmplt_showActionFA($parameter, $resultTheLine); ##showActionBasketsFA## : show action Font Awesome } elseif (preg_match("/^showActionBasketsFA\|/", $parameter)) { $var = $this->_tmplt_showActionBasketsFA($parameter, $resultTheLine); ##showActionAdvResultFA## : show action Font Awesome } elseif (preg_match("/^showActionAdvResultFA\|/", $parameter)) { $var = $this->_tmplt_showActionAdvResultFA($parameter, $resultTheLine); ##clickOnLine## : Action on click under the line } elseif (preg_match("/^clickOnLine$/", $parameter)) { $var = $this->_tmplt_clickOnLine($resultTheLine, $listKey, $lineIsDisabled); ##includeFile## : Action on click under the line } elseif (preg_match("/^includeFile\|/", $parameter)) { $var = $this->_tmplt_includeFile($parameter); ##getBusinessAppUrl## : Action on click under the line } elseif (preg_match("/^getBusinessAppUrl$/", $parameter)) { $var = $this->_tmplt_getBusinessAppUrl(); ##getListParameter## : } elseif (preg_match("/^getListParameter\|/", $parameter)) { $var = $this->_tmplt_getListParameter($parameter); ##setListParameter## : } elseif (preg_match("/^setListParameter\|/", $parameter)) { $var = $this->_tmplt_setListParameter($parameter); ##isModuleLoaded## : } elseif (preg_match("/^isModuleLoaded\|/", $parameter)) { $var = $this->_tmplt_isModuleLoaded($parameter); ##ifStatement## : } elseif (preg_match("/^ifStatement\|/", $parameter)) { $var = $this->_tmplt_ifStatement($parameter); } elseif (preg_match("/^func_bool_see_multi_contacts$/", $parameter)){ $var = $this->tmplt_func_bool_see_multi_contacts($resultTheLine); } elseif (preg_match("/^func_delete$/", $parameter)){ $var = $this->tmplt_func_delete($resultTheLine); } elseif (preg_match("/^func_modify$/", $parameter)){ $var = $this->tmplt_func_modify($resultTheLine); } elseif (preg_match("/^func_final_version$/", $parameter)){ $var = $this->tmplt_func_final_version($resultTheLine); } elseif (preg_match("/^func_previous_version$/", $parameter)){ $var = $this->tmplt_func_previous_version($resultTheLine); } elseif (preg_match("/^func_bool_see_notes$/", $parameter)){ $var = $this->tmplt_func_bool_see_notes($resultTheLine); } elseif (preg_match("/^func_cadenas\|/", $parameter)){ $var = $this->tmplt_func_cadenas($parameter); } elseif (preg_match("/^showDefaultAction$/", $parameter)){ $var = $this->tmplt_showDefaultAction($parameter); }elseif (preg_match("/^nbNoteAvis\|/", $parameter)){ $var = $this->tmplt_nbNoteAvis($parameter); } elseif (preg_match("/^func_isConfidential$/", $parameter)) { $var = $this->_tmplt_func_isConfidential($resultTheLine); ##showActionIcon## : show action icon } elseif (preg_match("/^func_load_case_status$/", $parameter)) { $var = $this->_tmplt_func_load_case_status($resultTheLine); } else { $var = _WRONG_FUNCTION_OR_WRONG_PARAMETERS; } return $var; } protected function _buildTemplate($templateFile, $resultArray, $listKey) { if (file_exists('custom/' . $_SESSION['custom_override_id'] . '/' . $templateFile)) { $templateFile = 'custom/' . $_SESSION['custom_override_id'] . '/' . $templateFile; } //Check if template file exists if (file_exists($templateFile)) { //Load template file $templateContent = $this->_loadTemplate($templateFile); //Explode template $templateContentArray = explode("#!#", $templateContent); //Get value from template foreach($templateContentArray as $templateSection) { if (substr($templateSection , 0, 5) == "TABLE") { //Get table string $table = substr($templateSection, 5); $trueTable = $table; preg_match_all('/##(.*?)##/', $trueTable, $output); //Replace functions by values for($i=0;$i_tmplt_loadVarSys($output[1][$i]); $table = str_replace($output[0][$i],$remplacementTable, $trueTable); } } elseif (substr($templateSection , 0, 4) == "HEAD") { //Get head string $head = substr($templateSection, 4); $trueHead = $head; preg_match_all('/##(.*?)##/', $trueHead, $output); for($i=0;$i'; $_remplacementHead = $this->_tmplt_loadVarSys($_output[1][$j]); // $debug .='---> '.$_remplacementHead.'
'; $_trueHead = str_replace($_output[0][$j],$_remplacementHead,$_trueHead); } $output[1][$i] = $_trueHead; $remplacementHead = $this->_tmplt_loadVarSys($output[1][$i]); $trueHead = str_replace($output[0][$i], $remplacementHead, $trueHead); } $head = $trueHead; } else if (substr($templateSection , 0, 6) == "RESULT") { //Get rows content $content = substr($templateSection, 6); } elseif (substr($templateSection , 0, 6) == "FOOTER") { //Get footer string $footer = substr($templateSection, 6); } } $rowsContent = ''; //Loop into the set of records for($theLine = $this->start; $theLine < $this->end ; $theLine++) { //Check if line is disable $lineIsDisabled = $this->_checkDisabledRules($this->params['disabledRules'], $resultArray[$theLine]); //Treat content $trueContent = $content; preg_match_all('/##(.*?)##/', $trueContent, $output); for($i=0;$i '.$output[1][$i].'
'; $_trueContent = ''; //If template function is called under template function $_trueContent = $output[1][$i]; preg_match_all('/#(.*?)#/', $_trueContent, $_output); for($j=0;$j '.$_output[0][$j].'
'; $_remplacement = $this->_tmplt_loadVarSys($_output[1][$j], $resultArray[$theLine], $listKey, $lineIsDisabled); // echo '---> '.$_remplacement.'
'; $_trueContent = str_replace($_output[0][$j],$_remplacement,$_trueContent); } $output[1][$i] = $_trueContent; // echo '<- '.$output[1][$i].'

'; $remplacement = $this->_tmplt_loadVarSys($output[1][$i], $resultArray[$theLine], $listKey, $lineIsDisabled); $trueContent = str_replace($output[0][$i],$remplacement,$trueContent); } $rowsContent .= $trueContent; } $buildedTemplate = $table.$head.$rowsContent.$footer; //Fix some json line breaks issues $buildedTemplate = str_replace(chr(10), "", $buildedTemplate); $buildedTemplate = str_replace(chr(13), "", $buildedTemplate); return $buildedTemplate; } else { return _NO_TEMPLATE_FILE_AVAILABLE. ': '.$templateFile; } } protected function _highlightWords($input, $keyword, $maxLength=30, $minLength=5) { $output = $input; if(strlen(trim($keyword)) < $maxLength && strlen(trim($keyword)) > $minLength ) { // $output = preg_replace("/(>|^)([^<]+)(?=<|$)/esx", "'\\1' . str_replace('" . $keyword . "', '" . $keyword . "', '\\2')", $input); // $output = preg_replace("/(?\\1', $input); $keywordArray = explode(" ", $keyword); for($i = 0; $i < count($keywordArray); $i++) { $save_keywordArray = ""; $pos = stripos($input, $keywordArray[$i]); if($pos !== false) { $save_keywordArray = substr($input, $pos, strlen($keywordArray[$i])); } $output = preg_replace("/(".$keywordArray[$i].")/i","".$save_keywordArray."",$input); } } return $output; } protected function _buildMyLink($link, $resultTheLine, $listKey='') { //If you want to use different key for action link if (strpos($link, "@@") !== false) { foreach(array_keys($resultTheLine) as $column) { // for every column $key = "@@".$resultTheLine[$column]['column']."@@"; //build the alias $val = $resultTheLine[$column]['value']; //get the real value $link = str_replace($key, $val, $link); //replace alias by real value } } //Use standard id (based on list key) if (!empty($listKey)) { //Get the ListKey value $keyValue = ''; for($i= 0; $i <= count($resultTheLine); $i++ ) { if($resultTheLine[$i]['column'] == $listKey) { $keyValue = $resultTheLine[$i]['value']; } } $link .= "&id=".$keyValue; } return $link; } protected function _removeUrlVar($url, $varName) { $url = html_entity_decode($url); $urlArray = parse_url($url); parse_str($urlArray['query'], $output); unset($output[$varName]); $urlVar = http_build_query($output); return strtok($url, '?') . '?' . $urlVar; } protected function _buildPageLink() { //Get page and module from REQUEST if (!isset($this->params['pageName']) || empty($this->params['pageName'])) $this->params['pageName'] = $_REQUEST['page']; if (!isset($this->params['moduleName']) || empty($this->params['moduleName'])) $this->params['moduleName'] = $_REQUEST['module']; //Url parameters if (isset($this->params['urlParameters'])) { $pos = strpos($this->params['urlParameters'], '&'); //if my urlParameters string have '&' if ($pos !== false) { //at the firt position if ($pos <> 0) { //And page is called by index page if ($this->params['bool_pageInModule']) { //Add '&' $this->params['urlParameters'] = '&'.$this->params['urlParameters']; } } } else {//my urlParameters string dont have '&' at all //And page is called by index page if ($this->params['bool_pageInModule']) { //Add '&' $this->params['urlParameters'] = '&'.$this->params['urlParameters']; } } } //Page pageName if (isset($this->params['pageName'])){ if ($this->params['bool_pageInModule'] && isset($this->params['moduleName'])) { //If page is called in a module by index page $link = $_SESSION['config']['businessappurl'].'index.php?page='.$this->params['pageName']."&module=" .$this->params['moduleName'].$this->params['urlParameters']; } elseif(isset($this->params['moduleName']) && !$this->params['bool_pageInModule']) { //Else if page is called inside the module $link = $_SESSION['urltomodules'].$this->params['moduleName']."/".$this->params['pageName'].".php?".$this->params['urlParameters']; } else { $link = $_SESSION['config']['businessappurl'].'index.php?page='.$this->params['pageName'].$this->params['urlParameters']; } } else { //Default link (anchor) to prevent error in link if no pageName or module name $link = "#"; } //String searched in list if(!empty($this->whatSearch)) { $link = $this->_removeUrlVar($link,'what'); $link.= '&what='.$this->whatSearch; } //Column order if(!empty($_REQUEST['order']) && !empty($_REQUEST['order_field'])) { //Remove some url parameters $link = $this->_removeUrlVar($link,'order'); $link = $this->_removeUrlVar($link,'order_field'); //Init $this->order = $_REQUEST['order']; $this->orderField = $_REQUEST['order_field']; } //Template if(isset($_REQUEST['template'])) { //Remove some url parameters $link = $this->_removeUrlVar($link,'template'); $this->template = $_REQUEST['template']; $link.= '&template='.$_REQUEST['template']; $_SESSION['save_list']['template'] = $_REQUEST['template']; } //Id (used in sublist) if(isset($_REQUEST['id'])) { $link = $this->_removeUrlVar($link,'id'); $link.= '&id='.$_REQUEST['id']; } //Number of lines to show if(isset($_REQUEST['lines']) && !empty($_REQUEST['lines'])) { $link = $this->_removeUrlVar($link, 'lines'); $link.= '&lines='.$_REQUEST['lines']; } //Display = true if (isset($_REQUEST['display']) && !empty($_REQUEST['display'])) { $link = $this->_removeUrlVar($link,'display'); $link.= '&display=true'; } return $link; } protected function _checkDisabledRules($disabledRules, $resultTheLine=array()) { $disabled = false; if (!empty($disabledRules)) { if(is_array($resultTheLine) && count($resultTheLine) > 0) { foreach(array_keys($resultTheLine) as $column) { // for every column $key = "@@".$resultTheLine[$column]['column']."@@"; //build the alias $val = "'".$resultTheLine[$column]['value']."'"; //get the real value with simple quotes $disabledRules = str_replace($key, $val, $disabledRules); //replace alias by real value } } //Eval disabled rule if (!empty($disabledRules)) { $rules = "return($disabledRules);"; //echo $rules."
\n"; if(@eval($rules)) { $disabled = true; } //var_dump($disabled); } } return $disabled; } protected function _createHeader($resultFirstRow, $listColumn, $showColumn, $sortColumn) { $count_td = 0; $column = ''; //If sublist if($this->params['bool_showSublist'] && !empty($this->params['sublistUrl'])){ $column .= ' '; $count_td ++; } //If checkbox if( $this->params['bool_checkBox'] === true) { $column .= '
'; $count_td ++; //If radio button } else if( $this->params['bool_radioButton'] === true) { $column .= ' '; $count_td ++; } //If view document if($this->params['bool_showIconDocument']) { $column .= ' '; $count_td ++; } //Print column header for($actualColumn = 0;$actualColumn < count($listColumn);$actualColumn++) { //Show column if($showColumn[$actualColumn] === true) { //Different background on ordered column (strpos($this->orderField, $sortColumn[$actualColumn]) !== false)? $columnStyle = ' style="background-image: url(static.php?filename=black_0.1.png);"' : $columnStyle = ''; //column $column .= '
' .$listColumn[$actualColumn]; //Show sort icon if($this->params['bool_sortColumn']) { if( $sortColumn[$actualColumn] !== false) { //Change color of sort icon ($this->order == 'desc' && (strpos($this->orderField, $sortColumn[$actualColumn]) !== false))? $sortImgDown = 'mCdarkOrange' : $sortImgDown = 'mCdarkBlue'; ($this->order == 'asc' && (strpos($this->orderField, $sortColumn[$actualColumn]) !== false))? $sortImgUp = 'mCdarkOrange' : $sortImgUp = 'mCdarkBlue'; $column .= '

'; //Build header $column .= ''; $column .= ''; } } $column .= '
'; $count_td ++; } } //Reserve space for action buttons for($i = 0;$i < count($this->actionButtons);$i++) { $column .= ' '; $count_td ++; } //Reserve space for details button if($this->params['bool_showIconDetails']) { $column .= ' '; $count_td ++; } $column .= ''; //Count the number of columns $this->countTd = $count_td; //Small toolbar $toolbar = ''; if($this->params['bool_showSmallToolbar']){ $toolbar = ''; $toolbar .= $this->_createSmallToolbar(); $toolbar .= ''; } //Add button $addButton = $footer = ''; if($this->params['bool_showAddButton']) { $addButton = $this->_displayAddButton(); $footer = ''.$addButton.''; } //Header $header = ''.$toolbar.$column.''.$footer; return $header; } protected function _getTools($resultFirstRow, $countResult) { //ADD ALWAYS VISISBLE PARAMETERS $tools = $urlParameters = ''; if (isset($this->params['tools']) && count($this->params['tools']) > 0) { for($i=0; $i < count($this->params['tools']); $i++) { if (!isset($this->params['tools'][$i]['alwaysVisible'])) $this->params['tools'][$i]['alwaysVisible'] = false; $toolIsDisabled = $this->_checkDisabledRules($this->params['tools'][$i]['disabledRules']); if (($toolIsDisabled === false && $countResult >0) || $this->params['tools'][$i]['alwaysVisible'] === true) { if(isset($this->params['tools'][$i]['script']) && !empty($this->params['tools'][$i]['script'])) { $script = $this->_buildMyLink($this->params['tools'][$i]['script'], $resultFirstRow); $tools .= ''; } else { //Url parameters if (isset($this->params['tools'][$i]['urlParameters'])) { $pos = strpos($this->params['tools'][$i]['urlParameters'], '&'); //if my urlParameters string have '&' if ($pos !== false) { //at the firt position if ($pos <> 0) { //Add '&' $this->params['tools'][$i]['urlParameters'] = '&'.$this->params['urlParameters']; } } $urlParameters = $this->params['tools'][$i]['urlParameters']; } //Href if(isset($this->params['tools'][$i]['href']) && !empty($this->params['tools'][$i]['href'])) { $href = $this->params['tools'][$i]['href']; } else { $href = $this->link.$urlParameters; } // If javascript alert box if(isset($this->params['tools'][$i]['alertText']) && !empty($this->params['tools'][$i]['alertText'])) { $tools .= ''; } else { $tools .= ''; } } //Image if(isset($this->params['tools'][$i]['icon'])) { $tools .= ' '; } else { $tools .= ' '; } $tools .= ' '; } } } return $tools; } protected function _displaySearchTools() { $searchTools = ''; if ($this->params['bool_showSearchTools']) { //Remove old what filter $searchToolsLink = $this->_removeUrlVar($this->link,'what'); // $searchTools .= '
'; //Alphabetical list $searchTools .= ''; //Search box $searchTools .= ''; $searchTools .= '
'._ALPHABETICAL_LIST.' : '; for($i=ord('A'); $i <= ord('Z');$i++) { //Highlight selected letter (chr($i) == trim($this->whatSearch))? $letter = ''.chr($i).'' : $letter = chr($i); $searchTools .= ''.$letter.' '; } $searchTools .= '- '._ALL.''; $searchTools .= ' '; if ($this->params['bool_showSearchBox']) { $searchTools .= '
'; (strlen($this->whatSearch) > 1)? $what = $this->whatSearch : $what =''; $searchTools .= ' '; if(isset($this->params['searchBoxAutoCompletionUrl']) && !empty($this->params['searchBoxAutoCompletionUrl'])) { $searchTools .= '
'; $searchTools .= ''; $searchTools .= ''; } $searchTools .= '
'; } $searchTools .= '
'; } return $searchTools; } protected function _createToolbar($resultFirstRow) { $toolbar = $tools = $templates = $filters = ''; $start = $end = 0; //Loading image $loading = ''; //Lines to show $nbLines = $this->params['linesToShow']; if(isset($_REQUEST['lines']) && !empty($_REQUEST['lines'])) { $nbLines = $this->params['linesToShow'] = strip_tags($_REQUEST['lines']); $_SESSION['save_list']['lines'] = $nbLines; } //Number of pages $nb_pages = ceil($this->countResult/$this->params['linesToShow']); // $debug .='NB total '.$this->countResult.' / NB show: '.$this->params['linesToShow'].' / Pages: '.$nb_pages.' /'; if(isset($_REQUEST['start']) && !empty($_REQUEST['start'])) $start = strip_tags($_REQUEST['start']); $end = $start + $this->params['linesToShow']; if($end > $this->countResult) $end = $this->countResult; //Get list of tools (icon and link) $tools = $this->_getTools($resultFirstRow, $this->countResult); //Get templates $templates = $this->_getTemplates(); //Get Filters if(isset($this->params['filters']) && count($this->params['filters']) > 0) { $height = '60px'; $filters = ''.($this->_displayFilters()).''; } else { $height = '30px'; } //Build dropdown lines object $linesDropdownList = ''; if ($this->params['bool_changeLinesToShow']) { $nbLinesSelect = array( 10, 25, 50, 100, 250, 500 ); if (!in_array($this->params['linesToShow'], $nbLinesSelect)) { array_push($nbLinesSelect, $this->params['linesToShow']); } sort($nbLinesSelect); $linesDropdownList .= ' '; $linesDropdownList .= ''; } //If there are more than 1 page, pagination if($nb_pages > 1) { //Build dropdown navigation object $next_start = 0; $pageDropdownList .= _GO_TO_PAGE.' '; // $lastpage = $lastpage - $this->params['linesToShow']; $previous = " "; $next = ""; //Previous if($start > 0) { $start_prev = $start - $this->params['linesToShow']; $previous = '    '; } //Next link if($start <> $lastpage) { $start_next = $start + $this->params['linesToShow']; $next = '     '; } $toolbar .= '
'; $toolbar .= ''; $toolbar .= ''; $toolbar .= ''; $toolbar .= ''; $toolbar .= ''; $toolbar .= ''; $toolbar .= ''; $toolbar .= ''; $toolbar .= ''; $toolbar .= ''; $toolbar .= ''; $toolbar .= ''; $toolbar .= ''; $toolbar .= $filters; $toolbar .= '
'.$loading.''.$previous.''.$next.'|'.$pageDropdownList.'|'.$linesDropdownList.'|'.$tools.'|'.$templates.'
'; $toolbar .= '
'; } else { //Show toolbar if templates, tools or filters if ( !empty($templates) || !empty($tools) || !empty($filters) || ($this->params['bool_changeLinesToShow'] && $this->countResult > 0) ) { // $showToolbar = true; //if no result if ($this->countResult == 0) { //reset templates and tools (no need if no result) // $templates = ' '; // $tools = ' '; //if not caused by filters => list is empty if($this->_haveFilter() !== true) { $filters = ''; // $showToolbar = false; } } //Toolbar if ($this->params['bool_showToolbar']) { $toolbar .= '
'; $toolbar .= ''; $toolbar .= ''; $toolbar .= ''; $toolbar .= ''; $toolbar .= ''; $toolbar .= ''; $toolbar .= ''; $toolbar .= ''; $toolbar .= ''; $toolbar .= ''; $toolbar .= ''; $toolbar .= ''; $toolbar .= ''; $toolbar .= $filters; $toolbar .= '
'.$loading.'  |'.$pageDropdownList.'|'.$linesDropdownList.'|'.$tools.'|'.$templates.'
'; $toolbar .= '
'; } } } $this->start = $start; $this->end = $end; return $toolbar; } protected function _createBottomToolbar($resultFirstRow) { //Init $toolbar = $tools = $templates = ''; $start = $end = 0; //Loading image $loading = ''; //Lines to show if(isset($_REQUEST['lines']) && !empty($_REQUEST['lines'])) { $nbLines = $this->params['linesToShow'] = strip_tags($_REQUEST['lines']); } //Number of pages $nb_pages = ceil($this->countResult/$this->params['linesToShow']); // $debug .='NB total '.$this->countResult.' / NB show: '.$this->params['linesToShow'].' / Pages: '.$nb_pages.' /'; if(isset($_REQUEST['start']) && !empty($_REQUEST['start'])) $start = strip_tags($_REQUEST['start']); $end = $start + $this->params['linesToShow']; if($end > $this->countResult) $end = $this->countResult; //Get list of tools (icon and link) $tools = $this->_getTools($resultFirstRow, $this->countResult); //Get templates $templates = $this->_getTemplates(); //Go to top link $goToTop =''; //Build dropdown lines object $linesDropdownList = ''; if ($this->params['bool_changeLinesToShow']) { $nbLinesSelect = array( 10, 25, 50, 100, 250, 500 ); if (!in_array($this->params['linesToShow'], $nbLinesSelect)) { array_push($nbLinesSelect, $this->params['linesToShow']); } sort($nbLinesSelect); $linesDropdownList .= ' '; $linesDropdownList .= ''; } //If there are more than 1 page, pagination if($nb_pages > 1) { //Build dropdown navigation object $next_start = 0; $pageDropdownList .= _GO_TO_PAGE.' ' ; // $lastpage = $lastpage - $this->params['linesToShow']; $previous = " "; $next = ""; //Previous if($start > 0) { $start_prev = $start - $this->params['linesToShow']; $previous = '    '; } //Next link if($start <> $lastpage) { $start_next = $start + $this->params['linesToShow']; $next = ' '; } //Toolbar $bottomToolbar .= '
'; $bottomToolbar .= '
'; $bottomToolbar .= ''; $bottomToolbar .= ''; $bottomToolbar .= ''; $bottomToolbar .= ''; $bottomToolbar .= ''; $bottomToolbar .= ''; $bottomToolbar .= ''; $bottomToolbar .= ''; $bottomToolbar .= ''; $bottomToolbar .= ''; $bottomToolbar .= ''; $bottomToolbar .= ''; $bottomToolbar .= ''; $bottomToolbar .= ''; $bottomToolbar .= ''; $bottomToolbar .= '
'.$loading.''.$previous.''.$next.'|'.$pageDropdownList.'|'.$linesDropdownList.'|'.$tools.'|'.$templates.'|'.$goToTop.'
'; $bottomToolbar .= '
'; } else { //Show toolbar if templates or tools if ( !empty($templates) || !empty($tools) || $this->params['bool_changeLinesToShow'] ) { //Toolbar $bottomToolbar .= '
'; $bottomToolbar .= ''; $bottomToolbar .= ''; $bottomToolbar .= ''; $bottomToolbar .= ''; $bottomToolbar .= ''; $bottomToolbar .= ''; $bottomToolbar .= ''; $bottomToolbar .= ''; $bottomToolbar .= ''; $bottomToolbar .= ''; $bottomToolbar .= ''; $bottomToolbar .= ''; $bottomToolbar .= ''; $bottomToolbar .= ''; $bottomToolbar .= ''; $bottomToolbar .= '
'.$loading.'  |'.$pageDropdownList.'|'.$linesDropdownList.'|'.$tools.'|'.$templates.'|'.$goToTop.'
'; $bottomToolbar .= '
'; } } $this->start = $start; $this->end = $end; return $bottomToolbar; } protected function _createSmallToolbar () { //Init $toolbar = ''; $start = $end = 0; //Lines to show if(isset($_REQUEST['lines']) && !empty($_REQUEST['lines'])) { $nbLines = $this->params['linesToShow'] = strip_tags($_REQUEST['lines']); } //Number of pages $nb_pages = ceil($this->countResult/$this->params['linesToShow']); if(isset($_REQUEST['start']) && !empty($_REQUEST['start'])) $start = strip_tags($_REQUEST['start']); $end = $start + $this->params['linesToShow']; if($end > $this->countResult) { $end = $this->countResult; } //Build dropdown lines object $linesDropdownList = ''; if ($this->params['bool_changeLinesToShow']) { $nbLinesSelect = array( 10, 25, 50, 100, 250, 500 ); if (!in_array($this->params['linesToShow'], $nbLinesSelect)) { array_push($nbLinesSelect, $this->params['linesToShow']); } sort($nbLinesSelect); $linesDropdownList = '
'; $linesDropdownList .= ' '; $linesDropdownList .= ''; $linesDropdownList .= '
' ; } //If there are more than 1 page, pagination if($nb_pages > 1) { //Build dropdown navigation object $next_start = 0; $pageDropdownList = '' .'" ; $lastpage = $lastpage - $this->params['linesToShow']; $previous = " "; $next = ""; //Previous if($start > 0) { $start_prev = $start - $this->params['linesToShow']; $previous .= '    '; } //Next if($start <> $lastpage) { $start_next = $start + $this->params['linesToShow']; $next = ' '; } //Loading image $loading = ''; //Small toolbar $toolbar .= ''; $toolbar .= ''; $toolbar .= ''; $toolbar .= ''; $toolbar .= ''; $toolbar .= ''; $toolbar .= '
'.$loading.''.$previous.''.$next.'|'.$pageDropdownList.'
'; } $this->start = $start; $this->end = $end; return $toolbar; } protected function _displayFilters() { $filters = $filtersControl = ''; if(isset($this->params['filters']) && count($this->params['filters']) > 0) { $found = false; for ($i =0; $iparams['filters']); $i++) { //var_dump($this->params['filters'][$i]); if (isset($_SESSION['filters'][$this->params['filters'][$i]])) { $filtersControl .= $this->_buildFilter($this->params['filters'][$i]); $found = true; } } if ($found) { //Display filter $filters .='
: '; $filters .= $filtersControl; //Clear icon $filters .='|  ' .''; $filters .='
'; } else { $filters = _NO_CORRESPONDING_FILTERS; } } return $filters; } protected function _createHiddenFields() { $hiddenFields = ''; //Action management hidden fields if ($this->withForm) { if (!empty($this->params['collId'])) $hiddenFields .= ''; if (!empty($this->params['moduleName'])) $hiddenFields .= ''; if (!empty($this->params['tableName'])) $hiddenFields .= ''; } //Regular hidden fields if(isset($this->params['hiddenFormFields']) && count($this->params['hiddenFormFields']) > 0) { for ($i =0; $iparams['hiddenFormFields']); $i++) { $hiddenFields .= ''; } } return $hiddenFields; } protected function _displayAddButton() { $addButton = ''; //$addButton .= ''; $addButton .= ''; if(isset($this->params['addButtonScript']) && !empty($this->params['addButtonScript'])) { //Script $addButtonScript = 'onClick="javascript:'.$this->params['addButtonScript'].'"'; $addButtonLink = 'javascript://'; } else if(isset($this->params['addButtonLink']) && !empty($this->params['addButtonLink'])) { //Link $addButtonScript = ''; $addButtonLink = $this->params['addButtonLink']; } else { //Error $addButtonLink = '#'; //ERROR RETURN } //$addButton .= ''.$this->params['addButtonLabel'].''; $addButton .= ''; $addButton .= ''; return $addButton; } protected function _createExtraJavascript() { $str .= ''; return $str; } protected function _createActionsList($currentBasket) { if (count($currentBasket) > 0 ) { //Default action if(!empty($currentBasket['default_action'])) { $this->params['bool_actionOnLineClick'] = true; //Enable action management $this->haveAction = true; $this->params['defaultAction'] = $currentBasket['default_action']; } //Collection if(!empty($currentBasket['coll_id'])) $this->params['collId'] = $currentBasket['coll_id']; //Table name if(!empty($currentBasket['table'])) $this->params['tableName'] = $currentBasket['table']; //Lock list if (!empty ($currentBasket['lock_list'])) $this->params['disabledRules'] = $currentBasket['lock_list']; //Basket clause if (!empty ($currentBasket['clause'])) $this->params['basketClause'] = $currentBasket['clause']; //Actions list if (count($currentBasket['actions']) > 0) { $this->params['actions'] = array(); for($i=0; $iparams['actions'], array('ID' => $currentBasket['actions'][$i]['ID'], 'LABEL' => $currentBasket['actions'][$i]['LABEL'])); } } } } //If no action disable all form input if ((!isset($this->params['actions']) || count($this->params['actions']) == 0) && $this->params['bool_standaloneForm'] === false ) { $this->params['bool_checkBox'] = false; $this->params['bool_radioButton'] = false; } else { //Display checkbox if both checkbox and radio type are disabled if ($this->params['bool_checkBox'] === false && $this->params['bool_radioButton'] === false && $this->params['bool_standaloneForm'] === false ) { $this->params['bool_checkBox'] = true; } //Enable action management $this->haveAction = true; } } protected function _displayButtons() { $buttons = ''; if (isset($this->params['buttons']) && count($this->params['buttons']) > 0) { for($i=0; $i < count($this->params['buttons']); $i++) { //Button type if (isset($this->params['buttons'][$i]['TYPE'])) $type = $this->params['buttons'][$i]['TYPE']; else $type = 'button'; $buttons .= ' '; } } return $buttons; } protected function _displayActionsList() { $actionsList = ''; $actionsList .= '

'; if (count($this->params['actions']) > 0) { $actionsList .= ' '._ACTIONS.' :'; $actionsList .= ' '; $actionsList .= ' '; } $actionsList .= $this->_displayButtons(); $actionsList .= '

'; return $actionsList; } protected function _createPreviewDiv() { $str_previsualise = '
_buildPreviewContent($actualLine, $listKey); } else { $content = $this->_buildMyLink($actualButton['content'], $actualLine); } // $icon .= $content; $icon .= '_buildMyLink($actualButton['script'], $actualLine); $icon .= '_buildMyLink($actualButton['alertText'], $actualLine); $icon .= 'onClick="if(confirm(\''.addslashes($alertText).'\')){'.$script.';} else {return false;};" '; } else { $icon .= 'onClick="'.$script.'" '; } if ($this->_checkTypeOfActionIcon($this->actionButtons, 'preview') === true) { $icon .= ' onMouseOver="$(\'identifierDetailFrame\').setValue(\'\'); ' .'$(\'return_previsualise\').style.display=\'none\';" '; } $icon .= ' title="'.$actualButton['tooltip'].'"'; } else { $href = $this->_buildMyLink($actualButton['href'], $actualLine, $listKey); $icon .= '_buildMyLink($actualButton['alertText'], $actualLine); $icon .= ' onClick="return(confirm(\''.addslashes($alertText).'\'));" '; if ($this->_checkTypeOfActionIcon($this->actionButtons, 'preview') === true) { $icon .= ' onMouseOver="$(\'identifierDetailFrame\').setValue(\'\'); ' .'$(\'return_previsualise\').style.display=\'none\';" '; } } } } //Style $showLabel = true; if (isset($actualButton['class'])) { //$icon .= ' class="'.$actualButton['class'].'">'; $icon .= '>'; if ($actualButton['class'] == 'change') { $icon .= ''; $showLabel = false; } elseif($actualButton['class'] == 'delete') { $icon .= ''; $showLabel = false; } elseif($actualButton['class'] == 'suspend') { $icon .= ''; $showLabel = false; } elseif($actualButton['class'] == 'authorize') { $icon .= ''; $showLabel = false; } elseif($actualButton['class'] == 'view') { $icon .= ''; $showLabel = false; } elseif($actualButton['class'] == 'use') { $icon .= ''; $showLabel = false; } } else { $icon .= '>'; } //Image if(isset($actualButton['icon'])) { $icon .= ''; } //Label if (isset($actualButton['label']) && $showLabel) { $icon .= ' '.$actualButton['label']; } $icon .= ''; return $icon; } protected function _checkTypeOfActionIcon($actionButtons, $type) { $isThisType = false; for($button = 0; $button < count($actionButtons); $button++) { if($actionButtons[$button]['type'] == $type) { $isThisType = true; break; } } return $isThisType; } protected function _createContent($resultArray, $listColumn, $listKey) { $content = $lineCss = ''; $content .= ''; //Loop into the set of records for($theLine = $this->start; $theLine < $this->end ; $theLine++) { //Init $href = ''; $resultTheLine = array(); //Simplify some values $resultTheLine = $resultArray[$theLine]; //Get the ListKey value $keyValue = ''; for($i= 0; $i <= count($resultTheLine); $i++ ) { if($resultTheLine[$i]['column'] == $listKey) { $keyValue = $resultTheLine[$i]['value']; } } //Check if line is disable $lineIsDisabled = $this->_checkDisabledRules($this->params['disabledRules'], $resultTheLine); //Alternate css for each line if($lineCss == '') $lineCss = 'col'; elseif($lineCss == 'col') $lineCss = ''; if ($lineIsDisabled === true && $this->haveAction) $content .= ''; else $content .= ''; //Show sublist toggle icon if($this->params['bool_showSublist'] && !empty($this->params['sublistUrl'])){ if ($lineIsDisabled === true) { $content .= '
'; } else { $sublist = $this->_buildMyLink($this->params['sublistUrl'], $resultTheLine, $listKey); $content .= '
'; } } //If disable or checkbox or radio button if ($lineIsDisabled === true && ($this->params['bool_checkBox'] === true|| $this->params['bool_radioButton'] === true)) { $content .= '
'; } else if($this->params['bool_checkBox'] === true) { $content .= '
'; } else if($this->params['bool_radioButton'] === true) { if($_SESSION['stockCheckbox'] != null){ $key = in_array($keyValue, $_SESSION['stockCheckbox']); if($key==true){ $content .= '
'; }else{ $content .= '
'; } }else{ $content .= '
'; } } //Show document icon if($this->params['bool_showIconDocument']){ $href = $this->_buildMyLink($this->params['viewDocumentLink'], $resultTheLine, $listKey); $content .= '
'; } //Show the rows (loop into columns) for($column = 0;$column < count($listColumn); $column++) { //If show column if($resultTheLine[$column]['show']==true) { $class =''; //Column content $columnValue = $this->_highlightWords($resultTheLine[$column]['value'], $this->whatSearch); //CSS if (isset($resultTheLine[$column]['class']) && !empty($resultTheLine[$column]['class']) ) { $class ='class="'.$resultTheLine[$column]['class'].'"'; } //Different background on ordered column (strpos($this->orderField, $resultTheLine[$column]['order']) !== false)? $columnStyle = ' style="background-image: url(static.php?filename=black_0.1.png);"' : $columnStyle = ''; //If there is action on line click if($this->params['bool_actionOnLineClick'] && isset($this->params['defaultAction']) && !empty($this->params['defaultAction']) && $lineIsDisabled === false ) { $content .= '
' .$columnValue.'
'; } else { $content .= '
' .$columnValue.'
'; } } } //Show action buttons for($button = 0; $button < count($this->actionButtons); $button++) { $actionIsDisabled = $this->_checkDisabledRules($this->actionButtons[$button]['disabledRules'], $resultTheLine); if ($actionIsDisabled) { $content .= ' '; } else { $content .= '
'; //Chceck type of action if(!isset($this->actionButtons[$button]['type']) or $this->actionButtons[$button]['type'] == 'standard') { //Standard icon $content .= $this->_createActionIcon($resultTheLine, $this->actionButtons[$button], $listKey); } else if($this->actionButtons[$button]['type'] == 'preview') { //View icon $content .= $this->_createActionIcon($resultTheLine, $this->actionButtons[$button], $listKey); } else if($this->actionButtons[$button]['type'] == 'switch') { //Switch icon //Switch rules to be ON $switchIsOn = $this->_checkDisabledRules($this->actionButtons[$button]['switchRules'], $resultTheLine); // if(isset($this->actionButtons[$button]['on']) && $switchIsOn) { //Switch ON $content .= $this->_createActionIcon($resultTheLine,$this->actionButtons[$button]['on'], $listKey); } else if(isset($this->actionButtons[$button]['off'])) { //Switch OFF $content .= $this->_createActionIcon($resultTheLine,$this->actionButtons[$button]['off'], $listKey); } } $content .= '
'; } } //Show details button if($this->params['bool_showIconDetails']) { $href = $this->_buildMyLink($this->params['viewDetailsLink'], $resultTheLine, $listKey); $content .= '
'; } //End of line $content .= ''; //Show sublist content (in another hidden line) if($this->params['bool_showSublist'] && !empty($this->params['sublistUrl'])){ $content .= '
'; } } $content .= ''; return $content; } public function showList($resultArray, $parameters=array(), $listKey='', $currentBasket=array()) { //Put in different arrays: label, show, sort of columns if (count($resultArray) > 0 && isset($resultArray[0])) { $listColumn = array(); $showColumn = array(); $sortColumn = array(); for ($j=0;$jparams = array(); $this->params = $parameters; $this->actionButtons = array(); $this->actionButtons = $parameters['actionIcons']; $this->divListId = $parameters['divListId']; $this->modeReturn = ($parameters['bool_modeReturn'] === true)? 'true' : 'false'; if(isset($parameters['height']) && !empty($parameters['height'])) $this->height = $parameters['height']; $this->formId = $parameters['formId']; $this->haveAction = false; $this->countResult = count($resultArray); if(count($currentBasket) > 0) $this->currentBasket = $currentBasket; if ((isset($this->params['collId']) && !empty($this->params['collId']))) { $this->collId = $this->params['collId']; } else if ((isset($currentBasket['coll_id']) && !empty($currentBasket['coll_id']))) { $this->collId = $currentBasket['coll_id']; } //Selected template or default template if(empty($this->template)) { if(isset($this->params['defaultTemplate']) && !empty($this->params['defaultTemplate'])) { $this->template = $this->params['defaultTemplate']; } } //Action par defaut if(isset($parameters['defaultAction']) && !empty($parameters['defaultAction'])) { $this->params['bool_actionOnLineClick'] = true; $this->haveAction = true; } //Standalone form if ($parameters['bool_standaloneForm'] === true) { $this->params['bool_actionOnLineClick'] = false; } //Page picto if(isset($parameters['pagePicto'])) $picto_path = ' '; //Top anchor $grid .= '
'; //Check ih there is a preview button before show preview div if ($this->_checkTypeOfActionIcon($this->actionButtons, 'preview') === true) { $grid .= $this->_createPreviewDiv(); } //Page title if(isset($parameters['pageTitle'])) { if($parameters['bool_bigPageTitle']) $grid .= '

'.$picto_path.$parameters['pageTitle'].'

'; else $grid .= ''.$picto_path.$parameters['pageTitle'].'
'; } //Actions list if(count($currentBasket) > 0) $this->_createActionsList($currentBasket); //Build page link $this->link = $this->_buildPageLink(); // $grid .= 'Link = '. $this->link.''; //debug //Search tools $grid .= $this->_displaySearchTools(); //Toolbar if ($this->params['bool_showSmallToolbar'] === false) { $grid .= $this->_createToolbar($resultArray[0]); } //Show bottom toolbar if ( $this->params['bool_showSmallToolbar'] === false && $this->params['bool_showBottomToolbar'] === true && $this->params['linesToShow'] > $_SESSION['config']['nblinetoshow'] && ( $this->countResult > $this->params['linesToShow'] || $this->countResult > $_SESSION['config']['nblinetoshow'] ) ) { $bottomToolbar = $this->_createBottomToolbar($resultArray[0]); } //If there some results if (count($resultArray) > 0 || $this->params['bool_showAddButton']) { //Need a form? $this->withForm = false; if( $this->params['bool_checkBox'] === true || $this->params['bool_radioButton'] === true || count($parameters['actions'] > 0) || count($parameters['buttons'] > 0) || !empty($parameters['defaultAction']) ) { //Need a form! $this->withForm = true; $B_form = $E_form = ''; //Extra javascript to handle form $grid.= $this->_createExtraJavascript(); //Build form $B_form .= '
'; $B_form .=''; //Get hidden fields $gridContent .= $this->_createHiddenFields(); //Actions (list or buttons) $E_form .= $this->_displayActionsList(); //End form $E_form .= '
'; } //Height $B_height = $E_height = ''; if(isset($parameters['listHeight']) && !empty($parameters['listHeight'])) { $B_height .= '
'; // $B_height .= '
'; $E_height .= '
'; } //Template mode if (!empty($this->template) && $this->template <> 'none') { //Build the grid from template $gridContent .= $this->_buildTemplate($_SESSION['html_templates'][$this->template]['PATH'], $resultArray, $listKey); //Build the list $grid .= $B_form . $B_height . $gridContent . $E_height . $E_form; //Normal mode } else { //Header $gridContent .= $this->_createHeader($resultArray[0], $listColumn, $showColumn, $sortColumn); //Content $gridContent.= $this->_createContent($resultArray, $listColumn, $listKey) ; //Build the list (!empty($this->params['listCss']))? $listCss = 'class="'.$this->params['listCss'].'"' : $listCss = ''; $grid .= $B_form . $B_height . '' . $gridContent . '
' . $E_height . $E_form. $bottomToolbar ; } //Process instructions if($this->params['bool_actionOnLineClick'] === true) $grid .= ''.$parameters['processInstructions'].''; } //Show the list if ($this->params['bool_modeReturn'] === true){ return $this->_parse($grid); } else { echo $this->_parse($grid); } } protected function _parse($text) { //... $text = str_replace("\r\n", "\n", $text); $text = str_replace("\r", "\n", $text); // $text = str_replace("\n", "\\n ", $text); return $text; } public function loadList($target, $showLoading=true, $divListId='divList', $returnMode = 'true', $init='true') { $list = "\n"; $loading =''; //Reset filters $this->_resetFilter(); //Reset html template list url $this->_resetUrlTemplates(); //Create javascript load list function $list .= ''; //Show loading image? if ($showLoading === true) { $loading = ''; } //Content div $list .= '
'.$loading.'
'; return $list; } public function loadList2($target, $showLoading=true, $divListId='divList', $returnMode = 'true', $init='true') { $list = "\n"; $loading =''; //Reset filters $this->_resetFilter2(); //Reset html template list url $this->_resetUrlTemplates(); //Create javascript load list function $list .= ''; //Show loading image? if ($showLoading === true) { $loading = ''; } //Content div $list .= '
'.$loading.'
'; return $list; } public function debug($viewAll=true) { $debug .='
';
        $debug .='Request:
'; $debug .= print_r($_REQUEST, true); $debug .='
Return mode: '.$this->modeReturn; $debug .='
Link: '.$this->link.'
'; $debug .='Have action: '.$this->haveAction.'
'; $debug .='With form: '.$this->withForm.'
'; $debug .='Selected template: '.$this->template.'
'; $debug .='Parameters:
'; $debug .= print_r($this->params, true); if ($viewAll) { $debug .='
Current basket:
'; $debug .= print_r($this->currentBasket, true); // $debug .='
Lists:
'; // $debug .= print_r($_SESSION['lists'], true); $debug .='
Filters:
'; $debug .= print_r($_SESSION['filters'], true); $debug .='
Filter clause: '.$this->getFilters().'
'; $debug .='Templates:
'; $debug .= print_r($_SESSION['html_templates'], true); } $debug .='
'; if ($this->params['bool_modeReturn']) { //Fix some json line breaks issues $debug = str_replace(chr(10), "", $debug); $debug = str_replace(chr(13), "", $debug); return $debug; } else { echo $debug; } } public function getLink() { return $this->link; } public function getStart() { return $this->start; } public function getOrder() { return $this->order; } public function getOrderField() { return $this->orderField; } public function setOrder($order='desc') { $this->order = $order; } public function setOrderField($field) { $this->orderField = $field; } public function getWhatSearch() { return $this->whatSearch; } public function getFilters() { $filtersClause = ''; $filtersArray = array(); foreach ($_SESSION['filters'] as $key => $val) { if (!empty($_SESSION['filters'][$key]['CLAUSE'])) { array_push($filtersArray, $_SESSION['filters'][$key]['CLAUSE']); } } if (count($filtersArray) > 0) $filtersClause .= '('.implode(' and ', $filtersArray).')'; //Build return $filtersClause; } public function getTemplate() { return $this->template; } public function setTemplate($template) { $this->template = $template; } public function setCollection($collId) { $this->collId = $collId; } }