/**
  * 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;
 }
 /**
  * Duplicate CheckList
  *
  * @return void
  */
 function duplicate()
 {
     $checklist = new CDailyCheckListType();
     $checklist->type = $this->type;
     $checklist->group_id = $this->group_id;
     $checklist->title = $this->title . " dupliqué";
     $checklist->type_validateur = $this->type_validateur;
     $checklist->description = $this->description;
     if ($msg = $checklist->store()) {
         return $msg;
     }
     foreach ($this->loadRefTypeLinks() as $link) {
         $_link = $link;
         $_link->_id = "";
         $_link->list_type_id = $checklist->_id;
         if ($msg = $_link->store()) {
             return $msg;
         }
     }
     foreach ($this->loadRefsCategories() as $categorie) {
         $items = $categorie->loadRefItemTypes();
         $new_categorie = $categorie;
         $new_categorie->_id = "";
         $new_categorie->list_type_id = $checklist->_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;
             }
         }
     }
 }