From 66f6d1bfd4f2d569adbcbb9e9468856557cd986e Mon Sep 17 00:00:00 2001 From: atm-greg Date: Tue, 11 Feb 2020 15:57:49 +0100 Subject: [PATCH 01/15] add missing fields --- .../class/accountancyexport.class.php | 31 +++++++++---------- .../accountancy/class/bookkeeping.class.php | 4 +++ 2 files changed, 19 insertions(+), 16 deletions(-) diff --git a/htdocs/accountancy/class/accountancyexport.class.php b/htdocs/accountancy/class/accountancyexport.class.php index 46d3feae5b2..9b107367129 100644 --- a/htdocs/accountancy/class/accountancyexport.class.php +++ b/htdocs/accountancy/class/accountancyexport.class.php @@ -935,6 +935,7 @@ class AccountancyExport foreach ($objectLines as $line) { $date_document = dol_print_date($line->doc_date, '%Y%m%d'); $date_creation = dol_print_date($line->date_creation, '%Y%m%d'); + $date_lim_reglement = dol_print_date($line->date_lim_reglement, '%Y%m%d'); // TYPE $type_enregistrement = 'E'; // For write movement @@ -950,7 +951,7 @@ class AccountancyExport // LIBE print $line->label_operation.$separator; // DATH - print $line->date_lim_reglement.$separator; + print $date_lim_reglement.$separator; // CNPI if ($line->doc_type == 'supplier_invoice') { if ($line->montant < 0) { @@ -969,21 +970,19 @@ class AccountancyExport } print $nature_piece.$separator; // RACI - /* - if (! empty($line->subledger_account)) { - if ($line->doc_type == 'supplier_invoice') { - $racine_subledger_account = '40'; - } elseif ($line->doc_type == 'customer_invoice') { - $racine_subledger_account = '41'; - } else { - $nature_piece = ''; - } - print $racine_subledger_account . $separator; - } else { - print $separator; - } - */ - print $separator; // deprecated CPTG & CPTA use instead + // if (! empty($line->subledger_account)) { +// if ($line->doc_type == 'supplier_invoice') { +// $racine_subledger_account = '40'; +// } elseif ($line->doc_type == 'customer_invoice') { +// $racine_subledger_account = '41'; +// } else { +// $racine_subledger_account = ''; +// } +// } else { + $racine_subledger_account = ''; // for records of type E leave this field blank +// } + + print $racine_subledger_account . $separator; // deprecated CPTG & CPTA use instead // MONT print price(abs($line->montant), 0, '', 1, 2).$separator; // CODC diff --git a/htdocs/accountancy/class/bookkeeping.class.php b/htdocs/accountancy/class/bookkeeping.class.php index 6068e6ec0c1..7177e79b427 100644 --- a/htdocs/accountancy/class/bookkeeping.class.php +++ b/htdocs/accountancy/class/bookkeeping.class.php @@ -926,6 +926,7 @@ class BookKeeping extends CommonObject $sql .= " t.debit,"; $sql .= " t.credit,"; $sql .= " t.lettering_code,"; + $sql .= " t.date_lettering,"; $sql .= " t.montant,"; $sql .= " t.sens,"; $sql .= " t.fk_user_author,"; @@ -934,6 +935,7 @@ class BookKeeping extends CommonObject $sql .= " t.journal_label,"; $sql .= " t.piece_num,"; $sql .= " t.date_creation,"; + $sql .= " t.date_lim_reglement,"; $sql .= " t.tms as date_modification,"; $sql .= " t.date_export"; $sql .= ' FROM '.MAIN_DB_PREFIX.$this->table_element.' as t'; @@ -1006,12 +1008,14 @@ class BookKeeping extends CommonObject $line->montant = $obj->montant; $line->sens = $obj->sens; $line->lettering_code = $obj->lettering_code; + $line->date_lettering = $obj->date_lettering; $line->fk_user_author = $obj->fk_user_author; $line->import_key = $obj->import_key; $line->code_journal = $obj->code_journal; $line->journal_label = $obj->journal_label; $line->piece_num = $obj->piece_num; $line->date_creation = $this->db->jdate($obj->date_creation); + $line->date_lim_reglement = $this->db->jdate($obj->date_lim_reglement); $line->date_modification = $this->db->jdate($obj->date_modification); $line->date_export = $this->db->jdate($obj->date_export); From fc170c1081713a7b89e0a3daa6e014a96d5b6aa9 Mon Sep 17 00:00:00 2001 From: stickler-ci Date: Tue, 11 Feb 2020 15:20:46 +0000 Subject: [PATCH 02/15] Fixing style errors. --- .../class/accountancyexport.class.php | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/htdocs/accountancy/class/accountancyexport.class.php b/htdocs/accountancy/class/accountancyexport.class.php index 9b107367129..c7d14d905c9 100644 --- a/htdocs/accountancy/class/accountancyexport.class.php +++ b/htdocs/accountancy/class/accountancyexport.class.php @@ -971,16 +971,16 @@ class AccountancyExport print $nature_piece.$separator; // RACI // if (! empty($line->subledger_account)) { -// if ($line->doc_type == 'supplier_invoice') { -// $racine_subledger_account = '40'; -// } elseif ($line->doc_type == 'customer_invoice') { -// $racine_subledger_account = '41'; -// } else { -// $racine_subledger_account = ''; -// } -// } else { + // if ($line->doc_type == 'supplier_invoice') { + // $racine_subledger_account = '40'; + // } elseif ($line->doc_type == 'customer_invoice') { + // $racine_subledger_account = '41'; + // } else { + // $racine_subledger_account = ''; + // } + // } else { $racine_subledger_account = ''; // for records of type E leave this field blank -// } + // } print $racine_subledger_account . $separator; // deprecated CPTG & CPTA use instead // MONT From 02f268ea4e233bac5ec4a4fbacb9ec4c9bec1014 Mon Sep 17 00:00:00 2001 From: John Botella Date: Tue, 11 Feb 2020 16:54:27 +0100 Subject: [PATCH 03/15] FIX - hasDelay for retained warranty --- htdocs/compta/facture/class/facture.class.php | 34 +++++++++++++++++-- 1 file changed, 32 insertions(+), 2 deletions(-) diff --git a/htdocs/compta/facture/class/facture.class.php b/htdocs/compta/facture/class/facture.class.php index 9172993acc7..9411f543f35 100644 --- a/htdocs/compta/facture/class/facture.class.php +++ b/htdocs/compta/facture/class/facture.class.php @@ -4481,15 +4481,40 @@ class Facture extends CommonInvoice // Paid invoices have status STATUS_CLOSED if ($this->statut != Facture::STATUS_VALIDATED) return false; - return $this->date_lim_reglement < ($now - $conf->facture->client->warning_delay); + $hasDelay = $this->date_lim_reglement < ($now - $conf->facture->client->warning_delay); + if($hasDelay && !empty($this->retained_warranty) && !empty($this->retained_warranty_date_limit)) + { + $totalpaye = $this->getSommePaiement(); + $totalpaye = floatval($totalpaye); + $RetainedWarrantyAmount = $this->getRetainedWarrantyAmount(); + if($totalpaye >= 0 && $RetainedWarrantyAmount>= 0) + { + if( ($totalpaye < $this->total_ttc - $RetainedWarrantyAmount) && $this->date_lim_reglement < ($now - $conf->facture->client->warning_delay) ) + { + $hasDelay = 1; + } + elseif($totalpaye < $this->total_ttc && $this->retained_warranty_date_limit < ($now - $conf->facture->client->warning_delay) ) + { + $hasDelay = 1; + } + else + { + $hasDelay = 0; + } + } + } + + return $hasDelay; } /** + * @param int $rounding Minimum number of decimal to show. If 0, no change, if -1, we use min($conf->global->MAIN_MAX_DECIMALS_UNIT,$conf->global->MAIN_MAX_DECIMALS_TOT) * @return number or -1 if not available */ - public function getRetainedWarrantyAmount() + public function getRetainedWarrantyAmount($rounding = -1) { + global $conf; if (empty($this->retained_warranty)) { return -1; } @@ -4533,6 +4558,11 @@ class Facture extends CommonInvoice $retainedWarrantyAmount = $this->total_ttc * $this->retained_warranty / 100; } + if ($rounding < 0){ + $rounding=min($conf->global->MAIN_MAX_DECIMALS_UNIT,$conf->global->MAIN_MAX_DECIMALS_TOT); + return round($retainedWarrantyAmount, 2); + } + return $retainedWarrantyAmount; } From 27dd9aec9f2877bd977dd270115dfa1c4b99dfd3 Mon Sep 17 00:00:00 2001 From: stickler-ci Date: Tue, 11 Feb 2020 16:12:48 +0000 Subject: [PATCH 04/15] Fixing style errors. --- htdocs/compta/facture/class/facture.class.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/compta/facture/class/facture.class.php b/htdocs/compta/facture/class/facture.class.php index 9411f543f35..d4a7efd3cf4 100644 --- a/htdocs/compta/facture/class/facture.class.php +++ b/htdocs/compta/facture/class/facture.class.php @@ -4559,7 +4559,7 @@ class Facture extends CommonInvoice } if ($rounding < 0){ - $rounding=min($conf->global->MAIN_MAX_DECIMALS_UNIT,$conf->global->MAIN_MAX_DECIMALS_TOT); + $rounding=min($conf->global->MAIN_MAX_DECIMALS_UNIT, $conf->global->MAIN_MAX_DECIMALS_TOT); return round($retainedWarrantyAmount, 2); } From cc6313cdf3e37f32aa4bd57fb370fdef1f006c6c Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Tue, 11 Feb 2020 19:32:27 +0100 Subject: [PATCH 05/15] Fix import examples --- htdocs/core/modules/modUser.class.php | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/htdocs/core/modules/modUser.class.php b/htdocs/core/modules/modUser.class.php index 6e5924945c9..449ad1f5cf4 100644 --- a/htdocs/core/modules/modUser.class.php +++ b/htdocs/core/modules/modUser.class.php @@ -314,7 +314,8 @@ class modUser extends DolibarrModules 'u.birth'=>'^[0-9][0-9][0-9][0-9]-[0-9][0-9]-[0-9][0-9]$' ); $this->import_examplevalues_array[$r]=array( - 'u.lastname'=>"Doe", 'u.firstname'=>'John', 'u.login'=>'jdoe', 'u.employee'=>'0 or 1', + 'u.lastname'=>"Doe", 'u.firstname'=>'John', 'u.login'=>'jdoe', 'u.employee'=>'0 or 1', 'u.job'=>'CTO', 'u.gender'=>'0 or 1', + 'u.pass_crypted'=>'Encrypted password', 'u.fk_soc'=>'0 (internal user) or company name (external user)', 'u.datec'=>dol_print_date(dol_now(), '%Y-%m-%d'), 'u.address'=>"61 jump street", 'u.zip'=>"123456",'u.town'=>"Big town",'u.fk_country'=>'US, FR, DE...','u.office_phone'=>"0101010101",'u.office_fax'=>"0101010102", 'u.email'=>"test@mycompany.com",'u.salary'=>"10000",'u.note'=>"This is an example of note for record",'u.datec'=>"2015-01-01 or 2015-01-01 12:30:00", From 5459e4b821df1f24e256c56bc311fb98470cf5c2 Mon Sep 17 00:00:00 2001 From: ptibogxiv Date: Tue, 11 Feb 2020 20:11:37 +0100 Subject: [PATCH 06/15] Fix netmeasure update and display nb: netmeasure is for real weight, volume or piece; i'll try to introduce in v12 price by unit using this value ( needed for some business ie fruits, vegetables....) --- htdocs/product/card.php | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/htdocs/product/card.php b/htdocs/product/card.php index 6d36495d5fc..f62979f96d3 100644 --- a/htdocs/product/card.php +++ b/htdocs/product/card.php @@ -17,7 +17,7 @@ * Copyright (C) 2016 Meziane Sof * Copyright (C) 2017 Josep Lluís Amador * Copyright (C) 2019 Frédéric France - * Copyright (C) 2019 Thibault FOUCART + * Copyright (C) 2019-2020 Thibault FOUCART * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -1513,7 +1513,7 @@ else // Net Measure print ''.$langs->trans("NetMeasure").''; print ' '; - print $formproduct->selectMeasuringUnits($object->net_measure_units, '', 0, 0, 0); + print $formproduct->selectMeasuringUnits("net_measure_units", "", $object->net_measure_units, 0, 0); print ''; } } @@ -1955,7 +1955,7 @@ else print ''.$langs->trans("NetMeasure").''; if ($object->net_measure != '') { - print $object->net_measure." ".measuringUnitString(0, "weight", $object->net_measure_units); + print $object->net_measure." ".measuringUnitString($object->net_measure_units, "", ""); } else { From 558ccdd8b9ee4edfb1f524cfa81f56ee56f8fc10 Mon Sep 17 00:00:00 2001 From: ptibogxiv Date: Tue, 11 Feb 2020 20:20:34 +0100 Subject: [PATCH 07/15] Update card.php --- htdocs/product/card.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/product/card.php b/htdocs/product/card.php index f62979f96d3..9d126ca96d9 100644 --- a/htdocs/product/card.php +++ b/htdocs/product/card.php @@ -1955,7 +1955,7 @@ else print ''.$langs->trans("NetMeasure").''; if ($object->net_measure != '') { - print $object->net_measure." ".measuringUnitString($object->net_measure_units, "", ""); + print $object->net_measure." ".measuringUnitString($object->net_measure_units); } else { From f17c7f4cb3ca1914282a619e0758c765327304e0 Mon Sep 17 00:00:00 2001 From: ptibogxiv Date: Tue, 11 Feb 2020 20:21:53 +0100 Subject: [PATCH 08/15] fix for unit with rowid (netmeasure) --- htdocs/core/lib/product.lib.php | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/htdocs/core/lib/product.lib.php b/htdocs/core/lib/product.lib.php index 9cf28ff20ee..f58af3500c0 100644 --- a/htdocs/core/lib/product.lib.php +++ b/htdocs/core/lib/product.lib.php @@ -520,7 +520,14 @@ function measuringUnitString($unit, $measuring_style = '', $scale = '', $use_sho require_once DOL_DOCUMENT_ROOT.'/core/class/cunits.class.php'; $measuringUnits= new CUnits($db); - if ($scale !== '') + if ($measuring_style == '' && $scale == '') + { + $arrayforfilter = array( + 't.rowid' => $unit, + 't.active' => 1 + ); + } + elseif ($scale !== '') { $arrayforfilter = array( 't.scale' => $scale, From e74df397eb08f0c9a196e167a469547b0f689eb7 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Wed, 12 Feb 2020 17:28:18 +0100 Subject: [PATCH 09/15] FIX #13094 --- htdocs/core/lib/security.lib.php | 3 ++ htdocs/user/card.php | 57 +++++++++++++++++++++++--------- 2 files changed, 44 insertions(+), 16 deletions(-) diff --git a/htdocs/core/lib/security.lib.php b/htdocs/core/lib/security.lib.php index 5a7b8342bd6..b811fe70abf 100644 --- a/htdocs/core/lib/security.lib.php +++ b/htdocs/core/lib/security.lib.php @@ -311,6 +311,9 @@ function restrictedArea($user, $features, $objectid = 0, $tableandshare = '', $f { foreach ($feature2 as $subfeature) { + if ($subfeature == 'user' && $user->id == $objectid && $user->rights->user->self->creer) continue; // User can edit its own card + if ($subfeature == 'user' && $user->id == $objectid && $user->rights->user->self->password) continue; // User can edit its own password + if (empty($user->rights->$feature->$subfeature->creer) && empty($user->rights->$feature->$subfeature->write) && empty($user->rights->$feature->$subfeature->create)) { diff --git a/htdocs/user/card.php b/htdocs/user/card.php index 7feaf2911fa..d12f6064131 100644 --- a/htdocs/user/card.php +++ b/htdocs/user/card.php @@ -40,6 +40,7 @@ require_once DOL_DOCUMENT_ROOT.'/user/class/user.class.php'; require_once DOL_DOCUMENT_ROOT.'/user/class/usergroup.class.php'; require_once DOL_DOCUMENT_ROOT.'/contact/class/contact.class.php'; require_once DOL_DOCUMENT_ROOT.'/core/class/html.formfile.class.php'; +require_once DOL_DOCUMENT_ROOT.'/core/lib/company.lib.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/images.lib.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/usergroups.lib.php'; require_once DOL_DOCUMENT_ROOT.'/core/class/extrafields.class.php'; @@ -85,8 +86,7 @@ if ($id) $socid = 0; if ($user->socid > 0) $socid = $user->socid; $feature2 = 'user'; - -$result = restrictedArea($user, 'user', $id, 'user&user', $feature2); +$result = restrictedArea($user, 'user', $id, 'user', $feature2); if ($user->id <> $id && !$canreaduser) accessforbidden(); @@ -567,12 +567,14 @@ if (empty($reshook)) { $object->fetch($id); - $object->oldcopy = clone $object; + if (GETPOST("password", "none")) { // If pass is empty, we do not change it. + $object->oldcopy = clone $object; - $ret = $object->setPassword($user, GETPOST("password")); - if ($ret < 0) - { - setEventMessages($object->error, $object->errors, 'errors'); + $ret = $object->setPassword($user, GETPOST("password", "none")); + if ($ret < 0) + { + setEventMessages($object->error, $object->errors, 'errors'); + } } } } @@ -1551,7 +1553,7 @@ else else { if ($user->admin) $valuetoshow .= ($valuetoshow ? (' '.$langs->trans("or").' ') : '').$langs->trans("Crypted").': '.$object->pass_indatabase_crypted; - else $valuetoshow .= ($valuetoshow ? (' '.$langs->trans("or").' ') : '').$langs->trans("Hidden"); + else $valuetoshow .= ($valuetoshow ? (' '.$langs->trans("or").' ') : '').''.$langs->trans("Hidden").''; } } @@ -2307,7 +2309,11 @@ else print ''.$langs->trans("Gender").''; print ''; $arraygender = array('man'=>$langs->trans("Genderman"), 'woman'=>$langs->trans("Genderwoman")); - print $form->selectarray('gender', $arraygender, GETPOST('gender') ?GETPOST('gender') : $object->gender, 1); + if ($caneditfield) { + print $form->selectarray('gender', $arraygender, GETPOSTISSET('gender') ?GETPOST('gender') : $object->gender, 1); + } else { + print $arraygender[$object->gender]; + } print ''; // Employee @@ -2387,31 +2393,50 @@ else // Address print ''.$form->editfieldkey('Address', 'address', '', $object, 0).''; - print ''; + if ($caneditfield) print ''; + print ''; // Zip print ''.$form->editfieldkey('Zip', 'zipcode', '', $object, 0).''; - print $formcompany->select_ziptown($object->zip, 'zipcode', array('town', 'selectcountry_id', 'state_id'), 6); + if ($caneditfield) { + print $formcompany->select_ziptown($object->zip, 'zipcode', array('town', 'selectcountry_id', 'state_id'), 6); + } else { + print $object->zip; + } print ''; // Town print ''.$form->editfieldkey('Town', 'town', '', $object, 0).''; - print $formcompany->select_ziptown($object->town, 'town', array('zipcode', 'selectcountry_id', 'state_id')); + if ($caneditfield) { + print $formcompany->select_ziptown($object->town, 'town', array('zipcode', 'selectcountry_id', 'state_id')); + } else { + print $object->town; + } print ''; // Country print ''.$form->editfieldkey('Country', 'selectcounty_id', '', $object, 0).''; - print $form->select_country((GETPOST('country_id') != '' ?GETPOST('country_id') : $object->country_id), 'country_id'); - if ($user->admin) print info_admin($langs->trans("YouCanChangeValuesForThisListFromDictionarySetup"), 1); + if ($caneditfield) { + print $form->select_country((GETPOST('country_id') != '' ?GETPOST('country_id') : $object->country_id), 'country_id'); + if ($user->admin) print info_admin($langs->trans("YouCanChangeValuesForThisListFromDictionarySetup"), 1); + } else { + $countrylabel = getCountry($object->country_id, '0'); + print $countrylabel; + } print ''; // State if (empty($conf->global->USER_DISABLE_STATE)) { print ''.$form->editfieldkey('State', 'state_id', '', $object, 0).''; - print $formcompany->select_state($object->state_id, $object->country_code, 'state_id'); + if ($caneditfield) { + print $formcompany->select_state($object->state_id, $object->country_code, 'state_id'); + } else { + print $object->state_label; + } print ''; } From 03a8414ba8fdcb1153e90c442b6ea875d9bc4bbd Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Wed, 12 Feb 2020 18:21:45 +0100 Subject: [PATCH 10/15] FIX #13085 --- htdocs/accountancy/class/accountancyexport.class.php | 1 + 1 file changed, 1 insertion(+) diff --git a/htdocs/accountancy/class/accountancyexport.class.php b/htdocs/accountancy/class/accountancyexport.class.php index 46d3feae5b2..c8160c7bc96 100644 --- a/htdocs/accountancy/class/accountancyexport.class.php +++ b/htdocs/accountancy/class/accountancyexport.class.php @@ -239,6 +239,7 @@ class AccountancyExport $filename = 'general_ledger-'.$this->getFormatCode($formatexportset); $type_export = 'general_ledger'; + global $db; // The tpl file use $db include DOL_DOCUMENT_ROOT.'/accountancy/tpl/export_journal.tpl.php'; From 9b0b5f755b9568b89d305778ff044de6ce27cd63 Mon Sep 17 00:00:00 2001 From: Thomas Date: Wed, 12 Feb 2020 13:50:58 +0100 Subject: [PATCH 11/15] Fixed missing trigger on contact delete --- htdocs/societe/class/api_contacts.class.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/societe/class/api_contacts.class.php b/htdocs/societe/class/api_contacts.class.php index cfddddb7b96..6b6c5a439a6 100644 --- a/htdocs/societe/class/api_contacts.class.php +++ b/htdocs/societe/class/api_contacts.class.php @@ -293,7 +293,7 @@ class Contacts extends DolibarrApi throw new RestException(401, 'Access not allowed for login ' . DolibarrApiAccess::$user->login); } $this->contact->oldcopy = clone $this->contact; - return $this->contact->delete($id); + return $this->contact->delete(); } /** From bd0666bf539708efe5860028d8900035c6829a04 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Wed, 12 Feb 2020 18:35:15 +0100 Subject: [PATCH 12/15] Update product.lib.php --- htdocs/core/lib/product.lib.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/core/lib/product.lib.php b/htdocs/core/lib/product.lib.php index f58af3500c0..54555eb018c 100644 --- a/htdocs/core/lib/product.lib.php +++ b/htdocs/core/lib/product.lib.php @@ -504,7 +504,7 @@ function measuring_units_string($scale = '', $measuring_style = '', $unit = 0, $ * Return translation label of a unit key * * @param int $unit ID of unit (rowid in llx_c_units table) - * @param string $measuring_style Style of unit: weight, volume,... + * @param string $measuring_style Style of unit: 'weight', 'volume', ..., '' = 'net_measure' for option PRODUCT_ADD_NET_MEASURE * @param string $scale Scale of unit: '0', '-3', '6', ... * @param int $use_short_label 1=Use short label ('g' instead of 'gram'). Short labels are not translated. * @return string Unit string From d419315e98cc7eca08be709a61ed42199eeede26 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Wed, 12 Feb 2020 19:36:29 +0100 Subject: [PATCH 13/15] FIX #13048 --- htdocs/modulebuilder/template/mymoduleindex.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/htdocs/modulebuilder/template/mymoduleindex.php b/htdocs/modulebuilder/template/mymoduleindex.php index 99ed522e273..fe2f932c129 100644 --- a/htdocs/modulebuilder/template/mymoduleindex.php +++ b/htdocs/modulebuilder/template/mymoduleindex.php @@ -47,8 +47,8 @@ $langs->loadLangs(array("mymodule@mymodule")); $action=GETPOST('action', 'alpha'); -// Securite acces client -if (! $user->rights->mymodule->read) accessforbidden(); +// Security check +//if (! $user->rights->mymodule->myobject->read) accessforbidden(); $socid=GETPOST('socid', 'int'); if (isset($user->socid) && $user->socid > 0) { From 3f4c787c840690c36f533ae7330b0a5d3fb5b4a9 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Wed, 12 Feb 2020 20:22:53 +0100 Subject: [PATCH 14/15] Fix physical stock were truncated in product/reassort page --- htdocs/product/reassort.php | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/htdocs/product/reassort.php b/htdocs/product/reassort.php index c107693b8c6..512d5ff2b89 100644 --- a/htdocs/product/reassort.php +++ b/htdocs/product/reassort.php @@ -256,14 +256,14 @@ if ($resql) } $param = ''; - if ($tosell) $param .= "&tosell=".$tosell; - if ($tobuy) $param .= "&tobuy=".$tobuy; - if ($type) $param .= "&type=".$type; - if ($fourn_id) $param .= "&fourn_id=".$fourn_id; - if ($snom) $param .= "&snom=".$snom; - if ($sref) $param .= "&sref=".$sref; - if ($toolowstock) $param .= "&toolowstock=".$toolowstock; - if ($search_categ) $param .= "&search_categ=".$search_categ; + if ($tosell) $param .= "&tosell=".urlencode($tosell); + if ($tobuy) $param .= "&tobuy=".urlencode($tobuy); + if ($type) $param .= "&type=".urlencode($type); + if ($fourn_id) $param .= "&fourn_id=".urlencode($fourn_id); + if ($snom) $param .= "&snom=".urlencode($snom); + if ($sref) $param .= "&sref=".urlencode($sref); + if ($toolowstock) $param .= "&toolowstock=".urlencode($toolowstock); + if ($search_categ) $param .= "&search_categ=".urlencode($search_categ); $formProduct = new FormProduct($db); $formProduct->loadWarehouses(); @@ -362,7 +362,7 @@ if ($resql) // Real stock print ''; if ($objp->seuil_stock_alerte != '' && ($objp->stock_physique < $objp->seuil_stock_alerte)) print img_warning($langs->trans("StockTooLow")).' '; - print $objp->stock_physique | 0; + print price2num($objp->stock_physique, 'MS'); print ''; // Details per warehouse From 83b5fe3c71117676aa481b967484a161311ed1f3 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Wed, 12 Feb 2020 20:24:58 +0100 Subject: [PATCH 15/15] FIX #13077 Replace left join with inner join (left join was useless) --- htdocs/product/stock/replenish.php | 58 +++++++++++++++--------------- 1 file changed, 29 insertions(+), 29 deletions(-) diff --git a/htdocs/product/stock/replenish.php b/htdocs/product/stock/replenish.php index 5164b72fa4a..427a8a18785 100644 --- a/htdocs/product/stock/replenish.php +++ b/htdocs/product/stock/replenish.php @@ -195,6 +195,7 @@ if ($action == 'order' && isset($_POST['valid'])) //we now know how many orders we need and what lines they have $i = 0; + $fail = 0; $orders = array(); $suppliersid = array_keys($suppliers); foreach ($suppliers as $supplier) @@ -311,6 +312,7 @@ if (!empty($conf->global->STOCK_ALLOW_ADD_LIMIT_STOCK_BY_WAREHOUSE) && $fk_entre $sql .= ' pse.desiredstock as desiredstockpse, pse.seuil_stock_alerte as seuil_stock_alertepse,'; } $sql .= ' '.$sqldesiredtock.' as desiredstockcombined, '.$sqlalertstock.' as seuil_stock_alertecombined,'; +$sql .= ' s.fk_product,'; $sql .= ' SUM('.$db->ifsql("s.reel IS NULL", "0", "s.reel").') as stock_physique'; // Add fields from hooks @@ -319,8 +321,8 @@ $reshook = $hookmanager->executeHooks('printFieldListSelect', $parameters); // N $sql .= $hookmanager->resPrint; $sql .= ' FROM '.MAIN_DB_PREFIX.'product as p'; -$sql .= ' LEFT JOIN '.MAIN_DB_PREFIX.'product_stock as s'; -$sql .= ' ON (p.rowid = s.fk_product AND s.fk_entrepot IN (SELECT ent.rowid FROM '.MAIN_DB_PREFIX.'entrepot AS ent WHERE ent.entity IN('.getEntity('stock').')))'; +$sql .= ' LEFT JOIN '.MAIN_DB_PREFIX.'product_stock as s ON p.rowid = s.fk_product'; +$sql .= ' LEFT JOIN '.MAIN_DB_PREFIX.'entrepot AS ent ON s.fk_entrepot = ent.rowid AND ent.entity IN('.getEntity('stock').')'; if ($fk_supplier > 0) { $sql .= ' INNER JOIN '.MAIN_DB_PREFIX.'product_fournisseur_price pfp ON (pfp.fk_product = p.rowid AND pfp.fk_soc = '.$fk_supplier.')'; } @@ -360,36 +362,34 @@ $sql .= ', s.fk_product'; if ($usevirtualstock) { - $sqlCommandesCli = "(SELECT ".$db->ifsql("SUM(cd.qty) IS NULL", "0", "SUM(cd.qty)")." as qty"; - $sqlCommandesCli .= " FROM ".MAIN_DB_PREFIX."commandedet as cd"; - $sqlCommandesCli .= " LEFT JOIN ".MAIN_DB_PREFIX."commande as c ON (c.rowid = cd.fk_commande)"; - $sqlCommandesCli .= " WHERE c.entity IN (".getEntity('commande').")"; - $sqlCommandesCli .= " AND cd.fk_product = p.rowid"; - $sqlCommandesCli .= " AND c.fk_statut IN (1,2))"; + $sqlCommandesCli = "(SELECT ".$db->ifsql("SUM(cd1.qty) IS NULL", "0", "SUM(cd1.qty)")." as qty"; // We need the ifsql because if result is 0 for product p.rowid, we must return 0 and not NULL + $sqlCommandesCli .= " FROM ".MAIN_DB_PREFIX."commandedet as cd1, ".MAIN_DB_PREFIX."commande as c1"; + $sqlCommandesCli .= " WHERE c1.rowid = cd1.fk_commande AND c1.entity IN (".getEntity('commande').")"; + $sqlCommandesCli .= " AND cd1.fk_product = p.rowid"; + $sqlCommandesCli .= " AND c1.fk_statut IN (1,2))"; - $sqlExpeditionsCli = "(SELECT ".$db->ifsql("SUM(ed.qty) IS NULL", "0", "SUM(ed.qty)")." as qty"; - $sqlExpeditionsCli .= " FROM ".MAIN_DB_PREFIX."expedition as e"; - $sqlExpeditionsCli .= " LEFT JOIN ".MAIN_DB_PREFIX."expeditiondet as ed ON (ed.fk_expedition = e.rowid)"; - $sqlExpeditionsCli .= " LEFT JOIN ".MAIN_DB_PREFIX."commandedet as cd ON (cd.rowid = ed.fk_origin_line)"; - $sqlExpeditionsCli .= " LEFT JOIN ".MAIN_DB_PREFIX."commande as c ON (c.rowid = cd.fk_commande)"; - $sqlExpeditionsCli .= " WHERE e.entity IN (".getEntity('expedition').")"; - $sqlExpeditionsCli .= " AND cd.fk_product = p.rowid"; - $sqlExpeditionsCli .= " AND e.fk_statut IN (1,2))"; + $sqlExpeditionsCli = "(SELECT ".$db->ifsql("SUM(ed2.qty) IS NULL", "0", "SUM(ed2.qty)")." as qty"; // We need the ifsql because if result is 0 for product p.rowid, we must return 0 and not NULL + $sqlExpeditionsCli .= " FROM ".MAIN_DB_PREFIX."expedition as e2,"; + $sqlExpeditionsCli .= " ".MAIN_DB_PREFIX."expeditiondet as ed2,"; + $sqlExpeditionsCli .= " ".MAIN_DB_PREFIX."commandedet as cd2"; + $sqlExpeditionsCli .= " WHERE ed2.fk_expedition = e2.rowid AND cd2.rowid = ed2.fk_origin_line AND e2.entity IN (".getEntity('expedition').")"; + $sqlExpeditionsCli .= " AND cd2.fk_product = p.rowid"; + $sqlExpeditionsCli .= " AND e2.fk_statut IN (1,2))"; - $sqlCommandesFourn = "(SELECT ".$db->ifsql("SUM(cd.qty) IS NULL", "0", "SUM(cd.qty)")." as qty"; - $sqlCommandesFourn .= " FROM ".MAIN_DB_PREFIX."commande_fournisseurdet as cd"; - $sqlCommandesFourn .= ", ".MAIN_DB_PREFIX."commande_fournisseur as c"; - $sqlCommandesFourn .= " WHERE c.rowid = cd.fk_commande"; - $sqlCommandesFourn .= " AND c.entity IN (".getEntity('supplier_order').")"; - $sqlCommandesFourn .= " AND cd.fk_product = p.rowid"; - $sqlCommandesFourn .= " AND c.fk_statut IN (3,4))"; + $sqlCommandesFourn = "(SELECT ".$db->ifsql("SUM(cd3.qty) IS NULL", "0", "SUM(cd3.qty)")." as qty"; // We need the ifsql because if result is 0 for product p.rowid, we must return 0 and not NULL + $sqlCommandesFourn .= " FROM ".MAIN_DB_PREFIX."commande_fournisseurdet as cd3,"; + $sqlCommandesFourn .= " ".MAIN_DB_PREFIX."commande_fournisseur as c3"; + $sqlCommandesFourn .= " WHERE c3.rowid = cd3.fk_commande"; + $sqlCommandesFourn .= " AND c3.entity IN (".getEntity('supplier_order').")"; + $sqlCommandesFourn .= " AND cd3.fk_product = p.rowid"; + $sqlCommandesFourn .= " AND c3.fk_statut IN (3,4))"; - $sqlReceptionFourn = "(SELECT ".$db->ifsql("SUM(fd.qty) IS NULL", "0", "SUM(fd.qty)")." as qty"; - $sqlReceptionFourn .= " FROM ".MAIN_DB_PREFIX."commande_fournisseur as cf"; - $sqlReceptionFourn .= " LEFT JOIN ".MAIN_DB_PREFIX."commande_fournisseur_dispatch as fd ON (fd.fk_commande = cf.rowid)"; - $sqlReceptionFourn .= " WHERE cf.entity IN (".getEntity('supplier_order').")"; - $sqlReceptionFourn .= " AND fd.fk_product = p.rowid"; - $sqlReceptionFourn .= " AND cf.fk_statut IN (3,4))"; + $sqlReceptionFourn = "(SELECT ".$db->ifsql("SUM(fd4.qty) IS NULL", "0", "SUM(fd4.qty)")." as qty"; // We need the ifsql because if result is 0 for product p.rowid, we must return 0 and not NULL + $sqlReceptionFourn .= " FROM ".MAIN_DB_PREFIX."commande_fournisseur as cf4,"; + $sqlReceptionFourn .= " ".MAIN_DB_PREFIX."commande_fournisseur_dispatch as fd4"; + $sqlReceptionFourn .= " WHERE fd4.fk_commande = cf4.rowid AND cf4.entity IN (".getEntity('supplier_order').")"; + $sqlReceptionFourn .= " AND fd4.fk_product = p.rowid"; + $sqlReceptionFourn .= " AND cf4.fk_statut IN (3,4))"; $sql .= ' HAVING (('.$sqldesiredtock.' >= 0 AND ('.$sqldesiredtock.' > SUM('.$db->ifsql("s.reel IS NULL", "0", "s.reel").')'; $sql .= ' - ('.$sqlCommandesCli.' - '.$sqlExpeditionsCli.') + ('.$sqlCommandesFourn.' - '.$sqlReceptionFourn.')))';