<?php
// +-------------------------------------------------+
// | 2002-2011 PMB Services / www.sigb.net pmb@sigb.net et contributeurs (voir www.sigb.net)
// +-------------------------------------------------+
// $Id: groupexpls_controller.class.php,v 1.1.2.5 2026/08/04 10:13:25 dgoron Exp $

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

global $class_path;
require_once($class_path."/groupexpl.class.php");
require_once($class_path."/groupexpls/groupexpls.class.php");

class groupexpls_controller extends lists_controller {
	
	protected static $model_class_name = 'groupexpl';
	
	protected static $list_ui_class_name = 'list_groupexpls_ui';
	
	protected static $cb_expl;
	
	public static function proceed($id=0) {
		global $msg;
		global $action;
		
		switch($action) {
		    case "form" :
		        static::proceed_edit($id);
		        break;
		    case "see_form" :
		        $model_instance = static::get_model_instance($id);
		        print $model_instance->get_see_form();
		        break;
		    case "raz_check" :
		        $model_instance = static::get_model_instance($id);
		        $model_instance->raz_check(static::$cb_expl);
		        print $model_instance->get_see_form();
		        break;
		    case "do_check" :
		        $model_instance = static::get_model_instance($id);
		        $model_instance->do_check(static::$cb_expl);
		        print $model_instance->get_see_form();
		        break;
		    case 'update':
		    case 'save':
		        static::proceed_save($id);
		        static::redirect_display_list();
		        break;
		    case 'delete':
		        static::proceed_delete($id);
		        static::redirect_display_list();
		        break;
		    case "add_expl" :
		        $model_instance = static::get_model_instance($id);
		        $model_instance->add_expl(static::$cb_expl);
		        print $model_instance->get_form();
		        break;
		    case "search_expl" :
		        if ($id=groupexpls::get_group_expl(static::$cb_expl)){
		            $model_instance = static::get_model_instance($id);
		            print $model_instance->get_see_form();
		        } else {
		            $groupexpls=new groupexpls();
		            $groupexpls->set_error_message($msg["groupexpl_list_error_cb_not_in_group"]);
		            print $groupexpls->get_cb_search_form();
		            static::proceed_default($id);
		        }
		        break;
		    case "del_expl" :
		        $model_instance = static::get_model_instance($id);
		        $model_instance->del_expl(static::$cb_expl);
		        print $model_instance->get_form();
		        break;
		    case "list" :
		    default:
		        $groupexpls = new groupexpls();
		        print $groupexpls->get_cb_search_form();
		        
		        parent::proceed($id);
		        break;
		}
	}
	
	public static function set_cb_expl($cb_expl) {
	    static::$cb_expl = $cb_expl;
	}
	
}