From 1f64b09430aadb5e7670bc5c8973b1b77b33519d Mon Sep 17 00:00:00 2001 From: Lucas Marcouiller Date: Thu, 21 Oct 2021 18:07:54 +0200 Subject: [PATCH 01/27] WIP : fix inventory scan --- htdocs/core/class/html.formother.class.php | 5 +- htdocs/langs/en_US/productbatch.lang | 3 +- htdocs/langs/fr_FR/productbatch.lang | 2 +- .../product/inventory/ajax/ajax.inventory.php | 47 ---------- .../inventory/ajax/searchfrombarcode.php | 54 +++++++++++ htdocs/product/inventory/inventory.php | 94 +++++++++---------- 6 files changed, 108 insertions(+), 97 deletions(-) delete mode 100644 htdocs/product/inventory/ajax/ajax.inventory.php create mode 100644 htdocs/product/inventory/ajax/searchfrombarcode.php diff --git a/htdocs/core/class/html.formother.class.php b/htdocs/core/class/html.formother.class.php index 99ee1b6af9b..1d8dd1db08e 100644 --- a/htdocs/core/class/html.formother.class.php +++ b/htdocs/core/class/html.formother.class.php @@ -77,7 +77,10 @@ class FormOther $out .= ' Scan a product barcode
'; $out .= ' Scan a product lot or serial number
'; - $out .= $langs->trans("QtyToAddAfterBarcodeScan").'
'; + $stringaddbarcode = $langs->trans("QtyToAddAfterBarcodeScan","tmphtml"); + $htmltoreplaceby = ''; + $stringaddbarcode = str_replace("tmphtml",$htmltoreplaceby,$stringaddbarcode); + $out .= $stringaddbarcode.'
'; $out .= ''; /*print '
'.$langs->trans("or").'
'; diff --git a/htdocs/langs/en_US/productbatch.lang b/htdocs/langs/en_US/productbatch.lang index 71e44e8f281..dd1e0ea4027 100644 --- a/htdocs/langs/en_US/productbatch.lang +++ b/htdocs/langs/en_US/productbatch.lang @@ -30,7 +30,7 @@ ManageLotMask=Custom mask CustomMasks=Option to define a different numbering mask for each product BatchLotNumberingModules=Numbering rule for automatic generation of lot number BatchSerialNumberingModules=Numbering rule for automatic generation of serial number (for products with property 1 unique lot/serial for each product) -QtyToAddAfterBarcodeScan=Qty to add for each barcode/lot/serial scanned +QtyToAddAfterBarcodeScan=Qty to %s for each barcode/lot/serial scanned LifeTime=Life span (in days) EndOfLife=End of life ManufacturingDate=Manufacturing date @@ -42,3 +42,4 @@ HideLots=Hide lots #Traceability - qc status OutOfOrder=Out of order InWorkingOrder=In working order +ToReplace=Replace \ No newline at end of file diff --git a/htdocs/langs/fr_FR/productbatch.lang b/htdocs/langs/fr_FR/productbatch.lang index ccd5e43d3d7..bcef04e75ed 100644 --- a/htdocs/langs/fr_FR/productbatch.lang +++ b/htdocs/langs/fr_FR/productbatch.lang @@ -30,7 +30,7 @@ ManageLotMask=Masque personnalisé CustomMasks=Option pour définir un masque de numérotation différent pour chaque produit BatchLotNumberingModules=Règle de numérotation pour la génération automatique de numéro de lot BatchSerialNumberingModules=Règle de numérotation pour la génération automatique de numéro de série (pour les produits avec propriété 1 lot/série unique pour chaque produit) -QtyToAddAfterBarcodeScan=Quantité à ajouter pour chaque code à barres/lot/série scanné +QtyToAddAfterBarcodeScan=Quantité à %s pour chaque code à barres/lot/série scanné LifeTime=Durée de vie (en jours) EndOfLife=Fin d'utilisation ManufacturingDate=Date de fabrication diff --git a/htdocs/product/inventory/ajax/ajax.inventory.php b/htdocs/product/inventory/ajax/ajax.inventory.php deleted file mode 100644 index 920607f4c1e..00000000000 --- a/htdocs/product/inventory/ajax/ajax.inventory.php +++ /dev/null @@ -1,47 +0,0 @@ -rights->stock->creer)) { - echo -1; exit; - } - - $fk_det_inventory = GETPOST('fk_det_inventory'); - - $det = new InventoryLine($db); - if ($det->fetch($fk_det_inventory)) { - $det->qty_view += GETPOST('qty'); - $res = $det->update($user); - - echo $det->qty_view; - } else { - echo -2; - } - - break; - - case 'pmp': - if (empty($user->rights->stock->creer) || empty($user->rights->stock->changePMP)) { - echo -1; exit; - } - - $fk_det_inventory = GETPOST('fk_det_inventory'); - - $det = new InventoryLine($db); - if ($det->fetch($fk_det_inventory)) { - $det->new_pmp = price2num(GETPOST('pmp')); - $det->update($user); - - echo $det->new_pmp; - } else { - echo -2; - } - - break; -} diff --git a/htdocs/product/inventory/ajax/searchfrombarcode.php b/htdocs/product/inventory/ajax/searchfrombarcode.php new file mode 100644 index 00000000000..259aa5999f6 --- /dev/null +++ b/htdocs/product/inventory/ajax/searchfrombarcode.php @@ -0,0 +1,54 @@ +. + */ + +/** + * \file /htdocs/product/inventory/ajax/searchfrombarcode.php + * \brief File to make Ajax action on product and stock + */ + +if (!defined('NOTOKENRENEWAL')) { + define('NOTOKENRENEWAL', '1'); // Disables token renewal +} +if (!defined('NOREQUIREHTML')) { + define('NOREQUIREHTML', '1'); +} +if (!defined('NOREQUIREAJAX')) { + define('NOREQUIREAJAX', '1'); +} +if (!defined('NOREQUIRESOC')) { + define('NOREQUIRESOC', '1'); +} +if (!defined('NOCSRFCHECK')) { + define('NOCSRFCHECK', '1'); +} +// Do not check anti CSRF attack test +if (!defined('NOREQUIREMENU')) { + define('NOREQUIREMENU', '1'); +} +// If there is no need to load and show top and left menu +if (!defined("NOLOGIN")) { + define("NOLOGIN", '1'); +} +if (!defined('NOIPCHECK')) { + define('NOIPCHECK', '1'); // Do not check IP defined into conf $dolibarr_main_restrict_ip +} +if (!defined('NOBROWSERNOTIF')) { + define('NOBROWSERNOTIF', '1'); +} +require '../../../main.inc.php'; +require_once DOL_DOCUMENT_ROOT.'/product/inventory/class/inventory.class.php'; + diff --git a/htdocs/product/inventory/inventory.php b/htdocs/product/inventory/inventory.php index 9a4d61209ba..9445e7896c6 100644 --- a/htdocs/product/inventory/inventory.php +++ b/htdocs/product/inventory/inventory.php @@ -542,6 +542,7 @@ if ($object->id > 0) { print ''; } include DOL_DOCUMENT_ROOT.'/core/class/html.formother.class.php'; $formother = new FormOther($db); - print $formother->getHTMLScannerForm(); + print $formother->getHTMLScannerForm("barcodescannerjs"); } //Call method to undo changes in real qty From 4d2b96d0294cf9fbf36fb08df277368f22762e13 Mon Sep 17 00:00:00 2001 From: Lucas Marcouiller Date: Thu, 21 Oct 2021 18:08:20 +0200 Subject: [PATCH 02/27] fix inventory scan --- htdocs/core/class/html.formother.class.php | 4 ++-- htdocs/product/inventory/ajax/searchfrombarcode.php | 1 - 2 files changed, 2 insertions(+), 3 deletions(-) diff --git a/htdocs/core/class/html.formother.class.php b/htdocs/core/class/html.formother.class.php index 1d8dd1db08e..d1f50889182 100644 --- a/htdocs/core/class/html.formother.class.php +++ b/htdocs/core/class/html.formother.class.php @@ -77,9 +77,9 @@ class FormOther $out .= ' Scan a product barcode
'; $out .= ' Scan a product lot or serial number
'; - $stringaddbarcode = $langs->trans("QtyToAddAfterBarcodeScan","tmphtml"); + $stringaddbarcode = $langs->trans("QtyToAddAfterBarcodeScan", "tmphtml"); $htmltoreplaceby = ''; - $stringaddbarcode = str_replace("tmphtml",$htmltoreplaceby,$stringaddbarcode); + $stringaddbarcode = str_replace("tmphtml", $htmltoreplaceby, $stringaddbarcode); $out .= $stringaddbarcode.'
'; $out .= ''; diff --git a/htdocs/product/inventory/ajax/searchfrombarcode.php b/htdocs/product/inventory/ajax/searchfrombarcode.php index 259aa5999f6..7ee9d2b6be9 100644 --- a/htdocs/product/inventory/ajax/searchfrombarcode.php +++ b/htdocs/product/inventory/ajax/searchfrombarcode.php @@ -51,4 +51,3 @@ if (!defined('NOBROWSERNOTIF')) { } require '../../../main.inc.php'; require_once DOL_DOCUMENT_ROOT.'/product/inventory/class/inventory.class.php'; - From 56ff2412c1712c39d3ecee14b2fd22ed107eb46c Mon Sep 17 00:00:00 2001 From: Lucas Marcouiller Date: Fri, 22 Oct 2021 16:39:42 +0200 Subject: [PATCH 03/27] start code to searchfrmbarcode --- .../inventory/ajax/searchfrombarcode.php | 26 +++++++++++++++++++ 1 file changed, 26 insertions(+) diff --git a/htdocs/product/inventory/ajax/searchfrombarcode.php b/htdocs/product/inventory/ajax/searchfrombarcode.php index 7ee9d2b6be9..73b1943f4c7 100644 --- a/htdocs/product/inventory/ajax/searchfrombarcode.php +++ b/htdocs/product/inventory/ajax/searchfrombarcode.php @@ -51,3 +51,29 @@ if (!defined('NOBROWSERNOTIF')) { } require '../../../main.inc.php'; require_once DOL_DOCUMENT_ROOT.'/product/inventory/class/inventory.class.php'; + +$action = GETPOST("action", "alpha"); +$barcode = GETPOST("barcode", "aZ09"); +$response = ""; +$fk_entrepot = -1; +if ($action == "existbarcode" && !empty($barcode)) { + $sql = "SELECT *"; + $sql .= " FROM ".MAIN_DB_PREFIX."product_stock as ps JOIN ".MAIN_DB_PREFIX."product as p ON ps.fk_product = p.rowid"; + " WHERE p.barcode = '".$db->escape($barcode)."'"; + $result = $db->query($sql); + if ($result) { + $objecttab = $db->fetch_row($resql); + $nbline = $db->num_rows($resql); + for ($i=0; $i < $nbline; $i++) { + if ($fk_entrepot != $objecttab[$i]) { + // code... + } + } + } else { + $response = "No results found for barcode"; + } +} else { + $response = "Error on action"; +} + +echo $response; From ae78bed41d6ca6de523859676a6eaba37fb6fce6 Mon Sep 17 00:00:00 2001 From: Lucas Marcouiller Date: Sat, 23 Oct 2021 14:36:31 +0200 Subject: [PATCH 04/27] call to ajax file --- htdocs/product/inventory/inventory.php | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/htdocs/product/inventory/inventory.php b/htdocs/product/inventory/inventory.php index 9445e7896c6..f2702fbc0db 100644 --- a/htdocs/product/inventory/inventory.php +++ b/htdocs/product/inventory/inventory.php @@ -600,6 +600,16 @@ if ($object->id > 0) { function barcodeserialforproduct(textarray,tabproduct,barcodeproductqty,selectaddorreplace,mode,autodetect=false){ textarray.forEach(function(element,index){ + $.ajax({ url: \''.DOL_URL_ROOT.'/product/inventory/ajax/searchfrombarcode.php\', + data: { "action":"existbarcode","barcode":element}, + type: \'POST\', + success: function(response) { + console.log("test+1"); + }, + error : function(output) { + console.error("Error on Fetch of KM articles"); + }, + }); console.log("Product "+(index+=1)+": "+element); BarCodeDoesNotExist=0; tabproduct.forEach(product => { From 694ce9be17f09697d6eb9aa604ac55933682cd07 Mon Sep 17 00:00:00 2001 From: lmarcouiller Date: Mon, 15 Nov 2021 14:23:52 +0100 Subject: [PATCH 05/27] update inventory --- .../inventory/ajax/searchfrombarcode.php | 20 ++++-- htdocs/product/inventory/inventory.php | 67 ++++++++++--------- 2 files changed, 47 insertions(+), 40 deletions(-) diff --git a/htdocs/product/inventory/ajax/searchfrombarcode.php b/htdocs/product/inventory/ajax/searchfrombarcode.php index 73b1943f4c7..559bf8b72da 100644 --- a/htdocs/product/inventory/ajax/searchfrombarcode.php +++ b/htdocs/product/inventory/ajax/searchfrombarcode.php @@ -50,23 +50,29 @@ if (!defined('NOBROWSERNOTIF')) { define('NOBROWSERNOTIF', '1'); } require '../../../main.inc.php'; -require_once DOL_DOCUMENT_ROOT.'/product/inventory/class/inventory.class.php'; +//require_once DOL_DOCUMENT_ROOT.'/product/inventory/class/inventory.class.php'; $action = GETPOST("action", "alpha"); $barcode = GETPOST("barcode", "aZ09"); +$product = GETPOST("product"); $response = ""; -$fk_entrepot = -1; +$fk_entrepot = GETPOST("fk_entrepot", "int"); if ($action == "existbarcode" && !empty($barcode)) { - $sql = "SELECT *"; + $sql = "SELECT ps.fk_entrepot, ps.fk_product, p.barcode"; $sql .= " FROM ".MAIN_DB_PREFIX."product_stock as ps JOIN ".MAIN_DB_PREFIX."product as p ON ps.fk_product = p.rowid"; - " WHERE p.barcode = '".$db->escape($barcode)."'"; + $sql .= " WHERE p.barcode = '".$db->escape($barcode)."'"; + if (!empty($fk_entrepot)) { + $sql .= "AND ps.fk_entrepot = '".$db->escape($fk_entrepot)."'"; + } $result = $db->query($sql); if ($result) { - $objecttab = $db->fetch_row($resql); $nbline = $db->num_rows($resql); for ($i=0; $i < $nbline; $i++) { - if ($fk_entrepot != $objecttab[$i]) { - // code... + $object = $db->fetch_object($resql); + if ($barcode == $object->barcode) { + if (!empty($object->fk_entrepot) && $product["Warehouse"] == $object->fk_entrepot) { + //si warehouse !=$object->fk_entrepot erreur + } } } } else { diff --git a/htdocs/product/inventory/inventory.php b/htdocs/product/inventory/inventory.php index f2702fbc0db..8adf1ebc67c 100644 --- a/htdocs/product/inventory/inventory.php +++ b/htdocs/product/inventory/inventory.php @@ -572,21 +572,23 @@ if ($object->id > 0) { } tabproduct.push({\'Id\':id,\'Warehouse\':warehouse,\'Barcode\':productbarcode,\'Batch\':productbatchcode,\'Qty\':productinput}); }) - switch(barcodemode){ - case "barcodeforautodetect": - barcodeserialforproduct(textarray,tabproduct,barcodeproductqty,selectaddorreplace,"barcode",true); - barcodeserialforproduct(textarray,tabproduct,barcodeproductqty,selectaddorreplace,"lotserial",true); - break; - case "barcodeforproduct": //TODO: create product !exist + ajout - barcodeserialforproduct(textarray,tabproduct,barcodeproductqty,selectaddorreplace,"barcode"); - break; - case "barcodeforlotserial": - barcodeserialforproduct(textarray,tabproduct,barcodeproductqty,selectaddorreplace,"lotserial"); - break; - default: - alert("'.$langs->trans("ErrorWrongBarcodemode").' \""+barcodemode+"\""); - throw"'.$langs->trans('ErrorWrongBarcodemode').' \""+barcodemode+"\""; - } + tabproduct.forEach(product => { + switch(barcodemode){ + case "barcodeforautodetect": + barcodeserialforproduct(textarray,product,barcodeproductqty,selectaddorreplace,"barcode",true); + barcodeserialforproduct(textarray,product,barcodeproductqty,selectaddorreplace,"lotserial",true); + break; + case "barcodeforproduct": //TODO: create product !exist + ajout + barcodeserialforproduct(textarray,product,barcodeproductqty,selectaddorreplace,"barcode"); + break; + case "barcodeforlotserial": + barcodeserialforproduct(textarray,product,barcodeproductqty,selectaddorreplace,"lotserial"); + break; + default: + alert("'.$langs->trans("ErrorWrongBarcodemode").' \""+barcodemode+"\""); + throw"'.$langs->trans('ErrorWrongBarcodemode').' \""+barcodemode+"\""; + } + )} tabproduct.forEach(product => { if(product.Qty!=0){ console.log("We change #"+product.Id+"_input to match input in scanner box"); @@ -598,13 +600,14 @@ if ($object->id > 0) { } - function barcodeserialforproduct(textarray,tabproduct,barcodeproductqty,selectaddorreplace,mode,autodetect=false){ + function barcodeserialforproduct(textarray,product,barcodeproductqty,selectaddorreplace,mode,autodetect=false){ textarray.forEach(function(element,index){ $.ajax({ url: \''.DOL_URL_ROOT.'/product/inventory/ajax/searchfrombarcode.php\', - data: { "action":"existbarcode","barcode":element}, + data: { "action":"existbarcode",'.(!empty($object->fk_warehouse)?'"fk_entrepot":'.$object->fk_warehouse.',':'').'"barcode":element,"product":product}, type: \'POST\', success: function(response) { console.log("test+1"); + //gerer erreur si entrepot different }, error : function(output) { console.error("Error on Fetch of KM articles"); @@ -612,23 +615,21 @@ if ($object->id > 0) { }); console.log("Product "+(index+=1)+": "+element); BarCodeDoesNotExist=0; - tabproduct.forEach(product => { - if(mode == "barcode"){ - testonproduct = product.Barcode - }else if (mode == "lotserial"){ - testonproduct = product.Batch + if(mode == "barcode"){ + testonproduct = product.Barcode + }else if (mode == "lotserial"){ + testonproduct = product.Batch + } + if(testonproduct == element){ + if(selectaddorreplace == "add"){ + productqty = parseInt(product.Qty,10) + product.Qty = productqty + (1*barcodeproductqty) + }else if(selectaddorreplace == "replace"){ + product.Qty = (1*barcodeproductqty) } - if(testonproduct == element){ - if(selectaddorreplace == "add"){ - productqty = parseInt(product.Qty,10) - product.Qty = productqty + (1*barcodeproductqty) - }else if(selectaddorreplace == "replace"){ - product.Qty = (1*barcodeproductqty) - } - }else{ - BarCodeDoesNotExist+=1; - } - }) + }else{ + BarCodeDoesNotExist+=1; + } if(autodetect == false){ if(BarCodeDoesNotExist >= tabproduct.length && mode == "barcode"){ alert("'.$langs->trans('ProductBarcodeDoesNotExist').': "+element); From 5b1028611aacd583fa9d7bde4f225e50770a65df Mon Sep 17 00:00:00 2001 From: lmarcouiller Date: Fri, 19 Nov 2021 13:55:59 +0100 Subject: [PATCH 06/27] update inventory 19 11 --- .../inventory/ajax/searchfrombarcode.php | 17 +++++++++++-- htdocs/product/inventory/inventory.php | 24 +++++++++---------- 2 files changed, 26 insertions(+), 15 deletions(-) diff --git a/htdocs/product/inventory/ajax/searchfrombarcode.php b/htdocs/product/inventory/ajax/searchfrombarcode.php index 559bf8b72da..884aff9ec12 100644 --- a/htdocs/product/inventory/ajax/searchfrombarcode.php +++ b/htdocs/product/inventory/ajax/searchfrombarcode.php @@ -50,13 +50,17 @@ if (!defined('NOBROWSERNOTIF')) { define('NOBROWSERNOTIF', '1'); } require '../../../main.inc.php'; -//require_once DOL_DOCUMENT_ROOT.'/product/inventory/class/inventory.class.php'; +//include_once DOL_DOCUMENT_ROOT.'/product/inventory/class/inventory.class.php'; +$object = new Inventory($db); + $action = GETPOST("action", "alpha"); $barcode = GETPOST("barcode", "aZ09"); $product = GETPOST("product"); $response = ""; $fk_entrepot = GETPOST("fk_entrepot", "int"); +$warehousefound = 0; +$warehouseid = 0; if ($action == "existbarcode" && !empty($barcode)) { $sql = "SELECT ps.fk_entrepot, ps.fk_product, p.barcode"; $sql .= " FROM ".MAIN_DB_PREFIX."product_stock as ps JOIN ".MAIN_DB_PREFIX."product as p ON ps.fk_product = p.rowid"; @@ -71,10 +75,19 @@ if ($action == "existbarcode" && !empty($barcode)) { $object = $db->fetch_object($resql); if ($barcode == $object->barcode) { if (!empty($object->fk_entrepot) && $product["Warehouse"] == $object->fk_entrepot) { - //si warehouse !=$object->fk_entrepot erreur + $warehousefound++; + $warehouseid = $object->fk_entrepot; } } } + if ($warehousefound < 1) { + $response = array('status'=>'error','errorcode'=>'NotFound','message'=>'No warehouse found for barcode'.$barcode); + } elseif ($warehousefound > 1) { + $response = array('status'=>'error','errorcode'=>'TooManyWarehouse','message'=>'Too many warehouse found'); + } else { + $response = array('status'=>'success','message'=>'Warehouse found','warehouse'=>$warehouseid); + } + $response = json_encode($response); } else { $response = "No results found for barcode"; } diff --git a/htdocs/product/inventory/inventory.php b/htdocs/product/inventory/inventory.php index 8adf1ebc67c..76e3d53de2f 100644 --- a/htdocs/product/inventory/inventory.php +++ b/htdocs/product/inventory/inventory.php @@ -588,7 +588,7 @@ if ($object->id > 0) { alert("'.$langs->trans("ErrorWrongBarcodemode").' \""+barcodemode+"\""); throw"'.$langs->trans('ErrorWrongBarcodemode').' \""+barcodemode+"\""; } - )} + }); tabproduct.forEach(product => { if(product.Qty!=0){ console.log("We change #"+product.Id+"_input to match input in scanner box"); @@ -605,12 +605,17 @@ if ($object->id > 0) { $.ajax({ url: \''.DOL_URL_ROOT.'/product/inventory/ajax/searchfrombarcode.php\', data: { "action":"existbarcode",'.(!empty($object->fk_warehouse)?'"fk_entrepot":'.$object->fk_warehouse.',':'').'"barcode":element,"product":product}, type: \'POST\', + async: false, success: function(response) { - console.log("test+1"); - //gerer erreur si entrepot different + response = JSON.parse(response); + if(response.status == "success"){ + console.log(response.message); + }else{ + console.error(response.message); + } }, error : function(output) { - console.error("Error on Fetch of KM articles"); + console.error("Error on barcodeserialforproduct function"); }, }); console.log("Product "+(index+=1)+": "+element); @@ -623,20 +628,13 @@ if ($object->id > 0) { if(testonproduct == element){ if(selectaddorreplace == "add"){ productqty = parseInt(product.Qty,10) - product.Qty = productqty + (1*barcodeproductqty) + product.Qty = productqty + barcodeproductqty }else if(selectaddorreplace == "replace"){ - product.Qty = (1*barcodeproductqty) + product.Qty = barcodeproductqty } }else{ BarCodeDoesNotExist+=1; } - if(autodetect == false){ - if(BarCodeDoesNotExist >= tabproduct.length && mode == "barcode"){ - alert("'.$langs->trans('ProductBarcodeDoesNotExist').': "+element); - }else if(BarCodeDoesNotExist >= tabproduct.length && mode == "lotserial"){ - alert("'.$langs->trans('ProductBatchDoesNotExist').': "+element); - } - } }) } '; From c529d1a928aef79b1a8c6518761b1f048d35b408 Mon Sep 17 00:00:00 2001 From: lmarcouiller Date: Mon, 29 Nov 2021 15:00:23 +0100 Subject: [PATCH 07/27] update inventory add replace work --- .../inventory/ajax/searchfrombarcode.php | 9 ++--- .../inventory/class/inventory.class.php | 1 + htdocs/product/inventory/inventory.php | 40 ++++++++++++------- 3 files changed, 29 insertions(+), 21 deletions(-) diff --git a/htdocs/product/inventory/ajax/searchfrombarcode.php b/htdocs/product/inventory/ajax/searchfrombarcode.php index 884aff9ec12..1a613c7a837 100644 --- a/htdocs/product/inventory/ajax/searchfrombarcode.php +++ b/htdocs/product/inventory/ajax/searchfrombarcode.php @@ -50,8 +50,6 @@ if (!defined('NOBROWSERNOTIF')) { define('NOBROWSERNOTIF', '1'); } require '../../../main.inc.php'; -//include_once DOL_DOCUMENT_ROOT.'/product/inventory/class/inventory.class.php'; -$object = new Inventory($db); $action = GETPOST("action", "alpha"); @@ -87,12 +85,11 @@ if ($action == "existbarcode" && !empty($barcode)) { } else { $response = array('status'=>'success','message'=>'Warehouse found','warehouse'=>$warehouseid); } - $response = json_encode($response); } else { - $response = "No results found for barcode"; + $response = array('status'=>'error','errorcode'=>'NotFound','message'=>"No results found for barcode"); } } else { - $response = "Error on action"; + $response = array('status'=>'error','errorcode'=>'ActionError','message'=>"Error on action"); } - +$response = json_encode($response); echo $response; diff --git a/htdocs/product/inventory/class/inventory.class.php b/htdocs/product/inventory/class/inventory.class.php index b972e44245b..092d98ea854 100644 --- a/htdocs/product/inventory/class/inventory.class.php +++ b/htdocs/product/inventory/class/inventory.class.php @@ -26,6 +26,7 @@ // Put here all includes required by your class file require_once DOL_DOCUMENT_ROOT.'/core/class/commonobject.class.php'; +require_once DOL_DOCUMENT_ROOT.'/core/class/commonobjectline.class.php'; //require_once DOL_DOCUMENT_ROOT . '/societe/class/societe.class.php'; //require_once DOL_DOCUMENT_ROOT . '/product/class/product.class.php'; diff --git a/htdocs/product/inventory/inventory.php b/htdocs/product/inventory/inventory.php index 4dcda1bba41..910084c12fe 100644 --- a/htdocs/product/inventory/inventory.php +++ b/htdocs/product/inventory/inventory.php @@ -571,19 +571,19 @@ if ($object->id > 0) { if(productinput == ""){ productinput = 0 } - tabproduct.push({\'Id\':id,\'Warehouse\':warehouse,\'Barcode\':productbarcode,\'Batch\':productbatchcode,\'Qty\':productinput}); + tabproduct.push({\'Id\':id,\'Warehouse\':warehouse,\'Barcode\':productbarcode,\'Batch\':productbatchcode,\'Qty\':productinput,\'fetched\':false}); }) - tabproduct.forEach(product => { + textarray.forEach(function(element,index){ switch(barcodemode){ case "barcodeforautodetect": - barcodeserialforproduct(textarray,product,barcodeproductqty,selectaddorreplace,"barcode",true); - barcodeserialforproduct(textarray,product,barcodeproductqty,selectaddorreplace,"lotserial",true); + barcodeserialforproduct(tabproduct,index,element,barcodeproductqty,selectaddorreplace,"barcode",true); + barcodeserialforproduct(tabproduct,index,element,barcodeproductqty,selectaddorreplace,"lotserial",true); break; case "barcodeforproduct": //TODO: create product !exist + ajout - barcodeserialforproduct(textarray,product,barcodeproductqty,selectaddorreplace,"barcode"); + barcodeserialforproduct(tabproduct,index,element,barcodeproductqty,selectaddorreplace,"barcode"); break; case "barcodeforlotserial": - barcodeserialforproduct(textarray,product,barcodeproductqty,selectaddorreplace,"lotserial"); + barcodeserialforproduct(tabproduct,index,element,barcodeproductqty,selectaddorreplace,"lotserial"); break; default: alert("'.$langs->trans("ErrorWrongBarcodemode").' \""+barcodemode+"\""); @@ -601,8 +601,10 @@ if ($object->id > 0) { } - function barcodeserialforproduct(textarray,product,barcodeproductqty,selectaddorreplace,mode,autodetect=false){ - textarray.forEach(function(element,index){ + function barcodeserialforproduct(tabproduct,index,element,barcodeproductqty,selectaddorreplace,mode,autodetect=false){ + BarcodeIsInProduct=0; + BarcodeSuccess=false; + tabproduct.forEach(product => { $.ajax({ url: \''.DOL_URL_ROOT.'/product/inventory/ajax/searchfrombarcode.php\', data: { "action":"existbarcode",'.(!empty($object->fk_warehouse)?'"fk_entrepot":'.$object->fk_warehouse.',':'').'"barcode":element,"product":product}, type: \'POST\', @@ -611,6 +613,7 @@ if ($object->id > 0) { response = JSON.parse(response); if(response.status == "success"){ console.log(response.message); + BarcodeSucess=true; }else{ console.error(response.message); } @@ -618,9 +621,8 @@ if ($object->id > 0) { error : function(output) { console.error("Error on barcodeserialforproduct function"); }, - }); + }); console.log("Product "+(index+=1)+": "+element); - BarCodeDoesNotExist=0; if(mode == "barcode"){ testonproduct = product.Barcode }else if (mode == "lotserial"){ @@ -628,15 +630,23 @@ if ($object->id > 0) { } if(testonproduct == element){ if(selectaddorreplace == "add"){ - productqty = parseInt(product.Qty,10) - product.Qty = productqty + barcodeproductqty + productqty = parseInt(product.Qty,10); + product.Qty = productqty + parseInt(barcodeproductqty,10); }else if(selectaddorreplace == "replace"){ - product.Qty = barcodeproductqty + if(product.fetched == false){ + product.Qty = barcodeproductqty + product.fetched=true + }else{ + productqty = parseInt(product.Qty,10); + product.Qty = productqty + parseInt(barcodeproductqty,10); + } } - }else{ - BarCodeDoesNotExist+=1; + BarcodeIsInProduct+=1; } }) + if(BarcodeIsInProduct==0 && BarcodeSuccess){ + //addproduct to db and tabproduct + } } '; print ''; From ae56619253059ef533f17e18f29255abb0e3df57 Mon Sep 17 00:00:00 2001 From: Lucas Marcouiller Date: Tue, 30 Nov 2021 15:38:27 +0100 Subject: [PATCH 08/27] add productadd function but error on tabproduct --- .../inventory/ajax/searchfrombarcode.php | 71 +++++++++++++------ htdocs/product/inventory/inventory.php | 35 +++++++-- 2 files changed, 79 insertions(+), 27 deletions(-) diff --git a/htdocs/product/inventory/ajax/searchfrombarcode.php b/htdocs/product/inventory/ajax/searchfrombarcode.php index 1a613c7a837..32cba249896 100644 --- a/htdocs/product/inventory/ajax/searchfrombarcode.php +++ b/htdocs/product/inventory/ajax/searchfrombarcode.php @@ -21,7 +21,10 @@ */ if (!defined('NOTOKENRENEWAL')) { - define('NOTOKENRENEWAL', '1'); // Disables token renewal + define('NOTOKENRENEWAL', 1); // Disables token renewal +} +if (!defined('NOREQUIREMENU')) { + define('NOREQUIREMENU', '1'); } if (!defined('NOREQUIREHTML')) { define('NOREQUIREHTML', '1'); @@ -35,32 +38,28 @@ if (!defined('NOREQUIRESOC')) { if (!defined('NOCSRFCHECK')) { define('NOCSRFCHECK', '1'); } -// Do not check anti CSRF attack test -if (!defined('NOREQUIREMENU')) { - define('NOREQUIREMENU', '1'); -} -// If there is no need to load and show top and left menu -if (!defined("NOLOGIN")) { - define("NOLOGIN", '1'); -} -if (!defined('NOIPCHECK')) { - define('NOIPCHECK', '1'); // Do not check IP defined into conf $dolibarr_main_restrict_ip -} -if (!defined('NOBROWSERNOTIF')) { - define('NOBROWSERNOTIF', '1'); -} require '../../../main.inc.php'; - +require_once DOL_DOCUMENT_ROOT."/product/stock/class/entrepot.class.php"; +$warehouse = new Entrepot($db); $action = GETPOST("action", "alpha"); $barcode = GETPOST("barcode", "aZ09"); $product = GETPOST("product"); $response = ""; + $fk_entrepot = GETPOST("fk_entrepot", "int"); +$fk_inventory = GETPOST("fk_inventory", "int"); +$fk_product = GETPOST("fk_product", "int"); +$reelqty = GETPOST("reelqty", "int"); +$qtyview = GETPOST("Qty", "int"); +$batch = GETPOST("batch","int"); + $warehousefound = 0; $warehouseid = 0; +$objectreturn = array(); + if ($action == "existbarcode" && !empty($barcode)) { - $sql = "SELECT ps.fk_entrepot, ps.fk_product, p.barcode"; + $sql = "SELECT ps.fk_entrepot, ps.fk_product, p.barcode,ps.reel"; $sql .= " FROM ".MAIN_DB_PREFIX."product_stock as ps JOIN ".MAIN_DB_PREFIX."product as p ON ps.fk_product = p.rowid"; $sql .= " WHERE p.barcode = '".$db->escape($barcode)."'"; if (!empty($fk_entrepot)) { @@ -68,13 +67,18 @@ if ($action == "existbarcode" && !empty($barcode)) { } $result = $db->query($sql); if ($result) { - $nbline = $db->num_rows($resql); + $nbline = $db->num_rows($result); for ($i=0; $i < $nbline; $i++) { - $object = $db->fetch_object($resql); + $object = $db->fetch_object($result); if ($barcode == $object->barcode) { - if (!empty($object->fk_entrepot) && $product["Warehouse"] == $object->fk_entrepot) { + $warehouse->fetch(0,$product["Warehouse"]); + if (!empty($object->fk_entrepot) && $warehouse->id == $object->fk_entrepot) { $warehousefound++; $warehouseid = $object->fk_entrepot; + $fk_product = $object->fk_product; + $reelqty = $object->reel; + + $objectreturn = array('fk_warehouse'=>$warehouseid,'fk_product'=>$fk_product,'reelqty'=>$reelqty); } } } @@ -83,7 +87,7 @@ if ($action == "existbarcode" && !empty($barcode)) { } elseif ($warehousefound > 1) { $response = array('status'=>'error','errorcode'=>'TooManyWarehouse','message'=>'Too many warehouse found'); } else { - $response = array('status'=>'success','message'=>'Warehouse found','warehouse'=>$warehouseid); + $response = array('status'=>'success','message'=>'Warehouse found','object'=>$objectreturn); } } else { $response = array('status'=>'error','errorcode'=>'NotFound','message'=>"No results found for barcode"); @@ -91,5 +95,30 @@ if ($action == "existbarcode" && !empty($barcode)) { } else { $response = array('status'=>'error','errorcode'=>'ActionError','message'=>"Error on action"); } + +if ($action == "addnewlineproduct") { + require_once DOL_DOCUMENT_ROOT."/product/inventory/class/inventory.class.php"; + $inventoryline = new InventoryLine($db); + if (!empty($fk_inventory)) { + $inventoryline->fk_inventory = $fk_inventory; + + $inventoryline->fk_warehouse = $fk_entrepot; + $inventoryline->fk_product = $fk_product; + $inventoryline->qty_stock = $reelqty; + $inventoryline->qty_view = $qtyview; + $inventoryline->batch = $batch; + $inventoryline->datec = dol_now(); + + $result = $inventoryline->create($user); + if ($result > 0) { + $response = array('status'=>'success','message'=>'Success on creating line'); + }else { + $response = array('status'=>'error','errorcode'=>'ErrorCreation','message'=>"Error on line creation"); + } + }else { + $response = array('status'=>'error','errorcode'=>'NoIdForInventory','message'=>"No id for inventory"); + } +} + $response = json_encode($response); echo $response; diff --git a/htdocs/product/inventory/inventory.php b/htdocs/product/inventory/inventory.php index 910084c12fe..58bdcbc0022 100644 --- a/htdocs/product/inventory/inventory.php +++ b/htdocs/product/inventory/inventory.php @@ -587,13 +587,32 @@ if ($object->id > 0) { break; default: alert("'.$langs->trans("ErrorWrongBarcodemode").' \""+barcodemode+"\""); - throw"'.$langs->trans('ErrorWrongBarcodemode').' \""+barcodemode+"\""; + throw "'.$langs->trans('ErrorWrongBarcodemode').' \""+barcodemode+"\""; } }); tabproduct.forEach(product => { if(product.Qty!=0){ console.log("We change #"+product.Id+"_input to match input in scanner box"); - $("#"+product.Id+"_input").val(product.Qty); + if(product.hasOwnProperty("reelqty")){ + $.ajax({ url: \''.DOL_URL_ROOT.'/product/inventory/ajax/searchfrombarcode.php\', + data: { "action":"addnewlineproduct","fk_entrepot":product.Warehouse,"batch":Batch,"fk_inventory":'.dol_escape_js($object->id).',"fk_product":product.fk_product,"reelqty":product.reelqty,"qty":product.Qty}, + type: \'POST\', + async: false, + success: function(response) { + response = JSON.parse(response); + if(response.status == "success"){ + console.log(response.message); + }else{ + console.error(response.message); + } + }, + error : function(output) { + console.error("Error on barcodeserialforproduct function"); + }, + }); + } else { + $("#"+product.Id+"_input").val(product.Qty); + } } }) document.forms["formrecord"].submit(); @@ -603,7 +622,7 @@ if ($object->id > 0) { function barcodeserialforproduct(tabproduct,index,element,barcodeproductqty,selectaddorreplace,mode,autodetect=false){ BarcodeIsInProduct=0; - BarcodeSuccess=false; + newproductrow=0 tabproduct.forEach(product => { $.ajax({ url: \''.DOL_URL_ROOT.'/product/inventory/ajax/searchfrombarcode.php\', data: { "action":"existbarcode",'.(!empty($object->fk_warehouse)?'"fk_entrepot":'.$object->fk_warehouse.',':'').'"barcode":element,"product":product}, @@ -613,7 +632,9 @@ if ($object->id > 0) { response = JSON.parse(response); if(response.status == "success"){ console.log(response.message); - BarcodeSucess=true; + if(!newproductrow){ + newproductrow = response.object; + } }else{ console.error(response.message); } @@ -644,9 +665,11 @@ if ($object->id > 0) { BarcodeIsInProduct+=1; } }) - if(BarcodeIsInProduct==0 && BarcodeSuccess){ - //addproduct to db and tabproduct + if(BarcodeIsInProduct==0 && newproductrow){ + //addproduct to tabproduct + tabproduct.push({\'Id\':tabproduct.length-1,\'Warehouse\':newproductrow.fk_warehouse,\'Barcode\':element,\'Batch\':"",\'Qty\':1,\'fetched\':true,\'reelqty\':object.reelqty}); } + return tabproduct; } '; print ''; From f39dd30a7f49b6cd9a542eb291e3c742090caf40 Mon Sep 17 00:00:00 2001 From: Lucas Marcouiller Date: Tue, 30 Nov 2021 15:38:48 +0100 Subject: [PATCH 09/27] fix precommit --- htdocs/product/inventory/ajax/searchfrombarcode.php | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/htdocs/product/inventory/ajax/searchfrombarcode.php b/htdocs/product/inventory/ajax/searchfrombarcode.php index 32cba249896..947a9904bf0 100644 --- a/htdocs/product/inventory/ajax/searchfrombarcode.php +++ b/htdocs/product/inventory/ajax/searchfrombarcode.php @@ -52,7 +52,7 @@ $fk_inventory = GETPOST("fk_inventory", "int"); $fk_product = GETPOST("fk_product", "int"); $reelqty = GETPOST("reelqty", "int"); $qtyview = GETPOST("Qty", "int"); -$batch = GETPOST("batch","int"); +$batch = GETPOST("batch", "int"); $warehousefound = 0; $warehouseid = 0; @@ -71,7 +71,7 @@ if ($action == "existbarcode" && !empty($barcode)) { for ($i=0; $i < $nbline; $i++) { $object = $db->fetch_object($result); if ($barcode == $object->barcode) { - $warehouse->fetch(0,$product["Warehouse"]); + $warehouse->fetch(0, $product["Warehouse"]); if (!empty($object->fk_entrepot) && $warehouse->id == $object->fk_entrepot) { $warehousefound++; $warehouseid = $object->fk_entrepot; @@ -112,10 +112,10 @@ if ($action == "addnewlineproduct") { $result = $inventoryline->create($user); if ($result > 0) { $response = array('status'=>'success','message'=>'Success on creating line'); - }else { + } else { $response = array('status'=>'error','errorcode'=>'ErrorCreation','message'=>"Error on line creation"); } - }else { + } else { $response = array('status'=>'error','errorcode'=>'NoIdForInventory','message'=>"No id for inventory"); } } From 7512305b449e0718513cc302c3117eed2215dba3 Mon Sep 17 00:00:00 2001 From: lmarcouiller Date: Wed, 1 Dec 2021 12:10:57 +0100 Subject: [PATCH 10/27] add porduct inventory but qty_view bug --- htdocs/product/inventory/ajax/searchfrombarcode.php | 7 +++++-- htdocs/product/inventory/inventory.php | 10 ++++------ 2 files changed, 9 insertions(+), 8 deletions(-) diff --git a/htdocs/product/inventory/ajax/searchfrombarcode.php b/htdocs/product/inventory/ajax/searchfrombarcode.php index 947a9904bf0..c4d53719d65 100644 --- a/htdocs/product/inventory/ajax/searchfrombarcode.php +++ b/htdocs/product/inventory/ajax/searchfrombarcode.php @@ -51,8 +51,9 @@ $fk_entrepot = GETPOST("fk_entrepot", "int"); $fk_inventory = GETPOST("fk_inventory", "int"); $fk_product = GETPOST("fk_product", "int"); $reelqty = GETPOST("reelqty", "int"); -$qtyview = GETPOST("Qty", "int"); +$qtyview = GETPOST("qty", "int"); $batch = GETPOST("batch", "int"); +$mode = GETPOST("mode", "aZ"); $warehousefound = 0; $warehouseid = 0; @@ -106,7 +107,9 @@ if ($action == "addnewlineproduct") { $inventoryline->fk_product = $fk_product; $inventoryline->qty_stock = $reelqty; $inventoryline->qty_view = $qtyview; - $inventoryline->batch = $batch; + if ($mode == "lotserial") { + $inventoryline->batch = $batch; + } $inventoryline->datec = dol_now(); $result = $inventoryline->create($user); diff --git a/htdocs/product/inventory/inventory.php b/htdocs/product/inventory/inventory.php index 58bdcbc0022..9376d583ad4 100644 --- a/htdocs/product/inventory/inventory.php +++ b/htdocs/product/inventory/inventory.php @@ -548,8 +548,8 @@ if ($object->id > 0) { var barcodeproductqty = $("input[name=barcodeproductqty]").val(); var textarea = $("textarea[name=barcodelist]").val(); var textarray = textarea.split("\n"); + var tabproduct = []; if(textarray[0] != ""){ - var tabproduct = []; $(".expectedqty").each(function(){ id = this.id; warehouse = $("#"+id+"_warehouse").children().first().text(); @@ -579,7 +579,7 @@ if ($object->id > 0) { barcodeserialforproduct(tabproduct,index,element,barcodeproductqty,selectaddorreplace,"barcode",true); barcodeserialforproduct(tabproduct,index,element,barcodeproductqty,selectaddorreplace,"lotserial",true); break; - case "barcodeforproduct": //TODO: create product !exist + ajout + case "barcodeforproduct": barcodeserialforproduct(tabproduct,index,element,barcodeproductqty,selectaddorreplace,"barcode"); break; case "barcodeforlotserial": @@ -595,7 +595,7 @@ if ($object->id > 0) { console.log("We change #"+product.Id+"_input to match input in scanner box"); if(product.hasOwnProperty("reelqty")){ $.ajax({ url: \''.DOL_URL_ROOT.'/product/inventory/ajax/searchfrombarcode.php\', - data: { "action":"addnewlineproduct","fk_entrepot":product.Warehouse,"batch":Batch,"fk_inventory":'.dol_escape_js($object->id).',"fk_product":product.fk_product,"reelqty":product.reelqty,"qty":product.Qty}, + data: { "action":"addnewlineproduct","fk_entrepot":product.Warehouse,"batch":product.Batch,"fk_inventory":'.dol_escape_js($object->id).',"fk_product":product.fk_product,"reelqty":product.reelqty,"qty":product.Qty}, type: \'POST\', async: false, success: function(response) { @@ -666,10 +666,8 @@ if ($object->id > 0) { } }) if(BarcodeIsInProduct==0 && newproductrow){ - //addproduct to tabproduct - tabproduct.push({\'Id\':tabproduct.length-1,\'Warehouse\':newproductrow.fk_warehouse,\'Barcode\':element,\'Batch\':"",\'Qty\':1,\'fetched\':true,\'reelqty\':object.reelqty}); + tabproduct.push({\'Id\':tabproduct.length-1,\'Warehouse\':newproductrow.fk_warehouse,\'Barcode\':element,\'Batch\':element,\'Qty\':barcodeproductqty,\'fetched\':true,\'reelqty\':newproductrow.reelqty,\'fk_product\':newproductrow.fk_product,\'mode\':mode}); } - return tabproduct; } '; print ''; From b732d80ca5fc504799eeef70cd6f8a2965a5bd97 Mon Sep 17 00:00:00 2001 From: lmarcouiller Date: Thu, 2 Dec 2021 15:56:34 +0100 Subject: [PATCH 11/27] Fix php 8.0 warnings --- htdocs/compta/facture/card.php | 10 ++++++---- htdocs/compta/facture/invoicetemplate_list.php | 6 +++++- htdocs/compta/facture/list.php | 8 ++++---- htdocs/compta/facture/stats/index.php | 6 +++--- htdocs/core/class/html.form.class.php | 2 +- 5 files changed, 19 insertions(+), 13 deletions(-) diff --git a/htdocs/compta/facture/card.php b/htdocs/compta/facture/card.php index 20f289ae141..c50f7a4e8e8 100644 --- a/htdocs/compta/facture/card.php +++ b/htdocs/compta/facture/card.php @@ -92,6 +92,8 @@ $search_montant_ttc = GETPOST('search_montant_ttc', 'alpha'); $origin = GETPOST('origin', 'alpha'); $originid = (GETPOST('originid', 'int') ? GETPOST('originid', 'int') : GETPOST('origin_id', 'int')); // For backward compatibility $fac_rec = GETPOST('fac_rec', 'int'); +$facid = GETPOST('facid', 'int'); +$ref_client = GETPOST('ref_client', 'int'); // PDF $hidedetails = (GETPOST('hidedetails', 'int') ? GETPOST('hidedetails', 'int') : (!empty($conf->global->MAIN_GENERATE_DOCUMENTS_HIDE_DETAILS) ? 1 : 0)); @@ -2771,7 +2773,7 @@ if (empty($reshook)) { include DOL_DOCUMENT_ROOT.'/core/actions_sendmails.inc.php'; // Actions to build doc - $upload_dir = $conf->facture->multidir_output[$object->entity]; + $upload_dir = $conf->facture->multidir_output[!empty($object->entity) ? $object->entity : $conf->entity]; $permissiontoadd = $usercancreate; include DOL_DOCUMENT_ROOT.'/core/actions_builddoc.inc.php'; @@ -3555,7 +3557,7 @@ if ($action == 'create') { print ''; - if ($conf->global->INVOICE_USE_RETAINED_WARRANTY) { + if (!empty($conf->global->INVOICE_USE_RETAINED_WARRANTY)) { $rwStyle = 'display:none;'; if (in_array(GETPOST('type', 'int'), $retainedWarrantyInvoiceAvailableType)) { $rwStyle = ''; @@ -3631,7 +3633,7 @@ if ($action == 'create') { // Incoterms if (!empty($conf->incoterm->enabled)) { print ''; - print ''; + print ''; print ''; $incoterm_id = GETPOST('incoterm_id'); $incoterm_location = GETPOST('location_incoterms'); @@ -3644,7 +3646,7 @@ if ($action == 'create') { } // Other attributes - $parameters = array('objectsrc' => $objectsrc, 'colspan' => ' colspan="2"', 'cols' => '2', 'socid'=>$socid); + $parameters = array('objectsrc' => !empty($objectsrc) ? $objectsrc : 0, 'colspan' => ' colspan="2"', 'cols' => '2', 'socid'=>$socid); $reshook = $hookmanager->executeHooks('formObjectOptions', $parameters, $object, $action); // Note that $action and $object may have been modified by hook print $hookmanager->resPrint; if (empty($reshook)) { diff --git a/htdocs/compta/facture/invoicetemplate_list.php b/htdocs/compta/facture/invoicetemplate_list.php index 9619e1a9ddd..d785ccbce93 100644 --- a/htdocs/compta/facture/invoicetemplate_list.php +++ b/htdocs/compta/facture/invoicetemplate_list.php @@ -692,6 +692,10 @@ if ($resql) { if ($num > 0) { $i = 0; $totalarray = array(); + $totalarray['nbfield'] = 0; + $totalarray['val']['f.total_ht'] = 0; + $totalarray['val']['f.total_tva'] = 0; + $totalarray['val']['f.total_ttc'] = 0; while ($i < min($num, $limit)) { $objp = $db->fetch_object($resql); if (empty($objp)) { @@ -701,7 +705,7 @@ if ($resql) { $companystatic->id = $objp->socid; $companystatic->name = $objp->name; - $invoicerectmp->id = $objp->id ? $objp->id : $objp->facid; + $invoicerectmp->id = !empty($objp->id) ? $objp->id : $objp->facid; $invoicerectmp->frequency = $objp->frequency; $invoicerectmp->suspended = $objp->suspended; $invoicerectmp->unit_frequency = $objp->unit_frequency; diff --git a/htdocs/compta/facture/list.php b/htdocs/compta/facture/list.php index 52b2fcceee0..02ce893b96d 100644 --- a/htdocs/compta/facture/list.php +++ b/htdocs/compta/facture/list.php @@ -805,7 +805,7 @@ if (!$sall) { } } // Add GroupBy from hooks - $parameters = array('all' => $all, 'fieldstosearchall' => $fieldstosearchall); + $parameters = array('all' => !empty($all) ? $all : 0, 'fieldstosearchall' => $fieldstosearchall); $reshook = $hookmanager->executeHooks('printFieldListGroupBy', $parameters, $object); // Note that $action and $object may have been modified by hook $sql .= $hookmanager->resPrint; } else { @@ -1650,7 +1650,7 @@ if ($resql) { $facturestatic->note_public = $obj->note_public; $facturestatic->note_private = $obj->note_private; - if ($conf->global->INVOICE_USE_SITUATION && $conf->global->INVOICE_USE_RETAINED_WARRANTY) { + if (!empty($conf->global->INVOICE_USE_SITUATION) && !empty($conf->global->INVOICE_USE_RETAINED_WARRANTY)) { $facturestatic->retained_warranty = $obj->retained_warranty; $facturestatic->retained_warranty_date_limit = $obj->retained_warranty_date_limit; $facturestatic->situation_final = $obj->retained_warranty_date_limit; @@ -1846,8 +1846,8 @@ if ($resql) { } // Alias if (!empty($arrayfields['s.name_alias']['checked'])) { - print ''; - print dol_escape_htmltag($obj->name_alias); + print ''; + print dol_escape_htmltag((!empty($obj->name_alias) ? $obj->name_alias : '')); print ''; if (!$i) { $totalarray['nbfield']++; diff --git a/htdocs/compta/facture/stats/index.php b/htdocs/compta/facture/stats/index.php index babadfe7366..c100263ac7f 100644 --- a/htdocs/compta/facture/stats/index.php +++ b/htdocs/compta/facture/stats/index.php @@ -380,11 +380,11 @@ foreach ($data as $val) { print ''; print ' 0 ? '&userid='.$userid : '').'">'.$year.''; print ''.$val['nb'].''; - print ''.($val['nb_diff'] < 0 ? '' : '+').round($val['nb_diff']).'%'; + print ''.(!empty($val['nb_diff']) && $val['nb_diff'] < 0 ? '' : '+').round(!empty($val['nb_diff']) ? $val['nb_diff'] : 0).'%'; print ''.price(price2num($val['total'], 'MT'), 1).''; - print ''.($val['total_diff'] < 0 ? '' : '+').round($val['total_diff']).'%'; + print ''.( !empty($val['total_diff']) && $val['total_diff'] < 0 ? '' : '+').round(!empty($val['total_diff']) ? $val['total_diff'] : 0).'%'; print ''.price(price2num($val['avg'], 'MT'), 1).''; - print ''.($val['avg_diff'] < 0 ? '' : '+').round($val['avg_diff']).'%'; + print ''.(!empty($val['avg_diff']) && $val['avg_diff'] < 0 ? '' : '+').round(!empty($val['avg_diff']) ? $val['avg_diff'] : 0).'%'; print ''; $oldyear = $year; } diff --git a/htdocs/core/class/html.form.class.php b/htdocs/core/class/html.form.class.php index a6718531ff3..5423175859b 100644 --- a/htdocs/core/class/html.form.class.php +++ b/htdocs/core/class/html.form.class.php @@ -8435,7 +8435,7 @@ class Form 'label'=>'LinkToContract', 'sql'=>"SELECT s.rowid as socid, s.nom as name, s.client, t.rowid, t.ref, t.ref_customer as ref_client, t.ref_supplier, SUM(td.total_ht) as total_ht FROM ".MAIN_DB_PREFIX."societe as s, ".MAIN_DB_PREFIX."contrat as t, ".MAIN_DB_PREFIX."contratdet as td WHERE t.fk_soc = s.rowid AND td.fk_contrat = t.rowid AND t.fk_soc IN (".$this->db->sanitize($listofidcompanytoscan).') AND t.entity IN ('.getEntity('contract').') GROUP BY s.rowid, s.nom, s.client, t.rowid, t.ref, t.ref_customer, t.ref_supplier' ), - 'fichinter'=>array('enabled'=>$conf->ficheinter->enabled, 'perms'=>1, 'label'=>'LinkToIntervention', 'sql'=>"SELECT s.rowid as socid, s.nom as name, s.client, t.rowid, t.ref FROM ".MAIN_DB_PREFIX."societe as s, ".MAIN_DB_PREFIX."fichinter as t WHERE t.fk_soc = s.rowid AND t.fk_soc IN (".$this->db->sanitize($listofidcompanytoscan).') AND t.entity IN ('.getEntity('intervention').')'), + 'fichinter'=>array('enabled'=>!empty($conf->ficheinter->enabled) ? $conf->ficheinter->enabled : 0, 'perms'=>1, 'label'=>'LinkToIntervention', 'sql'=>"SELECT s.rowid as socid, s.nom as name, s.client, t.rowid, t.ref FROM ".MAIN_DB_PREFIX."societe as s, ".MAIN_DB_PREFIX."fichinter as t WHERE t.fk_soc = s.rowid AND t.fk_soc IN (".$this->db->sanitize($listofidcompanytoscan).') AND t.entity IN ('.getEntity('intervention').')'), 'supplier_proposal'=>array('enabled'=>$conf->supplier_proposal->enabled, 'perms'=>1, 'label'=>'LinkToSupplierProposal', 'sql'=>"SELECT s.rowid as socid, s.nom as name, s.client, t.rowid, t.ref, '' as ref_supplier, t.total_ht FROM ".MAIN_DB_PREFIX."societe as s, ".MAIN_DB_PREFIX."supplier_proposal as t WHERE t.fk_soc = s.rowid AND t.fk_soc IN (".$this->db->sanitize($listofidcompanytoscan).') AND t.entity IN ('.getEntity('supplier_proposal').')'), 'order_supplier'=>array('enabled'=>$conf->supplier_order->enabled, 'perms'=>1, 'label'=>'LinkToSupplierOrder', 'sql'=>"SELECT s.rowid as socid, s.nom as name, s.client, t.rowid, t.ref, t.ref_supplier, t.total_ht FROM ".MAIN_DB_PREFIX."societe as s, ".MAIN_DB_PREFIX."commande_fournisseur as t WHERE t.fk_soc = s.rowid AND t.fk_soc IN (".$this->db->sanitize($listofidcompanytoscan).') AND t.entity IN ('.getEntity('commande_fournisseur').')'), 'invoice_supplier'=>array('enabled'=>$conf->supplier_invoice->enabled, 'perms'=>1, 'label'=>'LinkToSupplierInvoice', 'sql'=>"SELECT s.rowid as socid, s.nom as name, s.client, t.rowid, t.ref, t.ref_supplier, t.total_ht FROM ".MAIN_DB_PREFIX."societe as s, ".MAIN_DB_PREFIX."facture_fourn as t WHERE t.fk_soc = s.rowid AND t.fk_soc IN (".$this->db->sanitize($listofidcompanytoscan).') AND t.entity IN ('.getEntity('facture_fourn').')'), From 093191aeebc6685290c317884cc9d2c526265aba Mon Sep 17 00:00:00 2001 From: lmarcouiller Date: Fri, 3 Dec 2021 10:37:48 +0100 Subject: [PATCH 12/27] FIx php8.0 warnings --- htdocs/fourn/paiement/list.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/fourn/paiement/list.php b/htdocs/fourn/paiement/list.php index c4e18d50f90..5c76c1dddd0 100644 --- a/htdocs/fourn/paiement/list.php +++ b/htdocs/fourn/paiement/list.php @@ -348,7 +348,7 @@ if ($moreforfilter) { $varpage = empty($contextpage) ? $_SERVER['PHP_SELF'] : $contextpage; $selectedfields = $form->multiSelectArrayWithCheckbox('selectedfields', $arrayfields, $varpage); // This also change content of $arrayfields -if ($massactionbutton) { +if (!empty($massactionbutton)) { $selectedfields .= $form->showCheckAddButtons('checkforselect', 1); } From 325ad45bca794a69f12c0d45e5ad9954f3328529 Mon Sep 17 00:00:00 2001 From: lmarcouiller Date: Fri, 3 Dec 2021 16:04:23 +0100 Subject: [PATCH 13/27] update scan inventory error gestion --- htdocs/langs/en_US/stocks.lang | 3 +- .../inventory/ajax/searchfrombarcode.php | 17 ++-- htdocs/product/inventory/inventory.php | 77 +++++++++++-------- 3 files changed, 60 insertions(+), 37 deletions(-) diff --git a/htdocs/langs/en_US/stocks.lang b/htdocs/langs/en_US/stocks.lang index 75b6ea1bd4e..c26a8819a1d 100644 --- a/htdocs/langs/en_US/stocks.lang +++ b/htdocs/langs/en_US/stocks.lang @@ -265,4 +265,5 @@ ProductBarcodeDoesNotExist=Product with barcode does not exist WarehouseId=Warehouse ID WarehouseRef=Warehouse Ref SaveQtyFirst=Save the real inventoried quantities first, before asking creation of the stock movement. -InventoryStartedShort=Started \ No newline at end of file +InventoryStartedShort=Started +ErrorOnElementsInventory=Scan was aborted due to following barcode or batch number on error \ No newline at end of file diff --git a/htdocs/product/inventory/ajax/searchfrombarcode.php b/htdocs/product/inventory/ajax/searchfrombarcode.php index c4d53719d65..8dfac96c32b 100644 --- a/htdocs/product/inventory/ajax/searchfrombarcode.php +++ b/htdocs/product/inventory/ajax/searchfrombarcode.php @@ -60,18 +60,25 @@ $warehouseid = 0; $objectreturn = array(); if ($action == "existbarcode" && !empty($barcode)) { - $sql = "SELECT ps.fk_entrepot, ps.fk_product, p.barcode,ps.reel"; - $sql .= " FROM ".MAIN_DB_PREFIX."product_stock as ps JOIN ".MAIN_DB_PREFIX."product as p ON ps.fk_product = p.rowid"; - $sql .= " WHERE p.barcode = '".$db->escape($barcode)."'"; + if (!empty($mode) && $mode == "lotserial") { + $sql = "SELECT ps.fk_entrepot, ps.fk_product, p.barcode, ps.reel, pb.batch"; + $sql .= " FROM ".MAIN_DB_PREFIX."product_batch as pb"; + $sql .= " JOIN ".MAIN_DB_PREFIX."product_stock as ps ON pb.fk_product_stock = ps.rowid JOIN ".MAIN_DB_PREFIX."product as p ON ps.fk_product = p.rowid"; + $sql .= " WHERE pb.batch = '".$db->escape($barcode)."'"; + } else { + $sql = "SELECT ps.fk_entrepot, ps.fk_product, p.barcode,ps.reel"; + $sql .= " FROM ".MAIN_DB_PREFIX."product_stock as ps JOIN ".MAIN_DB_PREFIX."product as p ON ps.fk_product = p.rowid"; + $sql .= " WHERE p.barcode = '".$db->escape($barcode)."'"; + } if (!empty($fk_entrepot)) { - $sql .= "AND ps.fk_entrepot = '".$db->escape($fk_entrepot)."'"; + $sql .= " AND ps.fk_entrepot = '".$db->escape($fk_entrepot)."'"; } $result = $db->query($sql); if ($result) { $nbline = $db->num_rows($result); for ($i=0; $i < $nbline; $i++) { $object = $db->fetch_object($result); - if ($barcode == $object->barcode) { + if (($mode == "barcode" && $barcode == $object->barcode) || ($mode == "lotserial" && $barcode == $object->batch)) { $warehouse->fetch(0, $product["Warehouse"]); if (!empty($object->fk_entrepot) && $warehouse->id == $object->fk_entrepot) { $warehousefound++; diff --git a/htdocs/product/inventory/inventory.php b/htdocs/product/inventory/inventory.php index 9376d583ad4..51c2e9d2bc5 100644 --- a/htdocs/product/inventory/inventory.php +++ b/htdocs/product/inventory/inventory.php @@ -541,7 +541,10 @@ if ($object->id > 0) { if ($action == 'updatebyscaning') { if ($permissiontoadd) { print ''; From 1caaa335d16b5b5bfb1dbff16ae23cfb4ab9d36a Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Mon, 6 Dec 2021 18:18:31 +0100 Subject: [PATCH 16/27] Fix missing section with files on social contribution page --- htdocs/compta/sociales/card.php | 132 ++++++++++++++++++++++++++------ htdocs/compta/tva/card.php | 13 ++-- 2 files changed, 114 insertions(+), 31 deletions(-) diff --git a/htdocs/compta/sociales/card.php b/htdocs/compta/sociales/card.php index 8207802feaa..98ebe32f970 100644 --- a/htdocs/compta/sociales/card.php +++ b/htdocs/compta/sociales/card.php @@ -26,11 +26,11 @@ */ require '../../main.inc.php'; +require_once DOL_DOCUMENT_ROOT.'/core/class/html.formfile.class.php'; +require_once DOL_DOCUMENT_ROOT.'/core/class/html.formsocialcontrib.class.php'; require_once DOL_DOCUMENT_ROOT.'/compta/bank/class/account.class.php'; require_once DOL_DOCUMENT_ROOT.'/compta/sociales/class/chargesociales.class.php'; require_once DOL_DOCUMENT_ROOT.'/compta/sociales/class/paymentsocialcontribution.class.php'; -require_once DOL_DOCUMENT_ROOT.'/core/class/html.form.class.php'; -require_once DOL_DOCUMENT_ROOT.'/core/class/html.formsocialcontrib.class.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/tax.lib.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/date.lib.php'; require_once DOL_DOCUMENT_ROOT.'/user/class/user.class.php'; @@ -46,8 +46,14 @@ if (!empty($conf->accounting->enabled)) { $langs->loadLangs(array('compta', 'bills', 'banks', 'hrm')); $id = GETPOST('id', 'int'); +$ref = GETPOST('ref', 'alpha'); $action = GETPOST('action', 'aZ09'); -$confirm = GETPOST('confirm'); +$confirm = GETPOST('confirm', 'alpha'); +$cancel = GETPOST('cancel', 'aZ09'); +$contextpage = GETPOST('contextpage', 'aZ') ? GETPOST('contextpage', 'aZ') : 'myobjectcard'; // To manage different context of search +$backtopage = GETPOST('backtopage', 'alpha'); +$backtopageforcancel = GETPOST('backtopageforcancel', 'alpha'); + $fk_project = (GETPOST('fk_project') ? GETPOST('fk_project', 'int') : 0); $dateech = dol_mktime(GETPOST('echhour'), GETPOST('echmin'), GETPOST('echsec'), GETPOST('echmonth'), GETPOST('echday'), GETPOST('echyear')); @@ -56,11 +62,28 @@ $label = GETPOST('label', 'alpha'); $actioncode = GETPOST('actioncode'); $fk_user = GETPOST('userid', 'int'); +// Initialize technical objects $object = new ChargeSociales($db); +$extrafields = new ExtraFields($db); +$diroutputmassaction = $conf->tax->dir_output.'/temp/massgeneration/'.$user->id; +$hookmanager->initHooks(array('taxsocialcontributioncard', 'globalcard')); + +if (empty($action) && empty($id) && empty($ref)) { + $action = 'view'; +} + +// Load object if ($id > 0) { $object->fetch($id); } +$permissiontoread = $user->rights->tax->charges->lire; +$permissiontoadd = $user->rights->tax->charges->creer; // Used by the include of actions_addupdatedelete.inc.php and actions_lineupdown.inc.php +$permissiontodelete = $user->rights->tax->charges->supprimer || ($permissiontoadd && isset($object->status) && $object->status == $object::STATUS_DRAFT); +$permissionnote = $user->rights->tax->charges->creer; // Used by the include of actions_setnotes.inc.php +$permissiondellink = $user->rights->tax->charges->creer; // Used by the include of actions_dellink.inc.php +$upload_dir = $conf->tax->multidir_output[isset($object->entity) ? $object->entity : 1]; + // Security check $socid = GETPOST('socid', 'int'); if ($user->socid) { @@ -74,6 +97,12 @@ $result = restrictedArea($user, 'tax', $object->id, 'chargesociales', 'charges') * Actions */ +$parameters = array(); +$reshook = $hookmanager->executeHooks('doActions', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks +if ($reshook < 0) { + setEventMessages($hookmanager->error, $hookmanager->errors, 'errors'); +} + // Classify paid if ($action == 'confirm_paid' && $user->rights->tax->charges->creer && $confirm == 'yes') { $object->fetch($id); @@ -122,7 +151,7 @@ if ($action == 'setmode' && $user->rights->tax->charges->creer) { } } -// bank account +// Bank account if ($action == 'setbankaccount' && $user->rights->tax->charges->creer) { $object->fetch($id); $result = $object->setBankAccount(GETPOST('fk_account', 'int')); @@ -151,7 +180,7 @@ if ($action == 'confirm_delete' && $confirm == 'yes') { // Add social contribution if ($action == 'add' && $user->rights->tax->charges->creer) { - $amount = price2num(GETPOST('amount'), 'MT'); + $amount = price2num(GETPOST('amount', 'alpha'), 'MT'); if (!$dateech) { setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentities("Date")), null, 'errors'); @@ -189,7 +218,7 @@ if ($action == 'add' && $user->rights->tax->charges->creer) { if ($action == 'update' && !GETPOST("cancel") && $user->rights->tax->charges->creer) { - $amount = price2num(GETPOST('amount'), 'MT'); + $amount = price2num(GETPOST('amount', 'alpha'), 'MT'); if (!$dateech) { setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentities("Date")), null, 'errors'); @@ -297,6 +326,7 @@ if ($action == 'confirm_clone' && $confirm == 'yes' && ($user->rights->tax->char */ $form = new Form($db); +$formfile = new FormFile($db); $formsocialcontrib = new FormSocialContrib($db); $bankaccountstatic = new Account($db); if (!empty($conf->projet->enabled)) { @@ -308,7 +338,7 @@ $help_url = 'EN:Module_Taxes_and_social_contributions|FR:Module Taxes et dividen llxHeader("", $title, $help_url); -// Mode creation +// Form to create a social contribution if ($action == 'create') { print load_fiche_titre($langs->trans("NewSocialContribution")); @@ -411,11 +441,7 @@ if ($action == 'create') { print ''; } -/* *************************************************************************** */ -/* */ -/* Card Mode */ -/* */ -/* *************************************************************************** */ +// View mode if ($id > 0) { $object = new ChargeSociales($db); $result = $object->fetch($id); @@ -594,7 +620,7 @@ if ($id > 0) { } print ''; - // Bank Account + // Bank account if (!empty($conf->banque->enabled)) { print ''; print ''; } + // Other attributes + $parameters = array(); + $reshook = $hookmanager->executeHooks('formObjectOptions', $parameters, $object, $action); // Note that $action and $object may have been modified by hook + print $hookmanager->resPrint; + print '
'; @@ -614,6 +640,11 @@ if ($id > 0) { print '
'; print ''; @@ -627,7 +658,7 @@ if ($id > 0) { /* * Payments */ - $sql = "SELECT p.rowid, p.num_paiement as num_payment, datep as dp, p.amount,"; + $sql = "SELECT p.rowid, p.num_paiement as num_payment, p.datep as dp, p.amount,"; $sql .= " c.code as type_code,c.libelle as paiement_type,"; $sql .= ' ba.rowid as baid, ba.ref as baref, ba.label, ba.number as banumber, ba.account_number, ba.currency_code as bacurrency_code, ba.fk_accountancy_journal'; $sql .= " FROM ".MAIN_DB_PREFIX."paiementcharge as p"; @@ -637,7 +668,7 @@ if ($id > 0) { $sql .= ", ".MAIN_DB_PREFIX."chargesociales as cs"; $sql .= " WHERE p.fk_charge = ".((int) $id); $sql .= " AND p.fk_charge = cs.rowid"; - $sql .= " AND cs.entity IN (".getEntity('tax').")"; + $sql .= " AND cs.entity IN (".getEntity('sc').")"; $sql .= " ORDER BY dp DESC"; //print $sql; @@ -735,22 +766,15 @@ if ($id > 0) { print dol_get_fiche_end(); if ($action == 'edit') { - print '
'; - print ''; - print '   '; - print ''; - print '
'; - } + print $form->buttonsSaveCancel(); - if ($action == 'edit') { print "\n"; } - /* - * Actions buttons - */ + // Buttons for actions + if ($action != 'edit') { print '
'."\n"; @@ -788,6 +812,64 @@ if ($id > 0) { print "
"; } + + + // Select mail models is same action as presend + if (GETPOST('modelselected')) { + $action = 'presend'; + } + + if ($action != 'presend') { + print '
'; + print ''; // ancre + + $includedocgeneration = 1; + + // Documents + if ($includedocgeneration) { + $objref = dol_sanitizeFileName($object->ref); + $relativepath = $objref.'/'.$objref.'.pdf'; + $filedir = $conf->tax->dir_output.'/'.$objref; + $urlsource = $_SERVER["PHP_SELF"]."?id=".$object->id; + //$genallowed = $user->rights->tax->charges->lire; // If you can read, you can build the PDF to read content + $genallowed = 0; + $delallowed = $user->rights->tax->charges->creer; // If you can create/edit, you can remove a file on card + print $formfile->showdocuments('tax', $objref, $filedir, $urlsource, $genallowed, $delallowed, $object->model_pdf, 1, 0, 0, 28, 0, '', '', '', $langs->defaultlang); + } + + // Show links to link elements + //$linktoelem = $form->showLinkToObjectBlock($object, null, array('myobject')); + //$somethingshown = $form->showLinkedObjectBlock($object, $linktoelem); + + + print '
'; + + /* + $MAXEVENT = 10; + + $morehtmlcenter = dolGetButtonTitle($langs->trans('SeeAll'), '', 'fa fa-list-alt imgforviewmode', dol_buildpath('/mymodule/myobject_agenda.php', 1).'?id='.$object->id); + + // List of actions on element + include_once DOL_DOCUMENT_ROOT.'/core/class/html.formactions.class.php'; + $formactions = new FormActions($db); + $somethingshown = $formactions->showactions($object, $object->element.'@'.$object->module, (is_object($object->thirdparty) ? $object->thirdparty->id : 0), 1, '', $MAXEVENT, '', $morehtmlcenter); + */ + + print '
'; + } + + //Select mail models is same action as presend + if (GETPOST('modelselected')) { + $action = 'presend'; + } + + // Presend form + $modelmail = 'sc'; + $defaulttopic = 'InformationMessage'; + $diroutput = $conf->tax->dir_output; + $trackid = 'sc'.$object->id; + + include DOL_DOCUMENT_ROOT.'/core/tpl/card_presend.tpl.php'; } else { /* Social contribution not found */ dol_print_error('', $object->error); diff --git a/htdocs/compta/tva/card.php b/htdocs/compta/tva/card.php index ef09cd5aabc..530d18d17f9 100755 --- a/htdocs/compta/tva/card.php +++ b/htdocs/compta/tva/card.php @@ -306,7 +306,7 @@ if ($action == 'confirm_delete' && $confirm == 'yes') { } if ($action == 'update' && !GETPOST("cancel") && $user->rights->tax->charges->creer) { - $amount = price2num(GETPOST('amount')); + $amount = price2num(GETPOST('amount', 'alpha'), 'MT'); if (empty($amount)) { setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentities("Amount")), null, 'errors'); @@ -317,7 +317,7 @@ if ($action == 'update' && !GETPOST("cancel") && $user->rights->tax->charges->cr } else { $result = $object->fetch($id); - $object->amount = price2num($amount); + $object->amount = $amount; $result = $object->update($user); if ($result <= 0) { @@ -339,8 +339,8 @@ if ($action == 'confirm_clone' && $confirm == 'yes' && ($user->rights->tax->char $object->fetch($id); if ($object->id > 0) { - $object->paye = 0; $object->id = $object->ref = null; + $object->paye = 0; if (GETPOST('clone_label', 'alphanohtml')) { $object->label = GETPOST('clone_label', 'alphanohtml'); @@ -535,7 +535,7 @@ if ($action == 'create') { } // View mode -if ($id) { +if ($id > 0) { $head = vat_prepare_head($object); $totalpaye = $object->getSommePaiement(); @@ -705,7 +705,8 @@ if ($id) { $objp = $db->fetch_object($resql); print ''; - print ''.img_object($langs->trans("Payment"), "payment").' '.$objp->rowid.''; + print ''.img_object($langs->trans("Payment"), "payment").' '.$objp->rowid.''; + print ''; print ''.dol_print_date($db->jdate($objp->dp), 'day')."\n"; $labeltype = $langs->trans("PaymentType".$objp->type_code) != ("PaymentType".$objp->type_code) ? $langs->trans("PaymentType".$objp->type_code) : $objp->paiement_type; print "".$labeltype.' '.$objp->num_payment."\n"; @@ -768,7 +769,7 @@ if ($id) { if ($action == 'edit') { print $form->buttonsSaveCancel(); - print ""; + print "\n"; } From bfc8bb85a3d82b6ac989c740e0c515178b3f19e1 Mon Sep 17 00:00:00 2001 From: Marc de Lima Lucio <68746600+marc-dll@users.noreply.github.com> Date: Mon, 6 Dec 2021 18:23:47 +0100 Subject: [PATCH 17/27] FIX: thirparty ajax selector: no name or highlighting if at least ref and/or address displayed --- htdocs/societe/ajax/ajaxcompanies.php | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/htdocs/societe/ajax/ajaxcompanies.php b/htdocs/societe/ajax/ajaxcompanies.php index 89aa4f524b6..cbbcb14f361 100644 --- a/htdocs/societe/ajax/ajaxcompanies.php +++ b/htdocs/societe/ajax/ajaxcompanies.php @@ -125,15 +125,17 @@ if (GETPOST('newcompany') || GETPOST('socid', 'int') || GETPOST('id_fourn', 'int if ($resql) { while ($row = $db->fetch_array($resql)) { $label = ''; - if ($conf->global->SOCIETE_ADD_REF_IN_LIST) { + if (! empty($conf->global->SOCIETE_ADD_REF_IN_LIST)) { if (($row['client']) && (!empty($row['code_client']))) { $label = $row['code_client'].' - '; } if (($row['fournisseur']) && (!empty($row['code_fournisseur']))) { $label .= $row['code_fournisseur'].' - '; } - $label .= ' '.$row['name']; } + + $label .= $row['nom']; + if (!empty($conf->global->COMPANY_SHOW_ADDRESS_SELECTLIST)) { $label .= ($row['address'] ? ' - '.$row['address'] : '').($row['zip'] ? ' - '.$row['zip'] : '').($row['town'] ? ' '.$row['town'] : ''); if (!empty($row['country_code'])) { From fe40668f43998bf28bba206fc4d3ff89516095ed Mon Sep 17 00:00:00 2001 From: Francis Appels Date: Mon, 6 Dec 2021 20:32:44 +0100 Subject: [PATCH 18/27] Parameter 4 extrafieldsobjectkey seems to be required now. --- ChangeLog | 1 + htdocs/core/class/extrafields.class.php | 10 ++++------ 2 files changed, 5 insertions(+), 6 deletions(-) diff --git a/ChangeLog b/ChangeLog index 00962b10419..a70ff0d00e2 100644 --- a/ChangeLog +++ b/ChangeLog @@ -144,6 +144,7 @@ Following changes may create regressions for some external modules, but were nec * Method getDictvalue has been renamed into getDictionaryValue to match camel case rule. * To execute shell or command line command, your code must never use method like exec, shell_exec, popen, .. but must use the built-in method executeCLI() available into core/class/utils.class.php +* ExtraFields->showOutputField parameter 4 'extrafieldsobjectkey' is now required diff --git a/htdocs/core/class/extrafields.class.php b/htdocs/core/class/extrafields.class.php index 61c40499150..4eefdd4c6bc 100644 --- a/htdocs/core/class/extrafields.class.php +++ b/htdocs/core/class/extrafields.class.php @@ -1488,7 +1488,7 @@ class ExtraFields * @param string $key Key of attribute * @param string $value Value to show * @param string $moreparam To add more parameters on html input tag (only checkbox use html input for output rendering) - * @param string $extrafieldsobjectkey If defined (for example $object->table_element), function uses the new method to get extrafields data + * @param string $extrafieldsobjectkey Required (for example $object->table_element). * @return string Formated value */ public function showOutputField($key, $value, $moreparam = '', $extrafieldsobjectkey = '') @@ -1510,11 +1510,9 @@ class ExtraFields $help = $this->attributes[$extrafieldsobjectkey]['help'][$key]; $hidden = (empty($list) ? 1 : 0); // If $list empty, we are sure it is hidden, otherwise we show. If it depends on mode (view/create/edit form or list, this must be filtered by caller) } else { - // Old usage - $label = $this->attribute_label[$key]; - $type = $this->attribute_type[$key]; - $help = ''; // Not supported with old syntax - $hidden = 0; // hidden option only available for new syntax + // Old usage not allowed anymore + dol_syslog(get_class($this).'::showOutputField extrafieldsobjectkey required', LOG_WARNING); + return ''; } if ($hidden) { From ba507e7735ee91b9275487792af6244563f7cbe4 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Mon, 6 Dec 2021 20:53:01 +0100 Subject: [PATCH 19/27] css --- htdocs/theme/eldy/global.inc.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/theme/eldy/global.inc.php b/htdocs/theme/eldy/global.inc.php index 3c1a5abbe43..f61f5ab5c94 100644 --- a/htdocs/theme/eldy/global.inc.php +++ b/htdocs/theme/eldy/global.inc.php @@ -3607,7 +3607,7 @@ div.refidno { font-weight: normal; color: var(--refidnocolor); font-size: ; - line-height: 21px; + line-height: 1.4em; } div.refidno form { display: inline-block; From 5efa31204b4a6833e4d6b49e4f620fc3fde9f93c Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Tue, 7 Dec 2021 02:00:34 +0100 Subject: [PATCH 20/27] FIX ECM module was mixing contributions and vat and not showing salaries --- htdocs/core/ajax/ajaxdirpreview.php | 12 +++-- htdocs/core/ajax/ajaxdirtree.php | 4 +- htdocs/core/class/html.formfile.class.php | 9 +++- htdocs/ecm/index_auto.php | 57 ++++++++++++++--------- 4 files changed, 53 insertions(+), 29 deletions(-) diff --git a/htdocs/core/ajax/ajaxdirpreview.php b/htdocs/core/ajax/ajaxdirpreview.php index 63b4b3f7fc6..c4b79d89920 100644 --- a/htdocs/core/ajax/ajaxdirpreview.php +++ b/htdocs/core/ajax/ajaxdirpreview.php @@ -204,6 +204,8 @@ if ($type == 'directory') { 'contract', 'product', 'tax', + 'tax-vat', + 'salaries', 'project', 'project_task', 'fichinter', @@ -225,6 +227,7 @@ if ($type == 'directory') { // TODO change for multicompany sharing if ($module == 'company') { $upload_dir = $conf->societe->dir_output; + $excludefiles[] = '^contact$'; // The subdir 'contact' contains files of contacts. } elseif ($module == 'invoice') { $upload_dir = $conf->facture->dir_output; } elseif ($module == 'invoice_supplier') { @@ -243,6 +246,11 @@ if ($type == 'directory') { $upload_dir = $conf->product->dir_output; } elseif ($module == 'tax') { $upload_dir = $conf->tax->dir_output; + $excludefiles[] = '^vat$'; // The subdir 'vat' contains files of vats. + } elseif ($module == 'tax-vat') { + $upload_dir = $conf->tax->dir_output.'/vat'; + } elseif ($module == 'salaries') { + $upload_dir = $conf->salaries->dir_output; } elseif ($module == 'project') { $upload_dir = $conf->projet->dir_output; } elseif ($module == 'project_task') { @@ -280,10 +288,6 @@ if ($type == 'directory') { $textifempty = ($section ? $langs->trans("NoFileFound") : ($showonrightsize == 'featurenotyetavailable' ? $langs->trans("FeatureNotYetAvailable") : $langs->trans("NoFileFound"))); - if ($module == 'company') { - $excludefiles[] = '^contact$'; // The subdir 'contact' contains files of contacts with no id of thirdparty. - } - $filter = preg_quote($search_doc_ref, '/'); $filearray = dol_dir_list($upload_dir, "files", 1, $filter, $excludefiles, $sortfield, $sorting, 1); diff --git a/htdocs/core/ajax/ajaxdirtree.php b/htdocs/core/ajax/ajaxdirtree.php index d9a2c250b89..19c389ec7f8 100644 --- a/htdocs/core/ajax/ajaxdirtree.php +++ b/htdocs/core/ajax/ajaxdirtree.php @@ -125,7 +125,7 @@ $userstatic = new User($db); $form = new Form($db); $ecmdirstatic = new EcmDirectory($db); -// Load full tree of ECM module from database. We will use it to define nbofsubdir and nboffilesinsubdir +// Load full manual tree of ECM module from database. We will use it to define nbofsubdir and nboffilesinsubdir if (empty($sqltree)) { $sqltree = $ecmdirstatic->get_full_arbo(0); } @@ -169,7 +169,7 @@ if (!empty($conf->use_javascript_ajax) && empty($conf->global->MAIN_ECM_DISABLE_ if (empty($conf->use_javascript_ajax) || !empty($conf->global->MAIN_ECM_DISABLE_JS)) { print '
    '; - // Load full tree from database. We will use it to define nbofsubdir and nboffilesinsubdir + // Load full manual tree from database. We will use it to define nbofsubdir and nboffilesinsubdir if (empty($sqltree)) { $sqltree = $ecmdirstatic->get_full_arbo(0); // Slow } diff --git a/htdocs/core/class/html.formfile.class.php b/htdocs/core/class/html.formfile.class.php index e30f35758d1..cf3ff8dae4e 100644 --- a/htdocs/core/class/html.formfile.class.php +++ b/htdocs/core/class/html.formfile.class.php @@ -1676,6 +1676,12 @@ class FormFile } elseif ($modulepart == 'tax') { include_once DOL_DOCUMENT_ROOT.'/compta/sociales/class/chargesociales.class.php'; $object_instance = new ChargeSociales($this->db); + } elseif ($modulepart == 'tax-vat') { + include_once DOL_DOCUMENT_ROOT.'/compta/tva/class/tva.class.php'; + $object_instance = new Tva($this->db); + } elseif ($modulepart == 'salaries') { + include_once DOL_DOCUMENT_ROOT.'/salaries/class/salary.class.php'; + $object_instance = new Salary($this->db); } elseif ($modulepart == 'project') { include_once DOL_DOCUMENT_ROOT.'/projet/class/project.class.php'; $object_instance = new Project($this->db); @@ -1723,6 +1729,7 @@ class FormFile } //var_dump($filearray); + //var_dump($object_instance); // Get list of files stored into database for same relative directory $relativepathfromroot = preg_replace('/'.preg_quote(DOL_DATA_ROOT.'/', '/').'/', '', $upload_dir); @@ -1752,7 +1759,7 @@ class FormFile // To show ref or specific information according to view to show (defined by $modulepart) // $modulepart can be $object->table_name (that is 'mymodule_myobject') or $object->element.'-'.$module (for compatibility purpose) $reg = array(); - if ($modulepart == 'company' || $modulepart == 'tax') { + if ($modulepart == 'company' || $modulepart == 'tax' || $modulepart == 'tax-vat' || $modulepart == 'salaries') { preg_match('/(\d+)\/[^\/]+$/', $relativefile, $reg); $id = (isset($reg[1]) ? $reg[1] : ''); } elseif ($modulepart == 'invoice_supplier') { diff --git a/htdocs/ecm/index_auto.php b/htdocs/ecm/index_auto.php index 7f098951fe7..c4ec6afc90b 100644 --- a/htdocs/ecm/index_auto.php +++ b/htdocs/ecm/index_auto.php @@ -310,59 +310,73 @@ $rowspan = 0; $sectionauto = array(); if (!empty($conf->global->ECM_AUTO_TREE_ENABLED)) { if (!empty($conf->product->enabled) || !empty($conf->service->enabled)) { - $langs->load("products"); $rowspan++; $sectionauto[] = array('level'=>1, 'module'=>'product', 'test'=>(!empty($conf->product->enabled) || !empty($conf->service->enabled)), 'label'=>$langs->trans("ProductsAndServices"), 'desc'=>$langs->trans("ECMDocsByProducts")); + $langs->load("products"); + $rowspan++; $sectionauto[] = array('position'=>10, 'level'=>1, 'module'=>'product', 'test'=>(!empty($conf->product->enabled) || !empty($conf->service->enabled)), 'label'=>$langs->trans("ProductsAndServices"), 'desc'=>$langs->trans("ECMDocsByProducts")); } if (!empty($conf->societe->enabled)) { - $rowspan++; $sectionauto[] = array('level'=>1, 'module'=>'company', 'test'=>$conf->societe->enabled, 'label'=>$langs->trans("ThirdParties"), 'desc'=>$langs->trans("ECMDocsBy", $langs->transnoentitiesnoconv("ThirdParties"))); + $rowspan++; $sectionauto[] = array('position'=>20, 'level'=>1, 'module'=>'company', 'test'=>$conf->societe->enabled, 'label'=>$langs->trans("ThirdParties"), 'desc'=>$langs->trans("ECMDocsBy", $langs->transnoentitiesnoconv("ThirdParties"))); } if (!empty($conf->propal->enabled)) { - $rowspan++; $sectionauto[] = array('level'=>1, 'module'=>'propal', 'test'=>$conf->propal->enabled, 'label'=>$langs->trans("Proposals"), 'desc'=>$langs->trans("ECMDocsBy", $langs->transnoentitiesnoconv("Proposals"))); + $rowspan++; $sectionauto[] = array('position'=>30, 'level'=>1, 'module'=>'propal', 'test'=>$conf->propal->enabled, 'label'=>$langs->trans("Proposals"), 'desc'=>$langs->trans("ECMDocsBy", $langs->transnoentitiesnoconv("Proposals"))); } if (!empty($conf->contrat->enabled)) { - $rowspan++; $sectionauto[] = array('level'=>1, 'module'=>'contract', 'test'=>$conf->contrat->enabled, 'label'=>$langs->trans("Contracts"), 'desc'=>$langs->trans("ECMDocsBy", $langs->transnoentitiesnoconv("Contracts"))); + $rowspan++; $sectionauto[] = array('position'=>40, 'level'=>1, 'module'=>'contract', 'test'=>$conf->contrat->enabled, 'label'=>$langs->trans("Contracts"), 'desc'=>$langs->trans("ECMDocsBy", $langs->transnoentitiesnoconv("Contracts"))); } if (!empty($conf->commande->enabled)) { - $rowspan++; $sectionauto[] = array('level'=>1, 'module'=>'order', 'test'=>$conf->commande->enabled, 'label'=>$langs->trans("CustomersOrders"), 'desc'=>$langs->trans("ECMDocsBy", $langs->transnoentitiesnoconv("Orders"))); + $rowspan++; $sectionauto[] = array('position'=>50, 'level'=>1, 'module'=>'order', 'test'=>$conf->commande->enabled, 'label'=>$langs->trans("CustomersOrders"), 'desc'=>$langs->trans("ECMDocsBy", $langs->transnoentitiesnoconv("Orders"))); } if (!empty($conf->facture->enabled)) { - $rowspan++; $sectionauto[] = array('level'=>1, 'module'=>'invoice', 'test'=>$conf->facture->enabled, 'label'=>$langs->trans("CustomersInvoices"), 'desc'=>$langs->trans("ECMDocsBy", $langs->transnoentitiesnoconv("Invoices"))); + $rowspan++; $sectionauto[] = array('position'=>60, 'level'=>1, 'module'=>'invoice', 'test'=>$conf->facture->enabled, 'label'=>$langs->trans("CustomersInvoices"), 'desc'=>$langs->trans("ECMDocsBy", $langs->transnoentitiesnoconv("Invoices"))); } if (!empty($conf->supplier_proposal->enabled)) { - $langs->load("supplier_proposal"); $rowspan++; $sectionauto[] = array('level'=>1, 'module'=>'supplier_proposal', 'test'=>$conf->supplier_proposal->enabled, 'label'=>$langs->trans("SupplierProposals"), 'desc'=>$langs->trans("ECMDocsBy", $langs->transnoentitiesnoconv("SupplierProposals"))); + $langs->load("supplier_proposal"); + $rowspan++; $sectionauto[] = array('position'=>70, 'level'=>1, 'module'=>'supplier_proposal', 'test'=>$conf->supplier_proposal->enabled, 'label'=>$langs->trans("SupplierProposals"), 'desc'=>$langs->trans("ECMDocsBy", $langs->transnoentitiesnoconv("SupplierProposals"))); } if (!empty($conf->fournisseur->enabled) && empty($conf->global->MAIN_USE_NEW_SUPPLIERMOD) || !empty($conf->supplier_order->enabled)) { - $rowspan++; $sectionauto[] = array('level'=>1, 'module'=>'order_supplier', 'test'=>(!empty($conf->fournisseur->enabled) && empty($conf->global->MAIN_USE_NEW_SUPPLIERMOD) || !empty($conf->supplier_order->enabled)), 'label'=>$langs->trans("SuppliersOrders"), 'desc'=>$langs->trans("ECMDocsBy", $langs->transnoentitiesnoconv("PurchaseOrders"))); + $rowspan++; $sectionauto[] = array('position'=>80, 'level'=>1, 'module'=>'order_supplier', 'test'=>(!empty($conf->fournisseur->enabled) && empty($conf->global->MAIN_USE_NEW_SUPPLIERMOD) || !empty($conf->supplier_order->enabled)), 'label'=>$langs->trans("SuppliersOrders"), 'desc'=>$langs->trans("ECMDocsBy", $langs->transnoentitiesnoconv("PurchaseOrders"))); } if (!empty($conf->fournisseur->enabled) && empty($conf->global->MAIN_USE_NEW_SUPPLIERMOD) || !empty($conf->supplier_invoice->enabled)) { - $rowspan++; $sectionauto[] = array('level'=>1, 'module'=>'invoice_supplier', 'test'=>(!empty($conf->fournisseur->enabled) && empty($conf->global->MAIN_USE_NEW_SUPPLIERMOD) || !empty($conf->supplier_invoice->enabled)), 'label'=>$langs->trans("SuppliersInvoices"), 'desc'=>$langs->trans("ECMDocsBy", $langs->transnoentitiesnoconv("SupplierInvoices"))); + $rowspan++; $sectionauto[] = array('position'=>90, 'level'=>1, 'module'=>'invoice_supplier', 'test'=>(!empty($conf->fournisseur->enabled) && empty($conf->global->MAIN_USE_NEW_SUPPLIERMOD) || !empty($conf->supplier_invoice->enabled)), 'label'=>$langs->trans("SuppliersInvoices"), 'desc'=>$langs->trans("ECMDocsBy", $langs->transnoentitiesnoconv("SupplierInvoices"))); } if (!empty($conf->tax->enabled)) { - $langs->load("compta"); $rowspan++; $sectionauto[] = array('level'=>1, 'module'=>'tax', 'test'=>$conf->tax->enabled, 'label'=>$langs->trans("SocialContributions"), 'desc'=>$langs->trans("ECMDocsBy", $langs->transnoentitiesnoconv("SocialContributions"))); + $langs->load("compta"); + $rowspan++; $sectionauto[] = array('position'=>100, 'level'=>1, 'module'=>'tax', 'test'=>$conf->tax->enabled, 'label'=>$langs->trans("SocialContributions"), 'desc'=>$langs->trans("ECMDocsBy", $langs->transnoentitiesnoconv("SocialContributions"))); + $rowspan++; $sectionauto[] = array('position'=>110, 'level'=>1, 'module'=>'tax-vat', 'test'=>$conf->tax->enabled, 'label'=>$langs->trans("VAT"), 'desc'=>$langs->trans("ECMDocsBy", $langs->transnoentitiesnoconv("VAT"))); + } + if (!empty($conf->salaries->enabled)) { + $langs->load("compta"); + $rowspan++; $sectionauto[] = array('position'=>120, 'level'=>1, 'module'=>'salaries', 'test'=>$conf->salaries->enabled, 'label'=>$langs->trans("Salaries"), 'desc'=>$langs->trans("ECMDocsBy", $langs->transnoentitiesnoconv("Salaries"))); } if (!empty($conf->projet->enabled)) { - $rowspan++; $sectionauto[] = array('level'=>1, 'module'=>'project', 'test'=>$conf->projet->enabled, 'label'=>$langs->trans("Projects"), 'desc'=>$langs->trans("ECMDocsBy", $langs->transnoentitiesnoconv("Projects"))); - $rowspan++; $sectionauto[] = array('level'=>1, 'module'=>'project_task', 'test'=>$conf->projet->enabled, 'label'=>$langs->trans("Tasks"), 'desc'=>$langs->trans("ECMDocsBy", $langs->transnoentitiesnoconv("Tasks"))); + $rowspan++; $sectionauto[] = array('position'=>130, 'level'=>1, 'module'=>'project', 'test'=>$conf->projet->enabled, 'label'=>$langs->trans("Projects"), 'desc'=>$langs->trans("ECMDocsBy", $langs->transnoentitiesnoconv("Projects"))); + $rowspan++; $sectionauto[] = array('position'=>140, 'level'=>1, 'module'=>'project_task', 'test'=>$conf->projet->enabled, 'label'=>$langs->trans("Tasks"), 'desc'=>$langs->trans("ECMDocsBy", $langs->transnoentitiesnoconv("Tasks"))); } if (!empty($conf->ficheinter->enabled)) { - $langs->load("interventions"); $rowspan++; $sectionauto[] = array('level'=>1, 'module'=>'fichinter', 'test'=>$conf->ficheinter->enabled, 'label'=>$langs->trans("Interventions"), 'desc'=>$langs->trans("ECMDocsBy", $langs->transnoentitiesnoconv("Interventions"))); + $langs->load("interventions"); + $rowspan++; $sectionauto[] = array('position'=>150, 'level'=>1, 'module'=>'fichinter', 'test'=>$conf->ficheinter->enabled, 'label'=>$langs->trans("Interventions"), 'desc'=>$langs->trans("ECMDocsBy", $langs->transnoentitiesnoconv("Interventions"))); } if (!empty($conf->expensereport->enabled)) { - $langs->load("trips"); $rowspan++; $sectionauto[] = array('level'=>1, 'module'=>'expensereport', 'test'=>$conf->expensereport->enabled, 'label'=>$langs->trans("ExpenseReports"), 'desc'=>$langs->trans("ECMDocsBy", $langs->transnoentitiesnoconv("ExpenseReports"))); + $langs->load("trips"); + $rowspan++; $sectionauto[] = array('position'=>160, 'level'=>1, 'module'=>'expensereport', 'test'=>$conf->expensereport->enabled, 'label'=>$langs->trans("ExpenseReports"), 'desc'=>$langs->trans("ECMDocsBy", $langs->transnoentitiesnoconv("ExpenseReports"))); } if (!empty($conf->holiday->enabled)) { - $langs->load("holiday"); $rowspan++; $sectionauto[] = array('level'=>1, 'module'=>'holiday', 'test'=>$conf->holiday->enabled, 'label'=>$langs->trans("Holidays"), 'desc'=>$langs->trans("ECMDocsBy", $langs->transnoentitiesnoconv("Holidays"))); + $langs->load("holiday"); + $rowspan++; $sectionauto[] = array('position'=>170, 'level'=>1, 'module'=>'holiday', 'test'=>$conf->holiday->enabled, 'label'=>$langs->trans("Holidays"), 'desc'=>$langs->trans("ECMDocsBy", $langs->transnoentitiesnoconv("Holidays"))); } if (!empty($conf->banque->enabled)) { - $langs->load("banks"); $rowspan++; $sectionauto[] = array('level'=>1, 'module'=>'banque', 'test'=>$conf->banque->enabled, 'label'=>$langs->trans("BankAccount"), 'desc'=>$langs->trans("ECMDocsBy", $langs->transnoentitiesnoconv("BankAccount"))); - $rowspan++; $sectionauto[] = array('level'=>1, 'module'=>'chequereceipt', 'test'=>$conf->banque->enabled, 'label'=>$langs->trans("CheckReceipt"), 'desc'=>$langs->trans("ECMDocsBy", $langs->transnoentitiesnoconv("CheckReceipt"))); + $langs->load("banks"); + $rowspan++; $sectionauto[] = array('position'=>180, 'level'=>1, 'module'=>'banque', 'test'=>$conf->banque->enabled, 'label'=>$langs->trans("BankAccount"), 'desc'=>$langs->trans("ECMDocsBy", $langs->transnoentitiesnoconv("BankAccount"))); + $rowspan++; $sectionauto[] = array('position'=>190, 'level'=>1, 'module'=>'chequereceipt', 'test'=>$conf->banque->enabled, 'label'=>$langs->trans("CheckReceipt"), 'desc'=>$langs->trans("ECMDocsBy", $langs->transnoentitiesnoconv("CheckReceipt"))); } if (!empty($conf->mrp->enabled)) { - $langs->load("mrp"); $rowspan++; $sectionauto[] = array('level'=>1, 'module'=>'mrp-mo', 'test'=>$conf->mrp->enabled, 'label'=>$langs->trans("MOs"), 'desc'=>$langs->trans("ECMDocsBy", $langs->transnoentitiesnoconv("ManufacturingOrders"))); + $langs->load("mrp"); + $rowspan++; $sectionauto[] = array('position'=>200, 'level'=>1, 'module'=>'mrp-mo', 'test'=>$conf->mrp->enabled, 'label'=>$langs->trans("MOs"), 'desc'=>$langs->trans("ECMDocsBy", $langs->transnoentitiesnoconv("ManufacturingOrders"))); } if (!empty($conf->recruitment->enabled)) { - $langs->load("recruitment"); $rowspan++; $sectionauto[] = array('level'=>1, 'module'=>'recruitment-recruitmentcandidature', 'test'=>$conf->recruitment->enabled, 'label'=>$langs->trans("Candidatures"), 'desc'=>$langs->trans("ECMDocsBy", $langs->transnoentitiesnoconv("JobApplications"))); + $langs->load("recruitment"); + $rowspan++; $sectionauto[] = array('position'=>210, 'level'=>1, 'module'=>'recruitment-recruitmentcandidature', 'test'=>$conf->recruitment->enabled, 'label'=>$langs->trans("Candidatures"), 'desc'=>$langs->trans("ECMDocsBy", $langs->transnoentitiesnoconv("JobApplications"))); } - $rowspan++; $sectionauto[] = array('level'=>1, 'module'=>'user', 'test'=>1, 'label'=>$langs->trans("Users"), 'desc'=>$langs->trans("ECMDocsBy", $langs->transnoentitiesnoconv("Users"))); + $rowspan++; $sectionauto[] = array('position'=>220, 'level'=>1, 'module'=>'user', 'test'=>1, 'label'=>$langs->trans("Users"), 'desc'=>$langs->trans("ECMDocsBy", $langs->transnoentitiesnoconv("Users"))); $parameters = array(); $reshook = $hookmanager->executeHooks('addSectionECMAuto', $parameters); @@ -439,7 +453,7 @@ if (empty($action) || $action == 'file_manager' || preg_match('/refresh/i', $act $oldvallevel = 0; foreach ($sectionauto as $key => $val) { if (empty($val['test'])) { - continue; // If condition to show is ok + continue; // If condition to show the ECM auto directory is ok } print '