<?php
// +-------------------------------------------------+
// | 2002-2011 PMB Services / www.sigb.net pmb@sigb.net et contributeurs (voir www.sigb.net)
// +-------------------------------------------------+
// $Id: campaigns_controller.class.php,v 1.5.14.3 2026/07/02 08:52:13 dgoron Exp $

if (stristr($_SERVER['REQUEST_URI'], ".class.php")) die("no access");

global $class_path;
require_once($class_path."/campaigns/campaign.class.php");
require_once($class_path."/campaigns/campaign_stats.class.php");

class campaigns_controller extends lists_controller {
	
	protected static $model_class_name = 'campaign';
	
	protected static $list_ui_class_name = 'list_campaigns_ui';
	
	public static function proceed($id=0) {
		global $action, $view_name;
	
		switch ($action) {
			case 'view':
				print static::get_model_instance($id)->get_view();
				break;
			case 'detail':
			    list_campaigns_logs_ui::set_num_campaign($id);
			    list_campaigns_logs_ui::set_view_name($view_name);
			    $list_campaigns_logs_ui = list_campaigns_logs_ui::get_instance(array('campaigns' => [$id]));
			    print $list_campaigns_logs_ui->get_display_list();
			    break;
			case 'consolidate':
				$campaign_stats = new campaign_stats($id);
				$campaign_stats->build_data();
				$campaign_stats->save();
				print $campaign_stats->get_json_data();
				break;
			case 'list_view':
				print list_campaigns_ui::view();
				break;
			default:
				parent::proceed($id);
		}
	}
}