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'); }
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; }
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)); } }
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; }
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; } }
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)); }
public function actionEditProcess() { $attr = StringHelper::filterArrayString($_POST); $result = OrderMedlatec::model()->updateOrder($attr); if ($result) { ResponseHelper::JsonReturnSuccess('', 'Update success'); } else { ResponseHelper::JsonReturnError('', 'Update failed'); } }