id_empr); } /** * Initialisation des filtres disponibles */ protected function init_available_filters() { global $pmb_lecteurs_localises; if(!empty(static::$used_filter_list_mode)) { $this->available_filters = array(); $this->available_filters['main_fields'] = array(); //Ajout des champs fixes en tant que filtres disponibles foreach (static::$filter_list->fixedfields as $fixedfield) { //est-ce que le champ est filtrable if ($fixedfield["FILTERABLE"]=="yes") { if(!empty(static::$correspondence_filters_fields['main_fields'][$fixedfield["VALUE"]])) { $correspondence_filter = static::$correspondence_filters_fields['main_fields'][$fixedfield["VALUE"]]; } else { $correspondence_filter = $fixedfield["VALUE"]; } $this->available_filters['main_fields'][$correspondence_filter] = get_msg_to_display($fixedfield["NAME"]); } } //Ajout des champs spéciaux en tant que filtres disponibles foreach (static::$filter_list->specialfields as $specialfield) { if(!empty(static::$correspondence_filters_fields['main_fields'][$specialfield["ID"]])) { $correspondence_filter = static::$correspondence_filters_fields['main_fields'][$specialfield["ID"]]; } else { $correspondence_filter = $specialfield["ID"]; } $this->available_filters['main_fields'][$correspondence_filter] = get_msg_to_display($specialfield["NAME"]); } } else { $this->available_filters = array('main_fields' => array( 'simple_search' => '34', 'categorie' => 'editions_filter_empr_categ', 'categories' => 'dsi_ban_form_categ_lect', 'groups' => 'dsi_ban_form_groupe_lect', 'name' => 'dsi_ban_abo_empr_nom', 'has_mail' => 'dsi_ban_abo_mail', 'has_affected' => 'dsi_ban_lecteurs_affectes', 'mail' => 'email', 'codestat_one' => 'editions_filter_empr_codestat', 'codestat' => '24', 'status' => 'statut_empr', 'date_adhesion' => 'empr_date_adhesion', 'date_expiration' => 'readerlist_dateexpiration', 'date_creation' => 'date_creation_query', 'cp' => 'acquisition_cp', 'villes' => 'ville_empr', 'birth_dates' => 'year_empr', 'caddies' => 'caddie_de_EMPR' ) ); if($pmb_lecteurs_localises) { $this->available_filters['main_fields']['location'] = 'editions_filter_empr_location'; $this->available_filters['main_fields']['locations'] = '21'; } } $this->available_filters['custom_fields'] = array(); $this->add_custom_fields_available_filters('empr', 'id_empr'); } /** * Initialisation des filtres de recherche */ public function init_filters($filters=array()) { global $pmb_lecteurs_localises, $deflt2docs_location; $this->filters = array( 'simple_search' => '', 'empr_statut_edit' => '', 'empr_categ_filter' => '', 'empr_codestat_filter' => '', 'group' => '', 'status' => array(), 'categories' => array(), 'codestat' => array(), 'groups' => array(), 'name' => '', 'mail' => '', 'has_mail' => 0, 'has_affected' => 0, 'date_creation_start' => '', 'date_creation_end' => '', 'date_adhesion_start' => '', 'date_adhesion_end' => '', 'date_expiration_start' => '', 'date_expiration_end' => '', 'date_expiration_limit' => '', 'change_categ' => '', 'cp' => array(), 'villes' => array(), 'birth_dates' => array(), 'supposed_level' => array(), 'last_level_validated' => array(), 'types_abts' => array(), 'caddies' => array(), 'empr_ids' => array(), 'expl_locations' => array(), ); if(static::class == 'list_readers_bannette_ui' || static::class == 'list_readers_relances_ui') { $this->filters['empr_location_id'] = ''; $this->filters['locations'] = ($pmb_lecteurs_localises ? array($deflt2docs_location) : array()); } else { $this->filters['empr_location_id'] = ($pmb_lecteurs_localises ? $deflt2docs_location : ''); $this->filters['locations'] = array(); } parent::init_filters($filters); if(!empty(static::$used_filter_list_mode)) { $initialization = $this->objects_type.'_initialization'; global ${$initialization}; if(isset(${$initialization}) && ${$initialization} == 'reset') { $from_initialization = true; } else { $from_initialization = false; } static::set_filter_list_from_filters_ui($this->filters, $from_initialization); if (!static::$filter_list->error) { //Permet de regénérer la globale $all_level (relance::filter_niveau) static::$display_filters = static::$filter_list->display_filters(); } } } /** * Initialisation des colonnes disponibles */ protected function init_available_columns() { global $empr_show_caddie, $sub; if(!empty(static::$used_filter_list_mode)) { $this->available_columns = array(); $this->available_columns['main_fields'] = array(); //Ajout des champs fixes en tant que filtres disponibles foreach (static::$filter_list->fixedfields as $fixedfield) { if(!empty(static::$correspondence_columns_fields['main_fields'][$fixedfield["VALUE"]])) { $correspondence_column = static::$correspondence_columns_fields['main_fields'][$fixedfield["VALUE"]]; } else { $correspondence_column = $fixedfield["VALUE"]; } $this->available_columns['main_fields'][$correspondence_column] = get_msg_to_display($fixedfield["NAME"]); } //Ajout des champs spéciaux en tant que filtres disponibles foreach (static::$filter_list->specialfields as $specialfield) { if(!empty(static::$correspondence_columns_fields['main_fields'][$specialfield["ID"]])) { $correspondence_column = static::$correspondence_columns_fields['main_fields'][$specialfield["ID"]]; } else { $correspondence_column = $specialfield["ID"]; } $this->available_columns['main_fields'][$correspondence_column] = get_msg_to_display($specialfield["NAME"]); } } else { $this->available_columns = array('main_fields' => array( 'id' => '1601', 'cb' => 'code_barre_empr', 'empr_name' => 'nom_prenom_empr', 'adr1' => 'adresse_empr', 'cp' => 'acquisition_cp', 'ville' => 'ville_empr', 'birth' => 'year_empr', 'mail' => 'email', 'aff_date_adhesion' => 'empr_date_adhesion', 'aff_date_expiration' => 'readerlist_dateexpiration', 'empr_statut_libelle' => 'statut_empr', 'categ_libelle' => 'categ_empr', 'codestat_libelle' => 'codestat_empr', 'relance' => 'relance_imprime', 'location' => 'localisation_sort', 'groups' => 'groupe_empr', 'nb_loans' => 'empr_nb_pret', 'add_empr_cart' => 'add_empr_cart', 'type_abt' => 'type_abt_empr', 'tel1' => '73', 'tel2' => '73tel2', 'nb_resas_and_validated' => 'groupes_nb_resa_dont_valides' ) ); } if ($empr_show_caddie) { $this->available_columns['main_fields']['add_empr_cart'] = 'add_empr_cart'; } if(get_called_class() == 'list_readers_edition_ui' && $sub == 'categ_change') { $this->available_columns['main_fields']['categ_change'] = 'empr_categ_change_prochain'; } $this->available_columns['custom_fields'] = array(); $this->add_custom_fields_available_columns('empr', 'id'); } protected function init_default_settings() { parent::init_default_settings(); $this->set_setting_column('cb', 'text', array('bold' => true)); } protected function init_default_selected_filters() { if(!empty(static::$used_filter_list_mode)) { if(empty($this->selected_filters)) { $this->selected_filters = array(); } $filtercolumns = explode(",",static::$filter_list->filtercolumns); foreach ($filtercolumns as $filtercolumn) { if(substr($filtercolumn,0,2) == "#e") { $parametres_perso = $this->get_custom_parameters_instance('empr'); $custom_name = $parametres_perso->get_field_name_from_id(substr($filtercolumn,2)); $this->add_selected_filter($custom_name); } elseif(substr($filtercolumn,0,2) == "#p") { $parametres_perso = $this->get_custom_parameters_instance('pret'); $custom_name = $parametres_perso->get_field_name_from_id(substr($filtercolumn,2)); $this->add_selected_filter($custom_name); } else { $this->add_selected_filter(static::$correspondence_filters_fields['main_fields'][$filtercolumn]); } } } else { parent::init_default_selected_filters(); } } protected function init_no_sortable_columns() { $this->no_sortable_columns = array( 'add_empr_cart', ); } /** * Initialisation de la pagination par défaut */ protected function init_default_pager() { global $nb_per_page_empr; parent::init_default_pager(); $this->pager['nb_per_page'] = ($nb_per_page_empr ? $nb_per_page_empr : 10); } /** * Initialisation du tri par défaut appliqué */ protected function init_default_applied_sort() { if(!empty(static::$used_filter_list_mode)) { $sortablecolumns = explode(",", static::$filter_list->sortablecolumns); foreach ($sortablecolumns as $sortcolumn) { $fixedfield = static::$filter_list->fixedfields[$sortcolumn]; //est-ce que le champ est triable if ($fixedfield["SORTABLE"]=="yes") { if(!empty(static::$correspondence_columns_fields['main_fields'][$fixedfield["VALUE"]])) { $correspondence_column = static::$correspondence_columns_fields['main_fields'][$fixedfield["VALUE"]]; } else { $correspondence_column = $fixedfield["VALUE"]; } $this->add_applied_sort($correspondence_column); } } } else { $this->add_applied_sort('empr_name'); } } /** * Tri SQL */ protected function _get_query_order() { if($this->applied_sort[0]['by']) { $order = ''; $sort_by = $this->applied_sort[0]['by']; switch($sort_by) { case 'id': $order .= 'id_empr'; break; case 'empr_name' : $order .= 'empr_nom, empr_prenom'; break; case 'cb': $order .= 'empr_cb'; break; case 'adr1': $order .= 'empr_adr1'; break; case 'ville': $order .= 'empr_ville'; break; case 'birth': $order .= 'empr_year'; break; case 'mail': $order .= 'empr_mail'; break; case 'tel1': $order .= 'empr_tel1'; break; case 'tel2': $order .= 'empr_tel2'; break; case 'aff_date_adhesion': $order .= 'empr_date_adhesion'; break; case 'aff_date_expiration': $order .= 'empr_date_expiration'; break; case 'empr_statut_libelle': $order .= 'empr_statut.statut_libelle'; break; case 'categ_libelle': $order .= 'empr_categ.libelle'; break; case 'codestat_libelle': $order .= 'empr_codestat.libelle'; break; case 'location': $order .= 'docs_location.location_libelle'; break; default : $order .= parent::_get_query_order(); break; } if($order) { return $this->_get_query_order_sql_build($order); } else { return ""; } } } protected function set_filters_from_filter_list() { if(!empty(static::$filter_list)) { $filtercolumns = explode(",",static::$filter_list->filtercolumns); foreach ($filtercolumns as $filtercolumn) { if(substr($filtercolumn,0,2) == "#e") { $parametres_perso = $this->get_custom_parameters_instance('empr'); $custom_name = $parametres_perso->get_field_name_from_id(substr($filtercolumn,2)); $valeurs_post="f".$custom_name; $v=array(); global ${$valeurs_post}; if (${$valeurs_post}) $v=${$valeurs_post}; $t=array(); if(!empty($parametres_perso->t_fields[substr($filtercolumn,2)]['OPTIONS'][0]['UNSELECT_ITEM'][0]['VALUE'])) { $t[0]=$parametres_perso->t_fields[substr($filtercolumn,2)]['OPTIONS'][0]['UNSELECT_ITEM'][0]['VALUE']; } $w=array_diff($v,$t); $this->filters["#custom_field#".$custom_name] = array(); if (count($w)) { $this->filters["#custom_field#".$custom_name] = stripslashes_array($w); } } elseif(substr($filtercolumn,0,2) == "#p") { $parametres_perso = $this->get_custom_parameters_instance('pret'); $custom_name = $parametres_perso->get_field_name_from_id(substr($filtercolumn,2)); $valeurs_post="f".$custom_name; $v=array(); global ${$valeurs_post}; if (${$valeurs_post}) $v=${$valeurs_post}; $t=array(); if(!empty($parametres_perso->t_fields[substr($filtercolumn,2)]['OPTIONS'][0]['UNSELECT_ITEM'][0]['VALUE'])) { $t[0]=$parametres_perso->t_fields[substr($filtercolumn,2)]['OPTIONS'][0]['UNSELECT_ITEM'][0]['VALUE']; } $w=array_diff($v,$t); $this->filters["#custom_field#".$custom_name] = array(); if (count($w)) { $this->filters["#custom_field#".$custom_name] = stripslashes_array($w); } } elseif (array_key_exists($filtercolumn, static::$filter_list->fixedfields)) { $nom_valeurs_post="f".static::$filter_list->fixedfields[$filtercolumn]["ID"]; $valeurs_post=array(); global ${$nom_valeurs_post}; $valeurs_post=${$nom_valeurs_post}; $correspondence_filter = static::$correspondence_filters_fields['main_fields'][$filtercolumn]; $this->filters[$correspondence_filter] = array(); if (is_array($valeurs_post)) { $t=array(); $t[0]=-1; $v=array_diff($valeurs_post,$t); if (count($v)) { $this->filters[$correspondence_filter] = stripslashes_array($v); } } } else { $nom_valeurs_post="f".static::$filter_list->specialfields[$filtercolumn]["ID"]; $valeurs_post=array(); global ${$nom_valeurs_post}; $valeurs_post=${$nom_valeurs_post}; $correspondence_filter = static::$correspondence_filters_fields['main_fields'][$filtercolumn]; $this->filters[$correspondence_filter] = array(); if (is_array($valeurs_post)) { $t=array(); $t[0]=-1; $v=array_diff($valeurs_post,$t); if (count($v)) { $this->filters[$correspondence_filter] = stripslashes_array($v); } } } } } } /** * Filtres provenant du formulaire */ public function set_filters_from_form() { global $empr_location_id; global $empr_statut_edit; global $empr_categ_filter; global $empr_codestat_filter; if(isset($empr_location_id)) { $this->filters['empr_location_id'] = $empr_location_id*1; } if(isset($empr_statut_edit)) { $this->filters['empr_statut_edit'] = $empr_statut_edit*1; } if(isset($empr_categ_filter)) { $this->filters['empr_categ_filter'] = $empr_categ_filter*1; } if(isset($empr_codestat_filter)) { $this->filters['empr_codestat_filter'] = $empr_codestat_filter*1; } $this->set_filter_from_form('group', 'integer'); $this->set_filter_from_form('locations'); $this->set_filter_from_form('categories'); $this->set_filter_from_form('status'); $this->set_filter_from_form('codestat'); $this->set_filter_from_form('groups'); $this->set_filter_from_form('simple_search'); $this->set_filter_from_form('name'); $this->set_filter_from_form('mail'); $this->set_filter_from_form('has_mail'); $this->set_filter_from_form('has_affected'); $this->set_filter_from_form('date_creation_start'); $this->set_filter_from_form('date_creation_end'); $this->set_filter_from_form('date_adhesion_start'); $this->set_filter_from_form('date_adhesion_end'); $this->set_filter_from_form('date_expiration_start'); $this->set_filter_from_form('date_expiration_end'); $this->set_filter_from_form('cp'); $this->set_filter_from_form('villes'); $this->set_filter_from_form('birth_dates'); $this->set_filter_from_form('types_abts'); $this->set_filter_from_form('caddies'); //Filtres provenant de la classe filter_list if(!empty(static::$used_filter_list_mode)) { $this->set_filters_from_filter_list(); } parent::set_filters_from_form(); } protected function get_selector_query($type) { $query = ''; switch ($type) { case 'categories': $query = 'select id_categ_empr as id, libelle as label from empr_categ order by label'; break; case 'status': $query = 'select idstatut as id, statut_libelle as label from empr_statut order by label'; break; case 'groups': $query = 'select id_groupe as id, libelle_groupe as label from groupe order by label'; break; case 'locations': $query = 'select idlocation as id, location_libelle as label from docs_location order by label'; break; case 'codestat': $query = 'select idcode as id, libelle as label from empr_codestat order by label'; break; case 'villes': $query = 'select empr_ville as id, empr_ville as label from empr group by empr_ville order by empr_ville'; break; case 'cp': $query = 'select empr_cp as id, empr_cp as label from empr group by empr_cp order by empr_cp'; break; case 'birth_dates': $query = 'select empr_year as id, empr_year as label from empr group by empr_year order by empr_year'; break; case 'types_abts': $query = 'select id_type_abt as id, type_abt_libelle as label from type_abts order by label'; break; } return $query; } protected function get_search_filter_simple_search() { global $msg, $charset; return "filters['simple_search'], ENT_QUOTES, $charset)."\" title='$msg[3000]'/>"; } protected function get_search_filter_categorie() { return emprunteur::gen_combo_box_categ($this->filters['empr_categ_filter']); } protected function get_search_filter_categories() { global $msg; return $this->get_multiple_selector($this->get_selector_query('categories'), 'categories', $msg['dsi_all_categories']); } protected function get_search_filter_groups() { global $msg; return $this->get_multiple_selector($this->get_selector_query('groups'), 'groups', $msg['dsi_all_groups']); } protected function get_search_filter_location() { return docs_location::gen_combo_box_empr($this->filters['empr_location_id']); } protected function get_search_filter_locations() { global $msg; return $this->get_multiple_selector($this->get_selector_query('locations'), 'locations', $msg['all_location']); } protected function get_search_filter_codestat_one() { return emprunteur::gen_combo_box_codestat($this->filters['empr_codestat_filter']); } protected function get_search_filter_codestat() { global $msg; return $this->get_multiple_selector($this->get_selector_query('codestat'), 'codestat', $msg['all_codestat_empr']); } protected function get_search_filter_status() { global $msg; return gen_liste($this->get_selector_query('status'),"id","label","empr_statut_edit","",$this->filters['empr_statut_edit'],-1,"",0,$msg["all_statuts_empr"]); } protected function get_search_filter_name() { global $msg, $charset; return "filters['name'], ENT_QUOTES, $charset)."\" title='$msg[3000]'/>"; } protected function get_search_filter_has_mail() { global $msg, $charset; return " filters['has_mail'] ? "checked='checked'" : "")." /> filters['has_mail'] ? "checked='checked'" : "")." /> "; } protected function get_search_filter_mail() { global $charset; return "filters['mail'], ENT_QUOTES, $charset)."\" />"; } protected function get_search_filter_date_creation() { return $this->get_search_filter_interval_date('date_creation'); } protected function get_search_filter_date_adhesion() { return $this->get_search_filter_interval_date('date_adhesion'); } protected function get_search_filter_date_expiration() { return $this->get_search_filter_interval_date('date_expiration'); } protected function get_search_filter_villes() { global $msg; return $this->get_multiple_selector($this->get_selector_query('villes'), 'villes', $msg['all_cities_empr']); } protected function get_search_filter_cp() { global $msg; return $this->get_multiple_selector($this->get_selector_query('cp'), 'cp', $msg['all_cp_empr']); } protected function get_search_filter_birth_dates() { global $msg; return $this->get_multiple_selector($this->get_selector_query('birth_dates'), 'birth_dates', $msg['all_years_empr']); } protected function get_search_filter_abts_types() { global $msg; return $this->get_multiple_selector($this->get_selector_query('abts_types'), 'abts_types', $msg['all_type_abt_empr']); } protected function get_search_filter_caddies() { global $msg, $PMBuserid; $query = "SELECT idemprcaddie, name, empr_caddie_classement FROM empr_caddie where 1 "; if ($PMBuserid!=1) $query.=" and (autorisations='$PMBuserid' or autorisations like '$PMBuserid %' or autorisations like '% $PMBuserid %' or autorisations like '% $PMBuserid') "; $query.=" ORDER BY empr_caddie_classement, name "; return gen_liste_multiple ($query, "idemprcaddie", "name", "", $this->objects_type.'_caddies[]', "", $this->filters['caddies'], 0, $msg['dsi_panier_aucun'], 0,'', 5, 'empr_caddie_classement'); } /** * Affichage des filtres du formulaire de recherche */ public function get_search_filters_form() { $search_filters_form = ''; if(!empty(static::$used_filter_list_mode)) { $this->is_displayed_add_filters_block = false; if (!static::$filter_list->error) { if(empty(static::$display_filters)) { static::$display_filters = static::$filter_list->display_filters(); } $search_filters_form .= static::$display_filters; } } else { $search_filters_form .= parent::get_search_filters_form(); } return $search_filters_form; } /** * Affichage du formulaire de recherche */ public function get_display_search_form() { if(get_called_class() != 'list_readers_circ_ui') { if(!isset($this->is_displayed_options_block)) { $this->is_displayed_options_block = true; } } if(get_called_class() == 'list_readers_bannette_ui' || get_called_class() == 'list_readers_bannettes_ui') { $this->is_displayed_datasets_block = true; } if(get_called_class() == 'list_readers_bannettes_ui') { $this->is_displayed_add_filters_block = true; } $display_search_form = parent::get_display_search_form(); return $display_search_form; } protected function get_selection_actions() { global $msg; global $base_path; global $empr_show_caddie; global $sub; if(!isset($this->selection_actions)) { $this->selection_actions = array(); if ($empr_show_caddie) { $link = array(); $link['openPopUp'] = $base_path."/cart.php?object_type=EMPR&action=add_empr".($sub ? "_".$sub : ""); $link['openPopUpTitle'] = 'cart'; $this->selection_actions[] = $this->get_selection_action('caddie', $msg['add_empr_cart'], 'basket_20x20.gif', $link); } } return $this->selection_actions; } /** * Jointure externes SQL pour les besoins des filtres */ protected function _get_query_join_filters() { $filter_join_query = ''; if((is_array($this->filters['groups']) && count($this->filters['groups'])) || !empty($this->filters['group'])) { $filter_join_query .= " LEFT JOIN empr_groupe ON empr.id_empr=empr_groupe.empr_id"; } if(is_array($this->filters['caddies']) && count($this->filters['caddies'])) { $filter_join_query .= " LEFT JOIN empr_caddie_content ON empr_caddie_content.object_id=empr.id_empr"; } if($this->filters['has_affected']) { $filter_join_query .= $this->_get_query_join_filter_affected(); } return $filter_join_query; } /** * Filtre SQL */ protected function _get_query_filters() { global $pmb_lecteurs_localises; $filter_query = ''; $this->set_filters_from_form(); $filters = array(); if(!empty($this->filters['simple_search'])) { $elts = explode(' ', $this->filters['simple_search']); if(count($elts)>1) { $sql_elts = array(); foreach ($elts as $elt) { $elt = str_replace("*", "%", trim($elt)); if($elt) { $sql_elts[] = "(empr_nom like '".$elt."%' OR empr_nom like '% ".$elt."%' OR empr_nom like '%-".$elt."%' OR empr_prenom like '".$elt."%' OR empr_prenom like '% ".$elt."%' OR empr_prenom like '%-".$elt."%')"; } } if(count($sql_elts)) { $filters [] = "((".implode(' AND ',$sql_elts).") OR empr_cb like '".str_replace("*", "%", $this->filters['simple_search'])."%')" ; } } else { $elt = str_replace("*", "%", $this->filters['simple_search']); $filters [] = "(empr_nom like '".$elt."%' OR empr_nom like '%-".$elt."%' OR empr_prenom like '".$elt."%' OR empr_prenom like '%-".$elt."%' OR empr_cb like '".$elt."%')" ; } } if(!empty($this->filters['empr_location_id']) && $this->filters['empr_location_id'] != -1) { $filters [] = 'empr_location = "'.$this->filters['empr_location_id'].'"'; } if($this->filters['empr_statut_edit']) { $filters [] = 'empr_statut = "'.$this->filters['empr_statut_edit'].'"'; } if($this->filters['empr_categ_filter']) { $filters [] = 'empr_categ = "'.$this->filters['empr_categ_filter'].'"'; } if($this->filters['empr_codestat_filter']) { $filters [] = 'empr_codestat = "'.$this->filters['empr_codestat_filter'].'"'; } if($this->filters['group']) { $filters [] = 'groupe_id = "'.$this->filters['group'].'"'; } if($pmb_lecteurs_localises && array_key_exists('locations', $this->filters) && is_array($this->filters['locations']) && count($this->filters['locations'])) { $filters [] = 'empr_location IN ('.implode(',', $this->filters['locations']).')'; } if(is_array($this->filters['categories']) && count($this->filters['categories'])) { $filters [] = 'empr_categ IN ('.implode(',', $this->filters['categories']).')'; } if(is_array($this->filters['status']) && count($this->filters['status'])) { $filters [] = 'empr_statut IN ('.implode(',', $this->filters['status']).')'; } if(is_array($this->filters['codestat']) && count($this->filters['codestat'])) { $filters [] = 'empr_codestat IN ('.implode(',', $this->filters['codestat']).')'; } if(is_array($this->filters['groups']) && count($this->filters['groups'])) { $filters [] = 'groupe_id IN ('.implode(',', $this->filters['groups']).')'; } if($this->filters['name']) { $filters [] = 'empr_nom like "%'.str_replace('*', '%', $this->filters['name']).'%"'; } if($this->filters['mail']) { $filters [] = 'empr_mail like "%'.str_replace('*', '%', $this->filters['mail']).'%"'; } if($this->filters['has_mail']) { $filters [] = 'empr_mail <> ""'; } if($this->filters['has_affected']) { $query_affected = $this->_get_query_filter_affected(); if($query_affected) { $filters [] = $this->_get_query_filter_affected(); } } if($this->filters['date_creation_start']) { $filters [] = 'empr_creation >= "'.$this->filters['date_creation_start'].'"'; } if($this->filters['date_creation_end']) { $filters [] = 'empr_creation < "'.$this->filters['date_creation_end'].'"'; } if($this->filters['date_adhesion_start']) { $filters [] = 'empr_date_adhesion >= "'.$this->filters['date_adhesion_start'].'"'; } if($this->filters['date_adhesion_end']) { $filters [] = 'empr_date_adhesion < "'.$this->filters['date_adhesion_end'].'"'; } if($this->filters['date_expiration_start']) { $filters [] = 'empr_date_expiration >= "'.$this->filters['date_expiration_start'].'"'; } if($this->filters['date_expiration_end']) { $filters [] = 'empr_date_expiration < "'.$this->filters['date_expiration_end'].'"'; } if($this->filters['date_expiration_limit']) { $filters [] = $this->filters['date_expiration_limit']; } if($this->filters['change_categ']) { $filters [] = $this->filters['change_categ']; } if(is_array($this->filters['cp']) && count($this->filters['cp'])) { $filters [] = 'empr_cp IN ('.implode(',', $this->filters['cp']).')'; } if(is_array($this->filters['villes']) && count($this->filters['villes'])) { $filters [] = 'empr_ville IN ("'.implode('","', addslashes_array($this->filters['villes'])).'")'; } if(is_array($this->filters['birth_dates']) && count($this->filters['birth_dates'])) { $filters [] = 'empr_year IN ('.implode(',', $this->filters['birth_dates']).')'; } if(is_array($this->filters['last_level_validated']) && count($this->filters['last_level_validated'])) { $filters [] = 'niveau_relance IN ('.implode(',', $this->filters['last_level_validated']).')'; } if(is_array($this->filters['types_abts']) && count($this->filters['types_abts'])) { $filters [] = 'type_abt IN ('.implode(',', $this->filters['types_abts']).')'; } if(is_array($this->filters['expl_locations']) && count($this->filters['expl_locations'])) { //Géré par la classe filter_list } if(is_array($this->filters['caddies']) && count($this->filters['caddies'])) { $filters [] = 'empr_caddie_id IN ('.implode(',', $this->filters['caddies']).')'; } if(is_array($this->filters['empr_ids']) && count($this->filters['empr_ids'])) { $filters [] = 'id_empr IN ('.implode(',', $this->filters['empr_ids']).')'; } $custom_fields_filters = $this->_get_query_custom_fields_filters(); if(!empty($custom_fields_filters)) { foreach ($custom_fields_filters as $custom_field_filter) { $filters [] = $custom_field_filter; } } if(count($filters)) { $filter_query .= $this->_get_query_join_filters(); $filter_query .= $this->_get_query_join_custom_fields_filters('empr', 'id_empr'); $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 'empr_name': return strcmp(emprunteur::get_name($a->id), emprunteur::get_name($b->id)); break; case 'aff_date_adhesion': return strcmp($a->date_adhesion, $b->date_adhesion); break; case 'aff_date_expiration': return strcmp($a->date_expiration, $b->date_expiration); break; case 'location': return strcmp($a->empr_location_l, $b->empr_location_l); break; case 'groups': $cmp_a = ''; $groupes_a = emprunteur::get_groupes($a->id); if(count($groupes_a)) { $cmp_a = strip_tags($groupes_a[0]); } $cmp_b = ''; $groupes_b = emprunteur::get_groupes($b->id); if(count($groupes_b)) { $cmp_b = strip_tags($groupes_b[0]); } return strcmp($cmp_a, $cmp_b); break; case 'nb_loans': return $this->intcmp(emprunteur::get_nb_loans($a->id), emprunteur::get_nb_loans($b->id)); break; case 'nb_resas_and_validated': return $this->intcmp(emprunteur::get_nb_resas($a->id), emprunteur::get_nb_resas($b->id)); break; default : return parent::_compare_objects($a, $b); break; } } } /** * Construction dynamique de la fonction JS de tri */ protected function get_js_sort_script_sort() { global $sub; $display = parent::get_js_sort_script_sort(); switch (get_called_class()) { case 'list_readers_relances_ui': case 'list_readers_recouvr_ui': $display = str_replace('!!categ!!', 'relance', $display); break; case 'list_readers_circ_ui': $display = str_replace('!!categ!!', 'pret', $display); break; case 'list_readers_group_ui': $display = str_replace('!!categ!!', 'groups', $display); break; default: $display = str_replace('!!categ!!', 'empr', $display); break; } $display = str_replace('!!sub!!', $sub, $display); $display = str_replace('!!action!!', 'list', $display); return $display; } protected function iconepanier($id_emprunteur) { global $msg, $empr_show_caddie; $img_ajout_empr_caddie=""; if ($empr_show_caddie) { $img_ajout_empr_caddie = "\nbasket\n"; } return $img_ajout_empr_caddie; } protected function get_grouped_label($object, $property) { $grouped_label = ''; switch($property) { case 'categ_libelle': $grouped_label = $object->cat_l; break; case 'codestat_libelle': $grouped_label = $object->cstat_l; break; case 'groups': $grouped_label = implode(',', emprunteur::get_groupes($object->id)); break; case 'location': $docs_location = new docs_location($object->empr_location); $grouped_label .= $docs_location->libelle; break; case 'nb_loans': $grouped_label .= emprunteur::get_nb_loans($object->id); break; case 'type_abt': $query = "select type_abt_libelle from type_abts where id_type_abt='".$object->type_abt."'"; $result = pmb_mysql_query($query); if (pmb_mysql_num_rows($result)) { $grouped_label .= pmb_mysql_result($result,0,0); } break; default: $grouped_label = parent::get_grouped_label($object, $property); break; } return $grouped_label; } protected function get_cell_content($object, $property) { global $msg; $content = ''; switch($property) { case 'empr_name': $content .= $object->nom." ".$object->prenom; break; case 'categ_libelle': $content.= $object->cat_l; break; case 'categ_change': $today = getdate(); $age_lecteur = $today["year"] - $object->birth; // on construit le select catégorie $query = "SELECT id_categ_empr, libelle FROM empr_categ WHERE (".$age_lecteur." >= age_min or age_min=0) and (".$age_lecteur." <= age_max or age_max=0) ORDER BY age_min "; $result = pmb_mysql_query($query); $nbr_rows = pmb_mysql_num_rows($result); $content .= "