fix ringkasan terkumpul dan penambahan data filter dalam bajet

This commit is contained in:
hafifierahman
2023-03-29 22:16:20 +08:00
parent a892849f43
commit cbf7fef739
4 changed files with 631 additions and 581 deletions
+381 -281
View File
@@ -5,24 +5,27 @@
<div class="row justify-content-center">
<div class="col-md-12">
<div class="card">
<nav aria-label="breadcrumb">
<ol class="breadcrumb pb-3">
<li class="breadcrumb-item"><a href="{{ route('home') }}">Home</a></li>
<li class="breadcrumb-item active" aria-current="page">Bajet</li>
<li class="breadcrumb-item"><a href="{{ route('home') }}">Home</a></li>
<li class="breadcrumb-item active" aria-current="page">Bajet</li>
</ol>
</nav>
</nav>
<div class="card-body text-center">
<div class="d-flex">
<div id="divpembharian" class="card bg-light mb-3 col-4 mr-1">
<div class="card-header font-weight-bold">Pembiayaan</div>
<div class="card-body">
<div class="progress mb-2">
<div id="pembprogress" class="progress-bar progress-bar-striped progress-bar-animated" role="progressbar" style="width: 0%;" aria-valuenow="0" aria-valuemin="0" aria-valuemax="100">0%</div>
<div id="pembprogress"
class="progress-bar progress-bar-striped progress-bar-animated"
role="progressbar" style="width: 0%;" aria-valuenow="0" aria-valuemin="0"
aria-valuemax="100">0%</div>
</div>
<div class="d-flex justify-content-between col-12">
@@ -34,7 +37,7 @@
<div>
<span id="pembpercent">-100%</span>
</div>
</div>
<div class="d-flex justify-content-between col-12">
<div class="row col-9">
@@ -51,7 +54,10 @@
<div class="card-header font-weight-bold">Penebusan</div>
<div class="card-body">
<div class="progress mb-2">
<div id="penbprogress" class="progress-bar progress-bar-striped progress-bar-animated" role="progressbar" style="width: 0%;" aria-valuenow="0" aria-valuemin="0" aria-valuemax="100">0%</div>
<div id="penbprogress"
class="progress-bar progress-bar-striped progress-bar-animated"
role="progressbar" style="width: 0%;" aria-valuenow="0" aria-valuemin="0"
aria-valuemax="100">0%</div>
</div>
<div class="d-flex justify-content-between col-12">
@@ -63,7 +69,7 @@
<div>
<span id="penbpercent">0%</span>
</div>
</div>
<div class="d-flex justify-content-between col-12">
<div class="row col-9">
@@ -80,7 +86,10 @@
<div class="card-header font-weight-bold">Keuntungan</div>
<div class="card-body">
<div class="progress mb-2">
<div id="keunprogress" class="progress-bar progress-bar-striped progress-bar-animated" role="progressbar" style="width: 0%;" aria-valuenow="0" aria-valuemin="0" aria-valuemax="100">0%</div>
<div id="keunprogress"
class="progress-bar progress-bar-striped progress-bar-animated"
role="progressbar" style="width: 0%;" aria-valuenow="0" aria-valuemin="0"
aria-valuemax="100">0%</div>
</div>
<div class="d-flex justify-content-between col-12">
@@ -92,7 +101,7 @@
<div>
<span id="keunpercent">0%</span>
</div>
</div>
<div class="d-flex justify-content-between col-12">
<div class="row col-9">
@@ -116,7 +125,7 @@
</div>
</div>
</div>
<div class="card bg-light mb-3 col-4 mr-1">
<span class="font-weight-bold mt-2 mb-2">Penebusan Bulanan</span>
<div class="card-body">
@@ -124,7 +133,7 @@
</div>
</div>
</div>
<div class="card bg-light mb-3 col-4">
<span class="font-weight-bold mt-2 mb-2">Keuntungan Bulanan</span>
<div class="card-body">
@@ -156,7 +165,7 @@
<div class="card bg-light mb-3 col-4">
<div class="card-header font-weight-bold">Penebusan Terkumpul</div>
<div class="card-body">
<div class="row justify-content-center">
<div class="card text-white bg-info mb-3 col-5 mr-2 p-4">
ACTUAL : <span id="penbactualtahunan"></span>
@@ -172,7 +181,7 @@
<div class="card bg-light mb-3 col-4">
<div class="card-header font-weight-bold">Keuntungan Terkumpul</div>
<div class="card-body">
<div class="row justify-content-center">
<div class="card text-white bg-info mb-3 col-5 mr-2 p-4">
ACTUAL : <span id="keunactualtahunan"></span>
@@ -188,6 +197,103 @@
</div>
<div class="mt-3 row">
<div class="card bg-light mb-3 col-4">
<div class="card-header font-weight-bold">Data Sebenar</div>
<div class="card-body">
<table class="table">
<thead class="thead-dark">
<tr>
<th scope="col">Tempoh</th>
<th scope="col">Bil</th>
<th scope="col">RM</th>
</tr>
</thead>
<tbody>
@for($i=0;$i<13;$i++)
<tr>
<td>{{ ($i == 12) ? '12 >' : ($i + 1) }} bulan</td>
<td>{{ number_format($data_sebenar['count'][$i]) }}</td>
<td>{{ number_format($data_sebenar['sum'][$i],2) }}</td>
</tr>
@endfor
</tbody>
<tfoot class="thead-light">
<tr>
<th scope="col">Keseluruhan</th>
<th scope="col">{{ number_format($data_sebenar['count'][13]) }}</th>
<th scope="col">{{ number_format($data_sebenar['sum'][13],2) }}</th>
</tr>
</tfoot>
</table>
</div>
</div>
<div class="card bg-light mb-3 col-4">
<div class="card-header font-weight-bold">Data Lelong</div>
<div class="card-body">
<table class="table">
<table class="table">
<thead class="thead-dark">
<tr>
<th scope="col">Tempoh</th>
<th scope="col">Bil</th>
<th scope="col">RM</th>
</tr>
</thead>
<tbody>
@for($i=0;$i<13;$i++)
<tr>
<td>{{ ($i == 12) ? '12 >' : ($i + 1) }} bulan</td>
<td>{{ number_format($data_lelong['count'][$i]) }}</td>
<td>{{ number_format($data_lelong['sum'][$i],2) }}</td>
</tr>
@endfor
</tbody>
<tfoot class="thead-light">
<tr>
<th scope="col">Keseluruhan</th>
<th scope="col">{{ number_format($data_lelong['count'][13]) }}</th>
<th scope="col">{{ number_format($data_lelong['sum'][13],2) }}</th>
</tr>
</tfoot>
</table>
</div>
</div>
<div class="card bg-light mb-3 col-4">
<div class="card-header font-weight-bold">Data Filter</div>
<div class="card-body">
<table class="table">
<thead class="thead-dark">
<tr>
<th scope="col">Tempoh</th>
<th scope="col">Bil</th>
<th scope="col">RM</th>
</tr>
</thead>
<tbody>
@for($i=0;$i<13;$i++)
<tr>
<td>{{ ($i == 12) ? '12 >' : ($i + 1) }} bulan</td>
<td>{{ number_format($data_filter['count'][$i]) }}</td>
<td>{{ number_format($data_filter['sum'][$i],2) }}</td>
</tr>
@endfor
</tbody>
<tfoot class="thead-light">
<tr>
<th scope="col">Keseluruhan</th>
<th scope="col">{{ number_format($data_filter['count'][13]) }}</th>
<th scope="col">{{ number_format($data_filter['sum'][13],2) }}</th>
</tr>
</tfoot>
</table>
</div>
</div>
</div>
<div class="mt-3 d-flex justify-content-center">
<div class="card bg-light mb-3 col-10">
@@ -199,208 +305,207 @@
</div>
</div>
</div>
</div>
</div>
</div>
</div>
<script>
const d = new Date();
let tahunsemasa = d.getFullYear();
let pusherenv = "{{ env('PUSHER_APP_KEY') }}";
let api_url = "{{ $api_url }}";
const formatter = new Intl.NumberFormat('en-US', {
minimumFractionDigits: 2
minimumFractionDigits: 2
});
var options = {
series: [ {
name: 'Actual',
data: []
}],
chart: {
id: 'pembiayaan-bulanan',
height: 350,
type: 'bar'
},
yaxis: {
labels: {
series: [{
name: 'Actual',
data: []
}],
chart: {
id: 'pembiayaan-bulanan',
height: 350,
type: 'bar'
},
yaxis: {
labels: {
formatter: function (value) {
return 'RM ' + formatter.format(value);
}
},
},
plotOptions: {
bar: {
},
plotOptions: {
bar: {
columnWidth: '60%',
dataLabels: {
position: 'top',
position: 'top',
},
}
},
colors: ['#3498db'],
dataLabels: {
enabled: true,
style: {
colors: ['#333']
},
offsetY: -30,
formatter: function (val, opt) {
let total = ((val - opt.w.globals.seriesGoals[0][opt.dataPointIndex][0]['value']) / opt.w.globals.seriesGoals[0][opt.dataPointIndex][0]['value']) * 100
if(isNaN(total))
{
return 0.00
}else{
if(isFinite(total))
{
if(total == -100)
{
return 0.00
}else{
return total.toFixed(2)
}
}else{
return 0.00
}
}
},
},
legend: {
show: true,
showForSingleSeries: true,
customLegendItems: ['Actual', 'Expected'],
markers: {
fillColors: ['#3498db', '#e74c3c']
}
}
},
colors: ['#3498db'],
dataLabels: {
enabled: true,
style: {
colors: ['#333']
},
offsetY: -30,
formatter: function (val, opt) {
let total = ((val - opt.w.globals.seriesGoals[0][opt.dataPointIndex][0]['value']) / opt.w
.globals.seriesGoals[0][opt.dataPointIndex][0]['value']) * 100
if (isNaN(total)) {
return 0.00
} else {
if (isFinite(total)) {
if (total == -100) {
return 0.00
} else {
return total.toFixed(2)
}
} else {
return 0.00
}
}
},
},
legend: {
show: true,
showForSingleSeries: true,
customLegendItems: ['Actual', 'Expected'],
markers: {
fillColors: ['#3498db', '#e74c3c']
}
}
};
var optionsbilangan = {
series: [{
name: 'Gadai',
data:[]
}, {
name: 'Tebus',
data:[]
}],
chart: {
id: 'bilangan-bulanan',
height: 350,
type: 'bar'
},
plotOptions: {
bar: {
horizontal: false,
columnWidth: '55%',
endingShape: 'rounded',
dataLabels: {
position: 'top',
},
},
},
series: [{
name: 'Gadai',
data: []
}, {
name: 'Tebus',
data: []
}],
chart: {
id: 'bilangan-bulanan',
height: 350,
type: 'bar'
},
plotOptions: {
bar: {
horizontal: false,
columnWidth: '55%',
endingShape: 'rounded',
dataLabels: {
enabled: true,
distributed: true,
style: {
colors: ['#333'],
fontSize: '12px',
fontWeight: 'bold'
},
dropShadow: {
enabled: true,
left: 2,
top: 2,
opacity: 0.5
},
offsetY: -30,
background: {
enabled: true,
foreColor: '#fff',
borderRadius: 2,
padding: 4,
opacity: 0.9,
borderWidth: 1,
borderColor: '#fff'
},
formatter: function (val, opt) {
let total = ((val - opt.w.globals.seriesGoals[0][opt.dataPointIndex][0]['value']) / opt.w.globals.seriesGoals[0][opt.dataPointIndex][0]['value']) * 100
position: 'top',
},
},
if(isNaN(total))
{
return 0.00
}else{
if(isFinite(total))
{
if(total == -100)
{
},
dataLabels: {
enabled: true,
distributed: true,
style: {
colors: ['#333'],
fontSize: '12px',
fontWeight: 'bold'
},
dropShadow: {
enabled: true,
left: 2,
top: 2,
opacity: 0.5
},
offsetY: -30,
background: {
enabled: true,
foreColor: '#fff',
borderRadius: 2,
padding: 4,
opacity: 0.9,
borderWidth: 1,
borderColor: '#fff'
},
formatter: function (val, opt) {
let total = ((val - opt.w.globals.seriesGoals[0][opt.dataPointIndex][0]['value']) / opt.w
.globals.seriesGoals[0][opt.dataPointIndex][0]['value']) * 100
if (isNaN(total)) {
return 0.00
} else {
if (isFinite(total)) {
if (total == -100) {
return 0.00
}else{
} else {
return total.toFixed(2)
}
}else{
return 0.00
}
} else {
return 0.00
}
},
},
stroke: {
show: true,
width: 2,
colors: ['transparent']
},
legend: {
show: true,
showForSingleSeries: true,
customLegendItems: ['Gadai', 'Tebus','Expected'],
markers: {
fillColors: ['#70a1ff', '#7bed9f','#e74c3c']
}
},
yaxis: {
title: {
text: '(Bilangan Orang)'
}
},
fill: {
opacity: 1,
colors: ['#70a1ff', '#7bed9f']
},
tooltip: {
y: {
formatter: function (val) {
},
},
stroke: {
show: true,
width: 2,
colors: ['transparent']
},
legend: {
show: true,
showForSingleSeries: true,
customLegendItems: ['Gadai', 'Tebus', 'Expected'],
markers: {
fillColors: ['#70a1ff', '#7bed9f', '#e74c3c']
}
},
yaxis: {
title: {
text: '(Bilangan Orang)'
}
},
fill: {
opacity: 1,
colors: ['#70a1ff', '#7bed9f']
},
tooltip: {
y: {
formatter: function (val) {
return val + " orang"
}
}
}
}
}
};
var caw = "{{ $cawangan_info['kodcaw'] }}";
//Declaration of Engine --> 0:idle 1:waiting 2:success
var pembbul = 0;penbbul = 0;keunbul = 0;
var pembtah = 0;penbtah = 0;keuntah = 0;
var pembhar = 0;penbhar = 0;keunhar = 0;
var pembbul = 0;
penbbul = 0;
keunbul = 0;
var pembtah = 0;
penbtah = 0;
keuntah = 0;
var pembhar = 0;
penbhar = 0;
keunhar = 0;
var bilangan = 0;
//pusher
var pusher = new Pusher(pusherenv, {
cluster: 'ap1',
encrypted: true
});
var channel = pusher.subscribe('gadai-notify');
channel.bind('trigger-gadai', function(data) {
cluster: 'ap1',
encrypted: true
});
if(pembbul == 0 && pembtah == 0 && pembhar == 0 && bilangan == 0)
{
if(data.cawangan === caw)
{
var channel = pusher.subscribe('gadai-notify');
channel.bind('trigger-gadai', function (data) {
if (pembbul == 0 && pembtah == 0 && pembhar == 0 && bilangan == 0) {
if (data.cawangan === caw) {
CallPembBulanan();
CallPembTahunan();
CallPembToday();
@@ -411,49 +516,45 @@
});
var channel = pusher.subscribe('tebus-notify');
channel.bind('trigger-tebus', function(data) {
if(penbbul == 0 && penbtah == 0 && penbhar == 0 && bilangan == 0)
{
if(data.cawangan === caw)
{
channel.bind('trigger-tebus', function (data) {
if (penbbul == 0 && penbtah == 0 && penbhar == 0 && bilangan == 0) {
if (data.cawangan === caw) {
CallPenbBulanan();
CallPenbTahunan();
CallPenbToday();
CallBilangan();
}
}
}
});
var channel = pusher.subscribe('keuntungan-notify');
channel.bind('trigger-keuntungan', function(data) {
if(keunbul == 0 && keuntah == 0 && keunhar == 0)
{
if(data.cawangan === caw)
{
channel.bind('trigger-keuntungan', function (data) {
if (keunbul == 0 && keuntah == 0 && keunhar == 0) {
if (data.cawangan === caw) {
CallKeunBulanan();
CallKeunTahunan();
CallKeunToday();
CallKeunToday();
}
}
}
});
function CallPembBulanan(){
function CallPembBulanan() {
$.ajax({
method:'get',
method: 'get',
url: api_url + '/admin/pembiayaanBulanan',
datatype:'json',
data:{
datatype: 'json',
data: {
'kodcaw': "{{ $cawangan_info['kodcaw'] }}",
'year' : tahunsemasa
'year': tahunsemasa
},
beforeSend: function() {
beforeSend: function () {
pembbul = 1;
},
success:function(data){
success: function (data) {
pembbul = 2;
datapembiayaan(data);
}
@@ -461,20 +562,20 @@
}
function CallPenbBulanan(){
function CallPenbBulanan() {
$.ajax({
method:'get',
method: 'get',
url: api_url + '/admin/penebusanBulanan',
datatype:'json',
data:{
datatype: 'json',
data: {
'kodcaw': "{{ $cawangan_info['kodcaw'] }}",
'year' : tahunsemasa
'year': tahunsemasa
},
beforeSend: function() {
beforeSend: function () {
penbbul = 1;
},
success:function(data){
success: function (data) {
penbbul = 2;
datapenebusan(data);
}
@@ -482,20 +583,20 @@
}
function CallKeunBulanan(){
function CallKeunBulanan() {
$.ajax({
method:'get',
method: 'get',
url: api_url + '/admin/keuntunganBulanan',
datatype:'json',
data:{
datatype: 'json',
data: {
'kodcaw': "{{ $cawangan_info['kodcaw'] }}",
'year' : tahunsemasa
'year': tahunsemasa
},
beforeSend: function() {
beforeSend: function () {
keunbul = 1;
},
success:function(data){
success: function (data) {
keunbul = 2;
datakeuntungan(data);
}
@@ -503,18 +604,18 @@
}
function CallPembToday(){
function CallPembToday() {
$.ajax({
method:'get',
method: 'get',
url: api_url + '/admin/pembiayaanToday',
datatype:'json',
data:{
datatype: 'json',
data: {
'kodcaw': "{{ $cawangan_info['kodcaw'] }}",
},
beforeSend: function() {
beforeSend: function () {
pembhar = 1;
},
success:function(data){
success: function (data) {
$('#pembharian').text('RM' + formatter.format(data[0].gadaiToday));
$('#pembbajet').text('RM' + formatter.format(data[0].bajetharian.toFixed(2)));
$('#pembpercent').text(data[0].percentDiff.toFixed(2) + '%');
@@ -529,19 +630,19 @@
}
function CallPenbToday(){
function CallPenbToday() {
$.ajax({
method:'get',
method: 'get',
url: api_url + '/admin/penebusanToday',
datatype:'json',
data:{
datatype: 'json',
data: {
'kodcaw': "{{ $cawangan_info['kodcaw'] }}",
},
beforeSend: function() {
beforeSend: function () {
penbhar = 1;
},
success:function(data){
success: function (data) {
$('#penbharian').text('RM' + formatter.format(data[0].tebusToday));
$('#penbbajet').text('RM' + formatter.format(data[0].bajetharian.toFixed(2)));
$('#penbpercent').text(data[0].percentDiff.toFixed(2) + '%');
@@ -555,18 +656,18 @@
});
}
function CallKeunToday(){
function CallKeunToday() {
$.ajax({
method:'get',
method: 'get',
url: api_url + '/admin/keuntunganToday',
datatype:'json',
data:{
datatype: 'json',
data: {
'kodcaw': "{{ $cawangan_info['kodcaw'] }}",
},
beforeSend: function() {
beforeSend: function () {
keunhar = 1;
},
success:function(data){
success: function (data) {
$('#keunharian').text('RM' + formatter.format(data[0].upahToday));
$('#keunbajet').text('RM' + formatter.format(data[0].bajetharian.toFixed(2)));
$('#keunpercent').text(data[0].percentDiff.toFixed(2) + '%');
@@ -580,21 +681,21 @@
});
}
function CallPembTahunan(){
function CallPembTahunan() {
$.ajax({
method:'get',
method: 'get',
url: api_url + '/admin/pembiayaanTahunan',
datatype:'json',
data:{
datatype: 'json',
data: {
'kodcaw': "{{ $cawangan_info['kodcaw'] }}",
'year' : tahunsemasa
'year': tahunsemasa
},
beforeSend: function() {
beforeSend: function () {
pembtah = 1;
},
success:function(data){
success: function (data) {
$('#pembactualtahunan').text('RM' + formatter.format(data[0].total));
$('#pembbajettahunan').text('RM' + formatter.format(data[0].bajet));
pembtah = 0;
@@ -603,22 +704,22 @@
}
function CallPenbTahunan(){
function CallPenbTahunan() {
$.ajax({
method:'get',
method: 'get',
url: api_url + '/admin/penebusanTahunan',
datatype:'json',
data:{
datatype: 'json',
data: {
'kodcaw': "{{ $cawangan_info['kodcaw'] }}",
'year' : tahunsemasa
'year': tahunsemasa
},
beforeSend: function() {
beforeSend: function () {
penbtah = 1;
},
success:function(data){
success: function (data) {
$('#penbactualtahunan').text('RM' + formatter.format(data[0].total));
$('#penbbajettahunan').text('RM' + formatter.format(data[0].bajet));
penbtah = 0;
@@ -626,21 +727,21 @@
});
}
function CallKeunTahunan(){
function CallKeunTahunan() {
$.ajax({
method:'get',
method: 'get',
url: api_url + '/admin/keuntunganTahunan',
datatype:'json',
data:{
datatype: 'json',
data: {
'kodcaw': "{{ $cawangan_info['kodcaw'] }}",
'year' : tahunsemasa
'year': tahunsemasa
},
beforeSend: function() {
beforeSend: function () {
keuntah = 1;
},
success:function(data){
success: function (data) {
$('#keunactualtahunan').text('RM' + formatter.format(data[0].total));
$('#keunbajettahunan').text('RM' + formatter.format(data[0].bajet));
keuntah = 0;
@@ -649,32 +750,32 @@
}
function CallBilangan(){
function CallBilangan() {
$.ajax({
method:'get',
method: 'get',
url: api_url + '/admin/bilangan/gadai',
datatype:'json',
data:{
datatype: 'json',
data: {
'kodcaw': "{{ $cawangan_info['kodcaw'] }}",
'year' : tahunsemasa
'year': tahunsemasa
},
beforeSend: function() {
beforeSend: function () {
bilangan = 1;
},
success:function(datagadai){
success: function (datagadai) {
$.ajax({
method:'get',
method: 'get',
url: api_url + '/admin/bilangan/tebus',
datatype:'json',
data:{
datatype: 'json',
data: {
'kodcaw': "{{ $cawangan_info['kodcaw'] }}",
'year' : tahunsemasa
'year': tahunsemasa
},
success:function(datatebus){
success: function (datatebus) {
bilangan = 2;
bilanganbulanan(datagadai,datatebus);
bilanganbulanan(datagadai, datatebus);
}
});
}
@@ -682,7 +783,7 @@
}
$( document ).ready(function() {
$(document).ready(function () {
CallPembBulanan();
CallPenbBulanan();
@@ -697,46 +798,47 @@
});
function datapembiayaan(datapemb)
{
function datapembiayaan(datapemb) {
let chartpemb = new ApexCharts(document.querySelector("#chartpembiayaan"), options);
chartpemb.render();
chartpemb.updateSeries([{
data: datapemb
}]);
pembbul = 0;pembtah = 0;pembhar = 0;
pembbul = 0;
pembtah = 0;
pembhar = 0;
}
function datapenebusan(datapen)
{
function datapenebusan(datapen) {
var chartpen = new ApexCharts(document.querySelector("#chartpenebusan"), options);
chartpen.render();
chartpen.updateSeries([{
data: datapen
}]);
penbbul = 0;penbtah = 0;penbhar = 0;
penbbul = 0;
penbtah = 0;
penbhar = 0;
}
function datakeuntungan(datakeun)
{
function datakeuntungan(datakeun) {
var charkeun = new ApexCharts(document.querySelector("#chartkeuntungan"), options);
charkeun.render();
charkeun.updateSeries([{
data: datakeun
}]);
keunbul = 0;keuntah = 0;keunhar = 0;
keunbul = 0;
keuntah = 0;
keunhar = 0;
}
function bilanganbulanan(datagadai,datatebus)
{
function bilanganbulanan(datagadai, datatebus) {
var charbil = new ApexCharts(document.querySelector("#chartbilangan"), optionsbilangan);
charbil.render();
charbil.updateSeries(
[
{
[{
name: 'Gadai',
data: datagadai
},
@@ -749,8 +851,6 @@
bilangan = 0;
}
</script>