public function getAssignedOrders()
 {
     $input = Input::all();
     $response = array();
     try {
         $response['status'] = "1";
         $response['msg'] = "Success";
         $ApiRedis = new ApiRedis();
         $db = $this->redisDb;
         $orderProcessed = $ApiRedis->getOrderSpliceQueue($input['zone_id'], $db);
         $orderIds = array();
         $orders = array();
         foreach ($orderProcessed['assigned'] as $k => $v) {
             if ($k > 0) {
                 $orderHash = $ApiRedis->getOrderFromHash($k, $db);
                 if (empty($orderHash['address'])) {
                     $orderHash['address'] = "";
                 }
                 $order[$k] = $orderHash;
                 $orderIds[] = $k;
             }
         }
         if (count($orderIds) > 0) {
             $orderData = Order::select("order.id", "order.order_number", "order.market_office_city_delivery_zone_id", "customer.full_name", "driver.first_name", "driver.last_name", "order.customer_delivery_address", DB::raw("driver.id AS driver_id"))->join("customer", "customer.id", "=", "order.customer_id")->leftJoin('driver', 'driver.id', '=', 'order.driver_id')->whereIn("order.id", $orderIds)->get();
             foreach ($orderData as $value) {
                 $order[$value["id"]]["id"] = $value["id"];
                 $order[$value["id"]]["order_number"] = $value["order_number"] != "" ? $value["order_number"] : " ";
                 $order[$value["id"]]["customer_name"] = $value["full_name"] != "" ? $value["full_name"] : " ";
                 if ($value['last_name'] != null || $value['first_name'] != null) {
                     $order[$value["id"]]["driver_name"] = $value["first_name"] . " " . $value["last_name"];
                 } else {
                     $order[$value["id"]]["driver_name"] = "";
                 }
                 $order[$value["id"]]["show_driver"] = true;
                 if ($order[$value["id"]]["address"] == "") {
                     $order[$value["id"]]["address"] = $value['customer_delivery_address'] != "" ? $value['customer_delivery_address'] : " ";
                 }
             }
         }
         $response['orders'] = $order;
     } catch (Exception $e) {
         Log::error($e);
         $response['status'] = '0';
         $msg = (array) $e->getMessage();
         $response['msg'] = $msg[0];
     }
     return Response::json($response);
 }
 protected function getOrderHash($k, $v, $db)
 {
     $orderHash = array();
     $ApiRedis = new ApiRedis();
     $orderHash = $ApiRedis->getOrderFromHash($k, $db);
     $orderHash['destination_note'] = "";
     if ($v == "3") {
         $orderHash['order_status'] = "Processing Unassigned";
     } else {
         if ($v == "5") {
             $orderHash['order_status'] = "Assigned";
         } else {
             if ($v == "6") {
                 $orderHash['order_status'] = "Processing Assigned";
             } else {
                 if ($v == "7") {
                     $orderHash['order_status'] = "Started";
                 } else {
                     if ($v == "9") {
                         $orderHash['order_status'] = "Cancelling";
                     } else {
                         $orderHash['order_status'] = "Unassigned";
                     }
                 }
             }
         }
     }
     if (empty($orderHash['address'])) {
         $orderHash['address'] = "";
     }
     $orderHash["notes"] = "";
     if (!empty($orderHash['reason'])) {
         $orderHash["notes"] .= "<img src='images/bullet.jpg'> " . $orderHash['reason'] . "<br>";
     }
     if (!empty($orderHash['sms'])) {
         if ($orderHash['sms'] == true) {
             $orderHash["notes"] .= "<img src='images/bullet.jpg'> Late sms send.";
         }
     }
     $orderHash["notes"] = $orderHash["notes"] != "" ? $orderHash["notes"] : "&nbsp;";
     return $orderHash;
 }