*/
CCando::checkRead();
$date = CValue::getOrSession("date", CMbDT::date());
$kine_id = CValue::getOrSession("kine_id");
$surveillance = CValue::getOrSession("surveillance");
$sejour_id = CValue::get("sejour_id");
$height = CValue::get("height");
$selectable = CValue::get("selectable");
$large = CValue::get("large");
$print = CValue::get("print");
$kine = new CMediusers();
$kine->load($kine_id);
$sejour = new CSejour();
$sejour->load($sejour_id);
$nb_days_planning = $sejour->_id ? $sejour->getNbJourPlanning($date) : CEvenementSSR::getNbJoursPlanning($kine_id, $date);
$planning = new CPlanningWeek($date, null, null, $nb_days_planning, $selectable, $height, $large, !$print);
$planning->title = $surveillance ? "Surveillance '{$kine->_view}'" : "Rééducateur '{$kine->_view}'";
$planning->guid = $kine->_guid;
$planning->guid .= $surveillance ? "-surv" : "-tech";
// Chargement des evenement SSR
$evenement = new CEvenementSSR();
$where = array();
$where["debut"] = "BETWEEN '{$planning->_date_min_planning} 00:00:00' AND '{$planning->_date_max_planning} 23:59:59'";
$where["therapeute_id"] = " = '{$kine->_id}'";
$where["type_seance"] = $surveillance ? " = 'non_dediee'" : " <> 'non_dediee'";
/** @var CEvenementSSR[] $evenements */
$evenements = $evenement->loadList($where);
// Chargement des evenements SSR de "charge"
$where["type_seance"] = $surveillance ? " <> 'non_dediee'" : " = 'non_dediee'";
/** @var CEvenementSSR[] $evenements_charge */
$evenements_charge = $evenement->loadList($where);
$whereInterv["chir_id"] = $whereHP["chir_id"] = " = '{$chir_id}'";
$where[] = "chir_id = '{$chir_id}' OR remplacant_id = '{$chir_id}'";
$where["date"] = $whereInterv["date"] = $whereHP["date"] = "= '{$fin}'";
if ($_line_element_id) {
    $where["pour_tiers"] = "= '1'";
}
if ($plage->countList($where)) {
    $nbDays = 7;
} else {
    $where["date"] = "= '" . CMbDT::date("-1 day", $fin) . "'";
    if ($plage->countList($where)) {
        $nbDays = 6;
    }
}
//Instanciation du planning
$planning = new CPlanningWeek($debut, $debut, $fin, $nbDays, false, $print ? "1000" : "auto");
$planning->title = $prat->_view;
$planning->guid = $prat->_guid;
$planning->hour_min = "07";
$planning->hour_max = "20";
$planning->pauses = array("07", "12", "19");
$whereHP["plageop_id"] = " IS NULL";
for ($i = 0; $i < $nbDays; $i++) {
    $jour = CMbDT::date("+{$i} day", $debut);
    $where["date"] = $whereInterv["date"] = $whereHP["date"] = "= '{$jour}'";
    if (CAppUI::pref("showIntervPlanning")) {
        // HORS PLAGE
        $horsPlage = new COperation();
        /** @var COperation[] $horsPlages */
        $horsPlages = $horsPlage->loadList($whereHP);
        CMbObject::massLoadFwdRef($horsPlages, "chir_id");
CDossierMedical::massCountAllergies($dossiers);
// Récupération des commentaires
$commentaire = new CCommentairePlanning();
$where = array();
$where["debut"] = " <= '{$date_planning} 23:59:59'";
$where["fin"] = " >= '{$date_planning} 00:00:00'";
$where["salle_id"] = CSQLDataSource::prepareIn($salles_ids);
$commentaires = $commentaire->loadListWithPerms(PERM_READ, $where);
// Récupération des plages opératoires
$plageop = new CPlageOp();
$where = array();
$where["date"] = " = '{$date_planning}'";
$where["salle_id"] = CSQLDataSource::prepareIn($salles_ids);
$plages = $plageop->loadListWithPerms(PERM_READ, $where);
// Création du planning
$planning = new CPlanningWeek(0, 0, count($salles), count($salles), false, "auto");
$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);
 * @license    GNU General Public License, see http://www.gnu.org/licenses/gpl.html
 * @version    $Revision$
 */
CCando::checkRead();
$date = CValue::getOrSession("date", CMbDT::date());
$sejour_id = CValue::get("sejour_id");
$sejour = new CSejour();
$sejour->load($sejour_id);
$equipement = new CEquipement();
$equipement->load(CValue::get("equipement_id"));
if (!$equipement->visualisable) {
    echo "<div class='small-info'>L'équipement <strong>{$equipement->_view}</strong> n'est pas visualisable</div>";
    CApp::rip();
}
$nb_days_planning = $sejour->getNbJourPlanning($date);
$planning = new CPlanningWeek($date, null, null, $nb_days_planning, false, "auto", false, true);
$planning->title = "Equipement '{$equipement->_view}'";
$planning->guid = $equipement->_guid;
// Chargement des evenement SSR
$evenement = new CEvenementSSR();
$where["debut"] = "BETWEEN '{$planning->_date_min_planning} 00:00:00' AND '{$planning->_date_max_planning} 23:59:59'";
$where["equipement_id"] = " = '{$equipement->_id}'";
/** @var CEvenementSSR[] $evenements */
$evenements = $evenement->loadList($where);
foreach ($evenements as $_evenement) {
    $important = !$sejour_id || $_evenement->sejour_id == $sejour_id;
    $sejour = $_evenement->loadRefSejour();
    $patient = $sejour->loadRefPatient();
    // Title
    $therapeute = $_evenement->loadRefTherapeute();
    $title = ucfirst(strtolower($patient->nom)) . "  {$therapeute->_shortview}";
$where = array();
$where["date"] = $whereInterv["date"] = $whereHP["date"] = "= '{$dateArr}'";
$whereInterv["chir_id"] = $whereHP["chir_id"] = "= '{$chirSel}' ";
$where[] = "chir_id = '{$chirSel}' OR remplacant_id = '{$chirSel}'";
if (!$listPlage->countList($where)) {
    $nbDays--;
    // Aucune plage le dimanche, on peut donc tester le samedi.
    $dateArr = CMbDT::date("+5 day", $debut);
    $where["date"] = "= '{$dateArr}'";
    if (!$listPlage->countList($where)) {
        $nbDays--;
    }
}
$bank_holidays = array_merge(CMbDate::getHolidays($debut), CMbDate::getHolidays($fin));
// Planning Week
$planning = new CPlanningWeek($debut, $debut, $fin, $nbDays, false, "auto");
$user = new CMediusers();
$user->load($chirSel);
if ($user->_id) {
    $user->loadRefFunction();
    $planning->title = CMbString::htmlEntities($user->_view);
} else {
    $planning->title = "";
}
$can_edit = CCanDo::edit();
$planning->guid = $user->_guid;
$planning->hour_min = "07";
$planning->hour_max = "20";
$planning->pauses = array("07", "12", "19");
$planning->dragndrop = $planning->resizable = $can_edit ? 1 : 0;
$planning->hour_divider = 60 / CAppUI::conf("dPcabinet CPlageconsult minutes_interval");
$patient->loadRefPhotoIdentite();
$patient->loadRefLatestConstantes(null, array("poids", "taille"));
$dossier_medical = $patient->loadRefDossierMedical();
if ($dossier_medical->_id) {
    $dossier_medical->loadRefsAllergies();
    $dossier_medical->loadRefsAntecedents();
    $dossier_medical->countAntecedents();
    $dossier_medical->countAllergies();
}
$sejour->loadRefCurrAffectation($debut);
if (!$sejour->_ref_curr_affectation->_id) {
    $sejour->loadRefsAffectations();
    $sejour->_ref_curr_affectation = $sejour->_ref_last_affectation;
}
//Instanciation du planning
$planning = new CPlanningWeek($debut, $debut, $fin, $nbjours, false, 450, null, true);
$planning->title = "";
$planning->guid = $sejour->_guid;
$planning->hour_min = "07";
$planning->hour_max = "20";
$planning->pauses = array("12");
$ljoin = array();
$ljoin['plageconsult'] = "consultation.plageconsult_id = plageconsult.plageconsult_id";
$where = array();
$where[] = "plageconsult.date BETWEEN '{$debut}' AND '{$fin}'";
$where["patient_id"] = " = '{$patient->_id}'";
$consultation = new CConsultation();
$consultations = $consultation->loadList($where, null, null, "consultation_id", $ljoin);
foreach ($consultations as $_consult) {
    /* @var CConsultation $_consult*/
    $_consult->loadRefPlageConsult()->loadRefChir();
 * @license    GNU General Public License, see http://www.gnu.org/licenses/gpl.html
 * @version    $Revision$
 */
CCanDo::checkRead();
$sejour = new CSejour();
$sejour->load(CValue::get("sejour_id"));
$sejour->loadRefPatient();
$selectable = CValue::get("selectable");
$patient = $sejour->_ref_patient;
$height = CValue::get("height");
$print = CValue::get("print");
$large = CValue::get("large");
// Initialisation du planning
$date = CValue::getOrSession("date", CMbDT::date());
$nb_days_planning = $sejour->getNbJourPlanning($date);
$planning = new CPlanningWeek($date, $sejour->entree, $sejour->sortie, $nb_days_planning, $selectable, $height, $large, !$print);
$planning->title = "Patient '{$patient->_view}'";
$planning->guid = $sejour->_guid;
// Chargement des evenement SSR (ainsi que les seances collectives)
$evenement = new CEvenementSSR();
$ljoin = array();
$ljoin[] = "evenement_ssr AS evt_seance ON (evt_seance.seance_collective_id = evenement_ssr.evenement_ssr_id)";
$where = array();
$where[] = "(evenement_ssr.sejour_id = '{$sejour->_id}') OR (evenement_ssr.sejour_id IS NULL AND evt_seance.sejour_id = '{$sejour->_id}')";
$where["evenement_ssr.debut"] = "BETWEEN '{$planning->_date_min_planning} 00:00:00' AND '{$planning->_date_max_planning} 23:59:59'";
/** @var CEvenementSSR[] $evenements */
$evenements = $evenement->loadList($where, null, null, null, $ljoin);
foreach ($evenements as $_evenement) {
    if (!$_evenement->sejour_id) {
        // Chargement de l'evenement pour ce sejour
        $evt = new CEvenementSSR();
 */
CCanDo::checkRead();
$function_id = CValue::getOrSession("function_id");
$date = CValue::getOrSession("date");
// filters
$show_free = CValue::get("show_free", 1);
$cancelled = CValue::get("cancelled");
$hide_in_conge = CValue::get("hide_in_conge", 0);
$facturated = CValue::get("facturated");
$finished = CValue::get("finished");
$actes = CValue::get("actes");
$function = new CFunctions();
$function->load($function_id);
$muser = new CMediusers();
$musers = $muser->loadProfessionnelDeSanteByPref(PERM_READ, $function_id, null, true);
$planning = new CPlanningWeek(0, 0, count($musers), count($musers), false, "auto");
$planning->title = "Planning du " . htmlentities(CMbDT::format($date, "%A %d %B %Y"));
$planning->guid = "planning_j_n";
$planning->dragndrop = 1;
$planning->hour_divider = 12;
$planning->show_half = true;
$i = 0;
foreach ($musers as $_user) {
    $user_id = $_user->_id;
    // plages conge
    $conge = new CPlageConge();
    $where = array();
    $where["date_debut"] = " <= '{$date}'";
    $where["date_fin"] = " >= '{$date}'";
    $where["user_id"] = " = '{$_user->_id}'";
    $nb_conges = $conge->countList($where);