From 604cc5896e9f468e6245587da5286edf40236b0a Mon Sep 17 00:00:00 2001 From: vabeltran Date: Mon, 26 Feb 2018 12:31:40 +0100 Subject: [PATCH 01/20] FIX Unknown column 'pl.amount_requested' in compta/prelevement/factures.php Column 'amount_requested' in ORDER clause not exists because that column is called 'amount' now in 'prelevement_bons' table in db. --- htdocs/compta/prelevement/factures.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/compta/prelevement/factures.php b/htdocs/compta/prelevement/factures.php index c829b139436..64811c7604a 100644 --- a/htdocs/compta/prelevement/factures.php +++ b/htdocs/compta/prelevement/factures.php @@ -205,7 +205,7 @@ if ($result) print_liste_field_titre("Bill",$_SERVER["PHP_SELF"],"p.ref",'',$param,'',$sortfield,$sortorder); print_liste_field_titre("ThirdParty",$_SERVER["PHP_SELF"],"s.nom",'',$param,'',$sortfield,$sortorder); print_liste_field_titre("AmountInvoice",$_SERVER["PHP_SELF"],"f.total_ttc","",$param,'align="right"',$sortfield,$sortorder); - print_liste_field_titre("AmountRequested",$_SERVER["PHP_SELF"],"pl.amount_requested","",$param,'align="right"',$sortfield,$sortorder); + print_liste_field_titre("AmountRequested",$_SERVER["PHP_SELF"],"pl.amount","",$param,'align="right"',$sortfield,$sortorder); print_liste_field_titre("StatusDebitCredit",$_SERVER["PHP_SELF"],"","",$param,'align="center"',$sortfield,$sortorder); print_liste_field_titre(''); print "\n"; From b87db9d32d01feced9d2bb04711af9357e362a38 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Fri, 2 Mar 2018 16:38:56 +0100 Subject: [PATCH 02/20] Fix missing ; --- htdocs/install/mysql/tables/llx_expensereport_rules.sql | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/install/mysql/tables/llx_expensereport_rules.sql b/htdocs/install/mysql/tables/llx_expensereport_rules.sql index e6103ee8fb9..3aaca6f00b5 100644 --- a/htdocs/install/mysql/tables/llx_expensereport_rules.sql +++ b/htdocs/install/mysql/tables/llx_expensereport_rules.sql @@ -31,4 +31,4 @@ CREATE TABLE llx_expensereport_rules ( code_expense_rules_type varchar(50) NOT NULL, is_for_all tinyint DEFAULT '0', entity integer DEFAULT 1 -) ENGINE=InnoDB \ No newline at end of file +) ENGINE=InnoDB; \ No newline at end of file From bf4543a636f81e30dfa851e655419805b8c2727a Mon Sep 17 00:00:00 2001 From: Regis Houssin Date: Fri, 2 Mar 2018 17:05:52 +0100 Subject: [PATCH 03/20] Fix: missing hook during rename file action --- htdocs/core/actions_linkedfiles.inc.php | 72 ++++++++++++++----------- 1 file changed, 40 insertions(+), 32 deletions(-) diff --git a/htdocs/core/actions_linkedfiles.inc.php b/htdocs/core/actions_linkedfiles.inc.php index 0e0c444af33..5ec20a81b8c 100644 --- a/htdocs/core/actions_linkedfiles.inc.php +++ b/htdocs/core/actions_linkedfiles.inc.php @@ -177,42 +177,50 @@ elseif ($action == 'confirm_updateline' && GETPOST('save','alpha') && GETPOST('l elseif ($action == 'renamefile' && GETPOST('renamefilesave','alpha')) { // For documents pages, upload_dir contains already path to file from module dir, so we clean path into urlfile. - if (! empty($upload_dir)) - { - $filenamefrom=dol_sanitizeFileName(GETPOST('renamefilefrom','alpha'), '_', 0); // Do not remove accents - $filenameto=dol_sanitizeFileName(GETPOST('renamefileto','alpha'), '_', 0); // Do not remove accents + if (! empty($upload_dir)) + { + $reshook=$hookmanager->initHooks(array('actionlinkedfiles')); - // Security: - // Disallow file with some extensions. We rename them. - // Because if we put the documents directory into a directory inside web root (very bad), this allows to execute on demand arbitrary code. - if (preg_match('/\.htm|\.html|\.php|\.pl|\.cgi$/i',$filenameto) && empty($conf->global->MAIN_DOCUMENT_IS_OUTSIDE_WEBROOT_SO_NOEXE_NOT_REQUIRED)) - { - $filenameto.= '.noexe'; - } + $filenamefrom=dol_sanitizeFileName(GETPOST('renamefilefrom','alpha'), '_', 0); // Do not remove accents + $filenameto=dol_sanitizeFileName(GETPOST('renamefileto','alpha'), '_', 0); // Do not remove accents - if ($filenamefrom && $filenameto) - { - $srcpath = $upload_dir.'/'.$filenamefrom; - $destpath = $upload_dir.'/'.$filenameto; + $parameters=array('filenamefrom' => $filenamefrom, 'filenameto' => $filenameto); + $reshook=$hookmanager->executeHooks('renameUploadedFile', $parameters, $object); - $result = dol_move($srcpath, $destpath); - if ($result) - { - if ($object->id) - { - $object->addThumbs($destpath); - } + if (empty($reshook)) + { + // Security: + // Disallow file with some extensions. We rename them. + // Because if we put the documents directory into a directory inside web root (very bad), this allows to execute on demand arbitrary code. + if (preg_match('/\.htm|\.html|\.php|\.pl|\.cgi$/i',$filenameto) && empty($conf->global->MAIN_DOCUMENT_IS_OUTSIDE_WEBROOT_SO_NOEXE_NOT_REQUIRED)) + { + $filenameto.= '.noexe'; + } - // TODO Add revert function of addThumbs to remove for old name - //$object->delThumbs($srcpath); + if ($filenamefrom && $filenameto) + { + $srcpath = $upload_dir.'/'.$filenamefrom; + $destpath = $upload_dir.'/'.$filenameto; - setEventMessages($langs->trans("FileRenamed"), null); - } - else - { - $langs->load("errors"); // key must be loaded because we can't rely on loading during output, we need var substitution to be done now. - setEventMessages($langs->trans("ErrorFailToRenameFile", $filenamefrom, $filenameto), null, 'errors'); - } - } + $result = dol_move($srcpath, $destpath); + if ($result) + { + if ($object->id) + { + $object->addThumbs($destpath); + } + + // TODO Add revert function of addThumbs to remove for old name + //$object->delThumbs($srcpath); + + setEventMessages($langs->trans("FileRenamed"), null); + } + else + { + $langs->load("errors"); // key must be loaded because we can't rely on loading during output, we need var substitution to be done now. + setEventMessages($langs->trans("ErrorFailToRenameFile", $filenamefrom, $filenameto), null, 'errors'); + } + } + } } } From 473c16ede599c1e739f1332bff9395f47b67b091 Mon Sep 17 00:00:00 2001 From: florian HENRY Date: Fri, 2 Mar 2018 17:30:46 +0100 Subject: [PATCH 04/20] fix pgSQL install --- htdocs/install/mysql/migration/6.0.0-7.0.0.sql | 2 +- htdocs/install/mysql/tables/llx_expensereport_rules.sql | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/htdocs/install/mysql/migration/6.0.0-7.0.0.sql b/htdocs/install/mysql/migration/6.0.0-7.0.0.sql index 190e0dcf05f..e745ad20847 100644 --- a/htdocs/install/mysql/migration/6.0.0-7.0.0.sql +++ b/htdocs/install/mysql/migration/6.0.0-7.0.0.sql @@ -437,7 +437,7 @@ CREATE TABLE llx_expensereport_rules ( fk_usergroup integer DEFAULT NULL, fk_c_type_fees integer NOT NULL, code_expense_rules_type varchar(50) NOT NULL, - is_for_all tinyint DEFAULT '0', + is_for_all tinyint DEFAULT 0, entity integer DEFAULT 1 )ENGINE=innodb; diff --git a/htdocs/install/mysql/tables/llx_expensereport_rules.sql b/htdocs/install/mysql/tables/llx_expensereport_rules.sql index e6103ee8fb9..a105b8f28ca 100644 --- a/htdocs/install/mysql/tables/llx_expensereport_rules.sql +++ b/htdocs/install/mysql/tables/llx_expensereport_rules.sql @@ -29,6 +29,6 @@ CREATE TABLE llx_expensereport_rules ( fk_usergroup integer DEFAULT NULL, fk_c_type_fees integer NOT NULL, code_expense_rules_type varchar(50) NOT NULL, - is_for_all tinyint DEFAULT '0', + is_for_all tinyint DEFAULT 0, entity integer DEFAULT 1 ) ENGINE=InnoDB \ No newline at end of file From 8e85198bd15206e61c4ca4c00a9b1191629e5f12 Mon Sep 17 00:00:00 2001 From: Regis Houssin Date: Fri, 2 Mar 2018 18:09:06 +0100 Subject: [PATCH 05/20] Fix: missing $upload_dir --- htdocs/core/actions_linkedfiles.inc.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/core/actions_linkedfiles.inc.php b/htdocs/core/actions_linkedfiles.inc.php index 5ec20a81b8c..2ef3191154d 100644 --- a/htdocs/core/actions_linkedfiles.inc.php +++ b/htdocs/core/actions_linkedfiles.inc.php @@ -184,7 +184,7 @@ elseif ($action == 'renamefile' && GETPOST('renamefilesave','alpha')) $filenamefrom=dol_sanitizeFileName(GETPOST('renamefilefrom','alpha'), '_', 0); // Do not remove accents $filenameto=dol_sanitizeFileName(GETPOST('renamefileto','alpha'), '_', 0); // Do not remove accents - $parameters=array('filenamefrom' => $filenamefrom, 'filenameto' => $filenameto); + $parameters=array('filenamefrom' => $filenamefrom, 'filenameto' => $filenameto, 'upload_dir' => $upload_dir); $reshook=$hookmanager->executeHooks('renameUploadedFile', $parameters, $object); if (empty($reshook)) From b69d2800ef035d46e8fef6fe0067ffc0e72a6fe9 Mon Sep 17 00:00:00 2001 From: Regis Houssin Date: Fri, 2 Mar 2018 18:59:30 +0100 Subject: [PATCH 06/20] Fix: check if file name already exists --- htdocs/core/actions_linkedfiles.inc.php | 26 ++++++++++++++++--------- 1 file changed, 17 insertions(+), 9 deletions(-) diff --git a/htdocs/core/actions_linkedfiles.inc.php b/htdocs/core/actions_linkedfiles.inc.php index 2ef3191154d..4e9e0063dc3 100644 --- a/htdocs/core/actions_linkedfiles.inc.php +++ b/htdocs/core/actions_linkedfiles.inc.php @@ -202,18 +202,26 @@ elseif ($action == 'renamefile' && GETPOST('renamefilesave','alpha')) $srcpath = $upload_dir.'/'.$filenamefrom; $destpath = $upload_dir.'/'.$filenameto; - $result = dol_move($srcpath, $destpath); - if ($result) + if (!file_exists($destpath)) { - if ($object->id) + $result = dol_move($srcpath, $destpath); + if ($result) { - $object->addThumbs($destpath); + if ($object->id) + { + $object->addThumbs($destpath); + } + + // TODO Add revert function of addThumbs to remove for old name + //$object->delThumbs($srcpath); + + setEventMessages($langs->trans("FileRenamed"), null); + } + else + { + $langs->load("errors"); // key must be loaded because we can't rely on loading during output, we need var substitution to be done now. + setEventMessages($langs->trans("ErrorFailToRenameFile", $filenamefrom, $filenameto), null, 'errors'); } - - // TODO Add revert function of addThumbs to remove for old name - //$object->delThumbs($srcpath); - - setEventMessages($langs->trans("FileRenamed"), null); } else { From 0c529770278aca05eea9b1f966f1c2c141ddcce2 Mon Sep 17 00:00:00 2001 From: Regis Houssin Date: Sat, 3 Mar 2018 08:37:44 +0100 Subject: [PATCH 07/20] Fix: avoid Warning: A non-numeric value encountered --- htdocs/supplier_proposal/class/supplier_proposal.class.php | 1 + 1 file changed, 1 insertion(+) diff --git a/htdocs/supplier_proposal/class/supplier_proposal.class.php b/htdocs/supplier_proposal/class/supplier_proposal.class.php index 621a229121c..dc00360acfd 100644 --- a/htdocs/supplier_proposal/class/supplier_proposal.class.php +++ b/htdocs/supplier_proposal/class/supplier_proposal.class.php @@ -384,6 +384,7 @@ class SupplierProposal extends CommonObject if (empty($info_bits)) $info_bits=0; if (empty($rang)) $rang=0; if (empty($fk_parent_line) || $fk_parent_line < 0) $fk_parent_line=0; + if (empty($pu_ht)) $pu_ht=0; $remise_percent=price2num($remise_percent); $qty=price2num($qty); From eac1b2efe96ef5f449021aa3834e1116864619ba Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Sat, 3 Mar 2018 11:22:15 +0100 Subject: [PATCH 08/20] FIX Infinite loop on deletion of temp file when there is symbolic links --- htdocs/admin/tools/purge.php | 2 +- htdocs/core/class/utils.class.php | 2 +- htdocs/core/lib/files.lib.php | 9 +++++++-- 3 files changed, 9 insertions(+), 4 deletions(-) diff --git a/htdocs/admin/tools/purge.php b/htdocs/admin/tools/purge.php index bc328e951d4..f415ed1692c 100644 --- a/htdocs/admin/tools/purge.php +++ b/htdocs/admin/tools/purge.php @@ -86,7 +86,7 @@ if (! empty($conf->syslog->enabled)) $filelogparam=$filelog; if ($user->admin && preg_match('/^dolibarr.*\.log$/', basename($filelog))) { - $filelogparam =''.$filelog.''; } diff --git a/htdocs/core/class/utils.class.php b/htdocs/core/class/utils.class.php index 4502eb03240..7d5f742a779 100644 --- a/htdocs/core/class/utils.class.php +++ b/htdocs/core/class/utils.class.php @@ -67,7 +67,7 @@ class Utils // Delete temporary files if ($dolibarr_main_data_root) { - $filesarray=dol_dir_list($dolibarr_main_data_root,"directories",1,'^temp$','','','',2); + $filesarray=dol_dir_list($dolibarr_main_data_root, "directories", 1, '^temp$', '', '', '', 2, 0, '', 1); // Do not follow symlinks if ($choice == 'tempfilesold') { $now = dol_now(); diff --git a/htdocs/core/lib/files.lib.php b/htdocs/core/lib/files.lib.php index f62fb14c68b..088b68b1c2f 100644 --- a/htdocs/core/lib/files.lib.php +++ b/htdocs/core/lib/files.lib.php @@ -52,10 +52,11 @@ function dol_basename($pathfile) * @param int $mode 0=Return array minimum keys loaded (faster), 1=Force all keys like date and size to be loaded (slower), 2=Force load of date only, 3=Force load of size only * @param int $nohook Disable all hooks * @param string $relativename For recursive purpose only. Must be "" at first call. + * @param string $donotfollowsymlinks Do not follow symbolic links * @return array Array of array('name'=>'xxx','fullname'=>'/abc/xxx','date'=>'yyy','size'=>99,'type'=>'dir|file',...) * @see dol_dir_list_indatabase */ -function dol_dir_list($path, $types="all", $recursive=0, $filter="", $excludefilter=null, $sortcriteria="name", $sortorder=SORT_ASC, $mode=0, $nohook=0, $relativename="") +function dol_dir_list($path, $types="all", $recursive=0, $filter="", $excludefilter=null, $sortcriteria="name", $sortorder=SORT_ASC, $mode=0, $nohook=0, $relativename="", $donotfollowsymlinks=0) { global $db, $hookmanager; global $object; @@ -159,7 +160,11 @@ function dol_dir_list($path, $types="all", $recursive=0, $filter="", $excludefil // if we're in a directory and we want recursive behavior, call this function again if ($recursive) { - $file_list = array_merge($file_list, dol_dir_list($path."/".$file, $types, $recursive, $filter, $excludefilter, $sortcriteria, $sortorder, $mode, $nohook, ($relativename!=''?$relativename.'/':'').$file)); + if (empty($donotfollowsymlinks) || ! is_link($path."/".$file)) + { + //var_dump('eee '. $path."/".$file. ' '.is_dir($path."/".$file).' '.is_link($path."/".$file)); + $file_list = array_merge($file_list, dol_dir_list($path."/".$file, $types, $recursive, $filter, $excludefilter, $sortcriteria, $sortorder, $mode, $nohook, ($relativename!=''?$relativename.'/':'').$file, $donotfollowsymlinks)); + } } } else if (! $isdir && (($types == "files") || ($types == "all"))) From 44eb50c4249282fb1cac949b2617b81b8ab2177e Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Sat, 3 Mar 2018 11:57:10 +0100 Subject: [PATCH 09/20] FIX Infinite loop on deletion of temp file when there is symbolic links --- htdocs/core/class/utils.class.php | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/htdocs/core/class/utils.class.php b/htdocs/core/class/utils.class.php index 7d5f742a779..37ccea748f1 100644 --- a/htdocs/core/class/utils.class.php +++ b/htdocs/core/class/utils.class.php @@ -67,7 +67,7 @@ class Utils // Delete temporary files if ($dolibarr_main_data_root) { - $filesarray=dol_dir_list($dolibarr_main_data_root, "directories", 1, '^temp$', '', '', '', 2, 0, '', 1); // Do not follow symlinks + $filesarray=dol_dir_list($dolibarr_main_data_root, "directories", 1, '^temp$', '', 'name', SORT_ASC, 2, 0, '', 1); // Do not follow symlinks if ($choice == 'tempfilesold') { $now = dol_now(); @@ -81,10 +81,10 @@ class Utils if ($choice=='allfiles') { - // Delete all files (except install.lock) + // Delete all files (except install.lock, do not follow symbolic links) if ($dolibarr_main_data_root) { - $filesarray=dol_dir_list($dolibarr_main_data_root,"all",0,'','install\.lock$'); + $filesarray=dol_dir_list($dolibarr_main_data_root, "all", 0, '', 'install\.lock$', 'name', SORT_ASC, 0, 0, '', 1); } } @@ -93,7 +93,7 @@ class Utils // Define files log if ($dolibarr_main_data_root) { - $filesarray=dol_dir_list($dolibarr_main_data_root, "files", 0, '.*\.log[\.0-9]*$', 'install\.lock$'); + $filesarray=dol_dir_list($dolibarr_main_data_root, "files", 0, '.*\.log[\.0-9]*$', 'install\.lock$', 'name', SORT_ASC, 0, 0, '', 1); } $filelog=''; From c0664474e41c390b31e3de8e10445438c0b3fd98 Mon Sep 17 00:00:00 2001 From: Alexandre SPANGARO Date: Sun, 4 Mar 2018 06:32:55 +0100 Subject: [PATCH 10/20] Fix : Missing language file --- htdocs/admin/taxes.php | 1 + 1 file changed, 1 insertion(+) diff --git a/htdocs/admin/taxes.php b/htdocs/admin/taxes.php index bbf2435436e..a4aa1afbd8c 100644 --- a/htdocs/admin/taxes.php +++ b/htdocs/admin/taxes.php @@ -30,6 +30,7 @@ require_once DOL_DOCUMENT_ROOT . '/core/lib/admin.lib.php'; if (! empty($conf->accounting->enabled)) require_once DOL_DOCUMENT_ROOT . '/core/class/html.formaccounting.class.php'; $langs->load('admin'); +$langs->load("products"); if (!$user->admin) accessforbidden(); From 1a7c09b7d5e6dc76c17d7f1ef88385afd68eedfd Mon Sep 17 00:00:00 2001 From: fappels Date: Sun, 4 Mar 2018 12:35:32 +0100 Subject: [PATCH 11/20] Fix 0 is also a valid Qty Fix error handling --- htdocs/expedition/class/expedition.class.php | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/htdocs/expedition/class/expedition.class.php b/htdocs/expedition/class/expedition.class.php index 85408c7e14a..90a7abb291e 100644 --- a/htdocs/expedition/class/expedition.class.php +++ b/htdocs/expedition/class/expedition.class.php @@ -398,7 +398,7 @@ class Expedition extends CommonObject if (($lineId = $expeditionline->insert()) < 0) { - $this->error[]=$expeditionline->error; + $this->errors[]=$expeditionline->error; } return $lineId; } @@ -2386,9 +2386,9 @@ class ExpeditionLigne extends CommonObjectLine $error=0; // Check parameters - if (empty($this->fk_expedition) || empty($this->fk_origin_line) || empty($this->qty)) + if (empty($this->fk_expedition) || empty($this->fk_origin_line) || ! is_numeric($this->qty)) { - $this->errors[] = 'ErrorMandatoryParametersNotProvided'; + $this->error = 'ErrorMandatoryParametersNotProvided'; return -1; } // Clean parameters @@ -2418,6 +2418,7 @@ class ExpeditionLigne extends CommonObjectLine $result=$this->insertExtraFields(); if ($result < 0) { + $this->errors[]=$this->error; $error++; } } From f35679fb2a0f29fbcb131bbabeb47abeb723fac5 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Mon, 5 Mar 2018 13:11:07 +0100 Subject: [PATCH 12/20] Fix description of field of table --- htdocs/admin/system/dbtable.php | 32 +++++++++++++++++++++++--------- 1 file changed, 23 insertions(+), 9 deletions(-) diff --git a/htdocs/admin/system/dbtable.php b/htdocs/admin/system/dbtable.php index 19fa3fc1abd..d6e05ed2e72 100644 --- a/htdocs/admin/system/dbtable.php +++ b/htdocs/admin/system/dbtable.php @@ -75,7 +75,7 @@ else } } - if ($base == 1) + if ($base == 1) // mysql { $link=array(); $cons = explode(";", $row[14]); @@ -97,11 +97,19 @@ else // var_dump($link); - print ''; - print ''; - print ''; + print '
'.$langs->trans("Fields").''.$langs->trans("Type").''.$langs->trans("Index").''.$langs->trans("FieldsLinked").'
'; + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; - $sql = "DESCRIBE ".$table; + //$sql = "DESCRIBE ".$table; + $sql = "SHOW FULL COLUMNS IN ".$db->escape($table); + $resql = $db->query($sql); if ($resql) { @@ -111,12 +119,18 @@ else { $row = $db->fetch_row($resql); print ''; - print ""; - print ""; - print ""; + print ""; + print ""; + print ""; + print ""; + print ""; + print ""; + print ""; + print ""; - + + print ''; print ''; $i++; } From 184c7733012fb42e26ac46c5c6efc921dc7da445 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Mon, 5 Mar 2018 15:43:48 +0100 Subject: [PATCH 13/20] Fix error management --- htdocs/adherents/subscription.php | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/htdocs/adherents/subscription.php b/htdocs/adherents/subscription.php index 8d4b7829925..5a50c92f3e9 100644 --- a/htdocs/adherents/subscription.php +++ b/htdocs/adherents/subscription.php @@ -284,7 +284,7 @@ if ($user->rights->adherent->cotisation->creer && $action == 'subscription' && ! { if (! $_POST["label"]) $errmsg=$langs->trans("ErrorFieldRequired",$langs->transnoentities("Label")); if ($_POST["paymentsave"] != 'invoiceonly' && ! $_POST["operation"]) $errmsg=$langs->trans("ErrorFieldRequired",$langs->transnoentities("PaymentMode")); - if ($_POST["paymentsave"] != 'invoiceonly' && ! $_POST["accountid"]) $errmsg=$langs->trans("ErrorFieldRequired",$langs->transnoentities("FinancialAccount")); + if ($_POST["paymentsave"] != 'invoiceonly' && ! ($_POST["accountid"] > 0)) $errmsg=$langs->trans("ErrorFieldRequired",$langs->transnoentities("FinancialAccount")); } else { @@ -293,6 +293,7 @@ if ($user->rights->adherent->cotisation->creer && $action == 'subscription' && ! if ($errmsg) { setEventMessages($errmsg, null, 'errors'); + $error++; $action='addsubscription'; } } From d422fc8a116399e5884607ac973e9fa9b49439f6 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Mon, 5 Mar 2018 16:09:26 +0100 Subject: [PATCH 14/20] Fix SQL error when creating subscription --- htdocs/adherents/subscription.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/adherents/subscription.php b/htdocs/adherents/subscription.php index 5a50c92f3e9..5923603c9c9 100644 --- a/htdocs/adherents/subscription.php +++ b/htdocs/adherents/subscription.php @@ -332,7 +332,7 @@ if ($user->rights->adherent->cotisation->creer && $action == 'subscription' && ! if ($inserturlid > 0) { // Update table subscription - $sql ="UPDATE ".MAIN_DB_PREFIX."subscription SET fk_bank=".$insertid; + $sql ="UPDATE ".MAIN_DB_PREFIX."subscription SET fk_bank=".$inserturlid; $sql.=" WHERE rowid=".$crowid; dol_syslog("subscription::subscription", LOG_DEBUG); From 0b3e2e92e27eb9c829a973f32e6af5749344ec7e Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Mon, 5 Mar 2018 16:13:32 +0100 Subject: [PATCH 15/20] Revert "Fix SQL error when creating subscription" This reverts commit d422fc8a116399e5884607ac973e9fa9b49439f6. --- htdocs/adherents/subscription.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/adherents/subscription.php b/htdocs/adherents/subscription.php index 5923603c9c9..5a50c92f3e9 100644 --- a/htdocs/adherents/subscription.php +++ b/htdocs/adherents/subscription.php @@ -332,7 +332,7 @@ if ($user->rights->adherent->cotisation->creer && $action == 'subscription' && ! if ($inserturlid > 0) { // Update table subscription - $sql ="UPDATE ".MAIN_DB_PREFIX."subscription SET fk_bank=".$inserturlid; + $sql ="UPDATE ".MAIN_DB_PREFIX."subscription SET fk_bank=".$insertid; $sql.=" WHERE rowid=".$crowid; dol_syslog("subscription::subscription", LOG_DEBUG); From 81e193b725b8df2b930bbd76792bdf3bc76cb620 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Mon, 5 Mar 2018 20:46:54 +0100 Subject: [PATCH 16/20] Update expedition.class.php --- htdocs/expedition/class/expedition.class.php | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/htdocs/expedition/class/expedition.class.php b/htdocs/expedition/class/expedition.class.php index 90a7abb291e..b403f0f87dd 100644 --- a/htdocs/expedition/class/expedition.class.php +++ b/htdocs/expedition/class/expedition.class.php @@ -2418,7 +2418,6 @@ class ExpeditionLigne extends CommonObjectLine $result=$this->insertExtraFields(); if ($result < 0) { - $this->errors[]=$this->error; $error++; } } @@ -2429,7 +2428,6 @@ class ExpeditionLigne extends CommonObjectLine $result=$this->call_trigger('LINESHIPPING_INSERT',$user); if ($result < 0) { - $this->errors[]=$this->error; $error++; } // End call triggers @@ -2445,6 +2443,7 @@ class ExpeditionLigne extends CommonObjectLine dol_syslog(get_class($this)."::delete ".$errmsg, LOG_ERR); $this->error.=($this->error?', '.$errmsg:$errmsg); } + $this->db->rollback(); return -1*$error; } From a765dba57061b7604e526a3f12392c375e5fd611 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Tue, 6 Mar 2018 09:06:49 +0100 Subject: [PATCH 17/20] Fix trad --- htdocs/langs/fr_FR/accountancy.lang | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/htdocs/langs/fr_FR/accountancy.lang b/htdocs/langs/fr_FR/accountancy.lang index 85d1f6a5b58..ff24ea0c023 100644 --- a/htdocs/langs/fr_FR/accountancy.lang +++ b/htdocs/langs/fr_FR/accountancy.lang @@ -224,8 +224,8 @@ GeneralLedgerSomeRecordWasNotRecorded=Certaines des opérations n'ont pu être e NoNewRecordSaved=Plus d'enregistrements à journaliser ListOfProductsWithoutAccountingAccount=Liste des produits non liés à un compte comptable ChangeBinding=Changer les liens -Accounted=Comptabilisé dans le grand livre -NotYetAccounted=Pas encore comptabilisé dans le grand livre +Accounted=Comptabilisé +NotYetAccounted=Pas encore comptabilisé ## Admin ApplyMassCategories=Application en masse des catégories From 14d7ffa53b268d07b97eb840fffbde290531d536 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Mon, 5 Mar 2018 21:16:01 +0100 Subject: [PATCH 18/20] Fix cancel and template to record stock movement/correction --- htdocs/product/stock/mouvement.php | 2 +- .../product/stock/tpl/stockcorrection.tpl.php | 20 +++++++++---------- .../product/stock/tpl/stocktransfer.tpl.php | 18 ++++++++--------- 3 files changed, 20 insertions(+), 20 deletions(-) diff --git a/htdocs/product/stock/mouvement.php b/htdocs/product/stock/mouvement.php index e7329f1d44a..7a82b2d7371 100644 --- a/htdocs/product/stock/mouvement.php +++ b/htdocs/product/stock/mouvement.php @@ -634,7 +634,7 @@ if ($resql) /* */ /* ************************************************************************** */ - if (empty($action) && $id > 0) + if ((empty($action) || $action == 'list') && $id > 0) { print "
\n"; diff --git a/htdocs/product/stock/tpl/stockcorrection.tpl.php b/htdocs/product/stock/tpl/stockcorrection.tpl.php index 732fa8c889d..d946a23bf70 100644 --- a/htdocs/product/stock/tpl/stockcorrection.tpl.php +++ b/htdocs/product/stock/tpl/stockcorrection.tpl.php @@ -68,8 +68,8 @@ if (empty($conf) || ! is_object($conf)) print '
'; if ($object->element == 'product') { - print ''; - print ''; + print ''; - print ''; + print ''; } - print ''; - print ''; + print ''; + print ''; print ''; // Purchase price print ''; - print ''; + print ''; print ''; if (! empty($conf->projet->enabled)) { print ''; print ''; } print ''; @@ -133,7 +133,7 @@ if (empty($conf) || ! is_object($conf)) print ''; print ''; print ''; print ''; print ''; diff --git a/htdocs/product/stock/tpl/stocktransfer.tpl.php b/htdocs/product/stock/tpl/stocktransfer.tpl.php index 18f6b831cf2..4c89b97622f 100644 --- a/htdocs/product/stock/tpl/stocktransfer.tpl.php +++ b/htdocs/product/stock/tpl/stocktransfer.tpl.php @@ -72,20 +72,20 @@ if (empty($conf) || ! is_object($conf)) print ''; if ($object->element == 'product') { - print ''; - print ''; + print ''; } if ($object->element == 'stock') { - print ''; - print ''; + print ''; } - print ''; print ''; @@ -125,11 +125,11 @@ if (empty($conf) || ! is_object($conf)) // Label $valformovementlabel=(GETPOST("label")?GETPOST("label"):$langs->trans("MovementTransferStock", $productref)); print ''; - print ''; + print ''; print ''; - print ''; + print ''; print ''; print '
'.$langs->trans("Fields").''.$langs->trans("Type").''.$langs->trans("Index").''.$langs->trans("FieldsLinked").'
$row[0]$row[1]$row[3]".$row[0]."".$row[1]."".$row[3]."".(empty($row[4])?'':$row[4])."".(empty($row[5])?'':$row[5])."".(empty($row[6])?'':$row[6])."".(empty($row[7])?'':$row[7])."".(isset($link[$row[0]][0])?$link[$row[0]][0]:'')."."; print (isset($link[$row[0]][1])?$link[$row[0]][1]:'')."
'.$langs->trans("Warehouse").''; + print ''.$langs->trans("Warehouse").''; print $formproduct->selectWarehouses((GETPOST("dwid")?GETPOST("dwid",'int'):(GETPOST('id_entrepot')?GETPOST('id_entrepot','int'):'ifone')), 'id_entrepot', 'warehouseopen,warehouseinternal', 1, 0, 0, '', 0, 0, null, 'minwidth100'); print '   '.$langs->trans("Product").''; - print $form->select_produits(GETPOST('product_id'), 'product_id', (empty($conf->global->STOCK_SUPPORTS_SERVICES)?'0':''), 20, 0, -1); + print ''.$langs->trans("Product").''; + print $form->select_produits(GETPOST('product_id'), 'product_id', (empty($conf->global->STOCK_SUPPORTS_SERVICES)?'0':''), 20, 0, -1, 2, '', 0, null, 0, 1, 0, 'maxwidth500'); print '   '; print ''.$langs->trans("NumberOfUnit").''.$langs->trans("NumberOfUnit").'
'.$langs->trans("UnitPurchaseValue").''.$langs->trans("UnitPurchaseValue").''.$langs->trans('Project').''; - $formproject->select_projects(); + $formproject->select_projects(0, '', 'projectid', 0, 0, 1, 0, 0, 0, 0, '', 0, 0, 'maxwidth300'); print '
'.$langs->trans("MovementLabel").''; - print ''; + print ''; print ''.$langs->trans("InventoryCode").'
'.$langs->trans("WarehouseSource").''; + print ''.$langs->trans("WarehouseSource").''; print $formproduct->selectWarehouses((GETPOST("dwid")?GETPOST("dwid",'int'):(GETPOST('id_entrepot')?GETPOST('id_entrepot','int'):'ifone')), 'id_entrepot', 'warehouseopen,warehouseinternal', 1); print ''.$langs->trans("Product").''; - print $form->select_produits(GETPOST('product_id'),'product_id',(empty($conf->global->STOCK_SUPPORTS_SERVICES)?'0':'')); + print ''.$langs->trans("Product").''; + print $form->select_produits(GETPOST('product_id'), 'product_id', (empty($conf->global->STOCK_SUPPORTS_SERVICES)?'0':''), 20, 0, -1, 2, '', 0, null, 0, 1, 0, 'maxwidth500'); print ''.$langs->trans("WarehouseTarget").''; + print ''.$langs->trans("WarehouseTarget").''; print $formproduct->selectWarehouses(GETPOST('id_entrepot_destination'), 'id_entrepot_destination', 'warehouseopen,warehouseinternal', 1); print '
'.$langs->trans("NumberOfUnit").'
'.$langs->trans("MovementLabel").''.$langs->trans("MovementLabel").''; - print ''; + print ''; print ''.$langs->trans("InventoryCode").''.$langs->trans("InventoryCode").'
'; From 7c95233e3c78f5e031ff08c9a6806b143e10a0ae Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Mon, 5 Mar 2018 17:06:14 +0100 Subject: [PATCH 19/20] FIX Trad and creation date in subscription create --- htdocs/adherents/class/subscription.class.php | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/htdocs/adherents/class/subscription.class.php b/htdocs/adherents/class/subscription.class.php index 8d4b1884bab..1c4007780b9 100644 --- a/htdocs/adherents/class/subscription.class.php +++ b/htdocs/adherents/class/subscription.class.php @@ -77,15 +77,17 @@ class Subscription extends CommonObject $this->error=$langs->trans("ErrorBadValueForDate"); return -1; } + if (empty($this->datec)) $this->datec = $now; + $this->db->begin(); $sql = "INSERT INTO ".MAIN_DB_PREFIX."subscription (fk_adherent, datec, dateadh, datef, subscription, note)"; - $sql.= " VALUES (".$this->fk_adherent.", '".$this->db->idate($now)."',"; + $sql.= " VALUES (".$this->fk_adherent.", '".$this->db->idate($this->datec)."',"; $sql.= " '".$this->db->idate($this->dateh)."',"; $sql.= " '".$this->db->idate($this->datef)."',"; $sql.= " ".$this->amount.","; - $sql.= " '".$this->db->escape($this->note)."')"; + $sql.= " '".$this->db->escape($this->note_public?$this->note_public:$this->note)."')"; $resql = $this->db->query($sql); if (! $resql) { @@ -324,6 +326,8 @@ class Subscription extends CommonObject global $langs; $result=''; + + $langs->load("members"); $label=$langs->trans("ShowSubscription").': '.$this->ref; $linkstart = ''; From 17e012e0ace7d912ec421fc197f4a8ef7a4974fc Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Mon, 5 Mar 2018 17:07:59 +0100 Subject: [PATCH 20/20] FIX Subscription not correctly log in blockedlog --- htdocs/blockedlog/admin/blockedlog_list.php | 4 +- htdocs/blockedlog/ajax/block-info.php | 2 +- htdocs/blockedlog/class/blockedlog.class.php | 54 ++++++++++++++++--- ..._modBlockedlog_ActionsBlockedLog.class.php | 6 ++- 4 files changed, 54 insertions(+), 12 deletions(-) diff --git a/htdocs/blockedlog/admin/blockedlog_list.php b/htdocs/blockedlog/admin/blockedlog_list.php index d508d1edceb..9410ef9be5e 100644 --- a/htdocs/blockedlog/admin/blockedlog_list.php +++ b/htdocs/blockedlog/admin/blockedlog_list.php @@ -474,7 +474,7 @@ if (is_array($blocks)) print ''.$block->ref_object.''; // Link to source object - print ''.$object_link.''; + print ''.$object_link.''; // Amount print ''.price($block->amounts).''; @@ -501,7 +501,7 @@ if (is_array($blocks)) print ''; - // Status note + // Note print ''; if (! $checkresult[$block->id] || ($loweridinerror && $block->id >= $loweridinerror)) // If error { diff --git a/htdocs/blockedlog/ajax/block-info.php b/htdocs/blockedlog/ajax/block-info.php index c8a9cbf70be..a092b13ca99 100644 --- a/htdocs/blockedlog/ajax/block-info.php +++ b/htdocs/blockedlog/ajax/block-info.php @@ -87,7 +87,7 @@ function formatObject($objtoshow, $prefix) { $s.=''.($prefix?$prefix.' > ':'').$key.''; $s.=''; - if (in_array($key, array('date','datef'))) + if (in_array($key, array('date','datef','dateh','datec','datem','datep'))) { $s.=dol_print_date($val, 'dayhour'); } diff --git a/htdocs/blockedlog/class/blockedlog.class.php b/htdocs/blockedlog/class/blockedlog.class.php index 3dc3ade52e5..13a2840e360 100644 --- a/htdocs/blockedlog/class/blockedlog.class.php +++ b/htdocs/blockedlog/class/blockedlog.class.php @@ -239,6 +239,17 @@ class BlockedLog $this->error++; } } + else if($this->element === 'subscription') { + require_once DOL_DOCUMENT_ROOT.'/adherents/class/subscription.class.php'; + + $object = new Subscription($this->db); + if ($object->fetch($this->fk_object)>0) { + return $object->getNomUrl(1); + } + else{ + $this->error++; + } + } else if ($this->action == 'MODULE_SET') { return 'System to track events into unalterable logs were enabled'; @@ -313,6 +324,10 @@ class BlockedLog { $this->date_object = $object->datepaid?$object->datepaid:$object->datep; } + elseif ($object->element=='subscription') + { + $this->date_object = $object->dateh; + } else { $this->date_object = $object->date; } @@ -323,7 +338,10 @@ class BlockedLog // id of object $this->fk_object = $object->id; + + // Set object_data $this->object_data=new stdClass(); + $arrayoffieldstoexclude = array('table_element','fields','ref_previous','ref_next','origin','origin_id','oldcopy','picto','error','modelpdf','table_element_line','linkedObjectsIds','linkedObjects','fk_delivery_address'); // Add thirdparty info if (empty($object->thirdparty) && method_exists($object, 'fetch_thirdparty')) $object->fetch_thirdparty(); @@ -333,7 +351,7 @@ class BlockedLog foreach($object->thirdparty as $key=>$value) { - if (in_array($key, array('fields'))) continue; // Discard some properties + if (in_array($key, $arrayoffieldstoexclude)) continue; // Discard some properties if (! in_array($key, array( 'name','name_alias','ref_ext','address','zip','town','state_code','country_code','idprof1','idprof2','idprof3','idprof4','idprof5','idprof6','phone','fax','email','barcode', 'tva_intra', 'localtax1_assuj', 'localtax1_value', 'localtax2_assuj', 'localtax2_value', 'managers', 'capital', 'typent_code', 'forme_juridique_code', 'code_client', 'code_fournisseur' @@ -349,7 +367,7 @@ class BlockedLog foreach($mysoc as $key=>$value) { - if (in_array($key, array('fields'))) continue; // Discard some properties + if (in_array($key, $arrayoffieldstoexclude)) continue; // Discard some properties if (! in_array($key, array( 'name','name_alias','ref_ext','address','zip','town','state_code','country_code','idprof1','idprof2','idprof3','idprof4','idprof5','idprof6','phone','fax','email','barcode', 'tva_intra', 'localtax1_assuj', 'localtax1_value', 'localtax2_assuj', 'localtax2_value', 'managers', 'capital', 'typent_code', 'forme_juridique_code', 'code_client', 'code_fournisseur' @@ -366,12 +384,11 @@ class BlockedLog } // Field specific to object - if ($this->element == 'facture') { foreach($object as $key=>$value) { - if (in_array($key, array('fields'))) continue; // Discard some properties + if (in_array($key, $arrayoffieldstoexclude)) continue; // Discard some properties if (! in_array($key, array( 'ref','facnumber','ref_client','ref_supplier','date','datef','type','total_ht','total_tva','total_ttc','localtax1','localtax2','revenuestamp','datepointoftax','note_public','lines' ))) continue; // Discard if not into a dedicated list @@ -402,7 +419,7 @@ class BlockedLog { foreach($object as $key=>$value) { - if (in_array($key, array('fields'))) continue; // Discard some properties + if (in_array($key, $arrayoffieldstoexclude)) continue; // Discard some properties if (! in_array($key, array( 'ref','facnumber','ref_client','ref_supplier','date','datef','type','total_ht','total_tva','total_ttc','localtax1','localtax2','revenuestamp','datepointoftax','note_public' ))) continue; // Discard if not into a dedicated list @@ -498,7 +515,7 @@ class BlockedLog $paymentpart->thirdparty = new stdClass(); foreach($tmpobject->thirdparty as $key=>$value) { - if (in_array($key, array('fields'))) continue; // Discard some properties + if (in_array($key, $arrayoffieldstoexclude)) continue; // Discard some properties if (! in_array($key, array( 'name','name_alias','ref_ext','address','zip','town','state_code','country_code','idprof1','idprof2','idprof3','idprof4','idprof5','idprof6','phone','fax','email','barcode', 'tva_intra', 'localtax1_assuj', 'localtax1_value', 'localtax2_assuj', 'localtax2_value', 'managers', 'capital', 'typent_code', 'forme_juridique_code', 'code_client', 'code_fournisseur' @@ -515,7 +532,7 @@ class BlockedLog { foreach($tmpobject as $key=>$value) { - if (in_array($key, array('fields'))) continue; // Discard some properties + if (in_array($key, $arrayoffieldstoexclude)) continue; // Discard some properties if (! in_array($key, array( 'ref','facnumber','ref_client','ref_supplier','date','datef','type','total_ht','total_tva','total_ttc','localtax1','localtax2','revenuestamp','datepointoftax','note_public' ))) continue; // Discard if not into a dedicated list @@ -542,6 +559,29 @@ class BlockedLog if (! empty($object->newref)) $this->object_data->ref = $object->newref; } + elseif($this->element == 'subscription') + { + foreach($object as $key=>$value) + { + if (in_array($key, $arrayoffieldstoexclude)) continue; // Discard some properties + if (! in_array($key, array( + 'id','datec','dateh','datef','fk_adherent','amount','import_key','statut','note' + ))) continue; // Discard if not into a dedicated list + if (!is_object($value)) $this->object_data->{$key} = $value; + } + + if (! empty($object->newref)) $this->object_data->ref = $object->newref; + } + else // Generic case + { + foreach($object as $key=>$value) + { + if (in_array($key, $arrayoffieldstoexclude)) continue; // Discard some properties + if (!is_object($value)) $this->object_data->{$key} = $value; + } + + if (! empty($object->newref)) $this->object_data->ref = $object->newref; + } return 1; } diff --git a/htdocs/core/triggers/interface_50_modBlockedlog_ActionsBlockedLog.class.php b/htdocs/core/triggers/interface_50_modBlockedlog_ActionsBlockedLog.class.php index ec0b0cb6941..f97d1400018 100644 --- a/htdocs/core/triggers/interface_50_modBlockedlog_ActionsBlockedLog.class.php +++ b/htdocs/core/triggers/interface_50_modBlockedlog_ActionsBlockedLog.class.php @@ -69,14 +69,16 @@ class InterfaceActionsBlockedLog extends DolibarrTriggers $amounts = 0; if ($action==='BILL_VALIDATE' || $action==='BILL_DELETE' || $action === 'BILL_SENTBYMAIL' || $action==='BILL_SUPPLIER_VALIDATE' || $action==='BILL_SUPPLIER_DELETE' || $action === 'BILL_SUPPLIER_SENTBYMAIL' - || $action==='MEMBER_SUBCRIPTION_CREATE' || $action==='MEMBER_SUBCRIPTION_MODIFY' || $action==='MEMBER_SUBCRIPTION_DELETE' + || $action==='MEMBER_SUBSCRIPTION_CREATE' || $action==='MEMBER_SUBSCRIPTION_MODIFY' || $action==='MEMBER_SUBSCRIPTION_DELETE' || $action==='DON_VALIDATE' || $action==='DON_MODIFY' || $action==='DON_DELETE' || (in_array($object->element, array('facture','suplier_invoice')) && $action === 'DOC_DOWNLOAD') || (in_array($object->element, array('facture','suplier_invoice')) && $action === 'DOC_PREVIEW') ) { $qualified++; - if ($action==='DON_VALIDATE') $amounts = (double) $object->amount; + if (in_array($action, array( + 'MEMBER_SUBSCRIPTION_CREATE','MEMBER_SUBSCRIPTION_MODIFY','MEMBER_SUBSCRIPTION_DELETE', + 'DON_VALIDATE','DON_MODIFY','DON_DELETE'))) $amounts = (double) $object->amount; else $amounts = (double) $object->total_ttc; } /*if ($action === 'BILL_PAYED' || $action==='BILL_UNPAYED'