title = "actions/rulon-report" url = "/actions/rulon-report/:month/:year?" layout = "platform_main" is_hidden = 0 == param("month"); $year = $this->param("year"); if($this["month"] == 'default'){ $this["month"] = $currentDate->month; } //dd($reportDatas); if($year){ $reportDatas = []; $rulonProds = Romanah\Gokbakja\Models\ProductionMachine::select('gram', 'width') ->whereMonth('date', $this["month"]) ->whereYear('date', $year) ->groupBy('gram')->groupBy('width') ->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){ $qq->where('gram', $rulonProds[$x]->gram)->where('width', $rulonProds[$x]->width)->whereYear('date', $year)->whereMonth('date', $this["month"]); }) ->sum('amount'); $actionIn = Romanah\Gokbakja\Models\RulonAction::select('romanah_gokbakja_rulon_action.*') ->with('product') ->where('type', 'inbox') ->whereHas('product', function($qq) use($rulonProds, $x){ $qq->where('gram', $rulonProds[$x]->gram)->where('width', $rulonProds[$x]->width)->whereYear('date', $year)->whereMonth('date', $this["month"]); }) ->sum('amount'); $actionOut = Romanah\Gokbakja\Models\RulonAction::select('romanah_gokbakja_rulon_action.*') ->with('product') ->where('type', 'outbox') ->whereHas('product', function($qq) use($rulonProds, $x){ $qq->where('gram', $rulonProds[$x]->gram)->where('width', $rulonProds[$x]->width)->whereYear('date', $year)->whereMonth('date', $this["month"]); }) ->sum('amount'); $reportDatas[$x]["gram"] = $rulonProds[$x]->gram; $reportDatas[$x]["width"] = $rulonProds[$x]->width; $reportDatas[$x]["start_month"] = $action; $reportDatas[$x]["in"] = $actionIn; $reportDatas[$x]["out"] = $actionOut; } $this['reportDatas'] = $reportDatas; }else{ $reportDatas = []; $rulonProds = Romanah\Gokbakja\Models\ProductionMachine::select('gram', 'width') ->whereMonth('created_at', $this["month"]) ->whereYear('created_at', $currentDate->year) ->groupBy('gram')->groupBy('width') ->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, $currentDate){ $qq->where('gram', $rulonProds[$x]->gram)->where('width', $rulonProds[$x]->width)->whereYear('date', $currentDate->year)->whereMonth('date', $this["month"]); }) ->sum('amount'); $actionIn = Romanah\Gokbakja\Models\RulonAction::select('romanah_gokbakja_rulon_action.*') ->with('product') ->where('type', 'inbox') ->whereHas('product', function($qq) use($rulonProds, $x, $currentDate){ $qq->where('gram', $rulonProds[$x]->gram)->where('width', $rulonProds[$x]->width)->whereYear('date', $currentDate->year)->whereMonth('date', $this["month"]); }) ->sum('amount'); $actionOut = Romanah\Gokbakja\Models\RulonAction::select('romanah_gokbakja_rulon_action.*') ->with('product') ->where('type', 'outbox') ->whereHas('product', function($qq) use($rulonProds, $x, $currentDate){ $qq->where('gram', $rulonProds[$x]->gram)->where('width', $rulonProds[$x]->width)->whereYear('date', $currentDate->year)->whereMonth('date', $this["month"]); }) ->sum('amount'); $reportDatas[$x]["gram"] = $rulonProds[$x]->gram; $reportDatas[$x]["width"] = $rulonProds[$x]->width; $reportDatas[$x]["start_month"] = $action; $reportDatas[$x]["in"] = $actionIn; $reportDatas[$x]["out"] = $actionOut; } $this['reportDatas'] = $reportDatas; } } ?> == {% put styles %} {% endput %}

Aýlar Boýunça {{year}}

{% partial 'dataTableJs' %}