Ajout interface.php
This commit is contained in:
parent
f5446e0801
commit
25e8a2c758
86
htdocs/mrp/ajax/interface.php
Normal file
86
htdocs/mrp/ajax/interface.php
Normal file
@ -0,0 +1,86 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* \file htdocs/mrp/ajax/ajax_bom.php
|
||||
* \brief Ajax search component for Mrp. It get BOM content.
|
||||
*/
|
||||
|
||||
//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');
|
||||
}
|
||||
if (!defined('NOTOKENRENEWAL')) {
|
||||
define('NOTOKENRENEWAL', '1');
|
||||
}
|
||||
if (!defined('NOREQUIREMENU')) {
|
||||
define('NOREQUIREMENU', '1');
|
||||
}
|
||||
if (!defined('NOREQUIREHTML')) {
|
||||
define('NOREQUIREHTML', '1');
|
||||
}
|
||||
if (!defined('NOREQUIREAJAX')) {
|
||||
define('NOREQUIREAJAX', '1');
|
||||
}
|
||||
|
||||
global $db, $langs;
|
||||
|
||||
require '../../main.inc.php'; // Load $user and permissions
|
||||
|
||||
$warehouse_id = GETPOST('warehouse_id', 'int');
|
||||
$batch_id = GETPOST('batch_id', 'int');
|
||||
$fk_product = GETPOST('product_id', 'int');
|
||||
$action = GETPOST('action', 'alphanohtml');
|
||||
|
||||
if($action == 'updateselectbatchbywarehouse') {
|
||||
|
||||
$TRes = array();
|
||||
|
||||
$sql = "SELECT pb.batch, pb.rowid, ps.fk_entrepot, pb.qty, e.ref as label, ps.fk_product";
|
||||
$sql .= " FROM " . MAIN_DB_PREFIX . "product_batch as pb";
|
||||
$sql .= " LEFT JOIN " . MAIN_DB_PREFIX . "product_stock as ps on ps.rowid = pb.fk_product_stock";
|
||||
$sql .= " LEFT 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 ($warehouse_id > 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);
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
@ -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 '<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->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 '</td>';
|
||||
}
|
||||
@ -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();
|
||||
}
|
||||
});
|
||||
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
@ -659,7 +659,7 @@ class FormProduct
|
||||
if (empty($fk_entrepot) || $fk_entrepot == $arraytypes['entrepot_id']) {
|
||||
$label = $arraytypes['entrepot_label'].' - ';
|
||||
$label .= $arraytypes['batch'];
|
||||
$out .= '<option>'.$arraytypes['batch'].'</option>';
|
||||
$out .= '<option value="'.$arraytypes['batch'].'">('.$langs->trans('Stock Total').': '.$arraytypes['qty'].')</option>';
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Loading…
Reference in New Issue
Block a user