$query .= $surveillance ? "AND type_seance = 'non_dediee'" : "AND type_seance <> 'non_dediee'";
$query .= " GROUP BY DATE(debut)";
$duree_occupation = $ds->loadList($query);
foreach ($duree_occupation as $_occupation) {
    $duree_occupation = $_occupation["total"];
    $color = "#fff";
    if ($duree_occupation < $config["faible"]) {
        $color = "#8f8";
    }
    if ($duree_occupation > $config["eleve"]) {
        $color = "#f88";
    }
    if ($duree_occupation >= $config["faible"] && $duree_occupation <= $config["eleve"]) {
        $color = "#ff4";
    }
    $planning->addDayLabel($_occupation["date"], $_occupation["total"] . " mn", null, $color);
}
// Congés du personnel
/** @var CPlageConge $_plage */
foreach ($kine->loadBackRefs("plages_conge") as $_plage) {
    $planning->addUnavailability($_plage->date_debut, $_plage->date_fin);
}
// Activité du compte
if ($kine->deb_activite) {
    $deb = CMbDT::date("-1 DAY", $kine->deb_activite);
    $planning->addUnavailability(CMbDT::date("-1 WEEK", $deb), $deb);
}
if ($kine->fin_activite) {
    $fin = CMbDT::date("+1 DAY", $kine->fin_activite);
    $planning->addUnavailability($fin, CMbDT::date("+1 WEEK", $fin));
}
$planning->title = "Planning du " . CMbDT::format($date_planning, CAppUI::conf("longdate"));
//load the current bloc
if (isset($current_bloc)) {
    $planning->title .= " - {$current_bloc->nom}";
}
$planning->guid = "planning_interv";
$planning->hour_min = str_pad(CAppUI::conf("reservation debut_planning"), 2, 0, STR_PAD_LEFT);
$planning->dragndrop = $planning->resizable = CCanDo::edit() ? 1 : 0;
//hack for "false => 0"
$planning->hour_divider = 12;
$planning->show_half = true;
$i = 0;
$today = CMbDT::date();
foreach ($salles as $_salle) {
    $label_day = $bloc_id ? $_salle->_shortview : str_replace("-", "<br/>", $_salle->_view);
    $planning->addDayLabel($i, $label_day, null, null, null, true, array("salle_id" => $_salle->_id));
    if ($today == $date_planning) {
        $planning->addEvent(new CPlanningEvent(null, "{$i} " . CMbDT::time(), null, null, "red", null, "now"));
    }
    $i++;
}
// Tri des opérations par salle
$operations_by_salle = array();
foreach ($operations as $key => $_operation) {
    /** @var COperation $_operation */
    if (!$_operation->salle_id) {
        unset($operations[$key]);
        continue;
    }
    if (!isset($operations_by_salle[$_operation->salle_id])) {
        $operations_by_salle[$_operation->salle_id] = array();
        $total_evenement[$_date]["nb"] = 0;
    }
    $total_evenement[$_date]["duree"] += $_evenement->duree;
    $total_evenement[$_date]["nb"]++;
}
foreach ($total_evenement as $_date => $_total) {
    $alerts = array();
    if ($_total["duree"] < 120) {
        $alerts[] = "< 2h";
    }
    if ($_total["nb"] < 1) {
        $alerts[] = "0 indiv. ";
    }
    if ($count = count($alerts)) {
        $color = $count == 2 ? "#f88" : "#ff4";
        $planning->addDayLabel($_date, implode(" / ", $alerts), null, $color);
    }
}
foreach ($sejour->loadRefReplacements() as $_replacement) {
    if ($_replacement->_id) {
        $_replacement->loadRefReplacer();
        $_replacement->loadRefConge();
        $conge =& $_replacement->_ref_conge;
        for ($day = $conge->date_debut; $day <= $conge->date_fin; $day = CMbDT::date("+1 DAY", $day)) {
            $planning->addDayLabel($day, $_replacement->_ref_replacer->_view);
        }
    }
}
// Création du template
$smarty = new CSmartyDP();
$smarty->assign("planning", $planning);
$planning->pauses = array("07", "12", "19");
$planning->dragndrop = $planning->resizable = $can_edit ? 1 : 0;
$planning->hour_divider = 60 / CAppUI::conf("dPcabinet CPlageconsult minutes_interval");
$planning->no_dates = 0;
$plage = new CPlageconsult();
$whereHP["plageop_id"] = " IS NULL";
$users = array();
$conges_day = array();
if ($user->_id) {
    $muser = new CMediusers();
    $users = $muser->loadUsers(PERM_READ, $user->function_id);
}
for ($i = 0; $i < $nbDays; $i++) {
    $jour = CMbDT::date("+{$i} day", $debut);
    $is_holiday = array_key_exists($jour, $bank_holidays);
    $planning->addDayLabel($jour, '<span style="font-size: 1.4em">' . CMbDT::format($jour, "%a %d %b") . '</span>');
    // conges dans le header
    if (count($users)) {
        if (CModule::getActive("dPpersonnel")) {
            $_conges = CPlageConge::loadForIdsForDate(array_keys($users), $jour);
            foreach ($_conges as $key => $_conge) {
                $_conge->loadRefUser();
                $conges_day[$i][] = $_conge->_ref_user->_shortview;
            }
        }
    }
    $where["date"] = $whereInterv["date"] = $whereHP["date"] = "= '{$jour}'";
    if (CAppUI::pref("showIntervPlanning")) {
        if (!$is_holiday || CAppUI::pref("show_plage_holiday")) {
            //INTERVENTIONS
            /** @var CPlageOp[] $intervs */
Example #5
0
     if ($conge->replacer_id) {
         $replacer = $conge->loadRefReplacer();
         $libelle .= '<p style="text-align: center">Remplacé par : ' . CMbString::htmlEntities($replacer->_view) . '</p>';
     }
     $event = new CPlanningEvent($conge->_guid, "{$i} {$conge->date_debut} 00:00:00", 1440, $libelle, "#ffe87e", true, "hatching", null, false);
     $event->below = 1;
     $planning->addEvent($event);
 }
 // plages consult
 $plage = new CPlageconsult();
 $plage->date = $date;
 $plages = $plage->loadMatchingList();
 $style = "color:black;\n    font-size:1.3em;\n    text-shadow: 0 0 10px white;";
 $style .= $nb_conges ? "text-decoration: line-through;" : null;
 // add prat to the calendar
 $planning->addDayLabel($i, "<span style=\"{$style}\">" . CMbString::htmlEntities($_user->_view) . "</span>", null, "#" . $_user->_color, "ObjectTooltip.createEx(this, '" . $_user->_guid . "');", false, array("user_id" => $user_id));
 // if no conges or we want to hide plage
 if ($nb_conges && $hide_in_conge) {
     $i++;
     continue;
 }
 $plage = new CPlageconsult();
 $plage->chir_id = $user_id;
 $plage->date = $date;
 /** @var CPlageconsult[] $plages */
 $plages = $plage->loadMatchingList();
 foreach ($plages as $_plage) {
     // range
     $range = new CPlanningRange($_plage->_guid, $i . " " . $_plage->debut, CMbDT::minutesRelative($_plage->debut, $_plage->fin), $_plage->libelle, $_plage->color);
     $range->type = "plageconsult";
     $planning->addRange($range);