public function update(array $data, $where) { //save a snapshot now require_once 'History.php'; $historyTable = new History('trainer'); //cheezy way to get the id $parts = explode('=', $where[0]); $pid = trim($parts[1]); //link to the last history row $personHistoryTable = new History('person'); $hrow = $personHistoryTable->fetchAll("person_id = {$pid}", "vid DESC", 1); $historyTable->insert($this, $hrow->current()->vid); $rslt = parent::update($data, $where); return $rslt; }
public function afterUpdate($id, $data = null) { $data['_id'] = new MongoId($id); $hdata = array(); $hdata['historyTimestamp'] = new MongoDate(); $hdata['historyAction'] = 'update'; $hdata['historySequence'] = 1; $hdata['historyObjectType'] = 'asset'; $hdata['historyObject'] = $data; History::insert($hdata); return $id; }
public function postAssigncourier() { //courier_name:Shia Le Beouf //courier_id:5605512bccae5b64010041b6 //device_key:0f56deadbc6df60740ef5e2c576876b0e3310f7d //device_name:JY-002 //pickup_date:28-09-2 $in = Input::get(); $pickup_date = new MongoDate(strtotime($in['pickup_date'])); $shipments = Shipment::where('device_key', '=', $in['device_key'])->where('pick_up_date', '=', $pickup_date)->where('status', '=', Config::get('jayon.trans_status_admin_zoned'))->get(); //print_r($shipments->toArray()); $ts = new MongoDate(); foreach ($shipments as $sh) { $pre = clone $sh; $sh->bucket = Config::get('jayon.bucket_tracker'); $sh->status = Config::get('jayon.trans_status_admin_courierassigned'); $sh->courier_id = $in['courier_id']; $sh->courier_name = $in['courier_name']; $sh->save(); $hdata = array(); $hdata['historyTimestamp'] = $ts; $hdata['historyAction'] = 'assign_courier'; $hdata['historySequence'] = 1; $hdata['historyObjectType'] = 'shipment'; $hdata['historyObject'] = $sh->toArray(); $hdata['actor'] = Auth::user()->fullname; $hdata['actor_id'] = Auth::user()->_id; History::insert($hdata); $sdata = array(); $sdata['timestamp'] = $ts; $sdata['action'] = 'assign_courier'; $sdata['reason'] = 'initial'; $sdata['objectType'] = 'shipment'; $sdata['object'] = $sh->toArray(); $sdata['preObject'] = $pre->toArray(); $sdata['actor'] = Auth::user()->fullname; $sdata['actor_id'] = Auth::user()->_id; Shipmentlog::insert($sdata); //print_r($sh); } return Response::json(array('result' => 'OK', 'shipment' => $shipments)); }
public function postExttotrack() { $in = Input::get(); $results = Shipment::whereIn('_id', $in['ids'])->get(); date_default_timezone_set('Asia/Jakarta'); $ts = new MongoDate(); //print_r($results->toArray()); $reason = isset($in['reason']) ? $in['reason'] : 'move after print'; //if($results){ $res = false; //}else{ foreach ($results as $r) { $pre = clone $r; if ($r->logistic_type == 'external') { if (trim($r->awb) != '') { $r->bucket = Config::get('jayon.bucket_tracker'); $r->status = Config::get('jayon.trans_status_confirmed'); $r->save(); } } $hdata = array(); $hdata['historyTimestamp'] = $ts; $hdata['historyAction'] = 'print_external_barcode'; $hdata['historySequence'] = 1; $hdata['historyObjectType'] = 'shipment'; $hdata['historyObject'] = $r->toArray(); $hdata['actor'] = Auth::user()->fullname; $hdata['actor_id'] = Auth::user()->_id; History::insert($hdata); $sdata = array(); $sdata['timestamp'] = $ts; $sdata['action'] = 'print_external_barcode'; $sdata['reason'] = $reason; $sdata['objectType'] = 'shipment'; $sdata['object'] = $r->toArray(); $sdata['preObject'] = $pre->toArray(); $sdata['actor'] = Auth::user()->fullname; $sdata['actor_id'] = Auth::user()->_id; Shipmentlog::insert($sdata); $confirm = array('awb' => $r->awb, 'order_id' => $r->no_sales_order, 'consignee_id' => $r->consignee_olshop_cust, 'ff_id' => $r->consignee_olshop_orderid, 'ts' => $ts, 'sent' => 0); Confirmed::insert($confirm); } $res = true; //} if ($res) { return Response::json(array('result' => 'OK:MOVED')); } else { return Response::json(array('result' => 'ERR:MOVEFAILED')); } }
public function postAssigndevice() { $in = Input::get(); $device = Device::where('key', '=', $in['device'])->first(); $shipments = Shipment::whereIn('delivery_id', $in['ship_ids'])->get(); //print_r($shipments->toArray()); $ts = new MongoDate(); foreach ($shipments as $sh) { $pre = clone $sh; $sh->status = Config::get('jayon.trans_status_admin_zoned'); $sh->device_key = $device->key; $sh->device_name = $device->identifier; $sh->device_id = $device->_id; $sh->save(); $hdata = array(); $hdata['historyTimestamp'] = $ts; $hdata['historyAction'] = 'assign_device'; $hdata['historySequence'] = 1; $hdata['historyObjectType'] = 'shipment'; $hdata['historyObject'] = $sh->toArray(); $hdata['actor'] = Auth::user()->fullname; $hdata['actor_id'] = Auth::user()->_id; History::insert($hdata); $sdata = array(); $sdata['timestamp'] = $ts; $sdata['action'] = 'assign_device'; $sdata['reason'] = 'initial'; $sdata['objectType'] = 'shipment'; $sdata['object'] = $sh->toArray(); $sdata['preObject'] = $pre->toArray(); $sdata['actor'] = Auth::user()->fullname; $sdata['actor_id'] = Auth::user()->_id; Shipmentlog::insert($sdata); } return Response::json(array('result' => 'OK', 'shipment' => $shipments)); }
public function update(array $data, $where) { //save a snapshot now require_once 'History.php'; $historyTable = new History('person'); //cheezy way to get the id $parts = explode('=', $where[0]); $historyTable->insert($this, trim($parts[1])); $rslt = parent::update($data, $where); return $rslt; }
public function postCanceldata() { $in = Input::get(); $results = Shipment::whereIn('delivery_id', $in['ids'])->get(); date_default_timezone_set('Asia/Jakarta'); //print_r($results->toArray()); //if($results){ $res = false; //}else{ $ts = new MongoDate(); foreach ($results as $sh) { $sh->status = Config::get('jayon.trans_status_canceled'); //$sh->last_action_ts = $ts; //$sh->last_action = 'Cancel Data'; $sh->delivery_note = $in['reason']; $sh->save(); //print_r($sh); //print_r(Auth::user()); $hdata = array(); $hdata['historyTimestamp'] = $ts; $hdata['historyAction'] = 'cancel_data'; $hdata['historySequence'] = 1; $hdata['historyObjectType'] = 'shipment'; $hdata['historyObject'] = $sh->toArray(); $hdata['actor'] = Auth::user()->fullname; $hdata['actor_id'] = isset(Auth::user()->_id) ? Auth::user()->_id : Auth::user()->id; //print_r($hdata); History::insert($hdata); $sdata = array(); $sdata['timestamp'] = $ts; $sdata['action'] = 'cancel_data'; $sdata['reason'] = $in['reason']; $sdata['objectType'] = 'shipment'; $sdata['object'] = $sh->toArray(); $sdata['actor'] = Auth::user()->fullname; $sdata['actor_id'] = isset(Auth::user()->_id) ? Auth::user()->_id : Auth::user()->id; Shipmentlog::insert($sdata); $res = true; } //} if ($res) { return Response::json(array('result' => 'OK')); } else { return Response::json(array('result' => 'ERR:CANCELFAILED')); } }
public function postResetuploaded() { $in = Input::get(); $results = Shipment::whereIn('_id', $in['ids'])->get(); date_default_timezone_set('Asia/Jakarta'); //print_r($results->toArray()); //if($results){ $res = false; //}else{ $ts = new MongoDate(); foreach ($results as $sh) { $pre = clone $sh; $sh->uploaded = 0; $sh->last_action_ts = $ts; $sh->last_action = 'Reset Uploaded Flag'; $sh->last_reason = $in['reason']; $sh->save(); //print_r(Auth::user()); $hdata = array(); $hdata['historyTimestamp'] = $ts; $hdata['historyAction'] = 'cancel_data'; $hdata['historySequence'] = 1; $hdata['historyObjectType'] = 'shipment'; $hdata['historyObject'] = $sh->toArray(); $hdata['actor'] = Auth::user()->fullname; $hdata['actor_id'] = Auth::user()->_id; //print_r($hdata); History::insert($hdata); $sdata = array(); $sdata['timestamp'] = $ts; $sdata['action'] = 'cancel_data'; $sdata['reason'] = $in['reason']; $sdata['objectType'] = 'shipment'; $sdata['object'] = $sh->toArray(); $sdata['preObject'] = $pre->toArray(); $sdata['actor'] = Auth::user()->fullname; $sdata['actor_id'] = Auth::user()->_id; Shipmentlog::insert($sdata); } $res = true; //} if ($res) { return Response::json(array('result' => 'OK:RESCHED')); } else { return Response::json(array('result' => 'ERR:RESCHEDFAILED')); } }
public function postEdit($id, $data = null) { if (isset($data['useImage']) && $data['useImage'] == 'linked') { $this->validator = array('itemDescription' => 'required', 'extImageURL' => 'required'); } else { $this->validator = array('itemDescription' => 'required'); } $hobj = Asset::find($id)->toArray(); $hobj['_id'] = new MongoId($id); $hdata['historyTimestamp'] = new MongoDate(); $hdata['historyAction'] = 'update'; $hdata['historySequence'] = 0; $hdata['historyObjectType'] = 'asset'; $hdata['historyObject'] = $hobj; History::insert($hdata); return parent::postEdit($id, $data); }
/** * Execute the console command. * * @return mixed */ public function fire() { $wsdl = "http://api.rpxholding.com/wsdl/rpxwsdl.php?wsdl"; //$client = new SoapClient($wsdl); $username = '******'; $password = '******'; SoapWrapper::add(function ($service) use($wsdl, $username, $password) { $service->name('trackAWB')->wsdl($wsdl)->trace(true)->cache(WSDL_CACHE_NONE); // Optional: Set the WSDL cache //->options(['user' => $username, 'password' => $password, 'format'=>'JSON' ]); // Optional: Set some extra options }); $logistic_id = 'B234-JKT'; $delivery_trigger = 'DELIVERED'; $returned_trigger = 'UNDELIVERED'; $logistic = Logistic::where('consignee_olshop_cust', '=', $logistic_id)->first(); $orders = Shipment::where('awb', '!=', '')->where('bucket', '=', Config::get('jayon.bucket_tracker'))->where('status', '!=', 'delivered')->where('logistic_type', '=', 'external')->where('consignee_olshop_cust', '=', $logistic_id)->get(); if ($orders && count($orders->toArray()) > 0) { $req = array(); foreach ($orders as $ord) { $username = $logistic->api_user; $password = $logistic->api_pass; $data = [$username, $password, '8979867812376', 'JSON']; //string $user, string $password, string $awb, string $format SoapWrapper::service('trackAWB', function ($service) use($data) { var_dump($service->getFunctions()); print $service->call('getTrackingAWB', $data); //print_r($service->call('getTrackingAWB', [$data])); }); $res = json_decode($result, true); $reslog = $res; $reslog['timestamp'] = new MongoDate(); $reslog['consignee_logistic_id'] = $logistic->logistic_code; $reslog['consignee_olshop_cust'] = $logistic_id; Threeplstatuslog::insert($reslog); print_r($res); if (isset($res['cn_no'])) { $pre = clone $ord; $ls = $res['laststatus']; if ($ls['status'] == $delivery_trigger) { $ord->status = Config::get('jayon.trans_status_mobile_delivered'); $ord->position = 'CUSTOMER'; } if ($ls['status'] == $returned_trigger) { $ord->status = Config::get('jayon.trans_status_mobile_return'); } //$ord->district = $ls->district; $ord->logistic_status = $ls['status']; $ord->logistic_status_ts = $ls['time']; $ord->logistic_raw_status = $ls; $ord->save(); $ts = new MongoDate(); $hdata = array(); $hdata['historyTimestamp'] = $ts; $hdata['historyAction'] = 'api_shipment_change_status'; $hdata['historySequence'] = 1; $hdata['historyObjectType'] = 'shipment'; $hdata['historyObject'] = $ord->toArray(); $hdata['actor'] = $this->name; $hdata['actor_id'] = ''; History::insert($hdata); $sdata = array(); $sdata['timestamp'] = $ts; $sdata['action'] = 'api_shipment_change_status'; $sdata['reason'] = 'api_update'; $sdata['objectType'] = 'shipment'; $sdata['object'] = $ord->toArray(); $sdata['preObject'] = $pre->toArray(); $sdata['actor'] = $this->name; $sdata['actor_id'] = ''; Shipmentlog::insert($sdata); $this->saveStatus($res, $logistic->logistic_code, $logistic_id); } } } else { print 'Empty order list' . "\r\n"; } $actor = $this->name; Event::fire('log.api', array('RPXStatusDaemon', 'get', $actor, 'RPX STATUS PULL')); // }