warehouse layers [switchable]
This commit is contained in:
+102
-48
@@ -61,24 +61,24 @@
|
||||
</div>
|
||||
|
||||
<!-- Step 5: Zone -->
|
||||
<div class="mb-3 col-lg-6">
|
||||
<label for="zone" class="form-label">Zone</label>
|
||||
<select name="zone" id="zone" class="form-select" required disabled>
|
||||
<div class="mb-3 col-lg-6" id="group_zone">
|
||||
<label for="zone" class="form-label" id="label_zone">Zone</label>
|
||||
<select name="zone" id="zone" class="form-select" disabled>
|
||||
<option value="">Please select zone</option>
|
||||
</select>
|
||||
</div>
|
||||
|
||||
<!-- Step 6: Aisle -->
|
||||
<div class="mb-3 col-lg-6">
|
||||
<label for="aisle" class="form-label">Aisle</label>
|
||||
<select name="aisle" id="aisle" class="form-select" required disabled>
|
||||
<div class="mb-3 col-lg-6" id="group_aisle">
|
||||
<label for="aisle" class="form-label" id="label_aisle">Aisle</label>
|
||||
<select name="aisle" id="aisle" class="form-select" disabled>
|
||||
<option value="">Please select aisle</option>
|
||||
</select>
|
||||
</div>
|
||||
|
||||
<!-- Step 7: Rack -->
|
||||
<div class="mb-3 col-lg-6">
|
||||
<label for="rack" class="form-label">Rack</label>
|
||||
<div class="mb-3 col-lg-6" id="group_rack">
|
||||
<label for="rack" class="form-label" id="label_rack">Rack</label>
|
||||
<select name="rack" id="rack" class="form-select" required disabled>
|
||||
<option value="">Please select rack</option>
|
||||
</select>
|
||||
@@ -111,19 +111,63 @@
|
||||
<?php require "../include_ending.php";?>
|
||||
|
||||
<script>
|
||||
|
||||
var advanced = false;
|
||||
var label_rack = 'Location';
|
||||
var label_zone = 'Zone';
|
||||
var label_aisle = 'Aisle';
|
||||
|
||||
function load_location_config(callback) {
|
||||
return ajax_request({
|
||||
url: server_url + 'setting/api/engine/company_setting.php',
|
||||
autoPrepare: true,
|
||||
checkRequired: 0,
|
||||
action: 'read',
|
||||
onSuccess: function(res) {
|
||||
var s = res.output;
|
||||
advanced = s.advanced_location == 1;
|
||||
label_rack = s.location_label_rack || (advanced ? 'Rack' : 'Location');
|
||||
label_zone = s.location_label_zone || 'Zone';
|
||||
label_aisle = s.location_label_aisle || 'Aisle';
|
||||
if (callback) callback();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
function apply_location_labels() {
|
||||
if (advanced) {
|
||||
$('#group_zone').show();
|
||||
$('#group_aisle').show();
|
||||
$('#label_zone').text(label_zone);
|
||||
$('#label_aisle').text(label_aisle);
|
||||
$('#label_rack').text(label_rack);
|
||||
} else {
|
||||
$('#group_zone').hide();
|
||||
$('#group_aisle').hide();
|
||||
$('#label_rack').text(label_rack);
|
||||
}
|
||||
}
|
||||
|
||||
function manage_stock_out() {
|
||||
if (!advanced) {
|
||||
var rack_val = $('#rack').val();
|
||||
$('#zone').val(rack_val);
|
||||
$('#aisle').val(rack_val);
|
||||
}
|
||||
|
||||
return ajax_request({
|
||||
url: "<?php echo $server_url?>ics/api/engine/manage_stock_out.php",
|
||||
url: '<?php echo $server_url?>ics/api/engine/manage_stock_out.php',
|
||||
autoPrepare: true,
|
||||
checkRequired: 1,
|
||||
debugMode: 0,
|
||||
data: {
|
||||
"contact_id": $("#contact").attr('data-id')
|
||||
'contact_id': $('#contact').attr('data-id'),
|
||||
'zone': $('#zone').val(),
|
||||
'aisle': $('#aisle').val(),
|
||||
},
|
||||
action: 'manage',
|
||||
onSuccess: function(res) {
|
||||
window.location.href = "<?php echo $server_url?>ics/stock_out.php";
|
||||
onSuccess: function() {
|
||||
window.location.href = '<?php echo $server_url?>ics/stock_out.php';
|
||||
}
|
||||
});
|
||||
}
|
||||
@@ -227,7 +271,7 @@
|
||||
},
|
||||
action: 'read',
|
||||
onSuccess: function(res) {
|
||||
var option = '<option value="">Please select zone</option>';
|
||||
var option = '<option value="">Please select ' + label_zone.toLowerCase() + '</option>';
|
||||
$.each(res.output, function(key, item) {
|
||||
option += `<option value='${item.zone}'>${item.zone}</option>`;
|
||||
});
|
||||
@@ -252,7 +296,7 @@
|
||||
},
|
||||
action: 'read',
|
||||
onSuccess: function(res) {
|
||||
var option = '<option value="">Please select aisle</option>';
|
||||
var option = '<option value="">Please select ' + label_aisle.toLowerCase() + '</option>';
|
||||
$.each(res.output, function(key, item) {
|
||||
option += `<option value='${item}'>${item}</option>`;
|
||||
});
|
||||
@@ -277,7 +321,7 @@
|
||||
},
|
||||
action: 'read',
|
||||
onSuccess: function(res) {
|
||||
var option = '<option value="">Please select rack</option>';
|
||||
var option = '<option value="">Please select ' + label_rack.toLowerCase() + '</option>';
|
||||
$.each(res.output, function(key, item) {
|
||||
option += `<option value='${item}'>${item}</option>`;
|
||||
});
|
||||
@@ -291,9 +335,9 @@
|
||||
// ── Reset location dropdowns ──────────────────────────────────────────
|
||||
function reset_location() {
|
||||
$('#warehouse').html('<option value="">Select warehouse...</option>').prop('disabled', true);
|
||||
$('#zone').html('<option value="">Please select zone</option>').prop('disabled', true);
|
||||
$('#aisle').html('<option value="">Please select aisle</option>').prop('disabled', true);
|
||||
$('#rack').html('<option value="">Please select rack</option>').prop('disabled', true);
|
||||
$('#zone').html('<option value="">Please select ' + label_zone.toLowerCase() + '</option>').prop('disabled', true);
|
||||
$('#aisle').html('<option value="">Please select ' + label_aisle.toLowerCase() + '</option>').prop('disabled', true);
|
||||
$('#rack').html('<option value="">Please select ' + label_rack.toLowerCase() + '</option>').prop('disabled', true);
|
||||
}
|
||||
|
||||
|
||||
@@ -322,34 +366,39 @@
|
||||
|
||||
$('#warehouse').val('<?php echo $_GET["wh"];?>').prop('disabled', true);
|
||||
|
||||
retrieve_zone(function() {
|
||||
$('#zone').val(data.zone).prop('disabled', true);
|
||||
function populate_fields() {
|
||||
$.each(data, function(key, item) {
|
||||
if (!['warehouse', 'zone', 'aisle', 'rack', 'lot_number', 'serial_number'].includes(key)) {
|
||||
$('#' + key).val(item);
|
||||
}
|
||||
});
|
||||
$('#contact').val(data.contact_name)
|
||||
.attr('secondary', data.contact_name)
|
||||
.attr('data-id', data.contact_id);
|
||||
$('#product_name').val(data.product_name);
|
||||
$('#product_sku').attr('secondary', data.product_sku).prop('disabled', true);
|
||||
$('button[type=submit]').text('Update');
|
||||
$('button[type=reset]').hide();
|
||||
}
|
||||
|
||||
retrieve_aisle(function() {
|
||||
$('#aisle').val(data.aisle).prop('disabled', true);
|
||||
|
||||
retrieve_rack(function() {
|
||||
$('#rack').val(data.rack).prop('disabled', true);
|
||||
|
||||
$.each(data, function(key, item) {
|
||||
if (!['warehouse', 'zone', 'aisle', 'rack', 'lot_number', 'serial_number'].includes(key)) {
|
||||
$(`#${key}`).val(item);
|
||||
}
|
||||
if (advanced) {
|
||||
retrieve_zone(function() {
|
||||
$('#zone').val(data.zone).prop('disabled', true);
|
||||
retrieve_aisle(function() {
|
||||
$('#aisle').val(data.aisle).prop('disabled', true);
|
||||
retrieve_rack(function() {
|
||||
$('#rack').val(data.rack).prop('disabled', true);
|
||||
populate_fields();
|
||||
});
|
||||
|
||||
$('#contact').val(data.contact_name)
|
||||
.attr('secondary', data.contact_name)
|
||||
.attr('data-id', data.contact_id);
|
||||
|
||||
$('#product_name').val(data.product_name);
|
||||
$('#product_sku').attr('secondary', data.product_sku);
|
||||
$('#product_sku').prop('disabled', true);
|
||||
|
||||
$('button[type=submit]').text('Update');
|
||||
$('button[type=reset]').hide();
|
||||
});
|
||||
});
|
||||
});
|
||||
} else {
|
||||
// Simple mode — skip zone/aisle cascade
|
||||
retrieve_rack(function() {
|
||||
$('#rack').val(data.rack).prop('disabled', true);
|
||||
populate_fields();
|
||||
});
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
@@ -358,6 +407,7 @@
|
||||
// ── Boot ─────────────────────────────────────────────────────────────
|
||||
$(async function() {
|
||||
try {
|
||||
await load_location_config(apply_location_labels);
|
||||
await retrieve_warehouse();
|
||||
await retrieve_for_edit();
|
||||
} catch(e) {
|
||||
@@ -388,19 +438,23 @@
|
||||
retrieve_warehouse();
|
||||
});
|
||||
|
||||
// Warehouse selected → load zone
|
||||
// Warehouse selected → load zone (advanced) or rack directly (simple)
|
||||
$('#warehouse').on('change', function() {
|
||||
retrieve_zone();
|
||||
if (advanced) {
|
||||
retrieve_zone();
|
||||
} else {
|
||||
retrieve_rack();
|
||||
}
|
||||
});
|
||||
|
||||
// Zone selected → load aisle
|
||||
// Zone selected → load aisle (advanced only)
|
||||
$('#zone').on('change', function() {
|
||||
retrieve_aisle();
|
||||
if (advanced) retrieve_aisle();
|
||||
});
|
||||
|
||||
// Aisle selected → load rack
|
||||
// Aisle selected → load rack (advanced only)
|
||||
$('#aisle').on('change', function() {
|
||||
retrieve_rack();
|
||||
if (advanced) retrieve_rack();
|
||||
});
|
||||
|
||||
<?php } ?>
|
||||
|
||||
Reference in New Issue
Block a user