| Current Path : /var/www/html/crowdfunding/backend/views/report/ |
| Current File : /var/www/html/crowdfunding/backend/views/report/report4.php |
<?php
use yii\helpers\Html;
use yii\grid\GridView;
use yii\helpers\ArrayHelper;
use yii\data\ActiveDataProvider;
use backend\modules\campaign\models\Campaign;
use backend\modules\payment\models\Payment;
use backend\modules\payment\models\PaymentOtherChannel;
$this->title = Yii::t('app', 'Dashboard Zakat Collected');
$this->params['breadcrumbs'][] = $this->title;
?>
<script src='/assets/portal/js/highcharts/highcharts.js'></script>
<script src='/assets/portal/js/highcharts/series-label.js'></script>
<script src='/assets/portal/js/highcharts/exporting.js'></script>
<script src='/assets/portal/js/highcharts/export-data.js'></script>
<script src='/assets/portal/js/highcharts/accessibility.js'></script>
<style>
.highcharts-title{
font-family : inherit !important;
line-height : 1.5 !important;
font-size : 14px !important;
}
</style>
<div class="wrapper wrapper-content">
<div class="row">
<div class="col-sm-4">
<div class="ibox">
<div class="ibox-content">
<?php
$total_online = Payment::find()->andwhere(['=', 'payment.payment_status', 'verified'])->sum('payment_total');
if ($total_online > 0)
$total_online = $total_online / 100;
else
$total_online = 0;
$total_other = PaymentOtherChannel::find()->sum('channel_total_paid');
$total_radiuz = Campaign::getcollectedradiuzall();
?>
<div id="chart_by_channel" style="height:300px;"></div>
<script>
Highcharts.chart('chart_by_channel', {
chart: {type: 'pie'},
title: {text: 'CROWDZAKAT Collected by Channel'},
subtitle: {text: ''},
credits: {enabled: false},
tooltip: {
useHTML: true,
formatter: function () {
return this.point.name + '<br>RM ' + Highcharts.numberFormat(this.y, 2, '.', ',');
}
},
plotOptions: {
pie: {
allowPointSelect: true,
cursor: 'pointer',
dataLabels: {
enabled: true,
color: '#000000',
connectorColor: '#000000',
formatter: function () {
return this.point.name;
}
}
}
},
series: [{
name: 'Zakat Collected',
colorByPoint: true,
data: [
{name: 'CROWDZAKAT Online Payment', y:<?= $total_online ?>},
{name: 'CROWDZAKAT Other Channel', y: <?= $total_other ?>},
{name: 'RADIUZ Online Payment', y: <?= $total_radiuz ?>},
]
}]
});
</script>
</div>
</div>
</div>
<div class="col-sm-4">
<div class="ibox">
<div class="ibox-content">
<?php
$category_list = "";
$category_zakat = "";
$category_arr = ArrayHelper::map((new \yii\db\Query())
->from('ref')
->where(['=', 'cat', 'CAMPAIGN_CAT'])
->orderBy(['descr' => SORT_ASC])
->all(), 'code', 'descr');
if (!empty($category_arr)) {
foreach ($category_arr as $category_code => $category_label) {
$category_list .= "'" . $category_label . "',";
$total_online2 = Payment::find()
->innerJoin('campaign_donor', 'campaign_donor.donor_payment_id=payment.payment_id')
->innerJoin('campaign', 'campaign.campaign_id=campaign_donor.donor_campaign_id')
->where(['=', 'campaign.campaign_approval_status', 'approve'])
->andwhere(['=', 'campaign.campaign_cat', $category_code])
->andwhere(['=', 'payment.payment_status', 'verified'])
->sum('donor_amount');
$total_other2 = PaymentOtherChannel::find()
->innerJoin('campaign', 'campaign.campaign_id=channel_campaign_id')
->where(['=', 'campaign.campaign_cat', $category_code])
->sum('channel_total_paid');
$campaign_arr = ArrayHelper::map(
(new \yii\db\Query())
->from('campaign')
->where(['=', 'campaign_status', 'active'])
->andwhere(['=', 'campaign_cat', $category_code])
->all(), 'campaign_id', 'campaign_title');
$campaign_id_array = implode(",", array_keys($campaign_arr));
$total_radiuz2 = Campaign::getcollectedradiuzbymultiplecampaign($campaign_id_array);
$category_zakat_collected = $total_online2 + $total_other2 + $total_radiuz2;
$category_zakat .= $category_zakat_collected . ",";
}
}
?>
<div id="chart_by_category" style="height:300px;"></div>
<script>
Highcharts.chart('chart_by_category', {
chart: {
type: 'bar'
},
title: {text: 'CROWDZAKAT Collected by Program Category', },
subtitle: {text: ''},
xAxis: {
categories: [<?= $category_list ?>],
crosshair: true,
},
yAxis: {
min: 0,
title: {
text: false
}
},
tooltip: {
useHTML: true,
formatter: function () {
return this.x + '<br>RM ' + Highcharts.numberFormat(this.y, 2, '.', ',');
}
},
credits: {enabled: false},
legend: {enabled: false},
plotOptions: {
bar: {
colorByPoint: true,
pointPadding: 0.2,
borderWidth: 0
},
series: {
dataLabels: {
enabled: true,
color: '#000',
style: {fontWeight: 'bolder'},
formatter: function () {
return 'RM ' + Highcharts.numberFormat(this.y, 2, '.', ',');
},
},
pointPadding: 0.1,
groupPadding: 0
}
},
colors: [
'#8085e9', '#f15c80', '#e4d354', '#2b908f', '#f45b5b', '#91e8e1', '#7cb5ec', '#434348', '#90ed7d', '#f7a35c',
],
series: [
{
name: 'Category',
data: [<?= $category_zakat; ?>]
},
]
});
</script>
</div>
</div>
</div>
<div class="col-sm-4">
<div class="ibox">
<div class="ibox-content">
<?php
$asnaf_list = "";
$asnaf_zakat = "";
$asnaf_arr = ArrayHelper::map((new \yii\db\Query())
->from('ref')
->where(['=', 'cat', 'ASNAF_LIST'])
->orderBy(['descr' => SORT_ASC])
->all(), 'code', 'descr');
if (!empty($asnaf_arr)) {
foreach ($asnaf_arr as $asnaf_code => $asnaf_label) {
$asnaf_list .= "'" . $asnaf_label . "',";
$total_online3 = Payment::find()
->innerJoin('campaign_donor', 'campaign_donor.donor_payment_id=payment.payment_id')
->innerJoin('campaign', 'campaign.campaign_id=campaign_donor.donor_campaign_id')
->where(['=', 'campaign.campaign_approval_status', 'approve'])
->andwhere(['LIKE', 'campaign.campaign_cat_asnaf', '"' . $asnaf_code . '"'])
->andwhere(['=', 'payment.payment_status', 'verified'])
->sum('donor_amount');
$total_other3 = PaymentOtherChannel::find()
->innerJoin('campaign', 'campaign.campaign_id=channel_campaign_id')
->andwhere(['LIKE', 'campaign.campaign_cat_asnaf', '"' . $asnaf_code . '"'])
->sum('channel_total_paid');
$campaign_arr2 = ArrayHelper::map(
(new \yii\db\Query())
->from('campaign')
->where(['=', 'campaign_status', 'active'])
->andwhere(['LIKE', 'campaign.campaign_cat_asnaf', '"' . $asnaf_code . '"'])
->all(), 'campaign_id', 'campaign_title');
$campaign_id_array2 = implode(",", array_keys($campaign_arr2));
$total_radiuz3 = Campaign::getcollectedradiuzbymultiplecampaign($campaign_id_array2);
$asnaf_zakat_collected = $total_online3 + $total_other3 + $total_radiuz3;
$asnaf_zakat .= $asnaf_zakat_collected . ",";
}
}
?>
<div id="chart_by_asnaf" style="height:300px;"></div>
<script>
Highcharts.chart('chart_by_asnaf', {
chart: {
type: 'column'
},
title: {text: 'CROWDZAKAT Collected by Asnaf Type', },
subtitle: {text: ''},
xAxis: {
categories: [<?= $asnaf_list ?>],
crosshair: true,
},
yAxis: {
min: 0,
title: {
text: false
}
},
tooltip: {
useHTML: true,
formatter: function () {
return this.x + '<br>RM ' + Highcharts.numberFormat(this.y, 2, '.', ',');
}
},
credits: {enabled: false},
legend: {enabled: false},
plotOptions: {
column: {
colorByPoint: true,
pointPadding: 0.2,
borderWidth: 0
},
series: {
dataLabels: {
enabled: true,
color: '#000',
style: {fontWeight: 'bolder'},
formatter: function () {
return 'RM ' + Highcharts.numberFormat(this.y, 2, '.', ',');
},
},
pointPadding: 0.1,
groupPadding: 0
}
},
colors: [
'#7cb5ec', '#434348', '#90ed7d', '#f7a35c', '#8085e9', '#f15c80', '#e4d354', '#2b908f', '#f45b5b','#91e8e1',
],
series: [
{
name: 'Asnaf',
data: [<?= $asnaf_zakat; ?>]
},
]
});
</script>
</div>
</div>
</div>
</div>
<div class="ibox">
<div class="ibox-content">
<?php
$program_list = "";
$program_zakat = "";
$program_arr = ArrayHelper::map(
(new \yii\db\Query())
->from('campaign')
->where(['=', 'campaign_status', 'active'])
->orderBy(['campaign_title' => SORT_ASC])
->all(), 'campaign_id', 'campaign_title');
if (!empty($program_arr)) {
foreach ($program_arr as $program_id => $program_title) {
$program_list .= "'" . $program_title . "',";
$total_collected_crowdzakat = Campaign::getcollectedcrowdzakat($program_id);
$total_collected_radiuz = Campaign::getcollectedradiuz($program_id);
$total_collected_others = Campaign::getcollectedotherchannel($program_id);
$total_collected = $total_collected_crowdzakat + $total_collected_radiuz + $total_collected_others;
if (!empty($total_collected))
$program_zakat_collected = $total_collected;
else
$program_zakat_collected = 0;
$program_zakat .= $program_zakat_collected . ",";
}
}
?>
<div id="chart_by_program" style="height:300px;"></div>
<script>
Highcharts.chart('chart_by_program', {
chart: {
type: 'column'
},
title: {text: 'CROWDZAKAT Collected by Program', },
subtitle: {text: ''},
xAxis: {
categories: [<?= $program_list ?>],
crosshair: true,
},
yAxis: {
min: 0,
title: {
text: false
}
},
tooltip: {
useHTML: true,
formatter: function () {
return this.x + '<br>RM ' + Highcharts.numberFormat(this.y, 2, '.', ',');
}
},
credits: {enabled: false},
legend: {enabled: false},
plotOptions: {
column: {
pointPadding: 0.2,
borderWidth: 0,
colorByPoint: true,
},
series: {
dataLabels: {
enabled: true,
color: '#000',
style: {fontWeight: 'bolder'},
formatter: function () {
return 'RM ' + Highcharts.numberFormat(this.y, 2, '.', ',');
},
},
pointPadding: 0.1,
groupPadding: 0
}
},
colors: [
'#90ed7d', '#f7a35c', '#8085e9', '#f15c80', '#e4d354', '#2b908f', '#f45b5b', '#91e8e1', '#7cb5ec', '#434348',
],
series: [
{
name: 'Program',
data: [<?= $program_zakat; ?>]
},
]
});
</script>
</div>
</div>
<div class="row">
<div class="col-sm-4">
<div class="ibox">
<div class="ibox-content">
<?php
$year_list = "";
$year_zakat = "";
$year_arr = ArrayHelper::map((new \yii\db\Query())
->from('ref')
->where(['=', 'cat', 'ZAKATYEAR'])
->orderBy(['code' => SORT_DESC])
->all(), 'code', 'descr_en');
if (!empty($year_arr)) {
foreach ($year_arr as $year_code => $year_label) {
$year_list .= "'" . $year_label . "',";
$year_zakat_collected = (new \yii\db\Query())
->from('payment')
->where(['=', 'payment_status', 'verified'])
->andwhere(['=', 'payment_zakat_year', $year_code])
->sum('payment_total');
if (!empty($year_zakat_collected))
$year_zakat_collected = $year_zakat_collected / 100;
else
$year_zakat_collected = 0;
$year_zakat .= $year_zakat_collected . ",";
}
}
?>
<div id="chart_by_year" style="height:300px;"></div>
<script>
Highcharts.chart('chart_by_year', {
chart: {
type: 'bar'
},
title: {text: 'CROWDZAKAT Collected by Zakat Year', },
subtitle: {text: ''},
xAxis: {
categories: [<?= $year_list ?>],
crosshair: true,
},
yAxis: {
min: 0,
title: {
text: false
}
},
tooltip: {
useHTML: true,
formatter: function () {
return this.x + '<br>RM ' + Highcharts.numberFormat(this.y, 2, '.', ',');
}
},
credits: {enabled: false},
legend: {enabled: false},
plotOptions: {
bar: {
colorByPoint: true,
pointPadding: 0.2,
borderWidth: 0
},
series: {
dataLabels: {
enabled: true,
color: '#000',
style: {fontWeight: 'bolder'},
formatter: function () {
return 'RM ' + Highcharts.numberFormat(this.y, 2, '.', ',');
},
},
pointPadding: 0.1,
groupPadding: 0
}
},
colors: [
'#8085e9', '#f15c80', '#e4d354', '#2b908f', '#f45b5b', '#91e8e1', '#7cb5ec', '#434348', '#90ed7d', '#f7a35c',
],
series: [
{
name: 'Zakat Year',
data: [<?= $year_zakat; ?>]
},
]
});
</script>
</div>
</div>
</div>
<div class="col-sm-4">
<div class="ibox">
<div class="ibox-content">
<?php
$zakattype_list = "";
$zakattype_arr = ArrayHelper::map((new \yii\db\Query())
->from('ref')
->where(['=', 'cat', 'ZAKATTYPE'])
->orderBy(['sort' => SORT_DESC])
->all(), 'code', 'descr_en');
if (!empty($zakattype_arr)) {
foreach ($zakattype_arr as $zakattype_code => $zakattype_label) {
$total_zakattype_collected = (new \yii\db\Query())
->from('payment')
->where(['=', 'payment_status', 'verified'])
->andwhere(['=', 'payment_zakat_type', $zakattype_code])
->sum('payment_total');
if (!empty($total_zakattype_collected))
$total_zakattype_collected = $total_zakattype_collected / 100;
else
$total_zakattype_collected = 0;
$zakattype_list .= "{name: '" . $zakattype_label . "',y: " . $total_zakattype_collected . "},";
}
}
?>
<div id="chart_by_zakattype" style="height:300px;"></div>
<script>
Highcharts.chart('chart_by_zakattype', {
chart: {type: 'pie'},
title: {text: 'CROWDZAKAT Collected by Zakat Type'},
subtitle: {text: ''},
credits: {enabled: false},
tooltip: {
useHTML: true,
formatter: function () {
return this.point.name + '<br>RM ' + Highcharts.numberFormat(this.y, 2, '.', ',');
}
},
plotOptions: {
pie: {
allowPointSelect: true,
cursor: 'pointer',
dataLabels: {
enabled: false,
color: '#000000',
connectorColor: '#000000',
formatter: function () {
return '<b>' + this.point.name + '</b>: ' + this.percentage + ' clicks';
}
}
}
},
series: [{
name: 'Zakat Collected',
colorByPoint: true,
data: [<?= $zakattype_list; ?>]
}]
});
</script>
</div>
</div>
</div>
<div class="col-sm-4">
<div class="ibox">
<div class="ibox-content">
<?php
$identification_list = "";
$identification_zakat = "";
$identification_arr = ArrayHelper::map((new \yii\db\Query())
->from('ref')
->where(['=', 'cat', 'IDTYPE'])
->orderBy(['sort' => SORT_ASC])
->all(), 'code', 'descr_en');
if (!empty($identification_arr)) {
foreach ($identification_arr as $identification_code => $identification_label) {
$identification_list .= "'" . $identification_label . "',";
$identification_zakat_collected = (new \yii\db\Query())
->from('payment')
->where(['=', 'payment_status', 'verified'])
->andwhere(['=', 'payment_payer_id_type', $identification_code])
->sum('payment_total');
if (!empty($identification_zakat_collected))
$identification_zakat_collected = $identification_zakat_collected / 100;
else
$identification_zakat_collected = 0;
$identification_zakat .= $identification_zakat_collected . ",";
}
}
?>
<div id="chart_by_identification" style="height:300px;"></div>
<script>
Highcharts.chart('chart_by_identification', {
chart: {
type: 'column'
},
title: {text: 'CROWDZAKAT Collected by Identification Type', },
subtitle: {text: ''},
xAxis: {
categories: [<?= $identification_list ?>],
crosshair: true,
},
yAxis: {
min: 0,
title: {
text: false
}
},
tooltip: {
useHTML: true,
formatter: function () {
return this.x + '<br>RM ' + Highcharts.numberFormat(this.y, 2, '.', ',');
}
},
credits: {enabled: false},
legend: {enabled: false},
plotOptions: {
column: {
pointPadding: 0.2,
borderWidth: 0,
colorByPoint: true,
},
series: {
dataLabels: {
enabled: true,
color: '#000',
style: {fontWeight: 'bolder'},
formatter: function () {
return 'RM ' + Highcharts.numberFormat(this.y, 2, '.', ',');
},
},
pointPadding: 0.1,
groupPadding: 0
}
},
colors: ['#f7a35c', '#90ed7d', '#8085e9', ],
series: [
{
name: 'Identification Type',
data: [<?= $identification_zakat; ?>]
},
]
});
</script>
</div>
</div>
</div>
</div>
</div>