public function getMrktOfcDriverCount($mrktOfcId) { $drvCnt = 0; $datef = date('Y-m-d'); $curTime = date('H:m:s'); $meal_plan = FoodjetsMealPlan::select('id', 'market_office_id')->where(DB::raw("DATE(meal_plan_date)"), $datef)->where('start_time', '<=', $curTime)->where('end_time', '>=', $curTime)->where('active', 'true')->where('market_office_id', $mrktOfcId)->first(); if (!empty($meal_plan->id)) { $drvListIds = TodaysDriversInventory::select('todays_drivers_list_id')->where('foodjets_meal_plan_id', $meal_plan->id)->groupBy('todays_drivers_list_id')->get()->toArray(); //echo '<pre>'; print_r($drvListIds);die; $drvCnt = TodaysDriversList::where('date', $datef)->whereIn('id', $drvListIds)->count(); } return $drvCnt; }
public function getZoneMealPlanDriverQuantity($param = array(), $driver_id = 0) { if (!$param['market_office_city_delivery_zone_id'] || !$param['meal_plan_id'] || !$param['items'] || $driver_id == 0) { return false; } $driver = array(); $items = $this->_menuItems($param['items']); $data = TodaysDriversInventory::select("todays_drivers_list.drivers_id", "todays_drivers_inventory.foodjets_menu_item_id", "todays_drivers_inventory.quantity", "todays_drivers_inventory.todays_drivers_list_id")->join("todays_drivers_list", "todays_drivers_inventory.todays_drivers_list_id", "=", "todays_drivers_list.id")->where("todays_drivers_list.drivers_id", $driver_id)->where('todays_drivers_list.market_office_city_delivery_zone_id', $param['market_office_city_delivery_zone_id'])->where('todays_drivers_inventory.foodjets_meal_plan_id', $param['meal_plan_id'])->whereIn('todays_drivers_inventory.foodjets_menu_item_id', $items)->get(); foreach ($data as $each) { $driver[] = array('drivers_id' => $each['drivers_id'], 'foodjets_menu_item_id' => $each['foodjets_menu_item_id'], 'quantity' => $each['quantity'], 'todays_drivers_list_id' => $each['todays_drivers_list_id']); } return $driver; }
public function getDriversForZone($zoneId, $mrktOfcId) { $drivers = array(); $datef = date('Y-m-d'); $curTime = date('H:m:s'); $meal_plan = FoodjetsMealPlan::select('id', 'market_office_id')->where(DB::raw("DATE(meal_plan_date)"), $datef)->where('start_time', '<=', $curTime)->where('end_time', '>=', $curTime)->where('active', 'true')->where('market_office_id', $mrktOfcId)->first(); if (!empty($meal_plan->id)) { $drvListIds = TodaysDriversInventory::select('todays_drivers_list_id')->where('foodjets_meal_plan_id', $meal_plan->id)->groupBy('todays_drivers_list_id')->get()->toArray(); //echo '<pre>'; print_r($drvListIds);die; $driversIds = TodaysDriversList::select('drivers_id', DB::raw('id as list_id'), DB::raw("{$meal_plan->id} AS meal_plan_id"))->where('date', $datef)->whereIn('id', $drvListIds)->where('market_office_city_delivery_zone_id', $zoneId)->get(); foreach ($driversIds as $val) { $driverInfo = Driver::select(DB::raw('SUBSTRING(CONCAT_WS(" ",first_name,last_name),1,17) AS short_name'), DB::raw('CONCAT_WS(" ",first_name,last_name) AS driver_name'), 'image', 'onfleet_worker_status AS online_status')->where('id', $val['drivers_id'])->first(); if ($driverInfo['image'] != "" && $driverInfo['image'] != null) { $image = Config::get('images.driver') . $driverInfo['image']; } else { $image = "/images/avatar.png"; } if ($driverInfo['online_status'] == "true" && $driverInfo['online_status'] != null) { $online_status = 1; } else { $online_status = 0; } $driverInfo['image'] = $image; $driverInfo['online_status'] = $online_status; $driverInfo['meal_plan_id'] = $val['meal_plan_id']; $driverInfo['list_id'] = $val['list_id']; $driverInfo['driver_id'] = $val['drivers_id']; $drivers[] = $driverInfo; } } return $drivers; }