<?php
// +-------------------------------------------------+
// | 2002-2011 PMB Services / www.sigb.net pmb@sigb.net et contributeurs (voir www.sigb.net)
// +-------------------------------------------------+
// $Id: list_graphs_campaigns_ui.class.php,v 1.1 2026/06/24 05:43:24 dgoron Exp $
if (stristr($_SERVER['REQUEST_URI'], ".class.php")) die("no access");

class list_graphs_campaigns_ui extends list_graphs_ui {
    
    protected $campaigns_view;
    
    protected function _init_graphs() {
        switch ($this->filters['modele']) {
            case 'standard':
            default:
                //Affichage de l'histogramme d'ouverture et de clics par campagnes
                $this->add_graph('opening_and_clicks', '', 'ClusteredColumns');
                //Affichage de l'histogramme d'ouvertures par localisation par campagnes
                $this->add_graph('opening', 'recipients', 'ClusteredColumns', ['location']); //location
                //Affichage de l'histogramme d'ouvertures par catégorie par campagnes
                $this->add_graph('opening', 'recipients', 'ClusteredColumns', ['categ']); //categ
                
                //Affichage de l'histogramme de clics par localisation par campagnes
                $this->add_graph('clicks', 'recipients', 'ClusteredColumns', ['location']); //location
                //Affichage de l'histogramme de clics par catégorie par campagnes
                $this->add_graph('clicks', 'recipients', 'ClusteredColumns', ['categ']); //categ
                break;
        }
    }

    /**
     * Initialisation des filtres de recherche
     */
    public function init_filters($filters=array()) {
        $this->filters = array(
            'modele' => '',
            'campaigns' => array()
        );
        parent::init_filters($filters);
    }
    
    /**
	 * Affichage de la liste des objets
	 * @return string
	 */
	public function get_display_objects_list() {
	    $campaigns_view = $this->get_campaigns_view();
		$view = "
			<div class='row'>
				".$campaigns_view->get_display_summary()."
			</div>";
		$view .= "
		<div class='row'>";
		$view .= parent::get_display_objects_list();
		$view .= "</div>";
		return $view;
	}
    
    /**
     * Objet de la liste
     */
    protected function get_display_content_object_list($object, $indice) {
        $display = "<div class='".$this->objects_type."_view_graph campaign_view_graph'>";
        $list_campaigns_logs_ui = new list_campaigns_logs_ui(array('campaigns' => $this->filters['campaigns'], 'stat' => $object->name));
        $display .= $list_campaigns_logs_ui->get_display_graph($object->settings);
        $display .= "</div>";
        return $display;
    }
    
    public function get_campaigns_view() {
        if(!isset($this->campaigns_view)) {
            $this->campaigns_view = new campaigns_view();
            foreach ($this->filters['campaigns'] as $id_campaign) {
                $this->campaigns_view->add(new campaign($id_campaign));
            }
        }
        return $this->campaigns_view;
    }
}