/** * check before store * * @return null|string */ function check() { $this->completeField("date_debut", "date_fin", "user_id"); $plage_conge = new CPlageConge(); $plage_conge->user_id = $this->user_id; $plages_conge = $plage_conge->loadMatchingList(); unset($plages_conge[$this->_id]); /** @var $plages_conge CPlageConge[] */ foreach ($plages_conge as $_plage) { if (CMbRange::collides($this->date_debut, $this->date_fin, $_plage->date_debut, $_plage->date_fin)) { return CAppUI::tr("CPlageConge-conflit %s", $_plage->_view); } } return parent::check(); }
/** * @see parent::check() */ function check() { $this->completeField("debut", "fin"); if ($this->debut == null || $this->fin == null) { return parent::check(); } $siblings = $this->getSiblings(); if (count($siblings)) { foreach ($siblings as $_sibling) { if ($_sibling->debut == null || $_sibling->fin == null) { continue; } if (CMbRange::collides($this->debut, $this->fin, $_sibling->debut, $_sibling->fin) || CMbRange::inside($this->debut, $this->fin, $_sibling->debut, $_sibling->fin) || CMbRange::inside($_sibling->debut, $_sibling->fin, $this->debut, $this->fin)) { return "Collision de personnel !"; } } } return parent::check(); }
CPatient::massCountPhotoIdentite($patients); foreach ($affectations as $_affectation_imc) { /* @var CAffectation $_affectation_imc*/ if (CAppUI::conf("dPhospi vue_temporelle show_imc_patient", "CService-" . $_affectation_imc->service_id)) { $_affectation_imc->loadRefSejour()->loadRefPatient()->loadRefLatestConstantes(null, array("poids", "taille")); } } $operations = array(); $suivi_affectation = false; loadVueTempo($affectations, $suivi_affectation, $lits, $operations, $date_min, $date_max, $period, $prestation_id); $intervals = array(); if (count($lit->_ref_affectations)) { foreach ($lit->_ref_affectations as $_affectation) { $intervals[$_affectation->_id] = array("lower" => $_affectation->_entree, "upper" => $_affectation->_sortie); } $lit->_lines = CMbRange::rearrange($intervals); } // Pour les alertes, il est nécessaire de charger les autres lits // de la chambre concernée ainsi que les affectations $where = array(); $where["entree"] = "<= '{$date_max}'"; $where["sortie"] = ">= '{$date_min}'"; $lits_ids = $chambre->loadBackIds("lits"); foreach ($lits_ids as $_lit_id) { if ($lit_id == $_lit_id) { continue; } $_lit = new C**t(); $_lit->load($_lit_id); $where["lit_id"] = "= '{$_lit->_id}'"; $_affectations = $affectation->loadList($where);
/** * @see parent::check() */ function check() { $msg = null; $this->completeField("chir_id", "plageop_id", "sejour_id"); if (!$this->_id && !$this->chir_id) { $msg .= "Praticien non valide "; } // Bornes du séjour $sejour = $this->loadRefSejour(); $this->loadRefPlageOp(); if ($this->_check_bounds && !$this->_forwardRefMerging) { if ($this->plageop_id !== null && !$sejour->entree_reelle) { $date = CMbDT::date($this->_datetime); $entree = CMbDT::date($sejour->entree_prevue); $sortie = CMbDT::date($sejour->sortie_prevue); if (!CMbRange::in($date, $entree, $sortie)) { $msg .= "Intervention du {$date} en dehors du séjour du {$entree} au {$sortie}"; } } } // Vérification de la signature de l'anesthésiste pour la visite de pré-anesthésie if ($this->fieldModified("prat_visite_anesth_id") && $this->prat_visite_anesth_id !== null && $this->prat_visite_anesth_id != CAppUI::$user->_id) { $anesth = new CUser(); $anesth->load($this->prat_visite_anesth_id); if (!CUser::checkPassword($anesth->user_username, $this->_password_visite_anesth)) { $msg .= "Mot de passe incorrect"; } } return $msg . parent::check(); }
/** * Tell wether given day is active in planning * * @param string|object $day ISO date * * @return bool */ function isDayActive($day) { return CMbRange::in($day, $this->date_min_active, $this->date_max_active); }
/** * Charge le séjour et vérifie les dates liées * * @return CSejour */ function loadRefSejour() { /** @var CSejour $sejour */ $sejour = $this->loadFwdRef("sejour_id", true); $sejour->loadRefPatient(); $entree = CMbDT::date($sejour->_entree); $sortie = CMbDT::date($sejour->_sortie); $this->_in_bounds = CMbRange::collides($this->date_monday, $this->_date_sunday, $entree, $sortie, false); $this->_in_bounds_mon = CMbRange::in($this->date_monday, $entree, $sortie); $this->_in_bounds_tue = CMbRange::in($this->_date_tuesday, $entree, $sortie); $this->_in_bounds_wed = CMbRange::in($this->_date_wednesday, $entree, $sortie); $this->_in_bounds_thu = CMbRange::in($this->_date_thursday, $entree, $sortie); $this->_in_bounds_fri = CMbRange::in($this->_date_friday, $entree, $sortie); $this->_in_bounds_sat = CMbRange::in($this->_date_saturday, $entree, $sortie); $this->_in_bounds_sun = CMbRange::in($this->_date_sunday, $entree, $sortie); return $this->_ref_sejour = $sejour; }
/** * @deprecated use rearrange2 * rearrange a list of object in an optimized list * * @param array $intervals $intervals key => array(lower, upper); * @param boolean $permissive [optional] * @param array &$uncollided array of uncollided elements * * @return array $lines lignes avec les keys positionned */ static function rearrange($intervals, $permissive = true, &$uncollided = array()) { if (!count($intervals)) { return array(); } $lines = array(); $uncollided = $intervals; // multisort ruins the keys if numeric if (!is_numeric(reset(array_keys($intervals)))) { array_multisort($intervals, SORT_ASC, CMbArray::pluck($intervals, "lower")); //order by lower elements ASC } foreach ($intervals as $_interval_id => $_interval) { foreach ($lines as &$_line) { $line_occupied = false; foreach ($_line as $_positioned_id) { $positioned = $intervals[$_positioned_id]; if (CMbRange::collides($_interval["lower"], $_interval["upper"], $positioned["lower"], $positioned["upper"], $permissive)) { $line_occupied = true; unset($uncollided[$_positioned_id]); //continue 2; // Next line } } if ($line_occupied) { continue; } $_line[] = $_interval_id; continue 2; // Next interval } $lines[count($lines)] = array($_interval_id); } return $lines; }
$tplHeader->assign("applicationVersion", $applicationVersion); $tplHeader->assign("allInOne", CValue::get("_aio")); $tplHeader->assign("portal", array("help" => mbPortalURL($m, $tab), "tracker" => mbPortalURL("tracker"))); $tplHeader->display("header.tpl"); } // Check muters if ($muters = CValue::get("muters")) { $muters = explode("-", $muters); if (count($muters) % 2 != 0) { trigger_error("Muters should come by min-max intervals time pairs", E_USER_WARNING); } else { $time_now = CMbDT::time(); while (count($muters)) { $time_min = array_shift($muters); $time_max = array_shift($muters); if (CMbRange::in($time_now, $time_min, $time_max)) { CAppUI::stepMessage(UI_MSG_OK, "msg-common-system-muted", $time_now, $time_min, $time_max); return; } } } } // Check whether we should trace SQL queries if ($query_trace = CValue::get("query_trace")) { CSQLDataSource::$trace = true; } if ($query_report = CValue::get("query_report")) { CSQLDataSource::$report = true; } // tabBox et inclusion du fichier demandé if ($tab !== null) {
function addIntervention($elParent, COperation $operation, $referent = null, $light = false) { $identifiant = $this->addElement($elParent, "identifiant"); $this->addElement($identifiant, "emetteur", $operation->_id); $last_idex = $operation->_ref_last_id400; if (isset($last_idex->_id)) { $this->addElement($identifiant, "recepteur", $last_idex->id400); } $sejour = $operation->loadRefSejour(); if (!$operation->plageop_id) { $operation->completeField("date"); } // Calcul du début de l'intervention $mbOpDate = CValue::first($operation->_ref_plageop->date, $operation->date); $time_operation = $operation->time_operation == "00:00:00" ? null : $operation->time_operation; $mbOpHeureDebut = CValue::first($operation->debut_op, $operation->entree_salle, $time_operation, $operation->horaire_voulu, $operation->_ref_plageop->debut); $mbOpDebut = CMbRange::forceInside($sejour->entree, $sejour->sortie, "{$mbOpDate} {$mbOpHeureDebut}"); // Calcul de la fin de l'intervention $mbOpHeureFin = CValue::first($operation->fin_op, $operation->sortie_salle, CMbDT::addTime($operation->temp_operation, CMbDT::time($mbOpDebut))); $mbOpFin = CMbRange::forceInside($sejour->entree, $sejour->sortie, "{$mbOpDate} {$mbOpHeureFin}"); $debut = $this->addElement($elParent, "debut"); $this->addElement($debut, "date", CMbDT::date($mbOpDebut)); $this->addElement($debut, "heure", CMbDT::time($mbOpDebut)); $fin = $this->addElement($elParent, "fin"); $this->addElement($fin, "date", CMbDT::date($mbOpFin)); $this->addElement($fin, "heure", CMbDT::time($mbOpFin)); if ($light) { // Ajout des participants $mbParticipants = array(); foreach ($operation->_ref_actes_ccam as $acte_ccam) { $acte_ccam->loadRefExecutant(); $mbParticipant = $acte_ccam->_ref_executant; $mbParticipants[$mbParticipant->user_id] = $mbParticipant; } $participants = $this->addElement($elParent, "participants"); foreach ($mbParticipants as $mbParticipant) { $participant = $this->addElement($participants, "participant"); $medecin = $this->addElement($participant, "medecin"); $this->addProfessionnelSante($medecin, $mbParticipant); } // Libellé de l'opération $this->addTexte($elParent, "libelle", $operation->libelle, 80); } else { $this->addUniteFonctionnelle($elParent, $operation); // Uniquement le responsable de l’'intervention $participants = $this->addElement($elParent, "participants"); $participant = $this->addElement($participants, "participant"); $medecin = $this->addElement($participant, "medecin"); $this->addProfessionnelSante($medecin, $operation->loadRefChir()); // Libellé de l'opération $this->addTexte($elParent, "libelle", $operation->libelle, 4000); // Remarques sur l'opération $this->addTexte($elParent, "commentaire", CMbString::convertHTMLToXMLEntities("{$operation->materiel} - {$operation->rques}"), 4000); // Conventionnée ? $this->addElement($elParent, "convention", $operation->conventionne ? 1 : 0); // TypeAnesthésie : nomemclature externe (idex) if ($operation->type_anesth) { $tag_hprimxml = $this->_ref_receiver->_tag_hprimxml; $idexTypeAnesth = CIdSante400::getMatch("CTypeAnesth", $tag_hprimxml, null, $operation->type_anesth); $this->addElement($elParent, "typeAnesthesie", $idexTypeAnesth->id400); } // Indicateurs $indicateurs = $this->addElement($elParent, "indicateurs"); $dossier_medical = new CDossierMedical(); $dossier_medical->object_class = "CPatient"; $dossier_medical->object_id = $operation->loadRefPatient()->_id; $dossier_medical->loadMatchingObject(); $antecedents = $dossier_medical->loadRefsAntecedents(); foreach ($antecedents as $_antecedent) { $rques = CMbString::htmlspecialchars($_antecedent->rques); $rques = CMbString::convertHTMLToXMLEntities($rques); $this->addCodeLibelle($indicateurs, "indicateur", $_antecedent->_id, $rques); } // Extemporané if ($operation->exam_extempo) { $this->addCodeLibelle($indicateurs, "indicateur", "EXT", "Extemporané"); } // Recours / Durée USCPO $this->addElement($elParent, "recoursUscpo", $operation->duree_uscpo ? 1 : 0); $this->addElement($elParent, "dureeUscpo", $operation->duree_uscpo ? $operation->duree_uscpo : null); // Côté (droit|gauche|bilatéral|total|inconnu) // D - Droit // G - Gauche // B - Bilatéral // T - Total // I - Inconnu $cote = array("droit" => "D", "gauche" => "G", "bilatéral" => "B", "total" => "T", "inconnu" => "I", "haut" => "HT", "bas" => "BS"); $this->addCodeLibelle($elParent, "cote", $cote[$operation->cote], CMbString::capitalize($operation->cote)); } }
/** * @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; }
$where["sejour_id"] = " = '{$_sejour->_id}'"; $where["therapeute_id"] = " = '{$tech->kine_id}'"; $where["debut"] = "BETWEEN '{$date_min}' AND '{$date_max}'"; $transfer_count += $evenement->countList($where); } } // Transfer event counts if ($type == "reeducateur") { $date_min = max($monday, $conge->date_debut); $date_max = min($sunday, $conge->date_fin); $where = array(); $where["sejour_id"] = " = '{$sejour->_id}'"; $where["therapeute_id"] = " = '{$conge->user_id}'"; foreach (range(0, 6) as $weekday) { $day = CMbDT::date("+{$weekday} DAYS", $monday); if (!CMbRange::in($day, $date_min, $date_max)) { $transfer_counts[$day] = 0; continue; } $after = CMbDT::date("+1 DAY", $day); $where["debut"] = "BETWEEN '{$day}' AND '{$after}'"; $count = $evenement->countList($where); $transfer_counts[$day] = $count; $transfer_count += $count; } } // Création du template $smarty = new CSmartyDP(); $smarty->assign("evenements_counts", $evenements_counts); $smarty->assign("sejours", $sejours); $smarty->assign("all_sejours", $all_sejours);
/** * Tells if it collides with another affectation * * @param self $aff Other affectation * * @return bool */ function collide($aff) { if ($this->_id && $aff->_id && $this->_id == $aff->_id) { return false; } return CMbRange::collides($this->entree, $this->sortie, $aff->entree, $aff->sortie); }
/** * Check if the object collides another * * @param CSejour $sejour Sejour * @param bool $collides_update_sejour Launch updateFormFields * * @return boolean */ function collides(CSejour $sejour, $collides_update_sejour = true) { if ($this->_id && $sejour->_id && $this->_id == $sejour->_id) { return false; } if ($this->annule || $sejour->annule) { return false; } if (in_array($this->type, $this->_not_collides) || in_array($sejour->type, $this->_not_collides)) { return false; } if (CAppUI::conf('dPplanningOp CSejour ssr_not_collides', $this->loadRefEtablissement()->_guid)) { if ($this->type == "ssr" xor $sejour->type == "ssr") { return false; } } if ($this->group_id != $sejour->group_id) { return false; } if ($collides_update_sejour) { $this->updateFormFields(); } switch ($this->conf("check_collisions")) { case "no": return false; case "date": $lower1 = CMbDT::date($this->entree); $upper1 = CMbDT::date($this->sortie); $lower2 = CMbDT::date($sejour->entree); $upper2 = CMbDT::date($sejour->sortie); break; default: case "datetime": $lower1 = $this->entree; $upper1 = $this->sortie; $lower2 = $sejour->entree; $upper2 = $sejour->sortie; break; } return CMbRange::collides($lower1, $upper1, $lower2, $upper2, false); }
$acte->evenement_ssr_id = $evenement->_id; $msg = $acte->store(); CAppUI::displayMsg($msg, "{$acte->_class}-msg-create"); } } } else { if (count($_days)) { $entree = CMbDT::date($sejour->entree); $sortie = CMbDT::date($sejour->sortie); $bilan = $sejour->loadRefBilanSSR(); $referent = $bilan->loadRefKineReferent(); $date = CValue::getOrSession("date", CMbDT::date()); $monday = CMbDT::date("last monday", CMbDT::date("+1 day", $date)); foreach ($_days as $_number) { $_day = CMbDT::date("+{$_number} DAYS", $monday); if (!CMbRange::in($_day, $entree, $sortie)) { CAppUI::setMsg("CEvenementSSR-msg-failed-bounds", UI_MSG_WARNING); continue; } if (!$_heure_deb || !$duree) { continue; } $evenement = new CEvenementSSR(); $evenement->equipement_id = $equipement_id; $evenement->debut = "{$_day} {$_heure_deb}"; $evenement->duree = $duree; $evenement->remarque = $remarque; $evenement->therapeute_id = $therapeute_id; $evenement->type_seance = $type_seance; // Transfert kiné référent => kiné remplaçant si disponible if ($therapeute_id == $referent->_id) {
/** * Calcul si la réeducation est en cours au jour donné au regard des jours ouvrés * * @param string $date_min Date minimale * @param string $date_max Date maximale * * @return bool */ function getDatesEnCours($date_min, $date_max) { $this->loadRefSejour(); return $this->_encours = CMbRange::collides($date_min, $date_max, $this->_premier_jour, $this->_dernier_jour); }
$title .= " " . substr($patient->prenom, 0, 2) . "."; } if (!$sejour_id && $_evenement->remarque) { $title .= " - " . $_evenement->remarque; } // Color $therapeute = $_evenement->loadRefTherapeute(); $function = $therapeute->loadRefFunction(); $color = "#{$function->color}"; // Classes $class = ""; if (!$_evenement->countBackRefs("actes_cdarr") && !$_evenement->countBackRefs("actes_csarr")) { $class = "zero-actes"; } $_sejour = $_evenement->_ref_sejour; if (!CMbRange::in($_evenement->debut, CMbDT::date($_sejour->entree), CMbDT::date("+1 DAY", $_sejour->sortie))) { $class = "disabled"; } if ($_evenement->realise && $selectable) { $class = "realise"; } if ($_evenement->annule && $selectable) { $class = "annule"; } $css_classes = array(); $css_classes[] = $class; $css_classes[] = $sejour->_guid; $css_classes[] = $equipement->_guid; // Title and color in prescription case if ($line = $_evenement->loadRefPrescriptionLineElement()) { $element = $line->_ref_element_prescription;
/** * Récupération de la plage de l'intervention * * @param DOMNode $node Node * @param COperation $operation Intervention * * @return void */ function mappingPlage(DOMNode $node, COperation $operation) { $debut = $this->getDebutInterv($node); // Traitement de la date/heure début, et durée de l'opération $date_op = CMbDT::date($debut); $time_op = CMbDT::time($debut); // Recherche d'une éventuelle plageOp avec la salle $plageOp = new CPlageOp(); $plageOp->chir_id = $operation->chir_id; $plageOp->salle_id = $operation->salle_id; $plageOp->date = $date_op; $plageOps = $plageOp->loadMatchingList(); // Si on a pas de plage on recherche éventuellement une plage dans une autre salle if (count($plageOps) == 0) { $plageOp->salle_id = null; $plageOps = $plageOp->loadMatchingList(); // Si on retrouve des plages alors on ne prend pas en compte la salle du flux if (count($plageOps) > 0) { $operation->salle_id = null; } } foreach ($plageOps as $_plage) { // Si notre intervention est dans la plage Mediboard if (CMbRange::in($time_op, $_plage->debut, $_plage->fin)) { $plageOp = $_plage; break; } } if ($plageOp->_id) { $operation->plageop_id = $plageOp->_id; } else { // Dans le cas où l'on avait une plage sur l'interv on la supprime $operation->plageop_id = ""; $operation->date = $date_op; } }
/** * @see parent::checkProperty() */ function checkProperty($object) { $propValue =& $object->{$this->fieldName}; // Vérification du format $matches = array(); if (!preg_match("/^([0-9]{4})-([0-9]{1,2})-([0-9]{1,2})\$/", $propValue, $matches)) { if ($propValue === 'current' || $propValue === 'now') { $propValue = CMbDT::date(); return null; } return "Format de date invalide : '{$propValue}'"; } // Mois grégorien $mois = intval($matches[2]); if (!CMbRange::in($mois, $this->progressive ? 0 : 1, 12)) { // Possibilité de mettre des mois vides () return "Mois '{$mois}' non compris entre 1 et 12 ('{$propValue}')"; } // Jour grégorien $jour = intval($matches[3]); if (!CMbRange::in($jour, $this->progressive ? 0 : 1, 31)) { return "Jour '{$jour}' non compris entre 1 et 31 ('{$propValue}')"; } }
/** * @see parent::check() */ function check() { if ($this->_forwardRefMerging) { return null; } // Vérouillage d'un événement traité $this->completeField("realise", "annule", "nb_patient_seance", "nb_intervenant_seance"); $this->_traite = $this->realise || $this->annule; if ($this->_traite && !$this->_traitement) { return "Evénément déjà traité (réalisé ou annulé)"; } // Evénement dans les bornes du séjour $this->completeField("sejour_id", "debut"); $sejour = $this->loadRefSejour(); // Vérifier seulement les jours car les sorties peuvent être imprécises pour les hospit de jours if ($sejour->_id && $this->debut) { $date_debut = CMbDT::date($this->debut); $date_entree = CMbDT::date(CMbDT::date($sejour->entree)); $date_sortie = CMbDT::date(CMbDT::date($sejour->sortie)); if (!CMbRange::in($date_debut, $date_entree, $date_sortie)) { return "Evenement SSR en dehors des dates du séjour"; } } // Cas de la réalisation des événements SSR $this->loadRefTherapeute(); // Si le therapeute n'est pas defini, c'est if ($this->therapeute_id) { $therapeute = $this->_ref_therapeute; } else { // Chargement du therapeute de la seance $evt_seance = new CEvenementSSR(); $evt_seance->load($this->seance_collective_id); $evt_seance->loadRefTherapeute(); $therapeute = $evt_seance->_ref_therapeute; } if ($this->fieldModified("realise")) { // Si le thérapeute n'a pas d'identifiant CdARR if (!$therapeute->code_intervenant_cdarr) { return CAppUI::tr("CMediusers-code_intervenant_cdarr-none"); } $therapeute->loadRefIntervenantCdARR(); $code_intervenant_cdarr = $therapeute->_ref_intervenant_cdarr->code; // Création du RHS au besoins $rhs = $this->getRHS(); if (!$rhs->_id) { $rhs->store(); } if ($rhs->facture == 1) { CAppUI::stepAjax(CAppUI::tr("CRHS.charged"), UI_MSG_WARNING); } $this->loadView(); // Complétion de la ligne RHS foreach ($this->loadRefsActesCdARR() as $_acte_cdarr) { $ligne = new CLigneActivitesRHS(); $ligne->rhs_id = $rhs->_id; $ligne->executant_id = $therapeute->_id; $ligne->code_activite_cdarr = $_acte_cdarr->code; $ligne->code_intervenant_cdarr = $code_intervenant_cdarr; $ligne->loadMatchingObject(); $ligne->crementDay($this->debut, $this->realise ? "inc" : "dec"); $ligne->auto = "1"; $ligne->store(); } foreach ($this->loadRefsActesCsARR() as $_acte_csarr) { $ligne = new CLigneActivitesRHS(); $ligne->rhs_id = $rhs->_id; $ligne->executant_id = $therapeute->_id; $ligne->code_activite_csarr = $_acte_csarr->code; $ligne->code_intervenant_cdarr = $code_intervenant_cdarr; $ligne->modulateurs = $_acte_csarr->modulateurs; $ligne->phases = $_acte_csarr->phases; $ligne->nb_patient_seance = $this->nb_patient_seance; $ligne->nb_intervenant_seance = $this->nb_intervenant_seance; $ligne->loadMatchingObject(); $ligne->crementDay($this->debut, $this->realise ? "inc" : "dec"); $ligne->auto = "1"; $ligne->store(); } } return parent::check(); }
/** * rearrange the current list of events in a optimized way * * @return null */ function rearrange() { $events = array(); //days foreach ($this->events_sorted as $_events_by_day) { $intervals = array(); // tab foreach ($_events_by_day as $_events_by_hour) { foreach ($_events_by_hour as $_event) { //used as background, skip the rearrange if ($_event->below) { $_event->width = 0.9; $_event->offset = 0.1; continue; } $intervals[$_event->internal_id] = array("lower" => $_event->start, "upper" => $_event->end); $events[$_event->internal_id] = $_event; } } $uncollided = array(); $lines = CMbRange::rearrange($intervals, true, $uncollided); $lines_count = count($lines); $this->max_height_event = $lines_count > $this->max_height_event ? $lines_count : $this->max_height_event; foreach ($lines as $_line_number => $_line) { foreach ($_line as $_event_id) { $event = $events[$_event_id]; //get the event $event->height = $_line_number; //global = first line $event->width = 1 / $lines_count; $event->offset = $_line_number / $lines_count; if ($this->allow_superposition) { $event->offset += 0.05; } if ($lines_count == 1 && $this->allow_superposition) { $event->width = $event->width - 0.1; } //the line is not the first if ($_line_number >= 1 && $this->allow_superposition) { $event->width = 1 / $lines_count + 0.05; $event->offset = abs($_line_number / $lines_count - 0.1); } // lines uncollided //TODO: fix collisions problems if (in_array($event->internal_id, array_keys($uncollided)) && $_line_number < $lines_count - 1 && !$event->below) { //$event->width = (($lines_count - ($_line_number)) / $lines_count); //$event->width = ($_line_number == 0) ? $event->width-0.1 :$event->width +.05; } } } } }
/** * Fragment un remplacement par des congés du remplacant * * @return array Fragments d'intervales de dates */ function makeFragments() { $fragments = array(); $croppers = array(); foreach ($this->_ref_replacer_conges as $_conge) { $croppers[] = array("lower" => CMbDT::date("-1 DAY", $_conge->date_debut), "upper" => CMbDT::date("+1 DAY", $_conge->date_fin)); } if (count($this->_ref_replacer_conges) > 0) { $fragments = CMbRange::multiCrop(array(array("lower" => $this->deb, "upper" => $this->fin)), $croppers); foreach ($fragments as $key => $_fragment) { if (!CMbRange::collides($this->_min_deb, $this->_max_fin, $_fragment[0], $_fragment[1])) { unset($fragments[$key]); } } } return $this->_ref_replacement_fragments = $fragments; }