--- /tmp/dsg/dolibarr/htdocs/core/modules/cheque/doc/github_19.0.3_pdf_blochet.class.php +++ /tmp/dsg/dolibarr/htdocs/core/modules/cheque/doc/client_pdf_blochet.class.php @@ -38,35 +38,4 @@ - * @var int tab_top - */ - public $tab_top; - - /** - * @var int tab_height - */ - public $tab_height; - - /** - * @var int line_height - */ - public $line_height; - - /** - * @var int line per page - */ - public $line_per_page; - - /** - * @var Account bank account - */ - public $account; - - public $amount; - public $date; - public $nbcheque; - public $ref; - public $ref_ext; - - - /** - * @var array lines - */ - public $lines; + * Issuer + * @var Societe + */ + public $emetteur; @@ -81 +50 @@ - global $langs, $mysoc; + global $conf, $langs, $mysoc; @@ -97,13 +66,11 @@ - $this->marge_gauche = getDolGlobalInt('MAIN_PDF_MARGIN_LEFT', 10); - $this->marge_droite = getDolGlobalInt('MAIN_PDF_MARGIN_RIGHT', 10); - $this->marge_haute = getDolGlobalInt('MAIN_PDF_MARGIN_TOP', 10); - $this->marge_basse = getDolGlobalInt('MAIN_PDF_MARGIN_BOTTOM', 10); - - // Retrieves transmitter - $this->emetteur = $mysoc; - if (!$this->emetteur->country_code) { - $this->emetteur->country_code = substr($langs->defaultlang, -2); // By default if not defined - } - - // Define column position - $this->line_height = 5; + $this->marge_gauche = isset($conf->global->MAIN_PDF_MARGIN_LEFT) ? $conf->global->MAIN_PDF_MARGIN_LEFT : 10; + $this->marge_droite = isset($conf->global->MAIN_PDF_MARGIN_RIGHT) ? $conf->global->MAIN_PDF_MARGIN_RIGHT : 10; + $this->marge_haute = isset($conf->global->MAIN_PDF_MARGIN_TOP) ? $conf->global->MAIN_PDF_MARGIN_TOP : 10; + $this->marge_basse = isset($conf->global->MAIN_PDF_MARGIN_BOTTOM) ? $conf->global->MAIN_PDF_MARGIN_BOTTOM : 10; + + // Retrieves transmitter + $this->emetteur = $mysoc; + if (!$this->emetteur->country_code) $this->emetteur->country_code = substr($langs->defaultlang, -2); // By default if not defined + + // Define column position + $this->line_height = 5; @@ -114 +81 @@ - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps @@ -122 +89 @@ - * @return int 1=ok, 0=ko + * @return int 1=ok, 0=ko @@ -126 +93 @@ - // phpcs:enable + // phpcs:enable @@ -129,10 +96,6 @@ - if (!is_object($outputlangs)) { - $outputlangs = $langs; - } - // For backward compatibility with FPDF, force output charset to ISO, because FPDF expect text to be encoded in ISO - $sav_charset_output = $outputlangs->charset_output; - if (getDolGlobalString('MAIN_USE_FPDF')) { - $outputlangs->charset_output = 'ISO-8859-1'; - } - - // Load traductions files required by page + if (!is_object($outputlangs)) $outputlangs = $langs; + // For backward compatibility with FPDF, force output charset to ISO, because FPDF expect text to be encoded in ISO + $sav_charset_output = $outputlangs->charset_output; + if (!empty($conf->global->MAIN_USE_FPDF)) $outputlangs->charset_output = 'ISO-8859-1'; + + // Load traductions files required by page @@ -141,3 +104,4 @@ - $dir = $_dir."/".get_exdir($number, 0, 1, 0, $object, 'checkdeposits'); - - if (!is_dir($dir)) { + $dir = $_dir."/".get_exdir($number, 0, 1, 0, $object, 'cheque').$number; + + if (!is_dir($dir)) + { @@ -146 +110,2 @@ - if ($result < 0) { + if ($result < 0) + { @@ -155 +120,2 @@ - if (!is_object($hookmanager)) { + if (!is_object($hookmanager)) + { @@ -165,14 +131,13 @@ - $pdf = pdf_getInstance($this->format); - $heightforinfotot = 50; // Height reserved to output the info and total part - $heightforfreetext = (isset($conf->global->MAIN_PDF_FREETEXT_HEIGHT) ? $conf->global->MAIN_PDF_FREETEXT_HEIGHT : 5); // Height reserved to output the free text on last page - $heightforfooter = $this->marge_basse + 8; // Height reserved to output the footer (value include bottom margin) - if (getDolGlobalString('MAIN_GENERATE_DOCUMENTS_SHOW_FOOT_DETAILS')) { - $heightforfooter += 6; - } - $pdf->SetAutoPageBreak(1, 0); - - if (class_exists('TCPDF')) { - $pdf->setPrintHeader(false); - $pdf->setPrintFooter(false); - } - $pdf->SetFont(pdf_getPDFFont($outputlangs)); + $pdf = pdf_getInstance($this->format); + $heightforinfotot = 50; // Height reserved to output the info and total part + $heightforfreetext = (isset($conf->global->MAIN_PDF_FREETEXT_HEIGHT) ? $conf->global->MAIN_PDF_FREETEXT_HEIGHT : 5); // Height reserved to output the free text on last page + $heightforfooter = $this->marge_basse + 8; // Height reserved to output the footer (value include bottom margin) + if ($conf->global->MAIN_GENERATE_DOCUMENTS_SHOW_FOOT_DETAILS > 0) $heightforfooter += 6; + $pdf->SetAutoPageBreak(1, 0); + + if (class_exists('TCPDF')) + { + $pdf->setPrintHeader(false); + $pdf->setPrintFooter(false); + } + $pdf->SetFont(pdf_getPDFFont($outputlangs)); @@ -189,3 +154 @@ - if (getDolGlobalString('MAIN_DISABLE_PDF_COMPRESSION')) { - $pdf->SetCompression(false); - } + if (!empty($conf->global->MAIN_DISABLE_PDF_COMPRESSION)) $pdf->SetCompression(false); @@ -199 +162,2 @@ - if (($nboflines % $this->line_per_page) > 0) { + if (($nboflines % $this->line_per_page) > 0) + { @@ -202 +166,2 @@ - if ($pages == 0) { + if ($pages == 0) + { @@ -208 +173 @@ - $pagenb++; + $pagenb++; @@ -215,3 +180 @@ - if (method_exists($pdf, 'AliasNbPages')) { - $pdf->AliasNbPages(); - } + if (method_exists($pdf, 'AliasNbPages')) $pdf->AliasNbPages(); @@ -224 +187,2 @@ - if (!is_object($hookmanager)) { + if (!is_object($hookmanager)) + { @@ -232,6 +196,8 @@ - if ($reshook < 0) { - $this->error = $hookmanager->error; - $this->errors = $hookmanager->errors; - } - - dolChmod($file); + if ($reshook < 0) + { + $this->error = $hookmanager->error; + $this->errors = $hookmanager->errors; + } + + if (!empty($conf->global->MAIN_UMASK)) + @chmod($file, octdec($conf->global->MAIN_UMASK)); @@ -241,2 +207,2 @@ - $outputlangs->charset_output = $sav_charset_output; - return 1; // No error + $outputlangs->charset_output = $sav_charset_output; + return 1; // No error @@ -246 +212 @@ - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps @@ -250 +216 @@ - * @param TCPDF $pdf Pdf object + * @param PDF $pdf Pdf object @@ -258 +224 @@ - // phpcs:enable + // phpcs:enable @@ -267,5 +233,5 @@ - $pdf->SetXY(10, 8); - $pdf->MultiCell(0, 2, $title, 0, 'L'); - - $pdf->SetFont('', '', $default_font_size); - $pdf->SetXY(10, 15); + $pdf->SetXY(10, 8); + $pdf->MultiCell(0, 2, $title, 0, 'L'); + + $pdf->SetFont('', '', $default_font_size); + $pdf->SetXY(10, 15); @@ -273,25 +239,25 @@ - $pdf->SetXY(32, 15); - $pdf->SetFont('', '', $default_font_size); - $pdf->MultiCell(60, 2, $outputlangs->convToOutputCharset($this->ref.($this->ref_ext ? " - ".$this->ref_ext : '')), 0, 'L'); - - $pdf->SetFont('', '', $default_font_size); - $pdf->SetXY(10, 20); - $pdf->MultiCell(22, 2, $outputlangs->transnoentities("Date"), 0, 'L'); - $pdf->SetXY(32, 20); - $pdf->SetFont('', '', $default_font_size); - $pdf->MultiCell(60, 2, dol_print_date($this->date, "day", false, $outputlangs)); - - $pdf->SetFont('', '', $default_font_size); - $pdf->SetXY(10, 26); - $pdf->MultiCell(22, 2, $outputlangs->transnoentities("Owner"), 0, 'L'); - $pdf->SetFont('', '', $default_font_size); - $pdf->SetXY(32, 26); - $pdf->MultiCell(80, 2, $outputlangs->convToOutputCharset($this->account->proprio), 0, 'L'); - - $pdf->SetFont('', '', $default_font_size); - $pdf->SetXY(10, 32); - $pdf->MultiCell(0, 2, $outputlangs->transnoentities("Account"), 0, 'L'); - pdf_bank($pdf, $outputlangs, 32, 32, $this->account, 1); - - $pdf->SetFont('', '', $default_font_size); - $pdf->SetXY(114, 15); + $pdf->SetXY(32, 15); + $pdf->SetFont('', '', $default_font_size); + $pdf->MultiCell(60, 2, $outputlangs->convToOutputCharset($this->ref.($this->ref_ext ? " - ".$this->ref_ext : '')), 0, 'L'); + + $pdf->SetFont('', '', $default_font_size); + $pdf->SetXY(10, 20); + $pdf->MultiCell(22, 2, $outputlangs->transnoentities("Date"), 0, 'L'); + $pdf->SetXY(32, 20); + $pdf->SetFont('', '', $default_font_size); + $pdf->MultiCell(60, 2, dol_print_date($this->date, "day", false, $outputlangs)); + + $pdf->SetFont('', '', $default_font_size); + $pdf->SetXY(10, 26); + $pdf->MultiCell(22, 2, $outputlangs->transnoentities("Owner"), 0, 'L'); + $pdf->SetFont('', '', $default_font_size); + $pdf->SetXY(32, 26); + $pdf->MultiCell(80, 2, $outputlangs->convToOutputCharset($this->account->proprio), 0, 'L'); + + $pdf->SetFont('', '', $default_font_size); + $pdf->SetXY(10, 32); + $pdf->MultiCell(0, 2, $outputlangs->transnoentities("Account"), 0, 'L'); + pdf_bank($pdf, $outputlangs, 32, 32, $this->account, 1); + + $pdf->SetFont('', '', $default_font_size); + $pdf->SetXY(114, 15); @@ -300,8 +266,8 @@ - $pdf->Rect(9, 14, 192, 35); - $pdf->line(9, 19, 112, 19); - $pdf->line(9, 25, 112, 25); - //$pdf->line(9, 31, 201, 31); - $pdf->line(9, 31, 112, 31); - - $pdf->line(30, 14, 30, 49); - $pdf->line(112, 14, 112, 49); + $pdf->Rect(9, 14, 192, 35); + $pdf->line(9, 19, 112, 19); + $pdf->line(9, 25, 112, 25); + //$pdf->line(9, 31, 201, 31); + $pdf->line(9, 31, 112, 31); + + $pdf->line(30, 14, 30, 49); + $pdf->line(112, 14, 112, 49); @@ -321,5 +287,5 @@ - $pdf->SetXY(57, $posy + 1); - $pdf->MultiCell(40, 2, $this->nbcheque, 0, 'L'); - - $pdf->SetFont('', '', $default_font_size); - $pdf->SetXY(148, $posy + 1); + $pdf->SetXY(57, $posy + 1); + $pdf->MultiCell(40, 2, $this->nbcheque, 0, 'L'); + + $pdf->SetFont('', '', $default_font_size); + $pdf->SetXY(148, $posy + 1); @@ -339 +305 @@ - $pdf->MultiCell(40, 2, $outputlangs->transnoentities("Bank"), 0, 'L'); + $pdf->MultiCell(40, 2, $outputlangs->transnoentities("Bank"), 0, 'L'); @@ -342,2 +308,2 @@ - $pdf->SetXY(101, $this->tab_top + 2); - $pdf->MultiCell(40, 2, $outputlangs->transnoentities("CheckTransmitter"), 0, 'L'); + $pdf->SetXY(101, $this->tab_top + 2); + $pdf->MultiCell(40, 2, $outputlangs->transnoentities("CheckTransmitter"), 0, 'L'); @@ -354 +320 @@ - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps @@ -358 +324 @@ - * @param TCPDF $pdf PDF object + * @param PDF $pdf PDF object @@ -366 +332 @@ - // phpcs:enable + // phpcs:enable @@ -377,11 +343,23 @@ - for ($j = 0; $j < $num; $j++) { - // Dynamic max line heigh calculation - $dynamic_line_height = array(); - $dynamic_line_height[] = $pdf->getStringHeight(60, $outputlangs->convToOutputCharset($this->lines[$j]->bank_chq)); - $dynamic_line_height[] = $pdf->getStringHeight(80, $outputlangs->convToOutputCharset($this->lines[$j]->emetteur_chq)); - $max_line_height = max($dynamic_line_height); - // Calculate number of line used function of estimated line size - if ($max_line_height > $this->line_height) { - $nb_lines = floor($max_line_height / $this->line_height) + 1; - } else { - $nb_lines = 1; + for ($j = 0; $j < $num; $j++) + { + // Dynamic max line heigh calculation + $dynamic_line_height = array(); + $dynamic_line_height[] = $pdf->getStringHeight(60, $outputlangs->convToOutputCharset($this->lines[$j]->bank_chq)); + $dynamic_line_height[] = $pdf->getStringHeight(80, $outputlangs->convToOutputCharset($this->lines[$j]->emetteur_chq)); + $max_line_height = max($dynamic_line_height); + // Calculate number of line used function of estimated line size + if ($max_line_height > $this->line_height) $nb_lines = floor($max_line_height / $this->line_height) + 1; + else $nb_lines = 1; + + // Add page break if we do not have space to add current line + if ($lineinpage >= ($this->line_per_page - 1)) + { + $lineinpage = 0; $yp = 0; + + // New page + $pdf->AddPage(); + $pagenb++; + $this->Header($pdf, $pagenb, $pages, $outputlangs); + $pdf->SetFont('', '', $default_font_size - 1); + $pdf->MultiCell(0, 3, ''); // Set interline to 3 + $pdf->SetTextColor(0, 0, 0); @@ -390,15 +368 @@ - // Add page break if we do not have space to add current line - if ($lineinpage >= ($this->line_per_page - 1)) { - $lineinpage = 0; - $yp = 0; - - // New page - $pdf->AddPage(); - $pagenb++; - $this->Header($pdf, $pagenb, $pages, $outputlangs); - $pdf->SetFont('', '', $default_font_size - 1); - $pdf->MultiCell(0, 3, ''); // Set interline to 3 - $pdf->SetTextColor(0, 0, 0); - } - - $lineinpage += $nb_lines; + $lineinpage += $nb_lines; @@ -421 +385 @@ - $yp = $yp + ($this->line_height * $nb_lines); + $yp = $yp + ($this->line_height * $nb_lines); @@ -428,2 +392,2 @@ - * - * @param TCPDF $pdf PDF + * + * @param PDF $pdf PDF @@ -433 +397 @@ - * @return mixed + * @return void @@ -438,2 +402,3 @@ - - $showdetails = getDolGlobalInt('MAIN_GENERATE_DOCUMENTS_SHOW_FOOT_DETAILS', 0); + $default_font_size = pdf_getPDFFontSize($outputlangs); + + $showdetails = $conf->global->MAIN_GENERATE_DOCUMENTS_SHOW_FOOT_DETAILS; @@ -442,2 +406,0 @@ - $substitutionarray = pdf_getSubstitutionArray($outputlangs, null, $object); - complete_substitutions_array($substitutionarray, $outputlangs, $object); @@ -446,2 +409,3 @@ - if (!empty($conf->global->$paramfreetext)) { - $newfreetext = make_substitutions(getDolGlobalString($paramfreetext), $substitutionarray); + if (!empty($conf->global->$paramfreetext)) + { + $newfreetext = make_substitutions($conf->global->$paramfreetext, $substitutionarray);