diff --git a/htdocs/admin/pdf.php b/htdocs/admin/pdf.php
index 5030c487537..4d02a2ddb7a 100644
--- a/htdocs/admin/pdf.php
+++ b/htdocs/admin/pdf.php
@@ -104,6 +104,8 @@ if ($action == 'update') {
if (GETPOSTISSET('PDF_USE_ALSO_LANGUAGE_CODE')) dolibarr_set_const($db, "PDF_USE_ALSO_LANGUAGE_CODE", GETPOST('PDF_USE_ALSO_LANGUAGE_CODE', 'alpha'), 'chaine', 0, '', $conf->entity);
if (GETPOSTISSET('SHOW_SUBPRODUCT_REF_IN_PDF')) dolibarr_set_const($db, "SHOW_SUBPRODUCT_REF_IN_PDF", GETPOST('SHOW_SUBPRODUCT_REF_IN_PDF', 'alpha'), 'chaine', 0, '', $conf->entity);
+ if (GETPOSTISSET('PDF_SHOW_LINK_TO_ONLINE_PAYMENT')) dolibarr_set_const($db, "PDF_SHOW_LINK_TO_ONLINE_PAYMENT", GETPOST('PDF_SHOW_LINK_TO_ONLINE_PAYMENT', 'alpha'), 'chaine', 0, '', $conf->entity);
+
setEventMessages($langs->trans("SetupSaved"), null, 'mesgs');
header("Location: ".$_SERVER["PHP_SELF"]."?mainmenu=home&leftmenu=setup");
@@ -463,6 +465,16 @@ print '
| '.$langs->trans("ShowDetailsInPDFPageFoot").' | selectarray('MAIN_GENERATE_DOCUMENTS_SHOW_FOOT_DETAILS', $arraydetailsforpdffoot, (!empty($conf->global->MAIN_GENERATE_DOCUMENTS_SHOW_FOOT_DETAILS) ? $conf->global->MAIN_GENERATE_DOCUMENTS_SHOW_FOOT_DETAILS : 0));
print '
';
+// Show online payment link on invoices
+
+print '| '.$langs->trans("PDF_SHOW_LINK_TO_ONLINE_PAYMENT").' | ';
+if ($conf->use_javascript_ajax) {
+ print ajax_constantonoff('PDF_SHOW_LINK_TO_ONLINE_PAYMENT');
+} else {
+ print $form->selectyesno('PDF_SHOW_LINK_TO_ONLINE_PAYMENT', (!empty($conf->global->PDF_SHOW_LINK_TO_ONLINE_PAYMENT)) ? $conf->global->PDF_SHOW_LINK_TO_ONLINE_PAYMENT : 0, 1);
+}
+print ' |
';
+
print '';
print '';
diff --git a/htdocs/core/modules/facture/doc/pdf_crabe.modules.php b/htdocs/core/modules/facture/doc/pdf_crabe.modules.php
index 4cd2699a3d4..13d83dbd3f1 100644
--- a/htdocs/core/modules/facture/doc/pdf_crabe.modules.php
+++ b/htdocs/core/modules/facture/doc/pdf_crabe.modules.php
@@ -248,6 +248,14 @@ class pdf_crabe extends ModelePDFFactures
// Load translation files required by the page
$outputlangs->loadLangs(array("main", "bills", "products", "dict", "companies"));
+ global $outputlangsbis;
+ $outputlangsbis = null;
+ if (!empty($conf->global->PDF_USE_ALSO_LANGUAGE_CODE) && $outputlangs->defaultlang != $conf->global->PDF_USE_ALSO_LANGUAGE_CODE) {
+ $outputlangsbis = new Translate('', $conf);
+ $outputlangsbis->setDefaultLang($conf->global->PDF_USE_ALSO_LANGUAGE_CODE);
+ $outputlangsbis->loadLangs(array("main", "bills", "products", "dict", "companies"));
+ }
+
$nblines = count($object->lines);
// Loop on each lines to detect if there is at least one image to show
@@ -761,10 +769,10 @@ class pdf_crabe extends ModelePDFFactures
}
// Display info area
- $posy = $this->_tableau_info($pdf, $object, $bottomlasttab, $outputlangs);
+ $posy = $this->_tableau_info($pdf, $object, $bottomlasttab, $outputlangs, $outputlangsbis);
// Display total area
- $posy = $this->_tableau_tot($pdf, $object, $deja_regle, $bottomlasttab, $outputlangs);
+ $posy = $this->_tableau_tot($pdf, $object, $deja_regle, $bottomlasttab, $outputlangs, $outputlangsbis);
// Display Payments area
if (($deja_regle || $amount_credit_notes_included || $amount_deposits_included) && empty($conf->global->INVOICE_NO_PAYMENT_DETAILS)) {
@@ -1014,9 +1022,10 @@ class pdf_crabe extends ModelePDFFactures
* @param Facture $object Object to show
* @param int $posy Y
* @param Translate $outputlangs Langs object
- * @return void
+ * @param Translate $outputlangsbis Object lang for output bis
+ * @return int Pos y
*/
- protected function _tableau_info(&$pdf, $object, $posy, $outputlangs)
+ protected function _tableau_info(&$pdf, $object, $posy, $outputlangs, $outputlangsbis)
{
// phpcs:enable
global $conf, $mysoc;
@@ -1053,7 +1062,7 @@ class pdf_crabe extends ModelePDFFactures
$lib_condition_paiement = str_replace('\n', "\n", $lib_condition_paiement);
$pdf->MultiCell(67, 4, $lib_condition_paiement, 0, 'L');
- $posy = $pdf->GetY() + 3;
+ $posy = $pdf->GetY() + 3; // We need spaces for 2 lines payment conditions
}
if ($object->type != 2) {
@@ -1078,7 +1087,7 @@ class pdf_crabe extends ModelePDFFactures
}
// Show payment mode
- if ($object->mode_reglement_code
+ if (!empty($object->mode_reglement_code)
&& $object->mode_reglement_code != 'CHQ'
&& $object->mode_reglement_code != 'VIR') {
$pdf->SetFont('', 'B', $default_font_size - 2);
@@ -1091,9 +1100,25 @@ class pdf_crabe extends ModelePDFFactures
$lib_mode_reg = $outputlangs->transnoentities("PaymentType".$object->mode_reglement_code) != ('PaymentType'.$object->mode_reglement_code) ? $outputlangs->transnoentities("PaymentType".$object->mode_reglement_code) : $outputlangs->convToOutputCharset($object->mode_reglement);
$pdf->MultiCell(80, 5, $lib_mode_reg, 0, 'L');
- // Show online payment link
- $useonlinepayment = ((!empty($conf->paypal->enabled) || !empty($conf->stripe->enabled) || !empty($conf->paybox->enabled)) && !empty($conf->global->PDF_SHOW_LINK_TO_ONLINE_PAYMENT));
- if (($object->mode_reglement_code == 'CB' || $object->mode_reglement_code == 'VAD') && $object->statut != Facture::STATUS_DRAFT && $useonlinepayment) {
+ $posy = $pdf->GetY();
+ }
+
+ // Show online payment link
+ if (empty($object->mode_reglement_code) || $object->mode_reglement_code == 'CB' || $object->mode_reglement_code == 'VAD') {
+ $useonlinepayment = 0;
+ if (!empty($conf->global->PDF_SHOW_LINK_TO_ONLINE_PAYMENT)) {
+ if (!empty($conf->paypal->enabled)) {
+ $useonlinepayment++;
+ }
+ if (!empty($conf->stripe->enabled)) {
+ $useonlinepayment++;
+ }
+ if (!empty($conf->paybox->enabled)) {
+ $useonlinepayment++;
+ }
+ }
+
+ if ($object->statut != Facture::STATUS_DRAFT && $useonlinepayment) {
require_once DOL_DOCUMENT_ROOT.'/core/lib/payments.lib.php';
global $langs;
@@ -1102,11 +1127,11 @@ class pdf_crabe extends ModelePDFFactures
$paiement_url = getOnlinePaymentUrl('', 'invoice', $object->ref, '', '', '');
$linktopay = $langs->trans("ToOfferALinkForOnlinePayment", $servicename).' '.$outputlangs->transnoentities("ClickHere").'';
- $pdf->writeHTMLCell(80, 10, '', '', dol_htmlentitiesbr($linktopay), 0, 1);
+ $pdf->SetXY($this->marge_gauche, $posy);
+ $pdf->writeHTMLCell(80, 5, '', '', dol_htmlentitiesbr($linktopay), 0, 1);
}
-
- $posy = $pdf->GetY() + 2;
+ $posy = $pdf->GetY() + 1;
}
// Show payment mode CHQ
@@ -1181,12 +1206,13 @@ class pdf_crabe extends ModelePDFFactures
* @param int $deja_regle Amount already paid (in the currency of invoice)
* @param int $posy Position depart
* @param Translate $outputlangs Objet langs
+ * @param Translate $outputlangsbis Object lang for output bis
* @return int Position pour suite
*/
- protected function _tableau_tot(&$pdf, $object, $deja_regle, $posy, $outputlangs)
+ protected function _tableau_tot(&$pdf, $object, $deja_regle, $posy, $outputlangs, $outputlangsbis)
{
// phpcs:enable
- global $conf, $mysoc;
+ global $conf, $mysoc, $hookmanager;
$sign = 1;
if ($object->type == 2 && !empty($conf->global->INVOICE_POSITIVE_CREDIT_NOTE)) {
@@ -1253,7 +1279,8 @@ class pdf_crabe extends ModelePDFFactures
$tvacompl = " (".$outputlangs->transnoentities("NonPercuRecuperable").")";
}
- $totalvat = $outputlangs->transcountrynoentities("TotalLT1", $mysoc->country_code).' ';
+ $totalvat = $outputlangs->transcountrynoentities("TotalLT1", $mysoc->country_code).(is_object($outputlangsbis) ? ' / '.$outputlangsbis->transcountrynoentities("TotalLT1", $mysoc->country_code) : '');
+ $totalvat .= ' ';
$totalvat .= vatrate(abs($tvakey), 1).$tvacompl;
$pdf->MultiCell($col2x - $col1x, $tab2_hl, $totalvat, 0, 'L', 1);
@@ -1285,7 +1312,8 @@ class pdf_crabe extends ModelePDFFactures
$tvakey = str_replace('*', '', $tvakey);
$tvacompl = " (".$outputlangs->transnoentities("NonPercuRecuperable").")";
}
- $totalvat = $outputlangs->transcountrynoentities("TotalLT2", $mysoc->country_code).' ';
+ $totalvat = $outputlangs->transcountrynoentities("TotalLT2", $mysoc->country_code).(is_object($outputlangsbis) ? ' / '.$outputlangsbis->transcountrynoentities("TotalLT2", $mysoc->country_code) : '');
+ $totalvat .= ' ';
$totalvat .= vatrate(abs($tvakey), 1).$tvacompl;
$pdf->MultiCell($col2x - $col1x, $tab2_hl, $totalvat, 0, 'L', 1);
diff --git a/htdocs/core/modules/facture/doc/pdf_sponge.modules.php b/htdocs/core/modules/facture/doc/pdf_sponge.modules.php
index be458fcdd1a..2bd8fb2ecec 100644
--- a/htdocs/core/modules/facture/doc/pdf_sponge.modules.php
+++ b/htdocs/core/modules/facture/doc/pdf_sponge.modules.php
@@ -906,10 +906,10 @@ class pdf_sponge extends ModelePDFFactures
}
// Display infos area
- $posy = $this->drawInfoTable($pdf, $object, $bottomlasttab, $outputlangs);
+ $posy = $this->drawInfoTable($pdf, $object, $bottomlasttab, $outputlangs, $outputlangsbis);
// Display total zone
- $posy = $this->drawTotalTable($pdf, $object, $deja_regle, $bottomlasttab, $outputlangs);
+ $posy = $this->drawTotalTable($pdf, $object, $deja_regle, $bottomlasttab, $outputlangs, $outputlangsbis);
// Display payment area
if (($deja_regle || $amount_credit_notes_included || $amount_deposits_included) && empty($conf->global->INVOICE_NO_PAYMENT_DETAILS)) {
@@ -1104,9 +1104,10 @@ class pdf_sponge extends ModelePDFFactures
* @param Facture $object Object to show
* @param int $posy Y
* @param Translate $outputlangs Langs object
+ * @param Translate $outputlangsbis Object lang for output bis
* @return int Pos y
*/
- protected function drawInfoTable(&$pdf, $object, $posy, $outputlangs)
+ protected function drawInfoTable(&$pdf, $object, $posy, $outputlangs, $outputlangsbis)
{
global $conf, $mysoc;
@@ -1118,7 +1119,11 @@ class pdf_sponge extends ModelePDFFactures
if ($this->emetteur->country_code == 'FR' && empty($mysoc->tva_assuj)) {
$pdf->SetFont('', 'B', $default_font_size - 2);
$pdf->SetXY($this->marge_gauche, $posy);
- $pdf->MultiCell(100, 3, $outputlangs->transnoentities("VATIsNotUsedForInvoice"), 0, 'L', 0);
+ if ($mysoc->forme_juridique_code == 92) {
+ $pdf->MultiCell(100, 3, $outputlangs->transnoentities("VATIsNotUsedForInvoiceAsso"), 0, 'L', 0);
+ } else {
+ $pdf->MultiCell(100, 3, $outputlangs->transnoentities("VATIsNotUsedForInvoice"), 0, 'L', 0);
+ }
$posy = $pdf->GetY() + 4;
}
@@ -1138,7 +1143,7 @@ class pdf_sponge extends ModelePDFFactures
$lib_condition_paiement = str_replace('\n', "\n", $lib_condition_paiement);
$pdf->MultiCell(67, 4, $lib_condition_paiement, 0, 'L');
- $posy = $pdf->GetY() + 3;
+ $posy = $pdf->GetY() + 3; // We need spaces for 2 lines payment conditions
}
if ($object->type != 2) {
@@ -1163,7 +1168,7 @@ class pdf_sponge extends ModelePDFFactures
}
// Show payment mode
- if ($object->mode_reglement_code
+ if (!empty($object->mode_reglement_code)
&& $object->mode_reglement_code != 'CHQ'
&& $object->mode_reglement_code != 'VIR') {
$pdf->SetFont('', 'B', $default_font_size - 2);
@@ -1176,9 +1181,25 @@ class pdf_sponge extends ModelePDFFactures
$lib_mode_reg = $outputlangs->transnoentities("PaymentType".$object->mode_reglement_code) != ('PaymentType'.$object->mode_reglement_code) ? $outputlangs->transnoentities("PaymentType".$object->mode_reglement_code) : $outputlangs->convToOutputCharset($object->mode_reglement);
$pdf->MultiCell(80, 5, $lib_mode_reg, 0, 'L');
- // Show online payment link
- $useonlinepayment = ((!empty($conf->paypal->enabled) || !empty($conf->stripe->enabled) || !empty($conf->paybox->enabled)) && !empty($conf->global->PDF_SHOW_LINK_TO_ONLINE_PAYMENT));
- if (($object->mode_reglement_code == 'CB' || $object->mode_reglement_code == 'VAD') && $object->statut != Facture::STATUS_DRAFT && $useonlinepayment) {
+ $posy = $pdf->GetY();
+ }
+
+ // Show online payment link
+ if (empty($object->mode_reglement_code) || $object->mode_reglement_code == 'CB' || $object->mode_reglement_code == 'VAD') {
+ $useonlinepayment = 0;
+ if (!empty($conf->global->PDF_SHOW_LINK_TO_ONLINE_PAYMENT)) {
+ if (!empty($conf->paypal->enabled)) {
+ $useonlinepayment++;
+ }
+ if (!empty($conf->stripe->enabled)) {
+ $useonlinepayment++;
+ }
+ if (!empty($conf->paybox->enabled)) {
+ $useonlinepayment++;
+ }
+ }
+
+ if ($object->statut != Facture::STATUS_DRAFT && $useonlinepayment) {
require_once DOL_DOCUMENT_ROOT.'/core/lib/payments.lib.php';
global $langs;
@@ -1187,10 +1208,11 @@ class pdf_sponge extends ModelePDFFactures
$paiement_url = getOnlinePaymentUrl('', 'invoice', $object->ref, '', '', '');
$linktopay = $langs->trans("ToOfferALinkForOnlinePayment", $servicename).' '.$outputlangs->transnoentities("ClickHere").'';
- $pdf->writeHTMLCell(80, 10, '', '', dol_htmlentitiesbr($linktopay), 0, 1);
+ $pdf->SetXY($this->marge_gauche, $posy);
+ $pdf->writeHTMLCell(80, 5, '', '', dol_htmlentitiesbr($linktopay), 0, 1);
}
- $posy = $pdf->GetY() + 2;
+ $posy = $pdf->GetY() + 1;
}
// Show payment mode CHQ
@@ -1263,9 +1285,10 @@ class pdf_sponge extends ModelePDFFactures
* @param int $deja_regle Amount already paid (in the currency of invoice)
* @param int $posy Position depart
* @param Translate $outputlangs Objet langs
+ * @param Translate $outputlangsbis Object lang for output bis
* @return int Position pour suite
*/
- protected function drawTotalTable(&$pdf, $object, $deja_regle, $posy, $outputlangs)
+ protected function drawTotalTable(&$pdf, $object, $deja_regle, $posy, $outputlangs, $outputlangsbis)
{
global $conf, $mysoc, $hookmanager;
@@ -1276,14 +1299,6 @@ class pdf_sponge extends ModelePDFFactures
$default_font_size = pdf_getPDFFontSize($outputlangs);
- $outputlangsbis = null;
- if (!empty($conf->global->PDF_USE_ALSO_LANGUAGE_CODE) && $outputlangs->defaultlang != $conf->global->PDF_USE_ALSO_LANGUAGE_CODE) {
- $outputlangsbis = new Translate('', $conf);
- $outputlangsbis->setDefaultLang($conf->global->PDF_USE_ALSO_LANGUAGE_CODE);
- $outputlangsbis->loadLangs(array("main", "dict", "companies", "bills", "products", "propal"));
- $default_font_size--;
- }
-
$tab2_top = $posy;
$tab2_hl = 4;
$pdf->SetFont('', '', $default_font_size - 1);
diff --git a/htdocs/langs/en_US/admin.lang b/htdocs/langs/en_US/admin.lang
index 454df4ed28e..76dd117dbd8 100644
--- a/htdocs/langs/en_US/admin.lang
+++ b/htdocs/langs/en_US/admin.lang
@@ -2163,3 +2163,4 @@ APIsAreNotEnabled=APIs modules are not enabled
YouShouldSetThisToOff=You should set this to 0 or off
InstallAndUpgradeLockedBy=Install and upgrades are locked by the file %s
OldImplementation=Old implementation
+PDF_SHOW_LINK_TO_ONLINE_PAYMENT=If some online payment modules are enabled (Paypal, Stripe, ...), add a link on the PDF to make the online payment
\ No newline at end of file