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 @@
</div>
</div>
<script>
var selected_shift = '<?= isset($data) ? $data->kode_absensi : '' ?>';
var dropdown_karyawan, picker_tanggal_absen, index_day = 0,
id_kary = null,
id_company = null,
......@@ -225,7 +228,7 @@
?>
$('select#kode_absensi').val('<?php echo $kda ?>').trigger('change');
$('select#id_shift').select2();
// $('select#id_shift').select2();
$(document).ready(function() {
......@@ -397,41 +400,50 @@
}
function getjamshift() {
var id_cabang = $("#form_input #id_cabang").val();
var params = {};
params.id_cabang = id_cabang;
$.get('<?php echo route('dropdown.jamshift') ?>', params, function(result) {
$.get('<?php echo route('dropdown.jamshift') ?>', {id_cabang:id_cabang}, function(result) {
var data = $.parseJSON(result);
if (data.status) {
var option = '';
<?php
$selected = '';
if($data != null)
{
if($data->kode_absensi != null)
{
$kode = explode(',', $data->kode_absensi);
if(isset($kode[0]))
{
$selected = $kode[0];
}
}
}
?>
if ($('#id_shift').hasClass('select2-hidden-accessible')) {
$('#id_shift').select2('destroy');
}
var selected = '<?php echo $selected ?>';
$('#id_shift')
.empty()
.append('<option value="">Pilih Shift</option>');
$.each(data.data, function(k, v) {
var slt = (v.kode_shift == selected) ? 'selected' : '';
option += '<option '+slt+' libur="'+v.libur+'" value="' + v.id_master_shift + '">' + v.kode_shift + ' - ' + v.nama_shift + '</option>';
$('#id_shift').append(
'<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(){
$('select#id_shift').trigger('change');
// }, 300);
if (typeof selected_shift !== 'undefined' && selected_shift !== '') {
$('#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