Skip to content

Commit

Permalink
Merge branch 'develop' into patch-10
Browse files Browse the repository at this point in the history
  • Loading branch information
frederic34 authored Dec 10, 2024
2 parents 198860a + 860f89c commit 595a856
Show file tree
Hide file tree
Showing 3 changed files with 32 additions and 28 deletions.
22 changes: 12 additions & 10 deletions htdocs/core/modules/facture/doc/pdf_crabe.modules.php
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ class pdf_crabe extends ModelePDFFactures
*/
public function __construct($db)
{
global $conf, $langs, $mysoc;
global $langs, $mysoc;

// Translations
$langs->loadLangs(array("main", "bills"));
Expand Down Expand Up @@ -359,10 +359,10 @@ public function write_file($object, $outputlangs, $srctemplatepath = '', $hidede
$certprivate = empty($user->conf->CERTIFICATE_CRT_PRIVATE) ? '' : $user->conf->CERTIFICATE_CRT_PRIVATE;
// If user has no certificate, we try to take the company one
if (!$cert) {
$cert = !getDolGlobalString('CERTIFICATE_CRT') ? '' : $conf->global->CERTIFICATE_CRT;
$cert = getDolGlobalString('CERTIFICATE_CRT');
}
if (!$certprivate) {
$certprivate = !getDolGlobalString('CERTIFICATE_CRT_PRIVATE') ? '' : $conf->global->CERTIFICATE_CRT_PRIVATE;
$certprivate = getDolGlobalString('CERTIFICATE_CRT_PRIVATE');
}
// If a certificate is found
if ($cert) {
Expand Down Expand Up @@ -1162,14 +1162,17 @@ protected function _tableau_versements_header($pdf, $object, $outputlangs, $defa
protected function _tableau_info(&$pdf, $object, $posy, $outputlangs, $outputlangsbis)
{
// phpcs:enable
global $conf, $mysoc, $hookmanager;
global $mysoc, $hookmanager;

$default_font_size = pdf_getPDFFontSize($outputlangs);

$pdf->SetFont('', '', $default_font_size - 1);

krsort($this->tva_array);

// Clean data type
$object->total_tva = (float) $object->total_tva;

// Show VAT details
if ($object->total_tva != 0 && getDolGlobalInt('PDF_INVOICE_SHOW_VAT_ANALYSIS')) {
$pdf->SetFillColor(224, 224, 224);
Expand Down Expand Up @@ -1227,7 +1230,7 @@ protected function _tableau_info(&$pdf, $object, $posy, $outputlangs, $outputlan
}
}

// If France, show VAT mention if not applicable
// If France, show VAT mention if applicable
if ($this->emetteur->country_code == 'FR' && empty($object->total_tva) && (empty($mysoc->tva_assuj) || ($this->emetteur->isInEEC() && $object->thirdparty->isInEEC()))) {
$pdf->SetFont('', 'B', $default_font_size - 2);
$pdf->SetXY($this->marge_gauche, $posy);
Expand Down Expand Up @@ -1367,7 +1370,7 @@ protected function _tableau_info(&$pdf, $object, $posy, $outputlangs, $outputlan
if (empty($object->mode_reglement_code) || $object->mode_reglement_code == 'CHQ') {
// If payment mode unregulated or payment mode forced to CHQ
if (getDolGlobalInt('FACTURE_CHQ_NUMBER')) {
$diffsizetitle = (!getDolGlobalString('PDF_DIFFSIZE_TITLE') ? 3 : $conf->global->PDF_DIFFSIZE_TITLE);
$diffsizetitle = getDolGlobalInt('PDF_DIFFSIZE_TITLE', 3);

if (getDolGlobalInt('FACTURE_CHQ_NUMBER') > 0) {
$account = new Account($this->db);
Expand All @@ -1385,7 +1388,7 @@ protected function _tableau_info(&$pdf, $object, $posy, $outputlangs, $outputlan
$posy = $pdf->GetY() + 2;
}
}
if ($conf->global->FACTURE_CHQ_NUMBER == -1) {
if (getDolGlobalInt('FACTURE_CHQ_NUMBER') == -1) {
$pdf->SetXY($this->marge_gauche, $posy);
$pdf->SetFont('', 'B', $default_font_size - $diffsizetitle);
$pdf->MultiCell(100, 3, $outputlangs->transnoentities('PaymentByChequeOrderedTo', $this->emetteur->name), 0, 'L', 0);
Expand All @@ -1404,7 +1407,7 @@ protected function _tableau_info(&$pdf, $object, $posy, $outputlangs, $outputlan
// If payment mode not forced or forced to VIR, show payment with BAN
if (empty($object->mode_reglement_code) || $object->mode_reglement_code == 'VIR') {
if ($object->fk_account > 0 || $object->fk_bank > 0 || getDolGlobalInt('FACTURE_RIB_NUMBER')) {
$bankid = ($object->fk_account <= 0 ? $conf->global->FACTURE_RIB_NUMBER : $object->fk_account);
$bankid = ($object->fk_account <= 0 ? getDolGlobalString('FACTURE_RIB_NUMBER') : $object->fk_account);
if ($object->fk_bank > 0) {
$bankid = $object->fk_bank; // For backward compatibility when object->fk_account is forced with object->fk_bank
}
Expand Down Expand Up @@ -1828,7 +1831,7 @@ protected function _tableau_tot(&$pdf, $object, $deja_regle, $posy, $outputlangs
$index++;
$index++;
$pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
$pdf->MultiCell($col2x - $col1x, $tab2_hl, $conf->global->BILL_TEXT_TOTAL_FOOTER, 0, 'L', 0);
$pdf->MultiCell($col2x - $col1x, $tab2_hl, getDolGlobalString('BILL_TEXT_TOTAL_FOOTER'), 0, 'L', 0);
}

return ($tab2_top + ($tab2_hl * $index));
Expand Down Expand Up @@ -1877,7 +1880,6 @@ protected function _tableau(&$pdf, $tab_top, $tab_height, $nexY, $outputlangs, $
$pdf->SetXY($this->page_largeur - $this->marge_droite - ($pdf->GetStringWidth($titre) + 3), $tab_top - 4);
$pdf->MultiCell(($pdf->GetStringWidth($titre) + 3), 2, $titre);

//$conf->global->MAIN_PDF_TITLE_BACKGROUND_COLOR='230,230,230';
if (getDolGlobalString('MAIN_PDF_TITLE_BACKGROUND_COLOR')) {
$pdf->RoundedRect($this->marge_gauche, $tab_top, $this->page_largeur - $this->marge_droite - $this->marge_gauche, 5, $this->corner_radius, '1001', 'F', null, explode(',', getDolGlobalString('MAIN_PDF_TITLE_BACKGROUND_COLOR')));
}
Expand Down
27 changes: 13 additions & 14 deletions htdocs/core/modules/facture/doc/pdf_octopus.modules.php
Original file line number Diff line number Diff line change
Expand Up @@ -1329,14 +1329,17 @@ public function drawPaymentsTable(&$pdf, $object, $posy, $outputlangs)
*/
protected function drawInfoTable(&$pdf, $object, $posy, $outputlangs, $outputlangsbis)
{
global $conf, $mysoc, $hookmanager;
global $mysoc, $hookmanager;

$default_font_size = pdf_getPDFFontSize($outputlangs);

$pdf->SetFont('', '', $default_font_size - 1);

krsort($this->tva_array);

// Clean data type
$object->total_tva = (float) $object->total_tva;

// Show VAT details
if ($object->total_tva != 0 && getDolGlobalInt('PDF_INVOICE_SHOW_VAT_ANALYSIS')) {
$pdf->SetFillColor(224, 224, 224);
Expand Down Expand Up @@ -1394,7 +1397,7 @@ protected function drawInfoTable(&$pdf, $object, $posy, $outputlangs, $outputlan
}
}

// If France, show VAT mention if not applicable
// If France, show VAT mention if applicable
if ($this->emetteur->country_code == 'FR' && empty($object->total_tva) && (empty($mysoc->tva_assuj) || ($this->emetteur->isInEEC() && $object->thirdparty->isInEEC()))) {
$pdf->SetFont('', 'B', $default_font_size - 2);
$pdf->SetXY($this->marge_gauche, $posy);
Expand Down Expand Up @@ -1664,7 +1667,7 @@ protected function drawTotalTable(&$pdf, $object, $deja_regle, $posy, $outputlan
$pdf->SetXY($col1x, $tab2_top + 0);
$pdf->MultiCell($col2x - $col1x, $tab2_hl, $outputlangs->transnoentities("TotalHT").(is_object($outputlangsbis) ? ' / '.$outputlangsbis->transnoentities("TotalHT") : ''), 0, 'L', 1);

$total_ht = ((!empty($conf->multicurrency->enabled) && isset($object->multicurrency_tx) && $object->multicurrency_tx != 1) ? $object->multicurrency_total_ht : $object->total_ht);
$total_ht = ((isModEnabled('multicurrency') && isset($object->multicurrency_tx) && $object->multicurrency_tx != 1) ? $object->multicurrency_total_ht : $object->total_ht);
$pdf->SetXY($col2x, $tab2_top + 0);
$pdf->MultiCell($largcol2, $tab2_hl, price($total_ht, 0, $outputlangs), 0, 'R', 1);

Expand Down Expand Up @@ -2549,7 +2552,7 @@ protected function _pagefoot(&$pdf, $object, $outputlangs, $hidefreetext = 0)
*/
public function defineColumnField($object, $outputlangs, $hidedetails = 0, $hidedesc = 0, $hideref = 0)
{
global $conf, $hookmanager;
global $hookmanager;

// Default field style for content
$this->defaultContentsFieldsStyle = array(
Expand Down Expand Up @@ -2871,7 +2874,6 @@ public function _tableFirstPage(&$pdf, $tab_top, $tab_height, $nexY, $outputlang

$width = $this->page_largeur - $this->marge_gauche - $this->marge_droite - 83;

//$conf->global->MAIN_PDF_TITLE_BACKGROUND_COLOR='230,230,230';
if (getDolGlobalString('MAIN_PDF_TITLE_BACKGROUND_COLOR')) {
//$pdf->Rect($this->posx_cumul_anterieur - 1, $tab_top, $width, 5, 'F', null, explode(',', getDolGlobalString('MAIN_PDF_TITLE_BACKGROUND_COLOR')));
$pdf->RoundedRect($this->posx_cumul_anterieur - 1, $tab_top, $width, 5, $this->corner_radius, '1001', 'F', explode(',', getDolGlobalString('MAIN_PDF_TITLE_BACKGROUND_COLOR')));
Expand Down Expand Up @@ -3069,8 +3071,6 @@ public function _tableFirstPage(&$pdf, $tab_top, $tab_height, $nexY, $outputlang
*/
public function getDataSituation(&$object)
{
global $conf, $db;

// Fetch previous and next situations invoices.
// Return all previous and next invoices (both standard and credit notes)
$object->fetchPreviousNextSituationInvoice();
Expand Down Expand Up @@ -3233,7 +3233,6 @@ public function displayRetainedWarranty($object)
return $object->displayRetainedWarranty();
} else {
// FOR RETROCOMPATIBILITY
global $conf;

// TODO : add a flag on invoices to store this conf USE_RETAINED_WARRANTY_ONLY_FOR_SITUATION_FINAL

Expand Down Expand Up @@ -3365,7 +3364,7 @@ public function printRoundedRectBtp($pdf, $x, $y, $w, $h, $r, $hidetop = 0, $hid
*/
public function btpGetInvoiceAmounts($id, $forceReadFromDB = false)
{
global $user,$langs,$conf,$mysoc,$db,$hookmanager,$nblignes;
global $user, $langs, $mysoc, $db, $hookmanager, $nblignes;

$object = new Facture($db);
$object->fetch($id);
Expand Down Expand Up @@ -3517,7 +3516,7 @@ public function resumeLastPage(&$pdf, $object, $deja_regle, $posy, $outputlangs,
if (count($propals)) {
$propal = array_pop($propals);

$total_ht = ($conf->multicurrency->enabled && $propal->multicurrency_tx != 1) ? $propal->multicurrency_total_ht : $propal->total_ht;
$total_ht = (isModEnabled('multicurrency') && $propal->multicurrency_tx != 1) ? $propal->multicurrency_total_ht : $propal->total_ht;
$remain_to_pay = $total_ht;

$pdf->SetTextColor(0, 0, 60);
Expand All @@ -3540,7 +3539,7 @@ public function resumeLastPage(&$pdf, $object, $deja_regle, $posy, $outputlangs,
} elseif (count($orders)) {
$order = array_pop($orders);

$total_ht = ($conf->multicurrency->enabled && $order->multicurrency_tx != 1 ? $order->multicurrency_total_ht : $order->total_ht);
$total_ht = (isModEnabled('multicurrency') && $order->multicurrency_tx != 1 ? $order->multicurrency_total_ht : $order->total_ht);
$remain_to_pay = $total_ht;
}

Expand Down Expand Up @@ -3608,7 +3607,7 @@ public function resumeLastPage(&$pdf, $object, $deja_regle, $posy, $outputlangs,
$pdf->SetXY($posx, $posy);
$pdf->MultiCell($width, $height, $outputlangs->transnoentities("TotalHT"), 0, 'L', 1);

$total_ht = ($conf->multicurrency->enabled && $invoice->multicurrency_tx != 1 ? $invoice->multicurrency_total_ht : $invoice->total_ht);
$total_ht = (isModEnabled('multicurrency') && $invoice->multicurrency_tx != 1 ? $invoice->multicurrency_total_ht : $invoice->total_ht);

$pdf->SetXY($posx + $width, $posy);
$pdf->MultiCell($width2, $height, price($sign * ($total_ht + (!empty($invoice->remise) ? $invoice->remise : 0)), 0, $outputlangs), 0, 'R', 1);
Expand Down Expand Up @@ -3651,8 +3650,8 @@ public function resumeLastPage(&$pdf, $object, $deja_regle, $posy, $outputlangs,

$index++;

$total_ht = ($conf->multicurrency->enabled && $invoice->multicurrency_tx != 1) ? $invoice->multicurrency_total_ht : $invoice->total_ht;
$total_ttc = ($conf->multicurrency->enabled && $invoice->multicurrency_tx != 1) ? $invoice->multicurrency_total_ttc : $invoice->total_ttc;
$total_ht = (isModEnabled('multicurrency') && $invoice->multicurrency_tx != 1) ? $invoice->multicurrency_total_ht : $invoice->total_ht;
$total_ttc = (isModEnabled('multicurrency') && $invoice->multicurrency_tx != 1) ? $invoice->multicurrency_total_ttc : $invoice->total_ttc;

// Total TTC
$pdf->SetXY($posx, $posy + $height * $index);
Expand Down
11 changes: 7 additions & 4 deletions htdocs/core/modules/facture/doc/pdf_sponge.modules.php
Original file line number Diff line number Diff line change
Expand Up @@ -1268,6 +1268,9 @@ protected function drawInfoTable(&$pdf, $object, $posy, $outputlangs, $outputlan

krsort($this->tva_array);

// Clean data type
$object->total_tva = (float) $object->total_tva;

// Show VAT details
if ($object->total_tva != 0 && getDolGlobalInt('PDF_INVOICE_SHOW_VAT_ANALYSIS')) {
$pdf->SetFillColor(224, 224, 224);
Expand Down Expand Up @@ -1325,7 +1328,7 @@ protected function drawInfoTable(&$pdf, $object, $posy, $outputlangs, $outputlan
}
}

// If France, show VAT mention if not applicable
// If France, show VAT mention if applicable
if ($this->emetteur->country_code == 'FR' && empty($object->total_tva) && (empty($mysoc->tva_assuj) || ($this->emetteur->isInEEC() && $object->thirdparty->isInEEC()))) {
$pdf->SetFont('', '', $default_font_size - 2);
$pdf->SetXY($this->marge_gauche, $posy);
Expand Down Expand Up @@ -1468,7 +1471,7 @@ protected function drawInfoTable(&$pdf, $object, $posy, $outputlangs, $outputlan
if (empty($object->mode_reglement_code) || $object->mode_reglement_code == 'CHQ') {
// If payment mode unregulated or payment mode forced to CHQ
if (getDolGlobalInt('FACTURE_CHQ_NUMBER')) {
$diffsizetitle = (!getDolGlobalString('PDF_DIFFSIZE_TITLE') ? 3 : $conf->global->PDF_DIFFSIZE_TITLE);
$diffsizetitle = getDolGlobalInt('PDF_DIFFSIZE_TITLE', 3);

if (getDolGlobalInt('FACTURE_CHQ_NUMBER') > 0) {
$account = new Account($this->db);
Expand All @@ -1486,7 +1489,7 @@ protected function drawInfoTable(&$pdf, $object, $posy, $outputlangs, $outputlan
$posy = $pdf->GetY() + 2;
}
}
if ($conf->global->FACTURE_CHQ_NUMBER == -1) {
if (getDolGlobalInt('FACTURE_CHQ_NUMBER') == -1) {
$pdf->SetXY($this->marge_gauche, $posy);
$pdf->SetFont('', 'B', $default_font_size - $diffsizetitle);
$pdf->MultiCell($posxend - $this->marge_gauche, 3, $outputlangs->transnoentities('PaymentByChequeOrderedTo', $this->emetteur->name), 0, 'L', 0);
Expand Down Expand Up @@ -1570,7 +1573,7 @@ protected function drawInfoTable(&$pdf, $object, $posy, $outputlangs, $outputlan
*/
protected function drawTotalTable(&$pdf, $object, $deja_regle, $posy, $outputlangs, $outputlangsbis)
{
global $conf, $mysoc, $hookmanager;
global $mysoc, $hookmanager;

$sign = 1;
if ($object->type == 2 && getDolGlobalString('INVOICE_POSITIVE_CREDIT_NOTE')) {
Expand Down

0 comments on commit 595a856

Please sign in to comment.