Ejemplo n.º 1
0
 /**
  * @see parent::delete()
  */
 function delete()
 {
     // Suppression ou non de document en cours de modification
     $this->load($this->doc_ged_id);
     if (!$this->_lastactif) {
         $this->loadLastActif();
     }
     if (!$this->_lastentry) {
         $this->loadLastEntry();
     }
     if ($msg = $this->canDeleteEx()) {
         return $msg;
     }
     $this->_lastactif->delete_suivi($this->doc_ged_id, $this->_lastactif->doc_ged_suivi_id);
     if ($this->_lastactif->doc_ged_suivi_id) {
         $this->etat = self::TERMINE;
         $this->user_id = 0;
         $this->store();
     } else {
         return parent::delete();
     }
     return null;
 }
Ejemplo n.º 2
0
 /**
  * @see parent::delete()
  */
 function delete()
 {
     $consults = $this->loadRefsConsultations();
     $sejours = $this->loadRefsSejours();
     if ($msg = parent::delete()) {
         return $msg;
     }
     $msg = "";
     foreach ($consults as $_consult) {
         $_consult->grossesse_id = "";
         if ($_msg = $_consult->store()) {
             $msg .= "\n {$_msg}";
         }
     }
     foreach ($sejours as $_sejour) {
         $_sejour->grossesse_id = "";
         if ($_msg = $_sejour->store()) {
             $msg .= "\n {$_msg}";
         }
     }
     if ($msg) {
         return $msg;
     }
     return null;
 }
 /**
  * @see parent::delete()
  */
 function delete()
 {
     $this->completeField("order_item_id", "quantity");
     $this->loadRefOrderItem();
     $item = $this->_ref_order_item;
     $item->loadReference();
     $reference = $item->_ref_reference;
     $reference->loadRefProduct();
     $product = $reference->_ref_product;
     if ($product->loadRefStock()) {
         $product->_ref_stock_group->quantity -= $this->quantity;
     }
     // If the order is already flagged as received,
     // we check if it will still be after deletion
     $item->loadOrder();
     $order = $item->_ref_order;
     if ($order->_id && $order->received) {
         $count_renewed = $order->countRenewedItems();
         $count_received = $order->countReceivedItems() - (count($order->_ref_order_items) - $count_renewed);
         if ($count_received < $count_renewed) {
             $order->received = 0;
         }
     }
     if ($msg = parent::delete()) {
         return $msg;
     }
     // we store other objects only if deletion was ok !
     if ($product->_ref_stock_group && $product->_ref_stock_group->_id) {
         $product->_ref_stock_group->store();
     }
     if ($order && $order->_id) {
         $order->store();
     }
     return null;
 }
Ejemplo n.º 4
0
 /**
  * Redéfinition du delete
  *
  * @return void|string
  **/
 function delete()
 {
     if (count($this->_ref_reglements)) {
         return "Vous ne pouvez pas supprimer une facture ayant des règlements";
     }
     if (count($this->_ref_relances)) {
         return "Vous ne pouvez pas supprimer une facture ayant des relances";
     }
     if (CModule::getActive("dPfacturation")) {
         $where = array();
         $where["object_id"] = " = '{$this->_id}'";
         $where["object_class"] = " = '{$this->_class}'";
         $item = new CFactureItem();
         $items = $item->loadList($where);
         foreach ($items as $_item) {
             if ($msg = $_item->delete()) {
                 return $msg;
             }
         }
         $where = array();
         $where["facture_id"] = " = '{$this->_id}'";
         $where["facture_class"] = " = '{$this->_class}'";
         $where[] = "object_class = 'Sejour' OR object_class = 'CConsultation'";
         $liaison = new CFactureLiaison();
         $liaisons = $liaison->loadList($where);
         foreach ($liaisons as $lien) {
             if ($msg = $lien->delete()) {
                 return $msg;
             }
         }
     }
     // Standard delete
     if ($msg = parent::delete()) {
         return $msg;
     }
 }
Ejemplo n.º 5
0
 /**
  * @see parent::delete()
  */
 function delete()
 {
     $this->completeField("devenir_dentaire_id", "rank");
     /** @var CDevenirDentaire $devenir_dentaire */
     $devenir_dentaire = $this->loadFwdRef("devenir_dentaire_id");
     $actes_dentaires = $devenir_dentaire->loadRefsActesDentaires();
     foreach ($actes_dentaires as &$_acte_dentaire) {
         if ($_acte_dentaire->_id == $this->_id) {
             continue;
         }
         if ($_acte_dentaire->rank > $this->rank) {
             $_acte_dentaire->rank--;
             if ($msg = $_acte_dentaire->store()) {
                 CAppUI::setMsg($msg);
             }
         }
     }
     parent::delete();
 }
 /**
  * @see parent::delete()
  */
 function delete()
 {
     $this->completeField('delivery_id', 'quantity', 'date_delivery', 'date_reception');
     $this->loadRefsFwd();
     $stock = $this->getStock();
     $stock->loadRefsFwd();
     $infinite_group_stock = CAppUI::conf('dPstock CProductStockGroup infinite_quantity') == '1';
     $stock_service = new CProductStockService();
     $stock_service->product_id = $stock->product_id;
     $stock_service->object_id = $this->_ref_delivery->service_id;
     $stock_service->object_class = "CService";
     // XXX
     $stock_service->loadMatchingObject();
     if (!$infinite_group_stock && $this->date_delivery) {
         $stock->quantity += $this->quantity;
         if ($msg = $stock->store()) {
             return $msg;
         }
     }
     if ($stock_service->_id && $this->date_reception) {
         $stock_service->quantity -= $this->quantity;
         if ($msg = $stock_service->store()) {
             return $msg;
         }
     }
     // Calcul du stock du sejour
     if ($this->_code_cis && $this->_ref_delivery->sejour_id && CModule::getActive("pharmacie")) {
         $stock_sejour = CStockSejour::getFromCIS($this->_code_cis, $this->_ref_delivery->sejour_id);
         if ($stock_sejour->_id) {
             $codes_cip = CMedicamentProduit::getArticleCodes($this->_code_cis);
             $ds = $this->getDS();
             $where = array();
             $where["product.code"] = $ds->prepareIn($codes_cip);
             $where["product_delivery.sejour_id"] = $ds->prepare("= '{$this->_ref_delivery->sejour_id}'");
             $ljoin = array();
             $ljoin["product_stock_group"] = "product_stock_group.stock_id = product_delivery.stock_id\r\n                                           AND product_delivery.stock_class = 'CProductStockGroup'";
             $ljoin["product"] = "product.product_id = product_stock_group.product_id";
             $delivery = new CProductDelivery();
             $delivery->loadObject($where, "product_delivery.date_dispensation DESC", null, $ljoin);
             // Si la delivrance actuelle est la derniere pour ce sejour et ce CIS
             if ($delivery->_id == $this->delivery_id) {
                 // Mise a jour de la quantité du stock en quantité d'administration
                 $code_cip = $this->_ref_delivery->loadRefStock()->loadRefProduct()->code;
                 $product = CMedicamentArticle::get($code_cip);
                 if ($product->getId()) {
                     $ratio = $product->_ratio_cis_cip;
                     // Mise à jour du stock
                     $stock_sejour->datetime = $this->_ref_delivery->datetime_min;
                     $stock_sejour->quantite -= $this->quantity / $ratio;
                     $stock_sejour->quantite = round($stock_sejour->quantite, 4);
                     if ($msg = $stock_sejour->store()) {
                         return $msg;
                     }
                 }
             }
         }
     }
     return parent::delete();
 }
Ejemplo n.º 7
0
 /**
  * @see parent::delete()
  */
 function delete()
 {
     $this->completeField("type", "dossier_medical_id");
     if ($this->type == "alle") {
         $this->loadRefDossierMedical();
         $dossier_medical = $this->_ref_dossier_medical;
         if ($dossier_medical->object_class == "CPatient") {
             DSHM::remKeys("alertes-*-CPatient-" . $dossier_medical->object_id);
         }
     }
     return parent::delete();
 }
 /**
  * @see parent::delete()
  */
 function delete()
 {
     // Suppression du fichier correspondant
     if ($this->file_id) {
         $this->loadFile();
         if ($this->_ref_file->file_id) {
             $this->_ref_file->delete();
         }
     }
     //suppression de la doc
     return parent::delete();
 }
Ejemplo n.º 9
0
 /**
  * Delete object
  *
  * @param CMbObject $object Object
  *
  * @throws CMbException
  *
  * @return null|string null if successful otherwise returns and error message
  */
 static function deleteObject(CMbObject $object)
 {
     if ($msg = $object->delete()) {
         throw new CMbException($msg);
     }
     return null;
 }
Ejemplo n.º 10
0
 /**
  * @see parent::delete()
  */
 function delete()
 {
     if ($msg = $this->canDeleteEx()) {
         return $msg;
     }
     // suppression des objets des champs sans supprimer les colonnes de la table
     $fields = $this->loadRefsAllFields();
     foreach ($fields as $_field) {
         $_field->_dont_drop_column = true;
         $_field->delete();
     }
     /*$table_name = $this->getTableName();
       $query = "DROP TABLE `$table_name`";
       
       $ds = $this->_spec->ds;
       if (!$ds->query($query)) {
         return "La table '$table_name' n'a pas pu être supprimée (".$ds->error().")";
       }*/
     return parent::delete();
 }
 /**
  * @see parent::delete()
  */
 function delete()
 {
     $order = $this->loadOrder(false);
     if ($msg = parent::delete()) {
         return $msg;
     }
     if ($order->countBackRefs("order_items") == 0) {
         return $order->delete();
     }
     return null;
 }
Ejemplo n.º 12
0
 /**
  * Delete only one
  *
  * @return null|string
  */
 function deleteOne()
 {
     return parent::delete();
 }
Ejemplo n.º 13
0
 /**
  * @see parent::delete()
  */
 function delete()
 {
     $this->completeField("patient_id1", "patient_id2");
     $patient1 = $this->loadRefPatient1();
     $patient2 = $this->loadRefPatient2();
     if ($msg = parent::delete()) {
         return $msg;
     }
     if (!$patient1->loadPatientLinks()) {
         $patient1->status = $patient1->vip ? "VIP" : "PROV";
         $patient1->store();
     }
     if (!$patient2->loadPatientLinks()) {
         $patient2->status = $patient2->vip ? "VIP" : "PROV";
         $patient2->store();
     }
     return null;
 }
Ejemplo n.º 14
0
 /**
  * @see parent::delete()
  */
 function delete()
 {
     if ($msg = parent::delete()) {
         return $msg;
     }
     // Remove html content
     $content = $this->loadContentHTML();
     if ($content->_id) {
         if ($msg = $content->delete()) {
             return $msg;
         }
     }
     // Remove plain content
     $content = $this->loadContentPlain();
     if ($content->_id) {
         if ($msg = $content->delete()) {
             return $msg;
         }
     }
 }
Ejemplo n.º 15
0
 /**
  * @see parent::delete()
  */
 function delete()
 {
     $this->completeField("manual");
     //if ($this->manual) {
     /** @var CProductDeliveryTrace[] $traces */
     $traces = $this->loadBackRefs("delivery_traces");
     foreach ($traces as $_trace) {
         $_trace->_code_cis = $this->_code_cis;
         $_trace->_code_cip = $this->_code_cip;
         $_trace->delete();
     }
     //}
     return parent::delete();
 }
Ejemplo n.º 16
0
 /**
  * @see parent::delete()
  */
 function delete()
 {
     $this->completeField("taille", "poids", "patient_id");
     if ($this->taille || $this->poids) {
         DSHM::remKeys("alertes-*-CPatient-" . $this->patient_id);
     }
     return parent::delete();
 }
Ejemplo n.º 17
0
 /**
  * @see parent::delete()
  */
 function delete()
 {
     // Lors de la suppression du remplacant, on reaffecte les evenements au kine principal
     $this->completeField("sejour_id", "conge_id", "replacer_id");
     $conge = $this->loadRefConge();
     $sejour = $this->loadRefSejour();
     $bilan = $sejour->loadRefBilanSSR();
     $bilan->loadRefTechnicien();
     $date_debut = $conge->date_debut;
     $date_fin = CMbDT::date("+1 DAY", $conge->date_fin);
     $evenement_ssr = new CEvenementSSR();
     $where = array();
     $where["therapeute_id"] = " = '{$this->replacer_id}'";
     $where["sejour_id"] = " = '{$this->sejour_id}'";
     $where["debut"] = "BETWEEN '{$date_debut}' AND '{$date_fin}'";
     /** @var CEvenementSSR[] $evenements */
     $evenements = $evenement_ssr->loadList($where);
     foreach ($evenements as $_evenement) {
         $_evenement->therapeute_id = $sejour->_ref_bilan_ssr->_ref_technicien->kine_id;
         if ($msg = $_evenement->store()) {
             CAppUI::setMsg($msg, UI_MSG_WARNING);
         }
     }
     return parent::delete();
 }