Esempio n. 1
0
 /**
  * Execute the console command.
  *
  * @return mixed
  */
 public function fire()
 {
     $dbox = Boxstatus::where('appname', '=', Config::get('jex.tracker_app'))->where('deliveryStatus', '=', Config::get('jayon.trans_status_mobile_delivered'))->get();
     if ($dbox) {
         foreach ($dbox as $dbx) {
             print 'box status : ' . $dbx->deliveryId . ' ' . $dbx->boxId . ' ' . $dbx->deliveryStatus . "\r\n";
             $box = Box::where('delivery_id', '=', $dbx->deliveryId)->where(function ($q) use($dbx) {
                 $q->where('box_id', '=', intval($dbx->boxId))->orWhere('box_id', '=', strval($dbx->boxId));
             })->first();
             if ($box) {
                 print 'box before : ' . $box->delivery_id . ' ' . $box->box_id . ' ' . $box->deliveryStatus . "\r\n";
                 $box->deliveryStatus = $dbx->deliveryStatus;
                 print 'box after : ' . $box->delivery_id . ' ' . $box->box_id . ' ' . $box->deliveryStatus . "\r\n";
                 $box->save();
             }
         }
     }
 }
Esempio n. 2
0
 public function postBoxlist()
 {
     $in = Input::get();
     $ids = $in['ids'];
     $shipments = Shipment::whereIn('_id', $in['ids'])->get();
     $shipments = $shipments->toArray();
     for ($i = 0; $i < count($shipments); $i++) {
         $pick_up_date = $shipments[$i]['pick_up_date'];
         $shipments[$i]['pick_up_date'] = date('Y-m-d', $shipments[$i]['pick_up_date']->sec);
         $boxes = Box::where('fulfillment_code', '=', $shipments[$i]['fulfillment_code'])->where('order_id', '=', $shipments[$i]['order_id'])->where('delivery_id', '=', $shipments[$i]['delivery_id'])->get();
         $boxlist = array();
         foreach ($boxes as $d) {
             $boxlist[$d->_id]['_id'] = $d->_id;
             $boxlist[$d->_id]['fulfillment_code'] = $d->fulfillment_code;
             $boxlist[$d->_id]['deliveryStatus'] = $d->deliveryStatus;
             $boxlist[$d->_id]['courierStatus'] = $d->courierStatus;
             $boxlist[$d->_id]['box_id'] = $d->box_id;
         }
         $shipments[$i]['box_list'] = $boxlist;
     }
     return Response::json(array('result' => 'OK', 'shipment' => $shipments, 'boxes' => $boxlist));
     //print_r($caps);
 }
Esempio n. 3
0
 public function boxList($field, $val, $device_key, $obj = false)
 {
     $boxes = \Box::where($field, '=', $val)->get();
     $bx = array();
     if ($obj == true) {
         $boxes = $boxes->toArray();
         for ($n = 0; $n < count($boxes); $n++) {
             $ob = new \stdClass();
             foreach ($boxes[$n] as $k => $v) {
                 if ($k != '_id' && $k != 'id') {
                     $nk = $this->underscoreToCamelCase($k);
                 } else {
                     $nk = $k;
                 }
                 $ob->{$nk} = is_null($v) ? '' : $v;
             }
             //print_r($ob);
             $ob->extId = $ob->_id;
             unset($ob->_id);
             $ob->status = $this->lastBoxStatus($device_key, $ob->deliveryId, $ob->fulfillmentCode, $ob->boxId);
             $boxes[$n] = $ob;
         }
         return $boxes;
     } else {
         foreach ($boxes as $b) {
             $bx[] = $b->box_id;
         }
         if (count($bx) > 0) {
             return implode(',', $bx);
         } else {
             return '1';
         }
     }
 }
Esempio n. 4
0
 public function boxList($field, $val)
 {
     $boxes = \Box::where($field, '=', $val)->get();
     $bx = array();
     foreach ($boxes as $b) {
         $bx[] = $b->box_id;
     }
     if (count($bx) > 0) {
         return implode(',', $bx);
     } else {
         return '1';
     }
 }
 /**
  * Store a newly created resource in storage.
  *
  * @return Response
  */
 public function postBox()
 {
     $key = \Input::get('key');
     $appname = \Input::has('app') ? \Input::get('app') : 'app.name';
     //$user = \Apiauth::user($key);
     $user = \Device::where('key', '=', $key)->first();
     if (!$user) {
         $actor = 'no id : no name';
         \Event::fire('log.api', array($this->controller_name, 'post', $actor, 'device not found, upload image failed'));
         return \Response::json(array('status' => 'ERR:NODEVICE', 'timestamp' => time(), 'message' => 'Device Unregistered'));
     }
     $json = \Input::all();
     $batch = \Input::get('batch');
     $result = array();
     foreach ($json as $j) {
         //$j['mtimestamp'] = new \MongoDate(time());
         if (is_array($j)) {
             $blog = new \Boxid();
             foreach ($j as $k => $v) {
                 $blog->{$k} = $v;
             }
             $blog->appname = $appname;
             $blog->mtimestamp = new \MongoDate(time());
             $box = \Box::where('delivery_id', '=', $blog->deliveryId)->where('merchant_trans_id', '=', $blog->merchantTransId)->where('fulfillment_code', '=', $blog->fulfillmentCode)->where('box_id', '=', $blog->boxId)->first();
             if ($box) {
                 if ($appname == \Config::get('jex.pickup_app')) {
                     $box->pickupStatus = $blog->pickupStatus;
                 } elseif ($appname == \Config::get('jex.hub_app')) {
                     $box->warehouseStatus = $blog->warehouseStatus;
                 } else {
                     $box->deliveryStatus = $blog->deliveryStatus;
                     $box->courierStatus = $blog->courierStatus;
                 }
                 $box->save();
             }
             $r = $blog->save();
             if ($r) {
                 $result[] = array('status' => 'OK', 'timestamp' => time(), 'message' => 'log inserted');
             } else {
                 $result[] = array('status' => 'NOK', 'timestamp' => time(), 'message' => 'insertion failed');
             }
         }
     }
     //print_r($result);
     //die();
     $actor = $user->identifier . ' : ' . $user->devname;
     \Event::fire('log.api', array($this->controller_name, 'get', $actor, 'sync scan log'));
     return Response::json($result);
 }
 public function statusList($data)
 {
     $boxes = Box::where('delivery_id', $data['delivery_id'])->get();
     $bcount = 0;
     $dcount = 0;
     $rcount = 0;
     $pcount = 0;
     $dclass = '';
     $rclass = '';
     $pclass = '';
     if ($data['status'] == Config::get('jayon.trans_status_mobile_delivered_partial') || $data['status'] == Config::get('jayon.trans_status_mobile_delivered') || $data['status'] == Config::get('jayon.trans_status_mobile_return') || $data['status'] == Config::get('jayon.trans_status_mobile_pending')) {
         foreach ($boxes as $box) {
             if ($box->deliveryStatus == Config::get('jayon.trans_status_mobile_delivered')) {
                 $dcount++;
             }
             if ($box->deliveryStatus == Config::get('jayon.trans_status_mobile_return')) {
                 $rcount++;
             }
             if ($box->deliveryStatus == Config::get('jayon.trans_status_mobile_pending')) {
                 $pcount++;
             }
         }
         $bcount = count($boxes);
         $dclass = $dcount == 0 ? 'lightgrey' : '';
         $rclass = $rcount == 0 ? 'lightgrey' : '';
         $pclass = $pcount == 0 ? 'lightgrey' : '';
         /*
                     if(count($boxes) > ($dcount + $rcount) && $data['logistic_type'] == 'internal'){
                         $data['status'] = Config::get('jayon.trans_status_mobile_delivered_partial');
                     }*/
     }
     $slist = array(Prefs::colorizestatus($data['status'], 'delivery') . '<br /><span class="badge">BX:' . $bcount . '</span> <span class="badge ' . $dclass . ' ">D:' . $dcount . '</span> <span class="badge ' . $rclass . ' ">R:' . $rcount . '</span> <span class="badge ' . $pclass . '">P:' . $pcount . '</span>');
     return implode('<br />', $slist);
     //return '<span class="orange white-text">'.$data['status'].'</span><br /><span class="brown">'.$data['pickup_status'].'</span><br /><span class="green">'.$data['courier_status'].'</span><br /><span class="maroon">'.$data['warehouse_status'].'</span>';
 }
 public function dlstatusList($data)
 {
     $boxes = Box::where('delivery_id', $data['delivery_id'])->get();
     $bcount = 0;
     $dcount = 0;
     $rcount = 0;
     $pcount = 0;
     if ($data['status'] == Config::get('jayon.trans_status_mobile_delivered_partial') || $data['status'] == Config::get('jayon.trans_status_mobile_delivered') || $data['status'] == Config::get('jayon.trans_status_mobile_return') || $data['status'] == Config::get('jayon.trans_status_mobile_pending')) {
         foreach ($boxes as $box) {
             if ($box->deliveryStatus == Config::get('jayon.trans_status_mobile_delivered')) {
                 $dcount++;
             }
             if ($box->deliveryStatus == Config::get('jayon.trans_status_mobile_return')) {
                 $rcount++;
             }
             if ($box->deliveryStatus == Config::get('jayon.trans_status_mobile_pending')) {
                 $pcount++;
             }
         }
         $bcount = count($boxes);
         if (count($boxes) > $dcount + $rcount && $data['logistic_type'] == 'internal') {
             $data['status'] = Config::get('jayon.trans_status_mobile_delivered_partial');
         }
     }
     //$slist = array(
     //    $data['status'].' BOX:'.$bcount.' D:'.$dcount.' R:'.$rcount.' P:'.$pcount
     //);
     return $data['status'] . ' BOX:' . $bcount . ' D:' . $dcount . ' R:' . $rcount . ' P:' . $pcount;
     //return implode(' | ', $slist);
     //return '<span class="orange white-text">'.$data['status'].'</span><br /><span class="brown">'.$data['pickup_status'].'</span><br /><span class="green">'.$data['courier_status'].'</span><br /><span class="maroon">'.$data['warehouse_status'].'</span>';
 }
Esempio n. 8
0
 public static function save_box($delivery_id, $merchant_trans_id, $fulfillment_code, $count)
 {
     $affected = Box::where('delivery_id', '=', $delivery_id)->where('merchant_trans_id', '=', $merchant_trans_id)->where('fulfillment_code', '=', $fulfillment_code)->delete();
     for ($i = 0; $i < $count; $i++) {
         $bd = new Box();
         $bd->delivery_id = $delivery_id;
         $bd->merchant_trans_id = $merchant_trans_id;
         $bd->fulfillment_code = $fulfillment_code;
         $bd->box_id = $i + 1;
         $bd->save();
         $bds = new Boxstatus();
         $bds->delivery_id = $delivery_id;
         $bds->merchant_trans_id = $merchant_trans_id;
         $bds->fulfillment_code = $fulfillment_code;
         $bds->box_id = $i + 1;
         $bds->timestamp = date('Y-m-d H:i:s', time());
         $bds->save();
     }
 }