<?php

/**
 * $Id: vw_daily_check_list_group.php 28107 2015-04-28 09:07:12Z aurelie17 $
 *
 * @package    Mediboard
 * @subpackage SalleOp
 * @author     SARL OpenXtrem <*****@*****.**>
 * @license    GNU General Public License, see http://www.gnu.org/licenses/gpl.html
 * @version    $Revision: 28107 $
 */
CCanDo::checkAdmin();
$check_list_group_id = CValue::get('check_list_group_id');
$duplicate = CValue::get('duplicate', 0);
$check_list_group = new CDailyCheckListGroup();
if ($check_list_group_id) {
    $check_list_group->load($check_list_group_id);
    foreach ($check_list_group->loadRefChecklist() as $list_type) {
        $list_type->loadRefsCategories();
    }
}
$check_list_groups = $check_list_group->loadGroupList(null, 'title');
// Création du template
$smarty = new CSmartyDP();
$smarty->assign("check_list_groups", $check_list_groups);
$smarty->assign("check_list_group", $check_list_group);
$smarty->assign("duplicate", $duplicate);
if ($check_list_group_id != "") {
    $smarty->display("inc_edit_check_list_group.tpl");
} else {
    $smarty->display("vw_daily_check_list_group.tpl");
 $where_cat["list_type_id"] = "IS NULL";
 $lists = array();
 // Pre-anesth, pre-op, post-op
 foreach ($operation_check_list->_specs["type"]->_list as $type) {
     $list = CDailyCheckList::getList($selOp, null, $type);
     $list->loadItemTypes();
     $list->loadRefsFwd();
     $list->loadBackRefs('items');
     $list->isReadonly();
     $list->_ref_object->loadRefPraticien();
     $operation_check_lists[$type] = $list;
     $where_cat["type"] = " = '{$type}'";
     $operation_check_item_categories[$type] = $cat->loadList($where_cat, "title");
 }
 $type_personnel_no_has = array();
 foreach (CDailyCheckListGroup::loadChecklistGroup() as $_checklist_group) {
     foreach ($_checklist_group->_ref_check_liste_types as $_checklist_type) {
         $list = CDailyCheckList::getList($selOp, null, null, $_checklist_type->_id);
         $list->loadItemTypes();
         $list->loadRefsFwd();
         $list->loadBackRefs('items');
         $list->isReadonly();
         $list->_ref_object->loadRefPraticien();
         $check_lists_no_has[$_checklist_type->_id] = $list;
         $where_cat = array();
         $where_cat["target_class"] = " = 'COperation'";
         $where_cat["list_type_id"] = " = '{$_checklist_type->_id}'";
         $check_items_no_has_categories[$_checklist_type->_id] = $cat->loadList($where_cat, "title");
     }
     $validateurs = explode("|", $list->loadRefListType()->type_validateur);
     foreach ($validateurs as $validateur) {