245 lines
12 KiB
PHP
245 lines
12 KiB
PHP
|
<script>
|
||
|
var url = '{{ route('projects.data') }}';
|
||
|
var percent = null;
|
||
|
var validator;
|
||
|
$(document).ready(function() {
|
||
|
keyword = $("#keyword").val();
|
||
|
load_data_project(url, keyword, percent);
|
||
|
|
||
|
$("#keyword").on('keyup', function (e) {
|
||
|
if (e.key === 'Enter' || e.keyCode === 13) {
|
||
|
e.preventDefault();
|
||
|
load_data_project(url, $("#keyword").val(), percent);
|
||
|
}
|
||
|
});
|
||
|
|
||
|
$('#client_project').on('change.select2', function(e) {
|
||
|
var client_name = $(this).find('option:selected').text()
|
||
|
$('#client_name').val(client_name)
|
||
|
})
|
||
|
|
||
|
$('#project_id').on('change.select2', function(e) {
|
||
|
var detProject = $(this).find('option:selected').data('projectdet');
|
||
|
var projectName = $(this).find('option:selected').text()
|
||
|
$('#project_name').val(projectName)
|
||
|
$('#info_detail_project').val(detProject)
|
||
|
})
|
||
|
|
||
|
validator = FormValidation.formValidation(
|
||
|
KTUtil.getById('formData'),
|
||
|
{
|
||
|
fields: {
|
||
|
client_project: {
|
||
|
validators: {
|
||
|
notEmpty: {
|
||
|
message: 'Wajib diisi!'
|
||
|
}
|
||
|
}
|
||
|
},
|
||
|
project_id: {
|
||
|
validators: {
|
||
|
notEmpty: {
|
||
|
message: 'Wajib diisi!'
|
||
|
}
|
||
|
}
|
||
|
},
|
||
|
},
|
||
|
plugins: {
|
||
|
trigger: new FormValidation.plugins.Trigger(),
|
||
|
bootstrap: new FormValidation.plugins.Bootstrap()
|
||
|
}
|
||
|
}
|
||
|
);
|
||
|
});
|
||
|
|
||
|
$(document).on('click', '.pagination-wrapper a', function(e){
|
||
|
event.preventDefault();
|
||
|
var page = $(this).attr('href').split('page=')[1];
|
||
|
url = base_url + 'projects/data?page=' + page;
|
||
|
keyword = $("#keyword").val();
|
||
|
load_data_project (url, keyword, percent);
|
||
|
});
|
||
|
|
||
|
function load_data_project (url, keyword, percent) {
|
||
|
$.ajax({
|
||
|
type: 'GET',
|
||
|
url: url,
|
||
|
data: {
|
||
|
keyword : keyword,
|
||
|
percent : percent,
|
||
|
},
|
||
|
|
||
|
beforeSend: function () {
|
||
|
znLoadingPage()
|
||
|
},
|
||
|
|
||
|
success: function (response) {
|
||
|
if ( response.rc == 200 ) {
|
||
|
var data = response.data.projects.data;
|
||
|
var links = response.data.paginateLinks;
|
||
|
|
||
|
if ( data.length <= 0 ) {
|
||
|
znLoadingPageEnd()
|
||
|
// znNotif('warning', 'Data Project belum tersedia')
|
||
|
$('#card-project').append(`
|
||
|
<x-other.no_data
|
||
|
messageTitle="Maaf data project saat ini tidak ditemukan."
|
||
|
subMessage="Tekan tombol Add Project disebelah kanan atas untuk membuat sebuah project baru."
|
||
|
/>
|
||
|
`)
|
||
|
return false;
|
||
|
}
|
||
|
// var arr = _.chunk(data, 3);
|
||
|
znLoadingPageEnd()
|
||
|
var html = "";
|
||
|
// arr.forEach(function(items, index) {
|
||
|
html += `<div class="row">`;
|
||
|
// items.forEach(function (value, index) {
|
||
|
data.forEach(function (value, index) {
|
||
|
var url_img = "{{asset('assets/media/logos/no_img.png')}}";
|
||
|
if (value.logo_url) {
|
||
|
url_img = value.logo_url;
|
||
|
}
|
||
|
/* var status_project = '';
|
||
|
if(value.status_id == 1) {
|
||
|
status_project = '<span class="ribbon-inner bg-primary"></span>'+ value.status_project;
|
||
|
} else if(value.status_id == 2) {
|
||
|
status_project = '<span class="ribbon-inner bg-warning"></span>'+ value.status_project;
|
||
|
} else if(value.status_id == 3) {
|
||
|
status_project = '<span class="ribbon-inner bg-success"></span>'+ value.status_project;
|
||
|
} else {
|
||
|
status_project = '<span class="ribbon-inner bg-danger"></span>'+ value.status_project;
|
||
|
}
|
||
|
|
||
|
var due_date = G_formatDate(value.due_date, 'd-M-Y');
|
||
|
var present_due_date = new Date(value.due_date);
|
||
|
var present_start_date = new Date();
|
||
|
var one_day = 1000 * 60 * 60 * 24;
|
||
|
var Result = Math.round(present_due_date.getTime() - present_start_date.getTime()) / (one_day);
|
||
|
var days_overdue = Result>0?parseInt(Result.toFixed(0)):0; */
|
||
|
|
||
|
html += `<div class="col-xl-4 col-lg-6 col-md-6 col-sm-6">
|
||
|
<!--begin::Card-->
|
||
|
<div class="card card-custom gutter-b card-stretch">
|
||
|
<!--begin::Body-->
|
||
|
<div class="card-body pt-4">
|
||
|
<!--begin::User-->
|
||
|
<div class="d-flex align-items-center mb-7">
|
||
|
<!--begin::Pic-->
|
||
|
<div class="flex-shrink-0 mr-4">
|
||
|
<div class="symbol symbol-circle symbol-lg-75">
|
||
|
<img src="`+url_img+`" class="img-thumbnail img-fluid rounded-circle" style="object-fit: contain; object-position: center center;" alt="image" onerror="this.error=null; this.src='{{ asset('assets/media/logos/no_img.png') }}'"/>
|
||
|
</div>
|
||
|
</div>
|
||
|
<!--end::Pic-->
|
||
|
<!--begin::Title-->
|
||
|
<div class="d-flex flex-column">
|
||
|
<a href="#" class="text-dark font-weight-bold text-hover-primary font-size-h4 mb-0">${value.project_name}</a>
|
||
|
<span class="text-muted font-weight-bold">${value.client_name}</span>
|
||
|
</div>
|
||
|
<!--end::Title-->
|
||
|
</div>
|
||
|
<!--end::User-->
|
||
|
<!--begin::Desc-->
|
||
|
<p class="mb-7">${value.project_detail}
|
||
|
<!--...
|
||
|
<a href="javascript:void(0);" class="text-primary text-hover-info pr-1" data-toggle="popover" title="${value.project_name}" data-content="<span class='font-size-sm text-dark'>${value.project_detail}</span>" data-container="body" data-trigger="focus" data-placement="right" data-html="true">Read More</a></p>-->
|
||
|
<!--end::Desc-->
|
||
|
<!--begin::Info-->
|
||
|
<div class="mb-7">
|
||
|
<!--<div class="d-flex justify-content-between align-items-center">
|
||
|
<span class="text-dark-75 font-weight-bolder mr-2">Jumlah Anggota Tim:</span>
|
||
|
<a href="#" class="text-muted text-hover-primary"></a>
|
||
|
</div>
|
||
|
<div class="d-flex justify-content-between align-items-cente my-1">
|
||
|
<span class="text-dark-75 font-weight-bolder mr-2">Due Date:</span>
|
||
|
<a href="#" class="text-muted text-hover-primary"></a>
|
||
|
</div>
|
||
|
<div class="d-flex justify-content-between align-items-center">
|
||
|
<span class="text-dark-75 font-weight-bolder mr-2">Days to Duedate:</span>
|
||
|
<span class="text-muted font-weight-bold"></span>
|
||
|
</div>-->
|
||
|
</div>
|
||
|
<!--end::Info-->
|
||
|
<!--<a href="javascript:;" onclick="loadContent('detailProjects?id=${value.id}', this, event)" class="btn btn-block btn-sm btn-light-success font-weight-bolder text-uppercase py-4">Lihat Informasi Project</a>-->
|
||
|
<a href="javascript:;" onclick="editProject(${value.id})" class="btn btn-block btn-sm btn-light-success font-weight-bolder text-uppercase py-4">Edit Project</a>
|
||
|
</div>
|
||
|
<!--end::Body-->
|
||
|
</div>
|
||
|
<!--end:: Card-->
|
||
|
</div>`;
|
||
|
});
|
||
|
html += `</div>`;
|
||
|
// });
|
||
|
$("#card-project").html(html);
|
||
|
$(".pagination-wrapper").html(links);
|
||
|
$('[data-toggle="popover"]').popover();
|
||
|
KTUtil.scrollTop();
|
||
|
} else {
|
||
|
znLoadingPageEnd()
|
||
|
// notifToast('error', 'Terjadi Kesalahan');
|
||
|
znNotif('error', 'Terjadi Kesalahan');
|
||
|
}
|
||
|
}
|
||
|
|
||
|
}).done(function (msg) {
|
||
|
}).fail(function (msg) {
|
||
|
znLoadingPageEnd()
|
||
|
znNotif('danger', 'Terjadi Kesalahan');
|
||
|
$('#card-project').append(`
|
||
|
<x-other.no_data
|
||
|
messageTitle="Maaf data project saat ini tidak ditemukan."
|
||
|
subMessage="Tekan tombol Add Project disebelah kanan atas untuk membuat sebuah project baru."
|
||
|
/>
|
||
|
`)
|
||
|
});
|
||
|
}
|
||
|
|
||
|
function editProject(id) {
|
||
|
znLoadingPage();
|
||
|
$('#mForm_title').html(`Edit Data`);
|
||
|
$('#mForm_subTitle').html(`Edit Data Project`);
|
||
|
let formData = new FormData();
|
||
|
formData.append('id',id);
|
||
|
doPost(base_url+'projects/get_any/get_data_project', formData, function (msg, res) {
|
||
|
znLoadingPageEnd()
|
||
|
$('#get_id').val(res.data.id)
|
||
|
$('#client_project').val(res.data.client_id).trigger('change.select2')
|
||
|
$('#project_id').val(res.data.project_id_pm).trigger('change.select2')
|
||
|
$('#info_detail_project').val(res.data.project_detail)
|
||
|
$('#mForm').modal('show');
|
||
|
});
|
||
|
}
|
||
|
|
||
|
function store() {
|
||
|
validator.validate().then(function(status) {
|
||
|
if(status == 'Valid') {
|
||
|
popConfirm("Konfirmasi Proses",
|
||
|
`<div class="mt-2">Yakin Akan Menyimpan Data Ini ?</div>`, function () {
|
||
|
let myForm = document.getElementById('formData');
|
||
|
let formData = new FormData(myForm);
|
||
|
var isEdit = $('#get_id').val();
|
||
|
|
||
|
znLoadingModal('mForm');
|
||
|
doPost(base_url+'projects/act_any/store_data_project_css', formData, function (msg, data) {
|
||
|
znLoadingModalEnd('mForm');
|
||
|
if (data == null){
|
||
|
znNotif("danger", msg);
|
||
|
}else {
|
||
|
if(data.rc == 0){
|
||
|
znNotif('success','Berhasil Menyimpan Data');
|
||
|
$('#mForm').modal('hide');
|
||
|
// table.ajax.url(routeTable).load();
|
||
|
loadContent('projects', this, event)
|
||
|
}else{
|
||
|
znNotif("danger", data.rm);
|
||
|
}
|
||
|
}
|
||
|
})
|
||
|
|
||
|
});
|
||
|
}
|
||
|
})
|
||
|
}
|
||
|
|
||
|
</script>
|