Exemplo n.º 1
0
 public function actionGetOrderAndResult()
 {
     $request = Yii::app()->request;
     $order_id = StringHelper::filterString($request->getQuery('order_id'));
     $data = OrderMedlatec::model()->getOrderAndResult($order_id);
     ResponseHelper::JsonReturnSuccess($data, 'Success');
 }
Exemplo n.º 2
0
 public function deleteOrder($order_id)
 {
     $flag = TRUE;
     $results = ResultMedlatec::model()->findAllByAttributes(array('order_id' => $order_id));
     $order = OrderMedlatec::model()->findByPk($order_id);
     $order->delete();
     foreach ($results as $item) {
         $file = ResultFile::model()->findByAttributes(array('result_id' => $item->id));
         if (!$file->delete() || !$item->delete()) {
             $flag = FALSE;
         }
     }
     return $flag;
 }
Exemplo n.º 3
0
 public function actionResult()
 {
     $request = Yii::app()->request;
     $this->layoutPath = Yii::getPathOfAlias('webroot') . "/themes/classic/views/layouts";
     $this->layout = 'main_modal';
     $order_id = StringHelper::filterString($request->getQuery('oid'));
     $data = OrderMedlatec::model()->getOrderDetail($order_id);
     $result = ResultMedlatec::model()->findByAttributes(array('order_id' => $order_id));
     if ($result) {
         $files = ResultFile::model()->findAllByAttributes(array('result_id' => $result->id));
     }
     if (isset($result) && isset($files)) {
         $this->render('result', array('data' => $data, 'result' => $result, 'files' => $files));
     } else {
         $this->render('result', array('data' => $data));
     }
 }
Exemplo n.º 4
0
 public function getOrderDetail($order_id)
 {
     $order = OrderMedlatec::model()->findByPk($order_id);
     $attrs = $this->attributeLabels();
     $itemArr = array();
     foreach ($attrs as $key => $value) {
         $itemArr[$key] = $order->{$key};
     }
     $service = ServiceMedlatec::model()->findByPk($order->service_id);
     if (!empty($service)) {
         $service_name = $service->service_name;
     } else {
         $service_name = null;
     }
     $itemArr['service_name'] = $service_name;
     return $itemArr;
 }
Exemplo n.º 5
0
 public function updateResultByOrder($attr, $urls)
 {
     $check = ResultMedlatec::model()->findByAttributes(array('order_id' => $attr['order_id']));
     if ($check) {
         $check->setAttributes($attr);
         $check->updated_at = time();
         $check->save(FALSE);
         $order = OrderMedlatec::model()->findByPk($attr['order_id']);
         $order->status = 4;
         $order->save(FALSE);
         $meboo = $order->user_meboo;
         $device_tokens = DeviceTk::model()->findAllByAttributes(array('user_id' => $meboo));
         $message_android = array('medlatec_order' => array('order_id' => $attr['order_id']));
         $message_ios = array('alert' => 'Dịch vụ của bạn vừa có thông tin', 'sound' => 'default', 'data' => array('id' => $attr['order_id'], 'type' => '0'));
         $message = array('message_android' => $message_android, 'message_ios' => $message_ios);
         foreach ($device_tokens as $token) {
             //  echo $token->platform;
             Util::sendNotificationBasedOnStatus($token->device_token, $order->status, $message);
         }
         //die;
         if (!empty($urls) && is_array($urls)) {
             $files = ResultFile::model()->findAllByAttributes(array('result_id' => $check->id));
             if ($files) {
                 foreach ($files as $file) {
                     $file->delete();
                 }
             }
             foreach ($urls as $url) {
                 $file = new ResultFile();
                 $file->url = $url;
                 $file->updated_at = time();
                 $file->created_at = time();
                 $file->result_id = $check->id;
                 $file->save(FALSE);
             }
         }
         return TRUE;
     } else {
         $model = new ResultMedlatec();
         $model->setAttributes($attr);
         $model->order_id = $attr['order_id'];
         $model->created_at = time();
         $model->updated_at = time();
         $model->save(FALSE);
         $order = OrderMedlatec::model()->findByPk($attr['order_id']);
         $order->status = 4;
         $order->save(FALSE);
         $meboo = $order->user_meboo;
         $meboo_token = User::model()->findByPk($meboo);
         if ($meboo_token) {
             $message = array('medlatec_order' => array('order_id' => $attr['order_id']));
             Util::sendNotificationBasedOnStatus($meboo_token->device_token, $order->status, $message);
         }
         if (!empty($urls) && is_array($urls)) {
             foreach ($urls as $url) {
                 $file = new ResultFile();
                 $file->url = $url;
                 $file->updated_at = time();
                 $file->created_at = time();
                 $file->result_id = $model->id;
                 $file->save(FALSE);
             }
         }
         return TRUE;
     }
 }
Exemplo n.º 6
0
 public function actionOrder()
 {
     $request = Yii::app()->request;
     $this->layoutPath = Yii::getPathOfAlias('webroot') . "/themes/classic/views/layouts";
     $this->layout = 'main_modal';
     $order_id = StringHelper::filterString($request->getQuery('oid'));
     $data = OrderMedlatec::model()->getOrderDetail($order_id);
     $this->render('order', array('data' => $data));
 }
Exemplo n.º 7
0
 public function actionEditProcess()
 {
     $attr = StringHelper::filterArrayString($_POST);
     $result = OrderMedlatec::model()->updateOrder($attr);
     if ($result) {
         ResponseHelper::JsonReturnSuccess('', 'Update success');
     } else {
         ResponseHelper::JsonReturnError('', 'Update failed');
     }
 }