示例#1
0
CCanDo::checkEdit();
$indispo_ressource_id = CValue::getOrSession("indispo_ressource_id");
$date_indispo = CValue::getOrSession("date_indispo", CMbDT::date());
$date_min = CMbDT::format($date_indispo, "%Y-%m-01");
$date_max = CMbDT::date("-1 day", CMbDT::date("+1 month", $date_min));
$group_id = CGroups::loadCurrent()->_id;
$type_ressource = new CTypeRessource();
$where = array("group_id" => "= '{$group_id}'");
/** @var CTypeRessource[] $types_ressources */
$types_ressources = $type_ressource->loadList($where);
$ressources = array();
$indispos = array();
foreach ($types_ressources as $_type_ressource) {
    $ressources[$_type_ressource->_id] = $_type_ressource->loadRefsRessources();
    foreach ($ressources[$_type_ressource->_id] as $_ressource) {
        $indispo = new CIndispoRessource();
        $where = array();
        $where["deb"] = "<= '{$date_max}'";
        $where["fin"] = " >= '{$date_min}'";
        $where["ressource_materielle_id"] = "= '{$_ressource->_id}'";
        $indispos[$_ressource->_id] = $indispo->loadList($where);
    }
}
$smarty = new CSmartyDP();
$smarty->assign("ressources", $ressources);
$smarty->assign("indispos", $indispos);
$smarty->assign("types_ressources", $types_ressources);
$smarty->assign("date_indispo", $date_indispo);
$smarty->assign("prev_month", CMbDT::date("-1 month", $date_indispo));
$smarty->assign("next_month", CMbDT::date("+1 month", $date_indispo));
$smarty->assign("indispo_ressource_id", $indispo_ressource_id);
 /**
  * Chargement des périodes d'indisponibilité
  *
  * @param string $from date de début
  * @param string $to   date de fin
  *
  * @return CIndispoRessource[]
  */
 function loadRefsIndispos($from = null, $to = null)
 {
     if ($from && $to) {
         $indispo = new CIndispoRessource();
         $where = array();
         $ljoin = array();
         $where["deb"] = " <= '{$to}'";
         $where["fin"] = " >= '{$from}'";
         // Sur la ressource instanciée
         if ($this->_id) {
             $where["ressource_materielle_id"] = "= '{$this->_id}'";
         } elseif ($this->type_ressource_id) {
             // Ou sur son type si nouvel objet
             $ljoin["ressource_materielle"] = "ressource_materielle.ressource_materielle_id = indispo_ressource.ressource_materielle_id";
             $where["ressource_materielle.type_ressource_id"] = "= '{$this->type_ressource_id}'";
         }
         return $this->_ref_indispos = $indispo->loadList($where, null, null, null, $ljoin);
     }
     return $this->_ref_indispos = $this->loadBackRefs("indispos");
 }
示例#3
0
<?php

/**
 * $Id$
 *
 * @package    Mediboard
 * @subpackage dPbloc
 * @author     SARL OpenXtrem <*****@*****.**>
 * @license    GNU General Public License, see http://www.gnu.org/licenses/gpl.html
 * @version    $Revision$
 */
CCanDo::checkEdit();
$indispo_ressource_id = CValue::get("indispo_ressource_id");
$indispo = new CIndispoRessource();
$indispo->load($indispo_ressource_id);
$indispo->loadRefRessource();
$smarty = new CSmartyDP();
$smarty->assign("indispo", $indispo);
$smarty->display("inc_edit_indispo.tpl");