/**
  * Duplicate checklist HAS
  *
  * @return void|string
  */
 function duplicate()
 {
     $types_checklist = array_intersect(CDailyCheckList::$types, array($this->_type_has));
     foreach ($types_checklist as $type_name => $type) {
         $checklist_type = new CDailyCheckListType();
         $checklist_type->group_id = $this->group_id;
         $checklist_type->check_list_group_id = $this->_id;
         $checklist_type->type = 'intervention';
         $checklist_type->title = CAppUI::tr("CDailyCheckItemCategory.type." . $type_name);
         $checklist_type->description = CAppUI::tr("CDailyCheckList.{$type}.{$type_name}.small");
         $checklist_type->type_validateur = "chir_interv|op|op_panseuse|iade|sagefemme|manipulateur";
         if ($msg = $checklist_type->store()) {
             return $msg;
         }
         $where = array();
         $where["type"] = " = '{$type_name}'";
         $where["target_class"] = " = 'COperation'";
         $where["list_type_id"] = " IS NULL";
         $_categorie = new CDailyCheckItemCategory();
         foreach ($_categorie->loadList($where, "title") as $categorie) {
             /* @var CDailyCheckItemCategory $categorie*/
             $items = $categorie->loadRefItemTypes();
             $new_categorie = $categorie;
             $new_categorie->_id = "";
             $new_categorie->list_type_id = $checklist_type->_id;
             if ($msg = $new_categorie->store()) {
                 return $msg;
             }
             foreach ($items as $item) {
                 $new_item = $item;
                 $new_item->_id = "";
                 $new_item->category_id = $new_categorie->_id;
                 if ($msg = $new_item->store()) {
                     return $msg;
                 }
             }
         }
     }
     return null;
 }
 $cat = new CDailyCheckItemCategory();
 $where_cat = array();
 $where_cat["target_class"] = " = 'COperation'";
 $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");