Example #1
0
    $file->load($_data["file_id"]);
    $file->getDataURI();
    $_data["file_uri"] = $file->_data_uri;
}
//user
$user = CMediusers::get($user_id);
// file
$file = new CFile();
$file->setObject($context);
$file->file_name = CAppUI::tr("CFile-create-mozaic") . " de " . CAppUI::tr($context->_class) . " du " . CMbDT::dateToLocale(CMbDT::date()) . ".pdf";
$file->file_type = "application/pdf";
$file->file_category_id = $cat_id;
$file->author_id = CMediusers::get()->_id;
$file->fillFields();
$file->updateFormFields();
$file->forceDir();
$file->store();
$cr = new CCompteRendu();
$cr->_page_format = "A4";
$cr->_orientation = "portrait";
// use template for header and footer
$template_header = new CTemplateManager();
$context->fillTemplate($template_header);
$header = CCompteRendu::getSpecialModel($user, "CPatient", "[ENTETE MOZAIC]");
if ($header->_id) {
    $header->loadContent();
    $template_header->renderDocument($header->_source);
} else {
    $template_header->document = "<p style=\"text-align:center;\">" . $context->_view . "</p>";
}
$template_footer = new CTemplateManager();
Example #2
0
 /**
  * PDF conversion of a file
  *
  * @param string $file_path path to the file
  * @param string $pdf_path  path the pdf file
  *
  * @return bool
  */
 function convertToPDF($file_path = null, $pdf_path = null)
 {
     global $rootName;
     // Vérifier si openoffice est lancé
     if (!CFile::openofficeLaunched()) {
         return 0;
     }
     // Vérifier sa charge en mémoire
     CFile::openofficeOverload();
     if (!$file_path && !$pdf_path) {
         $file = new CFile();
         $file->setObject($this);
         $file->private = $this->private;
         $file->file_name = $this->file_name . ".pdf";
         $file->file_type = "application/pdf";
         $file->author_id = CAppUI::$user->_id;
         $file->fillFields();
         $file->updateFormFields();
         $file->forceDir();
         $save_name = $this->_file_path;
         if ($msg = $file->store()) {
             CAppUI::setMsg($msg, UI_MSG_ERROR);
             return 0;
         }
         $file_path = $this->_file_path;
         $pdf_path = $file->_file_path;
     }
     // Requête post pour la conversion.
     // Cela permet de mettre un time limit afin de garder le contrôle de la conversion.
     ini_set("default_socket_timeout", 10);
     $fileContents = base64_encode(file_get_contents($file_path));
     $url = CAppUI::conf("base_url") . "/index.php?m=dPfiles&a=ajax_ooo_convert&suppressHeaders=1";
     $data = array("file_data" => $fileContents, "pdf_path" => $pdf_path);
     // Fermeture de la session afin d'écrire dans le fichier de session
     CSessionHandler::writeClose();
     // Le header Connection: close permet de forcer a couper la connexion lorsque la requête est effectuée
     $ctx = stream_context_create(array('http' => array('method' => 'POST', 'header' => "Content-type: application/x-www-form-urlencoded charset=UTF-8\r\n" . "Connection: close\r\n" . "Cookie: mediboard=" . session_id() . "\r\n", 'content' => http_build_query($data))));
     // La requête post réouvre la session
     $res = file_get_contents($url, false, $ctx);
     if (isset($file) && $res == 1) {
         $file->doc_size = filesize($pdf_path);
         if ($msg = $file->store()) {
             CAppUI::setMsg($msg, UI_MSG_ERROR);
             return 0;
         }
     }
     // Si la conversion a échoué
     // on relance le service s'il ne répond plus.
     if ($res != 1) {
         CFile::openofficeOverload(1);
     }
     return $res;
 }
 /**
  * Traitement des retours en erreur d'xml d'un praticien
  *
  * @param int $chir_id praticien de la consultation
  *
  * @return void|string
  */
 static function traitementDossier($chir_id)
 {
     $files = array();
     $fs_source_reception = CExchangeSource::get("reception-tarmed-CMediusers-{$chir_id}", "file_system", true, null, false);
     if (!$fs_source_reception->_id || !$fs_source_reception->active) {
         return null;
     }
     $count_files = CMbPath::countFiles($fs_source_reception->host);
     if ($count_files < 100) {
         try {
             $files = $fs_source_reception->receive();
         } catch (CMbException $e) {
             return CAppUI::tr($e->getMessage());
         }
     }
     $delfile_read_reject = CAppUI::conf("dPfacturation Other delfile_read_reject", CGroups::loadCurrent());
     foreach ($files as $_file) {
         $fs = new CSourceFileSystem();
         $rejet = new self();
         $rejet->praticien_id = $chir_id;
         $rejet->file_name = basename($_file);
         if ($msg = $rejet->store()) {
             return $msg;
         }
         $rejet->readXML($fs->getData($_file));
         //Sauvegarde du XML en CFile
         $new_file = new CFile();
         $new_file->setObject($rejet);
         $new_file->file_name = basename($_file);
         $new_file->file_type = "application/xml";
         $new_file->author_id = CAppUI::$user->_id;
         $new_file->fillFields();
         $new_file->updateFormFields();
         $new_file->forceDir();
         $new_file->putContent(trim($fs->getData($_file)));
         if ($msg = $new_file->store()) {
             mbTrace($msg);
         }
         //Suppression du fichier selon configuration
         if ($delfile_read_reject) {
             $fs->delFile($_file);
         }
     }
     return null;
 }
Example #4
0
 /**
  * Make a PDF document archive of the sejour (based on soins/print_dossier_soins)
  *
  * @param string $title   File title
  * @param bool   $replace Replace existing file
  *
  * @return bool
  * @throws CMbException
  */
 function makePDFarchive($title = "Dossier complet", $replace = false)
 {
     if (!CModule::getActive("soins")) {
         return false;
     }
     $query = array("m" => "soins", "a" => "print_dossier_soins", "sejour_id" => $this->_id, "dialog" => 1, "offline" => 1, "limit" => 10000, "_aio" => 1, "_aio_ignore_scripts" => 1);
     $base = $_SERVER["SCRIPT_NAME"] . "?" . http_build_query($query, "", "&");
     $result = CApp::serverCall("http://127.0.0.1{$base}");
     $content = $result["body"];
     $file = new CFile();
     $file->setObject($this);
     $file->file_name = "{$title}.pdf";
     $file->file_type = "application/pdf";
     /*if ($file->loadMatchingObject()) {
           if ($replace) {
             $file->delete();
     
             // New file
             $file = new CFile();
             $file->setObject($this);
             $file->file_name = "$title.pdf";
             $file->file_type = "application/pdf";
           }
         }*/
     $file->fillFields();
     $file->updateFormFields();
     $file->forceDir();
     $file->author_id = CAppUI::$user->_id;
     $compte_rendu = new CCompteRendu();
     $compte_rendu->_orientation = "portrait";
     $format = CCompteRendu::$_page_formats["a4"];
     $page_width = round(72 / 2.54 * $format[0], 2);
     $page_height = round(72 / 2.54 * $format[1], 2);
     $compte_rendu->_page_format = array(0, 0, $page_width, $page_height);
     $content = str_replace("<!DOCTYPE html>", "", $content);
     CHtmlToPDFConverter::init("CWkHtmlToPDFConverter");
     //CHtmlToPDFConverter::init("CPrinceXMLConverter");
     $pdf = CHtmlToPDFConverter::convert($content, $compte_rendu->_page_format, $compte_rendu->_orientation);
     $file->putContent($pdf);
     if ($msg = $file->store()) {
         throw new CMbException($msg);
     }
     return true;
 }