/**
  * 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");
     }
 }
Пример #2
0
    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");
            $file->_file_path = $file_path;
            file_put_contents($file_path, $pdf);
            $printer_bvr->loadRefSource()->sendDocument($file);
Пример #3
0
 /**
  * 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);
         }
     }
 }