rulon report

This commit is contained in:
Shohrat 2023-12-27 17:33:49 +05:00
parent 379ee8bf07
commit c370c735e8
1 changed files with 57 additions and 40 deletions

View File

@ -21,32 +21,23 @@ function onStart() {
if($year){
$startDateOfYear = Carbon\Carbon::now()->startOfYear();
$formattedStartDateYear = $startDateOfYear->format('Y-m-d');
$startDate = Carbon\Carbon::create($year, $this["month"], 1);
$endDate = $startDate->endOfMonth();
$formattedStartDate = $startDate->format('Y-m-d');
$formattedEndDate = $endDate->format('Y-m-d');
$endMonthDate = $startDate->endOfMonth();
$formattedEndDate = $endMonthDate->format('Y-m-d');
$reportDatas = [];
//dd($action);
//$action = Romanah\Gokbakja\Models\RulonAction::select('romanah_gokbakja_rulon_action.*')
//->join('romanah_gokbakja_production_machine', 'romanah_gokbakja_rulon_action.product_id', 'romanah_gokbakja_production_machine.id')
//->where('romanah_gokbakja_production_machine.date', '<', $formattedStartDate)
//->addSelect('romanah_gokbakja_production_machine.width', 'romanah_gokbakja_production_machine.gram')
//->groupBy('romanah_gokbakja_production_machine.width')
//->groupBy('romanah_gokbakja_production_machine.gram')
//->addSelect(DB::raw('SUM(romanah_gokbakja_rulon_action.amount) as startDateSum'))
//->orderBy('romanah_gokbakja_production_machine.width', 'ASC')
//->get()->toArray();
$rulonProds = Romanah\Gokbakja\Models\ProductionMachine::select('gram', 'width')
->whereMonth('date', $this["month"])
->whereYear('date', $year)
->groupBy('gram')->groupBy('width')
->orderBy('gram', 'ASC')
->orderBy('width', 'ASC')
->distinct()
->get();
@ -54,17 +45,23 @@ function onStart() {
for ($x = 0; $x < count($rulonProds); $x++) {
$action = Romanah\Gokbakja\Models\RulonAction::select('romanah_gokbakja_rulon_action.*')
->with('product')
->whereHas('product', function($qq) use($rulonProds, $x, $formattedStartDate, $formattedEndDate){
$qq->where('gram', $rulonProds[$x]->gram)->where('width', $rulonProds[$x]->width)->where('date', '<', $formattedStartDate);
})
->sum('amount');
->with('product')
->whereHas('product', function($qq) use($rulonProds, $x, $formattedStartDateYear, $formattedStartDate){
$qq->where('gram', $rulonProds[$x]->gram)
->where('width', $rulonProds[$x]->width)
->whereBetween('date', [$formattedStartDateYear, $formattedStartDate]);
})
->sum('amount');
//dd($rulonProds[$x]->width);
$endAction = Romanah\Gokbakja\Models\RulonAction::select('romanah_gokbakja_rulon_action.*')
->with('product')
->whereHas('product', function($qq) use($rulonProds, $x, $formattedStartDate, $formattedEndDate){
$qq->where('gram', $rulonProds[$x]->gram)->where('width', $rulonProds[$x]->width)->where('date', '<', $formattedStartDate);
->whereHas('product', function($qq) use($rulonProds, $x, $formattedStartDateYear, $formattedEndDate){
$qq->where('gram', $rulonProds[$x]->gram)
->where('width', $rulonProds[$x]->width)
->whereBetween('date', [$formattedStartDateYear, $formattedEndDate]);
})
->sum('amount');
@ -73,7 +70,9 @@ function onStart() {
->with('product')
->where('type', 'inbox')
->whereHas('product', function($qq) use($rulonProds, $x, $year, $formattedStartDate, $formattedEndDate){
$qq->where('gram', $rulonProds[$x]->gram)->where('width', $rulonProds[$x]->width)->where('date', '<', $formattedStartDate);
$qq->where('gram', $rulonProds[$x]->gram)
->where('width', $rulonProds[$x]->width)
->whereBetween('date', [$formattedStartDate, $formattedEndDate]);
})
->sum('amount');
@ -82,7 +81,9 @@ function onStart() {
->with('product')
->where('type', 'outbox')
->whereHas('product', function($qq) use($rulonProds, $x, $year, $formattedStartDate, $formattedEndDate){
$qq->where('gram', $rulonProds[$x]->gram)->where('width', $rulonProds[$x]->width)->where('date', '>', $formattedEndDate);
$qq->where('gram', $rulonProds[$x]->gram)
->where('width', $rulonProds[$x]->width)
->whereBetween('date', [$formattedStartDate, $formattedEndDate]);
})
->sum('amount');
@ -99,11 +100,14 @@ function onStart() {
$this['reportDatas'] = $reportDatas;
}else{
$startDate = Carbon\Carbon::create($year, $this["month"], 1);
$endDate = $startDate->endOfMonth();
$startDateOfYear = Carbon\Carbon::now()->startOfYear();
$formattedStartDateYear = $startDateOfYear->format('Y-m-d');
$startDate = Carbon\Carbon::create($currentDate->year, $this["month"], 1);
$formattedStartDate = $startDate->format('Y-m-d');
$formattedEndDate = $endDate->format('Y-m-d');
$endMonthDate = $startDate->endOfMonth();
$formattedEndDate = $endMonthDate->format('Y-m-d');
$reportDatas = [];
@ -111,24 +115,33 @@ function onStart() {
->whereMonth('date', $this["month"])
->whereYear('date', $currentDate->year)
->groupBy('gram')->groupBy('width')
->orderBy('gram', 'ASC')
->orderBy('width', 'ASC')
->distinct()
->get();
for ($x = 0; $x < count($rulonProds); $x++) {
$action = Romanah\Gokbakja\Models\RulonAction::select('romanah_gokbakja_rulon_action.*')
->with('product')
->whereHas('product', function($qq) use($rulonProds, $x, $formattedStartDate, $formattedEndDate){
$qq->where('gram', $rulonProds[$x]->gram)->where('width', $rulonProds[$x]->width)->where('date', '<', $formattedStartDate);
})
->sum('amount');
->with('product')
->whereHas('product', function($qq) use($rulonProds, $x, $formattedStartDateYear, $formattedStartDate){
$qq->where('gram', $rulonProds[$x]->gram)
->where('width', $rulonProds[$x]->width)
->whereBetween('date', [$formattedStartDateYear, $formattedStartDate]);
})
->sum('amount');
//dd($rulonProds[$x]->width);
$endAction = Romanah\Gokbakja\Models\RulonAction::select('romanah_gokbakja_rulon_action.*')
->with('product')
->whereHas('product', function($qq) use($rulonProds, $x, $formattedStartDate, $formattedEndDate){
$qq->where('gram', $rulonProds[$x]->gram)->where('width', $rulonProds[$x]->width)->where('date', '>', $formattedEndDate);
->whereHas('product', function($qq) use($rulonProds, $x, $formattedStartDateYear, $formattedEndDate){
$qq->where('gram', $rulonProds[$x]->gram)
->where('width', $rulonProds[$x]->width)
->whereBetween('date', [$formattedStartDateYear, $formattedEndDate]);
})
->sum('amount');
@ -137,7 +150,9 @@ function onStart() {
->with('product')
->where('type', 'inbox')
->whereHas('product', function($qq) use($rulonProds, $x, $year, $formattedStartDate, $formattedEndDate){
$qq->where('gram', $rulonProds[$x]->gram)->where('width', $rulonProds[$x]->width)->where('date', '<', $formattedStartDate);
$qq->where('gram', $rulonProds[$x]->gram)
->where('width', $rulonProds[$x]->width)
->whereBetween('date', [$formattedStartDate, $formattedEndDate]);
})
->sum('amount');
@ -146,7 +161,9 @@ function onStart() {
->with('product')
->where('type', 'outbox')
->whereHas('product', function($qq) use($rulonProds, $x, $year, $formattedStartDate, $formattedEndDate){
$qq->where('gram', $rulonProds[$x]->gram)->where('width', $rulonProds[$x]->width)->where('date', '>', $formattedEndDate);
$qq->where('gram', $rulonProds[$x]->gram)
->where('width', $rulonProds[$x]->width)
->whereBetween('date', [$formattedStartDate, $formattedEndDate]);
})
->sum('amount');
@ -255,10 +272,10 @@ function onStart() {
<td style="font-weight: bold;">{{key + 1}}</td>
<td><a href="#" style="font-weight: bold;">{{report.gram}}</a></td>
<td>{{report.width}}</td>
<td>{{report.start_month}}</td>
<td style="color: darkgreen;">{{report.in}}</td>
<td style="color: darkred;">{{report.out}}</td>
<td>{{report.end_month}}</td>
<td>{{report.start_month|number_format(2)}}</td>
<td style="color: darkgreen;">{{report.in|number_format(2)}}</td>
<td style="color: darkred;">{{report.out == 0 ? '' : report.out|number_format(2)}}</td>
<td>{{report.end_month|number_format(2)}}</td>
</tr>
{% endfor %}