/** * @see parent::store() */ function store() { $this->completeField("pour_compte_id", "chir_id"); $change_pour_compte = $this->fieldModified("pour_compte_id"); if ($msg = parent::store()) { return $msg; } if ($change_pour_compte) { $consults = $this->loadRefsConsultations(); foreach ($consults as $_consult) { $facture = $_consult->loadRefFacture(); $facture->praticien_id = $this->pour_compte_id ? $this->pour_compte_id : $this->chir_id; $facture->store(); } } // pause if ($this->_update_pause && $this->_pause && $this->_pause_repeat_time) { $consult = new CConsultation(); $where = array(); $where["plageconsult_id"] = " = '{$this->_id}' "; $where["patient_id"] = " IS NULL"; $consult->loadObject($where); $consult->plageconsult_id = $this->_id; $consult->heure = $this->_pause; $consult->duree = $this->_pause_repeat_time; $consult->chrono = 16; $consult->_hour = null; $consult->_min = null; if ($msg = $consult->store()) { CAppUI::stepAjax($msg, UI_MSG_WARNING); } } return null; }
/** * @see parent::store() */ function store() { $this->updatePlainFields(); $this->completeField("chir_id", "spec_id"); $old = new CPlageOp(); if ($this->_id) { $old->load($this->_id); $old->loadRefsOperations(); } // Pas de changement de date si on a déjà des interventions if ($this->fieldModified("date") && count($old->_ref_operations)) { return CAppUI::tr("CPlageOp-failed-change_date", count($old->_ref_operations)); } // Erreur si on est en multi-praticiens, qu'il y a des interventions et qu'on veut mettre un praticien if ($this->fieldValued("chir_id") && !$this->unique_chir && $old->spec_id && count($old->_ref_operations)) { mbTrace("all the same to me"); } if (null !== $this->chir_id && $this->_id && !$this->unique_chir) { if (count($old->_ref_operations) && $old->spec_id && $this->chir_id) { return CAppUI::tr("CPlageOp-failed-multi_chir", count($old->_ref_operations)); } } // Si on change de praticien alors qu'il y a déjà des interventions if ($this->fieldAltered("chir_id") && count($old->_ref_operations)) { // Si certaines ne sont pas annulées, on sort if ($this->countOperationsAnnulees() != count($old->_ref_operations)) { return CAppUI::tr("CPlageOp-failed-change_chir", count($old->_ref_operations)); } // Si toutes les interventions sont annulées, on les met hors plage $this->completeField("salle_id", "date"); foreach ($old->_ref_operations as $_op) { $_op->plageop_id = ""; $_op->date = $this->date; $_op->salle_id = $this->salle_id; $_op->store(); } } // Erreur si on créé-modifie une plage sur une salle bloquée $salle = $this->loadRefSalle(); if (count($salle->loadRefsBlocages($this->date))) { return CAppUI::tr("CPlageOp-failed-use_locked_room", $salle->_view); } // Modification du salle_id de la plage -> repercussion sur les interventions if ($this->fieldModified("salle_id")) { foreach ($old->_ref_operations as $_operation) { if ($_operation->salle_id == $old->salle_id) { $_operation->salle_id = $this->salle_id; $_operation->store(false); } } } // Modification du début de la plage ou des minutes entre les interventions $this->completeField("debut", "temps_inter_op"); if ($this->fieldModified("debut") || $this->fieldModified("temps_inter_op")) { if ($this->fieldModified("temps_inter_op")) { $with_cancelled = CAppUI::conf("dPplanningOp COperation save_rank_annulee_validee"); $this->loadRefsOperations($with_cancelled, "rank, rank_voulu, horaire_voulu", true); } $this->reorderOp(); } if (!$this->_id || !$this->original_owner_id && !$this->original_function_id) { $this->original_owner_id = $this->chir_id; $this->original_function_id = $this->spec_id; } return parent::store(); }