filters['tags']) ; $i++){
$selector .= templates::get_input_completion('campaigns_ui_tags', 'campaigns_ui_tag', $i, $this->filters['tags'][$i]['id'], $this->filters['tags'][$i]['label'], 'campaigns_tags');
// if($i == 0) {
// $selector .= templates::get_button_add();
// }
}
$selector .= templates::get_input_hidden('max_tags', count($this->filters['tags']));
}else{
$selector .= templates::get_input_completion('campaigns_ui_tags', 'campaigns_ui_tag', 0, 0, '', 'campaigns_tags');
// $selector .= templates::get_button_add();
$selector .= templates::get_input_hidden('max_tags', 1);
}
return $selector;
}
protected function get_search_filter_date() {
return $this->get_search_filter_interval_date('date');
}
/**
* Filtre SQL
*/
protected function _get_query_filters() {
$filter_query = '';
$this->set_filters_from_form();
$filters = array();
if(is_array($this->filters['types']) && count($this->filters['types'])) {
$filters [] = 'campaign_type IN ("'.implode('","', $this->filters['types']).'")';
}
if(is_array($this->filters['labels']) && count($this->filters['labels'])) {
$filters [] = 'campaign_label IN ("'.implode('","', addslashes_array($this->filters['labels'])).'")';
}
if(is_array($this->filters['descriptors']) && count($this->filters['descriptors'])) {
$descriptors_ids = array();
foreach ($this->filters['descriptors'] as $descriptor) {
$descriptors_ids[] = $descriptor['id'];
}
$filters [] = 'id_campaign IN (select num_campaign from campaigns_descriptors where num_noeud IN ("'.implode(',', $descriptors_ids).'"))';
}
if(is_array($this->filters['tags']) && count($this->filters['tags'])) {
$tags_ids = array();
foreach ($this->filters['tags'] as $tag) {
$tags_ids[] = $tag['id'];
}
$filters [] = 'id_campaign IN (select num_campaign from campaigns_tags where num_tag IN ("'.implode(',', $tags_ids).'"))';
}
if($this->filters['date_start']) {
$filters [] = 'campaign_date >= "'.$this->filters['date_start'].'"';
}
if($this->filters['date_end']) {
$filters [] = 'campaign_date <= "'.$this->filters['date_end'].' 23:59:59"';
}
if($this->filters['ids']) {
$filters [] = 'id_campaign IN ('.$this->filters['ids'].')';
}
if(count($filters)) {
$filter_query .= ' where '.implode(' and ', $filters);
}
return $filter_query;
}
protected function _get_query_human_descriptors() {
$descriptors_labels = array();
foreach ($this->filters['descriptors'] as $descriptor) {
$descriptors_labels[] = $descriptor['label'];
}
return $descriptors_labels;
}
protected function _get_query_human_tags() {
$tags_labels = array();
foreach ($this->filters['tags'] as $tag) {
$tags_labels[] = $tag['label'];
}
return $tags_labels;
}
protected function _get_query_human_date() {
return $this->_get_query_human_interval_date('date');
}
protected function get_js_sort_script_sort() {
$display = parent::get_js_sort_script_sort();
$display = str_replace('!!categ!!', 'campaigns', $display);
$display = str_replace('!!sub!!', '', $display);
$display = str_replace('!!action!!', 'list', $display);
return $display;
}
protected function get_cell_content($object, $property) {
$content = '';
switch($property) {
case 'view_opening_rate':
$content .= $object->get_campaign_view()->get_campaign_stats()->get_opening_rate();
break;
case 'view_clicks_rate':
$content .= $object->get_campaign_view()->get_campaign_stats()->get_clicks_rate();
break;
case 'date':
$content .= $object->get_formatted_date();
break;
case 'recipients_number':
$content .= $object->get_campaign_view()->get_campaign_stats()->get_recipients_number();
break;
default :
$content .= parent::get_cell_content($object, $property);
break;
}
return $content;
}
protected function get_display_cell($object, $property) {
$attributes = array(
'onclick' => "window.location=\"".static::get_controller_url_base()."&action=view&id=".$object->get_id()."\""
);
$content = $this->get_cell_content($object, $property);
$display = $this->get_display_format_cell($content, $property, $attributes);
return $display;
}
protected function get_grouped_label($object, $property) {
$grouped_label = '';
switch($property) {
case 'date':
$grouped_label = substr($object->get_formatted_date(),0,10);
break;
case 'view_opening_rate':
$grouped_label = $object->get_campaign_view()->get_campaign_stats()->get_opening_rate(true);
break;
case 'view_clicks_rate':
$grouped_label = $object->get_campaign_view()->get_campaign_stats()->get_clicks_rate(true);
break;
case 'descriptors':
break;
case 'tags':
break;
case 'recipients_number':
$grouped_label = $object->get_campaign_view()->get_campaign_stats()->get_recipients_number();
break;
default:
$grouped_label = parent::get_grouped_label($object, $property);
break;
}
return $grouped_label;
}
public static function view_sort($selected_objects) {
$query = 'select id_campaign from campaigns where id_campaign IN ('.implode(',', $selected_objects).') ORDER BY campaign_date ASC';
$result = pmb_mysql_query($query);
$sorted_selected_objects = array();
while($row = pmb_mysql_fetch_object($result)) {
$sorted_selected_objects[] = $row->id_campaign;
}
return $sorted_selected_objects;
}
public static function view() {
global $msg;
$campaigns_view = new campaigns_view();
$selected_objects = static::get_selected_objects();
if(is_array($selected_objects) && count($selected_objects)) {
$selected_objects = static::view_sort($selected_objects);
foreach ($selected_objects as $id) {
$campaigns_view->add(new campaign($id));
}
}
$view = "
".$campaigns_view->get_display_summary()."
";
$view .= "
";
//Affichage de l'histogramme d'ouverture et de clics par campagnes
$view .= "
".$campaigns_view->get_instance('ClusteredColumns')->get_opening_and_clicks()."
";
$view .= "
";
//Affichage de l'histogramme d'ouvertures par localisation par campagnes
$view .= "
".$campaigns_view->get_instance('ClusteredColumns')->get_opening_by_recipients('location')."
";
//Affichage de l'histogramme d'ouvertures par catégorie par campagnes
$view .= "
".$campaigns_view->get_instance('ClusteredColumns')->get_opening_by_recipients('categ')."
";
$view .= "
";
//Affichage de l'histogramme de clics par localisation par campagnes
$view .= "
".$campaigns_view->get_instance('ClusteredColumns')->get_clicks_by_recipients('location')."
";
//Affichage de l'histogramme de clics par catégorie par campagnes
$view .= "
".$campaigns_view->get_instance('ClusteredColumns')->get_clicks_by_recipients('categ')."
";
$view .= "
";
//Affichage du(des) bouton(s)
$view .= "
";
return $view;
}
public static function delete() {
$selected_objects = static::get_selected_objects();
if(is_array($selected_objects) && count($selected_objects)) {
foreach ($selected_objects as $id) {
campaign::delete($id);
}
}
}
}