|
|
|
|
@ -17,6 +17,7 @@ use App\Models\Project;
|
|
|
|
|
use Illuminate\Http\Request;
|
|
|
|
|
use Illuminate\Support\Facades\DB;
|
|
|
|
|
use Maatwebsite\Excel\Facades\Excel;
|
|
|
|
|
use Spatie\Permission\Models\Role;
|
|
|
|
|
|
|
|
|
|
class OrdersController extends CommonController
|
|
|
|
|
{
|
|
|
|
|
@ -43,22 +44,27 @@ class OrdersController extends CommonController
|
|
|
|
|
$this->model = $this->model->whereRaw("UNIX_TIMESTAMP(`created_at`) >= " . $start_timestamp . " and UNIX_TIMESTAMP(`created_at`) < " . $end_timestamp);
|
|
|
|
|
$this->model = $this->model->where("project_id", $project_id);
|
|
|
|
|
|
|
|
|
|
$user = auth()->user();
|
|
|
|
|
$areaId = AdminAreaLink::where('project_id', $project_id)->where('admin_id', $user->id)->pluck('area_id');
|
|
|
|
|
$bedList = Bed::whereIn('area_id',$areaId)->pluck('id');
|
|
|
|
|
|
|
|
|
|
if ($request->keyword) {
|
|
|
|
|
$this->model = $this->model->where(function ($query) use ($request) {
|
|
|
|
|
$query->where("serial", "like", "%" . $request->keyword . "%")
|
|
|
|
|
->orWhere("contact", "like", "%" . $request->keyword . "%")
|
|
|
|
|
->orWhere("mobile", "like", "%" . $request->keyword . "%");
|
|
|
|
|
})->where(function ($query) use ($bedList) {
|
|
|
|
|
if ($bedList->isNotEmpty()) {
|
|
|
|
|
$query->whereIn('bed_id', $bedList);
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// 判断是否护士长
|
|
|
|
|
$userId = auth()->id();
|
|
|
|
|
$roleId = Role::where('name', 'like', '%护士长%')->where('guard_name', 'admin')->value('id');
|
|
|
|
|
$hushizhang = DB::table('model_has_roles')->where('role_id', $roleId)
|
|
|
|
|
->where('model_type', 'App\Admin')->where('model_id', $userId)->count();
|
|
|
|
|
if ($hushizhang) {
|
|
|
|
|
$user = auth()->user();
|
|
|
|
|
$areaId = AdminAreaLink::where('project_id', $project_id)->where('admin_id', $user->id)->pluck('area_id');
|
|
|
|
|
$bedList = Bed::whereIn('area_id', $areaId)->pluck('id');
|
|
|
|
|
$this->model = $this->model->whereIn('bed_id', $bedList);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if ($request->date) {
|
|
|
|
|
$this->model = $this->model->whereHas("orderItems", function ($query) use ($month, $request) {
|
|
|
|
|
$query->where("service_date", $month . "-" . $request->date);
|
|
|
|
|
@ -75,7 +81,7 @@ class OrdersController extends CommonController
|
|
|
|
|
"customer",
|
|
|
|
|
"manager",
|
|
|
|
|
"bed" => function ($query) {
|
|
|
|
|
$query->with(["room", "building","area"]);
|
|
|
|
|
$query->with(["room", "building", "area"]);
|
|
|
|
|
}
|
|
|
|
|
])
|
|
|
|
|
->orderBy("id", "desc");
|
|
|
|
|
@ -163,7 +169,7 @@ class OrdersController extends CommonController
|
|
|
|
|
|
|
|
|
|
$user = auth()->user();
|
|
|
|
|
$areaId = AdminAreaLink::where('project_id', $project_id)->where('admin_id', $user->id)->pluck('area_id');
|
|
|
|
|
$bedList = Bed::whereIn('area_id',$areaId)->pluck('id');
|
|
|
|
|
$bedList = Bed::whereIn('area_id', $areaId)->pluck('id');
|
|
|
|
|
|
|
|
|
|
$this->model = $this->model->where("project_id", $project_id)->whereNotNull("scored_at");
|
|
|
|
|
if (request()->keyword) {
|
|
|
|
|
@ -186,7 +192,7 @@ class OrdersController extends CommonController
|
|
|
|
|
"customer",
|
|
|
|
|
"manager",
|
|
|
|
|
"bed" => function ($query) {
|
|
|
|
|
$query->with(["room", "building","area"]);
|
|
|
|
|
$query->with(["room", "building", "area"]);
|
|
|
|
|
}
|
|
|
|
|
])
|
|
|
|
|
->orderBy("id", "desc")
|
|
|
|
|
|