|
|
|
|
@ -142,7 +142,10 @@ class StatisticsController extends CommonController
|
|
|
|
|
->whereHas("order", function ($query) use ($project_id) {
|
|
|
|
|
$query->where("project_id", $project_id);
|
|
|
|
|
})->sum("money");
|
|
|
|
|
$this_month_balances = Balance::whereRaw("UNIX_TIMESTAMP(`created_at`) >= " . $start_timestamp . " and UNIX_TIMESTAMP(`created_at`) < " . $end_timestamp)->get();
|
|
|
|
|
$this_month_balances = Balance::whereRaw("UNIX_TIMESTAMP(`created_at`) >= " . $start_timestamp . " and UNIX_TIMESTAMP(`created_at`) < " . $end_timestamp)
|
|
|
|
|
->whereHas("order", function ($query) use ($project_id) {
|
|
|
|
|
$query->where("project_id", $project_id);
|
|
|
|
|
})->get();
|
|
|
|
|
|
|
|
|
|
return view($this->urlPrefix . "/overview", compact("project_id", "month", "project", "prev_month_balance", "this_month_balance", "this_month_balances"));
|
|
|
|
|
}
|
|
|
|
|
@ -199,8 +202,20 @@ class StatisticsController extends CommonController
|
|
|
|
|
$month = request()->month ?? date("Y-m");
|
|
|
|
|
$months = $this->_getMonths();
|
|
|
|
|
|
|
|
|
|
$recharges = Recharge::with(["manager", "order", "patient"])->withCount("refunds")->whereNotNull("paid_at")->whereRaw("DATE_FORMAT(`paid_at`,'%Y-%m') = '{$month}'")->get();
|
|
|
|
|
$refunds = Refund::whereNotNull("paid_at")->whereRaw("DATE_FORMAT(`paid_at`,'%Y-%m') = '{$month}'")->get();
|
|
|
|
|
$recharges = Recharge::with(["manager", "order", "patient"])
|
|
|
|
|
->withCount("refunds")
|
|
|
|
|
->whereNotNull("paid_at")
|
|
|
|
|
->whereRaw("DATE_FORMAT(`paid_at`,'%Y-%m') = '{$month}'")
|
|
|
|
|
->whereHas("order", function ($query) use ($project_id) {
|
|
|
|
|
$query->where("project_id", $project_id);
|
|
|
|
|
})
|
|
|
|
|
->get();
|
|
|
|
|
$refunds = Refund::whereNotNull("paid_at")
|
|
|
|
|
->whereRaw("DATE_FORMAT(`paid_at`,'%Y-%m') = '{$month}'")
|
|
|
|
|
->whereHas("order", function ($query) use ($project_id) {
|
|
|
|
|
$query->where("project_id", $project_id);
|
|
|
|
|
})
|
|
|
|
|
->get();
|
|
|
|
|
|
|
|
|
|
return view($this->bladePath . ".finance", compact("recharges", "refunds", "projects", "project_id", "months", "month"));
|
|
|
|
|
}
|
|
|
|
|
|