a pinch of jquery to display only what we need when we need it
This commit is contained in:
parent
000342c2d8
commit
0965f28bf7
@ -307,8 +307,10 @@ if (empty($reshook)) {
|
||||
$object->status = GETPOST('statut');
|
||||
$object->status_buy = GETPOST('statut_buy');
|
||||
$object->status_batch = GETPOST('status_batch');
|
||||
$object->batch_mask = GETPOST('batch_mask', 'alpha');
|
||||
|
||||
if ($object->status_batch !== 0) {
|
||||
$object->batch_mask = GETPOST('batch_mask');
|
||||
}
|
||||
else $object->batch_mask = '';
|
||||
|
||||
$object->barcode_type = GETPOST('fk_barcode_type');
|
||||
$object->barcode = GETPOST('barcode');
|
||||
@ -477,7 +479,10 @@ if (empty($reshook)) {
|
||||
$object->status = GETPOST('statut', 'int');
|
||||
$object->status_buy = GETPOST('statut_buy', 'int');
|
||||
$object->status_batch = GETPOST('status_batch', 'aZ09');
|
||||
$object->batch_mask = GETPOST('batch_mask', 'alpha');
|
||||
if ($object->status_batch !== 0) {
|
||||
$object->batch_mask = GETPOST('batch_mask', 'alpha');
|
||||
}
|
||||
else $object->batch_mask = '';
|
||||
$object->fk_default_warehouse = GETPOST('fk_default_warehouse');
|
||||
// removed from update view so GETPOST always empty
|
||||
/*
|
||||
@ -1092,20 +1097,40 @@ if (is_object($objcanvas) && $objcanvas->displayCanvasExists($action)) {
|
||||
print '</td>';
|
||||
// Product specific batch number management
|
||||
$status_batch = GETPOST('status_batch');
|
||||
if ($status_batch !== '0'
|
||||
&& (($status_batch == '1' && $conf->global->PRODUCTBATCH_LOT_USE_PRODUCT_MASKS && $conf->global->PRODUCTBATCH_LOT_ADDON == 'mod_lot_advanced')
|
||||
|| ($status_batch == '2' && $conf->global->PRODUCTBATCH_SN_ADDON == 'mod_sn_advanced' && $conf->global->PRODUCTBATCH_SN_USE_PRODUCT_MASKS))) {
|
||||
$inherited_mask = $object->status_batch == '1' ? $conf->global->LOT_ADVANCED_MASK : $conf->global->SN_ADVANCED_MASK;
|
||||
print '<td>'.$langs->trans("ManageLotMask").'</td>';
|
||||
if ($status_batch !== '0') {
|
||||
$tooltip = $langs->trans("GenericMaskCodes", $langs->transnoentities("Batch"), $langs->transnoentities("Batch"));
|
||||
$tooltip .= $langs->trans("GenericMaskCodes2");
|
||||
$tooltip .= $langs->trans("GenericMaskCodes3");
|
||||
$tooltip .= $langs->trans("GenericMaskCodes4a", $langs->transnoentities("Batch"), $langs->transnoentities("Batch"));
|
||||
$tooltip .= $langs->trans("GenericMaskCodes5");
|
||||
print '<td>';
|
||||
print $form->textwithpicto('<input type="text" class="flat" size="24" name="batch_mask" id="batch_mask" value="'.$inherited_mask.'">', $tooltip, 1, 1);
|
||||
print '</td>';
|
||||
print '<td id="mask_option">'.$langs->trans("ManageLotMask").'</td>';
|
||||
if (($conf->global->PRODUCTBATCH_LOT_USE_PRODUCT_MASKS && $conf->global->PRODUCTBATCH_LOT_ADDON == 'mod_lot_advanced') || ($conf->global->PRODUCTBATCH_SN_USE_PRODUCT_MASKS && $conf->global->PRODUCTBATCH_SN_ADDON == 'mod_sn_advanced')) {
|
||||
$inherited_mask_lot = $conf->global->LOT_ADVANCED_MASK;
|
||||
$inherited_mask_sn = $conf->global->SN_ADVANCED_MASK;
|
||||
print '<td id="field_mask">';
|
||||
print $form->textwithpicto('<input type="text" class="flat" size="24" name="batch_mask" id="batch_mask_input">', $tooltip, 1, 1);
|
||||
print '</td>';
|
||||
}
|
||||
print '<script type="text/javascript">
|
||||
$(document).ready(function() {
|
||||
$("#field_mask, #mask_option").addClass("hideobject");
|
||||
$("#status_batch").on("change", function () {
|
||||
var optionSelected = $("option:selected", this);
|
||||
var valueSelected = this.value;
|
||||
$("#field_mask, #mask_option").addClass("hideobject");
|
||||
if (this.value == 1) {
|
||||
$("#field_mask, #mask_option").toggleClass("hideobject");
|
||||
$("#batch_mask_input").val("'.$inherited_mask_lot.'");
|
||||
}
|
||||
if (this.value == 2) {
|
||||
$("#field_mask, #mask_option").toggleClass("hideobject");
|
||||
$("#batch_mask_input").val("'.$inherited_mask_sn.'");
|
||||
}
|
||||
})
|
||||
})
|
||||
</script>';
|
||||
}
|
||||
|
||||
print '</tr>';
|
||||
|
||||
}
|
||||
@ -1570,20 +1595,47 @@ if (is_object($objcanvas) && $objcanvas->displayCanvasExists($action)) {
|
||||
$statutarray = array('0' => $langs->trans("ProductStatusNotOnBatch"), '1' => $langs->trans("ProductStatusOnBatch"), '2' => $langs->trans("ProductStatusOnSerial"));
|
||||
print $form->selectarray('status_batch', $statutarray, $object->status_batch);
|
||||
print '</td>';
|
||||
if ($object->status_batch !== '0'
|
||||
&& (($object->status_batch == '1' && $conf->global->PRODUCTBATCH_LOT_USE_PRODUCT_MASKS && $conf->global->PRODUCTBATCH_LOT_ADDON == 'mod_lot_advanced')
|
||||
|| ($object->status_batch == '2' && $conf->global->PRODUCTBATCH_SN_ADDON == 'mod_sn_advanced' && $conf->global->PRODUCTBATCH_SN_USE_PRODUCT_MASKS))) {
|
||||
$inherited_mask = $object->status_batch == '1' ? $conf->global->LOT_ADVANCED_MASK : $conf->global->SN_ADVANCED_MASK;
|
||||
print '<td>'.$langs->trans("ManageLotMask").'</td>';
|
||||
$mask = !is_empty($object->batch_mask) ? $object->batch_mask : $inherited_mask;
|
||||
if ($object->status_batch !== '0') {
|
||||
$tooltip = $langs->trans("GenericMaskCodes", $langs->transnoentities("Batch"), $langs->transnoentities("Batch"));
|
||||
$tooltip .= $langs->trans("GenericMaskCodes2");
|
||||
$tooltip .= $langs->trans("GenericMaskCodes3");
|
||||
$tooltip .= $langs->trans("GenericMaskCodes4a", $langs->transnoentities("Batch"), $langs->transnoentities("Batch"));
|
||||
$tooltip .= $langs->trans("GenericMaskCodes5");
|
||||
print '<td>';
|
||||
print $form->textwithpicto('<input type="text" class="flat" size="24" name="batch_mask" id="batch_mask" value="'.$mask.'">', $tooltip, 1, 1);
|
||||
print '<td id="mask_option">'.$langs->trans("ManageLotMask").'</td>';
|
||||
if ($object->status_batch == '1' && $conf->global->PRODUCTBATCH_LOT_USE_PRODUCT_MASKS && $conf->global->PRODUCTBATCH_LOT_ADDON == 'mod_lot_advanced') {
|
||||
$mask = !is_empty($object->batch_mask) ? $object->batch_mask : $conf->global->LOT_ADVANCED_MASK;
|
||||
}
|
||||
if ($object->status_batch == '2' && $conf->global->PRODUCTBATCH_SN_USE_PRODUCT_MASKS && $conf->global->PRODUCTBATCH_SN_ADDON == 'mod_sn_advanced') {
|
||||
$mask = !is_empty($object->batch_mask) ? $object->batch_mask : $conf->global->SN_ADVANCED_MASK;
|
||||
}
|
||||
$inherited_mask_lot = $conf->global->LOT_ADVANCED_MASK;
|
||||
$inherited_mask_sn = $conf->global->SN_ADVANCED_MASK;
|
||||
print '<td id="field_mask">';
|
||||
print $form->textwithpicto('<input type="text" class="flat" size="24" name="batch_mask" id="batch_mask_input" value="'.$mask.'">', $tooltip, 1, 1);
|
||||
print '</td>';
|
||||
|
||||
print '<script type="text/javascript">
|
||||
$(document).ready(function() {
|
||||
$("#field_mask, #mask_option").addClass("hideobject");
|
||||
var preselect = $("#status_batch option:selected");
|
||||
if (preselect !== "0") {
|
||||
$("#field_mask, #mask_option").toggleClass("hideobject");
|
||||
}
|
||||
$("#status_batch").on("change", function () {
|
||||
var optionSelected = $("option:selected", this);
|
||||
var valueSelected = this.value;
|
||||
$("#field_mask, #mask_option").addClass("hideobject");
|
||||
if (this.value == 1) {
|
||||
$("#field_mask, #mask_option").toggleClass("hideobject");
|
||||
$("#batch_mask_input").val("'.$inherited_mask_lot.'");
|
||||
}
|
||||
if (this.value == 2) {
|
||||
$("#field_mask, #mask_option").toggleClass("hideobject");
|
||||
$("#batch_mask_input").val("'.$inherited_mask_sn.'");
|
||||
}
|
||||
})
|
||||
})
|
||||
</script>';
|
||||
}
|
||||
print '</tr>';
|
||||
}
|
||||
|
||||
Loading…
Reference in New Issue
Block a user