id_bannette);
}
protected function _get_query_order() {
if ($this->applied_sort[0]['by']) {
$order = '';
$sort_by = $this->applied_sort[0]['by'];
switch($sort_by) {
case 'name':
$order .= 'nom_bannette, comment_public';
break;
case 'comment_public':
$order .= 'comment_public';
break;
default :
$order .= parent::_get_query_order();
break;
}
if($order) {
return $this->_get_query_order_sql_build($order);
} else {
return "";
}
}
}
/**
* Initialisation du tri par défaut appliqué
*/
protected function init_default_applied_sort() {
$this->add_applied_sort('name');
}
/**
* Initialisation des colonnes disponibles
*/
protected function init_available_columns() {
$this->available_columns =
array('main_fields' =>
array(
'name' => 'dsi_ban_form_nom',
'equations' => 'dsi_ban_list_equ',
'number_records' => 'dsi_ban_nb_notices',
'number_subscribed' => 'dsi_ban_nb_abonnes',
'send_last_date' => 'dsi_ban_date_last_envoi',
)
);
$this->available_columns['custom_fields'] = array();
}
protected function init_default_columns() {
$this->add_column('name');
$this->add_column('equations');
$this->add_column('number_records');
$this->add_column('number_subscribed');
$this->add_column('send_last_date');
}
protected function init_default_settings() {
parent::init_default_settings();
$this->set_setting_display('search_form', 'export_icons', false);
}
/**
* Initialisation des filtres disponibles
*/
protected function init_available_filters() {
$this->available_filters =
array('main_fields' =>
array(
'name' => 'dsi_ban_search_nom',
'id_classement' => 'dsi_classement',
)
);
$this->available_filters['custom_fields'] = array();
}
/**
* Initialisation des filtres de recherche
*/
public function init_filters($filters=array()) {
$this->filters = array(
'auto' => '',
'id_classement' => '',
'name' => '',
'proprio_bannette' => '',
'type' => '',
'num_empr' => ''
);
parent::init_filters($filters);
}
protected function init_default_selected_filters() {
$this->add_selected_filter('name');
$this->add_selected_filter('id_classement');
}
/**
* Filtres provenant du formulaire
*/
public function set_filters_from_form() {
global $id_classement;
$this->set_filter_from_form('name');
if(isset($id_classement)) {
$this->filters['id_classement'] = $id_classement;
}
$this->set_filter_from_form('type', 'integer');
parent::set_filters_from_form();
}
protected function get_search_filter_name() {
global $msg;
return "filters['name']."\" title='$msg[3000]' />";
}
protected function get_search_filter_id_classement() {
return gen_liste_classement("BAN", $this->filters['id_classement'], "this.form.submit();");
}
protected function get_search_filter_type() {
global $msg, $charset;
return "";
}
protected function get_button_add() {
global $msg;
return "";
}
/**
* Filtre SQL
*/
protected function _get_query_filters() {
global $sub;
$filter_query = '';
$this->set_filters_from_form();
$filters = array();
if($sub == 'lancer') {
$filters [] = '(DATE_ADD(date_last_envoi, INTERVAL periodicite DAY) <= sysdate())';
}
if($this->filters['auto'] !== '') {
$filters [] = 'bannette_auto = "'.$this->filters['auto'].'"';
}
if($this->filters['id_classement']) {
$filters [] = 'num_classement = "'.$this->filters['id_classement'].'"';
} elseif($this->filters['id_classement'] === 0) {
$filters [] = 'num_classement = "0"';
}
if($this->filters['name']) {
$filters [] = 'nom_bannette like "%'.str_replace("*", "%", addslashes($this->filters['name'])).'%"';
}
if($this->filters['num_empr'] != '') {
$filters [] = 'num_empr = "'.$this->filters['num_empr'].'"';
}
if($this->filters['proprio_bannette'] !== '') {
$filters [] = 'proprio_bannette = "'.$this->filters['proprio_bannette'].'"';
}
if($this->filters['type']) {
switch ($this->filters['type']) {
case 1:
$filters [] = 'proprio_bannette = 0';
break;
case 2:
$filters [] = 'proprio_bannette != 0';
break;
}
}
if(count($filters)) {
$filter_query .= ' where '.implode(' and ', $filters);
}
return $filter_query;
}
protected function _get_label_cell_header($name) {
global $msg, $charset;
switch ($name) {
case 'dsi_ban_form_nom':
return
"".htmlentities($msg['dsi_ban_form_nom'],ENT_QUOTES, $charset)."
(".htmlentities($msg['dsi_classement'],ENT_QUOTES, $charset).")
".htmlentities($msg['dsi_ban_form_com_gestion'],ENT_QUOTES, $charset)."
";
case 'dsi_ban_date_last_envoi':
return "".htmlentities($msg['dsi_ban_date_last_envoi'],ENT_QUOTES, $charset)."
(".htmlentities($msg['dsi_ban_date_last_remp'],ENT_QUOTES, $charset).")";
default:
return "".parent::_get_label_cell_header($name)."";
}
}
protected static function get_equations($id_bannette, $proprio_bannette=0) {
global $msg;
$requete = "select id_equation, num_classement, nom_equation, comment_equation, proprio_equation, num_bannette from equations, bannette_equation where num_equation=id_equation and proprio_equation='".$proprio_bannette."' and num_bannette='".$id_bannette."' order by nom_equation " ;
$resequ = pmb_mysql_query($requete);
$equ_trouvees = pmb_mysql_num_rows($resequ) ;
$equations = "" ;
while ($equa=pmb_mysql_fetch_object($resequ)) {
$eq_form= new equation($equa->id_equation) ;
$equations .= "