id_demande); } protected function get_title() { global $msg, $charset; return "

".$msg['demandes_gestion']." : ".$msg['demandes_search_form']." ".($this->filters['state'] ? htmlentities(stripslashes($this->liste_etat[$this->filters['state']]['comment']),ENT_QUOTES, $charset) : "")."

"; } protected function get_form_title() { global $msg; return $msg['demandes_search_filtre_form']; } /** * Initialisation des filtres disponibles */ protected function init_available_filters() { global $pmb_lecteurs_localises; $this->available_filters = array('main_fields' => array( 'user_input' => 'demandes_titre', 'demandeur' => 'demandes_user_filtre', 'state' => 'demandes_etat_filtre', 'date' => 'demandes_periode_filtre', 'affectation' => 'demandes_affectation_filtre', 'theme' => 'demandes_theme_filtre', 'type' => 'demandes_type_filtre' ) ); if($pmb_lecteurs_localises) { $this->available_filters['main_fields']['location'] = 'demandes_localisation_filtre'; } $this->available_filters['custom_fields'] = array(); $this->add_custom_fields_available_filters('demandes', 'id_demande'); } /** * Initialisation des filtres de recherche */ public function init_filters($filters=array()) { global $pmb_lecteurs_localises; $this->filters = array( 'user_input' => '', 'demandeur' => '', 'state' => 0, 'date_start' => '', 'date_end' => '', 'affectation' => 0, 'theme' => 0, 'type' => 0, 'type_action' => 0, 'statut_action' => array(), 'num_user' => 0, 'id_demande' => 0 ); if($pmb_lecteurs_localises || array_key_exists('location', $this->selected_filters)) { $this->filters['location'] = 0; } parent::init_filters($filters); } protected function init_default_selected_filters() { global $pmb_lecteurs_localises; $this->add_selected_filter('user_input'); $this->add_empty_selected_filter(); $this->add_empty_selected_filter(); $this->add_selected_filter('demandeur'); $this->add_selected_filter('state'); $this->add_selected_filter('date'); $this->add_selected_filter('affectation'); $this->add_selected_filter('theme'); $this->add_selected_filter('type'); if($pmb_lecteurs_localises) { $this->add_selected_filter('location'); } if(count($this->available_filters['custom_fields'])) { foreach ($this->available_filters['custom_fields'] as $property=>$label) { $this->add_selected_filter($property, $label); } } } protected function init_default_applied_sort() { $this->add_applied_sort('date_demande', 'desc'); } /** * Initialisation des colonnes disponibles */ protected function init_available_columns() { $this->available_columns = array('main_fields' => array( 'see' => '210', 'theme_demande' => 'demandes_theme', 'type_demande' => 'demandes_type', 'titre_demande' => 'demandes_titre', 'etat_demande' => 'demandes_etat', 'date_demande' => 'demandes_date_dmde', 'date_prevue' => 'demandes_date_prevue', 'deadline_demande' => 'demandes_date_butoir', 'demandeur' => 'demandes_demandeur', 'attribution' => 'demandes_attribution', 'progression' => 'demandes_progression', 'record' => 'demandes_notice' ) ); $this->available_columns['custom_fields'] = array(); $this->add_custom_fields_available_columns('demandes', 'id_demande'); } protected function add_column_more_details() { $this->columns[] = array( 'property' => '', 'label' => "", 'html' => "", 'exportable' => false ); } protected function get_display_html_content_selection() { return "
"; } protected function init_default_columns() { $this->add_column_more_details(); $this->add_column('see'); $this->add_column('theme_demande'); $this->add_column('type_demande'); $this->add_column('titre_demande'); $this->add_column('etat_demande'); $this->add_column('date_demande'); $this->add_column('date_prevue'); $this->add_column('deadline_demande'); $this->add_column('demandeur'); $this->add_column('attribution'); $this->add_column('progression'); if(count($this->available_columns['custom_fields'])) { foreach ($this->available_columns['custom_fields'] as $property=>$label) { $this->add_column($property, $label); } } $this->add_column('record'); $this->add_column_selection(); } protected function init_default_settings() { parent::init_default_settings(); $this->set_setting_display('search_form', 'export_icons', false); } public function get_display_list() { global $msg; $display = parent::get_display_list(); $display .= " "; return $display; } public function get_error_message_empty_list() { global $msg, $charset; return htmlentities($msg["demandes_liste_vide"], ENT_QUOTES, $charset); } protected function get_selection_actions() { global $msg; //TODO : Revoir les actions if(!isset($this->selection_actions)) { $this->selection_actions = array(); //afficher la liste des boutons de changement d'état if($this->filters['state']){ $states = $this->get_demandes()->workflow->getStateList($this->filters['state']); for($i=0;$i static::get_controller_url_base()."&act=change_state&state=".$states[$i]['id'], ); $this->selection_actions[] = $this->get_selection_action('state_'.$states[$i]['id'], $states[$i]['comment'], '', $state_link); } } if($this->filters['affectation'] == -1){ $affectation_link = array( 'href' => static::get_controller_url_base()."&act=affecter", ); // $affectation_btn = " ".$this->getUsersSelector(); $this->selection_actions[] = $this->get_selection_action('affectation', $msg['demandes_attribution_checked'], '', $affectation_link); } /* Ajouté dans other_actions pour le décalage à droite * * $delete_link = array( 'href' => static::get_controller_url_base()."&act=suppr_noti", 'confirm' => $msg['demandes_confirm_suppr'] ); $this->selection_actions[] = $this->get_selection_action('delete', $msg['63'], 'interdit.gif', $delete_link); */ } return $this->selection_actions; } protected function get_display_selection_action($action) { $display = parent::get_display_selection_action($action); if($action['name'] == 'affectation') { $display .= " ".$this->get_demandes()->getUsersSelector(); } return $display; } protected function get_display_others_actions() { global $msg; return "
"; } protected function get_selection_mode() { return 'button'; } protected function get_name_selected_objects() { return "chk"; } protected function init_no_sortable_columns() { $this->no_sortable_columns = array( 'see' ); } /** * Filtres provenant du formulaire */ public function set_filters_from_form() { global $user_input; global $idetat, $idempr, $date_debut,$date_fin; global $iduser, $id_type, $id_theme; global $dmde_loc; if(isset($user_input)) { $this->filters['user_input'] = stripslashes($user_input); } if(isset($idetat)) { $this->filters['state'] = intval($idetat); } if(isset($idempr)) { $this->filters['demandeur'] = intval($idempr); } if(isset($date_debut)) { $this->filters['date_start'] = $date_debut; } if(isset($date_fin)) { $this->filters['date_end'] = $date_fin; } if(isset($iduser)) { $this->filters['affectation'] = intval($iduser); } if(isset($id_type)) { $this->filters['type'] = intval($id_type); } if(isset($id_theme)) { $this->filters['theme'] = intval($id_theme); } if(isset($dmde_loc)) { $this->filters['location'] = intval($dmde_loc); } parent::set_filters_from_form(); } protected function get_search_filter_user_input() { global $charset; return ""; } protected function get_search_filter_demandeur() { global $charset; global $pmb_lecteurs_localises; return " get_form_name()."¶m1=idempr¶m2=empr_txt&deb_rech='+".pmb_escape()."(this.form.empr_txt.value)+'&filtre=ONLY_EMPR&callback=filtrer_user".($pmb_lecteurs_localises ? "&empr_loca='+this.form.dmde_loc.value": "'").", 'selector')\" /> "; } protected function get_search_filter_state() { return $this->get_demandes()->getStateSelector($this->filters['state'],'',true); } protected function get_search_filter_date() { global $msg; //Formulaire des filtres $date_deb=""; $date_but=""; return sprintf($msg['demandes_filtre_periode_lib'],$date_deb,$date_but); } protected function get_search_filter_affectation() { return $this->get_demandes()->getUsersSelector('',true,false,true); } protected function get_search_filter_theme() { $themes = new demandes_themes('demandes_theme','id_theme','libelle_theme',$this->filters['theme']); return $themes->getListSelector($this->filters['theme'],'',true); } protected function get_search_filter_type() { $types = new demandes_types('demandes_type','id_type','libelle_type',$this->filters['type']); return $types->getListSelector($this->filters['type'],'',true); } protected function get_search_filter_location() { global $msg, $charset; $req_loc = "select idlocation, location_libelle from docs_location"; $res_loc = pmb_mysql_query($req_loc); $sel_loc = ""; return $sel_loc; } /** * Affichage du formulaire de recherche */ public function get_display_search_form() { $this->is_displayed_add_filters_block = false; $display_search_form = parent::get_display_search_form(); return $display_search_form; } /** * Jointure externes SQL pour les besoins des filtres */ protected function _get_query_join_filters() { $filter_join_query = ''; if($this->filters['location']) { $filter_join_query .= " left join empr on (num_demandeur=id_empr) "; } return $filter_join_query; } /** * Filtre SQL */ protected function _get_query_filters() { $filter_query = ''; $this->set_filters_from_form(); $filters = array(); if($this->filters['user_input']) { $user_input = str_replace('*','%',$this->filters['user_input']); $filters [] = "titre_demande like '%".$user_input."%'"; } if($this->filters['demandeur']) { $filters [] = 'num_demandeur = "'.$this->filters['demandeur'].'"'; } if($this->filters['state']) { $filters [] = 'etat_demande = "'.$this->filters['state'].'"'; } //Filtre date if($this->filters['date_start']<$this->filters['date_end']){ $filters [] = "(date_demande >= '".$this->filters['date_start']."' and deadline_demande <= '".$this->filters['date_end']."' )"; } if($this->filters['theme']) { $filters [] = 'theme_demande = "'.$this->filters['theme'].'"'; } if($this->filters['type']) { $filters [] = 'type_demande = "'.$this->filters['type'].'"'; } if($this->filters['location']) { $filters [] = 'empr_location = "'.$this->filters['location'].'"'; } if($this->filters['type_action']) { $filters [] = 'type_action = "'.$this->filters['type_action'].'"'; } if(!empty($this->filters['statut_action'])) { $filters [] = 'statut_action IN ('.implode(',', $this->filters['statut_action']).')'; } if($this->filters['num_user']) { $filters [] = 'num_user = "'.$this->filters['num_user'].'"'; } if($this->filters['id_demande']) { $filters [] = 'id_demande = "'.$this->filters['id_demande'].'"'; } if(count($filters)) { $filter_query .= $this->_get_query_join_filters(); $filter_query .= ' where '.implode(' and ', $filters); } return $filter_query; } /** * Fonction de callback * @param object $a * @param object $b */ protected function _compare_objects($a, $b) { if($this->applied_sort[0]['by']) { $sort_by = $this->applied_sort[0]['by']; switch($sort_by) { case 'theme_demande': return strcmp($this->get_themes()->getLabel($a->{$sort_by}), $this->get_themes()->getLabel($b->{$sort_by})); break; case 'type_demande': return strcmp($this->get_types()->getLabel($a->{$sort_by}), $this->get_types()->getLabel($b->{$sort_by})); break; case 'etat_demande': return strcmp($a->workflow->getStateCommentById($a->etat_demande), $b->workflow->getStateCommentById($b->etat_demande)); break; case 'demandeur': return strcmp(emprunteur::get_name($a->num_demandeur, 1), emprunteur::get_name($b->num_demandeur, 1)); break; case 'attribution': // return; break; default : return parent::_compare_objects($a, $b); break; } } } protected function get_grouped_label($object, $property) { global $msg; $grouped_label = ''; switch($property) { default: $grouped_label = parent::get_grouped_label($object, $property); break; } return $grouped_label; } /** * Construction dynamique de la fonction JS de tri */ protected function get_js_sort_script_sort() { $display = parent::get_js_sort_script_sort(); $display = str_replace('!!categ!!', 'dmde', $display); $display = str_replace('!!sub!!', '', $display); $display = str_replace('!!action!!', 'list', $display); return $display; } protected function get_cell_content($object, $property) { global $msg, $charset; $content = ''; switch($property) { case 'see': if($object->dmde_read_gestion == 1){ // remplacer $action le jour où on décide d'activer la modif d'état manuellement par onclick=\"change_read_dmde('dmde".$dmde->id_demande."','$dmde->id_demande', true); return false;\" $content .= "get_gestion_link()."'\" id=\"dmde".$object->id_demande."Img1\" class=\"img_plus\" src='".get_url_icon('notification_empty.png')."' style='display:none'> get_gestion_link()."'\" id=\"dmde".$object->id_demande."Img2\" class=\"img_plus\" src='".get_url_icon('notification_new.png')."'>"; } else { // remplacer $action le jour où on décide d'activer la modif d'état manuellement par onclick=\"change_read_dmde('dmde".$dmde->id_demande."','$dmde->id_demande', true); return false;\" $content .= "get_gestion_link()."'\" id=\"dmde".$object->id_demande."Img1\" class=\"img_plus\" src='".get_url_icon('notification_empty.png')."' > get_gestion_link()."'\" id=\"dmde".$object->id_demande."Img2\" class=\"img_plus\" src='".get_url_icon('notification_new.png')."' style='display:none'>"; } break; case 'theme_demande': $content .= $this->get_themes()->getLabel($object->theme_demande); break; case 'type_demande': $content .= $this->get_types()->getLabel($object->type_demande); break; case 'etat_demande': $content .= $object->workflow->getStateCommentById($object->etat_demande); break; case 'date_demande': case 'date_prevue': case 'deadline_demande': $content .= formatdate($object->{$property}); break; case 'demandeur': $content .= emprunteur::get_name($object->num_demandeur, 1); break; case 'attribution': $nom_user = ''; if (!empty($object->users)) { foreach ($object->users as $user) { if ($user['statut'] == 1) { if (!empty($nom_user)) { $nom_user .= "/ "; } $nom_user .= $user['nom']; } } } $content .= $nom_user; break; case 'progression': $content .= " progression."%\" title='".$object->progression."%' /> "; break; case 'record': if($object->get_num_linked_notice()) { $content .= "".htmlentities($msg["; } break; default : $content .= parent::get_cell_content($object, $property); break; } return $content; } protected function get_display_content_object_list($object, $indice) { if(static::class == 'list_demandes_ui') { // affichage en gras si nouveauté du côté des notes ou des actions $object->dmde_read_gestion = demandes::dmde_majRead($object->id_demande,"_gestion"); if($object->dmde_read_gestion == 1){ $style=" style='cursor: pointer; font-weight:bold'"; } else { $style=" style='cursor: pointer'"; } $display = " "; foreach ($this->columns as $column) { if($column['html']) { $display .= $this->get_display_cell_html_value($object, $column['html']); } else { $display .= $this->get_display_cell($object, $column['property']); } } $display .= ""; //Le détail de l'action, contient les notes $display .="id_demande."Child\" style=\"display:none\"> columns))."\" id=\"action".$object->id_demande."ChildTd\">"; $display .=" "; return $display; } else { return parent::get_display_content_object_list($object, $indice); } } protected function _get_query_human() { global $msg; return "

".$msg['demandes_liste']." (".$this->pager['nb_results'].")

"; } public function get_demandes() { if(!isset($this->demandes)) { $this->demandes = new demandes(); } return $this->demandes; } public function get_themes() { if(!isset($this->themes)) { $this->themes = new demandes_themes('demandes_theme','id_theme','libelle_theme',$this->filters['theme']); } return $this->themes; } public function get_types() { if(!isset($this->types)) { $this->types = new demandes_types('demandes_type','id_type','libelle_type',$this->filters['type']); } return $this->types; } protected function get_button_add() { global $msg, $charset; return ""; } }