get_bannette()->nom_bannette;
}
protected function init_default_settings() {
parent::init_default_settings();
$this->set_setting_filter('codestat_one', 'visible', 0);
}
protected function init_default_selected_filters() {
global $pmb_lecteurs_localises;
$this->add_selected_filter('categories');
$this->add_selected_filter('groups');
if($pmb_lecteurs_localises) {
$this->add_selected_filter('locations');
} else {
$this->add_empty_selected_filter();
}
$this->add_selected_filter('name');
$this->add_selected_filter('has_mail');
$this->add_selected_filter('has_affected');
$this->add_selected_filter('mail');
}
protected function get_search_filter_has_affected() {
global $msg, $charset;
return "
filters['has_affected'] ? "checked='checked'" : "")." />
filters['has_affected'] ? "checked='checked'" : "")." />
";
}
/**
* Affichage des filtres du formulaire de recherche
*/
public function get_search_filters_form() {
global $msg;
global $faire;
$search_filters_form = '';
if($faire == "enregistrer") {
$search_filters_form .= "
".$msg["dsi_bannette_lecteurs_update"]."
";
}
$search_filters_form .= parent::get_search_filters_form();
return $search_filters_form;
}
/**
* Jointure externes SQL pour les lecteurs affectés
*/
protected function _get_query_join_filter_affected() {
return " JOIN bannette_abon ON bannette_abon.num_empr = empr.id_empr";
}
/**
* Filtre SQL pour les lecteurs affectés
*/
protected function _get_query_filter_affected() {
global $id_bannette;
$filter_query_affected = '';
if($this->id_bannette || $id_bannette) {
$filter_query_affected = 'bannette_abon.num_bannette = "'.($this->id_bannette ? $this->id_bannette : $id_bannette).'"';
}
return $filter_query_affected;
}
protected function get_search_buttons_extension() {
global $base_path;
global $msg;
global $form_cb;
return "
";
}
protected function add_column_mails_selection() {
$this->columns[] = array(
'property' => 'mails_selection',
'label' => "",
'html' => "",
'exportable' => false
);
}
protected function get_cell_content($object, $property) {
global $msg;
$content = '';
switch($property) {
case 'mails_selection':
$mails_selection = '';
if ($object->mail){
$requete_affect = "SELECT * FROM bannette_abon where num_empr='".$object->id."' and num_bannette='".$this->id_bannette."' ";
$res_affect = pmb_mysql_query($requete_affect);
if (pmb_mysql_num_rows($res_affect)){
$abon=pmb_mysql_fetch_object($res_affect);
}
$destinataires = explode(";",$object->mail) ;
if(count($destinataires)>1){
$mails_selection="";
}
}
$content .= $mails_selection;
break;
default:
$content .= parent::get_cell_content($object, $property);
break;
}
return $content;
}
protected function get_display_html_content_selection() {
return "";
}
protected function get_display_cell_html_value($object, $value) {
if(method_exists($object, 'get_id')) {
$value = str_replace('!!subscribed!!', ($this->get_bannette()->is_subscribed($object->get_id()) ? "checked='checked'" : ""), $value);
} else {
$value = str_replace('!!subscribed!!', ($this->get_bannette()->is_subscribed($object->id) ? "checked='checked'" : ""), $value);
}
return parent::get_display_cell_html_value($object, $value);
}
protected function init_default_columns() {
$this->add_column_selection();
$this->add_column('empr_name');
$this->add_column('mail');
$this->add_column_mails_selection();
}
protected function init_columns($columns=array()) {
parent::init_columns($columns);
if(count($this->selected_columns)) {
$this->add_column_mails_selection();
}
}
protected function get_selection_actions() {
global $msg;
global $base_path;
global $id_bannette;
if(!isset($this->selection_actions)) {
$this->selection_actions = array();
if($this->id_bannette || $id_bannette) {
$link = array();
$link['href'] = $base_path."/dsi.php?categ=bannettes&sub=pro&id_bannette=".($this->id_bannette ? $this->id_bannette : $id_bannette)."&suite=affect_lecteurs&faire=enregistrer";
$this->selection_actions[] = $this->get_selection_action('save', $msg['77'], 'sauv.gif', $link);
}
}
return $this->selection_actions;
}
protected function add_events_on_selection_actions() {
$display = "";
return $display;
}
public function get_export_icons() {
global $msg, $base_path, $form_cb;
if($this->get_setting('display', 'search_form', 'export_icons')) {
return "id_bannette."&form_cb=".$form_cb."'\"/>";
}
return "";
}
public static function get_controller_url_base() {
global $base_path;
global $categ, $sub, $id_bannette, $suite;
return $base_path.'/dsi.php?categ='.$categ.'&sub='.$sub.'&id_bannette='.$id_bannette.'&suite='.$suite;
}
public function run_action_affect_lecteurs() {
$selected_objects = static::get_selected_objects();
if(is_array($selected_objects)) {
$name = $this->objects_type."_mails_selection";
global ${$name};
$sel_mail = ${$name};
$objects = $this->objects;
foreach ($objects as $indice=>$object) {
$query = "select count(*) from bannette_abon where num_empr='".$object->id."' and num_bannette='".$this->id_bannette."'";
$result = pmb_mysql_query($query);
if(pmb_mysql_result($result, 0, 0)) {
if(!in_array($object->id, $selected_objects)) {
pmb_mysql_query("delete from bannette_abon where num_empr='".$object->id."' and num_bannette='".$this->id_bannette."'");
if($this->filters['has_affected']) {
unset($this->objects[$indice]);
$this->pager['nb_results']--;
}
}
} else {
if(in_array($object->id, $selected_objects)) {
pmb_mysql_query("insert into bannette_abon set num_empr='".$object->id."', num_bannette='".$this->id_bannette."', bannette_mail='".$sel_mail[$object->id]."'");
}
}
}
}
}
public function set_id_bannette($id_bannette) {
$this->id_bannette = $id_bannette+0;
}
public function get_bannette() {
if(!isset($this->bannette)) {
$this->bannette = new bannette($this->id_bannette);
}
return $this->bannette;
}
}