Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

NEW shipment kits with dispatcher v2 #27570

Open
wants to merge 40 commits into
base: develop
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
40 commits
Select commit Hold shift + click to select a range
5e5b11d
NEW shipment kits with dispatcher v2
lvessiller-opendsi Jan 16, 2024
b97dbc5
Update from develop
lvessiller-opendsi Jan 16, 2024
54454f3
Fix PHPCS
lvessiller-opendsi Jan 16, 2024
abc81a1
Fix pre-commit
lvessiller-opendsi Jan 16, 2024
5bacbfa
Fix PHPStan
lvessiller-opendsi Jan 16, 2024
cdbee1e
Fix PHPStan
lvessiller-opendsi Jan 16, 2024
8fa6c76
Fix travis CI
lvessiller-opendsi Jan 16, 2024
3409ca8
Fix travis CI
lvessiller-opendsi Jan 16, 2024
f50cf21
Fix travis CI
lvessiller-opendsi Jan 22, 2024
3f72007
Fix travis CI
lvessiller-opendsi Jan 22, 2024
f2c0f9d
Fix travis CI
lvessiller-opendsi Jan 22, 2024
aa22d07
Resolve conflicts
lvessiller-opendsi Mar 4, 2024
e16daf4
Merge develop
lvessiller-opendsi Mar 14, 2024
4a67790
NEW dispatch kit with batches as sub-component
lvessiller-opendsi Oct 16, 2024
a6c53d7
Resolve conflicts
lvessiller-opendsi Oct 16, 2024
d08044f
Resolve conflicts v2
lvessiller-opendsi Oct 16, 2024
489493f
Resolve conflicts v3
lvessiller-opendsi Oct 16, 2024
56c29c5
Fix phan errors
lvessiller-opendsi Oct 17, 2024
35a1668
Fix variable not declared
lvessiller-opendsi Oct 17, 2024
34494f4
Update from develop
lvessiller-opendsi Oct 28, 2024
f70cece
Fix precommit
lvessiller-opendsi Oct 28, 2024
3074d79
Merge branch 'develop' of github.com:Dolibarr/dolibarr into new-exped…
lvessiller-opendsi Oct 29, 2024
e5568dd
Merge from develop
lvessiller-opendsi Nov 8, 2024
854430e
Fix out js line not empty always true
lvessiller-opendsi Nov 8, 2024
3108fdc
Fix CI errors
lvessiller-opendsi Nov 8, 2024
6bf2160
Fix CI errors
lvessiller-opendsi Nov 8, 2024
ec3b7de
Merge branch 'develop' of github.com:Dolibarr/dolibarr into new-exped…
lvessiller-opendsi Nov 8, 2024
ef93cc9
Merge branch 'develop' of github.com:Dolibarr/dolibarr into new-exped…
lvessiller-opendsi Nov 8, 2024
49ae215
FIX batch number in expedition create line
lvessiller-opendsi Nov 8, 2024
c3c2b3b
Merge branch 'develop' of github.com:Dolibarr/dolibarr into new-exped…
lvessiller-opendsi Nov 8, 2024
cdf9fc3
Merge from develop
lvessiller-opendsi Nov 13, 2024
fa5ddc7
Fix initilize kit and incdec for find all children
lvessiller-opendsi Nov 16, 2024
aaa7332
NEW update batch from warehouse and warehouse from batch (ajax)
lvessiller-opendsi Nov 20, 2024
3051553
Add key StockTotal in en langs file
lvessiller-opendsi Nov 20, 2024
7e67257
Merge branch 'develop' of github.com:Dolibarr/dolibarr into new-exped…
lvessiller-opendsi Nov 20, 2024
d63f54e
Fix CI errors on lot_cache definition
lvessiller-opendsi Nov 20, 2024
fe1ca54
Remove one check parameters in comment
lvessiller-opendsi Nov 20, 2024
6b353a5
Show eat by and sell by date on update select batch by warehouse
lvessiller-opendsi Nov 22, 2024
f763894
Merge from develop
lvessiller-opendsi Nov 22, 2024
211db12
Add option to pre-select the batch with the earliest sell-by/eat-by d…
lvessiller-opendsi Nov 22, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions htdocs/admin/expedition.php
Original file line number Diff line number Diff line change
Expand Up @@ -456,6 +456,13 @@
print ajax_constantonoff('SHIPPING_DISPLAY_STOCK_ENTRY_DATE');
print '</td></tr>';

print '<tr class="oddeven">';
print '<td>'.$langs->trans('SHIPPING_SELL_EAT_BY_DATE_PRE_SELECT_EARLIEST');
print '</td>';
print '<td>';
print ajax_constantonoff('SHIPPING_SELL_EAT_BY_DATE_PRE_SELECT_EARLIEST');
print '</td></tr>';

$substitutionarray = pdf_getSubstitutionArray($langs, null, null, 2);
$substitutionarray['__(AnyTranslationKey)__'] = $langs->trans("Translation");
$htmltext = '<i>'.$langs->trans("AvailableVariables").':<br>';
Expand Down
51 changes: 39 additions & 12 deletions htdocs/admin/stock.php
Original file line number Diff line number Diff line change
Expand Up @@ -193,12 +193,19 @@
$formproduct = new FormProduct($db);



$disabled = '';
$disableStockCalculateOn = array();
if (getDolGlobalInt('PRODUIT_SOUSPRODUITS')) {
$langs->load('products');
print info_admin($langs->trans('WhenProductVirtualOnOptionAreForced'));
$disableStockCalculateOn[] = 'BILL';
$disableStockCalculateOn[] = 'VALIDATE_ORDER';
$disableStockCalculateOn[] = 'SHIPMENT_CLOSE';
}
if (isModEnabled('productbatch')) {
// If module lot/serial enabled, we force the inc/dec mode to STOCK_CALCULATE_ON_SHIPMENT_CLOSE and STOCK_CALCULATE_ON_RECEPTION_CLOSE
$langs->load("productbatch");
$disabled = ' disabled';
$disableStockCalculateOn[] = 'BILL';
$disableStockCalculateOn[] = 'VALIDATE_ORDER';

// STOCK_CALCULATE_ON_SHIPMENT_CLOSE
$descmode = $langs->trans('DeStockOnShipmentOnClosing');
Expand Down Expand Up @@ -237,7 +244,7 @@
print '<td class="right">';
if (isModEnabled('invoice')) {
if ($conf->use_javascript_ajax) {
if ($disabled) {
if (in_array('BILL', $disableStockCalculateOn)) {
print img_picto($langs->trans("Disabled"), 'off', 'class="opacitymedium"');
} else {
print ajax_constantonoff('STOCK_CALCULATE_ON_BILL', array(), null, 0, 0, 0, 2, 1, 0, '', '', 'reposition');
Expand All @@ -259,7 +266,7 @@
print '<td class="right">';
if (isModEnabled('order')) {
if ($conf->use_javascript_ajax) {
if ($disabled) {
if (in_array('VALIDATE_ORDER', $disableStockCalculateOn)) {
print img_picto($langs->trans("Disabled"), 'off', 'class="opacitymedium"');
} else {
print ajax_constantonoff('STOCK_CALCULATE_ON_VALIDATE_ORDER', array(), null, 0, 0, 0, 2, 1, 0, '', 'reposition');
Expand All @@ -283,7 +290,11 @@
print '<td class="right">';
if (isModEnabled("shipping")) {
if ($conf->use_javascript_ajax) {
print ajax_constantonoff('STOCK_CALCULATE_ON_SHIPMENT', array(), null, 0, 0, 0, 2, 1, 0, '', 'reposition');
if (in_array('SHIPMENT', $disableStockCalculateOn)) {
print img_picto($langs->trans("Disabled"), 'off', 'class="opacitymedium"');
} else {
print ajax_constantonoff('STOCK_CALCULATE_ON_SHIPMENT', array(), null, 0, 0, 0, 2, 1, 0, '', 'reposition');
}
} else {
$arrval = array('0' => $langs->trans("No"), '1' => $langs->trans("Yes"));
print $form->selectarray("STOCK_CALCULATE_ON_SHIPMENT", $arrval, $conf->global->STOCK_CALCULATE_ON_SHIPMENT);
Expand All @@ -300,7 +311,11 @@
print '<td class="right">';
if (isModEnabled("shipping")) {
if ($conf->use_javascript_ajax) {
print ajax_constantonoff('STOCK_CALCULATE_ON_SHIPMENT_CLOSE', array(), null, 0, 0, 0, 2, 1, 0, '', 'reposition');
if (in_array('SHIPMENT_CLOSE', $disableStockCalculateOn)) {
print img_picto($langs->trans("Disabled"), 'off', 'class="opacitymedium"');
} else {
print ajax_constantonoff('STOCK_CALCULATE_ON_SHIPMENT_CLOSE', array(), null, 0, 0, 0, 2, 1, 0, '', 'reposition');
}
} else {
$arrval = array('0' => $langs->trans("No"), '1' => $langs->trans("Yes"));
print $form->selectarray("STOCK_CALCULATE_ON_SHIPMENT_CLOSE", $arrval, getDolGlobalString('STOCK_CALCULATE_ON_SHIPMENT_CLOSE'));
Expand Down Expand Up @@ -333,7 +348,7 @@
print '<td class="right">';
if (isModEnabled("supplier_order") || isModEnabled("supplier_invoice")) {
if ($conf->use_javascript_ajax) {
if ($disabled) {
if (in_array('BILL', $disableStockCalculateOn)) {
print img_picto($langs->trans("Disabled"), 'off', 'class="opacitymedium"');
} else {
print ajax_constantonoff('STOCK_CALCULATE_ON_SUPPLIER_BILL', array(), null, 0, 0, 0, 2, 1, 0, '', 'reposition');
Expand All @@ -355,7 +370,7 @@
print '<td class="right">';
if (isModEnabled("supplier_order") || isModEnabled("supplier_invoice")) {
if ($conf->use_javascript_ajax) {
if ($disabled) {
if (in_array('VALIDATE_ORDER', $disableStockCalculateOn)) {
print img_picto($langs->trans("Disabled"), 'off', 'class="opacitymedium"');
} else {
print ajax_constantonoff('STOCK_CALCULATE_ON_SUPPLIER_VALIDATE_ORDER', array(), null, 0, 0, 0, 2, 1, 0, '', 'reposition');
Expand All @@ -377,7 +392,11 @@
print '<td class="right">';

if ($conf->use_javascript_ajax) {
print ajax_constantonoff('STOCK_CALCULATE_ON_RECEPTION', array(), null, 0, 0, 0, 2, 1, 0, '', 'reposition');
if (in_array('RECEPTION', $disableStockCalculateOn)) {
print img_picto($langs->trans("Disabled"), 'off', 'class="opacitymedium"');
} else {
print ajax_constantonoff('STOCK_CALCULATE_ON_RECEPTION', array(), null, 0, 0, 0, 2, 1, 0, '', 'reposition');
}
} else {
$arrval = array('0' => $langs->trans("No"), '1' => $langs->trans("Yes"));
print $form->selectarray("STOCK_CALCULATE_ON_RECEPTION", $arrval, $conf->global->STOCK_CALCULATE_ON_RECEPTION);
Expand All @@ -392,7 +411,11 @@
print '<td class="right">';

if ($conf->use_javascript_ajax) {
print ajax_constantonoff('STOCK_CALCULATE_ON_RECEPTION_CLOSE', array(), null, 0, 0, 0, 2, 1, 0, '', 'reposition');
if (in_array('RECEPTION_CLOSE', $disableStockCalculateOn)) {
print img_picto($langs->trans("Disabled"), 'off', 'class="opacitymedium"');
} else {
print ajax_constantonoff('STOCK_CALCULATE_ON_RECEPTION_CLOSE', array(), null, 0, 0, 0, 2, 1, 0, '', 'reposition');
}
} else {
$arrval = array('0' => $langs->trans("No"), '1' => $langs->trans("Yes"));
print $form->selectarray("STOCK_CALCULATE_ON_RECEPTION_CLOSE", $arrval, $conf->global->STOCK_CALCULATE_ON_RECEPTION_CLOSE);
Expand All @@ -406,7 +429,11 @@
print '<td class="right">';
if (isModEnabled("supplier_order")) {
if ($conf->use_javascript_ajax) {
print ajax_constantonoff('STOCK_CALCULATE_ON_SUPPLIER_DISPATCH_ORDER', array(), null, 0, 0, 0, 2, 1, 0, '', 'reposition');
if (in_array('SUPPLIER_DISPATCH_ORDER', $disableStockCalculateOn)) {
print img_picto($langs->trans("Disabled"), 'off', 'class="opacitymedium"');
} else {
print ajax_constantonoff('STOCK_CALCULATE_ON_SUPPLIER_DISPATCH_ORDER', array(), null, 0, 0, 0, 2, 1, 0, '', 'reposition');
}
} else {
$arrval = array('0' => $langs->trans("No"), '1' => $langs->trans("Yes"));
print $form->selectarray("STOCK_CALCULATE_ON_SUPPLIER_DISPATCH_ORDER", $arrval, $conf->global->STOCK_CALCULATE_ON_SUPPLIER_DISPATCH_ORDER);
Expand Down
149 changes: 149 additions & 0 deletions htdocs/expedition/ajax/interface.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,149 @@
<?php
/* Copyright (C) 2024 Laurent Destailleur (eldy) <[email protected]>
* Copyright (C) 2024 Lionel Vessiller <[email protected]>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/

/**
* \file htdocs/expedition/ajax/interface.php
* \brief Ajax search component for Shipment.
*/

if (!defined('NOREQUIRESOC')) {
define('NOREQUIRESOC', '1');
}
if (!defined('NOCSRFCHECK')) {
define('NOCSRFCHECK', '1');
}
if (!defined('NOTOKENRENEWAL')) {
define('NOTOKENRENEWAL', '1');
}
if (!defined('NOREQUIREMENU')) {
define('NOREQUIREMENU', '1');
}
if (!defined('NOREQUIREHTML')) {
define('NOREQUIREHTML', '1');
}
if (!defined('NOREQUIREAJAX')) {
define('NOREQUIREAJAX', '1');
}

require '../../main.inc.php'; // Load $user and permissions
/**
* @var DoliDB $db
* @var Translate $langs
* @var User $user
*/

$warehouse_id = GETPOSTINT('warehouse_id');
$batch = GETPOST('batch', 'alphanohtml');
$product_id = GETPOSTINT('product_id');
$action = GETPOST('action', 'alphanohtml');

$result = restrictedArea($user, 'expedition');

$permissiontowrite = $user->hasRight('expedition', 'write');

$is_eat_by_enabled = !getDolGlobalInt('PRODUCT_DISABLE_EATBY');
$is_sell_by_enabled = !getDolGlobalInt('PRODUCT_DISABLE_SELLBY');


/*
* View
*/

top_httphead("application/json");

if ($action == 'updateselectbatchbywarehouse' && $permissiontowrite) {
$resArr = array();

$sql = "SELECT pb.batch, pb.rowid, ps.fk_entrepot, pb.qty, e.ref as label, ps.fk_product";
if ($is_eat_by_enabled) {
$sql .= ", pl.eatby";
}
if ($is_sell_by_enabled) {
$sql .= ", pl.sellby";
}
$sql .= " FROM ".$db->prefix()."product_batch as pb";
$sql .= " LEFT JOIN ".$db->prefix()."product_stock as ps on ps.rowid = pb.fk_product_stock";
$sql .= " LEFT JOIN ".$db->prefix()."entrepot as e on e.rowid = ps.fk_entrepot AND e.entity IN (".getEntity('stock').")";
if ($is_eat_by_enabled || $is_sell_by_enabled) {
$sql .= " LEFT JOIN ".$db->prefix()."product_lot as pl on ps.fk_product = pl.fk_product AND pb.batch = pl.batch";
}
$sql .= " WHERE ps.fk_product = ".((int) $product_id);
if ($warehouse_id > 0) {
$sql .= " AND fk_entrepot = '".((int) $warehouse_id)."'";
}
$sql .= " ORDER BY e.ref, pb.batch";

$resql = $db->query($sql);

if ($resql) {
while ($obj = $db->fetch_object($resql)) {
$eat_by_date_formatted = '';
if ($is_eat_by_enabled && !empty($obj->eatby)) {
$eat_by_date_formatted = dol_print_date($db->jdate($obj->eatby), 'day');
}
$sell_by_date_formatted = '';
if ($is_sell_by_enabled && !empty($obj->sellby)) {
$sell_by_date_formatted = dol_print_date($db->jdate($obj->sellby), 'day');
}

// set qty
if (!isset($resArr[$obj->batch])) {
$resArr[$obj->batch] = array(
'qty' => (float) $obj->qty,
);
} else {
$resArr[$obj->batch]['qty'] += $obj->qty;
}

// set eat-by date
if (!isset($resArr[$obj->batch]['eatbydate'])) {
$resArr[$obj->batch]['eatbydate'] = $eat_by_date_formatted;
}

// set sell-by date
if (!isset($resArr[$obj->batch]['sellbydate'])) {
$resArr[$obj->batch]['sellbydate'] = $sell_by_date_formatted;
}
}
}

echo json_encode($resArr);
} elseif ($action == 'updateselectwarehousebybatch' && $permissiontowrite) {
$res = 0;

$sql = "SELECT pb.batch, pb.rowid, ps.fk_entrepot, e.ref, pb.qty";
$sql .= " FROM ".$db->prefix()."product_batch as pb";
$sql .= " JOIN ".$db->prefix()."product_stock as ps on ps.rowid = pb.fk_product_stock";
$sql .= " JOIN ".$db->prefix()."entrepot as e on e.rowid = ps.fk_entrepot AND e.entity IN (".getEntity('stock').")";
$sql .= " WHERE ps.fk_product = ".((int) $product_id);
if ($batch) {
$sql .= " AND pb.batch = '".$db->escape($batch)."'";
}
$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;
}
}

echo json_encode($res);
}
Loading
Loading