From 170a668b2bdf15f232c60a1d3c3f6a01a1236e32 Mon Sep 17 00:00:00 2001 From: ATM-Nicolas Date: Fri, 13 Jul 2018 11:09:56 +0200 Subject: [PATCH 01/14] FIX : Set contactCivName substitution key --- htdocs/core/tpl/card_presend.tpl.php | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/htdocs/core/tpl/card_presend.tpl.php b/htdocs/core/tpl/card_presend.tpl.php index 43cacab0e1c..b5d342d3e0a 100644 --- a/htdocs/core/tpl/card_presend.tpl.php +++ b/htdocs/core/tpl/card_presend.tpl.php @@ -167,6 +167,27 @@ if ($action == 'presend') ); complete_substitutions_array($substitutionarray, $outputlangs, $object, $parameters); + // Find the good contact adress + $custcontact = ''; + $contactarr = array(); + $contactarr = $object->liste_contact(- 1, 'external'); + + if (is_array($contactarr) && count($contactarr) > 0) { + foreach ($contactarr as $contact) { + if (in_array($contact['code'], array('BILLING'))) { + require_once DOL_DOCUMENT_ROOT . '/contact/class/contact.class.php'; + + $contactstatic = new Contact($db); + $contactstatic->fetch($contact['id']); + $custcontact = $contactstatic->getFullName($langs, 1); + } + } + + if (! empty($custcontact)) { + $substitutionarray['__CONTACTCIVNAME__'] = $custcontact; + } + } + // Tableau des substitutions $formmail->substit = $substitutionarray; From de8fd3d12c75ed44889c5656fd00a4b365de6691 Mon Sep 17 00:00:00 2001 From: ATM-Nicolas Date: Mon, 16 Jul 2018 09:33:14 +0200 Subject: [PATCH 02/14] NEW : Contact substitutions keys --- htdocs/core/tpl/card_presend.tpl.php | 32 ++++++++++++++++++---------- 1 file changed, 21 insertions(+), 11 deletions(-) diff --git a/htdocs/core/tpl/card_presend.tpl.php b/htdocs/core/tpl/card_presend.tpl.php index b5d342d3e0a..63b1cbab28d 100644 --- a/htdocs/core/tpl/card_presend.tpl.php +++ b/htdocs/core/tpl/card_presend.tpl.php @@ -173,18 +173,28 @@ if ($action == 'presend') $contactarr = $object->liste_contact(- 1, 'external'); if (is_array($contactarr) && count($contactarr) > 0) { + require_once DOL_DOCUMENT_ROOT . '/contact/class/contact.class.php'; + $contactstatic = new Contact($db); + foreach ($contactarr as $contact) { - if (in_array($contact['code'], array('BILLING'))) { - require_once DOL_DOCUMENT_ROOT . '/contact/class/contact.class.php'; - - $contactstatic = new Contact($db); - $contactstatic->fetch($contact['id']); - $custcontact = $contactstatic->getFullName($langs, 1); - } - } - - if (! empty($custcontact)) { - $substitutionarray['__CONTACTCIVNAME__'] = $custcontact; + switch($contact['code']) { + case 'BILLING': + $contactstatic->fetch($contact['id']); + $substitutionarray['__CONTACT_NAME_BILLING__'] = $contactstatic->getFullName($langs, 1); + break; + case 'CUSTOMER': + $contactstatic->fetch($contact['id']); + $substitutionarray['__CONTACT_NAME_CUSTOMER__'] = $contactstatic->getFullName($langs, 1); + break; + case 'SHIPPING': + $contactstatic->fetch($contact['id']); + $substitutionarray['__CONTACT_NAME_SHIPPING__'] = $contactstatic->getFullName($langs, 1); + break; + case 'SERVICE': + $contactstatic->fetch($contact['id']); + $substitutionarray['__CONTACT_NAME_SERVICE__'] = $contactstatic->getFullName($langs, 1); + break; + } } } From 3c5998e697f214224da97fb9b2a63d883c4d303c Mon Sep 17 00:00:00 2001 From: ATM-Nicolas Date: Mon, 16 Jul 2018 11:16:55 +0200 Subject: [PATCH 03/14] FIX : Refactoring --- htdocs/core/tpl/card_presend.tpl.php | 20 ++------------------ 1 file changed, 2 insertions(+), 18 deletions(-) diff --git a/htdocs/core/tpl/card_presend.tpl.php b/htdocs/core/tpl/card_presend.tpl.php index 63b1cbab28d..34f46a7ab92 100644 --- a/htdocs/core/tpl/card_presend.tpl.php +++ b/htdocs/core/tpl/card_presend.tpl.php @@ -177,24 +177,8 @@ if ($action == 'presend') $contactstatic = new Contact($db); foreach ($contactarr as $contact) { - switch($contact['code']) { - case 'BILLING': - $contactstatic->fetch($contact['id']); - $substitutionarray['__CONTACT_NAME_BILLING__'] = $contactstatic->getFullName($langs, 1); - break; - case 'CUSTOMER': - $contactstatic->fetch($contact['id']); - $substitutionarray['__CONTACT_NAME_CUSTOMER__'] = $contactstatic->getFullName($langs, 1); - break; - case 'SHIPPING': - $contactstatic->fetch($contact['id']); - $substitutionarray['__CONTACT_NAME_SHIPPING__'] = $contactstatic->getFullName($langs, 1); - break; - case 'SERVICE': - $contactstatic->fetch($contact['id']); - $substitutionarray['__CONTACT_NAME_SERVICE__'] = $contactstatic->getFullName($langs, 1); - break; - } + $contactstatic->fetch($contact['id']); + $substitutionarray['__CONTACT_NAME_'.$contact['code'].'__'] = $contactstatic->getFullName($langs, 1); } } From b306394c15b1871235702254c544d4f17c3097f2 Mon Sep 17 00:00:00 2001 From: Chl Date: Tue, 17 Jul 2018 23:50:06 +0200 Subject: [PATCH 04/14] corr. group by pour PostgreSQL --- htdocs/compta/index.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/compta/index.php b/htdocs/compta/index.php index 59a901ccdf8..ebaef08c7b5 100644 --- a/htdocs/compta/index.php +++ b/htdocs/compta/index.php @@ -838,7 +838,7 @@ if (! empty($conf->facture->enabled) && $user->rights->facture->lire) $reshook=$hookmanager->executeHooks('printFieldListWhereCustomerUnpaid',$parameters); $sql.=$hookmanager->resPrint; - $sql.= " GROUP BY f.facnumber, f.fk_statut, f.datef, f.type, f.total, f.tva, f.total_ttc, f.paye, f.tms, f.date_lim_reglement,"; + $sql.= " GROUP BY f.rowid, f.facnumber, f.fk_statut, f.datef, f.type, f.total, f.tva, f.total_ttc, f.paye, f.tms, f.date_lim_reglement,"; $sql.= " s.nom, s.rowid, s.email, s.code_client, s.code_compta, cc.rowid, cc.code"; $sql.= " ORDER BY f.datef ASC, f.facnumber ASC"; From 0c01f6e1395b4926817a0bb0e70422a1ead5da3f Mon Sep 17 00:00:00 2001 From: John BOTELLA Date: Fri, 20 Jul 2018 15:53:32 +0200 Subject: [PATCH 05/14] Fix situation invoice status --- htdocs/compta/facture/card.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/htdocs/compta/facture/card.php b/htdocs/compta/facture/card.php index d5835f96781..3bf70b9fc38 100644 --- a/htdocs/compta/facture/card.php +++ b/htdocs/compta/facture/card.php @@ -4730,7 +4730,7 @@ else if ($id > 0 || ! empty($ref)) } // For situation invoice with excess received - if ($object->statut == Facture::STATUS_VALIDATED + if ($object->statut > 0 && ($object->total_ttc - $totalpaye - $totalcreditnotes - $totaldeposits) > 0 && $user->rights->facture->creer && !$objectidnext @@ -4748,7 +4748,7 @@ else if ($id > 0 || ! empty($ref)) } // remove situation from cycle - if ($object->statut == Facture::STATUS_VALIDATED + if ($object->statut > 0 && $object->type == Facture::TYPE_SITUATION && $user->rights->facture->creer && !$objectidnext From 984a8e3720884511ada2a9c0b78bc5bd1be5a1eb Mon Sep 17 00:00:00 2001 From: Regis Houssin Date: Fri, 20 Jul 2018 17:28:32 +0200 Subject: [PATCH 06/14] FIX disable/enable foreign key checking for avoid errors --- htdocs/install/repair.php | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/htdocs/install/repair.php b/htdocs/install/repair.php index 896d6964bdd..ad63582c142 100644 --- a/htdocs/install/repair.php +++ b/htdocs/install/repair.php @@ -1081,6 +1081,10 @@ if ($ok && GETPOST('force_utf8_on_tables','alpha')) { $listoftables = $db->DDLListTables($db->database_name); + // Disable foreign key checking for avoid errors + $sql='SET FOREIGN_KEY_CHECKS=0'; + $resql = $db->query($sql); + foreach($listoftables as $table) { print ''; @@ -1095,6 +1099,10 @@ if ($ok && GETPOST('force_utf8_on_tables','alpha')) else print ' - Disabled'; print ''; } + + // Enable foreign key checking + $sql='SET FOREIGN_KEY_CHECKS=1'; + $resql = $db->query($sql); } else { From e9d9954380adff4258ae9fa7551b7880a062e92a Mon Sep 17 00:00:00 2001 From: Regis Houssin Date: Fri, 20 Jul 2018 18:33:14 +0200 Subject: [PATCH 07/14] FIX do not convert llx_const if mysql encrypt/decrypt is used --- htdocs/install/repair.php | 3 +++ 1 file changed, 3 insertions(+) diff --git a/htdocs/install/repair.php b/htdocs/install/repair.php index ad63582c142..269d276d338 100644 --- a/htdocs/install/repair.php +++ b/htdocs/install/repair.php @@ -1087,6 +1087,9 @@ if ($ok && GETPOST('force_utf8_on_tables','alpha')) foreach($listoftables as $table) { + // do not convert llx_const if mysql encrypt/decrypt is used + if ($conf->db->dolibarr_main_db_encryption != 0 && preg_match('/\_const$/', $table)) continue; + print ''; print $table; $sql='ALTER TABLE '.$table.' CONVERT TO CHARACTER SET utf8 COLLATE utf8_unicode_ci'; From 719db2574e98f29b9255b6143175dba44c1ae3ee Mon Sep 17 00:00:00 2001 From: Regis Houssin Date: Fri, 20 Jul 2018 18:39:18 +0200 Subject: [PATCH 08/14] FIX check if "confirmed" mode --- htdocs/install/repair.php | 20 ++++++++++++++------ 1 file changed, 14 insertions(+), 6 deletions(-) diff --git a/htdocs/install/repair.php b/htdocs/install/repair.php index 269d276d338..8e8aa5017ce 100644 --- a/htdocs/install/repair.php +++ b/htdocs/install/repair.php @@ -1079,11 +1079,16 @@ if ($ok && GETPOST('force_utf8_on_tables','alpha')) if ($db->type == "mysql" || $db->type == "mysqli") { - $listoftables = $db->DDLListTables($db->database_name); + $force_utf8_on_tables = GETPOST('force_utf8_on_tables','alpha'); + + $listoftables = $db->DDLListTables($db->database_name); // Disable foreign key checking for avoid errors - $sql='SET FOREIGN_KEY_CHECKS=0'; - $resql = $db->query($sql); + if ($force_utf8_on_tables == 'confirmed') + { + $sql='SET FOREIGN_KEY_CHECKS=0'; + $resql = $db->query($sql); + } foreach($listoftables as $table) { @@ -1094,7 +1099,7 @@ if ($ok && GETPOST('force_utf8_on_tables','alpha')) print $table; $sql='ALTER TABLE '.$table.' CONVERT TO CHARACTER SET utf8 COLLATE utf8_unicode_ci'; print ''; - if (GETPOST('force_utf8_on_tables','alpha') == 'confirmed') + if ($force_utf8_on_tables == 'confirmed') { $resql = $db->query($sql); print ' - Done ('.($resql?'OK':'KO').')'; @@ -1104,8 +1109,11 @@ if ($ok && GETPOST('force_utf8_on_tables','alpha')) } // Enable foreign key checking - $sql='SET FOREIGN_KEY_CHECKS=1'; - $resql = $db->query($sql); + if ($force_utf8_on_tables == 'confirmed') + { + $sql='SET FOREIGN_KEY_CHECKS=1'; + $resql = $db->query($sql); + } } else { From 5cdc9db1f8a29b9466a6f2f5f807d74229ad9c8e Mon Sep 17 00:00:00 2001 From: Regis Houssin Date: Fri, 20 Jul 2018 18:45:52 +0200 Subject: [PATCH 09/14] FIX add html comment --- htdocs/install/repair.php | 2 ++ 1 file changed, 2 insertions(+) diff --git a/htdocs/install/repair.php b/htdocs/install/repair.php index 8e8aa5017ce..1ad1beca350 100644 --- a/htdocs/install/repair.php +++ b/htdocs/install/repair.php @@ -1087,6 +1087,7 @@ if ($ok && GETPOST('force_utf8_on_tables','alpha')) if ($force_utf8_on_tables == 'confirmed') { $sql='SET FOREIGN_KEY_CHECKS=0'; + print ''; $resql = $db->query($sql); } @@ -1112,6 +1113,7 @@ if ($ok && GETPOST('force_utf8_on_tables','alpha')) if ($force_utf8_on_tables == 'confirmed') { $sql='SET FOREIGN_KEY_CHECKS=1'; + print ''; $resql = $db->query($sql); } } From 4995a0feb116c94bd34e0142cf31db9fb24774c5 Mon Sep 17 00:00:00 2001 From: Chl Date: Mon, 23 Jul 2018 18:27:53 +0200 Subject: [PATCH 10/14] Translation: adding 'Enable' term in main compta/facture/fiche-rec.php uses 'Enable' / 'Disable' in a button text but no translation is available for 'Enable'. Another option would be to change 'Enable' to 'Activate' in fiche-rec.php but I guess this word will probably be useful in other places. --- htdocs/langs/en_US/main.lang | 1 + 1 file changed, 1 insertion(+) diff --git a/htdocs/langs/en_US/main.lang b/htdocs/langs/en_US/main.lang index fb4d1d3dc20..92f32a80069 100644 --- a/htdocs/langs/en_US/main.lang +++ b/htdocs/langs/en_US/main.lang @@ -142,6 +142,7 @@ Closed=Closed Closed2=Closed NotClosed=Not closed Enabled=Enabled +Enable=Enable Deprecated=Deprecated Disable=Disable Disabled=Disabled From 0f115dafee2a75cc7000c57265493d15c9038199 Mon Sep 17 00:00:00 2001 From: Chl Date: Tue, 24 Jul 2018 00:30:43 +0200 Subject: [PATCH 11/14] 2 bugfix for PDF generated by Templates/Cron: DueDate and translation When launching Cron on a facturerec with auto_validate at 1, the generated PDF doesn't contain the DueDate, and some tokens like __INVOICE_PREVIOUS_MONTH_TEXT__ in the public notes are not translated (tested with fr_FR). --- htdocs/compta/facture/class/facture-rec.class.php | 3 +++ 1 file changed, 3 insertions(+) diff --git a/htdocs/compta/facture/class/facture-rec.class.php b/htdocs/compta/facture/class/facture-rec.class.php index 71123d1c6e2..a82f06ad851 100644 --- a/htdocs/compta/facture/class/facture-rec.class.php +++ b/htdocs/compta/facture/class/facture-rec.class.php @@ -984,6 +984,7 @@ class FactureRec extends CommonInvoice $error=0; $langs->load("bills"); + $langs->load('main'); $nb_create=0; @@ -1060,6 +1061,8 @@ class FactureRec extends CommonInvoice } if (! $error && $facturerec->generate_pdf) { + // We refresh the object in order to have all necessary data (like date_lim_reglement) + $facture->fetch($facture->id); $result = $facture->generateDocument($facturerec->modelpdf, $langs); if ($result <= 0) { From 25c93de80149135fe995c59b02f283c9cfde2e93 Mon Sep 17 00:00:00 2001 From: Regis Houssin Date: Tue, 24 Jul 2018 11:23:44 +0200 Subject: [PATCH 12/14] FIX missing drop old postgresql unique key --- htdocs/install/mysql/migration/7.0.0-8.0.0.sql | 3 +++ 1 file changed, 3 insertions(+) diff --git a/htdocs/install/mysql/migration/7.0.0-8.0.0.sql b/htdocs/install/mysql/migration/7.0.0-8.0.0.sql index 4da1c8cf408..8710b340622 100644 --- a/htdocs/install/mysql/migration/7.0.0-8.0.0.sql +++ b/htdocs/install/mysql/migration/7.0.0-8.0.0.sql @@ -51,6 +51,9 @@ ALTER TABLE llx_ecm_files ADD UNIQUE INDEX uk_ecm_files (filepath, filename, ent DROP TABLE llx_c_accountancy_category; DROP TABLE llx_c_accountingaccount; +-- drop old postgresql unique key +-- VPGSQL8.2 DROP INDEX llx_usergroup_rights_fk_usergroup_fk_id_key + update llx_propal set fk_statut = 1 where fk_statut = -1; ALTER TABLE llx_inventory ADD COLUMN fk_user_creat integer; From 20a1ffe8102dd169b616913cc4ed082bc8c6766d Mon Sep 17 00:00:00 2001 From: Regis Houssin Date: Tue, 24 Jul 2018 12:15:54 +0200 Subject: [PATCH 13/14] FIX field is autoincrement but not "rowid" --- htdocs/admin/dict.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/admin/dict.php b/htdocs/admin/dict.php index e4f9fa1dd90..32995bce38f 100644 --- a/htdocs/admin/dict.php +++ b/htdocs/admin/dict.php @@ -379,7 +379,7 @@ $tabrowid[9] = "code_iso"; $tabrowid[10]= ""; $tabrowid[11]= "rowid"; $tabrowid[12]= ""; -$tabrowid[13]= ""; +$tabrowid[13]= "id"; $tabrowid[14]= ""; $tabrowid[15]= ""; $tabrowid[16]= "code"; From 869a97c8d1942a8b570db4225e881af6fc2f96e3 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Tue, 24 Jul 2018 17:49:10 +0200 Subject: [PATCH 14/14] Update card.php --- htdocs/compta/facture/card.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/htdocs/compta/facture/card.php b/htdocs/compta/facture/card.php index 3bf70b9fc38..45e94d1e5d3 100644 --- a/htdocs/compta/facture/card.php +++ b/htdocs/compta/facture/card.php @@ -4730,7 +4730,7 @@ else if ($id > 0 || ! empty($ref)) } // For situation invoice with excess received - if ($object->statut > 0 + if ($object->statut > Facture::STATUS_DRAFT && ($object->total_ttc - $totalpaye - $totalcreditnotes - $totaldeposits) > 0 && $user->rights->facture->creer && !$objectidnext @@ -4748,7 +4748,7 @@ else if ($id > 0 || ! empty($ref)) } // remove situation from cycle - if ($object->statut > 0 + if ($object->statut > Facture::STATUS_DRAFT && $object->type == Facture::TYPE_SITUATION && $user->rights->facture->creer && !$objectidnext