From ac740e0a93d82f1f0921515705778cdb3a0bff3a Mon Sep 17 00:00:00 2001 From: atm-lena Date: Fri, 4 Mar 2022 11:28:03 +0100 Subject: [PATCH 1/8] Add pages to products list in inventory --- htdocs/product/inventory/inventory.php | 25 ++++++++++++++++++++++++- 1 file changed, 24 insertions(+), 1 deletion(-) diff --git a/htdocs/product/inventory/inventory.php b/htdocs/product/inventory/inventory.php index 95c9e2972cb..fc8b7c5cc35 100644 --- a/htdocs/product/inventory/inventory.php +++ b/htdocs/product/inventory/inventory.php @@ -40,6 +40,16 @@ $confirm = GETPOST('confirm', 'alpha'); $cancel = GETPOST('cancel', 'aZ09'); $contextpage = GETPOST('contextpage', 'aZ') ?GETPOST('contextpage', 'aZ') : 'inventorycard'; // To manage different context of search $backtopage = GETPOST('backtopage', 'alpha'); +$listoffset = GETPOST('listoffset', 'alpha'); +$limit = GETPOST('limit', 'int') > 0 ?GETPOST('limit', 'int') : $conf->liste_limit; +$page = GETPOSTISSET('pageplusone') ? (GETPOST('pageplusone') - 1) : GETPOST("page", 'int'); +if (empty($page) || $page == -1) { + $page = 0; +} +$offset = $limit * $page; +$pageprev = $page - 1; +$pagenext = $page + 1; +$savlimit = $limit; $fk_warehouse = GETPOST('fk_warehouse', 'int'); $fk_product = GETPOST('fk_product', 'int'); @@ -228,6 +238,7 @@ if (empty($reshook)) { $resql = $db->query($sql); if ($resql) { $num = $db->num_rows($resql); + $i = 0; $totalarray = array(); $inventoryline = new InventoryLine($db); @@ -284,7 +295,6 @@ if (empty($reshook)) { } } - $backurlforlist = DOL_URL_ROOT.'/product/inventory/list.php'; $backtopage = DOL_URL_ROOT.'/product/inventory/inventory.php?id='.$object->id; @@ -396,6 +406,14 @@ jQuery(document).ready(function() { // Part to show record if ($object->id > 0) { + + $param = '&id='.$object->id; + $param .= '&action=updateinventorylines'; + if ($limit > 0 && $limit != $conf->liste_limit) { + $param .= '&limit='.urlencode($limit); + } + $paramwithsearch = $param; + $res = $object->fetch_optionals(); $head = inventoryPrepareHead($object); @@ -905,6 +923,7 @@ if ($object->id > 0) { $sql .= ' id.fk_product, id.batch, id.qty_stock, id.qty_view, id.qty_regulated, id.fk_movement'; $sql .= ' FROM '.MAIN_DB_PREFIX.'inventorydet as id'; $sql .= ' WHERE id.fk_inventory = '.((int) $object->id); + $sql .= $db->plimit($limit + 1, $offset); $cacheOfProducts = array(); $cacheOfWarehouses = array(); @@ -914,6 +933,10 @@ if ($object->id > 0) { if ($resql) { $num = $db->num_rows($resql); + if (!empty($savlimit != 0) || $num > $limit || $page) { + print_fleche_navigation($page, $_SERVER["PHP_SELF"], $paramwithsearch, ($num > $limit), '', '',$limit, $num); + } + $i = 0; $hasinput = false; $totalarray = array(); From f3fb0ffd8a37966ee2d27c3b9c9854a69d75d97e Mon Sep 17 00:00:00 2001 From: atm-lena Date: Fri, 4 Mar 2022 16:44:15 +0100 Subject: [PATCH 2/8] Keep qty value between pages --- htdocs/core/actions_addupdatedelete.inc.php | 4 +- htdocs/product/inventory/inventory.php | 64 ++++++++++++++++----- 2 files changed, 52 insertions(+), 16 deletions(-) diff --git a/htdocs/core/actions_addupdatedelete.inc.php b/htdocs/core/actions_addupdatedelete.inc.php index 4857902b8cc..0a6151a5f60 100644 --- a/htdocs/core/actions_addupdatedelete.inc.php +++ b/htdocs/core/actions_addupdatedelete.inc.php @@ -28,6 +28,7 @@ // $permissiontodelete must be defined // $backurlforlist must be defined // $backtopage may be defined +// $gotopage // $triggermodname may be defined if (!empty($permissionedit) && empty($permissiontoadd)) { @@ -348,8 +349,7 @@ if ($action == 'confirm_deleteline' && $confirm == 'yes' && !empty($permissionto } setEventMessages($langs->trans('RecordDeleted'), null, 'mesgs'); - - header('Location: '.$_SERVER["PHP_SELF"].'?id='.$object->id); + header('Location: '.((empty($gotopage)) ? $_SERVER["PHP_SELF"].'?id='.$object->id : $gotopage)); exit; } else { $error++; diff --git a/htdocs/product/inventory/inventory.php b/htdocs/product/inventory/inventory.php index fc8b7c5cc35..480dbbaa27d 100644 --- a/htdocs/product/inventory/inventory.php +++ b/htdocs/product/inventory/inventory.php @@ -49,7 +49,6 @@ if (empty($page) || $page == -1) { $offset = $limit * $page; $pageprev = $page - 1; $pagenext = $page + 1; -$savlimit = $limit; $fk_warehouse = GETPOST('fk_warehouse', 'int'); $fk_product = GETPOST('fk_product', 'int'); @@ -104,6 +103,13 @@ if (empty($conf->global->MAIN_USE_ADVANCED_PERMS)) { $now = dol_now(); +//Parameters Page +$param = '&id='.$object->id; +if ($limit > 0 && $limit != $conf->liste_limit) { + $param .= '&limit='.urlencode($limit); +} +$paramwithsearch = $param; + /* * Actions @@ -232,6 +238,7 @@ if (empty($reshook)) { $sql .= ' id.fk_product, id.batch, id.qty_stock, id.qty_view, id.qty_regulated'; $sql .= ' FROM '.MAIN_DB_PREFIX.'inventorydet as id'; $sql .= ' WHERE id.fk_inventory = '.((int) $object->id); + $sql .= $db->plimit($limit, $offset); $db->begin(); @@ -295,6 +302,10 @@ if (empty($reshook)) { } } + if($action == 'confirm_deleteline'){ + $gotopage = $_SERVER["PHP_SELF"].'?id='.$object->id.'&page='.$page.$paramwithsearch; + } + $backurlforlist = DOL_URL_ROOT.'/product/inventory/list.php'; $backtopage = DOL_URL_ROOT.'/product/inventory/inventory.php?id='.$object->id; @@ -407,13 +418,6 @@ jQuery(document).ready(function() { // Part to show record if ($object->id > 0) { - $param = '&id='.$object->id; - $param .= '&action=updateinventorylines'; - if ($limit > 0 && $limit != $conf->liste_limit) { - $param .= '&limit='.urlencode($limit); - } - $paramwithsearch = $param; - $res = $object->fetch_optionals(); $head = inventoryPrepareHead($object); @@ -427,7 +431,7 @@ if ($object->id > 0) { } // Confirmation to delete line if ($action == 'deleteline') { - $formconfirm = $form->formconfirm($_SERVER["PHP_SELF"].'?id='.$object->id.'&lineid='.$lineid, $langs->trans('DeleteLine'), $langs->trans('ConfirmDeleteLine'), 'confirm_deleteline', '', 0, 1); + $formconfirm = $form->formconfirm($_SERVER["PHP_SELF"].'?id='.$object->id.'&lineid='.$lineid.'&page='.$page.$paramwithsearch, $langs->trans('DeleteLine'), $langs->trans('ConfirmDeleteLine'), 'confirm_deleteline', '', 0, 1); } // Clone confirmation @@ -923,7 +927,7 @@ if ($object->id > 0) { $sql .= ' id.fk_product, id.batch, id.qty_stock, id.qty_view, id.qty_regulated, id.fk_movement'; $sql .= ' FROM '.MAIN_DB_PREFIX.'inventorydet as id'; $sql .= ' WHERE id.fk_inventory = '.((int) $object->id); - $sql .= $db->plimit($limit + 1, $offset); + $sql .= $db->plimit($limit, $offset); $cacheOfProducts = array(); $cacheOfWarehouses = array(); @@ -933,8 +937,8 @@ if ($object->id > 0) { if ($resql) { $num = $db->num_rows($resql); - if (!empty($savlimit != 0) || $num > $limit || $page) { - print_fleche_navigation($page, $_SERVER["PHP_SELF"], $paramwithsearch, ($num > $limit), '', '',$limit, $num); + if (!empty($limit != 0) || $num > $limit || $page) { + print_fleche_navigation($page, $_SERVER["PHP_SELF"], $paramwithsearch, ($num >= $limit), '', '',$limit); } $i = 0; @@ -1014,7 +1018,7 @@ if ($object->id > 0) { // Picto delete line print ''; - print ''.img_delete().''; + print ''.img_delete().''; $qty_tmp = price2num(GETPOST("id_".$obj->rowid."_input_tmp", 'MS')) >= 0 ? GETPOST("id_".$obj->rowid."_input_tmp") : $qty_view; print ''; print ''; @@ -1048,7 +1052,6 @@ if ($object->id > 0) { print ''; - // Call method to disable the button if no qty entered yet for inventory if ($object->status != $object::STATUS_VALIDATED || !$hasinput) { @@ -1060,6 +1063,39 @@ if ($object->id > 0) { '; } print ''; + + + print ''; + } // End of page From 4e8dd1b6a582f39374b9017000643ffbb0704c7e Mon Sep 17 00:00:00 2001 From: atm-lena Date: Tue, 8 Mar 2022 10:02:30 +0100 Subject: [PATCH 3/8] Delete function disable button disablebuttonmakemovementandclose() --- htdocs/langs/en_US/stocks.lang | 4 +-- htdocs/product/inventory/inventory.php | 34 -------------------------- 2 files changed, 2 insertions(+), 36 deletions(-) diff --git a/htdocs/langs/en_US/stocks.lang b/htdocs/langs/en_US/stocks.lang index 98faab0c423..af06ce7e94c 100644 --- a/htdocs/langs/en_US/stocks.lang +++ b/htdocs/langs/en_US/stocks.lang @@ -251,7 +251,7 @@ SelectAStockMovementFileToImport=select a stock movement file to import InfoTemplateImport=Uploaded file needs to have this format (* are mandatory fields):
Source Warehouse* | Target Warehouse* | Product* | Quantity* | Lot/serial number
CSV character separator must be "%s" LabelOfInventoryMovemement=Inventory %s ReOpen=Reopen -ConfirmFinish=Do you confirm the closing of the inventory ? This will generate all stock movements to update your stock to the real qty you entered into the inventory. +ConfirmFinish=Do you confirm the closing of the inventory ? This will generate all stock movements to update your stock to the real qty you entered into the inventory.

No stock movement will be made on products that do not have an actual quantity entered. ObjectNotFound=%s not found MakeMovementsAndClose=Generate movements and close AutofillWithExpected=Fill real quantity with expected quantity @@ -271,4 +271,4 @@ ErrorCantFindCodeInInventory=Can't find the following code in inventory QtyWasAddedToTheScannedBarcode=Success !! The quantity was added to all the requested barcode. You can close the Scanner tool. StockChangeDisabled=Change on stock disabled NoWarehouseDefinedForTerminal=No warehouse defined for terminal -ClearQtys=Clear all quantities \ No newline at end of file +ClearQtys=Clear all quantities diff --git a/htdocs/product/inventory/inventory.php b/htdocs/product/inventory/inventory.php index 480dbbaa27d..385aae39248 100644 --- a/htdocs/product/inventory/inventory.php +++ b/htdocs/product/inventory/inventory.php @@ -393,28 +393,6 @@ $help_url = ''; llxHeader('', $langs->trans('Inventory'), $help_url); -// Disable button Generate movement if data were modified and not saved -print ''; - - // Part to show record if ($object->id > 0) { @@ -607,7 +585,6 @@ if ($object->id > 0) { objecttofill.value = object.innerText; }) console.log("Values filled (after click on fillwithexpected)"); - disablebuttonmakemovementandclose(); return false; });'; print '});'; @@ -858,7 +835,6 @@ if ($object->id > 0) { id = id.split("_")[1]; tmpvalue = $("#id_"+id+"_input_tmp").val() $("#id_"+id+"_input")[0].value = tmpvalue; - disablebuttonmakemovementandclose(); return false; /* disable submit */ }); });'; @@ -1052,16 +1028,6 @@ if ($object->id > 0) { print ''; - // Call method to disable the button if no qty entered yet for inventory - - if ($object->status != $object::STATUS_VALIDATED || !$hasinput) { - print ''; - } print ''; From 85628bad219028699b53c1e4b708142b4a3a63a6 Mon Sep 17 00:00:00 2001 From: atm-lena Date: Tue, 8 Mar 2022 10:20:58 +0100 Subject: [PATCH 4/8] Fix save button --- htdocs/product/inventory/inventory.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/product/inventory/inventory.php b/htdocs/product/inventory/inventory.php index 385aae39248..ea51080803e 100644 --- a/htdocs/product/inventory/inventory.php +++ b/htdocs/product/inventory/inventory.php @@ -516,7 +516,7 @@ if ($object->id > 0) { print dol_get_fiche_end(); - print '
'; + print ''; print ''; print ''; print ''; From 38e0a8817d4f9688398523ce77bcfc4be993a836 Mon Sep 17 00:00:00 2001 From: stickler-ci Date: Tue, 8 Mar 2022 09:49:31 +0000 Subject: [PATCH 5/8] Fixing style errors. --- htdocs/product/inventory/inventory.php | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/htdocs/product/inventory/inventory.php b/htdocs/product/inventory/inventory.php index ea51080803e..34aca5ef35f 100644 --- a/htdocs/product/inventory/inventory.php +++ b/htdocs/product/inventory/inventory.php @@ -302,7 +302,7 @@ if (empty($reshook)) { } } - if($action == 'confirm_deleteline'){ + if ($action == 'confirm_deleteline') { $gotopage = $_SERVER["PHP_SELF"].'?id='.$object->id.'&page='.$page.$paramwithsearch; } @@ -395,7 +395,6 @@ llxHeader('', $langs->trans('Inventory'), $help_url); // Part to show record if ($object->id > 0) { - $res = $object->fetch_optionals(); $head = inventoryPrepareHead($object); @@ -914,7 +913,7 @@ if ($object->id > 0) { $num = $db->num_rows($resql); if (!empty($limit != 0) || $num > $limit || $page) { - print_fleche_navigation($page, $_SERVER["PHP_SELF"], $paramwithsearch, ($num >= $limit), '', '',$limit); + print_fleche_navigation($page, $_SERVER["PHP_SELF"], $paramwithsearch, ($num >= $limit), '', '', $limit); } $i = 0; @@ -1061,7 +1060,6 @@ if ($object->id > 0) { }); }); '; - } // End of page From 7a6a980b69fac8d00e548c24f58d3f9c5b29c62d Mon Sep 17 00:00:00 2001 From: stickler-ci Date: Fri, 22 Apr 2022 07:36:56 +0000 Subject: [PATCH 6/8] Fixing style errors. --- htdocs/product/inventory/inventory.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/product/inventory/inventory.php b/htdocs/product/inventory/inventory.php index 05e8e50d514..0ee1806335c 100644 --- a/htdocs/product/inventory/inventory.php +++ b/htdocs/product/inventory/inventory.php @@ -1190,7 +1190,7 @@ if ($object->id > 0) { } print ''; -print ''; - - // Part to show record if ($object->id > 0) { $res = $object->fetch_optionals(); @@ -1207,7 +1183,6 @@ print ''; From 99efd244d6f3f1ab9dfcb9d8fe1a12b6b7bcb2d2 Mon Sep 17 00:00:00 2001 From: atm-lena Date: Thu, 16 Jun 2022 14:57:32 +0200 Subject: [PATCH 8/8] FIX Page limit GET / POST --- htdocs/product/inventory/inventory.php | 17 +++++++++-------- htdocs/ticket/list.php | 1 - 2 files changed, 9 insertions(+), 9 deletions(-) diff --git a/htdocs/product/inventory/inventory.php b/htdocs/product/inventory/inventory.php index ff21b499912..5e0bf2055e5 100644 --- a/htdocs/product/inventory/inventory.php +++ b/htdocs/product/inventory/inventory.php @@ -94,6 +94,14 @@ include DOL_DOCUMENT_ROOT.'/core/actions_fetchobject.inc.php'; // Must be includ //if ($user->socid > 0) $socid = $user->socid; //$result = restrictedArea($user, 'mymodule', $id); +//Parameters Page +$param = '&id='.$object->id; +if ($limit > 0 && $limit != $conf->liste_limit) { + $param .= '&limit='.urlencode($limit); +} +$paramwithsearch = $param; + + if (empty($conf->global->MAIN_USE_ADVANCED_PERMS)) { $permissiontoadd = $user->rights->stock->creer; $permissiontodelete = $user->rights->stock->supprimer; @@ -104,12 +112,6 @@ if (empty($conf->global->MAIN_USE_ADVANCED_PERMS)) { $now = dol_now(); -//Parameters Page -$param = '&id='.$object->id; -if ($limit > 0 && $limit != $conf->liste_limit) { - $param .= '&limit='.urlencode($limit); -} -$paramwithsearch = $param; /* @@ -547,8 +549,7 @@ if ($object->id > 0) { print dol_get_fiche_end(); - - print '
'; + print ''; print ''; print ''; print ''; diff --git a/htdocs/ticket/list.php b/htdocs/ticket/list.php index a8314c4bf89..edc42dadccb 100644 --- a/htdocs/ticket/list.php +++ b/htdocs/ticket/list.php @@ -683,7 +683,6 @@ if ($search_dateclose_end) { $param .= '&search_date_endmonth='.urlencode($tmparray['mon']); $param .= '&search_date_endyear='.urlencode($tmparray['year']); } - // List of mass actions available $arrayofmassactions = array( //'presend'=>img_picto('', 'email', 'class="pictofixedwidth"').$langs->trans("SendByMail"),