--- /tmp/dsg/dolibarr/htdocs/core/modules/printsheet/doc/github_19.0.3_pdf_standardlabel.class.php +++ /tmp/dsg/dolibarr/htdocs/core/modules/printsheet/doc/client_pdf_standardlabel.class.php @@ -39 +39 @@ - * @param TCPDF $pdf PDF reference + * @param PDF $pdf PDF reference @@ -44,2 +44,2 @@ - public function addSticker(&$pdf, $outputlangs, $param) - { + public function addSticker(&$pdf, $outputlangs, $param) + { @@ -49 +49 @@ - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps @@ -55 +55 @@ - * @param TCPDF $pdf PDF reference + * @param PDF $pdf PDF reference @@ -66 +66 @@ - // phpcs:enable + // phpcs:enable @@ -83 +83,2 @@ - if (!is_readable($logo)) { + if (!is_readable($logo)) + { @@ -85 +86,2 @@ - if (!empty($mysoc->logo_small) && is_readable($conf->mycompany->dir_output.'/logos/thumbs/'.$mysoc->logo_small)) { + if (!empty($mysoc->logo_small) && is_readable($conf->mycompany->dir_output.'/logos/thumbs/'.$mysoc->logo_small)) + { @@ -87 +89,3 @@ - } elseif (!empty($mysoc->logo) && is_readable($conf->mycompany->dir_output.'/logos/'.$mysoc->logo)) { + } + elseif (!empty($mysoc->logo) && is_readable($conf->mycompany->dir_output.'/logos/'.$mysoc->logo)) + { @@ -93,4 +97,3 @@ - if (!empty($photo)) { - if (!is_readable($photo)) { - $photo = ''; - } + if (!empty($photo)) + { + if (!is_readable($photo)) $photo = ''; @@ -103 +106,2 @@ - if ($this->code == "CARD") { + if ($this->code == "CARD") + { @@ -110 +114,2 @@ - if ($backgroundimage) { + if ($backgroundimage) + { @@ -114,2 +119 @@ - $xleft = 2; - $ytop = 2; + $xleft = 2; $ytop = 2; @@ -118,2 +122,4 @@ - if ($header != '') { - if ($this->code == "CARD") { + if ($header != '') + { + if ($this->code == "CARD") + { @@ -132,2 +138 @@ - $maxwidthtouse = round(($this->_Width - 2 * $xleft) * $imgscalewidth); - $maxheighttouse = round(($this->_Height - 2 * $ytop) * $imgscaleheight); + $maxwidthtouse = round(($this->_Width - 2 * $xleft) * $imgscalewidth); $maxheighttouse = round(($this->_Height - 2 * $ytop) * $imgscaleheight); @@ -135,2 +140 @@ - $widthtouse = $maxwidthtouse; - $heighttouse = 0; // old value for image + $widthtouse = $maxwidthtouse; $heighttouse = 0; // old value for image @@ -138 +142,2 @@ - if (!empty($tmp['height'])) { + if ($tmp['height']) + { @@ -140,7 +145,2 @@ - if ($imgratio >= $defaultratio) { - $widthtouse = $maxwidthtouse; - $heighttouse = round($widthtouse / $imgratio); - } else { - $heighttouse = $maxheighttouse; - $widthtouse = round($heighttouse * $imgratio); - } + if ($imgratio >= $defaultratio) { $widthtouse = $maxwidthtouse; $heighttouse = round($widthtouse / $imgratio); } + else { $heightouse = $maxheighttouse; $widthtouse = round($heightouse * $imgratio); } @@ -151 +151,2 @@ - if ($textright == '') { // Only a left part + if ($textright == '') // Only a left part + { @@ -153,5 +154,4 @@ - if ($textleft == '%LOGO%' && $logo) { - $pdf->Image($logo, $_PosX + $xleft, $_PosY + $ytop, $widthtouse, $heighttouse); - } elseif ($textleft == '%PHOTO%' && $photo) { - $pdf->Image($photo, $_PosX + $xleft, $_PosY + $ytop, $widthtouse, $heighttouse); - } else { + if ($textleft == '%LOGO%' && $logo) $pdf->Image($logo, $_PosX + $xleft, $_PosY + $ytop, $widthtouse, $heighttouse); + elseif ($textleft == '%PHOTO%' && $photo) $pdf->Image($photo, $_PosX + $xleft, $_PosY + $ytop, $widthtouse, $heighttouse); + else + { @@ -161,7 +161,7 @@ - } elseif ($textleft != '' && $textright != '') { // - if ($textleft == '%LOGO%' || $textleft == '%PHOTO%') { - if ($textleft == '%LOGO%' && $logo) { - $pdf->Image($logo, $_PosX + $xleft, $_PosY + $ytop, $widthtouse, $heighttouse); - } elseif ($textleft == '%PHOTO%' && $photo) { - $pdf->Image($photo, $_PosX + $xleft, $_PosY + $ytop, $widthtouse, $heighttouse); - } + } + elseif ($textleft != '' && $textright != '') // + { + if ($textleft == '%LOGO%' || $textleft == '%PHOTO%') + { + if ($textleft == '%LOGO%' && $logo) $pdf->Image($logo, $_PosX + $xleft, $_PosY + $ytop, $widthtouse, $heighttouse); + elseif ($textleft == '%PHOTO%' && $photo) $pdf->Image($photo, $_PosX + $xleft, $_PosY + $ytop, $widthtouse, $heighttouse); @@ -170,6 +170,5 @@ - } elseif ($textright == '%LOGO%' || $textright == '%PHOTO%') { - if ($textright == '%LOGO%' && $logo) { - $pdf->Image($logo, $_PosX + $this->_Width - $widthtouse - $xleft, $_PosY + $ytop, $widthtouse, $heighttouse); - } elseif ($textright == '%PHOTO%' && $photo) { - $pdf->Image($photo, $_PosX + $this->_Width - $widthtouse - $xleft, $_PosY + $ytop, $widthtouse, $heighttouse); - } + } + elseif ($textright == '%LOGO%' || $textright == '%PHOTO%') + { + if ($textright == '%LOGO%' && $logo) $pdf->Image($logo, $_PosX + $this->_Width - $widthtouse - $xleft, $_PosY + $ytop, $widthtouse, $heighttouse); + elseif ($textright == '%PHOTO%' && $photo) $pdf->Image($photo, $_PosX + $this->_Width - $widthtouse - $xleft, $_PosY + $ytop, $widthtouse, $heighttouse); @@ -178 +177,3 @@ - } else { // text on halft left and text on half right + } + else // text on halft left and text on half right + { @@ -184 +185,3 @@ - } else { // Only a right part + } + else // Only a right part + { @@ -186,5 +189,4 @@ - if ($textright == '%LOGO%' && $logo) { - $pdf->Image($logo, $_PosX + $this->_Width - $widthtouse - $xleft, $_PosY + $ytop, $widthtouse, $heighttouse); - } elseif ($textright == '%PHOTO%' && $photo) { - $pdf->Image($photo, $_PosX + $this->_Width - $widthtouse - $xleft, $_PosY + $ytop, $widthtouse, $heighttouse); - } else { + if ($textright == '%LOGO%' && $logo) $pdf->Image($logo, $_PosX + $this->_Width - $widthtouse - $xleft, $_PosY + $ytop, $widthtouse, $heighttouse); + elseif ($textright == '%PHOTO%' && $photo) $pdf->Image($photo, $_PosX + $this->_Width - $widthtouse - $xleft, $_PosY + $ytop, $widthtouse, $heighttouse); + else + { @@ -197,2 +199,4 @@ - if ($footer != '') { - if ($this->code == "CARD") { + if ($footer != '') + { + if ($this->code == "CARD") + { @@ -226 +230 @@ - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps @@ -239 +243 @@ - // phpcs:enable + // phpcs:enable @@ -244,4 +248 @@ - if (empty($this->Tformat)) { - dol_print_error('', 'ErrorBadTypeForCard'.$this->code); - exit; - } + if (empty($this->Tformat)) { dol_print_error('', 'ErrorBadTypeForCard'.$this->code); exit; } @@ -249,12 +250,10 @@ - // standard format or custom - if ($this->Tformat['paper-size'] != 'custom') { - $this->format = $this->Tformat['paper-size']; - } else { - //custom - $resolution = array($this->Tformat['custom_x'], $this->Tformat['custom_y']); - $this->format = $resolution; - } - - if (!is_object($outputlangs)) { - $outputlangs = $langs; - } + // standard format or custom + if ($this->Tformat['paper-size'] != 'custom') { + $this->format = $this->Tformat['paper-size']; + } else { + //custom + $resolution = array($this->Tformat['custom_x'], $this->Tformat['custom_y']); + $this->format = $resolution; + } + + if (!is_object($outputlangs)) $outputlangs = $langs; @@ -262,3 +261 @@ - if (getDolGlobalString('MAIN_USE_FPDF')) { - $outputlangs->charset_output = 'ISO-8859-1'; - } + if (!empty($conf->global->MAIN_USE_FPDF)) $outputlangs->charset_output = 'ISO-8859-1'; @@ -275,2 +272,4 @@ - if (!file_exists($dir)) { - if (dol_mkdir($dir) < 0) { + if (!file_exists($dir)) + { + if (dol_mkdir($dir) < 0) + { @@ -284 +283,2 @@ - if (class_exists('TCPDF')) { + if (class_exists('TCPDF')) + { @@ -295,3 +295 @@ - if (getDolGlobalString('MAIN_DISABLE_PDF_COMPRESSION')) { - $pdf->SetCompression(false); - } + if (!empty($conf->global->MAIN_DISABLE_PDF_COMPRESSION)) $pdf->SetCompression(false); @@ -306,10 +304,2 @@ - if ($posX > 0) { - $posX--; - } else { - $posX = 0; - } - if ($posY > 0) { - $posY--; - } else { - $posY = 0; - } + if ($posX > 0) $posX--; else $posX = 0; + if ($posY > 0) $posY--; else $posY = 0; @@ -326 +316,2 @@ - foreach ($arrayofrecords as $val) { + foreach ($arrayofrecords as $val) + { @@ -338 +329,20 @@ - dolChmod($file); + if (!empty($conf->global->MAIN_UMASK)) + @chmod($file, octdec($conf->global->MAIN_UMASK)); + + // Output to http stream + clearstatcache(); + + $attachment = true; + if (!empty($conf->global->MAIN_DISABLE_FORCE_SAVEAS)) $attachment = false; + $type = dol_mimetype($filename); + + //if ($encoding) header('Content-Encoding: '.$encoding); + if ($type) header('Content-Type: '.$type); + if ($attachment) header('Content-Disposition: attachment; filename="'.$filename.'"'); + else header('Content-Disposition: inline; filename="'.$filename.'"'); + + // Ajout directives pour resoudre bug IE + header('Cache-Control: Public, must-revalidate'); + header('Pragma: public'); + + readfile($file); --- /tmp/dsg/dolibarr/htdocs/core/modules/printsheet/doc/github_19.0.3_pdf_tcpdflabel.class.php +++ /tmp/dsg/dolibarr/htdocs/core/modules/printsheet/doc/client_pdf_tcpdflabel.class.php @@ -72 +72 @@ - * @param TCPDF $pdf PDF reference + * @param PDF $pdf PDF reference @@ -94 +94 @@ - * @param TCPDF $pdf PDF reference + * @param PDF $pdf PDF reference @@ -123 +123,2 @@ - if (!is_readable($logo)) { + if (!is_readable($logo)) + { @@ -125 +126,2 @@ - if (!empty($mysoc->logo_small) && is_readable($conf->mycompany->dir_output.'/logos/thumbs/'.$mysoc->logo_small)) { + if (!empty($mysoc->logo_small) && is_readable($conf->mycompany->dir_output.'/logos/thumbs/'.$mysoc->logo_small)) + { @@ -127 +129,3 @@ - } elseif (!empty($mysoc->logo) && is_readable($conf->mycompany->dir_output.'/logos/'.$mysoc->logo)) { + } + elseif (!empty($mysoc->logo) && is_readable($conf->mycompany->dir_output.'/logos/'.$mysoc->logo)) + { @@ -136 +140,2 @@ - if ($header != '') { + if ($header != '') + { @@ -138 +143 @@ - $pdf->Cell(2 * strlen($header), $this->_Line_Height, $outputlangs->convToOutputCharset($header), 0, 1, 'C'); + $pdf->Cell($this->_Width - 2 * $xleft, $this->_Line_Height, $outputlangs->convToOutputCharset($header), 0, 1, 'C'); @@ -157 +162,2 @@ - if ($textright == '') { // Only a left part + if ($textright == '') // Only a left part + { @@ -159,3 +165,3 @@ - if ($textleft == '%LOGO%' && $logo) { - $pdf->Image($logo, $_PosX + $xleft, $_PosY + $ytop, 0, $logoHeight); - } elseif ($code && !empty($encoding)) { + if ($textleft == '%LOGO%' && $logo) $pdf->Image($logo, $_PosX + $xleft, $_PosY + $ytop, 0, $logoHeight); + elseif ($code && !empty($encoding)) + { @@ -163 +169,3 @@ - } else { + } + else + { @@ -167 +175,3 @@ - } elseif ($textleft != '' && $textright != '') { // left and right part + } + elseif ($textleft != '' && $textright != '') // left and right part + { @@ -170,4 +180,5 @@ - if (($textleft == '%LOGO%' || $textleft == '%PHOTO%' || $textleft == '%BARCODE%') && !strstr($textright, '%')) { // left part logo/barcode right part text - if ($textleft == '%LOGO%' && $logo) { - $pdf->Image($logo, $_PosX + $xleft, $_PosY + $ytop, $logoWidth, 0); - } elseif ($code && !empty($encoding)) { + if (($textleft == '%LOGO%' || $textleft == '%PHOTO%' || $textleft == '%BARCODE%') && !strstr($textright, '%')) // left part logo/barcode right part text + { + if ($textleft == '%LOGO%' && $logo) $pdf->Image($logo, $_PosX + $xleft, $_PosY + $ytop, $logoWidth, 0); + elseif ($code && !empty($encoding)) + { @@ -178,4 +189,6 @@ - } elseif (($textright == '%LOGO%' || $textright == '%PHOTO%' || $textright == '%BARCODE%') && !strstr($textleft, '%')) { // right part logo/barcode left part text - if ($textright == '%LOGO%' && $logo) { - $pdf->Image($logo, $_PosX + ($widthtouse / 2), $_PosY + $ytop, $logoWidth, 0); - } elseif ($code && !empty($encoding)) { + } + elseif (($textright == '%LOGO%' || $textright == '%PHOTO%' || $textright == '%BARCODE%') && !strstr($textleft, '%')) // right part logo/barcode left part text + { + if ($textright == '%LOGO%' && $logo) $pdf->Image($logo, $_PosX + ($widthtouse / 2), $_PosY + $ytop, $logoWidth, 0); + elseif ($code && !empty($encoding)) + { @@ -186,5 +199,6 @@ - } elseif ($textleft == '%LOGO%') { // left part logo right part text/barcode - if ($logo) { - $pdf->Image($logo, $_PosX + $xleft, $_PosY + $ytop, 0, $logoHeight); - } - if ($code && !empty($encoding)) { + } + elseif ($textleft == '%LOGO%') // left part logo right part text/barcode + { + if ($logo) $pdf->Image($logo, $_PosX + $xleft, $_PosY + $ytop, 0, $logoHeight); + if ($code && !empty($encoding)) + { @@ -196,5 +210,6 @@ - } elseif ($textright == '%LOGO%') { // right part logo left part text/barcode - if ($logo) { - $pdf->Image($logo, $_PosX + $xleft + $widthtouse - $logoWidth + 1, $_PosY + $ytop, 0, $logoHeight); - } - if ($code && !empty($encoding)) { + } + elseif ($textright == '%LOGO%') // right part logo left part text/barcode + { + if ($logo) $pdf->Image($logo, $_PosX + $xleft + $widthtouse - $logoWidth + 1, $_PosY + $ytop, 0, $logoHeight); + if ($code && !empty($encoding)) + { @@ -206 +221,3 @@ - } else { // text on halft left and text on half right + } + else // text on halft left and text on half right + { @@ -212 +229,3 @@ - } else { // Only a right part + } + else // Only a right part + { @@ -214,3 +233,3 @@ - if ($textright == '%LOGO%' && $logo) { - $pdf->Image($logo, $_PosX + $this->_Width - $widthtouse - $xleft, $_PosY + $ytop, 0, $logoHeight); - } elseif ($code && !empty($encoding)) { + if ($textright == '%LOGO%' && $logo) $pdf->Image($logo, $_PosX + $this->_Width - $widthtouse - $xleft, $_PosY + $ytop, 0, $logoHeight); + elseif ($code && !empty($encoding)) + { @@ -218 +237,3 @@ - } else { + } + else + { @@ -225 +246,2 @@ - if ($footer != '') { + if ($footer != '') + { @@ -249 +271 @@ - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps @@ -262 +284 @@ - // phpcs:enable + // phpcs:enable @@ -267,4 +289 @@ - if (empty($this->Tformat)) { - dol_print_error('', 'ErrorBadTypeForCard'.$this->code); - exit; - } + if (empty($this->Tformat)) { dol_print_error('', 'ErrorBadTypeForCard'.$this->code); exit; } @@ -272,12 +291,10 @@ - // standard format or custom - if ($this->Tformat['paper-size'] != 'custom') { - $this->format = $this->Tformat['paper-size']; - } else { - //custom - $resolution = array($this->Tformat['custom_x'], $this->Tformat['custom_y']); - $this->format = $resolution; - } - - if (!is_object($outputlangs)) { - $outputlangs = $langs; - } + // standard format or custom + if ($this->Tformat['paper-size'] != 'custom') { + $this->format = $this->Tformat['paper-size']; + } else { + //custom + $resolution = array($this->Tformat['custom_x'], $this->Tformat['custom_y']); + $this->format = $resolution; + } + + if (!is_object($outputlangs)) $outputlangs = $langs; @@ -285,3 +302 @@ - if (getDolGlobalString('MAIN_USE_FPDF')) { - $outputlangs->charset_output = 'ISO-8859-1'; - } + if (!empty($conf->global->MAIN_USE_FPDF)) $outputlangs->charset_output = 'ISO-8859-1'; @@ -298,2 +313,4 @@ - if (!file_exists($dir)) { - if (dol_mkdir($dir) < 0) { + if (!file_exists($dir)) + { + if (dol_mkdir($dir) < 0) + { @@ -307 +324,2 @@ - if (class_exists('TCPDF')) { + if (class_exists('TCPDF')) + { @@ -318,3 +336 @@ - if (getDolGlobalString('MAIN_DISABLE_PDF_COMPRESSION')) { - $pdf->SetCompression(false); - } + if (!empty($conf->global->MAIN_DISABLE_PDF_COMPRESSION)) $pdf->SetCompression(false); @@ -329,10 +345,2 @@ - if ($posX > 0) { - $posX--; - } else { - $posX = 0; - } - if ($posY > 0) { - $posY--; - } else { - $posY = 0; - } + if ($posX > 0) $posX--; else $posX = 0; + if ($posY > 0) $posY--; else $posY = 0; @@ -349 +357,2 @@ - foreach ($arrayofrecords as $val) { + foreach ($arrayofrecords as $val) + { @@ -361 +370,20 @@ - dolChmod($file); + if (!empty($conf->global->MAIN_UMASK)) + @chmod($file, octdec($conf->global->MAIN_UMASK)); + + // Output to http stream + clearstatcache(); + + $attachment = true; + if (!empty($conf->global->MAIN_DISABLE_FORCE_SAVEAS)) $attachment = false; + $type = dol_mimetype($filename); + + //if ($encoding) header('Content-Encoding: '.$encoding); + if ($type) header('Content-Type: '.$type); + if ($attachment) header('Content-Disposition: attachment; filename="'.$filename.'"'); + else header('Content-Disposition: inline; filename="'.$filename.'"'); + + // Ajout directives pour resoudre bug IE + header('Cache-Control: Public, must-revalidate'); + header('Pragma: public'); + + readfile($file);