/**
  * Récupération du code tarif du séjour
  *
  * @param DOMNode $node     PV1 Node
  * @param CSejour $newVenue Admit
  *
  * @return void
  */
 function getFinancialClass(DOMNode $node, CSejour $newVenue)
 {
     $sender = $this->_ref_sender;
     if ($sender->_configs["handle_PV1_20"] == "none") {
         return;
     }
     $systeme_presta = CAppUI::conf("dPhospi prestations systeme_prestations", "CGroups-" . $newVenue->group_id);
     if ($systeme_presta == "standard") {
         return;
     }
     // Uniquement pour les prestas expertes
     $prestation = explode("#", $this->queryTextNode("PV1.20", $node));
     $presta_name = CMbArray::get($prestation, 0);
     $item_name = CMbArray::get($prestation, 1);
     $item_presta = new CItemPrestation();
     if ($item_name) {
         // Chargement de la prestation journalière
         $presta_journa = new CPrestationJournaliere();
         $presta_journa->nom = $presta_name;
         $presta_journa->loadMatchingObject();
         $item_presta->object_class = "CPrestationJournaliere";
         $item_presta->object_id = $presta_journa->_id;
     } else {
         $item_name = $presta_name;
     }
     // Chargement d'un item de prestation
     $item_presta->nom = $item_name;
     $item_presta->loadMatchingObject();
     if (!$item_presta->_id) {
         return;
     }
     $item_liaison = new CItemLiaison();
     $ljoin = array("item_prestation" => "item_prestation.item_prestation_id = item_liaison.item_souhait_id", "prestation_journaliere" => "item_prestation.object_id = prestation_journaliere_id");
     $where["item_liaison.sejour_id"] = " = '{$newVenue->_id}'";
     $where["item_liaison.date"] = " = '" . CMbDT::date($newVenue->entree) . "'";
     $where["prestation_journaliere.prestation_journaliere_id"] = " = '{$presta_journa->_id}'";
     $item_liaison->loadObject($where, null, null, $ljoin);
     if (!$item_liaison->_id) {
         $item_liaison->sejour_id = $newVenue->_id;
         $item_liaison->date = CMbDT::date($newVenue->entree);
     }
     $item_liaison->item_souhait_id = $item_presta->_id;
     $item_liaison->_eai_sender_guid = $sender->_guid;
     $item_liaison->store();
 }
<?php

/**
 * $Id$
 *
 * @package    Mediboard
 * @subpackage Hospi
 * @author     SARL OpenXtrem <*****@*****.**>
 * @license    GNU General Public License, see http://www.gnu.org/licenses/gpl.html
 * @version    $Revision$
 */
$item_id = CValue::getOrSession("item_id");
$object_class = CValue::getOrSession("object_class");
$object_id = CValue::getOrSession("object_id");
$item = new CItemPrestation();
$item->load($item_id);
$item->loadRefsNotes();
if (!$item->_id) {
    $item->object_class = $object_class;
    $item->object_id = $object_id;
    $item->rank = 1;
    if ($object_class == "CPrestationJournaliere") {
        /** @var CPrestationJournaliere $prestation */
        $prestation = new $object_class();
        $prestation->load($object_id);
        $item->rank = $prestation->countBackRefs("items") + 1;
    }
}
$smarty = new CSmartyDP();
$smarty->assign("item", $item);
$smarty->display("inc_edit_item_prestation.tpl");
 * @license    GNU General Public License, see http://www.gnu.org/licenses/gpl.html
 * @version    $Revision$
 */
$item_id_move = CValue::get("item_id_move");
$direction = CValue::get("direction");
$item_id = CValue::getOrSession("item_id");
$item = new CItemPrestation();
$item->load($item_id_move);
switch ($direction) {
    case "up":
        $item->rank--;
        break;
    case "down":
        $item->rank++;
}
$item_to_move = new CItemPrestation();
$item_to_move->object_class = $item->object_class;
$item_to_move->object_id = $item->object_id;
$item_to_move->rank = $item->rank;
$item_to_move->loadMatchingObject();
if ($item_to_move->_id) {
    $direction == "up" ? $item_to_move->rank++ : $item_to_move->rank--;
    $item_to_move->store();
}
$item->store();
$prestation = new $item->object_class();
$prestation->load($item->object_id);
$items = $prestation->loadBackRefs("items", "rank");
$i = 1;
foreach ($items as $item) {
    $item->rank = $i;
<?php

/**
 * $Id$
 *
 * @package    Mediboard
 * @subpackage Hospi
 * @author     SARL OpenXtrem <*****@*****.**>
 * @license    GNU General Public License, see http://www.gnu.org/licenses/gpl.html
 * @version    $Revision$
 */
$prestation = mbGetObjectFromGet("object_class", "object_id");
$item_id = CValue::getOrSession("item_id");
$items = $prestation->loadBackRefs("items", "rank");
CStoredObject::massLoadBackRefs($items, "sous_items");
foreach ($items as $_item) {
    $_item->loadRefsSousItems();
}
$item = new CItemPrestation();
$item->load($item_id);
$smarty = new CSmartyDP();
$smarty->assign("item", $item);
$smarty->assign("items", $items);
$smarty->assign("item_id", $item_id);
$smarty->assign("prestation", $prestation);
$smarty->display("inc_list_items_prestation.tpl");
 */
$keywords = CValue::get("keywords", "%%");
$lit_id = CValue::get("lit_id");
$lit = new C**t();
$lit->load($lit_id);
$liaisons_items = $lit->loadRefsLiaisonsItems();
$items_prestations = CMbObject::massLoadFwdRef($liaisons_items, "item_prestation_id");
$items_prestations_ids = CMbArray::pluck($items_prestations, "object_id");
// Un niveau unique par prestation
$where = array();
$where["object_id"] = CSQLDataSource::prepareNotIn($items_prestations_ids);
$where["object_class"] = " = 'CPrestationJournaliere'";
$where["group_id"] = "= '" . CGroups::loadCurrent()->_id . "'";
$ljoin = array();
$ljoin["prestation_journaliere"] = "prestation_journaliere.prestation_journaliere_id = item_prestation.object_id";
$item_prestation = new CItemPrestation();
/** @var CItemPrestation[] $items_prestations */
$items_prestations = $item_prestation->seek($keywords, $where, null, null, $ljoin);
$items_by_prestation = array();
$prestations = array();
foreach ($items_prestations as $_item_prestation) {
    if (!isset($items_by_prestation[$_item_prestation->object_id])) {
        $items_by_prestation[$_item_prestation->object_id] = array();
    }
    $items_by_prestation[$_item_prestation->object_id][$_item_prestation->rank] = $_item_prestation;
    if (!isset($prestations[$_item_prestation->object_id])) {
        $prestations[$_item_prestation->object_id] = $_item_prestation->loadRefObject();
    }
}
foreach ($items_by_prestation as &$_items) {
    ksort($_items);
<?php

/**
 * $Id$
 *  
 * @category Hospi
 * @package  Mediboard
 * @author   SARL OpenXtrem <*****@*****.**>
 * @license  GNU General Public License, see http://www.gnu.org/licenses/gpl.html
 * @version  $Revision$
 * @link     http://www.mediboard.org
 */
$keywords = CValue::get("keywords");
$type_hospi = CValue::get("type_hospi");
$item_prestation = new CItemPrestation();
$where = array();
$ljoin = array();
$ljoin["prestation_ponctuelle"] = "prestation_ponctuelle.prestation_ponctuelle_id = item_prestation.object_id";
$where["prestation_ponctuelle.group_id"] = "= '" . CGroups::loadCurrent()->_id . "'";
$where["item_prestation.object_class"] = "= 'CPrestationPonctuelle'";
if ($type_hospi) {
    $where[] = "prestation_ponctuelle.type_hospi IS NULL OR prestation_ponctuelle.type_hospi = '{$type_hospi}'";
}
$matches = $item_prestation->getAutocompleteList($keywords, $where, null, $ljoin);
$smarty = new CSmartyDP("modules/system");
$smarty->assign("matches", $matches);
$smarty->assign("view_field", "nom");
$smarty->assign("template", "");
$smarty->assign("show_view", "");
$smarty->assign("input", $keywords);
$smarty->display("inc_field_autocomplete.tpl");