Merge branch 'main' into feature-pdf-generate

This commit is contained in:
mikael-zakaria 2026-03-05 09:16:50 +07:00
commit b6666d405f
3 changed files with 85 additions and 29 deletions

View File

@ -849,34 +849,90 @@ function acttext_add() {
}) })
} }
$('#actby').change(function() { // $('#actby').change(function() {
var actby=this.value; // var actby=this.value;
if(actby == 'P') { // if(actby == 'P') {
var siteid=$('#siteid').val(); // var siteid=$('#siteid').val();
$.get("<?=base_url();?>/activities/getproduct/"+siteid, function(data) { // $.get("<?=base_url();?>/activities/getproduct/"+siteid, function(data) {
$('#actby_item').html(data); // $('#actby_item').html(data);
$('.select2').select2({ // $('.select2').select2({
theme: 'bootstrap-5', // theme: 'bootstrap-5',
width: '100%' // width: '100%'
}); // });
}) // })
} else if (actby == 'V') { // } else if (actby == 'V') {
$.get("<?=base_url();?>/activities/getvendor/0", function(data) { // $.get("<?=base_url();?>/activities/getvendor/0", function(data) {
$('#actby_item').html(data); // $('#actby_item').html(data);
}) // })
} else if (actby == 'C') { // } else if (actby == 'C') {
$.get("<?=base_url();?>/activities/getconsumable/0", function(data) { // $.get("<?=base_url();?>/activities/getconsumable/0", function(data) {
$('#actby_item').html(data); // $('#actby_item').html(data);
$('.select2').select2({ // $('.select2').select2({
theme: 'bootstrap-5', // theme: 'bootstrap-5',
width: '100%' // width: '100%'
}); // });
}) // })
}else { // }else {
$('#actby_item').html(''); // $('#actby_item').html('');
} // }
}) // })
// 1. Event ketika 'Activity by' diubah (Kode asli Anda dengan sedikit penyesuaian)
$('#actby').change(function() {
var actby = this.value;
if (actby == 'P') {
var siteid = $('#siteid').val();
// Cek apakah siteid sudah dipilih agar URL tidak menjadi /getproduct/ kosong
if (siteid) {
$.get("<?=base_url();?>/activities/getproduct/" + siteid, function(data) {
$('#actby_item').html(data);
$('.select2').select2({
theme: 'bootstrap-5',
width: '100%'
});
});
}
} else if (actby == 'V') {
$.get("<?=base_url();?>/activities/getvendor/0", function(data) {
$('#actby_item').html(data);
});
} else if (actby == 'C') {
$.get("<?=base_url();?>/activities/getconsumable/0", function(data) {
$('#actby_item').html(data);
$('.select2').select2({
theme: 'bootstrap-5',
width: '100%'
});
});
} else {
$('#actby_item').html('');
}
});
// 2. --- MODIFIKASI TAMBAHAN ---
// Event ketika 'Site' diubah
$('#siteid').change(function() {
var actby = $('#actby').val(); // Cek status Activity by saat ini
var siteid = this.value; // Ambil nilai siteid yang baru dipilih
// Hanya jalankan AJAX ulang JIKA Activity by sedang memilih 'P'
if (actby == 'P') {
if (siteid) { // Pastikan siteid tidak kosong ("-- Choose one --")
$.get("<?=base_url();?>/activities/getproduct/" + siteid, function(data) {
$('#actby_item').html(data);
$('.select2').select2({
theme: 'bootstrap-5',
width: '100%'
});
});
} else {
// Kosongkan item jika pengguna mengembalikan pilihan site ke "-- Choose one --"
$('#actby_item').html('');
}
}
});
if ($('#status').val() == 'R') { if ($('#status').val() == 'R') {
$("#opendate").prop('disabled', false); $("#actid_ref").prop('disabled', true); $(".closedate").prop('disabled', false); $("#opendate").prop('disabled', false); $("#actid_ref").prop('disabled', true); $(".closedate").prop('disabled', false);

View File

@ -1,7 +1,7 @@
<div class='row' id='get_product'> <div class='row' id='get_product'>
<div class='form-group col-12 col-lg-6'> <div class='form-group col-12 col-lg-6'>
<label class='form-label border-start border-5 border-primary ps-1'>Product ( Equipment / System )</label> <label class='form-label border-start border-5 border-primary ps-1'>Product ( Equipment / System )</label>
<select name='productid' class='form-select form-select-sm select2' id='productid'> <select name='productid' class='form-select form-select-sm select2' id='productid' required>
<option value=''>-- Choose one --</option> <option value=''>-- Choose one --</option>
<?php <?php
foreach ($products as $data) { foreach ($products as $data) {

View File

@ -1,7 +1,7 @@
<div class='row'> <div class='row'>
<div class='form-group col-12 col-lg-6'> <div class='form-group col-12 col-lg-6'>
<label class='form-label border-start border-5 border-primary ps-1'>Vendor</label> <label class='form-label border-start border-5 border-primary ps-1'>Vendor</label>
<select name='vendorid' class='form-select form-select-sm'> <select name='vendorid' class='form-select form-select-sm' required>
<option value=''>-- Choose one --</option> <option value=''>-- Choose one --</option>
<?php <?php
foreach ($vendors as $data) { foreach ($vendors as $data) {