From 347537a205696dde2eefebb6964d4bc0b2f11b6a Mon Sep 17 00:00:00 2001 From: Alexandre SPANGARO Date: Mon, 28 Sep 2020 06:44:01 +0200 Subject: [PATCH 01/16] Accountancy - Some fix --- htdocs/accountancy/admin/productaccount.php | 2 +- htdocs/accountancy/customer/list.php | 10 +++++----- htdocs/accountancy/expensereport/list.php | 10 +++++----- htdocs/accountancy/supplier/list.php | 10 +++++----- htdocs/langs/en_US/accountancy.lang | 4 ++-- htdocs/langs/en_US/admin.lang | 2 +- 6 files changed, 19 insertions(+), 19 deletions(-) diff --git a/htdocs/accountancy/admin/productaccount.php b/htdocs/accountancy/admin/productaccount.php index 79bfef57d3a..3e3fb104e70 100644 --- a/htdocs/accountancy/admin/productaccount.php +++ b/htdocs/accountancy/admin/productaccount.php @@ -152,7 +152,7 @@ if ($action == 'update') { } if ($result <= 0) { // setEventMessages(null, $accounting->errors, 'errors'); - $msg .= '
'.$langs->trans("ErrorDB").' : '.$langs->trans("Product").' '.$productid.' '.$langs->trans("NotVentilatedinAccount").' : id='.$accounting_account_id.'
'.$sql.'
'; + $msg .= '
'.$langs->trans("ErrorDB").' : '.$langs->trans("Product").' '.$productid.' '.$langs->trans("NotVentilatedinAccount").' : id='.$accounting_account_id.'
'.$sql.'
'; $ko++; } else { $db->begin(); diff --git a/htdocs/accountancy/customer/list.php b/htdocs/accountancy/customer/list.php index 3c28cdaab84..a06d2f25d8c 100644 --- a/htdocs/accountancy/customer/list.php +++ b/htdocs/accountancy/customer/list.php @@ -142,7 +142,7 @@ if (empty($reshook)) if ($massaction == 'ventil') { $msg = ''; - //print '
' . $langs->trans("Processing") . '...
'; + //print '
' . $langs->trans("Processing") . '...
'; if (!empty($mesCasesCochees)) { $msg = '
'.$langs->trans("SelectedLines").': '.count($mesCasesCochees).'
'; $msg .= '
'; @@ -157,7 +157,7 @@ if ($massaction == 'ventil') { if ($monCompte <= 0) { - $msg .= '
'.$langs->trans("Lineofinvoice").' '.$monId.' - '.$langs->trans("NoAccountSelected").'
'; + $msg .= '
'.$langs->trans("Lineofinvoice", $monId).' - '.$langs->trans("NoAccountSelected").'
'; $ko++; } else { $sql = " UPDATE ".MAIN_DB_PREFIX."facturedet"; @@ -165,14 +165,14 @@ if ($massaction == 'ventil') { $sql .= " WHERE rowid = ".((int) $monId); $accountventilated = new AccountingAccount($db); - $accountventilated->fetch($monCompte, ''); + $accountventilated->fetch($monCompte, '', 1); dol_syslog("accountancy/customer/list.php sql=".$sql, LOG_DEBUG); if ($db->query($sql)) { - $msg .= '
'.$langs->trans("Lineofinvoice").' '.$monId.' - '.$langs->trans("VentilatedinAccount").' : '.length_accountg($accountventilated->account_number).'
'; + $msg .= '
'.$langs->trans("Lineofinvoice", $monId).' - '.$langs->trans("VentilatedinAccount").' : '.length_accountg($accountventilated->account_number).'
'; $ok++; } else { - $msg .= '
'.$langs->trans("ErrorDB").' : '.$langs->trans("Lineofinvoice").' '.$monId.' - '.$langs->trans("NotVentilatedinAccount").' : '.length_accountg($accountventilated->account_number).'
'.$sql.'
'; + $msg .= '
'.$langs->trans("ErrorDB").' : '.$langs->trans("Lineofinvoice", $monId).' - '.$langs->trans("NotVentilatedinAccount").' : '.length_accountg($accountventilated->account_number).'
'.$sql.'
'; $ko++; } } diff --git a/htdocs/accountancy/expensereport/list.php b/htdocs/accountancy/expensereport/list.php index 77b8c6e57b9..c2fb21a911b 100644 --- a/htdocs/accountancy/expensereport/list.php +++ b/htdocs/accountancy/expensereport/list.php @@ -124,7 +124,7 @@ include DOL_DOCUMENT_ROOT.'/core/actions_massactions.inc.php'; if ($massaction == 'ventil') { $msg = ''; - //print '
' . $langs->trans("Processing") . '...
'; + //print '
' . $langs->trans("Processing") . '...
'; if (!empty($mesCasesCochees)) { $msg = '
'.$langs->trans("SelectedLines").': '.count($mesCasesCochees).'
'; $msg .= '
'; @@ -139,7 +139,7 @@ if ($massaction == 'ventil') { if ($monCompte <= 0) { - $msg .= '
'.$langs->trans("Lineofinvoice").' '.$monId.' - '.$langs->trans("NoAccountSelected").'
'; + $msg .= '
'.$langs->trans("Lineofinvoice").' '.$monId.' - '.$langs->trans("NoAccountSelected").'
'; $ko++; } else { $sql = " UPDATE ".MAIN_DB_PREFIX."expensereport_det"; @@ -147,14 +147,14 @@ if ($massaction == 'ventil') { $sql .= " WHERE rowid = ".$monId; $accountventilated = new AccountingAccount($db); - $accountventilated->fetch($monCompte, ''); + $accountventilated->fetch($monCompte, '', 1); dol_syslog('accountancy/expensereport/list.php:: sql='.$sql, LOG_DEBUG); if ($db->query($sql)) { - $msg .= '
'.$langs->trans("LineOfExpenseReport").' '.$monId.' - '.$langs->trans("VentilatedinAccount").' : '.length_accountg($accountventilated->account_number).'
'; + $msg .= '
'.$langs->trans("LineOfExpenseReport").' '.$monId.' - '.$langs->trans("VentilatedinAccount").' : '.length_accountg($accountventilated->account_number).'
'; $ok++; } else { - $msg .= '
'.$langs->trans("ErrorDB").' : '.$langs->trans("Lineofinvoice").' '.$monId.' - '.$langs->trans("NotVentilatedinAccount").' : '.length_accountg($accountventilated->account_number).'
'.$sql.'
'; + $msg .= '
'.$langs->trans("ErrorDB").' : '.$langs->trans("Lineofinvoice").' '.$monId.' - '.$langs->trans("NotVentilatedinAccount").' : '.length_accountg($accountventilated->account_number).'
'.$sql.'
'; $ko++; } } diff --git a/htdocs/accountancy/supplier/list.php b/htdocs/accountancy/supplier/list.php index 9e1668e1a35..96b36fa8fa3 100644 --- a/htdocs/accountancy/supplier/list.php +++ b/htdocs/accountancy/supplier/list.php @@ -146,7 +146,7 @@ if (empty($reshook)) if ($massaction == 'ventil') { $msg = ''; - //print '
' . $langs->trans("Processing") . '...
'; + //print '
' . $langs->trans("Processing") . '...
'; if (!empty($mesCasesCochees)) { $msg = '
'.$langs->trans("SelectedLines").': '.count($mesCasesCochees).'
'; $msg .= '
'; @@ -161,7 +161,7 @@ if ($massaction == 'ventil') { if ($monCompte <= 0) { - $msg .= '
'.$langs->trans("Lineofinvoice").' '.$monId.' - '.$langs->trans("NoAccountSelected").'
'; + $msg .= '
'.$langs->trans("Lineofinvoice").' '.$monId.' - '.$langs->trans("NoAccountSelected").'
'; $ko++; } else { $sql = " UPDATE ".MAIN_DB_PREFIX."facture_fourn_det"; @@ -169,14 +169,14 @@ if ($massaction == 'ventil') { $sql .= " WHERE rowid = ".$monId; $accountventilated = new AccountingAccount($db); - $accountventilated->fetch($monCompte, ''); + $accountventilated->fetch($monCompte, '', 1); dol_syslog('accountancy/supplier/list.php:: sql='.$sql, LOG_DEBUG); if ($db->query($sql)) { - $msg .= '
'.$langs->trans("Lineofinvoice").' '.$monId.' - '.$langs->trans("VentilatedinAccount").' : '.length_accountg($accountventilated->account_number).'
'; + $msg .= '
'.$langs->trans("Lineofinvoice").' '.$monId.' - '.$langs->trans("VentilatedinAccount").' : '.length_accountg($accountventilated->account_number).'
'; $ok++; } else { - $msg .= '
'.$langs->trans("ErrorDB").' : '.$langs->trans("Lineofinvoice").' '.$monId.' - '.$langs->trans("NotVentilatedinAccount").' : '.length_accountg($accountventilated->account_number).'
'.$sql.'
'; + $msg .= '
'.$langs->trans("ErrorDB").' : '.$langs->trans("Lineofinvoice").' '.$monId.' - '.$langs->trans("NotVentilatedinAccount").' : '.length_accountg($accountventilated->account_number).'
'.$sql.'
'; $ko++; } } diff --git a/htdocs/langs/en_US/accountancy.lang b/htdocs/langs/en_US/accountancy.lang index 464823810b2..5e4dddebc22 100644 --- a/htdocs/langs/en_US/accountancy.lang +++ b/htdocs/langs/en_US/accountancy.lang @@ -18,7 +18,7 @@ DefaultForService=Default for service DefaultForProduct=Default for product CantSuggest=Can't suggest AccountancySetupDoneFromAccountancyMenu=Most setup of the accountancy is done from the menu %s -ConfigAccountingExpert=Configuration of the module accounting expert +ConfigAccountingExpert=Configuration of the module accounting (double entry) Journalization=Journalization Journaux=Journals JournalFinancial=Financial journals @@ -131,7 +131,7 @@ LineId=Id line Processing=Processing EndProcessing=Process terminated. SelectedLines=Selected lines -Lineofinvoice=Line of invoice +Lineofinvoice=Line %s of invoice LineOfExpenseReport=Line of expense report NoAccountSelected=No accounting account selected VentilatedinAccount=Binded successfully to the accounting account diff --git a/htdocs/langs/en_US/admin.lang b/htdocs/langs/en_US/admin.lang index 49274730aeb..1498639d731 100644 --- a/htdocs/langs/en_US/admin.lang +++ b/htdocs/langs/en_US/admin.lang @@ -896,7 +896,7 @@ Permission1185=Approve purchase orders Permission1186=Order purchase orders Permission1187=Acknowledge receipt of purchase orders Permission1188=Delete purchase orders -Permission1189=Check/Uncheck a purhcase order reception +Permission1189=Check/Uncheck a purchase order reception Permission1190=Approve (second approval) purchase orders Permission1191=Export supplier orders and their attributes Permission1201=Get result of an export From d50932499f73d19dc627dddd8684d83ea1679de3 Mon Sep 17 00:00:00 2001 From: Alexandre SPANGARO Date: Mon, 28 Sep 2020 07:03:22 +0200 Subject: [PATCH 02/16] Fix select date on periodicity by default --- htdocs/accountancy/journal/bankjournal.php | 15 +++++++++------ .../accountancy/journal/expensereportsjournal.php | 15 +++++++++------ htdocs/accountancy/journal/purchasesjournal.php | 15 +++++++++------ htdocs/accountancy/journal/sellsjournal.php | 15 +++++++++------ 4 files changed, 36 insertions(+), 24 deletions(-) diff --git a/htdocs/accountancy/journal/bankjournal.php b/htdocs/accountancy/journal/bankjournal.php index 12fe8792401..4dd5df83152 100644 --- a/htdocs/accountancy/journal/bankjournal.php +++ b/htdocs/accountancy/journal/bankjournal.php @@ -93,12 +93,15 @@ $error = 0; $date_start = dol_mktime(0, 0, 0, $date_startmonth, $date_startday, $date_startyear); $date_end = dol_mktime(23, 59, 59, $date_endmonth, $date_endday, $date_endyear); -// Period by default on transfer -$dates = getDefaultDatesForTransfer(); -$date_start = $dates['date_start']; -$date_end = $dates['date_end']; -$pastmonthyear = $dates['pastmonthyear']; -$pastmonth = $dates['pastmonth']; +if (empty($date_startmonth) || empty($date_endmonth)) +{ + // Period by default on transfer + $dates = getDefaultDatesForTransfer(); + $date_start = $dates['date_start']; + $date_end = $dates['date_end']; + $pastmonthyear = $dates['pastmonthyear']; + $pastmonth = $dates['pastmonth']; +} if (!GETPOSTISSET('date_startmonth') && (empty($date_start) || empty($date_end))) // We define date_start and date_end, only if we did not submit the form { diff --git a/htdocs/accountancy/journal/expensereportsjournal.php b/htdocs/accountancy/journal/expensereportsjournal.php index b24f8550e50..bf8275cee1c 100644 --- a/htdocs/accountancy/journal/expensereportsjournal.php +++ b/htdocs/accountancy/journal/expensereportsjournal.php @@ -73,12 +73,15 @@ $journal_label = $accountingjournalstatic->label; $date_start = dol_mktime(0, 0, 0, $date_startmonth, $date_startday, $date_startyear); $date_end = dol_mktime(23, 59, 59, $date_endmonth, $date_endday, $date_endyear); -// Period by default on transfer -$dates = getDefaultDatesForTransfer(); -$date_start = $dates['date_start']; -$date_end = $dates['date_end']; -$pastmonthyear = $dates['pastmonthyear']; -$pastmonth = $dates['pastmonth']; +if (empty($date_startmonth) || empty($date_endmonth)) +{ + // Period by default on transfer + $dates = getDefaultDatesForTransfer(); + $date_start = $dates['date_start']; + $date_end = $dates['date_end']; + $pastmonthyear = $dates['pastmonthyear']; + $pastmonth = $dates['pastmonth']; +} if (!GETPOSTISSET('date_startmonth') && (empty($date_start) || empty($date_end))) // We define date_start and date_end, only if we did not submit the form { diff --git a/htdocs/accountancy/journal/purchasesjournal.php b/htdocs/accountancy/journal/purchasesjournal.php index 779c04f68fa..8e409b497b5 100644 --- a/htdocs/accountancy/journal/purchasesjournal.php +++ b/htdocs/accountancy/journal/purchasesjournal.php @@ -78,12 +78,15 @@ $journal_label = $accountingjournalstatic->label; $date_start = dol_mktime(0, 0, 0, $date_startmonth, $date_startday, $date_startyear); $date_end = dol_mktime(23, 59, 59, $date_endmonth, $date_endday, $date_endyear); -// Period by default on transfer -$dates = getDefaultDatesForTransfer(); -$date_start = $dates['date_start']; -$date_end = $dates['date_end']; -$pastmonthyear = $dates['pastmonthyear']; -$pastmonth = $dates['pastmonth']; +if (empty($date_startmonth) || empty($date_endmonth)) +{ + // Period by default on transfer + $dates = getDefaultDatesForTransfer(); + $date_start = $dates['date_start']; + $date_end = $dates['date_end']; + $pastmonthyear = $dates['pastmonthyear']; + $pastmonth = $dates['pastmonth']; +} if (!GETPOSTISSET('date_startmonth') && (empty($date_start) || empty($date_end))) // We define date_start and date_end, only if we did not submit the form { diff --git a/htdocs/accountancy/journal/sellsjournal.php b/htdocs/accountancy/journal/sellsjournal.php index 998f34745ac..589bad72749 100644 --- a/htdocs/accountancy/journal/sellsjournal.php +++ b/htdocs/accountancy/journal/sellsjournal.php @@ -81,12 +81,15 @@ $journal_label = $accountingjournalstatic->label; $date_start = dol_mktime(0, 0, 0, $date_startmonth, $date_startday, $date_startyear); $date_end = dol_mktime(23, 59, 59, $date_endmonth, $date_endday, $date_endyear); -// Period by default on transfer -$dates = getDefaultDatesForTransfer(); -$date_start = $dates['date_start']; -$date_end = $dates['date_end']; -$pastmonthyear = $dates['pastmonthyear']; -$pastmonth = $dates['pastmonth']; +if (empty($date_startmonth) || empty($date_endmonth)) +{ + // Period by default on transfer + $dates = getDefaultDatesForTransfer(); + $date_start = $dates['date_start']; + $date_end = $dates['date_end']; + $pastmonthyear = $dates['pastmonthyear']; + $pastmonth = $dates['pastmonth']; +} if (!GETPOSTISSET('date_startmonth') && (empty($date_start) || empty($date_end))) // We define date_start and date_end, only if we did not submit the form { From 10c034efdf2a6ab219b2cce40c277cbcf88b4d0a Mon Sep 17 00:00:00 2001 From: "Sekan, Tobias" Date: Mon, 28 Sep 2020 08:12:12 +0200 Subject: [PATCH 03/16] Fix contratcs are always zero on statistics board --- htdocs/contrat/class/contrat.class.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/contrat/class/contrat.class.php b/htdocs/contrat/class/contrat.class.php index f94b19c30b9..c87557e6f10 100644 --- a/htdocs/contrat/class/contrat.class.php +++ b/htdocs/contrat/class/contrat.class.php @@ -2257,7 +2257,7 @@ class Contrat extends CommonObject { while ($obj = $this->db->fetch_object($resql)) { - $this->nb["Contracts"] = $obj->nb; + $this->nb["contracts"] = $obj->nb; } $this->db->free($resql); return 1; From e3591a767e164c7ad76e829b4fe6624014f855cc Mon Sep 17 00:00:00 2001 From: "Sekan, Tobias" Date: Mon, 28 Sep 2020 08:31:39 +0200 Subject: [PATCH 04/16] fix count error on user categories --- htdocs/categories/viewcat.php | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/htdocs/categories/viewcat.php b/htdocs/categories/viewcat.php index 3a1d13d210e..67d972e4e11 100644 --- a/htdocs/categories/viewcat.php +++ b/htdocs/categories/viewcat.php @@ -876,12 +876,14 @@ if ($type == Categorie::TYPE_USER) print ''; print '
'; - $param = '&limit='.$limit.'&id='.$id.'&type='.$type; $num = count($objects); $nbtotalofrecords = ''; $newcardbutton = ''; - print_barre_liste($langs->trans("Users"), $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, $massactionbutton, $num, $nbtotalofrecords, 'user', 0, $newcardbutton, '', $limit); + $param = '&limit='.$limit.'&id='.$id.'&type='.$type; + $num = count($users); + + print_barre_liste($langs->trans("Users"), $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, $massactionbutton, $num, '', 'user', 0, '', '', $limit); print "\n"; - print ''."\n"; + print ''."\n"; if (count($users) > 0) { @@ -915,7 +917,7 @@ if ($type == Categorie::TYPE_USER) } -// List of Project +// List of warehouses if ($type == Categorie::TYPE_WAREHOUSE) { $permission = $user->rights->stock->creer; From f810f2c8e4990dfbdeb219d39af7f668d12c3bdd Mon Sep 17 00:00:00 2001 From: "Sekan, Tobias" Date: Mon, 28 Sep 2020 09:13:15 +0200 Subject: [PATCH 05/16] Fix wrong expected type in viewcat.php --- htdocs/categories/viewcat.php | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/htdocs/categories/viewcat.php b/htdocs/categories/viewcat.php index 3a1d13d210e..b75b937c357 100644 --- a/htdocs/categories/viewcat.php +++ b/htdocs/categories/viewcat.php @@ -316,7 +316,7 @@ print ''; $cats = $object->get_filles(); if ($cats < 0) { - dol_print_error($db, $cats->error, $cats->errors); + dol_print_error($db, $object->error, $object->errors); } elseif (count($cats) < 1) { print ''; @@ -431,7 +431,7 @@ if ($type == Categorie::TYPE_PRODUCT) $prods = $object->getObjectsInCateg($type, 0, $limit, $offset); if ($prods < 0) { - dol_print_error($db, $prods->error, $prods->errors); + dol_print_error($db, $object->error, $object->errors); } else { // Form to add record into a category $showclassifyform = 1; @@ -510,7 +510,7 @@ if ($type == Categorie::TYPE_SUPPLIER) $socs = $object->getObjectsInCateg($type, 0, $limit, $offset); if ($socs < 0) { - dol_print_error($db, $socs->error, $socs->errors); + dol_print_error($db, $object->error, $object->errors); } else { print ''; print ''; @@ -567,7 +567,7 @@ if ($type == Categorie::TYPE_CUSTOMER) $socs = $object->getObjectsInCateg($type, 0, $limit, $offset); if ($socs < 0) { - dol_print_error($db, $socs->error, $socs->errors); + dol_print_error($db, $object->error, $object->errors); } else { print ''; print ''; @@ -626,7 +626,7 @@ if ($type == Categorie::TYPE_MEMBER) $prods = $object->getObjectsInCateg($type, 0, $limit, $offset); if ($prods < 0) { - dol_print_error($db, $prods->error, $prods->errors); + dol_print_error($db, $object->error, $object->errors); } else { print ''; print ''; @@ -685,7 +685,7 @@ if ($type == Categorie::TYPE_CONTACT) $contacts = $object->getObjectsInCateg($type, 0, $limit, $offset); if ($contacts < 0) { - dol_print_error($db, $contacts->error, $contacts->errors); + dol_print_error($db, $object->error, $object->errors); } else { print ''; print ''; @@ -747,7 +747,7 @@ if ($type == Categorie::TYPE_ACCOUNT) $accounts = $object->getObjectsInCateg($type, 0, $limit, $offset); if ($accounts < 0) { - dol_print_error($db, $accounts->error, $accounts->errors); + dol_print_error($db, $object->error, $object->errors); } else { print ''; print ''; From 88772726d70e5d5fdde07170bb8d69ca1d9f12c0 Mon Sep 17 00:00:00 2001 From: Alexandre SPANGARO Date: Mon, 28 Sep 2020 09:32:49 +0200 Subject: [PATCH 06/16] New Add export for various payment --- htdocs/core/modules/modBanque.class.php | 26 ++++++++++++++++++++++++- htdocs/langs/en_US/banks.lang | 2 ++ 2 files changed, 27 insertions(+), 1 deletion(-) diff --git a/htdocs/core/modules/modBanque.class.php b/htdocs/core/modules/modBanque.class.php index 822ebd81e03..5b1e35df141 100644 --- a/htdocs/core/modules/modBanque.class.php +++ b/htdocs/core/modules/modBanque.class.php @@ -71,7 +71,7 @@ class modBanque extends DolibarrModules $this->depends = array(); $this->requiredby = array("modComptabilite", "modAccounting", "modPrelevement"); $this->conflictwith = array(); - $this->langfiles = array("banks", "compta", "bills", "companies"); + $this->langfiles = array("banks", "compta", "bills", "companies", "accounting"); // Constants $this->const = array(); @@ -202,6 +202,30 @@ class modBanque extends DolibarrModules $this->export_sql_end[$r] .= ' AND p.fk_paiement = 7'; $this->export_sql_end[$r] .= ' AND ba.entity IN ('.getEntity('bank_account').')'; $this->export_sql_order[$r] = ' ORDER BY b.datev, b.num_releve'; + + // Various Payment + $r++; + $this->export_code[$r] = $this->rights_class.'_'.$r; + $this->export_label[$r] = 'VariousPayment'; + $this->export_permission[$r] = array(array("banque", "export")); + $this->export_fields_array[$r] = array( + 'v.rowid'=>'VariousPaymentId', 'v.label'=>'VariousPaymentLabel', 'v.datev'=>'DateValue', 'v.datep'=>'DateOperation', + 'v.num_payment'=>'ChequeOrTransferNumber', 'v.amount'=>'Amount', 'v.sens'=>'Sens', + 't.fk_typepayment'=>"List:c_paiement:libelle:label", 'v.accountancy_code'=>'AccountAccounting', 'v.subledger_account'=>'SubledgerAccount', + 'p.title'=>'Project', 'v.note'=>'Note', 'v.datec'=>'DateCreation' + ); + $this->export_TypeFields_array[$r] = array('v.rowid'=>'Text', 'v.label'=>'Text', 'v.datep'=>'Date', 'v.datev'=>'Date', 'v.num_payment'=>'Text', 'v.amount'=>'Numeric', 'v.sens'=>'Boolean', 'v.fk_typepayment'=>'Text', "v.accountancy_code"=>"Text", "v.subledger_account"=>"Text", "p.title"=>"Text", "v.note"=>"Text", 'v.datec'=>"Date"); + $this->export_entities_array[$r] = array( + 'v.rowid'=>'payment', 'v.label'=>'payment', 'v.datev'=>'payment', 'v.datep'=>'payment', + 'v.num_payment'=>'payment', 'v.amount'=>'payment', 'v.sens'=>'payment', + 'v.fk_typepayment'=>'payment', 'v.accountancy_code'=>'payment', 'v.subledger_account'=>"payment", "p.title"=>"project", + 'v.note'=>"payment", 'v.datec'=>"payment" + ); + $this->export_sql_start[$r] = 'SELECT '; + $this->export_sql_end[$r] = ' FROM '.MAIN_DB_PREFIX.'payment_various as v'; + $this->export_sql_end[$r] .= ' LEFT JOIN '.MAIN_DB_PREFIX."projet as p ON v.fk_projet = p.rowid"; + $this->export_sql_end[$r] .= ' WHERE v.entity IN ('.getEntity('payment_various').')'; + $this->export_sql_order[$r] = ' ORDER BY v.datep'; } diff --git a/htdocs/langs/en_US/banks.lang b/htdocs/langs/en_US/banks.lang index 75f9549dca5..3cfa7ad2538 100644 --- a/htdocs/langs/en_US/banks.lang +++ b/htdocs/langs/en_US/banks.lang @@ -166,6 +166,8 @@ VariousPayment=Miscellaneous payment VariousPayments=Miscellaneous payments ShowVariousPayment=Show miscellaneous payment AddVariousPayment=Add miscellaneous payment +VariousPaymentId=Miscellaneous payment ID +VariousPaymentLabel=Miscellaneous payment label SEPAMandate=SEPA mandate YourSEPAMandate=Your SEPA mandate FindYourSEPAMandate=This is your SEPA mandate to authorize our company to make direct debit order to your bank. Return it signed (scan of the signed document) or send it by mail to From 7eaf26b09e2f6a0535a064a3520fdd0cae186d48 Mon Sep 17 00:00:00 2001 From: lvessiller Date: Mon, 28 Sep 2020 10:14:10 +0200 Subject: [PATCH 07/16] NEW add MAIN_EMAILCOLLECTOR_MAIL_WITHOUT_HEADER const to remove header in email collector --- .../class/emailcollector.class.php | 18 ++++++++++++------ htdocs/ticket/class/ticket.class.php | 2 +- 2 files changed, 13 insertions(+), 7 deletions(-) diff --git a/htdocs/emailcollector/class/emailcollector.class.php b/htdocs/emailcollector/class/emailcollector.class.php index 4b84a97fde0..b070b69b4c9 100644 --- a/htdocs/emailcollector/class/emailcollector.class.php +++ b/htdocs/emailcollector/class/emailcollector.class.php @@ -1672,8 +1672,10 @@ class EmailCollector extends CommonObject $description = dol_concatdesc($description, $messagetext); $descriptionfull = $description; - $descriptionfull = dol_concatdesc($descriptionfull, "----- Header"); - $descriptionfull = dol_concatdesc($descriptionfull, $header); + if (empty($conf->global->MAIN_EMAILCOLLECTOR_MAIL_WITHOUT_HEADER)) { + $descriptionfull = dol_concatdesc($descriptionfull, "----- Header"); + $descriptionfull = dol_concatdesc($descriptionfull, $header); + } // Insert record of emails sent $actioncomm->type_code = 'AC_OTH_AUTO'; // Type of event ('AC_OTH', 'AC_OTH_AUTO', 'AC_XXX'...) @@ -1760,8 +1762,10 @@ class EmailCollector extends CommonObject $description = dol_concatdesc($description, $messagetext); $descriptionfull = $description; - $descriptionfull = dol_concatdesc($descriptionfull, "----- Header"); - $descriptionfull = dol_concatdesc($descriptionfull, $header); + if (empty($conf->global->MAIN_EMAILCOLLECTOR_MAIL_WITHOUT_HEADER)) { + $descriptionfull = dol_concatdesc($descriptionfull, "----- Header"); + $descriptionfull = dol_concatdesc($descriptionfull, $header); + } $id_opp_status = dol_getIdFromCode($this->db, 'PROSP', 'c_lead_status', 'code', 'rowid'); $percent_opp_status = dol_getIdFromCode($this->db, 'PROSP', 'c_lead_status', 'code', 'percent'); @@ -1874,8 +1878,10 @@ class EmailCollector extends CommonObject $description = dol_concatdesc($description, $messagetext); $descriptionfull = $description; - $descriptionfull = dol_concatdesc($descriptionfull, "----- Header"); - $descriptionfull = dol_concatdesc($descriptionfull, $header); + if (empty($conf->global->MAIN_EMAILCOLLECTOR_MAIL_WITHOUT_HEADER)) { + $descriptionfull = dol_concatdesc($descriptionfull, "----- Header"); + $descriptionfull = dol_concatdesc($descriptionfull, $header); + } $tickettocreate->subject = $subject; $tickettocreate->message = $description; diff --git a/htdocs/ticket/class/ticket.class.php b/htdocs/ticket/class/ticket.class.php index f7813066a4c..2264fb3d9ee 100644 --- a/htdocs/ticket/class/ticket.class.php +++ b/htdocs/ticket/class/ticket.class.php @@ -482,7 +482,7 @@ class Ticket extends CommonObject global $langs; // Check parameters - if (!$id && !$track_id && !$ref) { + if (!$id && !$track_id && !$ref && !$email_msgid) { $this->error = 'ErrorWrongParameters'; dol_print_error(get_class($this)."::fetch ".$this->error); return -1; From 2e79064098f30ea6ade1d4e03d5d7a9f48b2e464 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Mon, 28 Sep 2020 11:07:53 +0200 Subject: [PATCH 08/16] Clean code --- htdocs/accountancy/admin/index.php | 32 ------------------------------ htdocs/core/lib/json.lib.php | 2 +- 2 files changed, 1 insertion(+), 33 deletions(-) diff --git a/htdocs/accountancy/admin/index.php b/htdocs/accountancy/admin/index.php index f37ff79a1fa..e5c104298bf 100644 --- a/htdocs/accountancy/admin/index.php +++ b/htdocs/accountancy/admin/index.php @@ -61,8 +61,6 @@ $list_binding = array( * Actions */ -$accounting_mode = empty($conf->global->ACCOUNTING_MODE) ? 'RECETTES-DEPENSES' : $conf->global->ACCOUNTING_MODE; - if ($action == 'update') { $error = 0; @@ -227,36 +225,6 @@ print ''; print ''; print ''; -// Default mode for calculating turnover (parameter ACCOUNTING_MODE) -/* -print '
'.$langs->trans("Users").' '.count($users).'
'.$langs->trans("Users").' '.$num.'
'; - -print ''; -print ''; -print "\n"; -print ''; -print '\n"; -print ''; -print '\n"; - -print "
' . $langs->trans('OptionMode') . '' . $langs->trans('Description') . '
' . $langs->trans('OptionModeTrue') . '' . nl2br($langs->trans('OptionModeTrueDesc')); -// Write info on way to count VAT -// if (! empty($conf->global->MAIN_MODULE_COMPTABILITE)) -// { -// // print "
\n"; -// // print nl2br($langs->trans('OptionModeTrueInfoModuleComptabilite')); -// } -// else -// { -// // print "
\n"; -// // print nl2br($langs->trans('OptionModeTrueInfoExpert')); -// } -print "
' . $langs->trans('OptionModeVirtual') . '' . nl2br($langs->trans('OptionModeVirtualDesc')) . "
\n"; - - -print '
'; -*/ - // Params print ''; print ''; diff --git a/htdocs/core/lib/json.lib.php b/htdocs/core/lib/json.lib.php index 57ed320afda..e4dfa3a0830 100644 --- a/htdocs/core/lib/json.lib.php +++ b/htdocs/core/lib/json.lib.php @@ -251,7 +251,7 @@ function dol_json_decode($json, $assoc = false) if ($out != '') { try { eval('$array = '.$out.';'); - } catch(Exception $e) { + } catch (Exception $e) { $array = array(); } } From a2ad1e2fc9da61a79ea2834105857b2775996a6f Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Mon, 28 Sep 2020 12:49:51 +0200 Subject: [PATCH 09/16] Fix #yogosha4544 --- htdocs/main.inc.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/main.inc.php b/htdocs/main.inc.php index cc489befd63..c8467b3192f 100644 --- a/htdocs/main.inc.php +++ b/htdocs/main.inc.php @@ -370,7 +370,7 @@ if ((!defined('NOCSRFCHECK') && empty($dolibarr_nocsrfcheck) && !empty($conf->gl || defined('CSRFCHECK_WITH_TOKEN')) // Check validity of token, only if option MAIN_SECURITY_CSRF_WITH_TOKEN enabled or if constant CSRFCHECK_WITH_TOKEN is set { // Check all cases that need a token (all POST actions, all actions and mass actions on pages with CSRFCHECK_WITH_TOKEN set, all sensitive GET actions) - if ($_SERVER['REQUEST_METHOD'] == 'POST' || ((GETPOSTISSET('action') || GETPOSTISSET('massaction')) && defined('CSRFCHECK_WITH_TOKEN')) || in_array(GETPOST('action', 'aZ09'), array('add', 'update', 'install', 'delete'))) + if ($_SERVER['REQUEST_METHOD'] == 'POST' || ((GETPOSTISSET('action') || GETPOSTISSET('massaction')) && defined('CSRFCHECK_WITH_TOKEN')) || in_array(GETPOST('action', 'aZ09'), array('add', 'update', 'install', 'delete', 'deletepro'))) { if (!GETPOSTISSET('token')) { dol_syslog("--- Access to ".$_SERVER["PHP_SELF"]." refused by CSRFCHECK_WITH_TOKEN protection. Token not provided."); From 9973ffab01c1fb1fe024170425e566726f3f57a6 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Mon, 28 Sep 2020 13:05:12 +0200 Subject: [PATCH 10/16] Fix sanitizing --- htdocs/compta/paiement/cheque/card.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/compta/paiement/cheque/card.php b/htdocs/compta/paiement/cheque/card.php index 2f9182f1693..24650ea343f 100644 --- a/htdocs/compta/paiement/cheque/card.php +++ b/htdocs/compta/paiement/cheque/card.php @@ -333,7 +333,7 @@ if ($action == 'new') if ($action == 'reject_check') { $formquestion = array( - array('type' => 'hidden', 'name' => 'bankid', 'value' => GETPOST('lineid')), + array('type' => 'hidden', 'name' => 'bankid', 'value' => GETPOST('lineid', 'int')), array('type' => 'date', 'name' => 'rejectdate_', 'label' => $langs->trans("RejectCheckDate"), 'value' => dol_now()) ); print $form->formconfirm($_SERVER["PHP_SELF"].'?id='.$object->id, $langs->trans("RejectCheck"), $langs->trans("ConfirmRejectCheck"), 'confirm_reject_check', $formquestion, '', 1); From b61815e95f786c725b94a27e92384908dfb03507 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Mon, 28 Sep 2020 16:22:15 +0200 Subject: [PATCH 11/16] Typo in action test --- htdocs/main.inc.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/htdocs/main.inc.php b/htdocs/main.inc.php index c8467b3192f..28014e8d669 100644 --- a/htdocs/main.inc.php +++ b/htdocs/main.inc.php @@ -370,11 +370,11 @@ if ((!defined('NOCSRFCHECK') && empty($dolibarr_nocsrfcheck) && !empty($conf->gl || defined('CSRFCHECK_WITH_TOKEN')) // Check validity of token, only if option MAIN_SECURITY_CSRF_WITH_TOKEN enabled or if constant CSRFCHECK_WITH_TOKEN is set { // Check all cases that need a token (all POST actions, all actions and mass actions on pages with CSRFCHECK_WITH_TOKEN set, all sensitive GET actions) - if ($_SERVER['REQUEST_METHOD'] == 'POST' || ((GETPOSTISSET('action') || GETPOSTISSET('massaction')) && defined('CSRFCHECK_WITH_TOKEN')) || in_array(GETPOST('action', 'aZ09'), array('add', 'update', 'install', 'delete', 'deletepro'))) + if ($_SERVER['REQUEST_METHOD'] == 'POST' || ((GETPOSTISSET('action') || GETPOSTISSET('massaction')) && defined('CSRFCHECK_WITH_TOKEN')) || in_array(GETPOST('action', 'aZ09'), array('add', 'update', 'install', 'delete', 'deleteprof'))) { if (!GETPOSTISSET('token')) { dol_syslog("--- Access to ".$_SERVER["PHP_SELF"]." refused by CSRFCHECK_WITH_TOKEN protection. Token not provided."); - print "Access by POST method (or to a page with CSRFCHECK_WITH_TOKEN on) is refused by CSRF protection in main.inc.php. Token not provided.\n"; + print "Access to this page this way (POST method or page with CSRFCHECK_WITH_TOKEN on or having a sensible value for action parameter) is refused by CSRF protection in main.inc.php. Token not provided.\n"; print "If you access your server behind a proxy using url rewriting, you might check that all HTTP header is propagated (or add the line \$dolibarr_nocsrfcheck=1 into your conf.php file or MAIN_SECURITY_CSRF_WITH_TOKEN to 0 into setup).\n"; die; } From 1a28d7f6418e00b9f1651df87fad31d945cadaa1 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Mon, 28 Sep 2020 16:33:27 +0200 Subject: [PATCH 12/16] Fix missing token --- htdocs/core/lib/ticket.lib.php | 3 +++ htdocs/main.inc.php | 2 +- 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/htdocs/core/lib/ticket.lib.php b/htdocs/core/lib/ticket.lib.php index 66729369af1..826e2d6bc98 100644 --- a/htdocs/core/lib/ticket.lib.php +++ b/htdocs/core/lib/ticket.lib.php @@ -431,6 +431,7 @@ function show_ticket_messaging($conf, $langs, $db, $filterobj, $objcon = '', $no //TODO Add limit in nb of results $sql .= $db->order($sortfield_new, $sortorder); + dol_syslog("company.lib::show_actions_done", LOG_DEBUG); $resql = $db->query($sql); if ($resql) @@ -529,6 +530,8 @@ function show_ticket_messaging($conf, $langs, $db, $filterobj, $objcon = '', $no $out .= '
'; $out .= ''; + $out .= ''; + if ($objcon && get_class($objcon) == 'Contact' && (is_null($filterobj) || get_class($filterobj) == 'Societe')) { diff --git a/htdocs/main.inc.php b/htdocs/main.inc.php index 28014e8d669..241fe39f1ac 100644 --- a/htdocs/main.inc.php +++ b/htdocs/main.inc.php @@ -370,7 +370,7 @@ if ((!defined('NOCSRFCHECK') && empty($dolibarr_nocsrfcheck) && !empty($conf->gl || defined('CSRFCHECK_WITH_TOKEN')) // Check validity of token, only if option MAIN_SECURITY_CSRF_WITH_TOKEN enabled or if constant CSRFCHECK_WITH_TOKEN is set { // Check all cases that need a token (all POST actions, all actions and mass actions on pages with CSRFCHECK_WITH_TOKEN set, all sensitive GET actions) - if ($_SERVER['REQUEST_METHOD'] == 'POST' || ((GETPOSTISSET('action') || GETPOSTISSET('massaction')) && defined('CSRFCHECK_WITH_TOKEN')) || in_array(GETPOST('action', 'aZ09'), array('add', 'update', 'install', 'delete', 'deleteprof'))) + if ($_SERVER['REQUEST_METHOD'] == 'POST' || ((GETPOSTISSET('action') || GETPOSTISSET('massaction')) && defined('CSRFCHECK_WITH_TOKEN')) || in_array(GETPOST('action', 'aZ09'), array('add', 'addtimespent', 'update', 'install', 'delete', 'deleteprof'))) { if (!GETPOSTISSET('token')) { dol_syslog("--- Access to ".$_SERVER["PHP_SELF"]." refused by CSRFCHECK_WITH_TOKEN protection. Token not provided."); From 2cbec87ddc289898fd5f4a46ba3e5379543b501e Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Mon, 28 Sep 2020 17:20:41 +0200 Subject: [PATCH 13/16] Update accountancy.lang --- htdocs/langs/en_US/accountancy.lang | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/langs/en_US/accountancy.lang b/htdocs/langs/en_US/accountancy.lang index 5e4dddebc22..adb87bcb8ca 100644 --- a/htdocs/langs/en_US/accountancy.lang +++ b/htdocs/langs/en_US/accountancy.lang @@ -131,7 +131,7 @@ LineId=Id line Processing=Processing EndProcessing=Process terminated. SelectedLines=Selected lines -Lineofinvoice=Line %s of invoice +Lineofinvoice=Line of invoice LineOfExpenseReport=Line of expense report NoAccountSelected=No accounting account selected VentilatedinAccount=Binded successfully to the accounting account From 4cf6e483ca51241326f01d33eaff538292ae4225 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Mon, 28 Sep 2020 18:49:20 +0200 Subject: [PATCH 14/16] Fix export of various payments. --- htdocs/admin/export.php | 2 +- .../modules/export/export_csv.modules.php | 1 - htdocs/core/modules/modBanque.class.php | 22 ++++++++++++++----- htdocs/exports/class/export.class.php | 1 + .../install/mysql/migration/12.0.0-13.0.0.sql | 2 +- test/phpunit/ExportTest.php | 11 ++++++---- 6 files changed, 27 insertions(+), 12 deletions(-) diff --git a/htdocs/admin/export.php b/htdocs/admin/export.php index d066197b580..ae7faafa937 100644 --- a/htdocs/admin/export.php +++ b/htdocs/admin/export.php @@ -95,7 +95,7 @@ print '
'; print ''; print ''; -print '"; +print ''; print ''; print ''; diff --git a/htdocs/core/modules/export/export_csv.modules.php b/htdocs/core/modules/export/export_csv.modules.php index 973e7ae536a..f4691ceb611 100644 --- a/htdocs/core/modules/export/export_csv.modules.php +++ b/htdocs/core/modules/export/export_csv.modules.php @@ -329,7 +329,6 @@ class ExportCsv extends ModeleExports global $conf; $addquote = 0; - // Rule Dolibarr: No HTML //print $charset.' '.$newvalue."\n"; //$newvalue=dol_string_nohtmltag($newvalue,0,$charset); diff --git a/htdocs/core/modules/modBanque.class.php b/htdocs/core/modules/modBanque.class.php index 5b1e35df141..11912cf778a 100644 --- a/htdocs/core/modules/modBanque.class.php +++ b/htdocs/core/modules/modBanque.class.php @@ -211,19 +211,31 @@ class modBanque extends DolibarrModules $this->export_fields_array[$r] = array( 'v.rowid'=>'VariousPaymentId', 'v.label'=>'VariousPaymentLabel', 'v.datev'=>'DateValue', 'v.datep'=>'DateOperation', 'v.num_payment'=>'ChequeOrTransferNumber', 'v.amount'=>'Amount', 'v.sens'=>'Sens', - 't.fk_typepayment'=>"List:c_paiement:libelle:label", 'v.accountancy_code'=>'AccountAccounting', 'v.subledger_account'=>'SubledgerAccount', - 'p.title'=>'Project', 'v.note'=>'Note', 'v.datec'=>'DateCreation' + 'cp.id'=>"PaymentMode", + 'v.accountancy_code'=>'AccountAccounting', 'v.subledger_account'=>'SubledgerAccount', + 'v.note'=>'Note', 'v.datec'=>'DateCreation', + 'p.ref'=>'ProjectRef', 'p.title'=>'ProjectLabel' + ); + $this->export_TypeFields_array[$r] = array( + 'v.rowid'=>'Text', 'v.label'=>'Text', 'v.datep'=>'Date', 'v.datev'=>'Date', + 'v.num_payment'=>'Text', 'v.amount'=>'Numeric', 'v.sens'=>'Numeric', + 'cp.id'=>'List:c_paiement:code:id:code', + "v.accountancy_code"=>"Text", "v.subledger_account"=>"Text", + "v.note"=>"Text", 'v.datec'=>"Date", + "p.ref"=>"Text", "p.title"=>"Text" ); - $this->export_TypeFields_array[$r] = array('v.rowid'=>'Text', 'v.label'=>'Text', 'v.datep'=>'Date', 'v.datev'=>'Date', 'v.num_payment'=>'Text', 'v.amount'=>'Numeric', 'v.sens'=>'Boolean', 'v.fk_typepayment'=>'Text', "v.accountancy_code"=>"Text", "v.subledger_account"=>"Text", "p.title"=>"Text", "v.note"=>"Text", 'v.datec'=>"Date"); $this->export_entities_array[$r] = array( 'v.rowid'=>'payment', 'v.label'=>'payment', 'v.datev'=>'payment', 'v.datep'=>'payment', 'v.num_payment'=>'payment', 'v.amount'=>'payment', 'v.sens'=>'payment', - 'v.fk_typepayment'=>'payment', 'v.accountancy_code'=>'payment', 'v.subledger_account'=>"payment", "p.title"=>"project", - 'v.note'=>"payment", 'v.datec'=>"payment" + 'cp.id'=>'payment', + 'v.accountancy_code'=>'payment', 'v.subledger_account'=>"payment", + 'v.note'=>"payment", 'v.datec'=>"payment", + "p.ref"=>"project", "p.title"=>"project" ); $this->export_sql_start[$r] = 'SELECT '; $this->export_sql_end[$r] = ' FROM '.MAIN_DB_PREFIX.'payment_various as v'; $this->export_sql_end[$r] .= ' LEFT JOIN '.MAIN_DB_PREFIX."projet as p ON v.fk_projet = p.rowid"; + $this->export_sql_end[$r] .= ' LEFT JOIN '.MAIN_DB_PREFIX."c_paiement as cp ON v.fk_typepayment = cp.id"; $this->export_sql_end[$r] .= ' WHERE v.entity IN ('.getEntity('payment_various').')'; $this->export_sql_order[$r] = ' ORDER BY v.datep'; } diff --git a/htdocs/exports/class/export.class.php b/htdocs/exports/class/export.class.php index 4d4b3626f75..c7d7f4eea89 100644 --- a/htdocs/exports/class/export.class.php +++ b/htdocs/exports/class/export.class.php @@ -539,6 +539,7 @@ class Export if (empty($this->array_export_fields) || !is_array($this->array_export_fields)) { $this->error = "ErrorBadParameter"; + dol_syslog($this->error, LOG_ERR); return -1; } diff --git a/htdocs/install/mysql/migration/12.0.0-13.0.0.sql b/htdocs/install/mysql/migration/12.0.0-13.0.0.sql index 710dcedab65..e76948808bb 100644 --- a/htdocs/install/mysql/migration/12.0.0-13.0.0.sql +++ b/htdocs/install/mysql/migration/12.0.0-13.0.0.sql @@ -28,7 +28,7 @@ -- Note: fields with type BLOB/TEXT can't have default value. --- Missing in v12 +-- Missing in v12 or lower ALTER TABLE llx_prelevement_bons ADD COLUMN type varchar(16) DEFAULT 'debit-order'; diff --git a/test/phpunit/ExportTest.php b/test/phpunit/ExportTest.php index cf1cafe74b1..2a3cb079baf 100644 --- a/test/phpunit/ExportTest.php +++ b/test/phpunit/ExportTest.php @@ -141,6 +141,9 @@ class ExportTest extends PHPUnit\Framework\TestCase $model='csv'; + $conf->global->EXPORT_CSV_SEPARATOR_TO_USE = ','; + print 'EXPORT_CSV_SEPARATOR_TO_USE = '.$conf->global->EXPORT_CSV_SEPARATOR_TO_USE; + // Creation of class to export using model ExportXXX $dir = DOL_DOCUMENT_ROOT . "/core/modules/export/"; $file = "export_".$model.".modules.php"; @@ -161,7 +164,7 @@ class ExportTest extends PHPUnit\Framework\TestCase print __METHOD__." valtotest=".$valtotest."\n"; $result = $objmodel->csvClean($valtotest, $langs->charset_output); print __METHOD__." result=".$result."\n"; - $this->assertEquals($result, '"A string with , and ; inside"'); + $this->assertEquals($result, '"A string with , and ; inside"', 'Error in csvClean for '.$file); $valtotest='A string with " inside'; print __METHOD__." valtotest=".$valtotest."\n"; @@ -182,7 +185,7 @@ class ExportTest extends PHPUnit\Framework\TestCase $this->assertEquals($result, '"A string with html
content
inside"'); // Same tests with strict mode - $conf->global->USE_STRICT_CSV_RULES=1; + $conf->global->USE_STRICT_CSV_RULES = 1; $valtotest='A simple string'; print __METHOD__." valtotest=".$valtotest."\n"; @@ -245,7 +248,7 @@ class ExportTest extends PHPUnit\Framework\TestCase // Build export file print "Process build_file for model = ".$model."\n"; $result=$objexport->build_file($user, $model, $datatoexport, $array_selected, array(), $sql); - $expectedresult=1; + $expectedresult = 1; $this->assertEquals($expectedresult, $result, 'Error in CSV export'); $model='tsv'; @@ -360,7 +363,7 @@ class ExportTest extends PHPUnit\Framework\TestCase // Build export file $sql = ""; $result=$objexport->build_file($user, $model, $datatoexport, $array_selected, array(), $sql); - $expectedresult=1; + $expectedresult = 1; $this->assertEquals($expectedresult, $result, "Call build_file() to export ".$exportfile.' failed'); $result=dol_is_file($exportfile); $this->assertTrue($result, 'File '.$exportfile.' not found'); From bd11154bfcd0ef3cc1d37140302a27e1809798a5 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Mon, 28 Sep 2020 18:56:53 +0200 Subject: [PATCH 15/16] NEW Can filter on accounting system ref in export of chart of account --- htdocs/core/modules/modAccounting.class.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/htdocs/core/modules/modAccounting.class.php b/htdocs/core/modules/modAccounting.class.php index 747cae06573..e769441288f 100644 --- a/htdocs/core/modules/modAccounting.class.php +++ b/htdocs/core/modules/modAccounting.class.php @@ -258,8 +258,8 @@ class modAccounting extends DolibarrModules $this->export_label[$r] = 'Chartofaccounts'; $this->export_icon[$r] = 'accounting'; $this->export_permission[$r] = array(array("accounting", "chartofaccount")); - $this->export_fields_array[$r] = array('ac.rowid'=>'ChartofaccountsId', 'ac.pcg_version'=>'Chartofaccounts', 'aa.rowid'=>'Id', 'aa.account_number'=>"AccountAccounting", 'aa.label'=>"Label", 'aa.account_parent'=>"Accountparent", 'aa.pcg_type'=>"Pcgtype", 'aa.active'=>'Status'); - $this->export_TypeFields_array[$r] = array('ac.rowid'=>'List:accounting_system:pcg_version', 'aa.account_number'=>"Text", 'aa.label'=>"Text", 'aa.account_parent'=>"Text", 'aa.pcg_type'=>'Text', 'aa.active'=>'Status'); + $this->export_fields_array[$r] = array('ac.rowid'=>'ChartofaccountsId', 'ac.pcg_version'=>'Chartofaccounts', 'aa.rowid'=>'ID', 'aa.account_number'=>"AccountAccounting", 'aa.label'=>"Label", 'aa.account_parent'=>"Accountparent", 'aa.pcg_type'=>"Pcgtype", 'aa.active'=>'Status'); + $this->export_TypeFields_array[$r] = array('ac.rowid'=>'List:accounting_system:pcg_version', 'ac.pcg_version'=>'Text', 'aa.rowid'=>'Numeric', 'aa.account_number'=>"Text", 'aa.label'=>"Text", 'aa.account_parent'=>"Text", 'aa.pcg_type'=>'Text', 'aa.active'=>'Status'); $this->export_entities_array[$r] = array('ac.rowid'=>"Accounting", 'ac.pcg_version'=>"Accounting", 'aa.rowid'=>'Accounting', 'aa.account_number'=>"Accounting", 'aa.label'=>"Accounting", 'aa.accountparent'=>"Accounting", 'aa.pcg_type'=>"Accounting", 'aa_active'=>"Accounting"); $this->export_sql_start[$r] = 'SELECT DISTINCT '; From 236c9bf1d24b875bb4f664a89e82f1cc39c8f998 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Mon, 28 Sep 2020 20:05:58 +0200 Subject: [PATCH 16/16] Fix regression making export feature not working --- htdocs/imports/import.php | 4 ++-- htdocs/main.inc.php | 5 ++++- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/htdocs/imports/import.php b/htdocs/imports/import.php index 93d3139ca90..9fdc5330103 100644 --- a/htdocs/imports/import.php +++ b/htdocs/imports/import.php @@ -77,8 +77,8 @@ $importmodelid = GETPOST('importmodelid'); $excludefirstline = (GETPOST('excludefirstline') ? GETPOST('excludefirstline') : 1); $endatlinenb = (GETPOST('endatlinenb') ? GETPOST('endatlinenb') : ''); $updatekeys = (GETPOST('updatekeys', 'array') ? GETPOST('updatekeys', 'array') : array()); -$separator = (GETPOST('separator') ? GETPOST('separator') : (!empty($conf->global->IMPORT_CSV_SEPARATOR_TO_USE) ? $conf->global->IMPORT_CSV_SEPARATOR_TO_USE : ',')); -$enclosure = (GETPOST('enclosure') ? GETPOST('enclosure') : '"'); +$separator = (GETPOST('separator', 'nohtml') ? GETPOST('separator', 'nohtml') : (!empty($conf->global->IMPORT_CSV_SEPARATOR_TO_USE) ? $conf->global->IMPORT_CSV_SEPARATOR_TO_USE : ',')); +$enclosure = (GETPOST('enclosure', 'nohtml') ? GETPOST('enclosure', 'nohtml') : '"'); $objimport = new Import($db); $objimport->load_arrays($user, ($step == 1 ? '' : $datatoimport)); diff --git a/htdocs/main.inc.php b/htdocs/main.inc.php index 241fe39f1ac..6cdf59a078a 100644 --- a/htdocs/main.inc.php +++ b/htdocs/main.inc.php @@ -118,7 +118,10 @@ function testSqlAndScriptInject($val, $type) $inj += preg_match('/javascript\s*:/i', $val); $inj += preg_match('/vbscript\s*:/i', $val); // For XSS Injection done by adding javascript closing html tags like with onmousemove, etc... (closing a src or href tag with not cleaned param) - if ($type == 1) $inj += preg_match('/"/i', $val); // We refused " in GET parameters value + if ($type == 1) { + $val = str_replace('enclosure="', 'enclosure=X', $val); // We accept enclosure=" + $inj += preg_match('/"/i', $val); // We refused " in GET parameters value. + } if ($type == 2) $inj += preg_match('/[;"]/', $val); // PHP_SELF is a file system path. It can contains spaces. return $inj; }
'.$langs->trans("ExportCsvSeparator").''."global->EXPORT_CSV_SEPARATOR_TO_USE) ? ',' : $conf->global->EXPORT_CSV_SEPARATOR_TO_USE)."\">