diff --git a/htdocs/commande/class/commande.class.php b/htdocs/commande/class/commande.class.php index 68f500a6d44..9435db2389e 100644 --- a/htdocs/commande/class/commande.class.php +++ b/htdocs/commande/class/commande.class.php @@ -4021,6 +4021,8 @@ class Commande extends CommonOrder $this->multicurrency_tx = 1; $this->multicurrency_code = $conf->currency; + $this->status = $this::STATUS_DRAFT; + // Lines $nbp = 5; $xnbp = 0; diff --git a/htdocs/core/lib/pdf.lib.php b/htdocs/core/lib/pdf.lib.php index 20cd8d62ac9..eb1e08ea01a 100644 --- a/htdocs/core/lib/pdf.lib.php +++ b/htdocs/core/lib/pdf.lib.php @@ -184,7 +184,7 @@ function pdf_getInstance($format = '', $metric = 'mm', $pagetype = 'P') $pdfa = getDolGlobalString('PDF_USE_A'); // PDF/A-1 ou PDF/A-3 } - if (class_exists('TCPDI')) { + if (!getDolGlobalString('MAIN_DISABLE_TCPDI') && class_exists('TCPDI')) { $pdf = new TCPDI($pagetype, $metric, $format, true, 'UTF-8', false, $pdfa); } else { $pdf = new TCPDF($pagetype, $metric, $format, true, 'UTF-8', false, $pdfa); @@ -781,8 +781,6 @@ function pdf_getSubstitutionArray($outputlangs, $exclude = null, $object = null, */ function pdf_watermark(&$pdf, $outputlangs, $h, $w, $unit, $text) { - global $langs, $mysoc, $user; - // Print Draft Watermark if ($unit == 'pt') { $k = 1; @@ -810,6 +808,7 @@ function pdf_watermark(&$pdf, $outputlangs, $h, $w, $unit, $text) $watermark_y = $h / 3; $pdf->SetFont('', 'B', 40); $pdf->SetTextColor(255, 192, 203); + //rotate $pdf->_out(sprintf('q %.5F %.5F %.5F %.5F %.2F %.2F cm 1 0 0 1 %.2F %.2F cm', cos($watermark_angle), sin($watermark_angle), -sin($watermark_angle), cos($watermark_angle), $watermark_x * $k, ($h - $watermark_y) * $k, -$watermark_x * $k, -($h - $watermark_y) * $k)); //print watermark @@ -1013,7 +1012,7 @@ function pdf_bank(&$pdf, $outputlangs, $curx, $cury, $account, $onlynumber = 0, */ function pdf_pagefoot(&$pdf, $outputlangs, $paramfreetext, $fromcompany, $marge_basse, $marge_gauche, $page_hauteur, $object, $showdetails = 0, $hidefreetext = 0, $page_largeur = 0, $watermark = '') { - global $conf, $user, $mysoc, $hookmanager; + global $conf, $hookmanager; $outputlangs->load("dict"); $line = ''; diff --git a/htdocs/core/modules/facture/doc/pdf_crabe.modules.php b/htdocs/core/modules/facture/doc/pdf_crabe.modules.php index a054e8fab87..818d157964b 100644 --- a/htdocs/core/modules/facture/doc/pdf_crabe.modules.php +++ b/htdocs/core/modules/facture/doc/pdf_crabe.modules.php @@ -2180,6 +2180,7 @@ class pdf_crabe extends ModelePDFFactures protected function _pagefoot(&$pdf, $object, $outputlangs, $hidefreetext = 0, $heightforqrinvoice = 0) { $showdetails = getDolGlobalInt('MAIN_GENERATE_DOCUMENTS_SHOW_FOOT_DETAILS', 0); + return pdf_pagefoot($pdf, $outputlangs, 'INVOICE_FREE_TEXT', $this->emetteur, $heightforqrinvoice + $this->marge_basse, $this->marge_gauche, $this->page_hauteur, $object, $showdetails, $hidefreetext, $this->page_largeur, $this->watermark); } } diff --git a/test/phpunit/BuildDocTest.php b/test/phpunit/BuildDocTest.php index fd2459de0b3..ca3ececfdd1 100644 --- a/test/phpunit/BuildDocTest.php +++ b/test/phpunit/BuildDocTest.php @@ -23,6 +23,7 @@ * \ingroup test * \brief PHPUnit test * \remarks To run this script as CLI: phpunit filename.php + * See also PdfDocTest to test methods */ global $conf,$user,$langs,$db; @@ -143,6 +144,8 @@ class BuildDocTest extends PHPUnit\Framework\TestCase die(1); } + print "PHP Version: ".phpversion()."\n"; + $db->begin(); // This is to have all actions inside a transaction even if test launched without suite. print __METHOD__."\n"; @@ -207,12 +210,29 @@ class BuildDocTest extends PHPUnit\Framework\TestCase $localobject=new Facture($db); $localobject->createFromOrder($localobjectcom, $user); $localobject->date_lim_reglement = dol_now() + 3600 * 24 *30; + $localobject->status = Facture::STATUS_DRAFT; + + // To be sure we are not using the Swiss QR Code addition + $conf->global->INVOICE_ADD_SWISS_QR_CODE = 0; + // Force config to use a watermark and without TCPDI + $conf->global->FACTURE_DRAFT_WATERMARK = 'A watermark'; + // Force without TCPDI + $conf->global->MAIN_DISABLE_TCPDI = 1; // Crabe (english) $localobject->model_pdf='crabe'; $result = $localobject->generateDocument($localobject->model_pdf, $langs); $this->assertLessThan($result, 0); - print __METHOD__." result=".$result."\n"; + print __METHOD__." result=".$result." for generation from crabe\n"; + + // Restore default usage with TCPDI + $conf->global->MAIN_DISABLE_TCPDI = 0; + + // Crabe (english) + $localobject->model_pdf='crabe'; + $result = $localobject->generateDocument($localobject->model_pdf, $langs); + $this->assertLessThan($result, 0); + print __METHOD__." result=".$result." for generation from crabe with MAIN_DISABLE_TCPDI and a watermark\n"; // Crabe (japanese) $newlangs1=new Translate("", $conf); diff --git a/test/phpunit/PdfDocTest.php b/test/phpunit/PdfDocTest.php index d58f1db8985..299372d667c 100644 --- a/test/phpunit/PdfDocTest.php +++ b/test/phpunit/PdfDocTest.php @@ -22,6 +22,7 @@ * \ingroup test * \brief PHPUnit test * \remarks To run this script as CLI: phpunit filename.php + * See also BuildDocTest to PDF generation */ global $conf,$user,$langs,$db;