title = "production/daily-seperate" url = "/production/daily-seperate/:month/:year?" layout = "platform_main" is_hidden = 0 == param("month"); $year = $this->param("year"); if($this["month"] == 'default'){ $this["month"] = $currentDate->month; } $reportDatas = []; $productionDates = Romanah\Gokbakja\Models\production::select('date', 'excruiter_id') ->whereMonth('date', $this["month"]) ->whereYear('date', $currentDate->year) ->with('excruiter') ->groupBy('date') ->groupBy('excruiter_id') ->orderBy('date', 'ASC') ->distinct() ->get(); for ($x = 0; $x < count($productionDates); $x++) { $sumDiff = Romanah\Gokbakja\Models\ProductionCalculate::where('date', $productionDates[$x]->date)->where('excruiter_id', $productionDates[$x]->excruiter_id); $sumDiff2 = Romanah\Gokbakja\Models\ProductionCalculate::where('date', $productionDates[$x]->date)->where('excruiter_id', $productionDates[$x]->excruiter_id); //dd($lastId1); $shift1 = $sumDiff->where('shift_id', 1)->sum('amount_calc'); $shift2 = $sumDiff2->where('shift_id', 2)->sum('amount_calc'); $reportDatas[$x]["date"] = $productionDates[$x]->date; $reportDatas[$x]["shift1"] = $shift1; $reportDatas[$x]["shift2"] = $shift2; $reportDatas[$x]["extrudor"] = $productionDates[$x]->excruiter->name; $reportDatas[$x]["all_shift_calc"] = ($shift1 + $shift2); $products_all = $sumDiff->with('product')->groupBy('product_id')->get(); for ($xx = 0; $xx < count($products_all); $xx++) { $sumDiffq = Romanah\Gokbakja\Models\ProductionCalculate::whereDate('date', $productionDates[$x]->date)->where('shift_id', 1)->where('excruiter_id', $productionDates[$x]->excruiter_id); $sumDiff2q = Romanah\Gokbakja\Models\ProductionCalculate::whereDate('date', $productionDates[$x]->date)->where('shift_id', 2)->where('excruiter_id', $productionDates[$x]->excruiter_id); $products_amount1 = $sumDiffq->where('product_id', $products_all[$xx]->product_id)->sum('amount_calc'); $products_amount2 = $sumDiff2q->where('product_id', $products_all[$xx]->product_id)->sum('amount_calc'); $reportDatas[$x]["products_shift1"][$xx]["product_code"] = $products_all[$xx]->product->code; $reportDatas[$x]["products_shift1"][$xx]["product_value"] = $products_amount1; $reportDatas[$x]["products_shift2"][$xx]["product_code"] = $products_all[$xx]->product->code; $reportDatas[$x]["products_shift2"][$xx]["product_value"] = $products_amount2; } $reportDatas[$x]["count_change1"] = $sumDiff->where('shift_id', 1)->groupBy('product_id')->count(); $reportDatas[$x]["count_change2"] = $sumDiff2->where('shift_id', 2)->groupBy('product_id')->count(); } $this["reportDatas"] = $reportDatas; //dd($reportDatas); if($year){ }else{ $reportDatas = []; } } ?> == {% put styles %} {% endput %}