1252 lines
37 KiB
PHP
1252 lines
37 KiB
PHP
<script>
|
|
var arrayPersonil = [];
|
|
var _validations = [];
|
|
|
|
var tableHead = "{{$head ?? '' }}";
|
|
var routeTable = "{{$table ?? ''}}";
|
|
routeTable = routeTable.replace(/amp;/g,'');
|
|
|
|
var type = "{{ $type ?? '' }}";
|
|
var validation,
|
|
validation_task,
|
|
validation_task_generate,
|
|
validation_project;
|
|
var table,
|
|
tableRincian;
|
|
|
|
// Class definition
|
|
var KTProjectsAdd = function () {
|
|
// Base elements
|
|
var _wizardEl;
|
|
var _formEl;
|
|
var _wizard;
|
|
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();
|
|
});
|
|
}
|
|
|
|
// 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: {
|
|
nama_project: {
|
|
validators: {
|
|
notEmpty: {
|
|
message: 'Wajib diisi!'
|
|
}
|
|
}
|
|
},
|
|
/* kode_project: {
|
|
validators: {
|
|
notEmpty: {
|
|
message: 'Wajib diisi!'
|
|
}
|
|
}
|
|
}, */
|
|
project_owner: {
|
|
validators: {
|
|
notEmpty: {
|
|
message: 'Wajib dipilih!'
|
|
}
|
|
}
|
|
},
|
|
tgl_mulai: {
|
|
validators: {
|
|
notEmpty: {
|
|
message: 'Wajib diisi!'
|
|
},
|
|
}
|
|
},
|
|
tgl_selesai: {
|
|
validators: {
|
|
notEmpty: {
|
|
message: 'Wajib diisi!'
|
|
},
|
|
}
|
|
},
|
|
budget_amount: {
|
|
validators: {
|
|
notEmpty: {
|
|
message: 'Wajib diisi!'
|
|
},
|
|
}
|
|
},
|
|
info_detail_project: {
|
|
validators: {
|
|
notEmpty: {
|
|
message: 'Wajib diisi!'
|
|
},
|
|
}
|
|
},
|
|
/* logo_project: {
|
|
validators: {
|
|
notEmpty: {
|
|
message: 'Wajib diisi!'
|
|
},
|
|
}
|
|
} */
|
|
},
|
|
plugins: {
|
|
trigger: new FormValidation.plugins.Trigger(),
|
|
bootstrap: new FormValidation.plugins.Bootstrap()
|
|
}
|
|
}
|
|
));
|
|
|
|
// Step 2
|
|
/* _validations.push(FormValidation.formValidation(
|
|
_formEl,
|
|
{
|
|
fields: {
|
|
// Step 2
|
|
communication: {
|
|
validators: {
|
|
choice: {
|
|
min: 1,
|
|
message: 'Please select at least 1 option'
|
|
}
|
|
}
|
|
},
|
|
language: {
|
|
validators: {
|
|
notEmpty: {
|
|
message: 'Please select a language'
|
|
}
|
|
}
|
|
},
|
|
timezone: {
|
|
validators: {
|
|
notEmpty: {
|
|
message: 'Please select a timezone'
|
|
}
|
|
}
|
|
}
|
|
},
|
|
plugins: {
|
|
trigger: new FormValidation.plugins.Trigger(),
|
|
bootstrap: new FormValidation.plugins.Bootstrap()
|
|
}
|
|
}
|
|
)); */
|
|
|
|
// Step 3
|
|
/* _validations.push(FormValidation.formValidation(
|
|
_formEl,
|
|
{
|
|
fields: {
|
|
address1: {
|
|
validators: {
|
|
notEmpty: {
|
|
message: 'Address is required'
|
|
}
|
|
}
|
|
},
|
|
postcode: {
|
|
validators: {
|
|
notEmpty: {
|
|
message: 'Postcode is required'
|
|
}
|
|
}
|
|
},
|
|
city: {
|
|
validators: {
|
|
notEmpty: {
|
|
message: 'City is required'
|
|
}
|
|
}
|
|
},
|
|
state: {
|
|
validators: {
|
|
notEmpty: {
|
|
message: 'state is required'
|
|
}
|
|
}
|
|
},
|
|
country: {
|
|
validators: {
|
|
notEmpty: {
|
|
message: 'Country is required'
|
|
}
|
|
}
|
|
},
|
|
},
|
|
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_projects_add');
|
|
_formEl = KTUtil.getById('kt_projects_add_form');
|
|
|
|
initWizard();
|
|
initValidation();
|
|
// initAvatar();
|
|
}
|
|
};
|
|
}();
|
|
|
|
jQuery(document).ready(function () {
|
|
if(type=='tambahProjects') {
|
|
KTProjectsAdd.init();
|
|
} else if(type=='detailProjects') {
|
|
var col = tableHead.split(',');
|
|
/* if (tableHeadAlias) {
|
|
var colAlias = tableHeadAlias.split(',');
|
|
} */
|
|
|
|
var colum = [];
|
|
|
|
col.forEach((c,k) => {
|
|
var v = {};
|
|
v['data'] = col[k];
|
|
/* if (tableHeadAlias) {
|
|
v['name'] = colAlias[k];
|
|
} */
|
|
colum.push(v);
|
|
});
|
|
console.log(colum)
|
|
var columStyle =
|
|
[
|
|
{ "orderable": false, "targets": [-1] },
|
|
];
|
|
|
|
table = znGetTableScrolling(routeTable,colum,columStyle,'indexTable');
|
|
|
|
validation_task = FormValidation.formValidation(
|
|
KTUtil.getById('form_task'),
|
|
{
|
|
fields: {
|
|
task_name: {
|
|
validators: {
|
|
notEmpty: {
|
|
message: 'Wajib diisi!'
|
|
}
|
|
}
|
|
},
|
|
start_date: {
|
|
validators: {
|
|
notEmpty: {
|
|
message: 'Wajib diisi!'
|
|
}
|
|
}
|
|
},
|
|
due_date: {
|
|
validators: {
|
|
notEmpty: {
|
|
message: 'Wajib diisi!'
|
|
}
|
|
}
|
|
},
|
|
status_id: {
|
|
validators: {
|
|
notEmpty: {
|
|
message: 'Wajib diisi!'
|
|
}
|
|
}
|
|
},
|
|
critical_level_id: {
|
|
validators: {
|
|
notEmpty: {
|
|
message: 'Wajib diisi!'
|
|
}
|
|
}
|
|
},
|
|
},
|
|
plugins: {
|
|
trigger: new FormValidation.plugins.Trigger(),
|
|
bootstrap: new FormValidation.plugins.Bootstrap()
|
|
}
|
|
}
|
|
);
|
|
validation_project = FormValidation.formValidation(
|
|
KTUtil.getById('form_edit_project'),
|
|
{
|
|
fields: {
|
|
nama_project: {
|
|
validators: {
|
|
notEmpty: {
|
|
message: 'Wajib diisi!'
|
|
}
|
|
}
|
|
},
|
|
project_owner: {
|
|
validators: {
|
|
notEmpty: {
|
|
message: 'Wajib dipilih!'
|
|
}
|
|
}
|
|
},
|
|
tgl_mulai: {
|
|
validators: {
|
|
notEmpty: {
|
|
message: 'Wajib diisi!'
|
|
},
|
|
}
|
|
},
|
|
tgl_selesai: {
|
|
validators: {
|
|
notEmpty: {
|
|
message: 'Wajib diisi!'
|
|
},
|
|
}
|
|
},
|
|
info_detail_project: {
|
|
validators: {
|
|
notEmpty: {
|
|
message: 'Wajib diisi!'
|
|
},
|
|
}
|
|
},
|
|
},
|
|
plugins: {
|
|
trigger: new FormValidation.plugins.Trigger(),
|
|
bootstrap: new FormValidation.plugins.Bootstrap()
|
|
}
|
|
}
|
|
);
|
|
|
|
$('[data-scroll="true"]').each(function() {
|
|
var el = $(this);
|
|
KTUtil.scrollInit(this, {
|
|
mobileNativeScroll: true,
|
|
handleWindowResize: true,
|
|
rememberPosition: (el.data('remember-position') == 'true' ? true : false),
|
|
height: function() {
|
|
if (KTUtil.isBreakpointDown('lg') && el.data('mobile-height')) {
|
|
return el.data('mobile-height');
|
|
} else {
|
|
return el.data('height');
|
|
}
|
|
}
|
|
});
|
|
});
|
|
} else if(type == 'kanbanProjects') {
|
|
validation_task = FormValidation.formValidation(
|
|
KTUtil.getById('form_task'),
|
|
{
|
|
fields: {
|
|
task_name: {
|
|
validators: {
|
|
notEmpty: {
|
|
message: 'Wajib diisi!'
|
|
}
|
|
}
|
|
},
|
|
start_date: {
|
|
validators: {
|
|
notEmpty: {
|
|
message: 'Wajib diisi!'
|
|
}
|
|
}
|
|
},
|
|
due_date: {
|
|
validators: {
|
|
notEmpty: {
|
|
message: 'Wajib diisi!'
|
|
}
|
|
}
|
|
},
|
|
status_id: {
|
|
validators: {
|
|
notEmpty: {
|
|
message: 'Wajib diisi!'
|
|
}
|
|
}
|
|
},
|
|
critical_level_id: {
|
|
validators: {
|
|
notEmpty: {
|
|
message: 'Wajib diisi!'
|
|
}
|
|
}
|
|
},
|
|
},
|
|
plugins: {
|
|
trigger: new FormValidation.plugins.Trigger(),
|
|
bootstrap: new FormValidation.plugins.Bootstrap()
|
|
}
|
|
}
|
|
);
|
|
}
|
|
|
|
});
|
|
|
|
function storeTask() {
|
|
validation_task.validate().then(function (status) {
|
|
if(status=='Valid') {
|
|
let myForm = document.getElementById('form_task');
|
|
let formData = new FormData(myForm);
|
|
popConfirm("Konfirmasi Data Task",
|
|
`<div class="mt-2">Yakin Akan Menyimpan Data Task Ini ?</div>`,
|
|
function() {
|
|
znLoadingModal('mFormTask')
|
|
doPost(base_url+'projects/act_any/store_data_task', formData, function (msg, data) {
|
|
// znLoadingPageEnd();
|
|
znLoadingModalEnd('mFormTask')
|
|
|
|
if (data == null){
|
|
znNotif("danger", msg);
|
|
}else {
|
|
if(data.rc == 0){
|
|
znNotif('success','Berhasil Menyimpan Data');
|
|
if(type=='detailProjects') {
|
|
tableRincian.ajax.reload();
|
|
table.ajax.url(routeTable).load();
|
|
$('#jml_task').html(data.jml_task.jml_task + ' Tasks');
|
|
$('#task_on_progress').html('Terdapat '+data.task_on_progress.totonprogress+' Task Berjalan');
|
|
} else if(type=='kanbanProjects') {
|
|
$('#kt_kanban_3').html(``)
|
|
KTKanbanBoardDemo.init();
|
|
}
|
|
$('#mFormTask').modal('hide')
|
|
}else{
|
|
znNotif("danger", data.rm);
|
|
}
|
|
}
|
|
})
|
|
});
|
|
}
|
|
})
|
|
}
|
|
|
|
function storeData() {
|
|
_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_projects_add_form');
|
|
let formData = new FormData(myForm);
|
|
popConfirm("Konfirmasi Data Project",
|
|
`<div class="mt-2">Yakin Akan Menyimpan Data Project Ini ?</div>`,
|
|
function() {
|
|
znLoadingPage();
|
|
doPost(base_url+'projects/act_any/store_data_projects', formData, function (msg, data) {
|
|
// znLoadingPageEnd();
|
|
|
|
if (data == null){
|
|
znLoadingPageEnd()
|
|
znNotif("danger", msg);
|
|
}else {
|
|
if(data.rc == 0){
|
|
znNotif('success','Berhasil Menyimpan Data');
|
|
window.location.href = base_url + 'projects';
|
|
}else{
|
|
znLoadingPageEnd()
|
|
znNotif("danger", data.rm);
|
|
}
|
|
}
|
|
})
|
|
});
|
|
}
|
|
} else {
|
|
znNotif('warning', 'Lengkapi Data')
|
|
}
|
|
});
|
|
}
|
|
|
|
function reviewProject() {
|
|
$('#review_project').html('');
|
|
$('#review_project').append('\
|
|
<tr>\
|
|
<td class="font-weight-bold text-muted">Nama Project</td>\
|
|
<td class="font-weight-bold">'+$('#nama_project').val()+'</td>\
|
|
</tr>\
|
|
<tr>\
|
|
<td class="font-weight-bold text-muted">Budgeting Awal</td>\
|
|
<td class="font-weight-bold">'+$('#budget_amount').val()+'</td>\
|
|
</tr>\
|
|
<tr>\
|
|
<td class="font-weight-bold text-muted">Info Detail Project</td>\
|
|
<td class="font-weight-bold">'+$('#info_detail_project').val()+'</td>\
|
|
</tr>\
|
|
<tr>\
|
|
<td class="font-weight-bold text-muted">Project Owner</td>\
|
|
<td class="font-weight-bold">'+$('#project_owner option:selected').text()+'</td>\
|
|
</tr>\
|
|
<tr>\
|
|
<td class="font-weight-bold text-muted">Tanggal Mulai</td>\
|
|
<td class="font-weight-bold">'+$('#tgl_mulai').val()+'</td>\
|
|
</tr>\
|
|
<tr>\
|
|
<td class="font-weight-bold text-muted">Tanggal Selesai</td>\
|
|
<td class="font-weight-bold">'+$('#tgl_selesai').val()+'</td>\
|
|
</tr>\
|
|
');
|
|
$('#review_anggota_tim').html('')
|
|
var td = '';
|
|
$.each(arrayPersonil, function(k,v) {
|
|
td+= (k+1)+'. '+v.personil_name+' ('+v.team_role_name+') <br>' ;
|
|
});
|
|
$('#review_anggota_tim').append('\
|
|
<tr>\
|
|
<td class="font-weight-bold">'+td+'</td>\
|
|
</tr>\
|
|
')
|
|
}
|
|
|
|
function tambahPersonil() {
|
|
$('#row_exist').val('');
|
|
$('#pilih_personil').val('').trigger('change.select2')
|
|
$('#pilih_team_role').val('').trigger('change.select2')
|
|
$("#pilih_personil > option").each(function(index) {
|
|
$('#pilih_personil').find('option[value="' + this.value + '"]').prop('disabled', false);
|
|
});
|
|
$("#pilih_team_role > option").each(function(index) {
|
|
$('#pilih_team_role').find('option[value="' + this.value + '"]').prop('disabled', false);
|
|
});
|
|
$.each(arrayPersonil, function(k,v) {
|
|
if(v.team_role_id) {
|
|
if(v.team_role_id==1) {
|
|
$("#pilih_team_role option[value=" + v.team_role_id + "]").attr('disabled','disabled');
|
|
}
|
|
}
|
|
$("#pilih_personil option[value=" + v.personil_id + "]").attr('disabled','disabled');
|
|
});
|
|
znModal('mForm');
|
|
}
|
|
|
|
function editPersonil(personil_id, team_role_id, row_exist) {
|
|
$('#row_exist').val(row_exist)
|
|
$('#pilih_personil').val(personil_id).trigger('change.select2')
|
|
$('#pilih_team_role').val(team_role_id).trigger('change.select2')
|
|
$("#pilih_personil > option").each(function(index) {
|
|
if(personil_id!=this.value) {
|
|
$('#pilih_personil').find('option[value="' + this.value + '"]').prop('disabled', true);
|
|
} else {
|
|
$('#pilih_personil').find('option[value="' + this.value + '"]').prop('disabled', false);
|
|
}
|
|
});
|
|
$("#pilih_team_role > option").each(function(index) {
|
|
if(team_role_id!=this.value) {
|
|
$('#pilih_team_role').find('option[value="' + this.value + '"]').prop('disabled', true);
|
|
} else {
|
|
$('#pilih_team_role').find('option[value="' + this.value + '"]').prop('disabled', false);
|
|
}
|
|
});
|
|
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').data('nama'),
|
|
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 if(team_role_id=='') {
|
|
znNotif('warning', 'Wajib Pilih Role')
|
|
} 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><input type="hidden" name="team_role_id_'+(k+1)+'" id="team_role_id_'+(k+1)+'" value="'+v.team_role_id+'">'+v.team_role_name+'</td>';
|
|
row_tbody+= '<td>Aktif</td>';
|
|
row_tbody+= '<td>\
|
|
<div class="dropdown dropdown-inline">\
|
|
<a href="javascript:;" class="btn btn-sm btn-clean btn-icon mr-2" data-toggle="dropdown">\
|
|
<span class="svg-icon svg-icon-md">\
|
|
<svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" width="24px" height="24px" viewBox="0 0 24 24" version="1.1">\
|
|
<g stroke="none" stroke-width="1" fill="none" fill-rule="evenodd">\
|
|
<rect x="0" y="0" width="24" height="24"/>\
|
|
<path d="M5,8.6862915 L5,5 L8.6862915,5 L11.5857864,2.10050506 L14.4852814,5 L19,5 L19,9.51471863 L21.4852814,12 L19,14.4852814 L19,19 L14.4852814,19 L11.5857864,21.8994949 L8.6862915,19 L5,19 L5,15.3137085 L1.6862915,12 L5,8.6862915 Z M12,15 C13.6568542,15 15,13.6568542 15,12 C15,10.3431458 13.6568542,9 12,9 C10.3431458,9 9,10.3431458 9,12 C9,13.6568542 10.3431458,15 12,15 Z" fill="#000000"/>\
|
|
</g>\
|
|
</svg>\
|
|
</span>\
|
|
</a>\
|
|
<div class="dropdown-menu dropdown-menu-sm dropdown-menu-right">\
|
|
<ul class="navi flex-column navi-hover py-2">\
|
|
<li class="navi-header font-weight-bolder text-uppercase font-size-xs text-primary pb-2">\
|
|
Choose an action:\
|
|
</li>\
|
|
<li class="navi-item">\
|
|
<a href="#" onclick="editPersonil('+v.personil_id+','+v.team_role_id+','+(k+1)+')" class="navi-link">\
|
|
<span class="navi-icon"><i class="la la-edit"></i></span>\
|
|
<span class="navi-text">Edit</span>\
|
|
</a>\
|
|
</li>\
|
|
<li class="navi-item">\
|
|
<a href="#" onclick="hapusPersonil('+k+')" class="navi-link">\
|
|
<span class="navi-icon"><i class="la la-trash"></i></span>\
|
|
<span class="navi-text">Hapus</span>\
|
|
</a>\
|
|
</li>\
|
|
</ul>\
|
|
</div>\
|
|
</div>\
|
|
</td>';
|
|
row_tbody+= '</tr>';
|
|
});
|
|
console.log(arrayPersonil)
|
|
$('#row_anggota').val(arrayPersonil.length)
|
|
$('#anggota_tim_tbody').html('')
|
|
$('#anggota_tim_tbody').append(row_tbody)
|
|
}
|
|
|
|
function tambahMember(team_code) {
|
|
$('#pilih_personil').val('').trigger('change.select2')
|
|
$('#pilih_team_role').val('').trigger('change.select2')
|
|
$('[id^=btn_personil_act]').attr('onclick','storeMemberTeam(\''+team_code+'\')')
|
|
$('[id^=btn_personil_act]').html('Tambah')
|
|
znLoadingPage()
|
|
$.when(getMemberNotInProject(team_code), getTeamRoleNotInProject(team_code)).done(function(a1, a2) {
|
|
znLoadingPageEnd()
|
|
validation = FormValidation.formValidation(
|
|
KTUtil.getById('form_personil'),
|
|
{
|
|
fields: {
|
|
pilih_personil: {
|
|
validators: {
|
|
notEmpty: {
|
|
message: 'Wajib diisi!'
|
|
}
|
|
}
|
|
},
|
|
pilih_team_role: {
|
|
validators: {
|
|
notEmpty: {
|
|
message: 'Wajib diisi!'
|
|
}
|
|
}
|
|
},
|
|
},
|
|
plugins: {
|
|
trigger: new FormValidation.plugins.Trigger(),
|
|
bootstrap: new FormValidation.plugins.Bootstrap()
|
|
}
|
|
}
|
|
);
|
|
znModal('mForm');
|
|
})
|
|
}
|
|
|
|
function storeMemberTeam(team_code) {
|
|
validation.validate().then(function (status) {
|
|
if (status == 'Valid') {
|
|
let myForm = document.getElementById('form_personil');
|
|
let formData = new FormData(myForm);
|
|
formData.append('team_code',team_code);
|
|
popConfirm("Konfirmasi Penambahan Member",
|
|
`<div class="mt-2">Yakin Akan Menambahkan Member ini ?</div>`,
|
|
function() {
|
|
znLoadingModal('mForm');
|
|
doPost(base_url+'projects/act_any/store_data_member', formData, function (msg, data) {
|
|
znLoadingModalEnd('mForm');
|
|
|
|
if (data == null){
|
|
znNotif("danger", msg);
|
|
}else {
|
|
if(data.rc == 0){
|
|
znNotif('success','Berhasil Menambahkan Member');
|
|
table.ajax.url(routeTable).load();
|
|
$('#foto_thumbnail_member').html(``)
|
|
var sisa = 0,
|
|
nomor = 0;
|
|
$.each(data.data, function(k,v) {
|
|
if(k<5) {
|
|
nomor = (k+1);
|
|
$('#foto_thumbnail_member').append(`
|
|
<div class="symbol symbol-30 symbol-circle" data-toggle="tooltip" title="`+v.full_name+`">
|
|
<img alt="Pic" src="`+v.image_url+`" />
|
|
</div>
|
|
`);
|
|
};
|
|
});
|
|
sisa = data.data.length - nomor;
|
|
if(sisa > 0) {
|
|
$('#foto_thumbnail_member').append(`
|
|
<div class="symbol symbol-30 symbol-circle symbol-light">
|
|
<span class="symbol-label font-weight-bold">`+sisa+`+</span>
|
|
</div>
|
|
`)
|
|
}
|
|
$('[data-toggle="tooltip"]').tooltip()
|
|
$('#mForm').modal('hide')
|
|
}else{
|
|
znNotif("danger", data.rm);
|
|
}
|
|
}
|
|
})
|
|
});
|
|
}
|
|
});
|
|
}
|
|
|
|
function getMemberNotInProject(team_code, set_id = 'pilih_personil') {
|
|
let formData = new FormData();
|
|
formData.append('team_code', team_code);
|
|
return doPost(base_url+'projects/get_any/get_member_not_in_project', formData, function (msg, data) {
|
|
$('#'+set_id).html(``)
|
|
$.each(data.data, function(k,v) {
|
|
$('#'+set_id).append('<option value="'+v.id+'">'+v.full_name+'</option>')
|
|
})
|
|
})
|
|
}
|
|
|
|
function getTeamRoleNotInProject(team_code, set_id = 'pilih_team_role') {
|
|
let formData = new FormData();
|
|
formData.append('team_code', team_code);
|
|
return doPost(base_url+'projects/get_any/get_team_role_not_in_project', formData, function (msg, data) {
|
|
$('#'+set_id).html(``)
|
|
$.each(data.data, function(k,v) {
|
|
$('#'+set_id).append('<option value="'+v.id+'" data-definition="'+v.definition+'">'+v.definition+'</option>')
|
|
})
|
|
})
|
|
}
|
|
|
|
function rincianTask(id_project, team_code, nama, member_id) {
|
|
$('#title_rincian').html('Rincian Task ' + nama)
|
|
$('#btn_add_task').attr('onclick','tambahTask(`'+id_project+'`,`'+member_id+'`)');
|
|
znLoadingPage()
|
|
$.when(loadRincianTask(id_project, member_id)).done(function(a1) {
|
|
znLoadingPageEnd()
|
|
znModal('mFormRincian')
|
|
})
|
|
}
|
|
|
|
function loadRincianTask(id_project, member_id) {
|
|
var url = base_url+'projects/dataTable?type=data_task_member&id_project='+id_project+'&member_id='+member_id;
|
|
var columDet = [];
|
|
columDet = [
|
|
{data: 'DT_RowIndex'},
|
|
{data: 'task_name'},
|
|
{data: 'task_code'},
|
|
{data: 'due_date'},
|
|
{data: 'project_name'},
|
|
{data: 'status_task'},
|
|
{data: 'action'},
|
|
];
|
|
|
|
var columStyleDet =
|
|
[
|
|
{ "orderable": false, "targets": [-1] },
|
|
];
|
|
|
|
return tableRincian = znGetTableScrolling(url,columDet,columStyleDet,'indexTableRincian', 39);
|
|
}
|
|
|
|
function tambahTask(id_project, member_id) {
|
|
$('#form_task')[0].reset();
|
|
$('.custom-file-label').html('')
|
|
validation_task.resetForm(true);
|
|
$.when(getStatus(), getCriticalLevel()).done(function(a1, a2) {
|
|
$('#id_project').val(id_project)
|
|
$('#member_id').val(member_id)
|
|
znModal('mFormTask')
|
|
})
|
|
}
|
|
|
|
function getStatus(set_id = 'status_id', id=null) {
|
|
var formData = new FormData();
|
|
return doPost(base_url+'projects/get_any/get_status', formData, function (msg, data) {
|
|
$('#'+set_id).html(``)
|
|
$.each(data.data, function(k,v) {
|
|
var selected = v.id==id?'selected':'';
|
|
$('#'+set_id).append('<option value="'+v.id+'" '+selected+'>'+v.definition+'</option>')
|
|
})
|
|
})
|
|
}
|
|
|
|
function getCriticalLevel(set_id = 'critical_level_id', id=null) {
|
|
var formData = new FormData();
|
|
return doPost(base_url+'projects/get_any/get_critical_level', formData, function (msg, data) {
|
|
$('#'+set_id).html(``)
|
|
$.each(data.data, function(k,v) {
|
|
var selected = v.id==id?'selected':'';
|
|
$('#'+set_id).append('<option value="'+v.id+'" '+selected+'>'+v.definition+'</option>')
|
|
})
|
|
})
|
|
}
|
|
|
|
function editRincian(id_task) {
|
|
$('#form_task')[0].reset();
|
|
$('.custom-file-label').html('')
|
|
validation_task.resetForm(true);
|
|
var formData = new FormData();
|
|
formData.append('id', id_task)
|
|
znLoadingModal('mFormRincian')
|
|
doPost(base_url + 'projects/get_any/get_data_task', formData, function(msg, data) {
|
|
var data = data.data[0];
|
|
$('#get_id').val(data.id)
|
|
$('#id_project').val(data.project_id)
|
|
$('#member_id').val(data.pic_id)
|
|
$('#task_name').val(data.task_name)
|
|
$('#task_code').val(data.task_code)
|
|
$('#start_date').val(znFormatDateClear(data.start_date))
|
|
$('#due_date').val(znFormatDateClear(data.due_date))
|
|
$('#task_note').val(data.task_note)
|
|
$.when(getStatus('status_id',data.status_id),getCriticalLevel('critical_level_id',data.critical_level_id)).done(function(a1, a2) {
|
|
znLoadingModalEnd('mFormRincian')
|
|
znModal('mFormTask')
|
|
})
|
|
});
|
|
}
|
|
|
|
function hapusRincian(id_task, project_id) {
|
|
let formData = new FormData();
|
|
formData.append('id', id_task)
|
|
formData.append('project_id', project_id)
|
|
popConfirm("Konfirmasi Hapus Task",
|
|
`<div class="mt-2">Yakin Akan Menghapus Data Task Ini ?</div>`,
|
|
function() {
|
|
znLoadingModal('mFormRincian')
|
|
doPost(base_url+'projects/act_any/delete_data_task', formData, function (msg, data) {
|
|
// znLoadingPageEnd();
|
|
znLoadingModalEnd('mFormRincian')
|
|
|
|
if (data == null){
|
|
znNotif("danger", msg);
|
|
}else {
|
|
if(data.rc == 0){
|
|
znNotif('success','Berhasil Menghapus Data');
|
|
tableRincian.ajax.reload();
|
|
table.ajax.url(routeTable).load();
|
|
$('#jml_task').html(data.jml_task.jml_task + ' Tasks');
|
|
$('#task_on_progress').html('Terdapat '+data.task_on_progress.totonprogress+' Task Berjalan');
|
|
}else{
|
|
znNotif("danger", data.rm);
|
|
}
|
|
}
|
|
})
|
|
});
|
|
}
|
|
|
|
function commentProject(id) {
|
|
znLoadingPage()
|
|
var formData = new FormData();
|
|
formData.append('id', id);
|
|
doPost(base_url + 'projects/get_any/data_project_comment', formData, function(msg, data) {
|
|
znLoadingPageEnd()
|
|
$('#comment_project').html(``)
|
|
$.each(data.data, function(k,v) {
|
|
var textAlign = 'text-left';
|
|
var alignItem = 'align-items-start';
|
|
var bgChat = 'bg-light-primary';
|
|
if(v.user_crt_id == '{{ Auth::user()->id }}') {
|
|
textAlign = 'align-items-right';
|
|
alignItem = 'align-items-end';
|
|
bgChat = 'bg-light-success';
|
|
}
|
|
$('#comment_project').append(`
|
|
<!--begin::Message In-->
|
|
<div class="d-flex flex-column mb-5 `+alignItem+`">
|
|
<div class="d-flex align-items-center">
|
|
<div class="symbol symbol-circle symbol-35 mr-3">
|
|
<img alt="Pic" src="`+v.image_url+`" onerror="this.error=null; this.src='{{ asset('assets/media/logos/no_img.png') }}'" />
|
|
</div>
|
|
<div>
|
|
<a href="#" class="text-dark-75 text-hover-primary font-weight-bold font-size-h6">`+v.full_name+`</a>
|
|
<span class="text-muted font-size-sm">`+znFormatDatetime(v.created_at)+`</span>
|
|
</div>
|
|
</div>
|
|
<div class="mt-2 rounded p-5 `+bgChat+` text-dark-50 font-weight-bold font-size-md `+textAlign+` max-w-400px">`+v.comment_note+`</div>
|
|
</div>
|
|
<!--end::Message In-->
|
|
`);
|
|
})
|
|
znModal('mCommentProject')
|
|
})
|
|
}
|
|
|
|
function storeCommentProject(id_project) {
|
|
var formData = new FormData();
|
|
formData.append('id_project', id_project)
|
|
formData.append('comment_note', $('#comment_note').val())
|
|
popConfirm("Konfirmasi Comment Note",
|
|
`<div class="mt-2">Yakin Akan Menyimpan Data Comment Ini ?</div>`,
|
|
function() {
|
|
znLoadingModal('mCommentProject')
|
|
doPost(base_url+'projects/act_any/store_data_comment_project', formData, function (msg, data) {
|
|
// znLoadingPageEnd();
|
|
znLoadingModalEnd('mCommentProject')
|
|
if (data == null){
|
|
znNotif("danger", msg);
|
|
}else {
|
|
if(data.rc == 0){
|
|
// znNotif('success','Berhasil Menyimpan Data');
|
|
$('#comment_note').val('');
|
|
$('#jmlComments').html(data.jmlComment + ' Comments')
|
|
commentProject(id_project)
|
|
}else{
|
|
znNotif("danger", data.rm);
|
|
}
|
|
}
|
|
})
|
|
});
|
|
}
|
|
|
|
function generateTask(id_project) {
|
|
$('#form_generate')[0].reset();
|
|
$('#pilih_model').val('').trigger('change.select2')
|
|
$('#pilih_member').val('').trigger('change.select2')
|
|
$('#list_model_task').html('')
|
|
znLoadingPage()
|
|
$.when(getMember(id_project), getModelTask()).done(function(a1, a2) {
|
|
$('#id_project_generate_task').val(id_project)
|
|
$('#pilih_model').on('select2:select', function (e) {
|
|
var data = e.params.data;
|
|
$('#list_model_task').html(``);
|
|
getModelTaskDetail(data.id, id_project);
|
|
});
|
|
validation_task_generate = FormValidation.formValidation(
|
|
KTUtil.getById('form_generate'),
|
|
{
|
|
fields: {
|
|
pilih_model: {
|
|
validators: {
|
|
notEmpty: {
|
|
message: 'Wajib dipilih'
|
|
}
|
|
}
|
|
},
|
|
/* task_name: {
|
|
selector: '.task_name_model',
|
|
validators: {
|
|
notEmpty: {
|
|
message: 'Wajib diisi!'
|
|
}
|
|
}
|
|
},
|
|
start_date: {
|
|
selector: '.start_date_model',
|
|
validators: {
|
|
notEmpty: {
|
|
message: 'Wajib diisi!'
|
|
}
|
|
}
|
|
},
|
|
due_date: {
|
|
selector: '.due_date_model',
|
|
validators: {
|
|
notEmpty: {
|
|
message: 'Wajib diisi!'
|
|
}
|
|
}
|
|
}, */
|
|
},
|
|
plugins: {
|
|
trigger: new FormValidation.plugins.Trigger(),
|
|
bootstrap: new FormValidation.plugins.Bootstrap()
|
|
}
|
|
}
|
|
);
|
|
znLoadingPageEnd()
|
|
znModal('mGenerateTask')
|
|
})
|
|
}
|
|
|
|
function getMember(id_project, set_id = 'pilih_member', 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(``)
|
|
$.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 getModelTask(set_id = 'pilih_model') {
|
|
var formData = new FormData();
|
|
return doPost(base_url+'projects/get_any/get_model_task', formData, function (msg, data) {
|
|
$('#'+set_id).html(``)
|
|
$('#'+set_id).append(`<option value="">Pilih Model</option>`);
|
|
$.each(data.data, function(k,v) {
|
|
$('#'+set_id).append('<option value="'+v.id+'">'+v.description+'</option>')
|
|
})
|
|
})
|
|
}
|
|
|
|
function getModelTaskDetail(id_model, id_project) {
|
|
var formData = new FormData();
|
|
formData.append('id', id_model)
|
|
znLoadingModal('mGenerateTask')
|
|
doPost(base_url+'projects/get_any/get_model_task_detail', formData, function (msg, data) {
|
|
$('#list_model_task').html(``)
|
|
$.each(data.data, function(k,v) {
|
|
$('#list_model_task').append(`
|
|
<div class="row">
|
|
<div class="col-3">
|
|
<x-form.select title="Pilih PIC Task" id="pic_id_generate`+(k+1)+`" classAdd="pic_id_model">
|
|
<x-slot name="option">
|
|
</x-slot>
|
|
</x-form.select>
|
|
</div>
|
|
<div class="col-3">
|
|
<x-form.input title="Task Name" id="task_name_generate`+(k+1)+`" value="`+v.task_name+`" classAdd="task_name_model" />
|
|
</div>
|
|
<div class="col-3">
|
|
<x-form.input title="Task Note" id="task_note_generate`+(k+1)+`" value="" classAdd="task_note_model" />
|
|
</div>
|
|
<div class="col-3">
|
|
<x-form.date title="Start Date" id="start_date_generate`+(k+1)+`" value="" classAdd="start_date_model" />
|
|
</div>
|
|
<div class="col-3">
|
|
<x-form.date title="Target Date" id="due_date_generate`+(k+1)+`" value="" classAdd="due_date_model" />
|
|
</div>
|
|
<div class="col-3">
|
|
<x-form.select title="Pilih Status" id="status_id_generate`+(k+1)+`" classAdd="status_id_model">
|
|
<x-slot name="option">
|
|
</x-slot>
|
|
</x-form.select>
|
|
</div>
|
|
<div class="col-3">
|
|
<x-form.select title="Pilih Level" id="critical_level_id_generate`+(k+1)+`" classAdd="critical_level_id_model">
|
|
<x-slot name="option">
|
|
</x-slot>
|
|
</x-form.select>
|
|
</div>
|
|
</div>
|
|
<div class="separator separator-dashed my-10"></div>
|
|
`)
|
|
var option = {
|
|
validators: {
|
|
notEmpty: {
|
|
message: 'Wajib dipilih'
|
|
}
|
|
}
|
|
};
|
|
validation_task_generate.addField('task_name_generate'+(k+1), option);
|
|
validation_task_generate.addField('start_date_generate'+(k+1), option);
|
|
validation_task_generate.addField('due_date_generate'+(k+1), option);
|
|
|
|
$.when(getStatus('status_id_generate'+(k+1)),getCriticalLevel('critical_level_id_generate'+(k+1)),getMember(id_project, 'pic_id_generate'+(k+1))).done(function(a1, a2) {
|
|
})
|
|
})
|
|
reInitForm()
|
|
$('#row_modeling').val(data.data.length);
|
|
znLoadingModalEnd('mGenerateTask')
|
|
});
|
|
}
|
|
|
|
function storeGenerateTask() {
|
|
validation_task_generate.validate().then(function (status) {
|
|
if(status=='Valid') {
|
|
let myForm = document.getElementById('form_generate');
|
|
let formData = new FormData(myForm);
|
|
popConfirm("Konfirmasi Data Task",
|
|
`<div class="mt-2">Yakin Akan Menyimpan Data Task Ini ?</div>`,
|
|
function() {
|
|
znLoadingModal('mGenerateTask')
|
|
doPost(base_url+'projects/act_any/store_data_generate_task', formData, function (msg, data) {
|
|
// znLoadingPageEnd();
|
|
znLoadingModalEnd('mGenerateTask')
|
|
|
|
if (data == null){
|
|
znNotif("danger", msg);
|
|
}else {
|
|
if(data.rc == 0){
|
|
znNotif('success','Berhasil Menyimpan Data');
|
|
table.ajax.url(routeTable).load();
|
|
$('#jml_task').html(data.jml_task.jml_task + ' Tasks');
|
|
$('#task_on_progress').html('Terdapat '+data.task_on_progress.totonprogress+' Task Berjalan');
|
|
$('#mGenerateTask').modal('hide')
|
|
}else{
|
|
znNotif("danger", data.rm);
|
|
}
|
|
}
|
|
})
|
|
});
|
|
}
|
|
})
|
|
}
|
|
|
|
function statusProject(status_id, id_project, progress) {
|
|
$.when(getStatusProject('pilih_status_project',status_id)).done(function(a1) {
|
|
$('#id_project_status').val(id_project)
|
|
$('#progress_status').val(progress)
|
|
})
|
|
znModal('mFormStatus')
|
|
}
|
|
|
|
function getStatusProject(set_id, id=null) {
|
|
var formData = new FormData();
|
|
return doPost(base_url+'projects/get_any/get_status_project', formData, function (msg, data) {
|
|
$('#'+set_id).html(``)
|
|
$.each(data.data, function(k,v) {
|
|
// var selected = v.id==id?'selected':'';
|
|
if(v.id != id) {
|
|
$('#'+set_id).append('<option value="'+v.id+'">'+v.definition+'</option>')
|
|
}
|
|
})
|
|
})
|
|
}
|
|
|
|
function storeUpdateStatus() {
|
|
var progress_status = parseInt($('#progress_status').val());
|
|
var pilih_status_project = $('#pilih_status_project').val();
|
|
if(pilih_status_project==3) {
|
|
if(progress_status==100) {
|
|
storeDataStatus()
|
|
} else {
|
|
znNotif('warning', 'Progress Project Belum Mencapai 100%')
|
|
}
|
|
} else {
|
|
storeDataStatus()
|
|
}
|
|
}
|
|
|
|
function storeDataStatus() {
|
|
popConfirm("Konfirmasi Update Status Project",
|
|
`<div class="mt-2">Yakin Akan Menyimpan Perubahan Ini ?</div>`,
|
|
function() {
|
|
var form = document.getElementById('form_status_project');
|
|
var formData = new FormData(form);
|
|
znLoadingModal('mFormStatus')
|
|
doPost(base_url + 'projects/act_any/store_status_project', formData, function(msg, data) {
|
|
znLoadingModalEnd('mFormStatus')
|
|
if (data == null){
|
|
znNotif("danger", msg);
|
|
}else {
|
|
if(data.rc == 0){
|
|
znNotif('success','Berhasil Menyimpan Data');
|
|
location.reload();
|
|
}else{
|
|
znNotif("danger", data.rm);
|
|
}
|
|
}
|
|
});
|
|
});
|
|
}
|
|
|
|
function editProject(id, dataJson) {
|
|
var data = JSON.parse(dataJson);
|
|
console.log(data)
|
|
$('#nama_project').val(data.project_name)
|
|
$('#project_owner').val(data.unit_owner_id).trigger('change.select2')
|
|
var tgl_mulai = znFormatDateClear(data.tgl_mulai);
|
|
$('#tgl_mulai').val(tgl_mulai)
|
|
var tgl_selesai = znFormatDateClear(data.tgl_selesai);
|
|
$('#tgl_selesai').val(tgl_selesai)
|
|
$('#info_detail_project').val(data.project_detail)
|
|
$('#id_project_edit').val(id)
|
|
znModal('mEditProject')
|
|
}
|
|
|
|
function storeEditProject() {
|
|
validation_project.validate().then(function(status) {
|
|
if(status == 'Valid') {
|
|
let myForm = document.getElementById('form_edit_project');
|
|
let formData = new FormData(myForm);
|
|
popConfirm("Konfirmasi Data Project",
|
|
`<div class="mt-2">Yakin Akan Mengubah Data Project Ini ?</div>`,
|
|
function() {
|
|
znLoadingModal('mEditProject');
|
|
doPost(base_url+'projects/act_any/store_data_projects', formData, function (msg, data) {
|
|
// znLoadingPageEnd();
|
|
|
|
if (data == null){
|
|
znLoadingModalEnd('mEditProject')
|
|
znNotif("danger", msg);
|
|
}else {
|
|
if(data.rc == 0){
|
|
znNotif('success','Berhasil Mengubah Data');
|
|
// window.location.href = base_url + 'projects';
|
|
location.reload()
|
|
}else{
|
|
znLoadingModalEnd('mEditProject')
|
|
znNotif("danger", data.rm);
|
|
}
|
|
}
|
|
})
|
|
});
|
|
} else {
|
|
znNotif('warning', 'Terdapat data wajib yang belum diisi')
|
|
}
|
|
});
|
|
}
|
|
</script> |