<?php /** * $Id$ * * @package Mediboard * @subpackage Hospi * @author SARL OpenXtrem <*****@*****.**> * @license GNU General Public License, see http://www.gnu.org/licenses/gpl.html * @version $Revision$ */ CCanDo::checkRead(); $printer_id = CView::get("printer_id", "num default|0", true); CView::checkin(); $printer = new CPrinter(); $ljoin = array("functions_mediboard" => "functions_mediboard.function_id = printer.function_id"); $where = array("functions_mediboard.group_id" => "= '" . CGroups::loadCurrent()->_id . "'"); $printers = $printer->loadList($where, "object_id, text", null, null, $ljoin); foreach ($printers as $_printer) { $_printer->loadTargetObject(); $_printer->loadRefFunction(); } $smarty = new CSmartyDP(); $smarty->assign("printers", $printers); $smarty->assign("printer_id", $printer_id); $smarty->display("inc_list_printers.tpl");
$printer_bvr->loadMatchingObject(); if (!$printer_bvr->_id) { CAppUI::setMsg("Les imprimantes ne sont pas paramétrées", UI_MSG_ERROR); echo CAppUI::getMsg(); return false; } else { $file = new CFile(); $file->object_id = $journal->checklist_id; $file->object_class = "CJournalBill"; $file->loadMatchingObject(); $printer_bvr->loadRefSource()->sendDocument($file); } if (!$uniq_checklist) { $factures = $journal->loadRefsFacture(); if (count($factures)) { $printer_justif = new CPrinter(); $printer_justif->function_id = $user->function_id; $printer_justif->label = "justif"; $printer_justif->loadMatchingObject(); if (!$printer_justif->_id) { CAppUI::setMsg("Les imprimantes ne sont pas paramétrées", UI_MSG_ERROR); echo CAppUI::getMsg(); return false; } $file = new CFile(); foreach ($factures as $facture) { $facture_pdf = new CEditPdf(); $facture_pdf->factures = array($facture); $pdf = ""; $pdf = $facture_pdf->editFactureBVR(false, "S"); $file_path = tempnam("tmp", "facture");
<?php /** * $Id$ * * @package Mediboard * @subpackage Hospi * @author SARL OpenXtrem <*****@*****.**> * @license GNU General Public License, see http://www.gnu.org/licenses/gpl.html * @version $Revision$ */ $printer_id = CValue::getOrSession("printer_id", 0); $printer = new CPrinter(); $order_by = "object_id, text"; $ljoin = array(); $ljoin["functions_mediboard"] = "functions_mediboard.function_id = printer.function_id"; $printers = $printer->loadList(null, $order_by, null, null, $ljoin); foreach ($printers as $_printer) { $_printer->loadTargetObject(); $_printer->loadRefFunction(); } $smarty = new CSmartyDP(); $smarty->assign("printers", $printers); $smarty->assign("printer_id", $printer_id); $smarty->display("inc_list_printers.tpl");
/** * Edition des journaux selon le type * * @param bool $read lecture * @param bool $create_journal Création du journal * * @return void */ function editJournal($read = true, $create_journal = true) { if ($create_journal) { $journal = new CJournalBill(); $journal->type = $this->type_pdf; $journal->nom = "Journal_" . $this->type_pdf . "_" . CMbDT::date(); $journal->_factures = $this->factures; if ($msg = $journal->store()) { mbTrace($msg); } else { $this->journal_id = $journal->_id; } } // Creation du PDF $this->pdf = new CMbPdf('l', 'mm'); $this->pdf->setPrintHeader(false); $this->pdf->setPrintFooter(false); $this->font = "vera"; $this->fontb = $this->font . "b"; $this->pdf->setFont($this->font, '', 8); $this->page = 0; $this->editEntete(); switch ($this->type_pdf) { case "paiement": $this->editPaiements(); break; case "debiteur": $this->editDebiteur(); break; case "rappel": $this->editRappel(); break; case "checklist": $this->editCheckList(); break; } if ($create_journal) { $file = new CFile(); $file->file_name = $journal->nom . ".pdf"; $file->file_type = "application/pdf"; $file->author_id = CMediusers::get()->_id; $file->file_category_id = 1; $file->setObject($journal); $file->fillFields(); $file->putContent($this->pdf->Output('Factures.pdf', "S")); if ($msg = $file->store()) { echo $msg; } if ($this->type_pdf == "checklist") { $user = CMediusers::get(); $printer = new CPrinter(); $printer->function_id = $user->function_id; $printer->label = "justif"; $printer->loadMatchingObject(); if (!$printer->_id) { CAppUI::setMsg("Les imprimantes ne sont pas paramétrées", UI_MSG_ERROR); echo CAppUI::getMsg(); return false; } $file = new CFile(); $pdf = $this->pdf->Output('Factures.pdf', "S"); $file_path = tempnam("tmp", "facture"); $file->_file_path = $file_path; file_put_contents($file_path, $pdf); $printer->loadRefSource()->sendDocument($file); unlink($file_path); } } if ($read) { //Affichage du fichier pdf $this->pdf->Output('Factures.pdf', "I"); } }
<?php /** * Impression d'un fichier par une imprimante réseau * * @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 */ $printer_id = CValue::get("printer_id"); $file_id = CValue::get("file_id"); $file = new CFile(); $file->load($file_id); $printer = new CPrinter(); $printer->load($printer_id); $printer->loadRefSource()->sendDocument($file);
/** * Impression des factures * * @param bool $ts tiers soldant * * @return void */ function printBill($ts = false) { if (count($this->factures)) { $user = CMediusers::get(); $printer_bvr = new CPrinter(); $printer_bvr->function_id = $user->function_id; $printer_bvr->label = "bvr"; $printer_bvr->loadMatchingObject(); $printer_justif = new CPrinter(); $printer_justif->function_id = $user->function_id; $printer_justif->label = "justif"; $printer_justif->loadMatchingObject(); if (!$printer_bvr->_id || !$printer_justif->_id) { CAppUI::setMsg("Les imprimantes ne sont pas paramétrées", UI_MSG_ERROR); echo CAppUI::getMsg(); return false; } $file = new CFile(); foreach ($this->factures as $facture) { $facture_pdf = new CEditPdf(); $facture_pdf->factures = array($facture); $pdf = ""; $pdf = $facture_pdf->editFactureBVR($ts, "S"); $file_path = tempnam("tmp", "facture"); $file->_file_path = $file_path; file_put_contents($file_path, $pdf); $printer_bvr->loadRefSource()->sendDocument($file); unlink($file_path); $pdf = ""; $pdf = $facture_pdf->editJustificatif($ts, "S"); $file_path = tempnam("tmp", "facture"); $file->_file_path = $file_path; file_put_contents($file_path, $pdf); $printer_justif->loadRefSource()->sendDocument($file); unlink($file_path); } } }
<?php /** * $Id$ * * @package Mediboard * @subpackage Hospi * @author SARL OpenXtrem <*****@*****.**> * @license GNU General Public License, see http://www.gnu.org/licenses/gpl.html * @version $Revision$ */ CCanDo::checkRead(); $printer_id = CView::get("printer_id", "num default|0", true); CView::checkin(); $printer = new CPrinter(); $printer->load($printer_id); if ($printer->_id) { $printer->loadTargetObject(); } $source = new CSourceLPR(); $sources = $source->loadlist(); $source = new CSourceSMB(); $sources = array_merge($sources, $source->loadlist()); $function = new CFunctions(); $where = array("group_id" => "= '" . CGroups::loadCurrent()->_id . "'"); $functions = $function->loadListWithPerms(PERM_READ, $where, "text"); $smarty = new CSmartyDP(); $smarty->assign("printer", $printer); $smarty->assign("sources", $sources); $smarty->assign("functions", $functions); $smarty->display("inc_edit_printer.tpl");
function printEtiquettes($printer_id = null, $stream = 1) { // Affectation de la police par défault si aucune n'est choisie if ($this->font == "") { $this->font = "dejavusansmono"; } // Calcul des dimensions de l'étiquette $largeur_etiq = ($this->largeur_page - 2 * $this->marge_horiz) / $this->nb_colonnes; $hauteur_etiq = ($this->hauteur_page - 2 * $this->marge_vert) / $this->nb_lignes; // Création du PDF $pdf = new CMbPdf('P', 'cm', array($this->largeur_page, $this->hauteur_page)); $pdf->setFont($this->font, '', $this->hauteur_ligne); $pdf->setPrintHeader(false); $pdf->setPrintFooter(false); $pdf->SetMargins($this->marge_horiz, $this->marge_vert, $this->marge_horiz); $pdf->SetAutoPageBreak(0, $this->marge_vert); $pdf->AddPage(); $distinct_texts = 1; $textes = array(); $pays = CAppUI::conf("ref_pays"); // La fonction nl2br ne fait qu'ajouter la balise <br />, elle ne supprime pas le \n. // Il faut donc le faire manuellement. $textes[1] = preg_replace("/[\t\r\n\f]/", '', utf8_encode(nl2br($this->texte))); if ($this->texte_2) { $distinct_texts++; $textes[] = preg_replace("/[\t\r\n\f]/", '', utf8_encode(nl2br($this->texte_2))); } if ($this->texte_3) { $distinct_texts++; $textes[] = preg_replace("/[\t\r\n\f]/", '', utf8_encode(nl2br($this->texte_3))); } if ($this->texte_4) { $distinct_texts++; $textes[] = preg_replace("/[\t\r\n\f]/", '', utf8_encode(nl2br($this->texte_4))); } $nb_etiqs = $this->nb_lignes * $this->nb_colonnes; $increment = floor($nb_etiqs / $distinct_texts); $current_text = 1; // Création de la grille d'étiquettes et écriture du contenu. for ($i = 0; $i < $nb_etiqs; $i++) { if ($i != 0 && $i % $increment == 0 && isset($textes[$current_text + 1])) { $current_text++; } if (round($pdf->GetX()) >= round($this->largeur_page - 2 * $this->marge_horiz)) { $pdf->SetX(0); $pdf->SetLeftMargin($this->marge_horiz); $pdf->SetY($pdf->GetY() + $hauteur_etiq); } if ($this->show_border) { $pdf->Rect($pdf->GetX(), $pdf->GetY(), $largeur_etiq, $hauteur_etiq, 'D'); } $x = $pdf->GetX(); $y = $pdf->GetY(); $pdf->SetLeftMargin($x); // On affecte la marge droite de manière à ce que la méthode Write fasse un retour chariot // lorsque le contenu écrit va dépasser la largeur de l'étiquette $pdf->SetRightMargin($this->largeur_page - $x - $largeur_etiq); $fragments = explode("@", $textes[$current_text]); $was_barcode = 0; CMbArray::removeValue("", $fragments); // Evaluation de la hauteur du contenu de la cellule // si un alignement spécifique est demandé. if ($this->text_align != "top") { $pdf_ex = new CMbPdf('p', 'cm', array($largeur_etiq, $hauteur_etiq)); $pdf_ex->setFont($this->font, '', $this->hauteur_ligne); $pdf_ex->SetMargins(0, 0, 0); $pdf_ex->setPrintHeader(false); $pdf_ex->setPrintFooter(false); $pdf_ex->SetAutoPageBreak(false); $pdf_ex->AddPage(); foreach ($fragments as $fragment) { if (preg_match("/BARCODE_(.*)/", $fragment, $matches) == 1) { switch ($pays) { case "2": $save_x = $pdf_ex->getX(); $pdf_ex->setY($pdf_ex->getY() + 0.4); $pdf_ex->setX($save_x); $barcode = $matches[1]; $pdf_ex->setFont("C39HrP24DhTt", '', 30); $pdf_ex->WriteHTML($barcode, false); $pdf_ex->setFont($this->font, '', $this->hauteur_ligne); break; default: $barcode_x = $pdf_ex->getX() + 0.15; $barcode_y = $pdf_ex->getY(); $barcode = $matches[1]; $barcode_width = strlen($barcode) * 0.4 + 0.4; $pdf_ex->writeBarcode($barcode_x, $barcode_y, $barcode_width, 0.8, "C128B", 1, null, null, $barcode, 25); $pdf_ex->setX($barcode_x + $barcode_width); } $was_barcode = 1; } else { if ($was_barcode) { $sub_fragments = explode("<br />", $fragment, 2); $pdf_ex->WriteHTML($sub_fragments[0], false); if (isset($sub_fragments[1])) { $actual_y = $pdf_ex->getY(); $pdf_ex->setY($actual_y + 0.8); $pdf_ex->WriteHTML($sub_fragments[1], false); } } else { $pdf_ex->WriteHTML($fragment, false); } $was_barcode = 0; } } $pdf_y = $pdf->getY(); $pdf_ex_y = $pdf_ex->getY(); switch ($this->text_align) { case "middle": $pdf->setY($pdf_y - 0.2 + ($hauteur_etiq - $pdf_ex_y) / 2); break; case "bottom": $pdf->setY($pdf_y - 0.4 + $hauteur_etiq - $pdf_ex_y); } } foreach ($fragments as $fragment) { if (preg_match("/BARCODE_(.*)/", $fragment, $matches) == 1) { switch ($pays) { case "2": // La position x est à remettre car perdue lors de la méthode setY $save_x = $pdf->getX(); $pdf->setY($pdf->getY() + 0.4); $pdf->setX($save_x); $barcode = $matches[1]; $pdf->setFont("C39HrP24DhTt", '', 30); $pdf->WriteHTML("*{$barcode}*", false); $pdf->setFont($this->font, '', $this->hauteur_ligne); break; default: $barcode_x = $pdf->getX() + 0.15; $barcode_y = $pdf->getY(); $barcode = $matches[1]; $barcode_width = strlen($barcode) * 0.4 + 0.4; $pdf->writeBarcode($barcode_x, $barcode_y, $barcode_width, 0.8, "C128B", 1, null, null, $barcode); $pdf->setX($barcode_x + $barcode_width); } $was_barcode = 1; } else { if ($was_barcode) { $sub_fragments = explode("<br />", $fragment, 2); $pdf->WriteHTML($sub_fragments[0], false); if (isset($sub_fragments[1])) { $actual_y = $pdf->getY(); $pdf->setY($actual_y + 0.8); $pdf->WriteHTML($sub_fragments[1], false); } } else { $pdf->WriteHTML($fragment, false); } $was_barcode = 0; } } $x = $x + $largeur_etiq; $pdf->SetY($y); $pdf->SetX($x); } if ($printer_id) { $file = new CFile(); $file->_file_path = tempnam("/tmp", "etiq"); file_put_contents($file->_file_path, $pdf->Output($this->nom . '.pdf', "S")); $printer = new CPrinter(); $printer->load($printer_id); $printer->loadRefSource()->sendDocument($file); unlink($file->_file_path); } else { if ($stream) { $pdf->Output($this->nom . '.pdf', "I"); } else { return $pdf->OutPut($this->nom . '.pdf', "S"); } } }
<?php /** * Liste des imprimantes en réseau * * @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 */ $mode_etiquette = CValue::get("mode_etiquette", 0); $object_class = CValue::get("object_class"); $object_id = CValue::get("object_id"); $modele_etiquette_id = CValue::get("modele_etiquette_id"); $printer = new CPrinter(); $printer->function_id = CMediusers::get()->function_id; $printers = $printer->loadMatchingList(); CMbObject::massLoadFwdRef($printers, "object_id"); /** @var $printers CPrinter[] */ foreach ($printers as $_printer) { $_printer->loadTargetObject(); } $smarty = new CSmartyDP(); $smarty->assign("mode_etiquette", $mode_etiquette); $smarty->assign("printers", $printers); $smarty->assign("object_class", $object_class); $smarty->assign("object_id", $object_id); $smarty->assign("modele_etiquette_id", $modele_etiquette_id); $smarty->display("inc_choose_printer.tpl");