コード例 #1
0
ファイル: MedlatecController.php プロジェクト: huynt57/soyba
 public function actionGetResultsOfOrder()
 {
     $request = Yii::app()->request;
     try {
         $order_id = StringHelper::filterString($request->getQuery('order_id'));
         $data = ResultMedlatec::model()->getResultOfOrder($order_id);
         ResponseHelper::JsonReturnSuccess($data, 'Success');
     } catch (exception $e) {
         var_dump($e->getMessage());
     }
     Yii::app()->end();
 }
コード例 #2
0
ファイル: OrderMedlatec.php プロジェクト: huynt57/medlatec
 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;
 }
コード例 #3
0
ファイル: OrderController.php プロジェクト: huynt57/medlatec
 public function actionUpdateResult()
 {
     try {
         $urls = NULL;
         $doctor = StringHelper::filterString($_POST['doctor']);
         $diagnose = StringHelper::filterString($_POST['diagnose']);
         $status = StringHelper::filterString($_POST['status']);
         $order_id = StringHelper::filterString($_POST['order_id']);
         $attr = array('doctor' => $doctor, 'diagnose' => $diagnose, 'status' => $status, 'order_id' => $order_id);
         //  var_dump($_FILES); die;
         if (isset($_FILES['file'])) {
             $urls = UploadHelper::getUrlUploadMultiImages($_FILES['file'], 'result');
         }
         if (ResultMedlatec::model()->updateResultByOrder($attr, $urls)) {
             ResponseHelper::JsonReturnSuccess('', 'Success');
         } else {
             ResponseHelper::JsonReturnError('', 'Error');
         }
     } catch (Exception $ex) {
         var_dump($ex->getMessage());
     }
     // ResultMedlatec::model()->up
 }
コード例 #4
0
ファイル: OrderMedlatec.php プロジェクト: huynt57/soyba
 public function getOrderAndResult($order_id)
 {
     $order_info = $this->getOrderDetail($order_id);
     $result_info = ResultMedlatec::model()->getResultOfOrder($order_id);
     return array('order_info' => $order_info, 'result_info' => $result_info);
 }
コード例 #5
0
ファイル: ResultMedlatec.php プロジェクト: huynt57/soyba
 public function getResultByUser($user_id, $limit, $offset)
 {
     //        $orders = OrderMedlatec::model()->findAllByAttributes(array('user_id' => $user_id));
     //        $returnArr = array();
     //        foreach ($orders as $order) {
     //            $itemArr = array();
     //            $itemArr = ResultMedlatec::model()->findByAttributes(array('order_id' => $order->id));
     //            if (!empty($itemArr)) {
     //                $returnArr[] = $itemArr;
     //            }
     //        }
     $criteria = new CDbCriteria();
     $criteria->limit = $limit;
     $criteria->offset = $offset;
     $criteria->join = "JOIN tbl_order_medlatec o where t.id = o.order_id";
     $criteria->select = "t.*, o.*";
     $criteria->condition = "o.user_meboo = {$user_id}";
     $returnArr = ResultMedlatec::model()->findAll($criteria);
     return $returnArr;
 }
コード例 #6
0
ファイル: ResultMedlatec.php プロジェクト: huynt57/medlatec
 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;
     }
 }
コード例 #7
0
ファイル: ResultController.php プロジェクト: huynt57/medlatec
 public function actionEditProcess()
 {
     $attr = StringHelper::filterArrayString($_POST);
     $result = ResultMedlatec::model()->updateResult($attr);
     if ($result) {
         ResponseHelper::JsonReturnSuccess('', 'Update success');
     } else {
         ResponseHelper::JsonReturnError('', 'Update failed');
     }
 }