WIP
This commit is contained in:
parent
a5ab9e059a
commit
2ea5da3e13
@ -1026,7 +1026,7 @@ if ($object->id > 0 && (empty($action) || ($action != 'edit' && $action != 'crea
|
|||||||
print '<td>';
|
print '<td>';
|
||||||
if ($tmpproduct->status_batch) {
|
if ($tmpproduct->status_batch) {
|
||||||
$preselected = (GETPOSTISSET('batch-'.$line->id.'-'.$i) ? GETPOST('batch-'.$line->id.'-'.$i) : '');
|
$preselected = (GETPOSTISSET('batch-'.$line->id.'-'.$i) ? GETPOST('batch-'.$line->id.'-'.$i) : '');
|
||||||
// print '<input type="text" class="width50" name="batch-'.$line->id.'-'.$i.'" value="'.$preselected.'" list="batch-'.$line->id.'-'.$i.'">';
|
print '<input type="text" class="width50" name="batch-'.$line->id.'-'.$i.'" value="'.$preselected.'" list="batch-'.$line->id.'-'.$i.'">';
|
||||||
print $formproduct->selectLotDataList('batch-'.$line->id.'-'.$i, 1, $line->fk_product, '');
|
print $formproduct->selectLotDataList('batch-'.$line->id.'-'.$i, 1, $line->fk_product, '');
|
||||||
// print $formproduct->selectLotStock('', 'batch-'.$line->id.'-'.$i, '', 0, '', $line->fk_product);
|
// print $formproduct->selectLotStock('', 'batch-'.$line->id.'-'.$i, '', 0, '', $line->fk_product);
|
||||||
}
|
}
|
||||||
@ -1340,7 +1340,7 @@ if ($object->id > 0 && (empty($action) || ($action != 'edit' && $action != 'crea
|
|||||||
|
|
||||||
//select lots/series
|
//select lots/series
|
||||||
var selectbatch_name = selectwarehouse.attr('name').replace('idwarehouse', 'batch');
|
var selectbatch_name = selectwarehouse.attr('name').replace('idwarehouse', 'batch');
|
||||||
var selectbatch = $("select[name*='" + selectbatch_name + "']");
|
var selectbatch = $("datalist[id*='" + selectbatch_name + "']");
|
||||||
var selectedbatch = selectbatch.val();
|
var selectedbatch = selectbatch.val();
|
||||||
|
|
||||||
//produit de la ligne
|
//produit de la ligne
|
||||||
@ -1357,21 +1357,21 @@ if ($object->id > 0 && (empty($action) || ($action != 'edit' && $action != 'crea
|
|||||||
}).done(function (data) {
|
}).done(function (data) {
|
||||||
|
|
||||||
selectbatch.empty();
|
selectbatch.empty();
|
||||||
|
$('input[name*='+selectbatch_name+']').val('');
|
||||||
|
|
||||||
var data = JSON.parse(data);
|
var data = JSON.parse(data);
|
||||||
|
|
||||||
selectbatch.append($('<option>', {
|
selectbatch.append($('<option>', {
|
||||||
value: -1,
|
value: '',
|
||||||
text: ''
|
|
||||||
}));
|
}));
|
||||||
|
|
||||||
$.each(data, function (key, value) {
|
$.each(data, function (key, value) {
|
||||||
|
|
||||||
//si aucun entrepôt sélectionné, alors c'est le stock total du num lot/serie qui s'affiche
|
//si aucun entrepôt sélectionné, alors c'est le stock total du num lot/serie qui s'affiche
|
||||||
if(selectwarehouse.val() == -1) {
|
if(selectwarehouse.val() == -1) {
|
||||||
var label = key + " (<?php echo $langs->trans('Stock total') ?> : " + value + ")";
|
var label = " (<?php echo $langs->trans('Stock total') ?> : " + value + ")";
|
||||||
} else {
|
} else {
|
||||||
var label = key + " (<?php echo $langs->trans('Stock') ?> : " + value + ")";
|
var label = " (<?php echo $langs->trans('Stock') ?> : " + value + ")";
|
||||||
}
|
}
|
||||||
|
|
||||||
if(key === selectedbatch) {
|
if(key === selectedbatch) {
|
||||||
@ -1391,9 +1391,8 @@ if ($object->id > 0 && (empty($action) || ($action != 'edit' && $action != 'crea
|
|||||||
|
|
||||||
//Lorsqu'un numéro de lot/série est sélectionné et qu'il n'est disponible seulement dans un entrepôt, l'entrepôt est automatiquement sélectionné
|
//Lorsqu'un numéro de lot/série est sélectionné et qu'il n'est disponible seulement dans un entrepôt, l'entrepôt est automatiquement sélectionné
|
||||||
function updateselectwarehousebybatch() {
|
function updateselectwarehousebybatch() {
|
||||||
var element = $("select[name*='batch']");
|
|
||||||
|
|
||||||
element.change(function () {
|
$(document).on('change', 'input', function(){
|
||||||
|
|
||||||
//select lot/série
|
//select lot/série
|
||||||
var selectbatch = $(this);
|
var selectbatch = $(this);
|
||||||
@ -1409,7 +1408,7 @@ if ($object->id > 0 && (empty($action) || ($action != 'edit' && $action != 'crea
|
|||||||
}
|
}
|
||||||
|
|
||||||
//produit de la ligne
|
//produit de la ligne
|
||||||
var product_element_name = element.attr('name').replace('batch', 'product');
|
var product_element_name = selectbatch.attr('name').replace('batch', 'product');
|
||||||
|
|
||||||
$.ajax({
|
$.ajax({
|
||||||
type: "POST",
|
type: "POST",
|
||||||
|
|||||||
@ -626,13 +626,13 @@ class FormProduct
|
|||||||
{
|
{
|
||||||
global $conf, $langs;
|
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 = '';
|
$out = '';
|
||||||
$productIdArray = array();
|
$productIdArray = array();
|
||||||
if (!is_array($objectLines) || !count($objectLines)) {
|
if (!is_array($objectLines) || !count($objectLines)) {
|
||||||
if (!empty($fk_product) && $fk_product > 0) {
|
if (!empty($fk_product) && $fk_product > 0) {
|
||||||
$productIdArray[] = (int)$fk_product;
|
$productIdArray[] = (int) $fk_product;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
foreach ($objectLines as $line) {
|
foreach ($objectLines as $line) {
|
||||||
@ -644,58 +644,26 @@ class FormProduct
|
|||||||
|
|
||||||
$nboflot = $this->loadLotStock($productIdArray);
|
$nboflot = $this->loadLotStock($productIdArray);
|
||||||
|
|
||||||
if ($conf->use_javascript_ajax && !$forcecombo) {
|
$out .= '<datalist id="'.$htmlname.'" >';
|
||||||
include_once DOL_DOCUMENT_ROOT.'/core/lib/ajax.lib.php';
|
|
||||||
$comboenhancement = ajax_combobox($htmlname, $events);
|
|
||||||
$out .= $comboenhancement;
|
|
||||||
}
|
|
||||||
|
|
||||||
$out .= '<select class="flat' . ($morecss ? ' ' . $morecss : '') . '"' . ($disabled ? ' disabled' : '') . ' id="' . $htmlname . '" name="' . ($htmlname . ($disabled ? '_disabled' : '')) . '">';
|
|
||||||
if ($empty) {
|
|
||||||
$out .= '<option value="-1">'.($empty_label ? $empty_label : ' ').'</option>';
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!empty($fk_product) && $fk_product > 0) {
|
if (!empty($fk_product) && $fk_product > 0) {
|
||||||
$productIdArray = array((int)$fk_product); // only show lot stock for product
|
$productIdArray = array((int) $fk_product); // only show lot stock for product
|
||||||
} else {
|
} else {
|
||||||
foreach ($this->cache_lot as $key => $value) {
|
foreach ($this->cache_lot as $key => $value) {
|
||||||
$productIdArray[] = $key;
|
$productIdArray[] = $key;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
$TBatchQuantity = array();
|
|
||||||
foreach ($productIdArray as $productId) {
|
foreach ($productIdArray as $productId) {
|
||||||
foreach ($this->cache_lot[$productId] as $id => $arraytypes) {
|
foreach ($this->cache_lot[$productId] as $id => $arraytypes) {
|
||||||
$TBatchQuantity[$productId][$arraytypes['batch']][$arraytypes['entrepot_id']] = $arraytypes['qty'];
|
if (empty($fk_entrepot) || $fk_entrepot == $arraytypes['entrepot_id']) {
|
||||||
}
|
$label = $arraytypes['entrepot_label'].' - ';
|
||||||
}
|
$label .= $arraytypes['batch'];
|
||||||
|
$out .= '<option>'.$arraytypes['batch'].'</option>';
|
||||||
foreach($TBatchQuantity as $id_product => $TBatchs){
|
|
||||||
|
|
||||||
foreach ($TBatchs as $batch => $TQtyByWarehouse) {
|
|
||||||
$label = $batch;
|
|
||||||
|
|
||||||
//si pas d'entrepôt, on affiche le stock total du lot, tout entrepôt compris
|
|
||||||
if (empty($fk_entrepot)) $label .= " (" . $langs->trans('Stock total') . " : " . array_sum($TQtyByWarehouse) . ")";
|
|
||||||
//sinon on affiche seulement le stock de l'entrepôt en question
|
|
||||||
else $label .= " (" . $langs->trans('Stock') . " : " . $TQtyByWarehouse[$fk_entrepot] . ")";
|
|
||||||
|
|
||||||
$out .= '<option value="' . $batch . '"';
|
|
||||||
|
|
||||||
if ($selected == $batch) {
|
|
||||||
$out .= ' selected';
|
|
||||||
}
|
}
|
||||||
|
|
||||||
$out .= ' data-html="' . dol_escape_htmltag($label) . '"';
|
|
||||||
$out .= '>';
|
|
||||||
$out .= $label;
|
|
||||||
$out .= '</option>';
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
$out .= '</datalist>';
|
||||||
|
|
||||||
$out .= '</select>';
|
|
||||||
|
|
||||||
return $out;
|
return $out;
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user