/** * Retourne la source d'un document * * @category CompteRendu * @package Mediboard * @author SARL OpenXtrem <*****@*****.**> * @license GNU General Public License, see http://www.gnu.org/licenses/gpl.html * @version SVN: $Id:\$ * @link http://www.mediboard.org */ CCanDo::checkRead(); $cr_id = CValue::get("compte_rendu_id"); $update_date_print = CValue::get("update_date_print", 0); $cr = new CCompteRendu(); $cr->load($cr_id); if (!$cr->_id) { return; } $cr->loadContent(); if (!$cr->canRead()) { return; } // Mise à jour de la date d'impression if ($update_date_print) { $cr->date_print = "now"; if ($msg = $cr->store()) { CAppUI::setMsg($msg, UI_MSG_ERROR); } } echo "<!DOCTYPE html>\n<html>\n\t<head>\n\t <link type=\"text/css\" rel=\"stylesheet\" href=\"style/mediboard/htmlarea.css\" media=\"all\" />\n\t</head>\n\t<body>\n\t {$cr->_source}\n\t</body>\n</html>";
$pack_id = CValue::get("pack_id", 0); $object_id = CValue::get("object_id", 0); $switch_mode = CValue::get("switch_mode", 0); $target_id = CValue::get("target_id"); $target_class = CValue::get("target_class"); $force_fast_edit = CValue::get("force_fast_edit", 0); // Faire ici le test des différentes variables dont on a besoin $compte_rendu = new CCompteRendu(); // Modification d'un document if ($compte_rendu_id) { $compte_rendu->load($compte_rendu_id); if (!$compte_rendu->_id) { CAppUI::stepAjax(CAppUI::tr("CCompteRendu-alert_doc_deleted")); CApp::rip(); } $compte_rendu->loadContent(); $compte_rendu->loadComponents(); $compte_rendu->loadFile(); } else { if ($modele_id == 0 && !$pack_id) { $compte_rendu->valueDefaults(); $compte_rendu->object_id = $object_id; $compte_rendu->object_class = $target_class; $compte_rendu->_ref_object = new $target_class(); $compte_rendu->_ref_object->load($object_id); $compte_rendu->updateFormFields(); } else { $compte_rendu->load($modele_id); $compte_rendu->loadFile(); $compte_rendu->loadContent(); $compte_rendu->_id = null;
if ($preface_id) { $component = new CCompteRendu(); $component->load($preface_id); $component->loadContent(); $preface = $component->_source; } if ($ending_id) { $component = new CCompteRendu(); $component->load($ending_id); $component->loadContent(); $ending = $component->_source; } if ($footer_id) { $component = new CCompteRendu(); $component->load($footer_id); $component->loadContent(); $footer = $component->_source; $sizefooter = $component->height; } $content = $compte_rendu->loadHTMLcontent($content, $mode, $margins, CCompteRendu::$fonts[$compte_rendu->font], $compte_rendu->size, true, $type, $header, $sizeheader, $footer, $sizefooter, $preface, $ending); } } else { $content = $compte_rendu->loadHTMLcontent($content, $mode, $margins, CCompteRendu::$fonts[$compte_rendu->font], $compte_rendu->size); } // Traitement du format de la page if ($page_format == "") { $page_width = round(72 / 2.54 * $page_width, 2); $page_height = round(72 / 2.54 * $page_height, 2); $page_format = array(0, 0, $page_width, $page_height); } // Création du CFile si inexistant
/** * Remplace l'entête ou le pied de page dans une source html * * @param string $source HTML source * @param int $component_id Id of the component * @param string $type Type of the component * * @return string */ static function replaceComponent($source, $component_id, $type = "header") { if (strpos($source, "<style type=\"text/css\">") === false) { $source = "<style type=\"text/css\">\n #header {\n height: 0px;\n /*DOMPDF top: 0;*/\n }\n\n #footer {\n height: 0px;\n /*DOMPDF bottom: 0;*/\n }\n @media print {\n body {\n margin-top: 0px;\n }\n hr.pagebreak {\n padding-top: 0px;\n }\n }\n @media dompdf {\n body {\n margin-bottom: 0px;\n }\n hr.pagebreak {\n padding-top: 0px;\n }\n }</style>\n <div id=\"body\">" . $source . "</div>"; } switch ($type) { case "header": $header = new CCompteRendu(); $header->load($component_id); $header->loadContent(true); if ($header->_source) { $header->_source = "<div id=\"header\">" . $header->_source . "</div>"; } $height = $header->height ? $header->height : 0; $source = preg_replace("/(#header\\s*\\{\\s*height:\\s*)([0-9]*[\\.0-9]*)px;/", '${1}' . $height . 'px;', $source); $source = preg_replace("/(body\\s*\\{\\s*margin-top:\\s*)([0-9]*[\\.0-9]*)px;/", '${1}' . $height . 'px;', $source); $source = preg_replace("/(body\\s*\\{\\s*padding-top:\\s*)([0-9]*[\\.0-9]*)px;/", '${1}' . $height . 'px;', $source); $source = preg_replace("/(hr.pagebreak\\s*\\{\\s*padding-top:\\s*)([0-9]*[\\.0-9]*)px;/", '${1}' . $height . 'px;', $source, 1); $pos_style = strpos($source, "</style>") + 9; $pos_header = strpos($source, "<div id=\"header\""); $pos_footer = strpos($source, "<div id=\"footer\""); $pos_body = strpos($source, "<div id=\"body\">"); if ($pos_header) { if ($pos_footer) { $source = substr_replace($source, $header->_source, $pos_header, $pos_footer - $pos_header); } else { $source = substr_replace($source, $header->_source, $pos_header, $pos_body - $pos_header); } } else { if ($pos_footer) { $source = substr_replace($source, $header->_source, $pos_style, $pos_footer - $pos_style); } else { $source = substr_replace($source, $header->_source, $pos_style, 0); } } break; case "footer": $footer = new CCompteRendu(); $footer->load($component_id); $footer->loadContent(true); if ($footer->_source) { $footer->_source = "<div id=\"footer\">" . $footer->_source . "</div>"; } $height = $footer->height ? $footer->height : 0; $source = preg_replace("/(#footer\\s*\\{\\s*footer:\\s*)([0-9]+[\\.0-9]*)px;/", '${1}' . $height . 'px;', $source); $source = preg_replace("/(body\\s*\\{\\s*margin-bottom:\\s*)([0-9]+[\\.0-9]*)px;/", '${1}' . $height . 'px;', $source); $pos_footer = strpos($source, "<div id=\"footer\""); $pos_body = strpos($source, "<div id=\"body\">"); if ($pos_footer) { $source = substr_replace($source, $footer->_source, $pos_footer, $pos_body - $pos_footer); } else { $source = substr_replace($source, $footer->_source, $pos_body, 0); } } return $source; }
foreach ($sejours as $_sejour) { $_sejour->loadRefPatient(); $_sejour->loadRefPraticien(); } CSejour::massLoadNDA($sejours); CPatient::massLoadIPP($patients); CStoredObject::massCountBackRefs($sejours, "affectations"); CStoredObject::massCountBackRefs($sejours, "consultations"); CStoredObject::massCountBackRefs($sejours, "files"); // Tri par nom de patient $sorter = CMbArray::pluck($sejours, "_ref_patient", "nom"); array_multisort($sorter, SORT_ASC, $sejours); // Chargement du modèle $modele = new CCompteRendu(); $modele->load($modele_id); $modele->loadContent(); $source = $modele->generateDocFromModel(); $nbDoc = array(); foreach ($sejours as $_sejour) { $compte_rendu = new CCompteRendu(); $compte_rendu->setObject($_sejour); $compte_rendu->nom = $modele->nom; $compte_rendu->modele_id = $modele->_id; $compte_rendu->margin_top = $modele->margin_top; $compte_rendu->margin_bottom = $modele->margin_bottom; $compte_rendu->margin_left = $modele->margin_left; $compte_rendu->margin_right = $modele->margin_right; $compte_rendu->page_height = $modele->page_height; $compte_rendu->page_width = $modele->page_width; $compte_rendu->fast_edit = $modele->fast_edit; $compte_rendu->fast_edit_pdf = $modele->fast_edit_pdf;
$object->fillTemplate($template); $cr = new CCompteRendu(); $cr->modele_id = $modele->_id; $cr->object_class = $object_class; $cr->object_id = $object_id; $cr->author_id = $user_id; $cr->nom = $modele->nom; $cr->margin_right = $modele->margin_right; $cr->margin_left = $modele->margin_left; $cr->margin_top = $modele->margin_top; $cr->margin_bottom = $modele->margin_bottom; $cr->file_category_id = $modele->file_category_id; $cr->font = $modele->font; $cr->size = $modele->size; $cr->factory = $modele->factory; $cr->loadContent(false); $cr->_source = $modele->generateDocFromModel(); $template->applyTemplate($cr); $cr->_source = $template->document; if ($msg = $cr->store()) { CAppUI::setMsg($msg, UI_MSG_ERROR); } if ($_modele_to_pack === $first) { $cr_to_push = $cr; } } if ($callback && $cr_to_push) { $fields = $cr_to_push->getProperties(); CAppUI::callbackAjax($callback, $cr_to_push->_id, $fields); } CAppUI::setMsg(CAppUI::tr("CPack-msg-create"), UI_MSG_OK);
/** * $Id$ * * @category Modèles * @package Mediboard * @author SARL OpenXtrem <*****@*****.**> * @license GNU General Public License, see http://www.gnu.org/licenses/gpl.html * @version $Revision$ * @link http://www.mediboard.org */ CCanDo::checkRead(); $modele_id = CValue::get("modele_id"); $modele = new CCompteRendu(); $modele->load($modele_id); $modele->loadContent(true); $doc = new CMbXMLDocument(null); $root = $doc->createElement("CCompteRendu"); $doc->appendChild($root); foreach (CCompteRendu::$fields_import_export as $_field) { ${$_field} = $doc->createElement($_field); $textnode = $doc->createTextNode(utf8_encode($modele->{$_field})); ${$_field}->appendChild($textnode); $root->appendChild(${$_field}); } // Attribut modele_id $key = $doc->createAttribute("modele_id"); $value = $doc->createTextNode($modele->_id); $key->appendChild($value); $root->appendChild($key); // Catégorie