From 77afadcc1f8a6fea029ed75df2fbe3a64f2f637a Mon Sep 17 00:00:00 2001 From: Eric Seigne Date: Tue, 12 Mar 2024 07:43:16 +0100 Subject: [PATCH 1/9] replace OR by AND condition --- htdocs/accountancy/bookkeeping/list.php | 2 +- htdocs/accountancy/bookkeeping/listbyaccount.php | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/htdocs/accountancy/bookkeeping/list.php b/htdocs/accountancy/bookkeeping/list.php index 5d91a0fc334..819d1fe21e8 100644 --- a/htdocs/accountancy/bookkeeping/list.php +++ b/htdocs/accountancy/bookkeeping/list.php @@ -519,7 +519,7 @@ if (empty($reshook)) { setEventMessages($object->error, $object->errors, 'errors'); $error++; break; - } elseif (isset($object->date_validation) || $object->date_validation != '') { + } elseif (isset($object->date_validation) && $object->date_validation != '') { setEventMessages($langs->trans("ValidatedRecordWhereFound"), null, 'errors'); $error++; break; diff --git a/htdocs/accountancy/bookkeeping/listbyaccount.php b/htdocs/accountancy/bookkeeping/listbyaccount.php index 50f2b308ea3..9d171900005 100644 --- a/htdocs/accountancy/bookkeeping/listbyaccount.php +++ b/htdocs/accountancy/bookkeeping/listbyaccount.php @@ -432,7 +432,7 @@ if (empty($reshook)) { setEventMessages($object->error, $object->errors, 'errors'); $error++; break; - } elseif (isset($object->date_validation) || $object->date_validation != '') { + } elseif (isset($object->date_validation) && $object->date_validation != '') { setEventMessages($langs->trans("ValidatedRecordWhereFound"), null, 'errors'); $error++; break; From 2ee52c1659e851221bf184ee46f014a5dcf2b288 Mon Sep 17 00:00:00 2001 From: Ferran Marcet Date: Tue, 12 Mar 2024 13:44:19 +0100 Subject: [PATCH 2/9] Fix: Error in the SQL to update the stock from batch to non-batch management --- htdocs/product/class/product.class.php | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/htdocs/product/class/product.class.php b/htdocs/product/class/product.class.php index b959d87063f..fa89c13b5cf 100644 --- a/htdocs/product/class/product.class.php +++ b/htdocs/product/class/product.class.php @@ -12,7 +12,7 @@ * Copyright (C) 2014 Henry Florian * Copyright (C) 2014-2016 Philippe Grand * Copyright (C) 2014 Ion agorria - * Copyright (C) 2016-2018 Ferran Marcet + * Copyright (C) 2016-2024 Ferran Marcet * Copyright (C) 2017 Gustavo Novaro * Copyright (C) 2019-2023 Frédéric France * Copyright (C) 2023 Benjamin Falière @@ -1341,8 +1341,8 @@ class Product extends CommonObject if (!$this->hasbatch() && $this->oldcopy->hasbatch()) { // Selection of all product stock mouvements that contains batchs - $sql = 'SELECT pb.qty, pb.fk_entrepot, pb.batch FROM '.MAIN_DB_PREFIX.'product_batch as pb'; - $sql.= ' INNER JOIN '.MAIN_DB_PREFIX.'product_stock as ps ON (ps.rowid = batch.fk_product_stock)'; + $sql = 'SELECT pb.qty, ps.fk_entrepot, pb.batch FROM '.MAIN_DB_PREFIX.'product_batch as pb'; + $sql.= ' INNER JOIN '.MAIN_DB_PREFIX.'product_stock as ps ON (ps.rowid = pb.fk_product_stock)'; $sql.= ' WHERE ps.fk_product = '.(int) $this->id; $resql = $this->db->query($sql); From 6679565638d619522280ba8587f28d70bb775cf0 Mon Sep 17 00:00:00 2001 From: Ferran Marcet Date: Tue, 12 Mar 2024 17:01:59 +0100 Subject: [PATCH 3/9] Fix: Error in the treatment of the date and the name of the variable --- htdocs/product/class/productbatch.class.php | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/htdocs/product/class/productbatch.class.php b/htdocs/product/class/productbatch.class.php index 0d6d4f52e68..f9d0edb5988 100644 --- a/htdocs/product/class/productbatch.class.php +++ b/htdocs/product/class/productbatch.class.php @@ -1,6 +1,7 @@ * Copyright (C) 2013-2014 Cedric GROSS + * Copyright (C) 2024 Ferran Marcet * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -519,7 +520,7 @@ class Productbatch extends CommonObject $tmp->import_key = $obj->import_key; if (getDolGlobalString('SHIPPING_DISPLAY_STOCK_ENTRY_DATE')) { - $tmp->context['stock_date_entry'] = $obj->date_entree; + $tmp->context['stock_entry_date'] = $dbs->jdate($obj->date_entree); } if ($fk_product > 0) { From b9ed346711072c479607050e8c742751145d414d Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Wed, 13 Mar 2024 15:54:15 +0100 Subject: [PATCH 4/9] FIX edit bank suggested for credit transfer payment in invoice setup when bank is closed. --- htdocs/admin/facture.php | 34 ++++++++++++++++++++++------------ 1 file changed, 22 insertions(+), 12 deletions(-) diff --git a/htdocs/admin/facture.php b/htdocs/admin/facture.php index 19f1182e608..7bf83eb4a9c 100644 --- a/htdocs/admin/facture.php +++ b/htdocs/admin/facture.php @@ -618,13 +618,14 @@ if (getDolGlobalString('INVOICE_USE_DEFAULT_DOCUMENT')) { // Hidden conf print '
'; print ''; print ''; + print ''; print '
'; print ''; print ''; print ''; print ''; - print ''; + print ''; print "\n"; $listtype = array( @@ -660,6 +661,7 @@ print load_fiche_titre($langs->trans("SuggestedPaymentModesIfNotDefinedInInvoice print ''; print ''; +print ''; print '
'; print '
'.$langs->trans("Type").''.$langs->trans("Name").'
'; @@ -668,17 +670,16 @@ print ''; print ''; -print ''; +print ''; print "\n"; print ''; print ""; print ""; print "
'; print ''; print $langs->trans("PaymentMode").'
".$langs->trans("SuggestPaymentByRIBOnAccount").""; if (isModEnabled('banque')) { - $sql = "SELECT rowid, label"; + $sql = "SELECT rowid, label, clos"; $sql .= " FROM ".MAIN_DB_PREFIX."bank_account"; - $sql .= " WHERE clos = 0"; - $sql .= " AND courant = 1"; + $sql .= " WHERE courant = 1"; $sql .= " AND entity IN (".getEntity('bank_account').")"; $resql = $db->query($sql); if ($resql) { @@ -688,15 +689,19 @@ if (isModEnabled('banque')) { print '"; + print ajax_combobox("rib"); } else { print ''.$langs->trans("NoActiveBankAccountDefined").''; } @@ -736,6 +741,8 @@ if ($resql) { } } print ""; +print ajax_combobox("chq", array(), 0, 0, 'resolve', -2); + print "
"; print '
'; @@ -758,12 +765,13 @@ print "\n"; print ''; print ''; print ''; +print ''; print ''; print $langs->trans("ForceInvoiceDate"); print ''; print $form->selectyesno("forcedate", getDolGlobalInt('FAC_FORCE_DATE_VALIDATION', 0), 1); print ''; -print ''; +print ''; print "\n"; print '
'; @@ -778,6 +786,7 @@ $htmltext .= ''; print '
'; print ''; print ''; +print ''; print ''; print $form->textwithpicto($langs->trans("FreeLegalTextOnInvoices"), $langs->trans("AddCRIfTooLong").'

'.$htmltext, 1, 'help', '', 0, 2, 'freetexttooltip').'
'; $variablename = 'INVOICE_FREE_TEXT'; @@ -789,7 +798,7 @@ if (!getDolGlobalString('PDF_ALLOW_HTML_FOR_FREE_TEXT')) { print $doleditor->Create(); } print ''; -print ''; +print ''; print "\n"; print '
'; @@ -797,12 +806,13 @@ print ''; print '
'; print ''; print ''; +print ''; print ''; print $form->textwithpicto($langs->trans("WatermarkOnDraftBill"), $htmltext, 1, 'help', '', 0, 2, 'watermarktooltip').'
'; print ''; print ''; print ''; -print ''; +print ''; print "\n"; print '
'; From 45a68ba612d3d4bf8b442605a784428690e72c1e Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Wed, 13 Mar 2024 20:17:26 +0100 Subject: [PATCH 5/9] Better error management --- htdocs/core/lib/files.lib.php | 14 +++++----- htdocs/core/lib/modulebuilder.lib.php | 27 +++++++++++++++---- htdocs/langs/en_US/errors.lang | 2 +- htdocs/modulebuilder/index.php | 21 ++++++++------- .../core/modules/modMyModule.class.php | 10 +++++-- 5 files changed, 49 insertions(+), 25 deletions(-) diff --git a/htdocs/core/lib/files.lib.php b/htdocs/core/lib/files.lib.php index d19e28faa01..960d9ee7eec 100644 --- a/htdocs/core/lib/files.lib.php +++ b/htdocs/core/lib/files.lib.php @@ -644,19 +644,17 @@ function dol_fileperm($pathoffile) /** * Make replacement of strings into a file. * - * @param string $srcfile Source file (can't be a directory) + * @param string $srcfile Source file (can't be a directory) * @param array $arrayreplacement Array with strings to replace. Example: array('valuebefore'=>'valueafter', ...) - * @param string $destfile Destination file (can't be a directory). If empty, will be same than source file. - * @param string $newmask Mask for new file (0 by default means $conf->global->MAIN_UMASK). Example: '0666' - * @param int $indexdatabase 1=index new file into database. - * @param int $arrayreplacementisregex 1=Array of replacement is already an array with key that is a regex. Warning: the key must be escaped with preg_quote for '/' - * @return int Return integer <0 if error, 0 if nothing done (dest file already exists), >0 if OK + * @param string $destfile Destination file (can't be a directory). If empty, will be same than source file. + * @param string $newmask Mask for new file (0 by default means $conf->global->MAIN_UMASK). Example: '0666' + * @param int $indexdatabase 1=index new file into database. + * @param int $arrayreplacementisregex 1=Array of replacement is already an array with key that is a regex. Warning: the key must be escaped with preg_quote for '/' + * @return int Return integer <0 if error, 0 if nothing done (dest file already exists), >0 if OK * @see dol_copy() */ function dolReplaceInFile($srcfile, $arrayreplacement, $destfile = '', $newmask = '0', $indexdatabase = 0, $arrayreplacementisregex = 0) { - global $conf; - dol_syslog("files.lib.php::dolReplaceInFile srcfile=".$srcfile." destfile=".$destfile." newmask=".$newmask." indexdatabase=".$indexdatabase." arrayreplacementisregex=".$arrayreplacementisregex); if (empty($srcfile)) { diff --git a/htdocs/core/lib/modulebuilder.lib.php b/htdocs/core/lib/modulebuilder.lib.php index 19d9c9319a2..68e8b982cce 100644 --- a/htdocs/core/lib/modulebuilder.lib.php +++ b/htdocs/core/lib/modulebuilder.lib.php @@ -456,20 +456,37 @@ function dolGetListOfObjectClasses($destdir) return -1; } + /** - * function for check if comment begin an end exist in modMyModule class - * @param string $file filename or path - * @param int $number 0 = For Menus,1 = For permissions, 2 = For Dictionaries - * @return int 1 if OK , -1 if KO + * Function to check if comment begin an end exist in modMyModule class + * + * @param string $file Filename or path + * @param int $number 0 = For Menus,1 = For permissions, 2 = For Dictionaries + * @return int 1 if OK , -1 if KO */ function checkExistComment($file, $number) { if (!file_exists($file)) { return -1; } + $content = file_get_contents($file); if ($number === 0) { - if (strpos($content, '/* BEGIN MODULEBUILDER LEFTMENU MYOBJECT */') !== false && strpos($content, '/* END MODULEBUILDER LEFTMENU MYOBJECT */') !== false) { + $ret = 0; + if (strpos($content, '/* BEGIN MODULEBUILDER TOPMENU MYOBJECT */') !== false) { + $ret++; + } + if (strpos($content, '/* END MODULEBUILDER TOPMENU MYOBJECT */') !== false) { + $ret++; + } + if (strpos($content, '/* BEGIN MODULEBUILDER LEFTMENU MYOBJECT */') !== false) { + $ret++; + } + if (strpos($content, '/* END MODULEBUILDER LEFTMENU MYOBJECT */') !== false) { + $ret++; + } + + if ($ret == 4) { return 1; } } elseif ($number === 1) { diff --git a/htdocs/langs/en_US/errors.lang b/htdocs/langs/en_US/errors.lang index 3290d9a2251..fe7cb304610 100644 --- a/htdocs/langs/en_US/errors.lang +++ b/htdocs/langs/en_US/errors.lang @@ -374,7 +374,7 @@ WarningModuleNeedRefresh = Module %s has been disabled. Don't forget to e WarningPermissionAlreadyExist=Existing permissions for this object WarningGoOnAccountancySetupToAddAccounts=If this list is empty, go into menu %s - %s - %s to load or create accounts for your chart of account. WarningCorrectedInvoiceNotFound=Corrected invoice not found -WarningCommentNotFound=Please check placement of start and end comments for %s section in file %s before submitting your action +WarningCommentNotFound=Warning: Can't find the start and/or end comments for the section %s into the file %s WarningAlreadyReverse=Stock movement already reversed SwissQrOnlyVIR = SwissQR invoice can only be added on invoices set to be paid with credit transfer payments. diff --git a/htdocs/modulebuilder/index.php b/htdocs/modulebuilder/index.php index 6d1a5a85d06..1e78c341f06 100644 --- a/htdocs/modulebuilder/index.php +++ b/htdocs/modulebuilder/index.php @@ -1017,6 +1017,8 @@ if ($dirins && $action == 'confirm_removefile' && !empty($module)) { // Init an object if ($dirins && $action == 'initobject' && $module && $objectname) { + $warning = 0; + $objectname = ucfirst($objectname); $dirins = $dirread = $listofmodules[strtolower($module)]['moduledescriptorrootpath']; @@ -1365,13 +1367,12 @@ if ($dirins && $action == 'initobject' && $module && $objectname) { } } - if (!$error) { foreach ($filetogenerate as $srcfile => $destfile) { $result = dol_copy($srcdir.'/'.$srcfile, $destdir.'/'.$destfile, $newmask, 0); if ($result <= 0) { if ($result < 0) { - $error++; + $warning++; $langs->load("errors"); setEventMessages($langs->trans("ErrorFailToCopyFile", $srcdir.'/'.$srcfile, $destdir.'/'.$destfile), null, 'errors'); } else { @@ -1383,6 +1384,7 @@ if ($dirins && $action == 'initobject' && $module && $objectname) { '/myobject\.class\.php/' => strtolower($objectname).'.class.php', '/myobject\.lib\.php/' => strtolower($objectname).'.lib.php', ); + dolReplaceInFile($destdir.'/'.$destfile, $arrayreplacement, '', 0, 0, 1); } } @@ -1529,8 +1531,8 @@ if ($dirins && $action == 'initobject' && $module && $objectname) { if (!$counter) { $checkComment = checkExistComment($moduledescriptorfile, 0); if ($checkComment < 0) { - $error++; - setEventMessages($langs->trans("WarningCommentNotFound", $langs->trans("Menus"), "mod".$module."class.php"), null, 'warnings'); + $warning++; + setEventMessages($langs->trans("WarningCommentNotFound", $langs->trans("Menus"), basename($moduledescriptorfile)), null, 'warnings'); } else { $arrayofreplacement = array('/* END MODULEBUILDER LEFTMENU MYOBJECT */' => '/*LEFTMENU '.strtoupper($objectname).'*/'.$stringtoadd."\n\t\t".'/*END LEFTMENU '.strtoupper($objectname).'*/'."\n\t\t".'/* END MODULEBUILDER LEFTMENU MYOBJECT */'); dolReplaceInFile($moduledescriptorfile, $arrayofreplacement); @@ -1580,7 +1582,7 @@ if ($dirins && $action == 'initobject' && $module && $objectname) { if (is_numeric($object) && $object <= 0) { $pathoffiletoeditsrc = $destdir.'/class/'.strtolower($objectname).'.class.php'; setEventMessages($langs->trans('ErrorFailToCreateFile', $pathoffiletoeditsrc), null, 'errors'); - $error++; + $warning++; } // check if documentation was generate and add table of properties object $file = $destdir.'/class/'.strtolower($objectname).'.class.php'; @@ -1610,7 +1612,7 @@ if ($dirins && $action == 'initobject' && $module && $objectname) { // check if module is enabled if (isModEnabled(strtolower($module))) { $result = unActivateModule(strtolower($module)); - dolibarr_set_const($db, "MAIN_IHM_PARAMS_REV", (int) $conf->global->MAIN_IHM_PARAMS_REV + 1, 'chaine', 0, '', $conf->entity); + dolibarr_set_const($db, "MAIN_IHM_PARAMS_REV", getDolGlobalInt('MAIN_IHM_PARAMS_REV') + 1, 'chaine', 0, '', $conf->entity); if ($result) { setEventMessages($result, null, 'errors'); } @@ -1898,11 +1900,12 @@ if ($dirins && $action == 'confirm_deletemodule') { } else { $error++; $langs->load("errors"); - dol_print_error($db, $langs->trans("ErrorFailedToLoadModuleDescriptorForXXX", $module)); - exit; + setEventMessages($langs->trans("ErrorFailedToLoadModuleDescriptorForXXX", $module), null, 'warnings'); } - $moduleobj->remove(); + if ($moduleobj) { + $moduleobj->remove(); + } $result = dol_delete_dir_recursive($dir); diff --git a/htdocs/modulebuilder/template/core/modules/modMyModule.class.php b/htdocs/modulebuilder/template/core/modules/modMyModule.class.php index 0b166dd54b1..53c7957cf78 100644 --- a/htdocs/modulebuilder/template/core/modules/modMyModule.class.php +++ b/htdocs/modulebuilder/template/core/modules/modMyModule.class.php @@ -28,6 +28,7 @@ */ include_once DOL_DOCUMENT_ROOT.'/core/modules/DolibarrModules.class.php'; + /** * Description and activation class for module MyModule */ @@ -303,8 +304,10 @@ class modMyModule extends DolibarrModules // Main menu entries to add $this->menu = array(); $r = 0; + // Add here entries to declare new menus - /* BEGIN MODULEBUILDER TOPMENU */ + + /* BEGIN MODULEBUILDER TOPMENU MYOBJECT */ $this->menu[$r++] = array( 'fk_menu'=>'', // '' if this is a top menu. For left menu, use 'fk_mainmenu=xxx' or 'fk_mainmenu=xxx,fk_leftmenu=yyy' where xxx is mainmenucode and yyy is a leftmenucode 'type'=>'top', // This is a Top menu entry @@ -320,7 +323,8 @@ class modMyModule extends DolibarrModules 'target'=>'', 'user'=>2, // 0=Menu for internal users, 1=external users, 2=both ); - /* END MODULEBUILDER TOPMENU */ + /* END MODULEBUILDER TOPMENU MYOBJECT */ + /* BEGIN MODULEBUILDER LEFTMENU MYOBJECT */ /*$this->menu[$r++]=array( 'fk_menu'=>'fk_mainmenu=mymodule', // '' if this is a top menu. For left menu, use 'fk_mainmenu=xxx' or 'fk_mainmenu=xxx,fk_leftmenu=yyy' where xxx is mainmenucode and yyy is a leftmenucode @@ -366,6 +370,8 @@ class modMyModule extends DolibarrModules 'user'=>2, // 0=Menu for internal users, 1=external users, 2=both );*/ /* END MODULEBUILDER LEFTMENU MYOBJECT */ + + // Exports profiles provided by this module $r = 1; /* BEGIN MODULEBUILDER EXPORT MYOBJECT */ From a0b26ae7cd293306e8908ff166e41bfc2cbe07e4 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Wed, 13 Mar 2024 21:41:55 +0100 Subject: [PATCH 6/9] FIX Amount of localtaxes in foreign currency was wrong on screen and PDF --- htdocs/comm/propal/card.php | 8 ++++++-- htdocs/comm/propal/class/propal.class.php | 2 ++ htdocs/commande/card.php | 8 ++++++-- htdocs/commande/class/commande.class.php | 2 ++ htdocs/compta/facture/card.php | 8 ++++++-- htdocs/compta/facture/class/facture.class.php | 2 ++ .../commande/doc/pdf_einstein.modules.php | 17 +++++++++++++---- .../commande/doc/pdf_eratosthene.modules.php | 17 +++++++++++++---- .../modules/facture/doc/pdf_crabe.modules.php | 19 +++++++++++++------ .../facture/doc/pdf_sponge.modules.php | 19 +++++++++++++------ .../modules/propale/doc/pdf_azur.modules.php | 19 +++++++++++++------ .../modules/propale/doc/pdf_cyan.modules.php | 19 +++++++++++++------ 12 files changed, 102 insertions(+), 38 deletions(-) diff --git a/htdocs/comm/propal/card.php b/htdocs/comm/propal/card.php index 3e201e1f683..97ed893601d 100644 --- a/htdocs/comm/propal/card.php +++ b/htdocs/comm/propal/card.php @@ -2857,7 +2857,9 @@ if ($action == 'create') { print '' . $langs->transcountry("AmountLT1", $mysoc->country_code) . ''; print '' . price($object->total_localtax1, '', $langs, 0, -1, -1, $conf->currency) . ''; if (isModEnabled("multicurrency") && ($object->multicurrency_code && $object->multicurrency_code != $conf->currency)) { - print '' . price($object->total_localtax1, '', $langs, 0, -1, -1, $object->multicurrency_code) . ''; + $object->multicurrency_total_localtax1 = price2num($object->total_localtax1 * $object->multicurrency_tx, 'MT'); + + print '' . price($object->multicurrency_total_localtax1, '', $langs, 0, -1, -1, $object->multicurrency_code) . ''; } print ''; @@ -2866,7 +2868,9 @@ if ($action == 'create') { print '' . $langs->transcountry("AmountLT2", $mysoc->country_code) . ''; print '' . price($object->total_localtax2, '', $langs, 0, -1, -1, $conf->currency) . ''; if (isModEnabled("multicurrency") && ($object->multicurrency_code && $object->multicurrency_code != $conf->currency)) { - print '' . price($object->total_localtax2, '', $langs, 0, -1, -1, $object->multicurrency_code) . ''; + $object->multicurrency_total_localtax2 = price2num($object->total_localtax2 * $object->multicurrency_tx, 'MT'); + + print '' . price($object->multicurrency_total_localtax2, '', $langs, 0, -1, -1, $object->multicurrency_code) . ''; } print ''; } diff --git a/htdocs/comm/propal/class/propal.class.php b/htdocs/comm/propal/class/propal.class.php index ec2fa41b991..48efe44c41c 100644 --- a/htdocs/comm/propal/class/propal.class.php +++ b/htdocs/comm/propal/class/propal.class.php @@ -272,6 +272,8 @@ class Propal extends CommonObject public $multicurrency_total_ht; public $multicurrency_total_tva; public $multicurrency_total_ttc; + public $multicurrency_total_localtax1; // not in database + public $multicurrency_total_localtax2; // not in database /** diff --git a/htdocs/commande/card.php b/htdocs/commande/card.php index 71aefc2e708..bf55cdd65e2 100644 --- a/htdocs/commande/card.php +++ b/htdocs/commande/card.php @@ -2770,7 +2770,9 @@ if ($action == 'create' && $usercancreate) { print '' . $langs->transcountry("AmountLT1", $mysoc->country_code) . ''; print '' . price($object->total_localtax1, '', $langs, 0, -1, -1, $conf->currency) . ''; if (isModEnabled("multicurrency") && ($object->multicurrency_code && $object->multicurrency_code != $conf->currency)) { - print '' . price($object->total_localtax1, '', $langs, 0, -1, -1, $object->multicurrency_code) . ''; + $object->multicurrency_total_localtax1 = price2num($object->total_localtax1 * $object->multicurrency_tx, 'MT'); + + print '' . price($object->multicurrency_total_localtax1, '', $langs, 0, -1, -1, $object->multicurrency_code) . ''; } print ''; @@ -2780,7 +2782,9 @@ if ($action == 'create' && $usercancreate) { print '' . $langs->transcountry("AmountLT2", $mysoc->country_code) . ''; print '' . price($object->total_localtax2, '', $langs, 0, -1, -1, $conf->currency) . ''; if (isModEnabled("multicurrency") && ($object->multicurrency_code && $object->multicurrency_code != $conf->currency)) { - print '' . price($object->total_localtax2, '', $langs, 0, -1, -1, $object->multicurrency_code) . ''; + $object->multicurrency_total_localtax2 = price2num($object->total_localtax2 * $object->multicurrency_tx, 'MT'); + + print '' . price($object->multicurrency_total_localtax2, '', $langs, 0, -1, -1, $object->multicurrency_code) . ''; } print ''; } diff --git a/htdocs/commande/class/commande.class.php b/htdocs/commande/class/commande.class.php index 6b6037d62d5..3ab9910376c 100644 --- a/htdocs/commande/class/commande.class.php +++ b/htdocs/commande/class/commande.class.php @@ -275,6 +275,8 @@ class Commande extends CommonOrder public $multicurrency_total_ht; public $multicurrency_total_tva; public $multicurrency_total_ttc; + public $multicurrency_total_localtax1; // not in database + public $multicurrency_total_localtax2; // not in database //! key of module source when order generated from a dedicated module ('cashdesk', 'takepos', ...) public $module_source; diff --git a/htdocs/compta/facture/card.php b/htdocs/compta/facture/card.php index 43b1087d89c..4310d340844 100644 --- a/htdocs/compta/facture/card.php +++ b/htdocs/compta/facture/card.php @@ -4904,7 +4904,9 @@ if ($action == 'create') { print '' . $langs->transcountry("AmountLT1", $mysoc->country_code) . ''; print '' . price($sign * $object->total_localtax1, '', $langs, 0, -1, -1, $conf->currency) . ''; if (isModEnabled("multicurrency") && ($object->multicurrency_code && $object->multicurrency_code != $conf->currency)) { - print '' . price($sign * $object->total_localtax1, '', $langs, 0, -1, -1, $object->multicurrency_code) . ''; + $object->multicurrency_total_localtax1 = price2num($object->total_localtax1 * $object->multicurrency_tx, 'MT'); + + print '' . price($sign * $object->multicurrency_total_localtax1, '', $langs, 0, -1, -1, $object->multicurrency_code) . ''; } print ''; @@ -4913,7 +4915,9 @@ if ($action == 'create') { print '' . $langs->transcountry("AmountLT2", $mysoc->country_code) . ''; print '' . price($sign * $object->total_localtax2, '', $langs, 0, -1, -1, $conf->currency) . ''; if (isModEnabled("multicurrency") && ($object->multicurrency_code && $object->multicurrency_code != $conf->currency)) { - print '' . price($sign * $object->total_localtax2, '', $langs, 0, -1, -1, $object->multicurrency_code) . ''; + $object->multicurrency_total_localtax2 = price2num($object->total_localtax2 * $object->multicurrency_tx, 'MT'); + + print '' . price($sign * $object->multicurrency_total_localtax2, '', $langs, 0, -1, -1, $object->multicurrency_code) . ''; } print ''; } diff --git a/htdocs/compta/facture/class/facture.class.php b/htdocs/compta/facture/class/facture.class.php index cf84bbd1b44..405d14e39ed 100644 --- a/htdocs/compta/facture/class/facture.class.php +++ b/htdocs/compta/facture/class/facture.class.php @@ -262,6 +262,8 @@ class Facture extends CommonInvoice public $multicurrency_total_ht; public $multicurrency_total_tva; public $multicurrency_total_ttc; + public $multicurrency_total_localtax1; // not in database + public $multicurrency_total_localtax2; // not in database /** * @var int Situation cycle reference number diff --git a/htdocs/core/modules/commande/doc/pdf_einstein.modules.php b/htdocs/core/modules/commande/doc/pdf_einstein.modules.php index 3f1a62c1b2b..b9d4661b679 100644 --- a/htdocs/core/modules/commande/doc/pdf_einstein.modules.php +++ b/htdocs/core/modules/commande/doc/pdf_einstein.modules.php @@ -988,8 +988,10 @@ class pdf_einstein extends ModelePDFCommandes $totalvat .= vatrate(abs($tvakey), 1).$tvacompl; $pdf->MultiCell($col2x - $col1x, $tab2_hl, $totalvat, 0, 'L', 1); + $total_localtax = ((isModEnabled("multicurrency") && isset($object->multicurrency_tx) && $object->multicurrency_tx != 1) ? price2num($tvaval * $object->multicurrency_tx, 'MT') : $tvaval); + $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index); - $pdf->MultiCell($largcol2, $tab2_hl, price($tvaval, 0, $outputlangs), 0, 'R', 1); + $pdf->MultiCell($largcol2, $tab2_hl, price($total_localtax, 0, $outputlangs), 0, 'R', 1); } } } @@ -1018,8 +1020,10 @@ class pdf_einstein extends ModelePDFCommandes $totalvat .= vatrate(abs($tvakey), 1).$tvacompl; $pdf->MultiCell($col2x - $col1x, $tab2_hl, $totalvat, 0, 'L', 1); + $total_localtax = ((isModEnabled("multicurrency") && isset($object->multicurrency_tx) && $object->multicurrency_tx != 1) ? price2num($tvaval * $object->multicurrency_tx, 'MT') : $tvaval); + $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index); - $pdf->MultiCell($largcol2, $tab2_hl, price($tvaval, 0, $outputlangs), 0, 'R', 1); + $pdf->MultiCell($largcol2, $tab2_hl, price($total_localtax, 0, $outputlangs), 0, 'R', 1); } } } @@ -1079,8 +1083,11 @@ class pdf_einstein extends ModelePDFCommandes $totalvat .= vatrate(abs($tvakey), 1).$tvacompl; $pdf->MultiCell($col2x - $col1x, $tab2_hl, $totalvat, 0, 'L', 1); + + $total_localtax = ((isModEnabled("multicurrency") && isset($object->multicurrency_tx) && $object->multicurrency_tx != 1) ? price2num($tvaval * $object->multicurrency_tx, 'MT') : $tvaval); + $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index); - $pdf->MultiCell($largcol2, $tab2_hl, price($tvaval, 0, $outputlangs), 0, 'R', 1); + $pdf->MultiCell($largcol2, $tab2_hl, price($total_localtax, 0, $outputlangs), 0, 'R', 1); } } } @@ -1112,8 +1119,10 @@ class pdf_einstein extends ModelePDFCommandes $totalvat .= vatrate(abs($tvakey), 1).$tvacompl; $pdf->MultiCell($col2x - $col1x, $tab2_hl, $totalvat, 0, 'L', 1); + $total_localtax = ((isModEnabled("multicurrency") && isset($object->multicurrency_tx) && $object->multicurrency_tx != 1) ? price2num($tvaval * $object->multicurrency_tx, 'MT') : $tvaval); + $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index); - $pdf->MultiCell($largcol2, $tab2_hl, price($tvaval, 0, $outputlangs), 0, 'R', 1); + $pdf->MultiCell($largcol2, $tab2_hl, price($total_localtax, 0, $outputlangs), 0, 'R', 1); } } } diff --git a/htdocs/core/modules/commande/doc/pdf_eratosthene.modules.php b/htdocs/core/modules/commande/doc/pdf_eratosthene.modules.php index f6f9cf79bfa..449d29f62a8 100644 --- a/htdocs/core/modules/commande/doc/pdf_eratosthene.modules.php +++ b/htdocs/core/modules/commande/doc/pdf_eratosthene.modules.php @@ -1194,8 +1194,10 @@ class pdf_eratosthene extends ModelePDFCommandes $totalvat .= vatrate(abs($tvakey), 1).$tvacompl; $pdf->MultiCell($col2x - $col1x, $tab2_hl, $totalvat, 0, 'L', 1); + $total_localtax = ((isModEnabled("multicurrency") && isset($object->multicurrency_tx) && $object->multicurrency_tx != 1) ? price2num($tvaval * $object->multicurrency_tx, 'MT') : $tvaval); + $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index); - $pdf->MultiCell($largcol2, $tab2_hl, price($tvaval, 0, $outputlangs), 0, 'R', 1); + $pdf->MultiCell($largcol2, $tab2_hl, price($total_localtax, 0, $outputlangs), 0, 'R', 1); } } } @@ -1224,8 +1226,10 @@ class pdf_eratosthene extends ModelePDFCommandes $totalvat .= vatrate(abs($tvakey), 1).$tvacompl; $pdf->MultiCell($col2x - $col1x, $tab2_hl, $totalvat, 0, 'L', 1); + $total_localtax = ((isModEnabled("multicurrency") && isset($object->multicurrency_tx) && $object->multicurrency_tx != 1) ? price2num($tvaval * $object->multicurrency_tx, 'MT') : $tvaval); + $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index); - $pdf->MultiCell($largcol2, $tab2_hl, price($tvaval, 0, $outputlangs), 0, 'R', 1); + $pdf->MultiCell($largcol2, $tab2_hl, price($total_localtax, 0, $outputlangs), 0, 'R', 1); } } } @@ -1285,8 +1289,11 @@ class pdf_eratosthene extends ModelePDFCommandes $totalvat .= vatrate(abs($tvakey), 1).$tvacompl; $pdf->MultiCell($col2x - $col1x, $tab2_hl, $totalvat, 0, 'L', 1); + + $total_localtax = ((isModEnabled("multicurrency") && isset($object->multicurrency_tx) && $object->multicurrency_tx != 1) ? price2num($tvaval * $object->multicurrency_tx, 'MT') : $tvaval); + $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index); - $pdf->MultiCell($largcol2, $tab2_hl, price($tvaval, 0, $outputlangs), 0, 'R', 1); + $pdf->MultiCell($largcol2, $tab2_hl, price($total_localtax, 0, $outputlangs), 0, 'R', 1); } } } @@ -1318,8 +1325,10 @@ class pdf_eratosthene extends ModelePDFCommandes $totalvat .= vatrate(abs($tvakey), 1).$tvacompl; $pdf->MultiCell($col2x - $col1x, $tab2_hl, $totalvat, 0, 'L', 1); + $total_localtax = ((isModEnabled("multicurrency") && isset($object->multicurrency_tx) && $object->multicurrency_tx != 1) ? price2num($tvaval * $object->multicurrency_tx, 'MT') : $tvaval); + $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index); - $pdf->MultiCell($largcol2, $tab2_hl, price($tvaval, 0, $outputlangs), 0, 'R', 1); + $pdf->MultiCell($largcol2, $tab2_hl, price($total_localtax, 0, $outputlangs), 0, 'R', 1); } } } diff --git a/htdocs/core/modules/facture/doc/pdf_crabe.modules.php b/htdocs/core/modules/facture/doc/pdf_crabe.modules.php index a0b26a8b17c..9a8e48e6f83 100644 --- a/htdocs/core/modules/facture/doc/pdf_crabe.modules.php +++ b/htdocs/core/modules/facture/doc/pdf_crabe.modules.php @@ -1426,8 +1426,6 @@ class pdf_crabe extends ModelePDFFactures if (!empty($conf->global->MAIN_GENERATE_DOCUMENTS_WITHOUT_VAT_IFNULL) && $tvaisnull) { // Nothing to do } else { - // FIXME amount of vat not supported with multicurrency - //Local tax 1 before VAT //if (!empty($conf->global->FACTURE_LOCAL_TAX1_OPTION) && $conf->global->FACTURE_LOCAL_TAX1_OPTION=='localtax1on') //{ @@ -1454,8 +1452,10 @@ class pdf_crabe extends ModelePDFFactures $totalvat .= vatrate(abs($tvakey), 1).$tvacompl; $pdf->MultiCell($col2x - $col1x, $tab2_hl, $totalvat, 0, 'L', 1); + $total_localtax = ((isModEnabled("multicurrency") && isset($object->multicurrency_tx) && $object->multicurrency_tx != 1) ? price2num($tvaval * $object->multicurrency_tx, 'MT') : $tvaval); + $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index); - $pdf->MultiCell($largcol2, $tab2_hl, price($tvaval, 0, $outputlangs), 0, 'R', 1); + $pdf->MultiCell($largcol2, $tab2_hl, price($total_localtax, 0, $outputlangs), 0, 'R', 1); } } } @@ -1485,8 +1485,10 @@ class pdf_crabe extends ModelePDFFactures $totalvat .= vatrate(abs($tvakey), 1).$tvacompl; $pdf->MultiCell($col2x - $col1x, $tab2_hl, $totalvat, 0, 'L', 1); + $total_localtax = ((isModEnabled("multicurrency") && isset($object->multicurrency_tx) && $object->multicurrency_tx != 1) ? price2num($tvaval * $object->multicurrency_tx, 'MT') : $tvaval); + $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index); - $pdf->MultiCell($largcol2, $tab2_hl, price($tvaval, 0, $outputlangs), 0, 'R', 1); + $pdf->MultiCell($largcol2, $tab2_hl, price($total_localtax, 0, $outputlangs), 0, 'R', 1); } } } @@ -1546,8 +1548,11 @@ class pdf_crabe extends ModelePDFFactures $totalvat .= vatrate(abs($tvakey), 1).$tvacompl; $pdf->MultiCell($col2x - $col1x, $tab2_hl, $totalvat, 0, 'L', 1); + + $total_localtax = ((isModEnabled("multicurrency") && isset($object->multicurrency_tx) && $object->multicurrency_tx != 1) ? price2num($tvaval * $object->multicurrency_tx, 'MT') : $tvaval); + $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index); - $pdf->MultiCell($largcol2, $tab2_hl, price($tvaval, 0, $outputlangs), 0, 'R', 1); + $pdf->MultiCell($largcol2, $tab2_hl, price($total_localtax, 0, $outputlangs), 0, 'R', 1); } } } @@ -1576,8 +1581,10 @@ class pdf_crabe extends ModelePDFFactures $totalvat .= vatrate(abs($tvakey), 1).$tvacompl; $pdf->MultiCell($col2x - $col1x, $tab2_hl, $totalvat, 0, 'L', 1); + $total_localtax = ((isModEnabled("multicurrency") && isset($object->multicurrency_tx) && $object->multicurrency_tx != 1) ? price2num($tvaval * $object->multicurrency_tx, 'MT') : $tvaval); + $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index); - $pdf->MultiCell($largcol2, $tab2_hl, price($tvaval, 0, $outputlangs), 0, 'R', 1); + $pdf->MultiCell($largcol2, $tab2_hl, price($total_localtax, 0, $outputlangs), 0, 'R', 1); } } //} diff --git a/htdocs/core/modules/facture/doc/pdf_sponge.modules.php b/htdocs/core/modules/facture/doc/pdf_sponge.modules.php index 57596f3edca..1b583bab5f4 100644 --- a/htdocs/core/modules/facture/doc/pdf_sponge.modules.php +++ b/htdocs/core/modules/facture/doc/pdf_sponge.modules.php @@ -1689,8 +1689,6 @@ class pdf_sponge extends ModelePDFFactures if (!empty($conf->global->MAIN_GENERATE_DOCUMENTS_WITHOUT_VAT_IFNULL) && $tvaisnull) { // Nothing to do } else { - // FIXME amount of vat not supported with multicurrency - //Local tax 1 before VAT //if (!empty($conf->global->FACTURE_LOCAL_TAX1_OPTION) && $conf->global->FACTURE_LOCAL_TAX1_OPTION=='localtax1on') //{ @@ -1717,8 +1715,10 @@ class pdf_sponge extends ModelePDFFactures $totalvat .= vatrate(abs($tvakey), 1).$tvacompl; $pdf->MultiCell($col2x - $col1x, $tab2_hl, $totalvat, 0, 'L', 1); + $total_localtax = ((isModEnabled("multicurrency") && isset($object->multicurrency_tx) && $object->multicurrency_tx != 1) ? price2num($tvaval * $object->multicurrency_tx, 'MT') : $tvaval); + $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index); - $pdf->MultiCell($largcol2, $tab2_hl, price($tvaval, 0, $outputlangs), 0, 'R', 1); + $pdf->MultiCell($largcol2, $tab2_hl, price($total_localtax, 0, $outputlangs), 0, 'R', 1); } } } @@ -1748,8 +1748,10 @@ class pdf_sponge extends ModelePDFFactures $totalvat .= vatrate(abs($tvakey), 1).$tvacompl; $pdf->MultiCell($col2x - $col1x, $tab2_hl, $totalvat, 0, 'L', 1); + $total_localtax = ((isModEnabled("multicurrency") && isset($object->multicurrency_tx) && $object->multicurrency_tx != 1) ? price2num($tvaval * $object->multicurrency_tx, 'MT') : $tvaval); + $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index); - $pdf->MultiCell($largcol2, $tab2_hl, price($tvaval, 0, $outputlangs), 0, 'R', 1); + $pdf->MultiCell($largcol2, $tab2_hl, price($total_localtax, 0, $outputlangs), 0, 'R', 1); } } } @@ -1833,8 +1835,11 @@ class pdf_sponge extends ModelePDFFactures $totalvat .= vatrate(abs($tvakey), 1).$tvacompl; $pdf->MultiCell($col2x - $col1x, $tab2_hl, $totalvat, 0, 'L', 1); + + $total_localtax = ((isModEnabled("multicurrency") && isset($object->multicurrency_tx) && $object->multicurrency_tx != 1) ? price2num($tvaval * $object->multicurrency_tx, 'MT') : $tvaval); + $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index); - $pdf->MultiCell($largcol2, $tab2_hl, price($tvaval, 0, $outputlangs), 0, 'R', 1); + $pdf->MultiCell($largcol2, $tab2_hl, price($total_localtax, 0, $outputlangs), 0, 'R', 1); } } } @@ -1866,8 +1871,10 @@ class pdf_sponge extends ModelePDFFactures $totalvat .= vatrate(abs($tvakey), 1).$tvacompl; $pdf->MultiCell($col2x - $col1x, $tab2_hl, $totalvat, 0, 'L', 1); + $total_localtax = ((isModEnabled("multicurrency") && isset($object->multicurrency_tx) && $object->multicurrency_tx != 1) ? price2num($tvaval * $object->multicurrency_tx, 'MT') : $tvaval); + $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index); - $pdf->MultiCell($largcol2, $tab2_hl, price($tvaval, 0, $outputlangs), 0, 'R', 1); + $pdf->MultiCell($largcol2, $tab2_hl, price($total_localtax, 0, $outputlangs), 0, 'R', 1); } } } diff --git a/htdocs/core/modules/propale/doc/pdf_azur.modules.php b/htdocs/core/modules/propale/doc/pdf_azur.modules.php index 85576e467ec..50a5af68ad4 100644 --- a/htdocs/core/modules/propale/doc/pdf_azur.modules.php +++ b/htdocs/core/modules/propale/doc/pdf_azur.modules.php @@ -1168,8 +1168,10 @@ class pdf_azur extends ModelePDFPropales $totalvat .= vatrate(abs($tvakey), 1).$tvacompl; $pdf->MultiCell($col2x - $col1x, $tab2_hl, $totalvat, 0, 'L', 1); + $total_localtax = ((isModEnabled("multicurrency") && isset($object->multicurrency_tx) && $object->multicurrency_tx != 1) ? price2num($tvaval * $object->multicurrency_tx, 'MT') : $tvaval); + $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index); - $pdf->MultiCell($largcol2, $tab2_hl, price($tvaval, 0, $outputlangs), 0, 'R', 1); + $pdf->MultiCell($largcol2, $tab2_hl, price($total_localtax, 0, $outputlangs), 0, 'R', 1); } } } @@ -1186,8 +1188,6 @@ class pdf_azur extends ModelePDFPropales if ($tvakey != 0) { // On affiche pas taux 0 //$this->atleastoneratenotnull++; - - $index++; $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index); @@ -1200,8 +1200,10 @@ class pdf_azur extends ModelePDFPropales $totalvat .= vatrate(abs($tvakey), 1).$tvacompl; $pdf->MultiCell($col2x - $col1x, $tab2_hl, $totalvat, 0, 'L', 1); + $total_localtax = ((isModEnabled("multicurrency") && isset($object->multicurrency_tx) && $object->multicurrency_tx != 1) ? price2num($tvaval * $object->multicurrency_tx, 'MT') : $tvaval); + $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index); - $pdf->MultiCell($largcol2, $tab2_hl, price($tvaval, 0, $outputlangs), 0, 'R', 1); + $pdf->MultiCell($largcol2, $tab2_hl, price($total_localtax, 0, $outputlangs), 0, 'R', 1); } } } @@ -1260,8 +1262,11 @@ class pdf_azur extends ModelePDFPropales $totalvat .= vatrate(abs($tvakey), 1).$tvacompl; $pdf->MultiCell($col2x - $col1x, $tab2_hl, $totalvat, 0, 'L', 1); + + $total_localtax = ((isModEnabled("multicurrency") && isset($object->multicurrency_tx) && $object->multicurrency_tx != 1) ? price2num($tvaval * $object->multicurrency_tx, 'MT') : $tvaval); + $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index); - $pdf->MultiCell($largcol2, $tab2_hl, price($tvaval, 0, $outputlangs), 0, 'R', 1); + $pdf->MultiCell($largcol2, $tab2_hl, price($total_localtax, 0, $outputlangs), 0, 'R', 1); } } } @@ -1292,8 +1297,10 @@ class pdf_azur extends ModelePDFPropales $totalvat .= vatrate(abs($tvakey), 1).$tvacompl; $pdf->MultiCell($col2x - $col1x, $tab2_hl, $totalvat, 0, 'L', 1); + $total_localtax = ((isModEnabled("multicurrency") && isset($object->multicurrency_tx) && $object->multicurrency_tx != 1) ? price2num($tvaval * $object->multicurrency_tx, 'MT') : $tvaval); + $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index); - $pdf->MultiCell($largcol2, $tab2_hl, price($tvaval, 0, $outputlangs), 0, 'R', 1); + $pdf->MultiCell($largcol2, $tab2_hl, price($total_localtax, 0, $outputlangs), 0, 'R', 1); } } } diff --git a/htdocs/core/modules/propale/doc/pdf_cyan.modules.php b/htdocs/core/modules/propale/doc/pdf_cyan.modules.php index 153a0460d84..67e49fca891 100644 --- a/htdocs/core/modules/propale/doc/pdf_cyan.modules.php +++ b/htdocs/core/modules/propale/doc/pdf_cyan.modules.php @@ -1289,8 +1289,10 @@ class pdf_cyan extends ModelePDFPropales $totalvat .= vatrate(abs($tvakey), 1).$tvacompl; $pdf->MultiCell($col2x - $col1x, $tab2_hl, $totalvat, 0, 'L', 1); + $total_localtax = ((isModEnabled("multicurrency") && isset($object->multicurrency_tx) && $object->multicurrency_tx != 1) ? price2num($tvaval * $object->multicurrency_tx, 'MT') : $tvaval); + $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index); - $pdf->MultiCell($largcol2, $tab2_hl, price($tvaval, 0, $outputlangs), 0, 'R', 1); + $pdf->MultiCell($largcol2, $tab2_hl, price($total_localtax, 0, $outputlangs), 0, 'R', 1); } } } @@ -1307,8 +1309,6 @@ class pdf_cyan extends ModelePDFPropales if ($tvakey != 0) { // On affiche pas taux 0 //$this->atleastoneratenotnull++; - - $index++; $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index); @@ -1322,8 +1322,10 @@ class pdf_cyan extends ModelePDFPropales $totalvat .= vatrate(abs($tvakey), 1).$tvacompl; $pdf->MultiCell($col2x - $col1x, $tab2_hl, $totalvat, 0, 'L', 1); + $total_localtax = ((isModEnabled("multicurrency") && isset($object->multicurrency_tx) && $object->multicurrency_tx != 1) ? price2num($tvaval * $object->multicurrency_tx, 'MT') : $tvaval); + $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index); - $pdf->MultiCell($largcol2, $tab2_hl, price($tvaval, 0, $outputlangs), 0, 'R', 1); + $pdf->MultiCell($largcol2, $tab2_hl, price($total_localtax, 0, $outputlangs), 0, 'R', 1); } } } @@ -1377,8 +1379,11 @@ class pdf_cyan extends ModelePDFPropales $totalvat .= vatrate(abs($tvakey), 1).$tvacompl; $pdf->MultiCell($col2x - $col1x, $tab2_hl, $totalvat, 0, 'L', 1); + + $total_localtax = ((isModEnabled("multicurrency") && isset($object->multicurrency_tx) && $object->multicurrency_tx != 1) ? price2num($tvaval * $object->multicurrency_tx, 'MT') : $tvaval); + $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index); - $pdf->MultiCell($largcol2, $tab2_hl, price($tvaval, 0, $outputlangs), 0, 'R', 1); + $pdf->MultiCell($largcol2, $tab2_hl, price($total_localtax, 0, $outputlangs), 0, 'R', 1); } } } @@ -1410,8 +1415,10 @@ class pdf_cyan extends ModelePDFPropales $totalvat .= vatrate(abs($tvakey), 1).$tvacompl; $pdf->MultiCell($col2x - $col1x, $tab2_hl, $totalvat, 0, 'L', 1); + $total_localtax = ((isModEnabled("multicurrency") && isset($object->multicurrency_tx) && $object->multicurrency_tx != 1) ? price2num($tvaval * $object->multicurrency_tx, 'MT') : $tvaval); + $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index); - $pdf->MultiCell($largcol2, $tab2_hl, price($tvaval, 0, $outputlangs), 0, 'R', 1); + $pdf->MultiCell($largcol2, $tab2_hl, price($total_localtax, 0, $outputlangs), 0, 'R', 1); } } } From 9c876b28419c1c2cfcb398693022ed799caf9ab6 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Wed, 13 Mar 2024 22:22:32 +0100 Subject: [PATCH 7/9] Fix phpunit --- htdocs/ai/admin/custom_prompt.php | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-) diff --git a/htdocs/ai/admin/custom_prompt.php b/htdocs/ai/admin/custom_prompt.php index 699479bbb9e..7790c822249 100644 --- a/htdocs/ai/admin/custom_prompt.php +++ b/htdocs/ai/admin/custom_prompt.php @@ -165,9 +165,6 @@ if ($action == 'confirm_deleteproperty' && GETPOST('confirm') == 'yes') { } } } -if ($action == 'confirm_deleteproperty') { - var_dump(GETPOST('confirm'));exit; -} /* @@ -344,7 +341,7 @@ if ($action == 'edit' || $action == 'create') { $('#postPromptInput').val(''); } }); - + $('.showInputBtn').click(function() { event.preventDefault(); var index = $(this).data('index'); @@ -357,7 +354,7 @@ if ($action == 'edit' || $action == 'create') { $(this).html($(this).data('icon-cancel')); $(this).data('state', 'cancel'); - } else { + } else { $('#prePromptInput_'+index).attr('disabled', 'disabled'); $('#postPromptInput_'+index).attr('disabled', 'disabled'); @@ -367,8 +364,8 @@ if ($action == 'edit' || $action == 'create') { } }); }); - - + + "; print $out; From ee214ae7fd8500afe493720afb4845aa8858b71d Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Wed, 13 Mar 2024 22:39:41 +0100 Subject: [PATCH 8/9] Test to avoid not found method --- htdocs/core/lib/functions.lib.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/core/lib/functions.lib.php b/htdocs/core/lib/functions.lib.php index 2f794579b7b..bcc2e9864e9 100644 --- a/htdocs/core/lib/functions.lib.php +++ b/htdocs/core/lib/functions.lib.php @@ -8322,7 +8322,7 @@ function getCommonSubstitutionArray($outputlangs, $onlykey = 0, $exclude = null, '__USER_SIGNATURE__' => (string) (($usersignature && !getDolGlobalString('MAIN_MAIL_DO_NOT_USE_SIGN')) ? ($onlykey == 2 ? dol_trunc(dol_string_nohtmltag($usersignature), 30) : $usersignature) : '') )); - if (is_object($user)) { + if (is_object($user) && ($user instanceof User)) { $substitutionarray = array_merge($substitutionarray, array( '__USER_ID__' => (string) $user->id, '__USER_LOGIN__' => (string) $user->login, From 07fe0f6cd0a66dbcdfb8310fd1ab26d474400401 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Thu, 14 Mar 2024 10:29:36 +0100 Subject: [PATCH 9/9] NEW: Module Website: Can link/unlink translation between web pages --- htdocs/website/index.php | 57 +++++++++++++++++++++++++++++++++------- 1 file changed, 48 insertions(+), 9 deletions(-) diff --git a/htdocs/website/index.php b/htdocs/website/index.php index 566a1c2feb9..37430439427 100644 --- a/htdocs/website/index.php +++ b/htdocs/website/index.php @@ -1155,7 +1155,17 @@ if ($action == 'addcontainer' && $usercanedit) { $substitutionarray = array(); $substitutionarray['__WEBSITE_CREATE_BY__'] = $user->getFullName($langs); - // Define id of page the new page is translation of + // Define id of the page the new page is translation of + /* + if ($objectpage->lang == $object->lang) { + // If + $pageidfortranslation = (GETPOSTINT('pageidfortranslation') > 0 ? GETPOSTINT('pageidfortranslation') : 0); + if ($pageidfortranslation > 0) { + // We must update the page $pageidfortranslation to set fk_page = $object->id. + // But what if page $pageidfortranslation is already linked to another ? + } + } else { + */ $pageidfortranslation = (GETPOSTINT('pageidfortranslation') > 0 ? GETPOSTINT('pageidfortranslation') : 0); if ($pageidfortranslation > 0) { // Check if the page we are translation of is already a translation of a source page. if yes, we will use source id instead @@ -1166,6 +1176,7 @@ if ($action == 'addcontainer' && $usercanedit) { } } $objectpage->fk_page = $pageidfortranslation; + //} $sample = GETPOST('sample', 'alpha'); if (empty($sample)) { @@ -2406,6 +2417,22 @@ if ($usercanedit && (($action == 'updatesource' || $action == 'updatecontent' || } } +if ($action == 'deletelang' && $usercanedit) { + $sql = "UPDATE ".MAIN_DB_PREFIX."website_page SET fk_page = NULL"; + $sql .= " WHERE rowid = ".GETPOSTINT('deletelangforid'); + //$sql .= " AND fk_page = ".((int) $objectpage->id); + + $resql = $db->query($sql); + if (!$resql) { + setEventMessages($db->lasterror(), null, 'errors'); + } else { + $objectpage->fk_page = null; + } + + $action = 'editmeta'; +} + + // Export site if ($action == 'exportsite' && $user->hasRight('website', 'export')) { $fileofzip = $object->exportWebSite(); @@ -4360,7 +4387,9 @@ if ($action == 'editmeta' || $action == 'createcontainer') { // Edit properties if ($i > 0) { $tmpstring .= '
'; } - $tmpstring .= $tmppage->getNomUrl(1).' ('.$tmppage->lang.')'; + $tmpstring .= $tmppage->getNomUrl(1).' '.picto_from_langcode($tmppage->lang).' '.$tmppage->lang; + // Button unlink + $tmpstring .= ' id).'">'.img_picto($langs->trans("Remove"), 'unlink').''; $translatedby++; $i++; } @@ -4376,17 +4405,27 @@ if ($action == 'editmeta' || $action == 'createcontainer') { // Edit properties dol_print_error($db); } } - if (empty($translatedby) && ($action == 'editmeta' || $action == 'createcontainer' || $objectpage->fk_page > 0)) { + if ((empty($translatedby) || ($objectpage->lang != $object->lang)) && ($action == 'editmeta' || $action == 'createcontainer' || $objectpage->fk_page > 0)) { $sourcepage = new WebsitePage($db); - $result = $sourcepage->fetch($objectpage->fk_page); - if ($result == 0) { - // not found, we can reset value to clean database - } elseif ($result > 0) { + $result = 1; + if ($objectpage->fk_page > 0) { + $result = $sourcepage->fetch($objectpage->fk_page); + if ($result == 0) { + // not found, we can reset value to clean database + // TODO + } + } + if ($result >= 0) { + if ($translatedby) { + print '
'; + } $translationof = $objectpage->fk_page; print ''.$langs->trans('ThisPageIsTranslationOf').' '; - print $formwebsite->selectContainer($website, 'pageidfortranslation', ($translationof ? $translationof : -1), 1, $action, 'minwidth300', array($objectpage->id)); + print $sourcepage->getNomUrl(2).' '.$formwebsite->selectContainer($website, 'pageidfortranslation', ($translationof ? $translationof : -1), 1, $action, 'minwidth300', array($objectpage->id)); if ($translationof > 0 && $sourcepage->lang) { - print $sourcepage->getNomUrl(2).' ('.$sourcepage->lang.')'; + print picto_from_langcode($sourcepage->lang).' '.$sourcepage->lang; + // Button unlink + print ' id).'">'.img_picto($langs->trans("Remove"), 'unlink').''; } } }