Commit 73d77fe4 by nurchamim

modul : bug laporan absensi

status : selesai
keterangan : bug fix tambah absensi, fitur cari pada select saat pilih shift tidak bisa
parent dec0f073
...@@ -200,6 +200,9 @@ ...@@ -200,6 +200,9 @@
</div> </div>
</div> </div>
<script> <script>
var selected_shift = '<?= isset($data) ? $data->kode_absensi : '' ?>';
var dropdown_karyawan, picker_tanggal_absen, index_day = 0, var dropdown_karyawan, picker_tanggal_absen, index_day = 0,
id_kary = null, id_kary = null,
id_company = null, id_company = null,
...@@ -225,7 +228,7 @@ ...@@ -225,7 +228,7 @@
?> ?>
$('select#kode_absensi').val('<?php echo $kda ?>').trigger('change'); $('select#kode_absensi').val('<?php echo $kda ?>').trigger('change');
$('select#id_shift').select2(); // $('select#id_shift').select2();
$(document).ready(function() { $(document).ready(function() {
...@@ -397,41 +400,50 @@ ...@@ -397,41 +400,50 @@
} }
function getjamshift() { function getjamshift() {
var id_cabang = $("#form_input #id_cabang").val(); var id_cabang = $("#form_input #id_cabang").val();
var params = {};
params.id_cabang = id_cabang; $.get('<?php echo route('dropdown.jamshift') ?>', {id_cabang:id_cabang}, function(result) {
$.get('<?php echo route('dropdown.jamshift') ?>', params, function(result) {
var data = $.parseJSON(result); var data = $.parseJSON(result);
if (data.status) { if (data.status) {
var option = '';
<?php if ($('#id_shift').hasClass('select2-hidden-accessible')) {
$selected = ''; $('#id_shift').select2('destroy');
if($data != null) }
{
if($data->kode_absensi != null)
{
$kode = explode(',', $data->kode_absensi);
if(isset($kode[0]))
{
$selected = $kode[0];
}
}
}
?>
var selected = '<?php echo $selected ?>'; $('#id_shift')
.empty()
.append('<option value="">Pilih Shift</option>');
$.each(data.data, function(k, v) { $.each(data.data, function(k, v) {
var slt = (v.kode_shift == selected) ? 'selected' : ''; $('#id_shift').append(
option += '<option '+slt+' libur="'+v.libur+'" value="' + v.id_master_shift + '">' + v.kode_shift + ' - ' + v.nama_shift + '</option>'; '<option value="'+v.id_master_shift+'" libur="'+v.libur+'">'
+ v.kode_shift + ' - ' + v.nama_shift +
'</option>'
);
});
$('#id_shift').select2({
width: '100%',
placeholder: 'Pilih Shift',
allowClear: true,
dropdownParent: $('.cont-pilih-shift')
}); });
$('select#id_shift').html(option);
// setTimeout(function(){ if (typeof selected_shift !== 'undefined' && selected_shift !== '') {
$('select#id_shift').trigger('change');
// }, 300); $('#id_shift option').each(function () {
var kode = $(this).text().split(' - ')[0];
if (kode === selected_shift) {
$('#id_shift')
.val($(this).val())
.trigger('change.select2');
}
});
}
} }
}); });
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment