Browse Source

Support ZATCA

Laurent Destailleur 3 years ago
parent
commit
baae99fbb4

+ 1 - 0
ChangeLog

@@ -12,6 +12,7 @@ For users:
 NEW: PHP 8.1 compatibility
 NEW: Support for recurring purchase invoices.
 NEW: #20292 Include German public holidays
+NEW: Can show ZATCA QRCode on PDFs
 NEW: #17123 added ExtraFields for Stock Mouvement
 NEW: #20609 : new massaction to assign a sale representatives on a selection of thirdparties
 NEW: #20653 edit discount pourcentage for all lines in one shot

+ 2 - 2
htdocs/accountancy/class/accountancyexport.class.php

@@ -111,7 +111,7 @@ class AccountancyExport
 	 */
 	public function getType()
 	{
-		global $langs;
+		global $langs, $hookmanager;
 
 		$listofexporttypes = array(
 			self::$EXPORT_TYPE_CONFIGURABLE => $langs->trans('Modelcsv_configurable'),
@@ -137,7 +137,7 @@ class AccountancyExport
 		);
 
 		// allow modules to define export formats
-		global $hookmanager;
+		$parameters = array();
 		$reshook = $hookmanager->executeHooks('getType', $parameters, $listofexporttypes);
 
 		ksort($listofexporttypes, SORT_NUMERIC);

+ 32 - 6
htdocs/admin/pdf_other.php

@@ -60,6 +60,9 @@ if ($action == 'update') {
 	if (GETPOSTISSET('MAIN_DOCUMENTS_WITH_PICTURE_WIDTH')) {
 		dolibarr_set_const($db, "MAIN_DOCUMENTS_WITH_PICTURE_WIDTH", GETPOST("MAIN_DOCUMENTS_WITH_PICTURE_WIDTH", 'int'), 'chaine', 0, '', $conf->entity);
 	}
+	if (GETPOSTISSET('INVOICE_ADD_ZATCA_QR_CODE')) {
+		dolibarr_set_const($db, "INVOICE_ADD_ZATCA_QR_CODE", GETPOST("INVOICE_ADD_ZATCA_QR_CODE", 'int'), 'chaine', 0, '', $conf->entity);
+	}
 
 	setEventMessages($langs->trans("SetupSaved"), null, 'mesgs');
 
@@ -90,19 +93,19 @@ $tooltiptext = '';
 print '<span class="opacitymedium">'.$form->textwithpicto($langs->trans("PDFOtherDesc"), $tooltiptext)."</span><br>\n";
 print "<br>\n";
 
+print '<form method="post" action="'.$_SERVER["PHP_SELF"].'">';
+print '<input type="hidden" name="token" value="'.newToken().'">';
+print '<input type="hidden" name="action" value="update">';
+
 if (!empty($conf->propal->enabled)) {
 	print load_fiche_titre($langs->trans("Proposal"), '', '');
 
-	print '<form method="post" action="'.$_SERVER["PHP_SELF"].'">';
-	print '<input type="hidden" name="token" value="'.newToken().'">';
-	print '<input type="hidden" name="action" value="update">';
-
 	print '<div class="div-table-responsive-no-min">';
 	print '<table summary="more" class="noborder centpercent">';
 	print '<tr class="liste_titre"><td class="titlefieldmiddle">'.$langs->trans("Parameter").'</td><td width="200px">'.$langs->trans("Value").'</td></tr>';
 
-	print '<tr class="oddeven"><td>'.$langs->trans("MAIN_GENERATE_PROPOSALS_WITH_PICTURE");
-	print ' <span class="opacitymedium">('.$langs->trans("RandomlySelectedIfSeveral").')</span>';
+	print '<tr class="oddeven"><td>';
+	print $form->textwithpicto($langs->trans("MAIN_GENERATE_PROPOSALS_WITH_PICTURE"), $langs->trans("RandomlySelectedIfSeveral"));
 	print '</td><td>';
 	if ($conf->use_javascript_ajax) {
 		print ajax_constantonoff('MAIN_GENERATE_PROPOSALS_WITH_PICTURE');
@@ -112,6 +115,29 @@ if (!empty($conf->propal->enabled)) {
 	}
 	print '</td></tr>';
 
+	print '</table>';
+	print '</div>';
+}
+
+
+if (!empty($conf->facture->enabled)) {
+	print load_fiche_titre($langs->trans("Invoices"), '', '');
+
+	print '<div class="div-table-responsive-no-min">';
+	print '<table summary="more" class="noborder centpercent">';
+	print '<tr class="liste_titre"><td class="titlefieldmiddle">'.$langs->trans("Parameter").'</td><td width="200px">'.$langs->trans("Value").'</td></tr>';
+
+	print '<tr class="oddeven"><td>';
+	print $form->textwithpicto($langs->trans("INVOICE_ADD_ZATCA_QR_CODE"), $langs->trans("INVOICE_ADD_ZATCA_QR_CODEMore"));
+	print '</td><td>';
+	if ($conf->use_javascript_ajax) {
+		print ajax_constantonoff('INVOICE_ADD_ZATCA_QR_CODE');
+	} else {
+		$arrval = array('0' => $langs->trans("No"), '1' => $langs->trans("Yes"));
+		print $form->selectarray("INVOICE_ADD_ZATCA_QR_CODE", $arrval, $conf->global->INVOICE_ADD_ZATCA_QR_CODE);
+	}
+	print '</td></tr>';
+
 	/*
 	  print '<tr class="oddeven"><td>'.$langs->trans("MAIN_PDF_PROPAL_USE_ELECTRONIC_SIGNING").'</td><td>';
 	  if ($conf->use_javascript_ajax) {

+ 2 - 1
htdocs/compta/paiement/cheque/class/remisecheque.class.php

@@ -200,8 +200,9 @@ class RemiseCheque extends CommonObject
 				}
 			}
 
+			$lines = array();
+
 			if ($this->id > 0 && $this->errno == 0) {
-				$lines = array();
 				$sql = "SELECT b.rowid";
 				$sql .= " FROM ".MAIN_DB_PREFIX."bank as b";
 				$sql .= " WHERE b.fk_type = 'CHQ'";

+ 2 - 0
htdocs/langs/en_US/admin.lang

@@ -2260,3 +2260,5 @@ TextOnly=Text only
 IconOnlyAllTextsOnHover=Icon only - All texts appears under icon on mouse hover menu bar
 IconOnlyTextOnHover=Icon only - Text of icon appears under icon on mouse hover the icon
 IconOnly=Icon only - Text on tooltip only
+INVOICE_ADD_ZATCA_QR_CODE=Show the ZATCA QR code on invoices
+INVOICE_ADD_ZATCA_QR_CODEMore=Some Arabic countries need this QR Code on their invoices