|
@@ -25,9 +25,9 @@
|
|
|
*/
|
|
|
|
|
|
/**
|
|
|
- * \file htdocs/expedition/dispatch.php
|
|
|
+ * \file htdocs/expedition/dispatch.php
|
|
|
* \ingroup expedition
|
|
|
- * \brief Page to dispatch shipments
|
|
|
+ * \brief Page to dispatch shipments
|
|
|
*/
|
|
|
|
|
|
// Load Dolibarr environment
|
|
@@ -60,6 +60,9 @@ $fk_default_warehouse = GETPOST('fk_default_warehouse', 'int');
|
|
|
$cancel = GETPOST('cancel', 'alpha');
|
|
|
$confirm = GETPOST('confirm', 'alpha');
|
|
|
|
|
|
+$error = 0;
|
|
|
+$errors = array();
|
|
|
+
|
|
|
if ($user->socid) {
|
|
|
$socid = $user->socid;
|
|
|
}
|
|
@@ -75,6 +78,7 @@ if (GETPOSTISSET("projectid")) {
|
|
|
$object = new Expedition($db);
|
|
|
$objectorder = new Commande($db);
|
|
|
|
|
|
+
|
|
|
if ($id > 0 || !empty($ref)) {
|
|
|
$result = $object->fetch($id, $ref);
|
|
|
if ($result <= 0) {
|
|
@@ -96,7 +100,7 @@ if ($id > 0 || !empty($ref)) {
|
|
|
$result = restrictedArea($user, 'expedition', $object, '');
|
|
|
|
|
|
if (!isModEnabled('stock')) {
|
|
|
- accessforbidden();
|
|
|
+ accessforbidden('Module stock disabled');
|
|
|
}
|
|
|
|
|
|
$usercancreate = $user->hasRight('expedition', 'creer');
|
|
@@ -148,46 +152,53 @@ if ($action == 'updatelines' && $usercancreate) {
|
|
|
$lot = '';
|
|
|
$dDLUO = '';
|
|
|
$dDLC = '';
|
|
|
- if ($modebatch == "batch") { //TODO: Make impossible to input non existing batchcode
|
|
|
+ if ($modebatch == "batch") { //TODO: Make impossible to input non existing batch code
|
|
|
$lot = GETPOST('lot_number_'.$reg[1].'_'.$reg[2]);
|
|
|
$dDLUO = dol_mktime(12, 0, 0, GETPOST('dluo_'.$reg[1].'_'.$reg[2].'month', 'int'), GETPOST('dluo_'.$reg[1].'_'.$reg[2].'day', 'int'), GETPOST('dluo_'.$reg[1].'_'.$reg[2].'year', 'int'));
|
|
|
$dDLC = dol_mktime(12, 0, 0, GETPOST('dlc_'.$reg[1].'_'.$reg[2].'month', 'int'), GETPOST('dlc_'.$reg[1].'_'.$reg[2].'day', 'int'), GETPOST('dlc_'.$reg[1].'_'.$reg[2].'year', 'int'));
|
|
|
}
|
|
|
|
|
|
+ $newqty = price2num(GETPOST($qty, 'alpha'), 'MS');
|
|
|
+
|
|
|
// We ask to move a qty
|
|
|
- if (($modebatch == "batch" && GETPOST($qty) > 0) || ($modebatch == "barcode" && GETPOST($qty) != 0)) {
|
|
|
- if (!(GETPOST($ent, 'int') > 0)) {
|
|
|
- dol_syslog('No dispatch for line '.$key.' as no warehouse was chosen.');
|
|
|
- $text = $langs->transnoentities('Warehouse').', '.$langs->transnoentities('Line').' '.($numline);
|
|
|
- setEventMessages($langs->trans('ErrorFieldRequired', $text), null, 'errors');
|
|
|
- $error++;
|
|
|
- }
|
|
|
- if ($modebatch == "batch") {
|
|
|
- $sql = "SELECT pb.rowid ";
|
|
|
- $sql .= " FROM ".MAIN_DB_PREFIX."product_batch as pb";
|
|
|
- $sql .= " JOIN ".MAIN_DB_PREFIX."product_stock as ps";
|
|
|
- $sql .= " ON ps.rowid = pb.fk_product_stock";
|
|
|
- $sql .= " WHERE pb.batch ='".$db->escape($lot)."'";
|
|
|
- $sql .= " AND ps.fk_product =".((int) GETPOST($prod, 'int')) ;
|
|
|
- $sql .= " AND ps.fk_entrepot =".((int) GETPOST($ent, 'int')) ;
|
|
|
- $resql = $db->query($sql);
|
|
|
- if ($resql) {
|
|
|
- $num = $db->num_rows($resql);
|
|
|
- if ($num > 1) {
|
|
|
- dol_syslog('No dispatch for line '.$key.' as too many combination warehouse, product, batch code was found ('.$num.').');
|
|
|
- setEventMessages($langs->trans('ErrorTooManyCombinationBatchcode', $numline, $num), null, 'errors');
|
|
|
- $error++;
|
|
|
- } elseif ($num < 1) {
|
|
|
- dol_syslog('No dispatch for line '.$key.' as no combination warehouse, product, batch code was found.');
|
|
|
- setEventMessages($langs->trans('ErrorNoCombinationBatchcode', $numline), null, 'errors');
|
|
|
- $error++;
|
|
|
+ if (($modebatch == "batch" && $newqty >= 0) || ($modebatch == "barcode" && $newqty != 0)) {
|
|
|
+ if ($newqty > 0) { // If we want a qty, we make test on input data
|
|
|
+ if (!(GETPOST($ent, 'int') > 0)) {
|
|
|
+ dol_syslog('No dispatch for line '.$key.' as no warehouse was chosen.');
|
|
|
+ $text = $langs->transnoentities('Warehouse').', '.$langs->transnoentities('Line').' '.($numline);
|
|
|
+ setEventMessages($langs->trans('ErrorFieldRequired', $text), null, 'errors');
|
|
|
+ $error++;
|
|
|
+ }
|
|
|
+ if (!$error && $modebatch == "batch") {
|
|
|
+ $sql = "SELECT pb.rowid ";
|
|
|
+ $sql .= " FROM ".MAIN_DB_PREFIX."product_batch as pb";
|
|
|
+ $sql .= " JOIN ".MAIN_DB_PREFIX."product_stock as ps";
|
|
|
+ $sql .= " ON ps.rowid = pb.fk_product_stock";
|
|
|
+ $sql .= " WHERE pb.batch = '".$db->escape($lot)."'";
|
|
|
+ $sql .= " AND ps.fk_product = ".((int) GETPOST($prod, 'int')) ;
|
|
|
+ $sql .= " AND ps.fk_entrepot = ".((int) GETPOST($ent, 'int')) ;
|
|
|
+
|
|
|
+ $resql = $db->query($sql);
|
|
|
+ if ($resql) {
|
|
|
+ $num = $db->num_rows($resql);
|
|
|
+ if ($num > 1) {
|
|
|
+ dol_syslog('No dispatch for line '.$key.' as too many combination warehouse, product, batch code was found ('.$num.').');
|
|
|
+ setEventMessages($langs->trans('ErrorTooManyCombinationBatchcode', $numline, $num), null, 'errors');
|
|
|
+ $error++;
|
|
|
+ } elseif ($num < 1) {
|
|
|
+ dol_syslog('No dispatch for line '.$key.' as no combination warehouse, product, batch code was found.');
|
|
|
+ setEventMessages($langs->trans('ErrorNoCombinationBatchcode', $numline), null, 'errors');
|
|
|
+ $error++;
|
|
|
+ }
|
|
|
+ $db->free($resql);
|
|
|
}
|
|
|
- $db->free($resql);
|
|
|
}
|
|
|
}
|
|
|
+ //var_dump($key.' '.$newqty.' '.$idline.' '.$error);
|
|
|
|
|
|
if (!$error) {
|
|
|
$qtystart = 0;
|
|
|
+
|
|
|
if ($idline > 0) {
|
|
|
$result = $expeditiondispatch->fetch($idline);
|
|
|
if ($result < 0) {
|
|
@@ -195,22 +206,38 @@ if ($action == 'updatelines' && $usercancreate) {
|
|
|
$error++;
|
|
|
} else {
|
|
|
$qtystart = $expeditiondispatch->qty;
|
|
|
- $expeditiondispatch->qty = GETPOST($qty);
|
|
|
+ $expeditiondispatch->qty = $newqty;
|
|
|
$expeditiondispatch->entrepot_id = GETPOST($ent, 'int');
|
|
|
|
|
|
- $result = $expeditiondispatch->update($user);
|
|
|
+ if ($newqty > 0) {
|
|
|
+ $result = $expeditiondispatch->update($user);
|
|
|
+ } else {
|
|
|
+ $result = $expeditiondispatch->delete($user);
|
|
|
+ }
|
|
|
if ($result < 0) {
|
|
|
setEventMessages($expeditiondispatch->error, $expeditiondispatch->errors, 'errors');
|
|
|
$error++;
|
|
|
}
|
|
|
|
|
|
if (!$error && $modebatch == "batch") {
|
|
|
- $sql = "UPDATE ".MAIN_DB_PREFIX.$expeditionlinebatch->table_element." SET";
|
|
|
- $sql .= " eatby = ".($eatby ? "'".$db->idate($eatby)."'" : "null");
|
|
|
- $sql .= " , sellby = ".($sellby ? "'".$db->idate($sellby)."'" : "null");
|
|
|
- $sql .= " , qty = ".((float) price2num(GETPOST($qty, 'int'), 'MS'));
|
|
|
- $sql .= " WHERE fk_expeditiondet = ".((int) $idline);
|
|
|
- $sql .= " AND batch = ".((int) $idline);
|
|
|
+ if ($newqty > 0) {
|
|
|
+ $suffixkeyfordate = preg_replace('/^product_batch/', '', $key);
|
|
|
+ $sellby = dol_mktime(0, 0, 0, GETPOST('dlc'.$suffixkeyfordate.'month'), GETPOST('dlc'.$suffixkeyfordate.'day'), GETPOST('dlc'.$suffixkeyfordate.'year'), '');
|
|
|
+ $eatby = dol_mktime(0, 0, 0, GETPOST('dluo'.$suffixkeyfordate.'month'), GETPOST('dluo'.$suffixkeyfordate.'day'), GETPOST('dluo'.$suffixkeyfordate.'year'));
|
|
|
+
|
|
|
+ $sql = "UPDATE ".MAIN_DB_PREFIX.$expeditionlinebatch->table_element." SET";
|
|
|
+ $sql .= " eatby = ".($eatby ? "'".$db->idate($eatby)."'" : "null");
|
|
|
+ $sql .= " , sellby = ".($sellby ? "'".$db->idate($sellby)."'" : "null");
|
|
|
+ $sql .= " , qty = ".((float) $newqty);
|
|
|
+ // TODO Add a column fk_warehouse
|
|
|
+ $sql .= " WHERE fk_expeditiondet = ".((int) $idline);
|
|
|
+ $sql .= " AND batch = '".$db->escape($lot)."'";
|
|
|
+ } else {
|
|
|
+ $sql = " DELETE FROM ".MAIN_DB_PREFIX.$expeditionlinebatch->table_element;
|
|
|
+ $sql .= " WHERE fk_expeditiondet = ".((int) $idline);
|
|
|
+ $sql .= " AND batch = '".$db->escape($lot)."'";
|
|
|
+ }
|
|
|
+
|
|
|
$resql = $db->query($sql);
|
|
|
if (!$db->query($sql)) {
|
|
|
dol_print_error($db);
|
|
@@ -222,34 +249,40 @@ if ($action == 'updatelines' && $usercancreate) {
|
|
|
$expeditiondispatch->fk_expedition = $object->id;
|
|
|
$expeditiondispatch->entrepot_id = GETPOST($ent, 'int');
|
|
|
$expeditiondispatch->fk_origin_line = GETPOST($fk_commandedet, 'int');
|
|
|
- $expeditiondispatch->qty = GETPOST($qty, 'int');
|
|
|
- $idline = $expeditiondispatch->insert($user);
|
|
|
- if ($idline < 0) {
|
|
|
- setEventMessages($expeditiondispatch->error, $expeditiondispatch->errors, 'errors');
|
|
|
- $error++;
|
|
|
- }
|
|
|
+ $expeditiondispatch->qty = $newqty;
|
|
|
|
|
|
- if ($modebatch == "batch" && !$error) {
|
|
|
- $expeditionlinebatch->sellby = $dDLUO;
|
|
|
- $expeditionlinebatch->eatby = $dDLC;
|
|
|
- $expeditionlinebatch->batch = $lot;
|
|
|
- $expeditionlinebatch->qty = GETPOST($qty, 'int');
|
|
|
- $expeditionlinebatch->fk_origin_stock = 0;
|
|
|
- $result = $expeditionlinebatch->create($idline);
|
|
|
- if ($result < 0) {
|
|
|
- setEventMessages($expeditionlinebatch->error, $expeditionlinebatch->errors, 'errors');
|
|
|
+ if ($newqty > 0) {
|
|
|
+ $idline = $expeditiondispatch->insert($user);
|
|
|
+ if ($idline < 0) {
|
|
|
+ setEventMessages($expeditiondispatch->error, $expeditiondispatch->errors, 'errors');
|
|
|
$error++;
|
|
|
}
|
|
|
+
|
|
|
+ if ($modebatch == "batch" && !$error) {
|
|
|
+ $expeditionlinebatch->sellby = $dDLUO;
|
|
|
+ $expeditionlinebatch->eatby = $dDLC;
|
|
|
+ $expeditionlinebatch->batch = $lot;
|
|
|
+ $expeditionlinebatch->qty = $newqty;
|
|
|
+ $expeditionlinebatch->fk_origin_stock = 0;
|
|
|
+ $expeditionlinebatch->fk_warehouse = GETPOST($ent, 'int');
|
|
|
+
|
|
|
+ $result = $expeditionlinebatch->create($idline);
|
|
|
+ if ($result < 0) {
|
|
|
+ setEventMessages($expeditionlinebatch->error, $expeditionlinebatch->errors, 'errors');
|
|
|
+ $error++;
|
|
|
+ }
|
|
|
+ }
|
|
|
}
|
|
|
}
|
|
|
|
|
|
- // If module stock is enabled and the stock increase is done on purchase order dispatching
|
|
|
- if (!$error && GETPOST($ent, 'int') > 0 && isModEnabled('stock') && !empty($conf->global->STOCK_CALCULATE_ON_SUPPLIER_DISPATCH_ORDER)) {
|
|
|
+ // If module stock is enabled and the stock decrease is done on edtion of this page
|
|
|
+ /*
|
|
|
+ if (!$error && GETPOST($ent, 'int') > 0 && isModEnabled('stock') && !empty($conf->global->STOCK_CALCULATE_ON_SHIPMENT_DISPATCH_ORDER)) {
|
|
|
$mouv = new MouvementStock($db);
|
|
|
$product = GETPOST($prod, 'int');
|
|
|
$entrepot = GETPOST($ent, 'int');
|
|
|
- $qtymouv = GETPOST($qty) - $qtystart;
|
|
|
- $price = GETPOST($pu);
|
|
|
+ $qtymouv = price2num(GETPOST($qty, 'alpha'), 'MS') - $qtystart;
|
|
|
+ $price = price2num(GETPOST($pu), 'MU');
|
|
|
$comment = GETPOST('comment');
|
|
|
$inventorycode = dol_print_date(dol_now(), 'dayhourlog');
|
|
|
$now = dol_now();
|
|
@@ -279,6 +312,7 @@ if ($action == 'updatelines' && $usercancreate) {
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
+ */
|
|
|
}
|
|
|
}
|
|
|
}
|
|
@@ -289,6 +323,9 @@ if ($action == 'updatelines' && $usercancreate) {
|
|
|
} else {
|
|
|
$db->commit();
|
|
|
setEventMessages($langs->trans("ReceptionUpdated"), null);
|
|
|
+
|
|
|
+ header("Location: ".DOL_URL_ROOT.'/expedition/dispatch.php?id='.$object->id);
|
|
|
+ exit;
|
|
|
}
|
|
|
} elseif ($action == 'setdate_livraison' && $usercancreate) {
|
|
|
$datedelivery = dol_mktime(GETPOST('liv_hour', 'int'), GETPOST('liv_min', 'int'), 0, GETPOST('liv_month', 'int'), GETPOST('liv_day', 'int'), GETPOST('liv_year', 'int'));
|
|
@@ -318,7 +355,8 @@ $morejs = array('/expedition/js/lib_dispatch.js.php');
|
|
|
llxHeader('', $title, $help_url, '', 0, 0, $morejs);
|
|
|
|
|
|
if ($object->id > 0 || !empty($object->ref)) {
|
|
|
- $lines = $object->lines;
|
|
|
+ $lines = $object->lines; // This is an array of detail of line, on line per source order line found intolines[]->fk_origin_line, then each line may have sub data
|
|
|
+ //var_dump($lines[0]->fk_origin_line); exit;
|
|
|
|
|
|
$num_prod = count($lines);
|
|
|
|
|
@@ -465,7 +503,7 @@ if ($object->id > 0 || !empty($object->ref)) {
|
|
|
print '<br>';
|
|
|
$disabled = 0; // This is used to disable or not the bulk selection of target warehouse. No reason to have it disabled so forced to 0.
|
|
|
|
|
|
- if ($object->statut == Reception::STATUS_DRAFT) {
|
|
|
+ if ($object->statut == Expedition::STATUS_DRAFT) {
|
|
|
require_once DOL_DOCUMENT_ROOT.'/product/class/html.formproduct.class.php';
|
|
|
$formproduct = new FormProduct($db);
|
|
|
$formproduct->loadWarehouses();
|
|
@@ -482,7 +520,7 @@ if ($object->id > 0 || !empty($object->ref)) {
|
|
|
print '<div class="div-table-responsive-no-min">';
|
|
|
print '<table class="noborder centpercent">';
|
|
|
|
|
|
- // Get list of lines from the shipments $products_dispatched with qty dispatched for each product id
|
|
|
+ // Get list of lines of the shipment $products_dispatched, with qty dispatched for each product id
|
|
|
$products_dispatched = array();
|
|
|
$sql = "SELECT ed.fk_origin_line as rowid, sum(ed.qty) as qty";
|
|
|
$sql .= " FROM ".MAIN_DB_PREFIX."expeditiondet as ed";
|
|
@@ -503,6 +541,7 @@ if ($object->id > 0 || !empty($object->ref)) {
|
|
|
}
|
|
|
$db->free($resql);
|
|
|
}
|
|
|
+
|
|
|
//$sql = "SELECT l.rowid, l.fk_product, l.subprice, l.remise_percent, l.ref AS sref, SUM(l.qty) as qty,";
|
|
|
$sql = "SELECT l.rowid, l.fk_product, l.subprice, l.remise_percent, '' AS sref, l.qty as qty,";
|
|
|
$sql .= " p.ref, p.label, p.tobatch, p.fk_default_warehouse";
|
|
@@ -565,8 +604,12 @@ if ($object->id > 0 || !empty($object->ref)) {
|
|
|
print '<td></td>';
|
|
|
}
|
|
|
print '<td class="right">'.$langs->trans("QtyOrdered").'</td>';
|
|
|
- print '<td class="right">'.$langs->trans("QtyDispatchedShort").'</td>';
|
|
|
- print ' <td class="right">'.$langs->trans("QtyToDispatchShort");
|
|
|
+ if ($object->status == Expedition::STATUS_DRAFT) {
|
|
|
+ print '<td class="right">'.$langs->trans("QtyToDispatchShort"); // Qty to dispatch (sum for all lines of batch detail if there is)
|
|
|
+ } else {
|
|
|
+ print '<td class="right">'.$langs->trans("QtyDispatchedShort").'</td>';
|
|
|
+ }
|
|
|
+ print '<td class="right">'.$langs->trans("QtyToDispatchShort");
|
|
|
print '<td width="32"></td>';
|
|
|
|
|
|
if (!empty($conf->global->SUPPLIER_ORDER_CAN_UPDATE_BUYINGPRICE_DURING_RECEIPT)) {
|
|
@@ -610,6 +653,7 @@ if ($object->id > 0 || !empty($object->ref)) {
|
|
|
|
|
|
$conf->cache['product'] = array();
|
|
|
|
|
|
+ // Loop on each line of origin order
|
|
|
while ($i < $num) {
|
|
|
$objp = $db->fetch_object($resql);
|
|
|
|
|
@@ -754,8 +798,8 @@ if ($object->id > 0 || !empty($object->ref)) {
|
|
|
print '</td>';
|
|
|
|
|
|
print '<td>';
|
|
|
- print '<input disabled="" type="text" class="inputlotnumber quatrevingtquinzepercent" id="lot_number'.$suffix.'" name="lot_number'.$suffix.'" value="'.$objd->batch.'">';
|
|
|
- //print '<input type="hidden" class="inputlotnumber quatrevingtquinzepercent" id="lot_number'.$suffix.'" name="lot_number'.$suffix.'" value="'.$objd->batch.'">';
|
|
|
+ print '<input type="text" class="inputlotnumber quatrevingtquinzepercent" id="lot_number'.$suffix.'" name="lot_number'.$suffix.'" value="'.$objd->batch.'">';
|
|
|
+ //print '<input type="hidden" id="lot_number'.$suffix.'" name="lot_number'.$suffix.'" value="'.$objd->batch.'">';
|
|
|
print '</td>';
|
|
|
if (empty($conf->global->PRODUCT_DISABLE_SELLBY)) {
|
|
|
print '<td class="nowraponall">';
|
|
@@ -809,8 +853,10 @@ if ($object->id > 0 || !empty($object->ref)) {
|
|
|
}
|
|
|
// Qty to dispatch
|
|
|
print '<td class="right">';
|
|
|
- print '<a href="#" id="reset'.$suffix.'" class="resetline">'.img_picto($langs->trans("Reset"), 'eraser', 'class="pictofixedwidth opacitymedium"').'</a>';
|
|
|
- print '<input id="qty'.$suffix.'" onchange="onChangeDispatchLineQty($(this))" name="qty'.$suffix.'" data-type="'.$type.'" data-index="'.$i.'" class="width50 right qtydispatchinput" value="'.(GETPOSTISSET('qty'.$suffix) ? GETPOST('qty'.$suffix, 'int') : $objd->qty).'" data-expected="'.$objd->qty.'">';
|
|
|
+ print '<a href="" id="reset'.$suffix.'" class="resetline">'.img_picto($langs->trans("Reset"), 'eraser', 'class="pictofixedwidth opacitymedium"').'</a>';
|
|
|
+ $suggestedvalue = (GETPOSTISSET('qty'.$suffix) ? GETPOST('qty'.$suffix, 'int') : $objd->qty);
|
|
|
+ //var_dump($suggestedvalue);exit;
|
|
|
+ print '<input id="qty'.$suffix.'" onchange="onChangeDispatchLineQty($(this))" name="qty'.$suffix.'" data-type="'.$type.'" data-index="'.$i.'" class="width50 right qtydispatchinput" value="'.$suggestedvalue.'" data-expected="'.$objd->qty.'">';
|
|
|
print '</td>';
|
|
|
print '<td>';
|
|
|
if (isModEnabled('productbatch') && $objp->tobatch > 0) {
|
|
@@ -953,8 +999,14 @@ if ($object->id > 0 || !empty($object->ref)) {
|
|
|
}
|
|
|
// Qty to dispatch
|
|
|
print '<td class="right">';
|
|
|
- print '<a href="#" id="reset'.$suffix.'" class="resetline">'.img_picto($langs->trans("Reset"), 'eraser', 'class="pictofixedwidth opacitymedium"').'</a>';
|
|
|
- print '<input id="qty'.$suffix.'" onchange="onChangeDispatchLineQty($(this))" name="qty'.$suffix.'" data-index="'.$i.'" data-type="text" class="width50 right qtydispatchinput" value="'.(GETPOSTISSET('qty'.$suffix) ? GETPOST('qty'.$suffix, 'int') : (empty($conf->global->SUPPLIER_ORDER_DISPATCH_FORCE_QTY_INPUT_TO_ZERO) ? $remaintodispatch : 0)).'" data-expected="'.$remaintodispatch.'">';
|
|
|
+ print '<a href="" id="reset'.$suffix.'" class="resetline">'.img_picto($langs->trans("Reset"), 'eraser', 'class="pictofixedwidth opacitymedium"').'</a>';
|
|
|
+ $amounttosuggest = (GETPOSTISSET('qty'.$suffix) ? GETPOST('qty'.$suffix, 'int') : (empty($conf->global->SUPPLIER_ORDER_DISPATCH_FORCE_QTY_INPUT_TO_ZERO) ? $remaintodispatch : 0));
|
|
|
+ if (count($products_dispatched)) {
|
|
|
+ // There is already existing lines into llx_expeditiondet, this means a plan for the shipment has already been started.
|
|
|
+ // In such a case, we do not suggest new values, we suggest the value known.
|
|
|
+ $amounttosuggest = (GETPOSTISSET('qty'.$suffix) ? GETPOST('qty'.$suffix, 'int') : (isset($products_dispatched[$objp->rowid]) ? $products_dispatched[$objp->rowid] : ''));
|
|
|
+ }
|
|
|
+ print '<input id="qty'.$suffix.'" onchange="onChangeDispatchLineQty($(this))" name="qty'.$suffix.'" data-index="'.$i.'" data-type="text" class="width50 right qtydispatchinput" value="'.$amounttosuggest.'" data-expected="'.$amounttosuggest.'">';
|
|
|
print '</td>';
|
|
|
print '<td>';
|
|
|
if (isModEnabled('productbatch') && $objp->tobatch > 0) {
|
|
@@ -1011,14 +1063,14 @@ if ($object->id > 0 || !empty($object->ref)) {
|
|
|
print '</div>';
|
|
|
|
|
|
if ($nbproduct) {
|
|
|
- $checkboxlabel = $langs->trans("CloseReceivedSupplierOrdersAutomatically", $langs->transnoentitiesnoconv('StatusOrderReceivedAll'));
|
|
|
+ //$checkboxlabel = $langs->trans("CloseReceivedSupplierOrdersAutomatically", $langs->transnoentitiesnoconv('StatusOrderReceivedAll'));
|
|
|
|
|
|
print '<div class="center">';
|
|
|
$parameters = array();
|
|
|
$reshook = $hookmanager->executeHooks('addMoreActionsButtons', $parameters, $object, $action); // Note that $action and $object may have been
|
|
|
// modified by hook
|
|
|
if (empty($reshook)) {
|
|
|
- if (empty($conf->reception->enabled)) {
|
|
|
+ /*if (empty($conf->reception->enabled)) {
|
|
|
print $langs->trans("Comment").' : ';
|
|
|
print '<input type="text" class="minwidth400" maxlength="128" name="comment" value="';
|
|
|
print GETPOSTISSET("comment") ? GETPOST("comment") : $langs->trans("DispatchSupplierOrder", $object->ref);
|
|
@@ -1031,6 +1083,8 @@ if ($object->id > 0 || !empty($object->ref)) {
|
|
|
$dispatchBt = empty($conf->reception->enabled) ? $langs->trans("Receive") : $langs->trans("CreateReception");
|
|
|
|
|
|
print '<br>';
|
|
|
+ */
|
|
|
+
|
|
|
print '<input type="submit" id="submitform" class="button" name="dispatch" value="'.$langs->trans("Save").'"';
|
|
|
$disabled = 0;
|
|
|
if (!$usercancreate) {
|
|
@@ -1067,11 +1121,13 @@ if ($object->id > 0 || !empty($object->ref)) {
|
|
|
print '<script type="text/javascript">
|
|
|
$(document).ready(function () {
|
|
|
$("select[name=fk_default_warehouse]").change(function() {
|
|
|
+ console.log("warehouse is modified");
|
|
|
var fk_default_warehouse = $("option:selected", this).val();
|
|
|
$("select[name^=entrepot_]").val(fk_default_warehouse).change();
|
|
|
});
|
|
|
|
|
|
$("#autoreset").click(function() {
|
|
|
+ console.log("we click on autoreset");
|
|
|
$(".autoresettr").each(function(){
|
|
|
id = $(this).attr("name");
|
|
|
idtab = id.split("_");
|
|
@@ -1102,7 +1158,8 @@ if ($object->id > 0 || !empty($object->ref)) {
|
|
|
return false;
|
|
|
});
|
|
|
|
|
|
- $(".resetline").click(function(){
|
|
|
+ $(".resetline").on("click", function(event) {
|
|
|
+ event.preventDefault();
|
|
|
id = $(this).attr("id");
|
|
|
id = id.split("reset_");
|
|
|
console.log("Reset trigger for id = qty_"+id[1]);
|