/** * add an event to the present planning * * @param CPlanningEvent $event an event * * @return null */ function addEvent(CPlanningEvent $event) { //start plage out of borne $date_start = CMbDT::date($event->start); if ($date_start != $this->date) { $event->day = $this->date; $event->start = $this->date . " 00:00:00"; $event->hour = "00"; $event->minutes = "00"; $event->length = CMbDT::minutesRelative($event->start, $event->end); } //end of plage is out of borne $date_end = CMbDT::date($event->end); if ($date_end != $this->date) { $event->length = CMbDT::minutesRelative($event->start, $this->date . " 23:59:59"); } parent::addEvent($event); }
/** @var CPlageOp[] $intervs */ $interv = new CPlageOp(); $intervs = $interv->loadList($whereInterv); CMbObject::massLoadFwdRef($intervs, "chir_id"); foreach ($intervs as $_interv) { $range = new CPlanningRange($_interv->_guid, $jour . " " . $_interv->debut, CMbDT::minutesRelative($_interv->debut, $_interv->fin), CAppUI::tr($_interv->_class), "bbccee", "plageop"); $planning->addRange($range); } } $plages = $plage->loadList($where); CMbObject::massLoadFwdRef($plages, "chir_id"); /** @var $_plage CPlageconsult */ foreach ($plages as $_plage) { $_plage->loadRefsFwd(1); $_plage->loadRefsConsultations(false); $range = new CPlanningRange($_plage->_guid, $jour . " " . $_plage->debut, CMbDT::minutesRelative($_plage->debut, $_plage->fin)); $range->color = $_plage->color; $range->type = "plageconsult"; $planning->addRange($range); foreach ($_plage->_ref_consultations as $_consult) { $debute = "{$jour} {$_consult->heure}"; if ($_consult->patient_id) { $_consult->loadRefPatient(); $color = "#fee"; if ($_consult->premiere) { $color = "#faa"; } elseif ($_consult->derniere) { $color = "#faf"; } elseif ($_consult->sejour_id) { $color = "#CFFFAD"; }
/** * @param $areas * @param $series * @param $where * @param $ljoin * @param $dates * @param $period * @param $sejour CSejour * @param $total * @param $start_field * @param $end_field */ function computeAttente($areas, &$series, $where, $ljoin, $dates, $period, $sejour, &$total, $start_field, $end_field) { $only_duration = empty($areas); // never when ljoin on consult (form field) if (strpos($start_field, "._") === false) { $where[$start_field] = "IS NOT NULL"; } if (strpos($end_field, "._") === false) { $where[$end_field] = "IS NOT NULL"; } if (!$only_duration) { foreach ($areas as $key => $value) { // never when ljoin on consult (form field) if (isset($value[$start_field]) && strpos($start_field, "._") === false) { $where[$start_field] = $value[$start_field]; } if (isset($value[$end_field]) && strpos($end_field, "._") === false) { $where[$end_field] = $value[$end_field]; } $series[$key] = array('data' => array(), "label" => utf8_encode($value[0])); foreach ($dates as $i => $_date) { $_date_next = CMbDT::date("+1 {$period}", $_date); $where['sejour.entree'] = "BETWEEN '{$_date}' AND '{$_date_next}'"; $count = $sejour->countList($where, null, $ljoin); $total += $count; $series[$key]['data'][$i] = array($i, intval($count)); } } } // Time $areas = array_merge(array(null)); foreach ($areas as $key => $value) { $key = count($series); $series[$key] = array('data' => array(), 'yaxis' => $only_duration ? 1 : 2, 'lines' => array("show" => true), 'points' => array("show" => true), 'mouse' => array("track" => true, "trackFormatter" => "timeLabelFormatter"), 'label' => $only_duration ? "" : "Temps", 'color' => "red", "shadowSize" => 0); foreach ($dates as $i => $_date) { $_date_next = CMbDT::date("+1 {$period}", $_date); $where['sejour.entree'] = "BETWEEN '{$_date}' AND '{$_date_next}'"; /** @var CSejour[] $_sejours */ $_sejours = $sejour->loadList($where, null, null, null, $ljoin); // FIXME $times = array(); foreach ($_sejours as $_sejour) { list($_start_class, $_start_field) = explode(".", $start_field); list($_end_class, $_end_field) = explode(".", $end_field); // load RPU if ($_start_class == "rpu" || $_end_class == "rpu") { $_sejour->loadRefRPU(); $_rpu = $_sejour->_ref_rpu; } // load consult if ($_start_class == "consultation" || $_end_class == "consultation") { $_sejour->loadRefsConsultations(); $_consult = $_sejour->_ref_consult_atu; if (!$_consult || !$_consult->heure) { continue; } $_consult->loadRefPlageConsult(); if (!$_consult->_date) { continue; } } switch ($_start_class) { case "sejour": $_start_object = $_sejour; break; case "rpu": $_start_object = $_rpu; break; case "consultation": $_start_object = $_consult; break; } switch ($_end_class) { case "sejour": $_end_object = $_sejour; break; case "rpu": $_end_object = $_rpu; break; case "consultation": $_end_object = $_consult; break; } $start = $_start_object->{$_start_field}; $end = $_end_object->{$_end_field}; if ($start && $end) { $times[] = CMbDT::minutesRelative($start, $end); } } $count = array_sum($times); $mean = count($times) ? $count / count($times) : 0; $variance = 0; foreach ($times as $time) { $variance += pow($time - $mean, 2); } if (count($times)) { $variance /= count($times); } $std_dev = sqrt($variance); $series[$key]['data'][$i] = array($i, $mean); // mean - std_dev if (!isset($series[$key + 1])) { $series[$key + 1] = $series[$key]; $series[$key + 1]["color"] = "#666"; $series[$key + 1]["lines"]["lineWidth"] = 1; $series[$key + 1]["points"]["show"] = false; $series[$key + 1]["label"] = utf8_encode("Temps - écart type"); } $series[$key + 1]['data'][$i] = array($i, $mean - $std_dev); // mean + std_dev if (!isset($series[$key + 2])) { $series[$key + 2] = $series[$key]; $series[$key + 2]["color"] = "#666"; $series[$key + 2]["lines"]["lineWidth"] = 1; $series[$key + 2]["points"]["show"] = false; $series[$key + 2]["label"] = utf8_encode("Temps + écart type"); } $series[$key + 2]['data'][$i] = array($i, $mean + $std_dev); } } // Echange du dernier et tu premier des lignes pour avoir celle du milieu en avant plan $c = count($series); list($series[$c - 3], $series[$c - 1]) = array($series[$c - 1], $series[$c - 3]); }
/** * Update the form (derived) fields plain fields * * @return void */ function updateFormFields() { parent::updateFormFields(); // Chargement des contents if ($this->_load_content) { $this->loadContent(); } $this->_self_sender = $this->sender_id === null; $this->_self_receiver = $this->receiver_id === null; if ($this->date_echange > CMbDT::dateTime("+ " . CAppUI::conf("eai exchange_format_delayed") . " minutes", $this->date_production)) { $this->_delayed = CMbDT::minutesRelative($this->date_production, $this->date_echange); } }
$consult_anesth = $interv->loadRefsConsultAnesth(); $group = CGroups::loadCurrent(); $pack = $interv->loadRefGraphPack(); list($graphs, $yaxes_count, $time_min, $time_max, $time_debut_op_iso, $time_fin_op_iso) = CObservationResultSet::buildGraphs($interv, $pack->_id); $time_debut_op = CMbDate::toUTCTimestamp($time_debut_op_iso); $time_fin_op = CMbDate::toUTCTimestamp($time_fin_op_iso); $evenements = CObservationResultSet::buildEventsGrid($interv, $time_debut_op_iso, $time_fin_op_iso, $time_min, $time_max); $now = 100 * (CMbDate::toUTCTimestamp(CMbDT::dateTime()) - $time_min) / ($time_max - $time_min); $graph_packs = CSupervisionGraphPack::getAllFor($group); $concentrators = null; if (CModule::getActive("patientMonitoring")) { $concentrator = new CMonitoringConcentrator(); $concentrators = $concentrator->loadList(); } // Création du template $smarty = new CSmartyDP(); $smarty->assign("pack", $pack); $smarty->assign("interv", $interv); $smarty->assign("graphs", $graphs); $smarty->assign("evenements", $evenements); $smarty->assign("time_debut_op", $time_debut_op); $smarty->assign("time_fin_op", $time_fin_op); $smarty->assign("yaxes_count", $yaxes_count); $smarty->assign("consult_anesth", $consult_anesth); $smarty->assign("now", $now); $smarty->assign("time_debut_op_iso", $time_debut_op_iso); $smarty->assign("time_fin_op_iso", $time_fin_op_iso); $smarty->assign("graph_packs", $graph_packs); $smarty->assign("concentrators", $concentrators); $smarty->assign("nb_minutes", CMbDT::minutesRelative($time_debut_op_iso, $time_fin_op_iso)); $smarty->display("inc_vw_surveillance_perop.tpl");
$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); //colors $color = "#cfc"; if ($_plage->remplacant_id && $_plage->remplacant_id != $chirSel) { // Je suis remplacé par un autre médecin $color = "#FAA"; } if ($_plage->remplacant_id && $_plage->remplacant_id == $chirSel) { // Je remplace un autre médecin $color = "#FDA"; } // consults libres if ($show_free) { $_plage->loadRefsConsultations(false);
$where = array(); $where[] = "(plagesop.date BETWEEN '{$debut}' AND '{$fin}') OR (operations.date BETWEEN '{$debut}' AND '{$fin}')"; $where["operations.sejour_id"] = " = '{$sejour_id}'"; $operation = new COperation(); $operations = $operation->loadList($where, null, null, "operation_id", $ljoin); foreach ($operations as $_operation) { /* @var COperation $_operation*/ $_operation->loadRefChir(); $_operation->loadRefPlageOp(); $color = "#fcc"; $class = null; if ($_operation->_acte_execution == $_operation->_datetime) { $_operation->_acte_execution = CMbDT::addDateTime($_operation->temp_operation, $_operation->_datetime); } $libelle = "Intervention par le Dr " . $_operation->_ref_chir->_view . " - {$_operation->libelle}"; $event = new CPlanningEvent($_operation->_guid, $_operation->_datetime, CMbDT::minutesRelative($_operation->_datetime, $_operation->_acte_execution), $libelle, $color, true); $event->onmousover = true; $planning->addEvent($event); } $dates = array($debut, $fin); $prescription = $sejour->loadRefPrescriptionSejour(); $lines["imagerie"] = $prescription->loadRefsLinesElement(null, "imagerie"); $lines["kine"] = $prescription->loadRefsLinesElement(null, "kine"); foreach ($lines as $category => $cat) { $color = $category == "kine" ? "#ccf" : "aaa"; foreach ($cat as $_line) { /* @var CPrescriptionLineElement $_line*/ // Chargement des planifications pour la date courante $planif = new CPlanificationSysteme(); $where = array(); $where["object_id"] = " = '{$_line->_id}'";
} $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; $plage->display_hours = true; if ($_astreinte->getPerm(PERM_EDIT)) { $plage->addMenuItem("edit", utf8_encode("Modifier l'astreinte"));
/** * Chargement des interventions * * @param bool $annulee Prise en compte des interventions annulées * @param string $order Paramètre ORDER SQL * @param bool $sorted Utilisation du paramètre ORDER SQL passé en paramètre * @param null $validated Uniquement les validées * @param array $where Tableau de paramètres WHERE SQL * * @return COperation[] */ function loadRefsOperations($annulee = true, $order = "rank, time_operation, rank_voulu, horaire_voulu", $sorted = false, $validated = null, $where = array()) { $where += array("plageop_id" => "= '{$this->plageop_id}'"); if (!$annulee) { $where["annulee"] = "= '0'"; } /** @var COperation[] $operations */ $operations = array(); $op = new COperation(); if (!$sorted) { $operations = $op->loadList($where, $order); } else { $order = "rank, rank_voulu, horaire_voulu"; if ($validated === null || $validated === true) { $where["rank"] = "> 0"; $operations = CMbArray::mergeKeys($operations, $op->loadList($where, $order)); } if ($validated === null || $validated === false) { // Sans rank $where["rank"] = "= 0"; $where["rank_voulu"] = "> 0"; $operations = CMbArray::mergeKeys($operations, $op->loadList($where, $order)); // Sans rank voulu $where["rank_voulu"] = "= 0"; $where["horaire_voulu"] = "IS NOT NULL"; $operations = CMbArray::mergeKeys($operations, $op->loadList($where, $order)); $where["horaire_voulu"] = "IS NULL"; $operations = CMbArray::mergeKeys($operations, $op->loadList($where, $order)); } } foreach ($operations as $_operation) { $_operation->_ref_plageop = $this; if ($_operation->temp_operation) { $this->_cumulative_minutes = $this->_cumulative_minutes + CMbDT::minutesRelative("00:00:00", $_operation->temp_operation); } } return $this->_ref_operations = $operations; }
/** * Donne les heures limites d'une intervention * * @param COperation $interv Reference interv * * @return array */ static function getLimitTimes(COperation $interv) { $round_minutes = 10; $round = $round_minutes * 60000; // FIXME $sejour = $interv->loadRefSejour(); // Cas du partogramme if ($sejour->grossesse_id) { $grossesse = $sejour->loadRefGrossesse(); // Debut = debut travail OU entree salle if ($grossesse->datetime_debut_travail) { $time_debut_op_iso = $grossesse->datetime_debut_travail; } else { $time_min = $interv->entree_salle; $date = CMbDT::date($interv->_datetime); $time_debut_op_iso = "{$date} {$time_min}"; } // Fin = fin accouchement OU debut+1 heure OU maintenant if ($grossesse->datetime_accouchement) { $time_fin_op_iso = $grossesse->datetime_accouchement; } else { $time_fin_op_iso = max(CMbDT::dateTime(), CMbDT::dateTime("+1 HOUR", $time_debut_op_iso)); } } else { $time_min = $interv->entree_salle; $time_max = CMbDT::time("+" . CMbDT::minutesRelative("00:00:00", $interv->temp_operation) . " MINUTES", $interv->entree_salle); $date = CMbDT::date($interv->_datetime); $fin = CValue::first($interv->sortie_salle, $interv->fin_op, $interv->retrait_garrot); if ($fin) { $time_max = max($time_max, $fin); } $time_debut_op_iso = "{$date} {$time_min}"; $time_fin_op_iso = "{$date} {$time_max}"; } $timestamp_min = floor(CMbDate::toUTCTimestamp($time_debut_op_iso) / $round) * $round; $timestamp_max = ceil(CMbDate::toUTCTimestamp($time_fin_op_iso) / $round) * $round; return array($timestamp_min, $timestamp_max, $time_debut_op_iso, $time_fin_op_iso); }
/** * Charge le sender * * @return CViewSender */ function loadRefSender() { $sender = $this->loadFwdRef("sender_id", true); $this->_last_age = CMbDT::minutesRelative($this->last_datetime, CMbDT::dateTime()); return $this->_ref_sender = $sender; }
/** * @see parent::mine */ function mine($salle_id, $date) { parent::mine($salle_id, $date); // plages $plage_op = new CPlageOp(); $plage_op->date = $date; $plage_op->salle_id = $salle_id; /** @var CPlageOp[] $plages */ $plages = $plage_op->loadMatchingList(); $plages_to_use = array(); $range_plage = array(); foreach ($plages as $kp => $_plage) { if ($_plage->debut >= $_plage->fin) { continue; } $plages_to_use[$kp] = $_plage; CMbRange::union($range_plage, array("lower" => $_plage->debut, "upper" => $_plage->fin)); } $this->nb_plages_planned = count($plages); $this->nb_plages_planned_valid = count($plages_to_use); $this->cumulative_plages_planned = 0; foreach ($range_plage as $_range) { $this->cumulative_plages_planned += CMbDT::minutesRelative($_range["lower"], $_range["upper"]); } // interventions $interv = new COperation(); $interv->salle_id = $salle_id; $interv->date = $date; /** @var COperation[] $intervs */ $intervs = $interv->loadMatchingList(); $interv_to_use = array(); $range_inter = array(); foreach ($intervs as $ki => $_interv) { // cleanup invalid if (!$_interv->entree_salle || !$_interv->sortie_salle || $_interv->entree_salle >= $_interv->sortie_salle) { continue; } $interv_to_use[$ki] = $_interv; CMbRange::union($range_inter, array("lower" => $_interv->entree_salle, "upper" => $_interv->sortie_salle)); } $this->nb_real_interventions = count($intervs); $this->nb_real_intervention_valid = count($interv_to_use); $this->cumulative_real_interventions = 0; foreach ($range_inter as $_range) { $this->cumulative_real_interventions += CMbDT::minutesRelative($_range["lower"], $_range["upper"]); } // opening patient $interv_to_use = array(); $range_inter_opened = array(); foreach ($intervs as $ki => $_interv) { // cleanup invalid if (!$_interv->debut_op || !$_interv->fin_op || $_interv->debut_op >= $_interv->fin_op) { continue; } $interv_to_use[$ki] = $_interv; CMbRange::union($range_inter_opened, array("lower" => $_interv->debut_op, "upper" => $_interv->fin_op)); } $this->nb_interventions_opened_patient = count($intervs); $this->nb_intervention_opened_patient_valid = count($interv_to_use); $this->cumulative_opened_patient = 0; foreach ($range_inter_opened as $_range) { $this->cumulative_opened_patient += CMbDT::minutesRelative($_range["lower"], $_range["upper"]); } // range operation $this->cumulative_plages_minus_interventions = 0; $plages_minus_interv = CMbRange::multiCrop($range_plage, $range_inter); foreach ($plages_minus_interv as $_plage) { $this->cumulative_plages_minus_interventions = CMbDT::minutesRelative($_plage["lower"], $_plage["upper"]); } $this->cumulative_interventions_minus_plages = 0; $interv_minus_plage = CMbRange::multiCrop($range_inter, $range_plage); foreach ($interv_minus_plage as $_plage) { $this->cumulative_interventions_minus_plages = CMbDT::minutesRelative($_plage["lower"], $_plage["upper"]); } return $this; }
} $event->title .= "<br/>Durée cumulée : "; $event->title .= $_plage->_cumulative_minutes ? CMbDT::transform("+ {$_plage->_cumulative_minutes} MINUTES", "00:00:00", "%Hh%M") : " —"; $event->title .= "</small>"; $event->type = $_plage->_class; $event->datas = array("id" => $_plage->_id); $event->css_class = $_plage->_class; $event->setObject($_plage); $calendar->days[$_plage->date][$_plage->_guid] = $event; } // hors plage $sql = "\n SELECT plageop_id, date, chir_id,\n SEC_TO_TIME(SUM(TIME_TO_SEC(temp_operation))) as accumulated_time,\n MIN(time_operation) AS first_time,\n MAX(time_operation) AS last_time,\n COUNT(*) AS nb_op\n FROM operations, sejour\n WHERE (date BETWEEN '{$calendar->date_min}' AND '{$calendar->date_max}')\n AND plageop_id IS NULL\n AND sejour.sejour_id = operations.sejour_id\n AND sejour.group_id = '{$group_id}'\n AND (chir_id = '{$_prat->_id}' OR anesth_id = '{$_prat->_id}')\n AND operations.annulee = '0'\n AND sejour.annule = '0'\n GROUP BY date, plageop_id"; $hps = $ds->loadList($sql); foreach ($hps as $_hp) { $guid = "hps_" . $_hp["date"] . $_prat->_id; $event = new CPlanningEvent($guid, $_hp["date"] . " " . $_hp["first_time"], CMbDT::minutesRelative($_hp["date"] . " 00:00:00", $_hp["date"] . " " . $_hp["accumulated_time"])); $event->title = "<strong>" . CMbDT::format($_hp["first_time"], '%H:%M') . " - " . CMbDT::format($_hp["last_time"], "%H:%M") . "</strong> " . $_hp["nb_op"] . " " . CAppUI::tr("CIntervHorsPlage") . "<small>"; if ($function_id) { $event->title .= " - " . $_prat->_shortview; } $event->title .= "<br/>Durée cumulée : " . CMbDT::format($_hp["accumulated_time"], '%Hh%M'); $event->title .= "</small>"; $event->datas = array("date" => $_hp['date'], "chir_id" => $_hp["chir_id"]); $event->css_class = $event->type = "CIntervHorsPlage"; $event->css_class .= " date_" . $_hp["date"]; $calendar->days[$_hp["date"]][$guid] = $event; } } else { $plages_op = array(); $hps = array(); }
} } // Ajout des plages, OK foreach ($plages_by_salle as $salle_id => $_plages) { $i = array_search($salle_id, $salles_ids); CMbObject::massLoadRefsNotes($_plages); CMbObject::massLoadFwdRef($_plages, "chir_id"); CMbObject::massLoadFwdRef($_plages, "anesth_id"); CMbObject::massLoadFwdRef($_plages, "spec_id"); foreach ($_plages as $_plage) { $_plage->loadRefsNotes(); $_plage->loadRefChir()->loadRefFunction(); $_plage->loadRefSpec(); $_plage->loadRefAnesth()->loadRefFunction(); $debut = "{$i} " . CMbDT::time($_plage->debut); $duree = CMbDT::minutesRelative(CMbDT::time($_plage->debut), CMbDT::time($_plage->fin)); //fetch $smarty = new CSmartyDP("modules/reservation"); $smarty->assign("plageop", $_plage); $smarty_plageop = $smarty->fetch("inc_planning/libelle_plageop.tpl"); $smarty_plageop = htmlspecialchars_decode(CMbString::htmlEntities($smarty_plageop, ENT_NOQUOTES), ENT_NOQUOTES); $event = new CPlanningEvent($_plage->_guid, $debut, $duree, $smarty_plageop, "#efbf99", true, null, $_plage->_guid, false); $event->below = true; $event->type = "plage_planning"; $event->plage["id"] = $_plage->_id; if ($can_edit) { $event->addMenuItem("edit", CMbString::htmlEntities("Modifier cette plage")); $event->addMenuItem("list", CMbString::htmlEntities("Gestion des interventions")); } $planning->addEvent($event); }
/** * @see parent::updateFormFields() */ function updateFormFields() { parent::updateFormFields(); $this->_total = CMbDT::timeCountIntervals($this->debut, $this->fin, $this->freq); if ($this->freq == "1:00:00" || $this->freq == "01:00:00") { $this->_freq = "60"; } else { $this->_freq = substr($this->freq, 3, 2); $this->_freq_minutes = CMbDT::minutesRelative("00:00:00", $this->freq); } }
/** * Ajout d'un évènement à un planning * * @param CPlanningWeek &$planning planning concerné * @param CPlageHoraire $_plage plage à afficher * @param string $date date de l'évènement * @param string $libelle libellé de l'évènement * @param string $color couleur de l'évènement * @param string $type type de l'évènement * @param string|null $class css class to apply * * @return void */ function ajoutEvent(&$planning, $_plage, $date, $libelle, $color, $type, $class = null) { $debute = "{$date} {$_plage->debut}"; $event = new CPlanningEvent($_plage->_guid, $debute, CMbDT::minutesRelative($_plage->debut, $_plage->fin), $libelle, $color, true, $class, null); $event->resizable = true; //Paramètres de la plage de consultation $event->type = $type; $pct = $_plage->_fill_rate; if ($pct > "100") { $pct = "100"; } if ($pct == "") { $pct = 0; } $event->plage["id"] = $_plage->_id; $event->plage["pct"] = $pct; if ($type == "consultation") { $event->plage["locked"] = $_plage->locked; $event->plage["_affected"] = $_plage->_affected; $event->plage["_nb_patients"] = $_plage->_nb_patients; $event->plage["_total"] = $_plage->_total; } else { $event->plage["locked"] = 0; $event->plage["_count_operations"] = $_plage->_count_operations; } $event->plage["list_class"] = $_plage->_guid; $event->plage["add_class"] = $date; $event->plage["list_title"] = $date; $event->plage["add_title"] = $type; //Ajout de l'évènement au planning $planning->addEvent($event); }
/** * Charge la plage de consultation englobante * * @param boolean $cache [optional] Use cache * * @return CPlageconsult */ function loadRefPlageConsult($cache = true) { $this->completeField("plageconsult_id"); /** @var CPlageConsult $plage */ $plage = $this->loadFwdRef("plageconsult_id", $cache); $time = CMbDT::time("+" . CMbDT::minutesRelative("00:00:00", $plage->freq) * $this->duree . " MINUTES", $this->heure); $this->_date_fin = "{$plage->date} {$time}"; $this->_duree = CMbDT::minutesRelative("00:00:00", $plage->freq) * $this->duree; $plage->_ref_chir = $plage->loadFwdRef("chir_id", $cache); $plage->_ref_remplacant = $plage->loadFwdRef("remplacant_id", $cache); // Distant fields /** @var CMediusers $chir */ $chir = $plage->_ref_remplacant->_id ? $plage->_ref_remplacant : $plage->_ref_chir; $this->_date = $plage->date; $this->_datetime = CMbDT::addDateTime($this->heure, $this->_date); $this->_acte_execution = $this->_datetime; $this->_is_anesth = $chir->isAnesth(); $this->_is_dentiste = $chir->isDentiste(); $this->_praticien_id = $chir->_id; $this->_ref_chir = $chir; return $this->_ref_plageconsult = $plage; }
/** * Add a load event * * @param CPlanningEvent|string $start an event * @param integer $length [optional] length of the load * * @return null */ function addLoad($start, $length = null) { $this->has_load = true; if ($start instanceof CPlanningEvent) { $event = $start; if ($this->no_dates) { $day = $event->day; } else { $day = CMbDT::date($event->day); } } else { if ($this->no_dates) { $day = $start; } else { $day = CMbDT::date($start); } $event = new CPlanningEvent(null, $start, $length); } $start = $event->start; $end = $event->end; $div_size = 60 / $this->hour_divider; $min = round(CMbDT::minutesRelative($day, $start) / $div_size) - 1; $max = round(CMbDT::minutesRelative($day, $end) / $div_size) + 1; for ($i = $min; $i <= $max; $i++) { $div_min = CMbDT::dateTime("+" . $i * $div_size . " MINUTES", $day); //$div_max = CMbDT::dateTime("+".(($i+1)*$div_size)." MINUTES", $day); // FIXME: ameliorer ce calcul if ($div_min >= $start && $div_min < $end) { $hour = CMbDT::format($div_min, "%H"); $min = CMbDT::format($div_min, "%M"); if (!isset($this->load_data[$day][$hour][$min])) { $this->load_data[$day][$hour][$min] = 0; } $this->load_data[$day][$hour][$min]++; } } }
$color = "#CCC"; } elseif ($_plage->remplacant_id && $_plage->remplacant_id != $chirSel) { $color = "#FAA"; } elseif ($_plage->remplacant_id && !$_plage->remplacant_ok) { $color = "#FDA"; } elseif ($_plage->remplacant_id && $_plage->remplacant_ok) { $color = "#BFB"; } } elseif ($_plage->pour_compte_id) { $color = "#EDC"; } $class = null; if ($_plage->pour_tiers) { $class = "pour_tiers"; } $event = new CPlanningEvent($_plage->_guid, $debute, CMbDT::minutesRelative($_plage->debut, $_plage->fin), $libelle, $color, true, $class, null); $event->useHeight = true; //Menu des évènements $event->addMenuItem("list", "Voir le contenu de la plage"); $nonRemplace = !$_plage->remplacant_id || $_plage->remplacant_id != $chirSel || $_plage->remplacant_id == $chirSel && $_plage->chir_id == $chirSel; $nonDelegue = !$_plage->pour_compte_id || $_plage->pour_compte_id != $chirSel || $_plage->pour_compte_id == $chirSel && $_plage->chir_id == $chirSel; if ($nonRemplace && $nonDelegue && $_plage->getPerm(PERM_EDIT)) { $event->addMenuItem("edit", "Modifier cette plage"); } $event->addMenuItem("clock", "Planifier une consultation dans cette plage"); //Paramètres de la plage de consultation $event->type = "consultation"; $event->plage["id"] = $_plage->plageconsult_id; $pct = $_plage->_fill_rate; if ($pct > "100") { $pct = "100";
/** * if an event is more than 1 day long. * * @param CPlanningEvent $event an event to divide * * @return null */ function explodeEvent(CPlanningEvent $event) { $daysDifference = CMbDT::daysRelative($event->start, $event->end); $day = CMbDT::date($event->start); //create 2 sub-event $left_rightBorne = CMbDT::date($event->start) . " 23:59:59"; $event_left = new CPlanningEvent($event->guid, $event->start, CMbDT::minutesRelative($event->start, $left_rightBorne), $event->title, $event->color, $event->important, $event->css_class, null, false); $event_left->mb_object = $event->mb_object; $event_left->plage = $event->plage; $event_left->end = $left_rightBorne; $event_left->type = $event->type; $event_left->display_hours = $event->display_hours; $event_left->menu = $event->menu; self::addEvent($event_left); if ($daysDifference > 1) { for ($a = 1; $a < $daysDifference; $a++) { $day = CMbDT::date("+1 DAY", $day); $dayBetween = new CPlanningEvent($event->guid, $day . " 00:00:00", 1440, $event->title, $event->color, $event->important, $event->css_class, null, false); $dayBetween->end = $day . " 23:59:59"; $dayBetween->mb_object = $event->mb_object; $dayBetween->plage = $event->plage; $dayBetween->type = $event->type; $dayBetween->display_hours = $event->display_hours; $dayBetween->menu = $event->menu; self::addEvent($dayBetween); } } $right_lefttBorne = CMbDT::date($event->end) . " 00:00:00"; $event_right = new CPlanningEvent($event->guid, $right_lefttBorne, CMbDT::minutesRelative($right_lefttBorne, $event->end), $event->title, $event->color, true, $event->css_class, null, false); $event_right->end = $event->end; $event_right->mb_object = $event->mb_object; $event_right->plage = $event->plage; $event_right->type = $event->type; $event_right->menu = $event->menu; $event_right->display_hours = $event->display_hours; self::addEvent($event_right); }
/** * get the number of hours between start & end * * @return float */ function getHours() { return $this->_hours = CMbDT::minutesRelative($this->start, $this->end) / 60; }