// hack for first day of week
        if (date("w", strtotime($date)) == 0) {
            $date = CMbDT::date("-1 DAY", $date);
        }
        $week_monday = CMbDT::date("this week", $date);
        $week_sunday = CMbDT::date("Next Sunday", $week_monday);
        $where["start"] = "< '{$week_sunday} 23:59:00'";
        $where["end"] = "> '{$week_monday} 00:00:00'";
        $date_next = CMbDT::date("+1 WEEK", $date);
        $date_prev = CMbDT::date("-1 WEEK", $date);
        $calendar = new CPlanningWeekNew($date, $week_monday, $week_sunday);
        break;
}
$calendar->guid = "CPlanning-{$mode}-{$date}";
$calendar->title = "Astreintes-{$mode}-{$date}";
$astreintes = $astreinte->loadList($where, $order);
/** @var $astreintes CPlageAstreinte[] */
foreach ($astreintes as $_astreinte) {
    $length = CMbDT::minutesRelative($_astreinte->start, $_astreinte->end);
    //not in the current group
    $_astreinte->loadRefUser();
    $_astreinte->loadRefColor();
    $libelle = "<span style=\"text-align:center;\">";
    $libelle .= $_astreinte->libelle ? "<strong>{$_astreinte->libelle}</strong><br/>" : null;
    $libelle .= $_astreinte->_ref_user . '<br/>' . $_astreinte->phone_astreinte . "</span>";
    $libelle = CMbString::purifyHTML($libelle);
    $plage = new CPlanningEvent($_astreinte->_guid, $_astreinte->start, $length, $libelle, "#" . $_astreinte->_color, true, 'astreinte', false, false);
    $plage->setObject($_astreinte);
    $plage->plage["id"] = $_astreinte->_id;
    $plage->type = $_astreinte->type;
    $plage->end = $_astreinte->end;
// load ref function
foreach ($mediusers as $mid => $_medius) {
    $_medius->loadRefFunction();
}
// Query
$where = array();
$where["user_id"] = CSQLDataSource::prepareIn(array_keys($mediusers), $filter->user_id);
$where["group_id"] = " = '{$group->_id}'";
$debut = CValue::first($filter->start, $filter->end);
$fin = CValue::first($filter->end, $filter->start);
if ($fin || $debut) {
    $where["start"] = "<= '{$fin}'";
    $where["end"] = ">= '{$debut}'";
}
/** @var CPlageAstreinte[] $plages */
$plages = $filter->loadList($where, "start DESC", "0,100");
// Regrouper par utilisateur
$found_users = array();
$plages_per_user = array();
foreach ($plages as $_plage) {
    if (!isset($found_users[$_plage->user_id])) {
        $found_users[$_plage->user_id] = null;
    }
    $found_users[$_plage->user_id] = $mediusers[$_plage->user_id];
    $_plage->_ref_user = $_plage->loadRefUser();
    $_plage->loadRefColor();
    $_plage->getDuration();
    if (!isset($plages_per_user[$_plage->user_id])) {
        $plages_per_user[$_plage->user_id] = 0;
    }
    $plages_per_user[$_plage->user_id]++;
Exemple #3
0
        $fin_periode = CMbDT::transform('+1 month', $debut_periode, '%Y-%m-%d');
        $fin_periode = CMbDT::transform('-1 day', $fin_periode, '%Y-%m-%d');
    }
}
$tableau_periode = array();
for ($i = 0; $i < CMbDT::daysRelative($debut_periode, $fin_periode) + 1; $i++) {
    $tableau_periode[$i] = CMbDT::transform('+' . $i . 'day', $debut_periode, '%Y-%m-%d');
}
$where = array();
$where[] = "((date_debut >= '{$debut_periode}' AND date_debut <= '{$fin_periode}'" . ")OR (date_fin >= '{$debut_periode}' AND date_fin <= '{$fin_periode}')" . "OR (date_debut <='{$debut_periode}' AND date_fin >= '{$fin_periode}'))";
$where["user_id"] = CSQLDataSource::prepareIn(array_keys($mediusers), $filter->user_id);
$plageastreinte = new CPlageAstreinte();
$plagesconge = array();
$orderby = "user_id";
/** @var CPlageAstreinte[] $plagesastreintes */
$plagesastreintes = $plageastreinte->loadList($where, $orderby);
$tabUser_plage = array();
$tabUser_plage_indices = array();
foreach ($plagesastreintes as $_plage) {
    $_plage->loadRefUser();
    $_plage->_ref_user->loadRefFunction();
    $_plage->_deb = CMbDT::daysRelative($debut_periode, $_plage->start);
    $_plage->_fin = CMbDT::daysRelative($_plage->start, $_plage->end) + 1;
    $_plage->_duree = CMbDT::daysRelative($_plage->start, $_plage->end) + 1;
}
$smarty = new CSmartyDP();
$smarty->assign("debut_periode", $debut_periode);
$smarty->assign("filter", $filter);
$smarty->assign("plagesastreinte", $plagesastreintes);
$smarty->assign("choix", $choix);
$smarty->assign("mediusers", $mediusers);
<?php

/** $Id: **/
/**
 * @package Mediboard
 * @subpackage dPpersonnel
 * @version $Revision:
 * @author SARL OpenXtrem
 * @license GNU General Public License, see http://www.gnu.org/licenses/gpl.html
 */
CCanDo::checkRead();
$date = CValue::get("date", CMbDT::date());
$group = CGroups::loadCurrent();
// Plages d'astreinte pour l'utilisateur
$plage_astreinte = new CPlageAstreinte();
$where = array();
$where["start"] = "< '{$date} 23:59:00'";
$where["end"] = "> '{$date} 00:00:00'";
$where["group_id"] = " = '{$group->_id}' ";
$plages_astreinte = $plage_astreinte->loadList($where);
/** @var $plages_astreinte CPlageAstreinte[] */
foreach ($plages_astreinte as $_plage) {
    $_plage->loadRefUser();
    $_plage->loadRefColor();
}
// Création du template
$smarty = new CSmartyDP();
$smarty->assign("plages_astreinte", $plages_astreinte);
$smarty->assign("title", CAppUI::tr("CPlageAstreinte.For") . " " . htmlentities(CMbDT::format($date, CAppUI::conf("longdate"))));
$smarty->assign("date", $date);
$smarty->display("vw_list_day_astreinte.tpl");