diff --git a/app/Models/Tracks.php b/app/Models/Tracks.php index 9674bb3..c50650d 100755 --- a/app/Models/Tracks.php +++ b/app/Models/Tracks.php @@ -370,7 +370,61 @@ class Tracks extends Model $query .= " ;"; - return DB::select($query, $params); + // return DB::select($query, $params); + $rawTracks = DB::select($query, $params); + $cleanTracks = self::filterJumps($rawTracks); + + if (isset($filter["limit"])) { + return array_slice($cleanTracks, 0, $filter["limit"]); + } + return $cleanTracks; + } + + public static function haversineDistance($lat1, $lon1, $lat2, $lon2) + { + $earthRadius = 6371000; // meters + + $lat1 = deg2rad($lat1); + $lon1 = deg2rad($lon1); + $lat2 = deg2rad($lat2); + $lon2 = deg2rad($lon2); + + $dlat = $lat2 - $lat1; + $dlon = $lon2 - $lon1; + + $a = sin($dlat / 2) ** 2 + cos($lat1) * cos($lat2) * sin($dlon / 2) ** 2; + $c = 2 * atan2(sqrt($a), sqrt(1 - $a)); + + return $earthRadius * $c; + } + + public static function filterJumps($points, $maxDistance = 50, $maxTimeGap = 10) + { + $filtered = []; + $last = null; + + foreach ($points as $p) { + if (!$last) { + $filtered[] = $p; + $last = $p; + continue; + } + + $distance = self::haversineDistance( + $last->latitude, + $last->longitude, + $p->latitude, + $p->longitude + ); + $timeGap = $p->lst_loc_crt - $last->lst_loc_crt; + + if ($distance <= $maxDistance || $timeGap > $maxTimeGap) { + $filtered[] = $p; + $last = $p; + } + } + + return $filtered; } public static function nearestInCircle($lat, $lng, $rad, $filter = []) diff --git a/resources/views/menu_v1/dashboard.blade.php b/resources/views/menu_v1/dashboard.blade.php index cddcd46..33d8ed8 100755 --- a/resources/views/menu_v1/dashboard.blade.php +++ b/resources/views/menu_v1/dashboard.blade.php @@ -22,8 +22,8 @@ } /* .cLogoGroup { - display: inherit; - } */ + display: inherit; + } */ #openLeftSideBar1Mobile { display: none; } @@ -35,11 +35,11 @@ @media (max-width: 425px) { /* .cLogoGroup { - display: none; - } - .cNameGroup { - margin-bottom: 0!important; - } */ + display: none; + } + .cNameGroup { + margin-bottom: 0!important; + } */ #openLeftSideBar1 { display: none !important; } @@ -766,13 +766,13 @@ }, calcPeriodeDate: function(startDate, endDate) { if (startDate.format('YYYY-MM-DD') === 'Invalid date') { - Helper.toast('Warning', 'just now', 'Tanggal mulai periode tidak valid'); + Helper.toast('Warning', 'just now', 'Start date of the period is not valid'); return { isValid: false }; } if (endDate.format('YYYY-MM-DD') === 'Invalid date') { - Helper.toast('Warning', 'just now', 'Tanggal akhir periode tidak valid'); + Helper.toast('Warning', 'just now', 'End date of the period is not valid'); return { isValid: false }; @@ -781,13 +781,13 @@ const duration = moment.duration(endDate.diff(startDate)); const diffDays = duration.days(); if (diffDays > 30) { - Helper.toast('Warning', 'just now', 'Maksimal periode 1 bulan'); + Helper.toast('Warning', 'just now', 'Maximum period is 1 month'); return { isValid: false }; } if (diffDays < 0) { - Helper.toast('Warning', 'just now', 'Rentang periode tidak valid'); + Helper.toast('Warning', 'just now', 'Invalid period range'); return { isValid: false }; @@ -2606,7 +2606,7 @@ let startMarker = Leaflet.addMarkers({ lat: start.latitude, lng: start.longitude, - label: `Titik Awal
${start.nopol1} ${start.nopol2} ${start.nopol3}
${moment.unix(start?.lst_loc_crt).format('DD MMM YYYY HH:mm')}
Speed: ${(typeof start.lst_speed != 'undefined') ? start.lst_speed : '0'}
${Number(start.latitude).toFixed(5)},${Number(start.longitude).toFixed(6)}
${decodeURIComponent(start.fulladdress || 'address')}`, + label: `Start Poin
${start.nopol1} ${start.nopol2} ${start.nopol3}
${moment.unix(start?.lst_loc_crt).format('DD MMM YYYY HH:mm')}
Speed: ${(typeof start.lst_speed != 'undefined') ? start.lst_speed : '0'}
${Number(start.latitude).toFixed(5)},${Number(start.longitude).toFixed(6)}
${decodeURIComponent(start.fulladdress || 'address')}`, options: { icon: Icon.titikAwal(), // rotationAngle: 290 @@ -2615,7 +2615,7 @@ let finishMarker = Leaflet.addMarkers({ lat: finish.latitude, lng: finish.longitude, - label: `Titik Akhir
${finish.nopol1} ${finish.nopol2} ${finish.nopol3}
${moment.unix(finish?.lst_loc_crt).format('DD MMM YYYY HH:mm')}
Speed: ${(typeof finish.lst_speed != 'undefined') ? finish.lst_speed : '0'}
${Number(finish.latitude).toFixed(5)},${Number(finish.longitude).toFixed(6)}
${decodeURIComponent(finish.fulladdress || 'address')}`, + label: `End Poin
${finish.nopol1} ${finish.nopol2} ${finish.nopol3}
${moment.unix(finish?.lst_loc_crt).format('DD MMM YYYY HH:mm')}
Speed: ${(typeof finish.lst_speed != 'undefined') ? finish.lst_speed : '0'}
${Number(finish.latitude).toFixed(5)},${Number(finish.longitude).toFixed(6)}
${decodeURIComponent(finish.fulladdress || 'address')}`, options: { icon: Icon.titikAkhir() } diff --git a/resources/views/menu_v2/Finance/billing.blade.php b/resources/views/menu_v2/Finance/billing.blade.php index b069727..e278afc 100755 --- a/resources/views/menu_v2/Finance/billing.blade.php +++ b/resources/views/menu_v2/Finance/billing.blade.php @@ -78,8 +78,7 @@ 1 - + @@ -134,7 +133,7 @@ file_jimp_worker: "{{ asset('assets/js/worker/jimp.js') }}", storage_lara: "{{ asset('storage') }}/", periodeStartDate: '', // unix timestamps - periodeEndDate: '', // unix timestamps + periodeEndDate: '', // unix timestamps stts_order: { wait: "{{ App\Models\Orders::STTS_WAIT }}", confirm: "{{ App\Models\Orders::STTS_CONFIRM }}", @@ -166,53 +165,73 @@ }; const Filter = { - activate: function() { - const startDate = moment().startOf('month'); - const endDate = moment().endOf('month'); - $('#filter-startDate').val(startDate.format('YYYY-MM-DD')).trigger('change'); - $('#filter-endDate').val(endDate.format('YYYY-MM-DD')).trigger('change'); - State.periodeStartDate = startDate.unix(); - State.periodeEndDate = endDate.unix(); - Filter.evPeriodeDate(); - }, - evPeriodeDate: function() { - $('#filter-startDate').on('change', function(e) { - const { isValid, data } = Filter.calcPeriodeDate(moment($('#filter-startDate').val()), moment($('#filter-endDate').val())) - if (!isValid) return false; + activate: function() { + const startDate = moment().startOf('month'); + const endDate = moment().endOf('month'); + $('#filter-startDate').val(startDate.format('YYYY-MM-DD')).trigger('change'); + $('#filter-endDate').val(endDate.format('YYYY-MM-DD')).trigger('change'); + State.periodeStartDate = startDate.unix(); + State.periodeEndDate = endDate.unix(); + Filter.evPeriodeDate(); + }, + evPeriodeDate: function() { + $('#filter-startDate').on('change', function(e) { + const { + isValid, + data + } = Filter.calcPeriodeDate(moment($('#filter-startDate').val()), moment($('#filter-endDate').val())) + if (!isValid) return false; State.periodeStartDate = data.startDate.unix(); - State.periodeEndDate = data.endDate.unix(); - DTable.reload(); - }); - $('#filter-endDate').on('change', function(e) { - const { isValid, data } = Filter.calcPeriodeDate(moment($('#filter-startDate').val()), moment($('#filter-endDate').val())) - if (!isValid) return false; + State.periodeEndDate = data.endDate.unix(); + DTable.reload(); + }); + $('#filter-endDate').on('change', function(e) { + const { + isValid, + data + } = Filter.calcPeriodeDate(moment($('#filter-startDate').val()), moment($('#filter-endDate').val())) + if (!isValid) return false; State.periodeStartDate = data.startDate.unix(); - State.periodeEndDate = data.endDate.unix(); - DTable.reload(); - }); - }, - calcPeriodeDate: function(startDate, endDate) { - if (startDate.format('YYYY-MM-DD') === 'Invalid date') { - Helper.toast('Warning', 'just now', 'Tanggal mulai periode tidak valid'); - return { isValid: false }; - } - if (endDate.format('YYYY-MM-DD') === 'Invalid date') { - Helper.toast('Warning', 'just now', 'Tanggal akhir periode tidak valid'); - return { isValid: false }; - } - const duration = moment.duration(endDate.diff(startDate)); - const diffDays = duration.days(); - if (diffDays > 30) { - Helper.toast('Warning', 'just now', 'Maksimal periode 1 bulan'); - return { isValid: false }; - } - if (diffDays < 0) { - Helper.toast('Warning', 'just now', 'Rentang periode tidak valid'); - return { isValid: false }; - } - return { isValid: true, data: { startDate, endDate } }; - }, - } + State.periodeEndDate = data.endDate.unix(); + DTable.reload(); + }); + }, + calcPeriodeDate: function(startDate, endDate) { + if (startDate.format('YYYY-MM-DD') === 'Invalid date') { + Helper.toast('Warning', 'just now', 'Tanggal mulai periode tidak valid'); + return { + isValid: false + }; + } + if (endDate.format('YYYY-MM-DD') === 'Invalid date') { + Helper.toast('Warning', 'just now', 'End date of the period is not valid'); + return { + isValid: false + }; + } + const duration = moment.duration(endDate.diff(startDate)); + const diffDays = duration.days(); + if (diffDays > 30) { + Helper.toast('Warning', 'just now', 'Maksimal periode 1 bulan'); + return { + isValid: false + }; + } + if (diffDays < 0) { + Helper.toast('Warning', 'just now', 'Rentang periode tidak valid'); + return { + isValid: false + }; + } + return { + isValid: true, + data: { + startDate, + endDate + } + }; + }, + } const DTable = { activate: function() { @@ -341,7 +360,7 @@ return 'Lunas'; } else if (State.is_paid.yes == row.is_invc_paid) { if (row.total_billing !== row.total_payed) { - return 'Belum lunas'; + return 'Belum lunas'; } return 'Lunas'; } else if (State.stts_order.drop == data) { diff --git a/resources/views/menu_v2/Finance/ledgerBalance.blade.php b/resources/views/menu_v2/Finance/ledgerBalance.blade.php index b5b9884..f58de19 100755 --- a/resources/views/menu_v2/Finance/ledgerBalance.blade.php +++ b/resources/views/menu_v2/Finance/ledgerBalance.blade.php @@ -19,7 +19,7 @@
-
+
Uang Masuk
@@ -118,7 +118,7 @@ file_jimp_worker: "{{ asset('assets/js/worker/jimp.js') }}", storage_lara: "{{ asset('storage') }}/", periodeStartDate: '', // unix timestamps - periodeEndDate: '', // unix timestamps + periodeEndDate: '', // unix timestamps stts_order: { wait: "{{ App\Models\Orders::STTS_WAIT }}", confirm: "{{ App\Models\Orders::STTS_CONFIRM }}", @@ -176,59 +176,79 @@ }; const Filter = { - activate: function() { - const startDate = moment().startOf('month'); - const endDate = moment().endOf('month'); - $('#filter-startDate').val(startDate.format('YYYY-MM-DD')).trigger('change'); - $('#filter-endDate').val(endDate.format('YYYY-MM-DD')).trigger('change'); - State.periodeStartDate = startDate.unix(); - State.periodeEndDate = endDate.unix(); - Filter.evPeriodeDate(); - }, - evPeriodeDate: function() { - $('#filter-startDate').on('change', function(e) { - const { isValid, data } = Filter.calcPeriodeDate(moment($('#filter-startDate').val()), moment($('#filter-endDate').val())) - if (!isValid) return false; + activate: function() { + const startDate = moment().startOf('month'); + const endDate = moment().endOf('month'); + $('#filter-startDate').val(startDate.format('YYYY-MM-DD')).trigger('change'); + $('#filter-endDate').val(endDate.format('YYYY-MM-DD')).trigger('change'); + State.periodeStartDate = startDate.unix(); + State.periodeEndDate = endDate.unix(); + Filter.evPeriodeDate(); + }, + evPeriodeDate: function() { + $('#filter-startDate').on('change', function(e) { + const { + isValid, + data + } = Filter.calcPeriodeDate(moment($('#filter-startDate').val()), moment($('#filter-endDate').val())) + if (!isValid) return false; State.periodeStartDate = data.startDate.unix(); - State.periodeEndDate = data.endDate.unix(); - DTable.reload(); - }); - $('#filter-endDate').on('change', function(e) { - const { isValid, data } = Filter.calcPeriodeDate(moment($('#filter-startDate').val()), moment($('#filter-endDate').val())) - if (!isValid) return false; + State.periodeEndDate = data.endDate.unix(); + DTable.reload(); + }); + $('#filter-endDate').on('change', function(e) { + const { + isValid, + data + } = Filter.calcPeriodeDate(moment($('#filter-startDate').val()), moment($('#filter-endDate').val())) + if (!isValid) return false; State.periodeStartDate = data.startDate.unix(); - State.periodeEndDate = data.endDate.unix(); - DTable.reload(); - }); - }, - calcPeriodeDate: function(startDate, endDate) { - if (startDate.format('YYYY-MM-DD') === 'Invalid date') { - Helper.toast('Warning', 'just now', 'Tanggal mulai periode tidak valid'); - return { isValid: false }; - } - if (endDate.format('YYYY-MM-DD') === 'Invalid date') { - Helper.toast('Warning', 'just now', 'Tanggal akhir periode tidak valid'); - return { isValid: false }; - } - const duration = moment.duration(endDate.diff(startDate)); - const diffDays = duration.days(); - if (diffDays > 30) { - Helper.toast('Warning', 'just now', 'Maksimal periode 1 bulan'); - return { isValid: false }; - } - if (diffDays < 0) { - Helper.toast('Warning', 'just now', 'Rentang periode tidak valid'); - return { isValid: false }; - } - return { isValid: true, data: { startDate, endDate } }; - }, - } + State.periodeEndDate = data.endDate.unix(); + DTable.reload(); + }); + }, + calcPeriodeDate: function(startDate, endDate) { + if (startDate.format('YYYY-MM-DD') === 'Invalid date') { + Helper.toast('Warning', 'just now', 'Tanggal mulai periode tidak valid'); + return { + isValid: false + }; + } + if (endDate.format('YYYY-MM-DD') === 'Invalid date') { + Helper.toast('Warning', 'just now', 'End date of the period is not valid'); + return { + isValid: false + }; + } + const duration = moment.duration(endDate.diff(startDate)); + const diffDays = duration.days(); + if (diffDays > 30) { + Helper.toast('Warning', 'just now', 'Maksimal periode 1 bulan'); + return { + isValid: false + }; + } + if (diffDays < 0) { + Helper.toast('Warning', 'just now', 'Rentang periode tidak valid'); + return { + isValid: false + }; + } + return { + isValid: true, + data: { + startDate, + endDate + } + }; + }, + } const DTable = { - table: null, + table: null, activate: function() { DTable.reload(); - DTable.eventChildRow(); + DTable.eventChildRow(); }, reload: function() { // $('#tLedgerBl').DataTable(); @@ -277,19 +297,19 @@ // searchable: true, // render: function(data, type, row, meta) { // let action = ` - // - // - // - // `; + // + // + // + // `; // return action; // } // }, - { - "className": 'dt-control', - "orderable": false, - "data": null, - "defaultContent": '', - }, + { + "className": 'dt-control', + "orderable": false, + "data": null, + "defaultContent": '', + }, { data: 'ord_code', className: 'text-start text-nowrap', @@ -339,7 +359,7 @@ searchable: true, render: function(data, type, row, meta) { return (new Intl.NumberFormat('id-ID')).format(data); - // return (new Intl.NumberFormat('id-ID')).format(row.total_in - row.total_out); + // return (new Intl.NumberFormat('id-ID')).format(row.total_in - row.total_out); }, }, ], @@ -354,72 +374,74 @@ $('#totAllIn').text((new Intl.NumberFormat('id-ID')).format(total_in)); $('#totAllOut').text((new Intl.NumberFormat('id-ID')).format(total_out)); }, - eventChildRow: function() { - $('#tLedgerBl tbody').on('click', 'td.dt-control', function () { - var tr = $(this).closest('tr'); - var row = DTable.table.row( tr ); - - if ( row.child.isShown() ) { - // This row is already open - close it - row.child.hide(); - tr.removeClass('shown'); - } - else { - // Open this row - row.child( DTable.formatChildRow(row.data()) ).show(); - tr.addClass('shown'); - } - } ); - }, - formatChildRow: function(d) { - // `d` is the original data object for the row - // let template = ` - let template = `
- - - - - - - - - - - - - ` - for (let item of d.a_items) { - // perlu diperbaiki cara if di query, jika kalkulasi ke vendor maka is_aprv = , jika ke client is_bill_aprv = 1 - if (item.calc_to_vdr == State.calc_to_vdr.yes && item.is_aprv != State.is_aprv.yes) continue; - if (item.invc_to_client == State.invc_to_client.yes && item.is_bill_aprv != State.is_aprv.yes) continue; + eventChildRow: function() { + $('#tLedgerBl tbody').on('click', 'td.dt-control', function() { + var tr = $(this).closest('tr'); + var row = DTable.table.row(tr); - let small_desc = '', amt_in = 0, amt_out = 0, amt_bl = 0; - if (item.is_bill_paid == State.is_a_item_paid.paid) { - amt_in = item.amt_in; - small_desc += `
waktu dibayarkan ${moment.unix(item.paid_bill_at).format('DD MMM YYYY HH:mm:ss')}`; + if (row.child.isShown()) { + // This row is already open - close it + row.child.hide(); + tr.removeClass('shown'); + } else { + // Open this row + row.child(DTable.formatChildRow(row.data())).show(); + tr.addClass('shown'); } - if (item.is_paid == State.is_a_item_paid.paid) { - amt_out = item.amt_out; - small_desc += `
waktu keluar ${moment.unix(item.paid_at).format('DD MMM YYYY HH:mm:ss')}`; - } - if (amt_in != 0 || amt_out != 0) { - amt_bl = item.amt_bl; - } - template += ` - - - - - - - - - `; + }); + }, + formatChildRow: function(d) { + // `d` is the original data object for the row + // let template = `
ItemJumlahSatuanInvoice (Rp)Pembayaran (Rp)Masuk (Rp)Keluar (Rp)Balance (Rp)
${item.item_desc}${small_desc}${item.unit_qty}${item.unit_type_name}${(new Intl.NumberFormat('id-ID')).format(item.amt_in)}${(new Intl.NumberFormat('id-ID')).format(item.amt_out)}${(new Intl.NumberFormat('id-ID')).format(amt_in)}${(new Intl.NumberFormat('id-ID')).format(amt_out)}${(new Intl.NumberFormat('id-ID')).format(amt_bl)}
+ let template = `
+ + + + + + + + + + + + + ` + for (let item of d.a_items) { + // perlu diperbaiki cara if di query, jika kalkulasi ke vendor maka is_aprv = , jika ke client is_bill_aprv = 1 + if (item.calc_to_vdr == State.calc_to_vdr.yes && item.is_aprv != State.is_aprv.yes) continue; + if (item.invc_to_client == State.invc_to_client.yes && item.is_bill_aprv != State.is_aprv.yes) continue; + + let small_desc = '', + amt_in = 0, + amt_out = 0, + amt_bl = 0; + if (item.is_bill_paid == State.is_a_item_paid.paid) { + amt_in = item.amt_in; + small_desc += `
waktu dibayarkan ${moment.unix(item.paid_bill_at).format('DD MMM YYYY HH:mm:ss')}`; } - template += ` -
ItemJumlahSatuanInvoice (Rp)Pembayaran (Rp)Masuk (Rp)Keluar (Rp)Balance (Rp)
`; + if (item.is_paid == State.is_a_item_paid.paid) { + amt_out = item.amt_out; + small_desc += `
waktu keluar ${moment.unix(item.paid_at).format('DD MMM YYYY HH:mm:ss')}`; + } + if (amt_in != 0 || amt_out != 0) { + amt_bl = item.amt_bl; + } + template += ` + ${item.item_desc}${small_desc} + ${item.unit_qty} + ${item.unit_type_name} + ${(new Intl.NumberFormat('id-ID')).format(item.amt_in)} + ${(new Intl.NumberFormat('id-ID')).format(item.amt_out)} + ${(new Intl.NumberFormat('id-ID')).format(amt_in)} + ${(new Intl.NumberFormat('id-ID')).format(amt_out)} + ${(new Intl.NumberFormat('id-ID')).format(amt_bl)} + `; + } + template += ` + `; return template - }, + }, }; Wrapper.activate(); diff --git a/resources/views/menu_v2/Finance/payment.blade.php b/resources/views/menu_v2/Finance/payment.blade.php index b0eae41..9540e4b 100755 --- a/resources/views/menu_v2/Finance/payment.blade.php +++ b/resources/views/menu_v2/Finance/payment.blade.php @@ -122,8 +122,8 @@ const State = { file_jimp_worker: "{{ asset('assets/js/worker/jimp.js') }}", storage_lara: "{{ asset('storage') }}/", - periodeStartDate: '', // unix timestamps - periodeEndDate: '', // unix timestamps + periodeStartDate: '', // unix timestamps + periodeEndDate: '', // unix timestamps stts_order: { wait: "{{ App\Models\Orders::STTS_WAIT }}", confirm: "{{ App\Models\Orders::STTS_CONFIRM }}", @@ -147,7 +147,7 @@ const Wrapper = { activate: function() { - Filter.activate(); + Filter.activate(); Wrapper.event(); DTable.activate(); }, @@ -157,7 +157,7 @@ return 'Lunas'; } else if (State.is_paid.yes == row.is_vdr_paid) { if (row.total_payment !== row.total_payed) { - return 'Belum lunas'; + return 'Belum lunas'; } return 'Lunas'; } else if (State.stts_order.drop == stts) { @@ -180,54 +180,74 @@ }, }; - const Filter = { - activate: function() { - const startDate = moment().startOf('month'); - const endDate = moment().endOf('month'); - $('#filter-startDate').val(startDate.format('YYYY-MM-DD')).trigger('change'); - $('#filter-endDate').val(endDate.format('YYYY-MM-DD')).trigger('change'); - State.periodeStartDate = startDate.unix(); - State.periodeEndDate = endDate.unix(); - Filter.evPeriodeDate(); - }, - evPeriodeDate: function() { - $('#filter-startDate').on('change', function(e) { - const { isValid, data } = Filter.calcPeriodeDate(moment($('#filter-startDate').val()), moment($('#filter-endDate').val())) - if (!isValid) return false; + const Filter = { + activate: function() { + const startDate = moment().startOf('month'); + const endDate = moment().endOf('month'); + $('#filter-startDate').val(startDate.format('YYYY-MM-DD')).trigger('change'); + $('#filter-endDate').val(endDate.format('YYYY-MM-DD')).trigger('change'); + State.periodeStartDate = startDate.unix(); + State.periodeEndDate = endDate.unix(); + Filter.evPeriodeDate(); + }, + evPeriodeDate: function() { + $('#filter-startDate').on('change', function(e) { + const { + isValid, + data + } = Filter.calcPeriodeDate(moment($('#filter-startDate').val()), moment($('#filter-endDate').val())) + if (!isValid) return false; State.periodeStartDate = data.startDate.unix(); - State.periodeEndDate = data.endDate.unix(); - DTable.reload(); - }); - $('#filter-endDate').on('change', function(e) { - const { isValid, data } = Filter.calcPeriodeDate(moment($('#filter-startDate').val()), moment($('#filter-endDate').val())) - if (!isValid) return false; + State.periodeEndDate = data.endDate.unix(); + DTable.reload(); + }); + $('#filter-endDate').on('change', function(e) { + const { + isValid, + data + } = Filter.calcPeriodeDate(moment($('#filter-startDate').val()), moment($('#filter-endDate').val())) + if (!isValid) return false; State.periodeStartDate = data.startDate.unix(); - State.periodeEndDate = data.endDate.unix(); - DTable.reload(); - }); - }, - calcPeriodeDate: function(startDate, endDate) { - if (startDate.format('YYYY-MM-DD') === 'Invalid date') { - Helper.toast('Warning', 'just now', 'Tanggal mulai periode tidak valid'); - return { isValid: false }; - } - if (endDate.format('YYYY-MM-DD') === 'Invalid date') { - Helper.toast('Warning', 'just now', 'Tanggal akhir periode tidak valid'); - return { isValid: false }; - } - const duration = moment.duration(endDate.diff(startDate)); - const diffDays = duration.days(); - if (diffDays > 30) { - Helper.toast('Warning', 'just now', 'Maksimal periode 1 bulan'); - return { isValid: false }; - } - if (diffDays < 0) { - Helper.toast('Warning', 'just now', 'Rentang periode tidak valid'); - return { isValid: false }; - } - return { isValid: true, data: { startDate, endDate } }; - }, - } + State.periodeEndDate = data.endDate.unix(); + DTable.reload(); + }); + }, + calcPeriodeDate: function(startDate, endDate) { + if (startDate.format('YYYY-MM-DD') === 'Invalid date') { + Helper.toast('Warning', 'just now', 'Tanggal mulai periode tidak valid'); + return { + isValid: false + }; + } + if (endDate.format('YYYY-MM-DD') === 'Invalid date') { + Helper.toast('Warning', 'just now', 'End date of the period is not valid'); + return { + isValid: false + }; + } + const duration = moment.duration(endDate.diff(startDate)); + const diffDays = duration.days(); + if (diffDays > 30) { + Helper.toast('Warning', 'just now', 'Maksimal periode 1 bulan'); + return { + isValid: false + }; + } + if (diffDays < 0) { + Helper.toast('Warning', 'just now', 'Rentang periode tidak valid'); + return { + isValid: false + }; + } + return { + isValid: true, + data: { + startDate, + endDate + } + }; + }, + } const DTable = { activate: function() {