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

".htmlentities($msg[907], ENT_QUOTES, $charset)."

"; } /** * Initialisation des filtres disponibles */ protected function init_available_filters() { global $empr_groupes_localises; $this->available_filters = array('main_fields' => array( 'name' => '908', ) ); if ($empr_groupes_localises){ $this->available_filters['main_fields']['locations'] = 'editions_filter_empr_location'; } $this->available_filters['custom_fields'] = array(); } /** * Initialisation des filtres de recherche */ public function init_filters($filters=array()) { $this->filters = array( 'name' => '*', 'locations' => array() ); parent::init_filters($filters); } /** * Initialisation des colonnes disponibles */ protected function init_available_columns() { $this->available_columns = array('main_fields' => array( 'libelle' => '904', 'libelle_resp' => '913', 'nb_members' => 'circ_group_emprunteur', 'nb_loans' => '349', 'nb_resas' => 'reserv_en_cours', ) ); } protected function init_default_columns() { $this->add_column('libelle'); $this->add_column('libelle_resp'); $this->add_column('nb_members'); $this->add_column('nb_loans'); $this->add_column('nb_resas'); } protected function init_default_settings() { parent::init_default_settings(); $this->set_setting_display('search_form', 'export_icons', false); } protected function init_default_selected_filters() { global $empr_groupes_localises; $this->add_selected_filter('name'); if($empr_groupes_localises) { $this->add_selected_filter('locations'); } } /** * Initialisation du tri par défaut appliqué */ protected function init_default_applied_sort() { $this->add_applied_sort('libelle'); } /** * Initialisation de la pagination par défaut */ protected function init_default_pager() { global $nb_per_page_author; parent::init_default_pager(); if ($nb_per_page_author != "") { $this->pager['nb_per_page'] = $nb_per_page_author; } } /** * 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_groupe'; break; case 'libelle' : $order .= 'libelle_groupe'; break; default : $order .= parent::_get_query_order(); break; } if($order) { return $this->_get_query_order_sql_build($order); } else { return ""; } } } /** * Filtres provenant du formulaire */ public function set_filters_from_form() { global $group_location_id; $this->set_filter_from_form('name'); if(isset($group_location_id)) { $this->filters['locations'] = $group_location_id; } parent::set_filters_from_form(); } protected function get_search_filter_name() { global $msg; return "filters['name']."\" title='$msg[3001]' />"; } protected function get_search_filter_locations() { return group::gen_combo_box_grp($this->filters['locations'],1); } protected function get_button_add() { global $msg; return ""; } /** * Jointure externes SQL pour les besoins des filtres */ protected function _get_query_join_filters() { $filter_join_query = ''; if(is_array($this->filters['locations']) && count($this->filters['locations'])) { $filter_join_query .= " LEFT JOIN empr ON groupe.resp_groupe=empr.id_empr"; } return $filter_join_query; } /** * Filtre SQL */ protected function _get_query_filters() { global $empr_groupes_localises; $filter_query = ''; $this->set_filters_from_form(); $filters = array(); if($this->filters['name']) { $filters [] = 'libelle_groupe like "%'.str_replace("*", "%", addslashes($this->filters['name'])).'%"'; } if($empr_groupes_localises && array_key_exists('locations', $this->filters) && is_array($this->filters['locations']) && count($this->filters['locations'])) { //Toutes les localisations sélectionnées if (!in_array('-1',$this->filters['locations'])) { //Aucune localisation if (in_array('-2',$this->filters['locations'])) { $filters [] = '(empr_location IN ('.implode(',', $this->filters['locations']).') OR empr_location IS NULL)'; } else { $filters [] = 'empr_location IN ('.implode(',', $this->filters['locations']).')'; } } } 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 'nb_members': return $this->intcmp($a->nb_members, $b->nb_members); break; case 'nb_loans': return $this->intcmp($a->get_nb_loans(), $b->get_nb_loans()); break; case 'nb_resas': return $this->intcmp($a->get_nb_resas(), $b->get_nb_resas()); 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(); $display = str_replace('!!categ!!', 'groups', $display); $display = str_replace('!!sub!!', $sub, $display); $display = str_replace('!!action!!', 'list', $display); return $display; } protected function get_cell_content($object, $property) { $content = ''; switch($property) { case 'nb_loans': $content .= $object->get_nb_loans(); break; case 'nb_resas': $content .= $object->get_nb_resas(); break; default : $content .= parent::get_cell_content($object, $property); break; } return $content; } protected function get_display_cell($object, $property) { global $base_path; $attributes = array(); switch($property) { default: $attributes['onclick'] = "window.location=\"".$base_path."/circ.php?categ=groups&action=showgroup&groupID=".$object->id."\""; break; } $content = $this->get_cell_content($object, $property); $display = $this->get_display_format_cell($content, $property, $attributes); return $display; } public function get_error_message_empty_list() { global $msg, $charset; return str_replace('!!group_cle!!', htmlentities(stripslashes($this->filters['name']),ENT_QUOTES, $charset), $msg[918]); } protected function _get_query_property_filter($property) { switch ($property) { case 'locations': return "select location_libelle from docs_location where idlocation IN (".implode(',', $this->filters[$property]).")"; } return ''; } public static function get_controller_url_base() { global $base_path; global $categ, $action; return $base_path.'/circ.php?categ='.$categ.'&action='.$action; } }