mirror of
https://github.com/Dolibarr/dolibarr.git
synced 2026-01-06 17:13:03 +01:00
Clean code
This commit is contained in:
@@ -1,16 +1,12 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* \file htdocs/mrp/ajax/ajax_bom.php
|
||||
* \brief Ajax search component for Mrp. It get BOM content.
|
||||
* \file htdocs/mrp/ajax/interface.php
|
||||
*/
|
||||
|
||||
//if (! defined('NOREQUIREUSER')) define('NOREQUIREUSER','1'); // Not disabled cause need to load personalized language
|
||||
//if (! defined('NOREQUIREDB')) define('NOREQUIREDB','1'); // Not disabled cause need to load personalized language
|
||||
if (!defined('NOREQUIRESOC')) {
|
||||
define('NOREQUIRESOC', '1');
|
||||
}
|
||||
//if (! defined('NOREQUIRETRAN')) define('NOREQUIRETRAN','1');
|
||||
if (!defined('NOCSRFCHECK')) {
|
||||
define('NOCSRFCHECK', '1');
|
||||
}
|
||||
|
||||
@@ -1027,7 +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 '<input type="text" class="width50" name="batch-'.$line->id.'-'.$i.'" value="'.$preselected.'" list="batch-'.$line->id.'-'.$i.'">';
|
||||
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 '</td>';
|
||||
}
|
||||
@@ -1324,25 +1324,23 @@ if ($object->id > 0 && (empty($action) || ($action != 'edit' && $action != 'crea
|
||||
<script type="text/javascript" language="javascript">
|
||||
|
||||
$(document).ready(function() {
|
||||
//Consumption : When a warehouse is selected, only the lot/serial numbers that are available in it are offered
|
||||
updateselectbatchbywarehouse();
|
||||
//Consumption : When a lot/serial number is selected and it is only available in one warehouse, the warehouse is automatically selected
|
||||
updateselectwarehousebybatch();
|
||||
});
|
||||
|
||||
//Lorsqu'un entrepôt est sélectionné, on propose seulement les numéro de séries qui sont disponibles dans celui-ci
|
||||
function updateselectbatchbywarehouse() {
|
||||
var element = $("select[name*='idwarehouse']");
|
||||
|
||||
element.change(function () {
|
||||
|
||||
//select entrepôts
|
||||
var selectwarehouse = $(this);
|
||||
|
||||
//select lots/series
|
||||
var selectbatch_name = selectwarehouse.attr('name').replace('idwarehouse', 'batch');
|
||||
var selectbatch = $("datalist[id*='" + selectbatch_name + "']");
|
||||
var selectedbatch = selectbatch.val();
|
||||
|
||||
//produit de la ligne
|
||||
var product_element_name = selectwarehouse.attr('name').replace('idwarehouse', 'product');
|
||||
|
||||
$.ajax({
|
||||
@@ -1365,7 +1363,6 @@ if ($object->id > 0 && (empty($action) || ($action != 'edit' && $action != 'crea
|
||||
|
||||
$.each(data, function (key, value) {
|
||||
|
||||
//si aucun entrepôt sélectionné, alors c'est le stock total du num lot/serie qui s'affiche
|
||||
if(selectwarehouse.val() == -1) {
|
||||
var label = " (<?php echo $langs->trans('Stock total') ?> : " + value + ")";
|
||||
} else {
|
||||
@@ -1384,25 +1381,20 @@ 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é
|
||||
function updateselectwarehousebybatch() {
|
||||
|
||||
$(document).on('change', 'input', function(){
|
||||
$(document).on('change', 'input[name*=batch]', function(){
|
||||
|
||||
//select lot/série
|
||||
var selectbatch = $(this);
|
||||
|
||||
//select entrepôts
|
||||
var selectwarehouse_name = selectbatch.attr('name').replace('batch', 'idwarehouse');
|
||||
var selectwarehouse = $("select[name*='" + selectwarehouse_name + "']");
|
||||
var selectedwarehouse = selectwarehouse.val();
|
||||
|
||||
//si un entrepôt est déjà sélectionné, alors on ne change rien
|
||||
if(selectedwarehouse != -1){
|
||||
return;
|
||||
}
|
||||
|
||||
//produit de la ligne
|
||||
var product_element_name = selectbatch.attr('name').replace('batch', 'product');
|
||||
|
||||
$.ajax({
|
||||
|
||||
Reference in New Issue
Block a user