From 40fe3849dc0df5f0bf1ece51a6ebc5794fd3687f Mon Sep 17 00:00:00 2001 From: Regis Houssin Date: Mon, 12 Feb 2018 08:21:35 +0100 Subject: [PATCH 01/21] Fix: avoid Warning: A non-numeric value encountered --- htdocs/product/class/product.class.php | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/htdocs/product/class/product.class.php b/htdocs/product/class/product.class.php index e6439031146..06e234ff0c0 100644 --- a/htdocs/product/class/product.class.php +++ b/htdocs/product/class/product.class.php @@ -1649,7 +1649,7 @@ class Product extends CommonObject * @param string $newdefaultvatcode Default vat code * @return int <0 if KO, >0 if OK */ - function updatePrice($newprice, $newpricebase, $user, $newvat='',$newminprice='', $level=0, $newnpr=0, $newpbq=0, $ignore_autogen=0, $localtaxes_array=array(), $newdefaultvatcode='') + function updatePrice($newprice, $newpricebase, $user, $newvat='',$newminprice=0, $level=0, $newnpr=0, $newpbq=0, $ignore_autogen=0, $localtaxes_array=array(), $newdefaultvatcode='') { global $conf,$langs; @@ -1677,7 +1677,7 @@ class Product extends CommonObject return -1; } - if ($newprice!='' || $newprice==0) + if ($newprice != '' || $newprice == 0) { if ($newpricebase == 'TTC') { @@ -1685,7 +1685,7 @@ class Product extends CommonObject $price = price2num($newprice) / (1 + ($newvat / 100)); $price = price2num($price,'MU'); - if ($newminprice!='' || $newminprice==0) + if ($newminprice != '' || $newminprice == 0) { $price_min_ttc = price2num($newminprice,'MU'); $price_min = price2num($newminprice) / (1 + ($newvat / 100)); @@ -1703,7 +1703,7 @@ class Product extends CommonObject $price_ttc = ( $newnpr != 1 ) ? price2num($newprice) * (1 + ($newvat / 100)) : $price; $price_ttc = price2num($price_ttc,'MU'); - if ($newminprice!='' || $newminprice==0) + if ($newminprice != '' || $newminprice == 0) { $price_min = price2num($newminprice,'MU'); $price_min_ttc = price2num($newminprice) * (1 + ($newvat / 100)); From f37d48233183d8fc1c7cf24a167d83cfd013c696 Mon Sep 17 00:00:00 2001 From: florian HENRY Date: Fri, 9 Mar 2018 11:37:23 +0100 Subject: [PATCH 02/21] fix warning and sql error --- htdocs/blockedlog/class/blockedlog.class.php | 1 + htdocs/core/modules/modFournisseur.class.php | 6 +++++- htdocs/holiday/define_holiday.php | 5 +++-- 3 files changed, 9 insertions(+), 3 deletions(-) diff --git a/htdocs/blockedlog/class/blockedlog.class.php b/htdocs/blockedlog/class/blockedlog.class.php index 8c35ec11834..77bf90e2717 100644 --- a/htdocs/blockedlog/class/blockedlog.class.php +++ b/htdocs/blockedlog/class/blockedlog.class.php @@ -103,6 +103,7 @@ class BlockedLog public $ref_object = ''; public $object_data = null; + public $user_fullname=''; /** * Array of tracked event codes diff --git a/htdocs/core/modules/modFournisseur.class.php b/htdocs/core/modules/modFournisseur.class.php index 9e8bdc8ea03..d8ed86907fd 100644 --- a/htdocs/core/modules/modFournisseur.class.php +++ b/htdocs/core/modules/modFournisseur.class.php @@ -531,7 +531,11 @@ class modFournisseur extends DolibarrModules case 'sellist': $tmp=''; $tmpparam=unserialize($obj->param); // $tmp ay be array 'options' => array 'c_currencies:code_iso:code_iso' => null - if ($tmpparam['options'] && is_array($tmpparam['options'])) $tmp=array_shift(array_keys($tmpparam['options'])); + + if ($tmpparam['options'] && is_array($tmpparam['options'])) { + $tmpparam_param_key=array_keys($tmpparam['options']); + $tmp=array_shift($tmpparam_param_key); + } if (preg_match('/[a-z0-9_]+:[a-z0-9_]+:[a-z0-9_]+/', $tmp)) $typeFilter="List:".$tmp; break; } diff --git a/htdocs/holiday/define_holiday.php b/htdocs/holiday/define_holiday.php index a7d4789468e..e5bd8c0e8c0 100644 --- a/htdocs/holiday/define_holiday.php +++ b/htdocs/holiday/define_holiday.php @@ -216,8 +216,9 @@ if (empty($user->rights->holiday->read_all)) $userchilds=$user->getAllChildIds(1); $filters.=' AND u.rowid IN ('.join(', ',$userchilds).')'; } - -$filters.=natural_search(array('u.firstname','u.lastname'), $search_name); +if (!empty($search_name)) { + $filters.=natural_search(array('u.firstname','u.lastname'), $search_name); +} if ($search_supervisor > 0) $filters.=natural_search(array('u.fk_user'), $search_supervisor, 2); $listUsers = $holiday->fetchUsers(false, true, $filters); From ee557768865200c759948872bd4aa6919f0b811a Mon Sep 17 00:00:00 2001 From: Romain DELVAL Date: Fri, 9 Mar 2018 12:38:28 +0100 Subject: [PATCH 03/21] FIX Duplicate product_type asignement on order addline On addline order method, ther is a duplicate assignation on line->product_type before call to "insert" method. The second assignement always make product_type to "0" while it was fetched from product himsel like it was made on first asignement few lines above --- htdocs/commande/class/commande.class.php | 1 - 1 file changed, 1 deletion(-) diff --git a/htdocs/commande/class/commande.class.php b/htdocs/commande/class/commande.class.php index c107dff6960..b7b92eb997d 100644 --- a/htdocs/commande/class/commande.class.php +++ b/htdocs/commande/class/commande.class.php @@ -1405,7 +1405,6 @@ class Commande extends CommonOrder $this->line->total_localtax1=$total_localtax1; $this->line->total_localtax2=$total_localtax2; $this->line->total_ttc=$total_ttc; - $this->line->product_type=$type; $this->line->special_code=$special_code; $this->line->origin=$origin; $this->line->origin_id=$origin_id; From 1c966d4769b5257ee68dfd6f6a8ed5ed70f2ddb3 Mon Sep 17 00:00:00 2001 From: florian HENRY Date: Fri, 9 Mar 2018 12:57:58 +0100 Subject: [PATCH 04/21] on going --- htdocs/core/menus/standard/eldy.lib.php | 6 +++--- htdocs/product/inventory/card.php | 10 ++++++---- htdocs/product/inventory/list.php | 1 + 3 files changed, 10 insertions(+), 7 deletions(-) diff --git a/htdocs/core/menus/standard/eldy.lib.php b/htdocs/core/menus/standard/eldy.lib.php index 077b6c8ba64..3abff3f714e 100644 --- a/htdocs/core/menus/standard/eldy.lib.php +++ b/htdocs/core/menus/standard/eldy.lib.php @@ -1257,9 +1257,9 @@ function print_left_eldy_menu($db,$menu_array_before,$menu_array_after,&$tabMenu if (! empty($conf->stock->enabled)) { $langs->load("stocks"); - $newmenu->add("/product/inventory/list.php?leftmenu=stock", $langs->trans("Inventory"), 0, $user->rights->stock->lire, '', $mainmenu, 'stock'); - $newmenu->add("/product/inventory/card.php?action=create", $langs->trans("NewInventory"), 1, $user->rights->stock->creer); - $newmenu->add("/product/inventory/list.php", $langs->trans("List"), 1, $user->rights->stock->lire); + $newmenu->add("/product/inventory/list.php?leftmenu=stock", $langs->trans("Inventory"), 0, $user->rights->stock->advance_inventory->read, '', $mainmenu, 'stock'); + $newmenu->add("/product/inventory/card.php?action=create", $langs->trans("NewInventory"), 1, $user->rights->stock->advance_inventory->create); + $newmenu->add("/product/inventory/list.php", $langs->trans("List"), 1, $user->rights->stock->advance_inventory->read); } } diff --git a/htdocs/product/inventory/card.php b/htdocs/product/inventory/card.php index e393721c47d..5fc63653ffc 100644 --- a/htdocs/product/inventory/card.php +++ b/htdocs/product/inventory/card.php @@ -36,6 +36,8 @@ $action = GETPOST('action', 'alpha'); $cancel = GETPOST('cancel', 'aZ09'); $backtopage = GETPOST('backtopage', 'alpha'); +$result = restrictedArea($user, 'stock', $id, '', 'advance_inventory'); + // Initialize technical objects $object=new Inventory($db); $extrafields = new ExtraFields($db); @@ -80,8 +82,8 @@ if (empty($reshook)) { $error=0; - $permissiontoadd = $user->rights->stock->creer; - $permissiontodelete = $user->rights->stock->supprimer; + $permissiontoadd = $user->rights->stock->advance_inventory->create; + $permissiontodelete = $user->rights->stock->advance_inventory->write; $backurlforlist = DOL_URL_ROOT.'/product/inventory/list.php'; // Actions cancel, add, update or delete @@ -327,7 +329,7 @@ if ($object->id > 0 && (empty($action) || ($action != 'edit' && $action != 'crea // Send print '' . $langs->trans('SendMail') . ''."\n"; - if ($user->rights->inventory->write) + if ($user->rights->stock->advance_inventory->write) { print ''.$langs->trans("Modify").''."\n"; } @@ -336,7 +338,7 @@ if ($object->id > 0 && (empty($action) || ($action != 'edit' && $action != 'crea print ''.$langs->trans('Modify').''."\n"; } - if ($user->rights->inventory->delete) + if ($user->rights->stock->advance_inventory->write) { print ''.$langs->trans('Delete').''."\n"; } diff --git a/htdocs/product/inventory/list.php b/htdocs/product/inventory/list.php index cb67168b214..c53ffafa8a3 100644 --- a/htdocs/product/inventory/list.php +++ b/htdocs/product/inventory/list.php @@ -72,6 +72,7 @@ if ($user->societe_id > 0) //$socid = $user->societe_id; accessforbidden(); } +$result = restrictedArea($user, 'stock', $objectid, '', 'advance_inventory'); // Initialize array of search criterias $search_all=trim(GETPOST("search_all",'alpha')); From f0164f268996f893083f53570fb4854b1b05919c Mon Sep 17 00:00:00 2001 From: florian HENRY Date: Fri, 9 Mar 2018 14:25:37 +0100 Subject: [PATCH 05/21] fix type date --- htdocs/core/actions_addupdatedelete.inc.php | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/htdocs/core/actions_addupdatedelete.inc.php b/htdocs/core/actions_addupdatedelete.inc.php index 6318e4d5c54..b8ede4d7d14 100644 --- a/htdocs/core/actions_addupdatedelete.inc.php +++ b/htdocs/core/actions_addupdatedelete.inc.php @@ -93,8 +93,16 @@ if ($action == 'update' && ! empty($permissiontoadd)) if (in_array($key, array('rowid', 'entity', 'date_creation', 'tms', 'fk_user_creat', 'fk_user_modif', 'import_key'))) continue; // Ignore special fields // Set value to update - if (in_array($object->fields[$key]['type'], array('text', 'html'))) $value = GETPOST($key,'none'); - else $value = GETPOST($key,'alpha'); + if (in_array($object->fields[$key]['type'], array('text', 'html'))) { + $value = GETPOST($key,'none'); + } + elseif ($object->fields[$key]['type']=='date') { + $value = dol_mktime(12, 0, 0, GETPOST($key.'month'), GETPOST($key.'day'), GETPOST($key.'year')); + } elseif ($object->fields[$key]['type']=='datetime') { + $value = dol_mktime(GETPOST($key.'hour'), GETPOST($key.'min'), 0, GETPOST($key.'month'), GETPOST($key.'day'), GETPOST($key.'year')); + } else { + $value = GETPOST($key,'alpha'); + } if (preg_match('/^integer:/i', $object->fields[$key]['type']) && $value == '-1') $value=''; // This is an implicit foreign key field if (! empty($object->fields[$key]['foreignkey']) && $value == '-1') $value=''; // This is an explicit foreign key field From d82c62b638191f5ec960af456c8a841e306f8210 Mon Sep 17 00:00:00 2001 From: Maxime Kohlhaas Date: Fri, 9 Mar 2018 21:51:59 +0100 Subject: [PATCH 06/21] Fix supplier order clone was keeping objectlinked --- htdocs/fourn/class/fournisseur.commande.class.php | 2 -- 1 file changed, 2 deletions(-) diff --git a/htdocs/fourn/class/fournisseur.commande.class.php b/htdocs/fourn/class/fournisseur.commande.class.php index a42546fdb84..a58f33502aa 100644 --- a/htdocs/fourn/class/fournisseur.commande.class.php +++ b/htdocs/fourn/class/fournisseur.commande.class.php @@ -321,8 +321,6 @@ class CommandeFournisseur extends CommonOrder if ($this->statut == 0) $this->brouillon = 1; - $this->fetchObjectLinked(); - //$result=$this->fetch_lines(); $this->lines=array(); From d92fa3a69c1ab614e99ee519fbb770002942688b Mon Sep 17 00:00:00 2001 From: Maxime Kohlhaas Date: Fri, 9 Mar 2018 23:49:40 +0100 Subject: [PATCH 07/21] Fix required field + space in dispatch --- htdocs/fourn/commande/card.php | 2 +- htdocs/fourn/commande/dispatch.php | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/htdocs/fourn/commande/card.php b/htdocs/fourn/commande/card.php index f083d71740e..ad27a496672 100644 --- a/htdocs/fourn/commande/card.php +++ b/htdocs/fourn/commande/card.php @@ -2453,7 +2453,7 @@ elseif (! empty($object->id)) print $form->select_date('','',1,1,'',"commande",1,1,1); print "\n"; - print "".$langs->trans("Delivery")."\n"; + print "".$langs->trans("Delivery")."\n"; $liv = array(); $liv[''] = ' '; $liv['tot'] = $langs->trans("CompleteOrNoMoreReceptionExpected"); diff --git a/htdocs/fourn/commande/dispatch.php b/htdocs/fourn/commande/dispatch.php index 049f158a0be..04c039cfbb1 100644 --- a/htdocs/fourn/commande/dispatch.php +++ b/htdocs/fourn/commande/dispatch.php @@ -457,7 +457,7 @@ if ($id > 0 || ! empty($ref)) { print ''; print ''; - print '
'; + print '
'; print ''; // Set $products_dispatched with qty dispatched for each product id From 04bcc4dd46666d73518c22db3e2bfa6184a10586 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Sat, 10 Mar 2018 12:39:39 +0100 Subject: [PATCH 08/21] Update eldy.lib.php --- htdocs/core/menus/standard/eldy.lib.php | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/htdocs/core/menus/standard/eldy.lib.php b/htdocs/core/menus/standard/eldy.lib.php index 3abff3f714e..e976408c285 100644 --- a/htdocs/core/menus/standard/eldy.lib.php +++ b/htdocs/core/menus/standard/eldy.lib.php @@ -1257,9 +1257,18 @@ function print_left_eldy_menu($db,$menu_array_before,$menu_array_after,&$tabMenu if (! empty($conf->stock->enabled)) { $langs->load("stocks"); - $newmenu->add("/product/inventory/list.php?leftmenu=stock", $langs->trans("Inventory"), 0, $user->rights->stock->advance_inventory->read, '', $mainmenu, 'stock'); - $newmenu->add("/product/inventory/card.php?action=create", $langs->trans("NewInventory"), 1, $user->rights->stock->advance_inventory->create); - $newmenu->add("/product/inventory/list.php", $langs->trans("List"), 1, $user->rights->stock->advance_inventory->read); + if (empty(MAIN_USE_ADVANCED_PERMS)) + { + $newmenu->add("/product/inventory/list.php?leftmenu=stock", $langs->trans("Inventory"), 0, $user->rights->stock->read, '', $mainmenu, 'stock'); + $newmenu->add("/product/inventory/card.php?action=create", $langs->trans("NewInventory"), 1, $user->rights->stock->create); + $newmenu->add("/product/inventory/list.php", $langs->trans("List"), 1, $user->rights->stock->read); + } + else + { + $newmenu->add("/product/inventory/list.php?leftmenu=stock", $langs->trans("Inventory"), 0, $user->rights->stock->advance_inventory->read, '', $mainmenu, 'stock'); + $newmenu->add("/product/inventory/card.php?action=create", $langs->trans("NewInventory"), 1, $user->rights->stock->advance_inventory->create); + $newmenu->add("/product/inventory/list.php", $langs->trans("List"), 1, $user->rights->stock->advance_inventory->read); + } } } From 75b470b5801c653c2d525f4aceac937c1fb7b198 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Sat, 10 Mar 2018 12:43:01 +0100 Subject: [PATCH 09/21] Update eldy.lib.php --- htdocs/core/menus/standard/eldy.lib.php | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/htdocs/core/menus/standard/eldy.lib.php b/htdocs/core/menus/standard/eldy.lib.php index e976408c285..15a262654f4 100644 --- a/htdocs/core/menus/standard/eldy.lib.php +++ b/htdocs/core/menus/standard/eldy.lib.php @@ -1257,16 +1257,16 @@ function print_left_eldy_menu($db,$menu_array_before,$menu_array_after,&$tabMenu if (! empty($conf->stock->enabled)) { $langs->load("stocks"); - if (empty(MAIN_USE_ADVANCED_PERMS)) + if (empty($conf->global->MAIN_USE_ADVANCED_PERMS)) { - $newmenu->add("/product/inventory/list.php?leftmenu=stock", $langs->trans("Inventory"), 0, $user->rights->stock->read, '', $mainmenu, 'stock'); - $newmenu->add("/product/inventory/card.php?action=create", $langs->trans("NewInventory"), 1, $user->rights->stock->create); - $newmenu->add("/product/inventory/list.php", $langs->trans("List"), 1, $user->rights->stock->read); + $newmenu->add("/product/inventory/list.php?leftmenu=stock", $langs->trans("Inventory"), 0, $user->rights->stock->lire, '', $mainmenu, 'stock'); + $newmenu->add("/product/inventory/card.php?action=create", $langs->trans("NewInventory"), 1, $user->rights->stock->creer); + $newmenu->add("/product/inventory/list.php", $langs->trans("List"), 1, $user->rights->stock->lire); } else { $newmenu->add("/product/inventory/list.php?leftmenu=stock", $langs->trans("Inventory"), 0, $user->rights->stock->advance_inventory->read, '', $mainmenu, 'stock'); - $newmenu->add("/product/inventory/card.php?action=create", $langs->trans("NewInventory"), 1, $user->rights->stock->advance_inventory->create); + $newmenu->add("/product/inventory/card.php?action=create", $langs->trans("NewInventory"), 1, $user->rights->stock->advance_inventory->write); $newmenu->add("/product/inventory/list.php", $langs->trans("List"), 1, $user->rights->stock->advance_inventory->read); } } From a7f82af352555379fcd7d2d8e85b3252365f8cd1 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Sat, 10 Mar 2018 12:49:25 +0100 Subject: [PATCH 10/21] Update card.php --- htdocs/product/inventory/card.php | 21 ++++++++++++++++++--- 1 file changed, 18 insertions(+), 3 deletions(-) diff --git a/htdocs/product/inventory/card.php b/htdocs/product/inventory/card.php index 5fc63653ffc..69658f2b42a 100644 --- a/htdocs/product/inventory/card.php +++ b/htdocs/product/inventory/card.php @@ -36,7 +36,14 @@ $action = GETPOST('action', 'alpha'); $cancel = GETPOST('cancel', 'aZ09'); $backtopage = GETPOST('backtopage', 'alpha'); -$result = restrictedArea($user, 'stock', $id, '', 'advance_inventory'); +if (empty($conf->global->MAIN_USE_ADVANCED_PERMS)) +{ + $result = restrictedArea($user, 'stock', $id); +} +else +{ + $result = restrictedArea($user, 'stock', $id, '', 'advance_inventory'); +} // Initialize technical objects $object=new Inventory($db); @@ -82,8 +89,16 @@ if (empty($reshook)) { $error=0; - $permissiontoadd = $user->rights->stock->advance_inventory->create; - $permissiontodelete = $user->rights->stock->advance_inventory->write; + if (empty($conf->global->MAIN_USE_ADVANCED_PERMS)) + { + $permissiontoadd = $user->rights->stock->write; + $permissiontodelete = $user->rights->stock->write; + } + else + { + $permissiontoadd = $user->rights->stock->advance_inventory->create; + $permissiontodelete = $user->rights->stock->advance_inventory->write; + } $backurlforlist = DOL_URL_ROOT.'/product/inventory/list.php'; // Actions cancel, add, update or delete From 64f2f324de8d40e4438e5ec1f354e39f25f92492 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Sat, 10 Mar 2018 12:52:09 +0100 Subject: [PATCH 11/21] Update card.php --- htdocs/product/inventory/card.php | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/htdocs/product/inventory/card.php b/htdocs/product/inventory/card.php index 69658f2b42a..30bb3312576 100644 --- a/htdocs/product/inventory/card.php +++ b/htdocs/product/inventory/card.php @@ -75,6 +75,16 @@ $extralabels = $extrafields->fetch_name_optionals_label($object->table_element); // Load object include DOL_DOCUMENT_ROOT.'/core/actions_fetchobject.inc.php'; // Must be include, not include_once // Must be include, not include_once. Include fetch and fetch_thirdparty but not fetch_optionals +if (empty($conf->global->MAIN_USE_ADVANCED_PERMS)) +{ + $permissiontoadd = $user->rights->stock->write; + $permissiontodelete = $user->rights->stock->write; +} +else +{ + $permissiontoadd = $user->rights->stock->advance_inventory->create; + $permissiontodelete = $user->rights->stock->advance_inventory->write; +} /* @@ -89,16 +99,6 @@ if (empty($reshook)) { $error=0; - if (empty($conf->global->MAIN_USE_ADVANCED_PERMS)) - { - $permissiontoadd = $user->rights->stock->write; - $permissiontodelete = $user->rights->stock->write; - } - else - { - $permissiontoadd = $user->rights->stock->advance_inventory->create; - $permissiontodelete = $user->rights->stock->advance_inventory->write; - } $backurlforlist = DOL_URL_ROOT.'/product/inventory/list.php'; // Actions cancel, add, update or delete @@ -344,7 +344,7 @@ if ($object->id > 0 && (empty($action) || ($action != 'edit' && $action != 'crea // Send print '' . $langs->trans('SendMail') . ''."\n"; - if ($user->rights->stock->advance_inventory->write) + if ($permissiontoadd) { print ''.$langs->trans("Modify").''."\n"; } @@ -353,7 +353,7 @@ if ($object->id > 0 && (empty($action) || ($action != 'edit' && $action != 'crea print ''.$langs->trans('Modify').''."\n"; } - if ($user->rights->stock->advance_inventory->write) + if ($permissiontodelete) { print ''.$langs->trans('Delete').''."\n"; } From 212536a3fdf9e1b89aaa17bdf7e5a09b5011564c Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Sat, 10 Mar 2018 12:54:20 +0100 Subject: [PATCH 12/21] Update list.php --- htdocs/product/inventory/list.php | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/htdocs/product/inventory/list.php b/htdocs/product/inventory/list.php index c53ffafa8a3..f3089099efe 100644 --- a/htdocs/product/inventory/list.php +++ b/htdocs/product/inventory/list.php @@ -72,7 +72,14 @@ if ($user->societe_id > 0) //$socid = $user->societe_id; accessforbidden(); } -$result = restrictedArea($user, 'stock', $objectid, '', 'advance_inventory'); +if (empty($conf->global->MAIN_USE_ADVANCED_PERMS)) +{ + $result = restrictedArea($user, 'stock', $objectid); +} +else +{ + $result = restrictedArea($user, 'stock', $objectid, '', 'advance_inventory'); +} // Initialize array of search criterias $search_all=trim(GETPOST("search_all",'alpha')); From 6793bfae3a1f0740cf5449c89f3ea5740a0e5161 Mon Sep 17 00:00:00 2001 From: jean Date: Sat, 10 Mar 2018 14:17:52 +0100 Subject: [PATCH 13/21] FIX #8289 add a cofoiguration for correct stopck calculation --- htdocs/product/class/product.class.php | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/htdocs/product/class/product.class.php b/htdocs/product/class/product.class.php index e6439031146..8d6042907ca 100644 --- a/htdocs/product/class/product.class.php +++ b/htdocs/product/class/product.class.php @@ -2271,6 +2271,29 @@ class Product extends CommonObject } } } + + if (! empty($conf->global->STOCK_CALCULATE_ON_BILL) && ! empty($conf->global->DECREASE_ONLY_UNINVOICEDPRODUCTS)) + { + $adeduire = 0; + $sql = "SELECT sum(fd.qty) as count FROM ".MAIN_DB_PREFIX."facturedet fd "; + $sql .= " JOIN ".MAIN_DB_PREFIX."facture f ON fd.fk_facture = f.rowid "; + $sql .= " JOIN ".MAIN_DB_PREFIX."element_element el ON el.fk_target = f.rowid and el.targettype = 'facture' and sourcetype = 'commande'"; + $sql .= " JOIN ".MAIN_DB_PREFIX."commande c ON el.fk_source = c.rowid "; + $sql .= " WHERE c.fk_statut IN (".$filtrestatut.") AND c.facture = 0 AND fd.fk_product = ".$this->id; + dol_syslog(__METHOD__.":: sql $sql", LOG_NOTICE); + + $resql = $this->db->query($sql); + if ( $resql ) + { + if ($this->db->num_rows($resql) > 0) + { + $obj = $this->db->fetch_object($resql); + $adeduire += $obj->count; + } + } + + $this->stats_commande['qty'] -= $adeduire ; + } return 1; } From 836054a8b3eb67b776a79daafd475c470b1ff0aa Mon Sep 17 00:00:00 2001 From: BadPixxel Date: Sat, 10 Mar 2018 14:51:24 +0100 Subject: [PATCH 14/21] BugFix Issue #8261: Variants module. Combinations cannot be edited --- htdocs/variants/combinations.php | 36 +++++++++++++++++--------------- 1 file changed, 19 insertions(+), 17 deletions(-) diff --git a/htdocs/variants/combinations.php b/htdocs/variants/combinations.php index 3101d44ecf5..84f3b7fa91c 100644 --- a/htdocs/variants/combinations.php +++ b/htdocs/variants/combinations.php @@ -346,12 +346,12 @@ if (! empty($id) || ! empty($ref)) foreach ($prodattr_all as $each) { $prodattr_alljson[$each->id] = $each; } - + ?>