<?php

/**
 * $Id: vw_daily_check_item_category.php 25667 2014-11-03 11:07:55Z aurelie17 $
 *
 * @package    Mediboard
 * @subpackage SalleOp
 * @author     SARL OpenXtrem <*****@*****.**>
 * @license    GNU General Public License, see http://www.gnu.org/licenses/gpl.html
 * @version    $Revision: 25667 $
 */
CCanDo::checkAdmin();
$item_category_id = CValue::getOrSession('item_category_id');
$list_type_id = CValue::get('list_type_id');
$list_type = new CDailyCheckListType();
$list_type->load($list_type_id);
$item_category = new CDailyCheckItemCategory();
if ($item_category->load($item_category_id)) {
    $item_category->loadRefsNotes();
    $item_category->loadRefItemTypes();
} else {
    $item_category->list_type_id = $list_type_id;
    $item_category->target_class = $list_type->type == "ouverture_salle" ? "CSalle" : "CBlocOperatoire";
}
foreach (CDailyCheckList::$_HAS_classes as $_class) {
    unset($item_category->_specs["target_class"]->_locales[$_class]);
}
list($targets, $item_categories_by_class) = CDailyCheckItemCategory::getCategoriesTree();
// Création du template
$smarty = new CSmartyDP();
$smarty->assign("item_category", $item_category);
 /**
  * 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;
 }
Exemplo n.º 3
0
<?php

/**
 * $Id: ajax_edit_checklist_type.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();
global $g;
$check_list_type_id = CValue::getOrSession('check_list_type_id');
$check_list_group_id = CValue::get('check_list_group_id');
$list_type = new CDailyCheckListType();
$list_type->load($check_list_type_id);
$list_type->loadRefsNotes();
$list_type->loadRefsCategories();
$list_type->makeLinksArray();
list($targets, $by_type) = CDailyCheckListType::getListTypesTree();
if ($list_type->type != "intervention" || !$list_type->check_list_group_id) {
    unset($list_type->_specs["type_validateur"]->_list[10]);
}
foreach ($targets as $_targets) {
    foreach ($_targets as $_target) {
        $_target->loadRefsFwd();
    }
}
if ($check_list_group_id) {
    $list_type->type = 'intervention';
 /**
  * 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;
             }
         }
     }
 }
 /**
  * Get the lists related to an object
  *
  * @param CMbObject $object Object to get the check lists of
  * @param string    $date   The reference date
  * @param string    $type   type de checklist
  *
  * @return array
  */
 static function getCheckLists(CMbObject $object, $date, $type = "ouverture_salle")
 {
     $daily_check_list_type = new CDailyCheckListType();
     $where = array("daily_check_list_type_link.object_class" => "= '{$object->_class}'", "daily_check_list_type_link.object_id IS NULL\r\n      OR\r\n     daily_check_list_type_link.object_id = '{$object->_id}'");
     $where["type"] = " = '{$type}'";
     $ljoin = array("daily_check_list_type_link" => "daily_check_list_type_link.list_type_id = daily_check_list_type.daily_check_list_type_id");
     /** @var CDailyCheckListType[] $daily_check_list_types  */
     $daily_check_list_types = $daily_check_list_type->loadGroupList($where, "title", null, "daily_check_list_type_id", $ljoin);
     /** @var CDailyCheckList[] $daily_check_lists  */
     $daily_check_lists = array();
     $check_list_not_validated = 0;
     foreach ($daily_check_list_types as $_list_type) {
         $_list_type->loadRefsCategories();
         $daily_check_list = CDailyCheckList::getList($object, $date, null, $_list_type->_id);
         $daily_check_list->loadItemTypes();
         $daily_check_list->loadBackRefs('items');
         $daily_check_list->loadRefListType();
         if (!$daily_check_list->_id || !$daily_check_list->validator_id) {
             $check_list_not_validated++;
         }
         $daily_check_lists[] = $daily_check_list;
     }
     return array($check_list_not_validated, $daily_check_list_types, $daily_check_lists);
 }