g_sto/themes/gokbakja/partials/report/product-month-row.htm

52 lines
1.5 KiB
HTML
Raw Normal View History

2023-09-19 19:52:14 +00:00
[viewBag]
==
<?php
function onStart (){
$year = $this->param("year");
$prodId = $this->prodId;
$currentDate = Carbon\Carbon::now()->timezone('UTC +05:00');
2023-10-11 22:11:21 +00:00
$allAmount = $this->all_amount;
2023-09-19 19:52:14 +00:00
if($year){
2023-10-11 22:11:21 +00:00
$amountCalc = Romanah\Gokbakja\Models\PivotProduction::where('product_id', $prodId)
->whereMonth('created_at', $this["month"])
->whereYear('created_at', $year)
->orderBy('id', 'DESC')
->first();
if ($amountCalc != null){
$this["pivot_calc"] = (float) ($amountCalc->amount_percentage / 100) * (float) $allAmount;
$this["percentageCalc"] = (float) $amountCalc->amount_percentage;
}else{
$this["pivot_calc"] = 0;
}
2023-09-19 19:52:14 +00:00
}else{
2023-10-11 22:11:21 +00:00
$amountCalc = Romanah\Gokbakja\Models\PivotProduction::where('product_id', $prodId)
->whereMonth('created_at', $this["month"])
->whereYear('created_at', $currentDate->year)
->orderBy('id', 'DESC')
->first();
if ($amountCalc != null){
$this["pivot_calc"] = (float) ($amountCalc->amount_percentage / 100) * (float) $allAmount;
$this["percentageCalc"] = (float) $amountCalc->amount_percentage;
}else{
$this["pivot_calc"] = 0;
}
2023-09-19 19:52:14 +00:00
}
}
?>
==
<td style="text-align: center;">
<span class="badge badge-soft-info"
2023-10-11 22:11:21 +00:00
style="font-size: 14px;">{{pivot_calc|number_format}} kg</span>
2023-09-19 19:52:14 +00:00
</td>