";
}
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 = "
";
$sel_loc .= "filters['location'] ? 'selected' : '').">".htmlentities($msg['demandes_localisation_all'],ENT_QUOTES,$charset)." ";
while($loc = pmb_mysql_fetch_object($res_loc)){
$sel_loc .= "filters['location']==$loc->idlocation) ? 'selected' : '').">".htmlentities($loc->location_libelle,ENT_QUOTES,$charset)." ";
}
$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 .= "
";
}
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 "
";
}
}