/**
  * @see parent::doStore()
  */
 function doStore()
 {
     if (isset($_FILES['attachment'])) {
         $mail_id = CValue::post('mail_id');
         $mail = new CUserMail();
         $mail->load($mail_id);
         $files = array();
         foreach ($_FILES['attachment']['error'] as $key => $file_error) {
             if (isset($_FILES['attachment']['name'][$key])) {
                 $files[] = array('name' => $_FILES['attachment']['name'][$key], 'tmp_name' => $_FILES['attachment']['tmp_name'][$key], 'error' => $_FILES['attachment']['error'][$key], 'size' => $_FILES['attachment']['size'][$key]);
             }
         }
         foreach ($files as $_key => $_file) {
             if ($_file['error'] == UPLOAD_ERR_NO_FILE) {
                 continue;
             }
             if ($_file['error'] != 0) {
                 CAppUI::setMsg(CAppUI::tr("CFile-msg-upload-error-" . $_file["error"]), UI_MSG_ERROR);
                 continue;
             }
             $attachment = new CMailAttachments();
             $attachment->name = $_file['name'];
             $content_type = mime_content_type($_file['tmp_name']);
             $attachment->type = $attachment->getTypeInt($content_type);
             $attachment->bytes = $_file['size'];
             $attachment->mail_id = $mail_id;
             $content_type = explode('/', $content_type);
             $attachment->subtype = strtoupper($content_type[1]);
             $attachment->disposition = 'ATTACHMENT';
             $attachment->extension = substr(strrchr($attachment->name, '.'), 1);
             $attachment->part = $mail->countBackRefs('mail_attachments') + 1;
             $attachment->store();
             $file = new CFile();
             $file->setObject($attachment);
             $file->author_id = CAppUI::$user->_id;
             $file->file_name = $attachment->name;
             $file->file_date = CMbDT::dateTime();
             $file->fillFields();
             $file->updateFormFields();
             $file->doc_size = $attachment->bytes;
             $file->file_type = mime_content_type($_file['tmp_name']);
             $file->moveFile($_file, true);
             if ($msg = $file->store()) {
                 CAppUI::setMsg(CAppUI::tr('CMailAttachments-error-upload-file') . ':' . CAppUI::tr($msg), UI_MSG_ERROR);
                 CApp::rip();
             }
             $attachment->file_id = $file->_id;
             if ($msg = $attachment->store()) {
                 CAppUI::setMsg($msg, UI_MSG_ERROR);
                 CApp::rip();
             }
         }
         CAppUI::setMsg('CMailAttachments-msg-added', UI_MSG_OK);
     } else {
         parent::doStore();
     }
 }
 function doStore()
 {
     parent::doStore();
     $dialog = CValue::post("dialog");
     $isNew = !CValue::post("patient_id");
     $patient_id = $this->_obj->patient_id;
     if ($isNew) {
         $this->redirectStore .= "&patient_id={$patient_id}&created={$patient_id}";
     } elseif ($dialog) {
         $this->redirectStore .= "&name=" . $this->_obj->nom . "&firstname=" . $this->_obj->prenom;
     }
 }
Exemplo n.º 3
0
 function doStore()
 {
     parent::doStore();
     $dialog = CValue::post("dialog");
     if ($dialog) {
         $this->redirectStore .= "&a=pat_selector&dialog=1&name=" . $this->_obj->nom . "&firstName=" . $this->_obj->prenom . "&useVitale=" . $this->_obj->_bind_vitale;
         if (CAppUI::conf("dPpatients CPatient auto_selected_patient", CGroups::loadCurrent())) {
             $this->redirectStore .= "&patient_id=" . $this->_obj->patient_id;
         }
     } else {
         $this->redirectStore .= "&m=dPpatients&tab=vw_idx_patients&id=" . $this->_obj->patient_id;
     }
 }
Exemplo n.º 4
0
 function doStore()
 {
     global $_validation, $m;
     if (!$_validation) {
         // Pas de $_validation ==> pas d'edition de la fiche
         if (!$this->_old->fiche_ei_id) {
             // Nouvelle fiche
             $this->_obj->date_fiche = CMbDT::dateTime();
         } elseif ($this->_old->qualite_date_validation) {
             // NE RIEN FAIRE !! -> Attente de verif et de controle
         } elseif (!$this->_old->qualite_date_validation && $this->_old->service_date_validation) {
             $this->_obj->qualite_date_validation = CMbDT::dateTime();
         } elseif (!$this->_old->service_date_validation && $this->_old->date_validation) {
             $this->_obj->service_date_validation = CMbDT::dateTime();
         } elseif (!$this->_old->date_validation) {
             $this->_obj->date_validation = CMbDT::dateTime();
         }
     }
     $this->redirectStore = "m={$m}&tab=vw_incidentvalid";
     parent::doStore();
 }
Exemplo n.º 5
0
 function doStore()
 {
     parent::doStore();
     if (CModule::getActive("dPprescription") && !$this->_old->_id) {
         $p_to_c = new CPrescriptionProtocoleToConcept();
         $count_p_to_c = $p_to_c->countList();
         if ($count_p_to_c > 0) {
             /** @var CExObject $ex_object */
             $ex_object = $this->_obj;
             $all_fields = $ex_object->loadRefExClass()->loadRefsAllFields();
             $bool_concept_ids = array();
             foreach ($all_fields as $_field) {
                 if (strpos($_field->prop, "bool") === 0 && $_field->concept_id && $ex_object->{$_field->name} == "1") {
                     $bool_concept_ids[] = $_field->concept_id;
                 }
             }
             $bool_concept_ids = array_unique($bool_concept_ids);
             $where = array("concept_id" => $p_to_c->getDS()->prepareIn($bool_concept_ids));
             $protocole_ids = array_values(CMbArray::pluck($p_to_c->loadList($where), "protocole_id"));
             if (count($protocole_ids)) {
                 /** @var CSejour $sejour */
                 $sejour = $ex_object->getReferenceObject("CSejour");
                 if ($sejour && $sejour->_id) {
                     $prescription = $sejour->loadRefPrescriptionSejour();
                     if (!$prescription->_id) {
                         $prescription = new CPrescription();
                         $prescription->object_id = $sejour->_id;
                         $prescription->object_class = $sejour->_class;
                         $prescription->type = "sejour";
                         if ($msg = $prescription->store()) {
                             CAppUI::setMsg($msg, UI_MSG_WARNING);
                         }
                     }
                     $ops_ids = implode("-", CMbArray::pluck($sejour->loadRefsOperations(array("annulee" => "= '0'")), "operation_id"));
                     CAppUI::callbackAjax("window.opener.ExObject.checkOpsBeforeProtocole", $protocole_ids, $prescription->_id, $sejour->_id, $ops_ids);
                 }
             }
         }
     }
 }
<?php

/**
 * $Id$
 *
 * @package    Mediboard
 * @subpackage Labo
 * @author     SARL OpenXtrem <*****@*****.**>
 * @license    GNU General Public License, see http://www.gnu.org/licenses/gpl.html
 * @version    $Revision$
 */
$do = new CDoObjectAddEdit("CPrescriptionLaboExamen");
$pack = new CPackExamensLabo();
$pack->load($_POST["_pack_examens_labo_id"]);
$pack->loadRefs();
foreach ($pack->_ref_items_examen_labo as $item) {
    $_POST["examen_labo_id"] = $item->_ref_examen_labo->_id;
    $_POST["pack_examens_labo_id"] = $pack->_id;
    $do->doBind();
    $do->doStore();
}
$do->ajax = 1;
$do->doRedirect();
 /**
  * @see parent::doStore()
  */
 function doStore()
 {
     $upload = null;
     if (CValue::POST("_from_yoplet") == 1) {
         /** @var CFile $obj */
         $obj = $this->_obj;
         $array_file_name = array();
         $path = CAppUI::conf("dPfiles yoplet_upload_path");
         if (!$path) {
             $path = "tmp";
         }
         // On retire les backslashes d'escape
         $file_name = stripslashes($this->request['_file_path']);
         // Récupération du nom de l'image en partant de la fin de la chaîne
         // et en rencontrant le premier \ ou /
         preg_match('@[\\\\/]([^\\\\/]*)$@i', $file_name, $array_file_name);
         $file_name = $array_file_name[1];
         $extension = strrchr($file_name, '.');
         $_rename = $this->request['_rename'] ? $this->request['_rename'] : 'upload';
         $file_path = "{$path}/" . $this->request['_checksum'];
         $obj->file_name = $_rename == 'upload' ? $file_name : $_rename . $extension;
         $obj->_old_file_path = $this->request['_file_path'];
         $obj->doc_size = filesize($file_path);
         $obj->author_id = CAppUI::$user->_id;
         if (CModule::getActive("cda")) {
             $obj->type_doc = $this->request["type_doc"];
         }
         $obj->fillFields();
         $obj->updateFormFields();
         $obj->file_type = CMbPath::guessMimeType($file_name);
         if ($msg = $obj->store()) {
             CAppUI::setMsg($msg, UI_MSG_ERROR);
         } else {
             $obj->forceDir();
             $obj->moveFile($file_path);
         }
         return parent::doStore();
     }
     $_file_category_id = CValue::post("_file_category_id");
     $language = CValue::post("language");
     $type_doc = CValue::post("type_doc");
     $named = CValue::post("named");
     $rename = CValue::post("_rename");
     CValue::setSession("_rename", $rename);
     if (isset($_FILES["formfile"])) {
         $aFiles = array();
         $upload =& $_FILES["formfile"];
         foreach ($upload["error"] as $fileNumber => $etatFile) {
             if (!$named) {
                 $rename = $rename ? $rename . strrchr($upload["name"][$fileNumber], '.') : "";
             }
             if ($upload["name"][$fileNumber]) {
                 $aFiles[] = array("_mode" => "file", "name" => $upload["name"][$fileNumber], "type" => CMbPath::guessMimeType($upload["name"][$fileNumber]), "tmp_name" => $upload["tmp_name"][$fileNumber], "error" => $upload["error"][$fileNumber], "size" => $upload["size"][$fileNumber], "language" => $language, "type_doc" => $type_doc, "file_category_id" => $_file_category_id, "object_id" => CValue::post("object_id"), "object_class" => CValue::post("object_class"), "_rename" => $rename);
             }
         }
         // Pasted images, via Data uri
         if (!empty($_POST["formdatauri"])) {
             $data_uris = $_POST["formdatauri"];
             $data_names = $_POST["formdatauri_name"];
             foreach ($data_uris as $fileNumber => $fileContent) {
                 $parsed = $this->parseDataUri($fileContent);
                 $_name = $data_names[$fileNumber];
                 if (!$named) {
                     $ext = strrchr($_name, '.');
                     if ($ext === false) {
                         $ext = "." . substr(strrchr($parsed["mime"], '/'), 1);
                         $_name .= $ext;
                     }
                     $rename = $rename ? $rename . $ext : "";
                 }
                 $temp = tempnam(sys_get_temp_dir(), "up_");
                 file_put_contents($temp, $parsed["data"]);
                 if ($data_names[$fileNumber]) {
                     $aFiles[] = array("_mode" => "datauri", "name" => $_name, "type" => $parsed["mime"], "tmp_name" => $temp, "error" => 0, "size" => strlen($parsed["data"]), "language" => $language, "type_doc" => $type_doc, "file_category_id" => $_file_category_id, "object_id" => CValue::post("object_id"), "object_class" => CValue::post("object_class"), "_rename" => $rename);
                 }
             }
         }
         $merge_files = CValue::post("_merge_files");
         if ($merge_files) {
             $pdf = new CMbPDFMerger();
             $this->_obj = new $this->_obj->_class();
             /** @var CFile $obj */
             $obj = $this->_obj;
             $file_name = "";
             $nb_converted = 0;
             foreach ($aFiles as $key => $file) {
                 $converted = 0;
                 if ($file["error"] == UPLOAD_ERR_NO_FILE) {
                     continue;
                 }
                 if ($file["error"] != 0) {
                     CAppUI::setMsg(CAppUI::tr("CFile-msg-upload-error-" . $file["error"]), UI_MSG_ERROR);
                     continue;
                 }
                 // Si c'est un pdf, on le rajoute sans aucun traitement
                 if (substr(strrchr($file["name"], '.'), 1) == "pdf") {
                     $file_name .= substr($file["name"], 0, strpos($file["name"], '.'));
                     $pdf->addPDF($file["tmp_name"], 'all');
                     $nb_converted++;
                     $converted = 1;
                 } else {
                     if ($obj->isPDFconvertible($file["name"]) && $obj->convertToPDF($file["tmp_name"], $file["tmp_name"] . "_converted")) {
                         $pdf->addPDF($file["tmp_name"] . "_converted", 'all');
                         $file_name .= substr($file["name"], 0, strpos($file["name"], '.'));
                         $nb_converted++;
                         $converted = 1;
                     } else {
                         $other_file = new CFile();
                         $other_file->bind($file);
                         $other_file->file_name = $file["name"];
                         $other_file->file_type = $file["type"];
                         $other_file->doc_size = $file["size"];
                         $other_file->fillFields();
                         $other_file->private = CValue::post("private");
                         if (false == ($res = $other_file->moveTemp($file))) {
                             CAppUI::setMsg("Fichier non envoyé", UI_MSG_ERROR);
                             continue;
                         }
                         $other_file->author_id = CAppUI::$user->_id;
                         if ($msg = $other_file->store()) {
                             CAppUI::setMsg("Fichier non enregistré: {$msg}", UI_MSG_ERROR);
                             continue;
                         }
                         CAppUI::setMsg("Fichier enregistré", UI_MSG_OK);
                     }
                 }
                 // Pour le nom du pdf de fusion, on concatène les noms des fichiers
                 if ($key != count($aFiles) - 1 && $converted) {
                     $file_name .= "-";
                 }
             }
             // Si des fichiers ont été convertis et ajoutés à PDFMerger,
             // création du cfile.
             if ($nb_converted) {
                 $obj->file_name = $file_name . ".pdf";
                 $obj->file_type = "application/pdf";
                 $obj->author_id = CAppUI::$user->_id;
                 $obj->private = CValue::post("private");
                 $obj->object_id = CValue::post("object_id");
                 $obj->object_class = CValue::post("object_class");
                 $obj->updateFormFields();
                 $obj->fillFields();
                 $obj->forceDir();
                 $tmpname = tempnam("/tmp", "pdf_");
                 $pdf->merge('file', $tmpname);
                 $obj->doc_size = strlen(file_get_contents($tmpname));
                 $obj->moveFile($tmpname);
                 //rename($tmpname, $obj->_file_path . "/" .$obj->file_real_filename);
                 if ($msg = $obj->store()) {
                     CAppUI::setMsg("Fichier non enregistré: {$msg}", UI_MSG_ERROR);
                 } else {
                     CAppUI::setMsg("Fichier enregistré", UI_MSG_OK);
                 }
             }
         } else {
             foreach ($aFiles as $file) {
                 if ($file["error"] == UPLOAD_ERR_NO_FILE) {
                     continue;
                 }
                 if ($file["error"] != 0) {
                     CAppUI::setMsg(CAppUI::tr("CFile-msg-upload-error-" . $file["error"]), UI_MSG_ERROR);
                     continue;
                 }
                 // Reinstanciate
                 $this->_obj = new $this->_obj->_class();
                 /** @var CFile $obj */
                 $obj = $this->_obj;
                 $obj->bind($file);
                 $obj->file_name = empty($file["_rename"]) ? $file["name"] : $file["_rename"];
                 $obj->file_type = $file["type"];
                 if ($obj->file_type == "application/x-download") {
                     $obj->file_type = CMbPath::guessMimeType($obj->file_name);
                 }
                 $obj->doc_size = $file["size"];
                 $obj->fillFields();
                 $obj->private = CValue::post("private");
                 if ($file["_mode"] == "file") {
                     $res = $obj->moveTemp($file);
                 } else {
                     $res = $obj->moveFile($file["tmp_name"]);
                 }
                 if (false == $res) {
                     CAppUI::setMsg("Fichier non envoyé", UI_MSG_ERROR);
                     continue;
                 }
                 // File owner on creation
                 if (!$obj->file_id) {
                     $obj->author_id = CAppUI::$user->_id;
                 }
                 if ($msg = $obj->store()) {
                     CAppUI::setMsg("Fichier non enregistré: {$msg}", UI_MSG_ERROR);
                     continue;
                 }
                 CAppUI::setMsg("Fichier enregistré", UI_MSG_OK);
             }
         }
         // Redaction du message et renvoi
         if (CAppUI::isMsgOK() && $this->redirectStore) {
             $this->redirect =& $this->redirectStore;
         }
         if (!CAppUI::isMsgOK() && $this->redirectError) {
             $this->redirect =& $this->redirectError;
         }
     } else {
         parent::doStore();
     }
 }
 /**
  * @see parent::doStore()
  */
 function doStore()
 {
     /** @var CUserMail $mail */
     $mail = $this->_obj;
     $mail->date_inbox = CMbDT::dateTime();
     $mail->date_read = $mail->date_inbox;
     $content_html = new CContentHTML();
     $mail->_content = CUserMail::purifyHTML($mail->_content);
     $content_html->content = $mail->_content;
     if (!($msg = $content_html->store())) {
         $mail->text_html_id = $content_html->_id;
         $mail->_text_html = $content_html;
     }
     $content_plain = new CContentAny();
     $content_plain->content = strip_tags($mail->_content);
     if (!($msg = $content_plain->store())) {
         $mail->text_plain_id = $content_plain->_id;
     }
     $hash = CMbSecurity::hash(CMbSecurity::SHA256, "==FROM==\n{$mail->from}\n==TO==\n{$mail->to}\n==SUBJECT==\n{$mail->subject}\n==CONTENT==\n{$mail->_content}");
     if ($msg = $mail->store()) {
         CAppUI::setMsg($msg, UI_MSG_ERROR);
         return parent::doStore();
     }
     $action = CValue::post('action');
     switch ($action) {
         case 'draft':
             $mail->draft = '1';
             CAppUI::setMsg('CUserMail-msg-drafted', UI_MSG_OK);
             break;
         case 'send':
             $mail->sent = '1';
             $mail->draft = '0';
             $account = $mail->loadAccount();
             if ($mail->_is_apicrypt) {
                 /** @var CSourceSMTP $smtp */
                 $smtp = CExchangeSource::get("mediuser-{$account->object_id}-apicrypt", 'smtp');
             } else {
                 /** @var CSourceSMTP $smtp */
                 $smtp = CExchangeSource::get("mediuser-{$account->object_id}", 'smtp');
             }
             $smtp->init();
             foreach (explode(',', $mail->to) as $_address) {
                 $smtp->addTo($_address);
             }
             if ($mail->cc != '') {
                 foreach (explode(',', $mail->cc) as $_address) {
                     $smtp->addCc($_address);
                 }
             }
             if ($mail->bcc != '') {
                 foreach (explode(',', $mail->bcc) as $_address) {
                     $smtp->addBcc($_address);
                 }
             }
             $smtp->setSubject($mail->subject);
             if ($mail->_is_apicrypt) {
                 $receiver = explode(',', $mail->to);
                 $body = CApicrypt::encryptBody($account->object_id, $receiver[0], $mail->_content);
                 $smtp->setBody($body);
             } else {
                 $smtp->setBody($mail->_content);
             }
             /** @var CMailAttachments[] $attachments */
             $attachments = $mail->loadAttachments();
             foreach ($attachments as $_attachment) {
                 $file = $_attachment->loadFiles();
                 $smtp->addAttachment($file->_file_path, $file->file_name);
             }
             try {
                 $smtp->send();
                 CAppUI::setMsg('CUserMail-msg-sent', UI_MSG_OK);
             } catch (phpmailerException $e) {
                 CAppUI::setMsg($e->errorMessage(), UI_MSG_ERROR);
             } catch (CMbException $e) {
                 $e->stepAjax();
             }
             break;
         default:
     }
     $mail->store();
     if (CAppUI::isMsgOK() && $this->redirectStore) {
         $this->redirect =& $this->redirectStore;
     }
     if (!CAppUI::isMsgOK() && $this->redirectError) {
         $this->redirect =& $this->redirectError;
     }
 }
Exemplo n.º 9
0
 function doStore()
 {
     $this->_obj->resetModifications();
     parent::doStore();
 }