From d5f0fe6c105d8ecd2a8d91c6e547bdef06c57eaa Mon Sep 17 00:00:00 2001 From: atm-lena Date: Fri, 21 Jan 2022 10:55:06 +0100 Subject: [PATCH 01/88] OF consumption batch select : wip --- htdocs/mrp/mo_production.php | 5 ++- .../product/class/html.formproduct.class.php | 38 ++++++++++++++----- 2 files changed, 31 insertions(+), 12 deletions(-) diff --git a/htdocs/mrp/mo_production.php b/htdocs/mrp/mo_production.php index bc1a0457325..efe922a304a 100644 --- a/htdocs/mrp/mo_production.php +++ b/htdocs/mrp/mo_production.php @@ -1023,8 +1023,9 @@ if ($object->id > 0 && (empty($action) || ($action != 'edit' && $action != 'crea print ''; if ($tmpproduct->status_batch) { $preselected = (GETPOSTISSET('batch-'.$line->id.'-'.$i) ? GETPOST('batch-'.$line->id.'-'.$i) : ''); - print ''; - print $formproduct->selectLotDataList('batch-'.$line->id.'-'.$i, 0, $line->fk_product, '', ''); +// print ''; + print $formproduct->selectLotDataList('batch-'.$line->id.'-'.$i, 0, $line->fk_product, 1, ''); +// print $formproduct->selectLotStock('', 'batch-'.$line->id.'-'.$i, '', 0, '', $line->fk_product); } print ''; } diff --git a/htdocs/product/class/html.formproduct.class.php b/htdocs/product/class/html.formproduct.class.php index da10faa4f34..c6365935fb8 100644 --- a/htdocs/product/class/html.formproduct.class.php +++ b/htdocs/product/class/html.formproduct.class.php @@ -626,13 +626,13 @@ class FormProduct { global $conf, $langs; - dol_syslog(get_class($this)."::selectLotDataList $htmlname, $empty, $fk_product, $fk_entrepot,$objectLines", LOG_DEBUG); + dol_syslog(get_class($this) . "::selectLotDataList $htmlname, $empty, $fk_product, $fk_entrepot,$objectLines", LOG_DEBUG); $out = ''; $productIdArray = array(); if (!is_array($objectLines) || !count($objectLines)) { if (!empty($fk_product) && $fk_product > 0) { - $productIdArray[] = (int) $fk_product; + $productIdArray[] = (int)$fk_product; } } else { foreach ($objectLines as $line) { @@ -644,26 +644,44 @@ class FormProduct $nboflot = $this->loadLotStock($productIdArray); - $out .= ''; + $out .= ''; return $out; } From 378473ca1f96429c6422b68d363cf2f96b983fa5 Mon Sep 17 00:00:00 2001 From: atm-lena Date: Fri, 21 Jan 2022 12:21:47 +0100 Subject: [PATCH 02/88] OF Consumption batch select : WIP --- htdocs/mrp/mo_production.php | 3 +- .../product/class/html.formproduct.class.php | 42 ++++++++++++------- 2 files changed, 30 insertions(+), 15 deletions(-) diff --git a/htdocs/mrp/mo_production.php b/htdocs/mrp/mo_production.php index efe922a304a..ce35b526025 100644 --- a/htdocs/mrp/mo_production.php +++ b/htdocs/mrp/mo_production.php @@ -184,6 +184,7 @@ if (empty($reshook)) { $pos = 0; // Process line to consume foreach ($object->lines as $line) { + if ($line->role == 'toconsume') { $tmpproduct = new Product($db); $tmpproduct->fetch($line->fk_product); @@ -1024,7 +1025,7 @@ if ($object->id > 0 && (empty($action) || ($action != 'edit' && $action != 'crea if ($tmpproduct->status_batch) { $preselected = (GETPOSTISSET('batch-'.$line->id.'-'.$i) ? GETPOST('batch-'.$line->id.'-'.$i) : ''); // print ''; - print $formproduct->selectLotDataList('batch-'.$line->id.'-'.$i, 0, $line->fk_product, 1, ''); + print $formproduct->selectLotDataList('batch-'.$line->id.'-'.$i, 1, $line->fk_product, ''); // print $formproduct->selectLotStock('', 'batch-'.$line->id.'-'.$i, '', 0, '', $line->fk_product); } print ''; diff --git a/htdocs/product/class/html.formproduct.class.php b/htdocs/product/class/html.formproduct.class.php index c6365935fb8..d357383df23 100644 --- a/htdocs/product/class/html.formproduct.class.php +++ b/htdocs/product/class/html.formproduct.class.php @@ -622,7 +622,7 @@ class FormProduct * @param array $objectLines Only cache lot numbers for products in lines of object. If no lines only for fk_product. If no fk_product, all. * @return string HTML datalist */ - public function selectLotDataList($htmlname = 'batch_id', $empty = 0, $fk_product = 0, $fk_entrepot = 0, $objectLines = array()) + public function selectLotDataList($htmlname = 'batch_id', $empty = 0, $fk_product = 0, $fk_entrepot = 0, $objectLines = array(), $forcecombo = 0, $events = array(), $morecss = 'minwidth200', $disabled = 0, $selected = '', $empty_label = '') { global $conf, $langs; @@ -644,7 +644,16 @@ class FormProduct $nboflot = $this->loadLotStock($productIdArray); + if ($conf->use_javascript_ajax && !$forcecombo) { + include_once DOL_DOCUMENT_ROOT.'/core/lib/ajax.lib.php'; + $comboenhancement = ajax_combobox($htmlname, $events); + $out .= $comboenhancement; + } + $out .= ''; + // Qty print ''; @@ -1022,8 +1024,9 @@ if ($object->id > 0 && (empty($action) || ($action != 'edit' && $action != 'crea element.change(function(){ + var element = $(this); - console.log($(this).val()); + var product_element_name = element.attr('name').replace('idwarehouse', 'product'); $.ajax({ type: "POST", @@ -1031,11 +1034,12 @@ if ($object->id > 0 && (empty($action) || ($action != 'edit' && $action != 'crea data: { action: "updateselectbatchbywarehouse", warehouse_id: $(this).val(), - fk_product : fk_product ?> + product_id: $("input[name='"+product_element_name+"']").val() } }).done(function( data ) { - var element2 = $("#id.'-'.$i ?>"); + var element2_name = element.attr('name').replace('idwarehouse', 'batch'); + var element2 = $("select[name*='"+element2_name+"']"); element2.empty(); @@ -1082,10 +1086,11 @@ if ($object->id > 0 && (empty($action) || ($action != 'edit' && $action != 'crea - - stock->enabled) { print ''; @@ -1081,49 +1031,6 @@ if ($object->id > 0 && (empty($action) || ($action != 'edit' && $action != 'crea // print $formproduct->selectLotStock('', 'batch-'.$line->id.'-'.$i, '', 0, '', $line->fk_product); } print ''; - - ?> - - - - id > 0 && (empty($action) || ($action != 'edit' && $action != 'crea print ''; print ''; + + ?> + + + + Date: Tue, 25 Jan 2022 12:33:28 +0100 Subject: [PATCH 06/88] WIP --- htdocs/mrp/mo_production.php | 56 ++++++++++++++++++++---------------- 1 file changed, 31 insertions(+), 25 deletions(-) diff --git a/htdocs/mrp/mo_production.php b/htdocs/mrp/mo_production.php index 5a7de44e7bd..c74f286323d 100644 --- a/htdocs/mrp/mo_production.php +++ b/htdocs/mrp/mo_production.php @@ -1332,13 +1332,14 @@ if ($object->id > 0 && (empty($action) || ($action != 'edit' && $action != 'crea //Lorsqu'un entrepôt est sélectionné, on propose seulement les numéro de séries qui sont disponibles dans celui-ci //TODO : revoir requête sql de l'interface pour les cas suivants : si entrepôt sélectionné, alors quantité des nums individuel, sinon quantité globale function updateselectbatchbywarehouse() { - var element = $("select[name*='idwarehouse']"); element.change(function () { - var element = $(this); + var element2_name = element.attr('name').replace('idwarehouse', 'batch'); + var element2 = $("select[name*='" + element2_name + "']"); + var product_element_name = element.attr('name').replace('idwarehouse', 'product'); $.ajax({ @@ -1351,9 +1352,8 @@ if ($object->id > 0 && (empty($action) || ($action != 'edit' && $action != 'crea } }).done(function (data) { - console.log(data); - var element2_name = element.attr('name').replace('idwarehouse', 'batch'); - var element2 = $("select[name*='" + element2_name + "']"); + console.log(data) + var selected = element2.val(); element2.empty(); @@ -1366,10 +1366,20 @@ if ($object->id > 0 && (empty($action) || ($action != 'edit' && $action != 'crea $.each(data, function (key, value) { - element2.append($(''; + } else { + var option =''; + } + + element2.append(option); + }); }); @@ -1386,6 +1396,15 @@ if ($object->id > 0 && (empty($action) || ($action != 'edit' && $action != 'crea var element = $(this); + var element2_name = element.attr('name').replace('batch', 'idwarehouse'); + var element2 = $("select[name*='" + element2_name + "']"); + + var selected = element2.val(); + + if(selected != -1){ + return; + } + var product_element_name = element.attr('name').replace('batch', 'product'); $.ajax({ @@ -1398,24 +1417,11 @@ if ($object->id > 0 && (empty($action) || ($action != 'edit' && $action != 'crea } }).done(function (data) { - var element2_name = element.attr('name').replace('batch', 'idwarehouse'); - var element2 = $("select[name*='" + element2_name + "']"); - - element2.empty(); - var data = JSON.parse(data); - element2.append($(''; return $out; } From f5446e0801ce5d0307acc19c35df8d7c0f3a58ee Mon Sep 17 00:00:00 2001 From: atm-lena Date: Tue, 25 Jan 2022 17:23:48 +0100 Subject: [PATCH 09/88] Clean --- htdocs/product/class/html.formproduct.class.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/product/class/html.formproduct.class.php b/htdocs/product/class/html.formproduct.class.php index ce4681db7ba..da10faa4f34 100644 --- a/htdocs/product/class/html.formproduct.class.php +++ b/htdocs/product/class/html.formproduct.class.php @@ -622,7 +622,7 @@ class FormProduct * @param array $objectLines Only cache lot numbers for products in lines of object. If no lines only for fk_product. If no fk_product, all. * @return string HTML datalist */ - public function selectLotDataList($htmlname = 'batch_id', $empty = 0, $fk_product = 0, $fk_entrepot = 0, $objectLines = array(), $forcecombo = 0, $events = array(), $morecss = 'minwidth200', $disabled = 0, $selected = '', $empty_label = '') + public function selectLotDataList($htmlname = 'batch_id', $empty = 0, $fk_product = 0, $fk_entrepot = 0, $objectLines = array()) { global $conf, $langs; From 25e8a2c75833f29a3003127aeac3a0ddb306a74b Mon Sep 17 00:00:00 2001 From: atm-lena Date: Wed, 26 Jan 2022 09:40:15 +0100 Subject: [PATCH 10/88] Ajout interface.php --- htdocs/mrp/ajax/interface.php | 86 +++++++++++++++++++ htdocs/mrp/mo_production.php | 9 +- .../product/class/html.formproduct.class.php | 2 +- 3 files changed, 88 insertions(+), 9 deletions(-) create mode 100644 htdocs/mrp/ajax/interface.php diff --git a/htdocs/mrp/ajax/interface.php b/htdocs/mrp/ajax/interface.php new file mode 100644 index 00000000000..b91cfc34c13 --- /dev/null +++ b/htdocs/mrp/ajax/interface.php @@ -0,0 +1,86 @@ + 0) $sql .= " AND fk_entrepot = '" . $warehouse_id . "'"; + $sql .= " ORDER BY e.ref, pb.batch"; + + $resql = $db->query($sql); + + if ($resql) { + while ($obj = $db->fetch_object($resql)) { + $TRes[$obj->batch] += $obj->qty; + } + } + + print json_encode($TRes); +} elseif($action == 'updateselectwarehousebybatch'){ + + $res = 0; + + $sql = "SELECT pb.batch, pb.rowid, ps.fk_entrepot, e.ref, pb.qty"; + $sql .= " FROM " . MAIN_DB_PREFIX . "product_batch as pb"; + $sql .= " JOIN " . MAIN_DB_PREFIX . "product_stock as ps on ps.rowid = pb.fk_product_stock"; + $sql .= " JOIN " . MAIN_DB_PREFIX . "entrepot as e on e.rowid = ps.fk_entrepot AND e.entity IN (" . getEntity('stock') . ")"; + $sql .= " WHERE ps.fk_product = '" . $fk_product . "'"; + if ($batch_id > 0) $sql.= " AND pb.batch = '" . $batch_id . "'"; + $sql .= " ORDER BY e.ref, pb.batch"; + + $resql = $db->query($sql); + + if($resql){ + if($db->num_rows($resql) == 1){ + $obj = $db->fetch_object($resql); + $res = $obj->fk_entrepot; + } + } + + print json_encode($res); + +} + + + diff --git a/htdocs/mrp/mo_production.php b/htdocs/mrp/mo_production.php index a9d56c1a850..cfb1616e751 100644 --- a/htdocs/mrp/mo_production.php +++ b/htdocs/mrp/mo_production.php @@ -1027,8 +1027,7 @@ if ($object->id > 0 && (empty($action) || ($action != 'edit' && $action != 'crea if ($tmpproduct->status_batch) { $preselected = (GETPOSTISSET('batch-'.$line->id.'-'.$i) ? GETPOST('batch-'.$line->id.'-'.$i) : ''); print ''; - print $formproduct->selectLotDataList('batch-'.$line->id.'-'.$i, 1, $line->fk_product, ''); -// print $formproduct->selectLotStock('', 'batch-'.$line->id.'-'.$i, '', 0, '', $line->fk_product); + print $formproduct->selectLotDataList('batch-'.$line->id.'-'.$i, 0, $line->fk_product, '', '');// print $formproduct->selectLotStock('', 'batch-'.$line->id.'-'.$i, '', 0, '', $line->fk_product); } print ''; } @@ -1357,7 +1356,6 @@ if ($object->id > 0 && (empty($action) || ($action != 'edit' && $action != 'crea }).done(function (data) { selectbatch.empty(); - $('input[name*='+selectbatch_name+']').val(''); var data = JSON.parse(data); @@ -1381,11 +1379,8 @@ if ($object->id > 0 && (empty($action) || ($action != 'edit' && $action != 'crea } selectbatch.append(option); - }); - }); - }); } @@ -1420,14 +1415,12 @@ if ($object->id > 0 && (empty($action) || ($action != 'edit' && $action != 'crea } }).done(function (data) { - console.log(data); var data = JSON.parse(data); if(data != 0){ selectwarehouse.val(data).change(); } }); - }); } diff --git a/htdocs/product/class/html.formproduct.class.php b/htdocs/product/class/html.formproduct.class.php index da10faa4f34..b9a01af1666 100644 --- a/htdocs/product/class/html.formproduct.class.php +++ b/htdocs/product/class/html.formproduct.class.php @@ -659,7 +659,7 @@ class FormProduct if (empty($fk_entrepot) || $fk_entrepot == $arraytypes['entrepot_id']) { $label = $arraytypes['entrepot_label'].' - '; $label .= $arraytypes['batch']; - $out .= ''; + $out .= ''; } } } From ccacf2e89aee64b9f16a070d7546027266cd2311 Mon Sep 17 00:00:00 2001 From: atm-lena Date: Wed, 26 Jan 2022 09:49:06 +0100 Subject: [PATCH 11/88] Clean code --- htdocs/mrp/ajax/interface.php | 6 +----- htdocs/mrp/mo_production.php | 16 ++++------------ 2 files changed, 5 insertions(+), 17 deletions(-) diff --git a/htdocs/mrp/ajax/interface.php b/htdocs/mrp/ajax/interface.php index b91cfc34c13..45709b81ac0 100644 --- a/htdocs/mrp/ajax/interface.php +++ b/htdocs/mrp/ajax/interface.php @@ -1,16 +1,12 @@ id > 0 && (empty($action) || ($action != 'edit' && $action != 'crea if ($tmpproduct->status_batch) { $preselected = (GETPOSTISSET('batch-'.$line->id.'-'.$i) ? GETPOST('batch-'.$line->id.'-'.$i) : ''); print ''; - print $formproduct->selectLotDataList('batch-'.$line->id.'-'.$i, 0, $line->fk_product, '', '');// print $formproduct->selectLotStock('', 'batch-'.$line->id.'-'.$i, '', 0, '', $line->fk_product); + print $formproduct->selectLotDataList('batch-'.$line->id.'-'.$i, 0, $line->fk_product, '', ''); } print ''; } @@ -1324,25 +1324,23 @@ if ($object->id > 0 && (empty($action) || ($action != 'edit' && $action != 'crea - Date: Tue, 4 Apr 2023 23:35:42 +0200 Subject: [PATCH 78/88] Update interface.php --- htdocs/mrp/ajax/interface.php | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-) diff --git a/htdocs/mrp/ajax/interface.php b/htdocs/mrp/ajax/interface.php index 4822294a95c..195c9a570bd 100644 --- a/htdocs/mrp/ajax/interface.php +++ b/htdocs/mrp/ajax/interface.php @@ -23,15 +23,24 @@ if (!defined('NOREQUIREAJAX')) { define('NOREQUIREAJAX', '1'); } -global $db, $langs; - require '../../main.inc.php'; // Load $user and permissions $warehouse_id = GETPOST('warehouse_id', 'int'); $batch = GETPOST('batch', 'alphanohtml'); $fk_product = GETPOST('product_id', 'int'); $action = GETPOST('action', 'alphanohtml'); -$permissiontoproduce = GETPOST('permissiontoproduce', 'int'); + +$result = restrictedArea($user, 'mrp'); + +$permissiontoproduce = $user->rights->mrp->write; + + + +/* + * View + */ + +top_httphead("application/json"); if ($action == 'updateselectbatchbywarehouse' && $permissiontoproduce) { $TRes = array(); @@ -57,7 +66,6 @@ if ($action == 'updateselectbatchbywarehouse' && $permissiontoproduce) { } echo json_encode($TRes); - exit(); } elseif ($action == 'updateselectwarehousebybatch' && $permissiontoproduce) { $res = 0; @@ -79,5 +87,4 @@ if ($action == 'updateselectbatchbywarehouse' && $permissiontoproduce) { } echo json_encode($res); - exit(); } From 6777c27c5bea501bd1ac553bca8378e8ee87b464 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Tue, 4 Apr 2023 23:36:24 +0200 Subject: [PATCH 79/88] Look and feel v17 --- htdocs/mrp/mo_production.php | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/htdocs/mrp/mo_production.php b/htdocs/mrp/mo_production.php index b0e0b84202a..c36926260e6 100644 --- a/htdocs/mrp/mo_production.php +++ b/htdocs/mrp/mo_production.php @@ -727,6 +727,7 @@ if ($object->id > 0 && (empty($action) || ($action != 'edit' && $action != 'crea print ''; print ''; + // Product print ''; // Qty print ''; @@ -745,13 +746,14 @@ if ($object->id > 0 && (empty($action) || ($action != 'edit' && $action != 'crea if (in_array($action, array('consumeorproduce', 'consumeandproduceall'))) { $listwarehouses = $tmpwarehouse->list_array(1); if (count($listwarehouses) > 1) { - print '
' . $langs->trans("ForceTo") . ' ' . $form->selectarray('fk_default_warehouse', $listwarehouses, $fk_default_warehouse, 1, 0, 0, '', 0, 0, 0, '', 'minwidth100 maxwidth300', 1); + print '
'.$form->selectarray('fk_default_warehouse', $listwarehouses, $fk_default_warehouse, $langs->trans("ForceTo"), 0, 0, '', 0, 0, 0, '', 'minwidth100 maxwidth200', 1); } elseif (count($listwarehouses) == 1) { - print '
' . $langs->trans("ForceTo") . ' ' . $form->selectarray('fk_default_warehouse', $listwarehouses, $fk_default_warehouse, 0, 0, 0, '', 0, 0, 0, '', 'minwidth100 maxwidth300', 1); + print '
'.$form->selectarray('fk_default_warehouse', $listwarehouses, $fk_default_warehouse, 0, 0, 0, '', 0, 0, 0, '', 'minwidth100 maxwidth200', 1); } } } print ''; + if (isModEnabled('stock')) { // Available print ''; // Product print ''; // Qty print ''; @@ -1458,7 +1458,7 @@ if ($object->id > 0 && (empty($action) || ($action != 'edit' && $action != 'crea print ''; // Batch number in same column than the stock movement picto @@ -1510,9 +1510,8 @@ if ($object->id > 0 && (empty($action) || ($action != 'edit' && $action != 'crea }); function updateselectbatchbywarehouse() { - var element = $("select[name*='idwarehouse']"); - - element.change(function () { + $(document).on('change', "select[name*='idwarehouse']", function () { + console.log("We change warehouse so we update the list of possible batch number"); var selectwarehouse = $(this); @@ -1529,13 +1528,19 @@ if ($object->id > 0 && (empty($action) || ($action != 'edit' && $action != 'crea action: "updateselectbatchbywarehouse", permissiontoproduce: , warehouse_id: $(this).val(), + token: '', product_id: $("input[name='" + product_element_name + "']").val() } }).done(function (data) { selectbatch.empty(); - var data = JSON.parse(data); + if (typeof data == "object") { + console.log("data is already type object, no need to parse it"); + } else { + console.log("data is type "+(typeof data)); + data = JSON.parse(data); + } selectbatch.append($('
'.$langs->trans("Product").''.$langs->trans("Qty").''; @@ -870,7 +872,7 @@ if ($object->id > 0 && (empty($action) || ($action != 'edit' && $action != 'crea print '
'.$tmpproduct->getNomUrl(1); - print '
'.$tmpproduct->label.''; + print '
'.$tmpproduct->label.'
'; print '
'; From 86445cdd83deca5ca37feed3bf316273f0b873e3 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Wed, 5 Apr 2023 01:08:23 +0200 Subject: [PATCH 80/88] NEW Dynamic choice of warehouse and batch in MO production. --- htdocs/mrp/mo_production.php | 29 +++++++++++++------ .../product/class/html.formproduct.class.php | 2 ++ 2 files changed, 22 insertions(+), 9 deletions(-) diff --git a/htdocs/mrp/mo_production.php b/htdocs/mrp/mo_production.php index 3b538a06902..8d3d11d167d 100644 --- a/htdocs/mrp/mo_production.php +++ b/htdocs/mrp/mo_production.php @@ -672,7 +672,7 @@ if ($object->id > 0 && (empty($action) || ($action != 'edit' && $action != 'crea print '
'; print '
'.$langs->trans("ConfirmProductionDesc", $langs->transnoentitiesnoconv("Confirm")).'
'; - print ''.$langs->trans("InventoryCode").':   '; + print ''.$langs->trans("InventoryCode").':   '; print ''; print $langs->trans("MovementLabel").':

'; print '
'; @@ -1080,7 +1080,7 @@ if ($object->id > 0 && (empty($action) || ($action != 'edit' && $action != 'crea print '
'; if ($tmpproduct->status_batch) { $preselected = (GETPOSTISSET('batch-'.$line->id.'-'.$i) ? GETPOST('batch-'.$line->id.'-'.$i) : ''); - print ''; + print ''; print $formproduct->selectLotDataList('batch-'.$line->id.'-'.$i, 0, $line->fk_product, '', ''); } print ''; if ($tmpproduct->status_batch) { $preselected = (GETPOSTISSET('batchtoproduce-'.$line->id.'-'.$i) ? GETPOST('batchtoproduce-'.$line->id.'-'.$i) : ''); - print ''; + print ''; } print '
'."\n"; - -// Line for filters fields +// Fields title search +// -------------------------------------------------------------------- print ''; // Action column if (getDolGlobalString('MAIN_CHECKBOX_LEFT_COLUMN')) { - print ''; @@ -423,7 +493,7 @@ include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_input.tpl.php'; // Fields from hook $parameters = array('arrayfields'=>$arrayfields); -$reshook = $hookmanager->executeHooks('printFieldListOption', $parameters); // Note that $action and $object may have been modified by hook +$reshook = $hookmanager->executeHooks('printFieldListOption', $parameters, $object, $action); // Note that $action and $object may have been modified by hook print $hookmanager->resPrint; // Date creation if (!empty($arrayfields['c.datec']['checked'])) { @@ -438,55 +508,71 @@ if (!empty($arrayfields['c.tms']['checked'])) { // Action column if (!getDolGlobalString('MAIN_CHECKBOX_LEFT_COLUMN')) { - print ''; } -print "\n"; +print ''."\n"; +$totalarray = array(); +$totalarray['nbfield'] = 0; +// Fields title label +// -------------------------------------------------------------------- print ''; +// Action column if (getDolGlobalString('MAIN_CHECKBOX_LEFT_COLUMN')) { print_liste_field_titre($selectedfields, $_SERVER["PHP_SELF"], '', '', '', 'align="center"', $sortfield, $sortorder, 'maxwidthsearch '); + $totalarray['nbfield']++; } if (!empty($arrayfields['d.ref']['checked'])) { print_liste_field_titre($arrayfields['d.ref']['label'], $_SERVER["PHP_SELF"], "c.rowid", $param, "", "", $sortfield, $sortorder); + $totalarray['nbfield']++; } if (!empty($arrayfields['d.fk_type']['checked'])) { print_liste_field_titre($arrayfields['d.fk_type']['label'], $_SERVER["PHP_SELF"], "c.fk_type", $param, "", "", $sortfield, $sortorder); + $totalarray['nbfield']++; } if (!empty($arrayfields['d.lastname']['checked'])) { print_liste_field_titre($arrayfields['d.lastname']['label'], $_SERVER["PHP_SELF"], "d.lastname", $param, "", "", $sortfield, $sortorder); + $totalarray['nbfield']++; } if (!empty($arrayfields['d.firstname']['checked'])) { print_liste_field_titre($arrayfields['d.firstname']['label'], $_SERVER["PHP_SELF"], "d.firstname", $param, "", "", $sortfield, $sortorder); + $totalarray['nbfield']++; } if (!empty($arrayfields['d.login']['checked'])) { print_liste_field_titre($arrayfields['d.login']['label'], $_SERVER["PHP_SELF"], "d.login", $param, "", "", $sortfield, $sortorder); + $totalarray['nbfield']++; } if (!empty($arrayfields['t.libelle']['checked'])) { print_liste_field_titre($arrayfields['t.libelle']['label'], $_SERVER["PHP_SELF"], "c.note", $param, "", '', $sortfield, $sortorder); + $totalarray['nbfield']++; } if (!empty($arrayfields['d.bank']['checked'])) { print_liste_field_titre($arrayfields['d.bank']['label'], $_SERVER["PHP_SELF"], "b.fk_account", $param, "", "", $sortfield, $sortorder); + $totalarray['nbfield']++; } if (!empty($arrayfields['c.dateadh']['checked'])) { print_liste_field_titre($arrayfields['c.dateadh']['label'], $_SERVER["PHP_SELF"], "c.dateadh", $param, "", '', $sortfield, $sortorder, 'center nowraponall '); + $totalarray['nbfield']++; } if (!empty($arrayfields['c.datef']['checked'])) { print_liste_field_titre($arrayfields['c.datef']['label'], $_SERVER["PHP_SELF"], "c.datef", $param, "", '', $sortfield, $sortorder, 'center nowraponall '); + $totalarray['nbfield']++; } if (!empty($arrayfields['d.amount']['checked'])) { print_liste_field_titre($arrayfields['d.amount']['label'], $_SERVER["PHP_SELF"], "c.subscription", $param, "", '', $sortfield, $sortorder, 'right '); + $totalarray['nbfield']++; } // Extra fields include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_title.tpl.php'; // Hook fields -$parameters = array('arrayfields'=>$arrayfields, 'param'=>$param, 'sortfield'=>$sortfield, 'sortorder'=>$sortorder); -$reshook = $hookmanager->executeHooks('printFieldListTitle', $parameters); // Note that $action and $object may have been modified by hook +$parameters = array('arrayfields'=>$arrayfields, 'param'=>$param, 'sortfield'=>$sortfield, 'sortorder'=>$sortorder, 'totalarray'=>&$totalarray); +$reshook = $hookmanager->executeHooks('printFieldListTitle', $parameters, $object, $action); // Note that $action and $object may have been modified by hook print $hookmanager->resPrint; if (!empty($arrayfields['c.datec']['checked'])) { print_liste_field_titre($arrayfields['c.datec']['label'], $_SERVER["PHP_SELF"], "c.datec", "", $param, 'align="center" class="nowrap"', $sortfield, $sortorder); @@ -494,17 +580,25 @@ if (!empty($arrayfields['c.datec']['checked'])) { if (!empty($arrayfields['c.tms']['checked'])) { print_liste_field_titre($arrayfields['c.tms']['label'], $_SERVER["PHP_SELF"], "c.tms", "", $param, 'align="center" class="nowrap"', $sortfield, $sortorder); } +// Action column if (!getDolGlobalString('MAIN_CHECKBOX_LEFT_COLUMN')) { - print_liste_field_titre($selectedfields, $_SERVER["PHP_SELF"], '', '', '', 'align="center"', $sortfield, $sortorder, 'maxwidthsearch '); + print getTitleFieldOfList($selectedfields, 0, $_SERVER["PHP_SELF"], '', '', '', '', $sortfield, $sortorder, 'center maxwidthsearch ')."\n"; + $totalarray['nbfield']++; } -print "\n"; - +print ''."\n"; +// Loop on record +// -------------------------------------------------------------------- +$i = 0; +$savnbfield = $totalarray['nbfield']; $totalarray = array(); $totalarray['nbfield'] = 0; $imaxinloop = ($limit ? min($num, $limit) : $num); while ($i < $imaxinloop) { - $obj = $db->fetch_object($result); + $obj = $db->fetch_object($resql); + if (empty($obj)) { + break; // Should not happen + } $subscription->ref = $obj->crowid; $subscription->id = $obj->crowid; @@ -532,9 +626,16 @@ while ($i < $imaxinloop) { if ($mode == 'kanban') { if ($i == 0) { - print ''; } } else { - print ''; + // Show here line of result + $j = 0; + print ''; // Action column if (getDolGlobalString('MAIN_CHECKBOX_LEFT_COLUMN')) { - print '\n"; + + print ''."\n"; } $i++; } @@ -720,19 +824,19 @@ if ($num == 0) { $colspan++; } } - print ''; + print ''; } $db->free($resql); -$parameters = array('sql' => $sql); -$reshook = $hookmanager->executeHooks('printFieldListFooter', $parameters); // Note that $action and $object may have been modified by hook +$parameters = array('arrayfields'=>$arrayfields, 'sql' => $sql); +$reshook = $hookmanager->executeHooks('printFieldListFooter', $parameters, $object, $action); // Note that $action and $object may have been modified by hook print $hookmanager->resPrint; -print "
'; + print ''; $searchpicto = $form->showFilterButtons('left'); print $searchpicto; print ''; + print ''; $searchpicto = $form->showFilterButtons(); print $searchpicto; print '
'; + print '
'; print '
'; } + // Output Kanban + if ($massactionbutton || $massaction) { // If we are in select mode (massactionbutton defined) or if we have already selected and sent an action ($massaction) defined + $selected = 0; + if (in_array($object->id, $arrayofselected)) { + $selected = 1; + } + } //fetch informations needs on this mode $subscription->fk_adherent = $adherent->getNomUrl(1); @@ -552,10 +653,12 @@ while ($i < $imaxinloop) { print '
'; + print ''; if ($massactionbutton || $massaction) { // If we are in select mode (massactionbutton defined) or if we have already selected and sent an action ($massaction) defined $selected = 0; if (in_array($obj->crowid, $arrayofselected)) { @@ -690,7 +793,7 @@ while ($i < $imaxinloop) { } // Action column if (!getDolGlobalString('MAIN_CHECKBOX_LEFT_COLUMN')) { - print ''; + print ''; if ($massactionbutton || $massaction) { // If we are in select mode (massactionbutton defined) or if we have already selected and sent an action ($massaction) defined $selected = 0; if (in_array($obj->crowid, $arrayofselected)) { @@ -703,7 +806,8 @@ while ($i < $imaxinloop) { $totalarray['nbfield']++; } } - print "
'.$langs->trans("NoRecordFound").'
'.$langs->trans("NoRecordFound").'
"; -print ''; -print ''; +print ''."\n"; +print ''."\n"; +print ''."\n"; // End of page llxFooter(); diff --git a/htdocs/compta/bank/class/account.class.php b/htdocs/compta/bank/class/account.class.php index 4b17f3baab0..f9a665640cd 100644 --- a/htdocs/compta/bank/class/account.class.php +++ b/htdocs/compta/bank/class/account.class.php @@ -1463,6 +1463,7 @@ class Account extends CommonObject public function getNomUrl($withpicto = 0, $mode = '', $option = '', $save_lastsearch_value = -1, $notooltip = 0) { global $conf, $langs, $user; + include_once DOL_DOCUMENT_ROOT.'/core/lib/bank.lib.php'; $result = ''; @@ -1504,7 +1505,7 @@ class Account extends CommonObject } } - $linkstart = ' Date: Wed, 5 Apr 2023 03:15:42 +0200 Subject: [PATCH 86/88] FIX Filter on member status --- htdocs/adherents/list.php | 5 +++-- htdocs/adherents/type.php | 4 ++-- htdocs/core/lib/functions.lib.php | 7 ++++++- htdocs/langs/en_US/members.lang | 1 + 4 files changed, 12 insertions(+), 5 deletions(-) diff --git a/htdocs/adherents/list.php b/htdocs/adherents/list.php index f4208f590fd..35d4015e270 100644 --- a/htdocs/adherents/list.php +++ b/htdocs/adherents/list.php @@ -424,10 +424,10 @@ if ($search_filter == 'waitingsubscription') { $sql .= " AND (datefin IS NULL AND t.subscription = '1')"; } if ($search_filter == 'uptodate') { - $sql .= " AND (datefin >= '".$db->idate($now)."' OR t.subscription = '0')"; + $sql .= " AND (datefin >= '".$db->idate($now)."' OR (datefin IS NULL AND t.subscription = '0'))"; } if ($search_filter == 'outofdate') { - $sql .= " AND (datefin < '".$db->idate($now)."' AND t.subscription = '1')"; + $sql .= " AND (datefin < '".$db->idate($now)."')"; } if ($search_status != '') { // Peut valoir un nombre ou liste de nombre separes par virgules @@ -516,6 +516,7 @@ if (empty($conf->global->MAIN_DISABLE_FULL_SCANLIST)) { } $db->free($resql); } +//print $sql; // Complete request and execute it with limit $sql .= $db->order($sortfield, $sortorder); diff --git a/htdocs/adherents/type.php b/htdocs/adherents/type.php index 8a4c189766f..394a17433f4 100644 --- a/htdocs/adherents/type.php +++ b/htdocs/adherents/type.php @@ -433,7 +433,7 @@ if ($action == 'create') { print $form->selectarray("morphy", $morphys, GETPOSTISSET("morphy") ? GETPOST("morphy", 'aZ09') : 'morphy'); print ""; - print ''.$langs->trans("SubscriptionRequired").''; + print ''.$form->textwithpicto($langs->trans("SubscriptionRequired"), $langs->trans("SubscriptionRequiredDesc")).''; print $form->selectyesno("subscription", 1, 1); print ''; @@ -509,7 +509,7 @@ if ($rowid > 0) { print ''.$langs->trans("MembersNature").''.$object->getmorphylib($object->morphy).''; print ''; - print ''.$langs->trans("SubscriptionRequired").''; + print ''.$form->textwithpicto($langs->trans("SubscriptionRequired"), $langs->trans("SubscriptionRequiredDesc")).''; print yn($object->subscription); print ''; diff --git a/htdocs/core/lib/functions.lib.php b/htdocs/core/lib/functions.lib.php index bdeb1994ba3..2da236006c0 100644 --- a/htdocs/core/lib/functions.lib.php +++ b/htdocs/core/lib/functions.lib.php @@ -8049,6 +8049,10 @@ function getCommonSubstitutionArray($outputlangs, $onlykey = 0, $exclude = null, } if (is_object($object) && $object->element == 'member') { $typeforonlinepayment = 'member'; + $amounttouse = 0; + if (!empty($object->last_subscription_amount)) { + $amounttouse = $object->last_subscription_amount; + } } if (is_object($object) && $object->element == 'contrat') { $typeforonlinepayment = 'contract'; @@ -8056,7 +8060,8 @@ function getCommonSubstitutionArray($outputlangs, $onlykey = 0, $exclude = null, if (is_object($object) && $object->element == 'fichinter') { $typeforonlinepayment = 'ficheinter'; } - $url = getOnlinePaymentUrl(0, $typeforonlinepayment, $substitutionarray['__REF__']); + + $url = getOnlinePaymentUrl(0, $typeforonlinepayment, $substitutionarray['__REF__'], $amounttouse); $paymenturl = $url; } diff --git a/htdocs/langs/en_US/members.lang b/htdocs/langs/en_US/members.lang index 3251618032f..032d4008f00 100644 --- a/htdocs/langs/en_US/members.lang +++ b/htdocs/langs/en_US/members.lang @@ -94,6 +94,7 @@ NoTypeDefinedGoToSetup=No member types defined. Go to menu "Members types" NewMemberType=New member type WelcomeEMail=Welcome email SubscriptionRequired=Contribution required +SubscriptionRequiredDesc=If subscription is required, a subscription with a start or end date must be recorded to have the member up to date (whatever is subscription amount, even if subscription is free). DeleteType=Delete VoteAllowed=Vote allowed Physical=Individual From 124961308d46ddbd690825efb807e2c7bf0c5362 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Wed, 5 Apr 2023 03:25:35 +0200 Subject: [PATCH 87/88] Debug v18 --- htdocs/adherents/class/adherent_type.class.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/htdocs/adherents/class/adherent_type.class.php b/htdocs/adherents/class/adherent_type.class.php index cfcdf81a9b9..b17453bc646 100644 --- a/htdocs/adherents/class/adherent_type.class.php +++ b/htdocs/adherents/class/adherent_type.class.php @@ -1005,9 +1005,9 @@ class AdherentType extends CommonObject $return .= ''; $return .= '
'; $return .= ''.(method_exists($this, 'getNomUrl') ? $this->getNomUrl() : $this->ref).''; - $return .= ''; + //$return .= ''; if ($user->rights->adherent->configurer) { - $return .= 'ref.'">'.img_edit().''; + $return .= 'ref).'">'.img_edit().''; } else { $return .= ' '; } From 9b141e9d1d2b43b4b9af8216be0d5a6e90871753 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Wed, 5 Apr 2023 03:26:27 +0200 Subject: [PATCH 88/88] var not used --- htdocs/adherents/class/adherent_type.class.php | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/htdocs/adherents/class/adherent_type.class.php b/htdocs/adherents/class/adherent_type.class.php index b17453bc646..9ee0de6c055 100644 --- a/htdocs/adherents/class/adherent_type.class.php +++ b/htdocs/adherents/class/adherent_type.class.php @@ -996,8 +996,6 @@ class AdherentType extends CommonObject { global $langs, $user; - $selected = (empty($arraydata['selected']) ? 0 : $arraydata['selected']); - $return = '
'; $return .= '
'; $return .= ''; @@ -1005,7 +1003,10 @@ class AdherentType extends CommonObject $return .= ''; $return .= '
'; $return .= ''.(method_exists($this, 'getNomUrl') ? $this->getNomUrl() : $this->ref).''; + + //$selected = (empty($arraydata['selected']) ? 0 : $arraydata['selected']); //$return .= ''; + if ($user->rights->adherent->configurer) { $return .= 'ref).'">'.img_edit().''; } else {