chess/resources/views/content/projects/action_meeting.blade.php

556 lines
23 KiB
PHP
Raw Permalink Normal View History

2024-08-29 03:56:32 +00:00
<script>
var routeTable,
colum,
columnStyle,
table,
_validations = [],
_validations2 = [],
validation_ba,
arrayPersonil = [];
// Class definition
var KTMeetings = function () {
// Base elements
var _wizardEl;
var _wizardEl2;
var _wizardEl3;
var _formEl;
var _formEl2;
var _wizard;
var _wizard2;
var _wizard3;
var _avatar;
// Private functions
var initWizard = function () {
// Initialize form wizard
_wizard = new KTWizard(_wizardEl, {
startStep: 1, // initial active step number
clickableSteps: true // allow step clicking
});
// Validation before going to next page
_wizard.on('beforeNext', function (wizard) {
// Don't go to the next step yet
_wizard.stop();
// reviewProject()
// _wizard.goNext();
// Validate form
if(_wizard.getStep()==1) {
var validator = _validations[0]; // get validator for currnt step
validator.validate().then(function (status) {
if (status == 'Valid') {
_wizard.goNext();
KTUtil.scrollTop();
} else {
znNotif('warning', 'Lengkapi Data')
KTUtil.scrollTop();
}
});
}
/* if(_wizard.getStep()==2) {
_wizard.stop();
var row_anggota = $('#row_anggota').val()
if(row_anggota==0 || row_anggota==null) {
znNotif('warning', 'Pilih anggota tim minimal 1 anggota')
KTUtil.scrollTop();
} else {
_wizard.goNext();
KTUtil.scrollTop();
}
} */
});
/* _wizard.on('beforeFinish', function(wizard) {
}) */
// Change Event
_wizard.on('change', function (wizard) {
KTUtil.scrollTop();
});
}
var initWizard2 = function() {
_wizard2 = new KTWizard(_wizardEl2, {
startStep: 1, // initial active step number
clickableSteps: true // allow step clicking
});
_wizard2.on('change', function (wizard) {
KTUtil.scrollTop();
});
}
var initWizard3 = function() {
_wizard3 = new KTWizard(_wizardEl3, {
startStep: 1, // initial active step number
clickableSteps: true // allow step clicking
});
// Validation before going to next page
_wizard3.on('beforeNext', function (wizard) {
// Don't go to the next step yet
_wizard3.stop();
// reviewProject()
// _wizard3.goNext();
// Validate form
if(_wizard3.getStep()==1) {
var validator = _validations2[0]; // get validator for currnt step
validator.validate().then(function (status) {
if (status == 'Valid') {
_wizard3.goNext();
KTUtil.scrollTop();
} else {
znNotif('warning', 'Lengkapi Data')
KTUtil.scrollTop();
}
});
}
/* if(_wizard3.getStep()==2) {
_wizard3.stop();
var row_anggota = $('#row_anggota').val()
if(row_anggota==0 || row_anggota==null) {
znNotif('warning', 'Pilih anggota tim minimal 1 anggota')
KTUtil.scrollTop();
} else {
_wizard3.goNext();
KTUtil.scrollTop();
}
} */
});
_wizard3.on('change', function (wizard) {
KTUtil.scrollTop();
});
}
// Form Validation
var initValidation = function () {
// Init form validation rules. For more info check the FormValidation plugin's official documentation:https://formvalidation.io/
// Step 1
_validations.push(FormValidation.formValidation(
_formEl,
{
fields: {
title: {
validators: {
notEmpty: {
message: 'Wajib diisi!'
}
}
},
start_date: {
validators: {
notEmpty: {
message: 'Wajib dipilih!'
}
}
},
start_time: {
validators: {
notEmpty: {
message: 'Wajib diisi!'
},
}
},
end_time: {
validators: {
notEmpty: {
message: 'Wajib diisi!'
},
}
},
inv_content: {
validators: {
callback: {
message: 'Wajib diisi!',
callback: function(input) {
const code = $('[name="inv_content"]').summernote('code');
// <p><br></p> is code generated by Summernote for empty content
return (code !== '' && code !== '<p><br></p>');
}
}
}
},
},
plugins: {
trigger: new FormValidation.plugins.Trigger(),
bootstrap: new FormValidation.plugins.Bootstrap()
}
}
));
}
var initValidation2 = function () {
// Init form validation rules. For more info check the FormValidation plugin's official documentation:https://formvalidation.io/
// Step 1
_validations2.push(FormValidation.formValidation(
_formEl2,
{
fields: {
mom_content: {
validators: {
callback: {
message: 'Wajib diisi!',
callback: function(input) {
const code = $('[name="mom_content"]').summernote('code');
// <p><br></p> is code generated by Summernote for empty content
return (code !== '' && code !== '<p><br></p>');
}
}
}
},
},
plugins: {
trigger: new FormValidation.plugins.Trigger(),
bootstrap: new FormValidation.plugins.Bootstrap()
}
}
));
}
/* var initAvatar = function () {
_avatar = new KTImageInput('kt_projects_add_avatar');
} */
return {
// public functions
init: function () {
_wizardEl = KTUtil.getById('kt_meetings_add');
_wizardEl2 = KTUtil.getById('kt_meetings_det');
_wizardEl3 = KTUtil.getById('kt_meetings_edit');
_formEl = KTUtil.getById('kt_meetings_add_form');
_formEl2 = KTUtil.getById('kt_meetings_edit_form');
initWizard();
initWizard2();
initWizard3();
initValidation();
initValidation2();
// initAvatar();
}
};
}();
$(document).ready(function() {
KTMeetings.init();
routeTable = '{{ $table }}';
colum = [
{data: 'id', name: 'id'},
{data: 'tittle', name: 'tittle'},
{data: 'start_date', name: 'start_date'},
{data: 'start_time', name: 'start_time'},
{data: 'end_time', name: 'end_time'},
{data: 'is_done', name: 'is_done'},
{data: 'action', name: 'action'},
];
columStyle =
[
{ "orderable": false, "targets": [-1] },
];
table = znGetTableScrolling(routeTable,colum,columStyle,'indexTable');
$('.znTime').timepicker({
minuteStep: 15,
defaultTime: '',
showSeconds: false,
showMeridian: false,
snapToStep: true
});
$('.summernote').summernote({
height: 150
}).on('summernote.change', function(customEvent, contents, $editable) {
// Revalidate the content when its value is changed by Summernote
_validations[0].revalidateField('inv_content');
_validations2[0].revalidateField('mom_content');
});
reInitForm()
})
function storeMeeting() {
_validations[0].validate().then(function (status) {
if (status == 'Valid') {
if($('#row_anggota').val()==0 || $('#row_anggota').val()==null) {
znNotif('warning', 'Lengkapi data anggota tim')
} else {
let myForm = document.getElementById('kt_meetings_add_form');
let formData = new FormData(myForm);
const code = $('[name="inv_content"]').summernote('code');
formData.append('inv_content', code);
popConfirm("Konfirmasi Data Meeting",
`<div class="mt-2">Yakin Akan Menyimpan Data Meeting Ini ?</div>`,
function() {
// znLoadingPage();
znLoadingModal('mFormMeeting')
doPost(base_url+'projects/act_any/store_data_meeting', formData, function (msg, data) {
// znLoadingPageEnd();
znLoadingModalEnd('mFormMeeting')
if (data == null){
// znLoadingPageEnd()
znNotif("danger", msg);
}else {
if(data.rc == 0){
znNotif('success','Berhasil Menyimpan Data');
// window.location.href = base_url + 'projects';
table.ajax.url(routeTable).load();
$('#mFormMeeting').modal('hide')
}else{
znLoadingPageEnd()
znNotif("danger", data.rm);
}
}
})
});
}
} else {
znNotif('warning', 'Lengkapi Data')
}
});
}
function storeUpdateMeeting() {
_validations2[0].validate().then(function (status) {
if (status == 'Valid') {
let myForm = document.getElementById('kt_meetings_edit_form');
let formData = new FormData(myForm);
const code = $('[name="mom_content"]').summernote('code');
formData.append('mom_content', code);
popConfirm("Konfirmasi Data Meeting",
`<div class="mt-2">Yakin Akan Mengupdate Data Meeting Ini ?</div>`,
function() {
// znLoadingPage();
znLoadingModal('mFormUpdateMeeting')
doPost(base_url+'projects/act_any/store_data_meeting', formData, function (msg, data) {
// znLoadingPageEnd();
znLoadingModalEnd('mFormUpdateMeeting')
if (data == null){
// znLoadingPageEnd()
znNotif("danger", msg);
}else {
if(data.rc == 0){
znNotif('success','Berhasil Mengupdate Data');
// window.location.href = base_url + 'projects';
table.ajax.url(routeTable).load();
$('#mFormUpdateMeeting').modal('hide')
}else{
znLoadingPageEnd()
znNotif("danger", data.rm);
}
}
})
});
} else {
znNotif('warning', 'Lengkapi Data')
}
});
}
function clearModalForm() {
$('#kt_meetings_add_form')[0].reset();
$('#anggota_tim_tbody').html(``)
reInitForm()
}
function tambahAllPersonil(idProject) {
var formData = new FormData();
formData.append('id', idProject)
znLoadingModal('mFormMeeting');
return doPost(base_url+'projects/get_any/get_member_project', formData, function (msg, data) {
znLoadingModalEnd('mFormMeeting');
$.each(data.data, function(k,v) {
arrayPersonil.push({
'key': k,
'personil_id': v.member_id,
'personil_name': v.full_name,
// 'team_role_id': team_role_id,
// 'team_role_name': team_role_name
})
cetakAnggota(arrayPersonil)
})
})
}
function tambahPersonil(idProject) {
$('#row_exist').val('');
$('#form_personil')[0].reset();
znLoadingModal('mFormMeeting');
$.when(getMember(idProject)).done(function() {
znLoadingModalEnd('mFormMeeting');
znModal('mForm');
})
}
function hapusPersonil(key) {
arrayPersonil.splice(key,1)
cetakAnggota(arrayPersonil)
}
function pickPersonil() {
var row_anggota = $('#row_anggota').val();
var row_new = $('#row_exist').val()!=''?$('#row_exist').val()-1:parseInt(row_anggota)+1;
var row_tbody = '',
personil_id = $('#pilih_personil').val(),
personil_name = $('#pilih_personil').find(':selected').text();
// team_role_id = $('#pilih_team_role').val(),
// team_role_name = $('#pilih_team_role').find(':selected').data('definition');
if(arrayPersonil[row_new]) {
arrayPersonil[row_new].key = $('#row_exist').val();
arrayPersonil[row_new].personal_id = personil_id;
arrayPersonil[row_new].personil_name = personil_name;
// arrayPersonil[row_new].team_role_id = team_role_id;
// arrayPersonil[row_new].team_role_name = team_role_name;
} else {
arrayPersonil.push({
'key': row_new+1,
'personil_id': personil_id,
'personil_name': personil_name,
// 'team_role_id': team_role_id,
// 'team_role_name': team_role_name
})
}
if(personil_id=='') {
znNotif('warning', 'Wajib Pilih Personil')
} else {
cetakAnggota(arrayPersonil);
znModalHide('mForm')
}
}
function cetakAnggota(arrayPersonil) {
var row_tbody = '';
$.each(arrayPersonil, function(k,v) {
row_tbody+= '<tr id="row_'+(k+1)+'">';
row_tbody+= '<td>'+(k+1)+'</td>';
row_tbody+= '<td><input type="hidden" name="personil_id_'+(k+1)+'" id="personil_id_'+(k+1)+'" value="'+v.personil_id+'">'+v.personil_name+'</td>';
row_tbody+= '<td>\
<a href="#" class="btn btn-sm btn-icon btn-danger" onclick="hapusPersonil('+k+')" class="navi-link">\
<span class="navi-icon"><i class="la la-trash"></i></span>\
</a>\
</td>';
row_tbody+= '</tr>';
});
$('#row_anggota').val(arrayPersonil.length)
$('#anggota_tim_tbody').html('')
$('#anggota_tim_tbody').append(row_tbody)
}
function getMember(id_project, set_id = 'pilih_personil', id = null) {
var formData = new FormData();
formData.append('id', id_project)
return doPost(base_url+'projects/get_any/get_member_project', formData, function (msg, data) {
$('#'+set_id).html(``)
$('#'+set_id).append('<option value="">Pilih Member</option>')
$.each(data.data, function(k,v) {
var selected = v.member_id==id?'selected':'';
$('#'+set_id).append('<option value="'+v.member_id+'" '+selected+'>'+v.full_name+' ('+v.definition+')</option>')
})
})
}
function detailMeeting(id) {
znLoadingPage();
let formData = new FormData();
formData.append('id',id);
doPost(base_url+'projects/get_any/detail_meeting', formData, function (msg, res) {
znLoadingPageEnd()
var data = res.data;
console.log(data)
$('#meeting_id_det').html(data.meeting.id)
$('#title_det').html(data.meeting.tittle)
$('#start_date_det').html(G_formatDate(data.meeting.start_date, 'd-M-Y'))
$('#start_time_det').html(data.meeting.start_time)
$('#end_time_det').html(data.meeting.end_time)
$('#is_done_det').html(data.meeting.is_done?'Selesai':'Belum Selesai')
$('#inv_content_det').html(data.meeting.inv_content)
$('#mom_content_det').html(data.meeting.mom_content?data.meeting.mom_content:'Belum Ada Risalah Meeting')
if(data.meeting.mom_doc_url) {
$('#mom_doc_url_det').removeClass('d-none')
$('#mom_doc_url_det').attr('href', data.meeting.mom_doc_url)
$('#mom_doc_url_det').attr('target', '_blank')
$('#textDocKosong').html('')
} else {
$('#mom_doc_url_det').addClass('d-none')
$('#mom_doc_url_det').removeAttr('target')
$('#textDocKosong').html('<h6 style="font-size: 12px;text-align: justify;line-height: 20px;">Tidak Ada Dokumen</h6>')
}
$('#anggota_tim_tbody_det').html('');
$('#anggota_tim_tbody2_det').html('');
var no = 1;
var no2 = 1;
$.each(data.meetingParticipant, function(k, v) {
if(v.is_present!=null) {
if(v.is_present) {
$('#anggota_tim_tbody_det').append(`
<tr>
<td>${no++}</td>
<td>${v.full_name}</td>
</tr>
`);
} else {
$('#anggota_tim_tbody2_det').append(`
<tr>
<td>${no2++}</td>
<td>${v.full_name}</td>
<td>${v.notes}</td>
</tr>
`);
}
}
})
$('#mFormDetMeeting').modal('show');
});
}
function editMeeting(id) {
znLoadingPage();
reInitForm()
let formData = new FormData();
formData.append('id',id);
doPost(base_url+'projects/get_any/detail_meeting', formData, function (msg, res) {
znLoadingPageEnd()
var data = res.data;
$('#get_id_meeting').val(id)
$("#mom_content").summernote("code", data.meeting.mom_content);
var is_done = data.meeting.is_done?'true':'false';
$('#is_done_edit').val(is_done).trigger('change.select2');
if(data.meeting.mom_doc_url) {
$('#mom_doc_url_attachment').removeClass('d-none')
$('#mom_doc_url_attachment').attr('href', data.meeting.mom_doc_url)
} else {
$('#mom_doc_url_attachment').addClass('d-none')
}
$('#row_anggota_update').val(data.meetingParticipant.length)
$('#anggota_tim_tbody_update').html('');
$.each(data.meetingParticipant, function(k, v) {
var no = 1;
var checkHadir = v.is_present==true?'checked':'';
var checkTidakHadir = v.is_present==false?'checked':'';
var notes = v.notes?v.notes:'';
$('#anggota_tim_tbody_update').append(`
<tr>
<td><input type="hidden" name="mp_id${k+1}" value="${v.id}"/>${k+1}</td>
<td>${v.full_name}</td>
<td align="center"><div class="radio-inline">
<label class="radio">
<input type="radio" name="hadir${k+1}" value="true" ${checkHadir}>
<span></span>Hadir</label>
<label class="radio">
<input type="radio" name="hadir${k+1}" value="false" ${checkTidakHadir}>
<span></span>Tidak Hadir</label>
</div></td>
<td><input autocomplete="off" type="text" value="${notes}" name="ket${k+1}" id="ket${k+1}" class="form-control form-control-solid " placeholder="Isikan Keterangan"/></td>
</tr>
`);
})
$('#mFormUpdateMeeting').modal('show')
});
}
</script>