/var/www/vhosts/nabawater/backend/controllers
NameSizeModeActions
ActivityLogController.php16500644editdlrm
AddressTypeController.php64660644editdlrm
AdminOrderReportController.php35920644editdlrm
AdminUserController.php125230644editdlrm
AdsController.php97430644editdlrm
AreaController.php70190644editdlrm
BannerController.php71000644editdlrm
BranchController.php339890644editdlrm
BranchReviewController.php22090644editdlrm
CashBackPromotionsController.php120510644editdlrm
CategoryController.php87950644editdlrm
CityController.php55180644editdlrm
CmsController.php60260644editdlrm
ConfigurationController.php105640644editdlrm
CountryController.php52340644editdlrm
CouponController.php152450644editdlrm
CuisineController.php82070644editdlrm
DashboardController.php58050644editdlrm
DeliveryAreaController.php75060644editdlrm
DeliveryboyController.php76620644editdlrm
DeliveryChargeSettingsController.php45560644editdlrm
DriverOrderController.php35850644editdlrm
EnquiryController.php25410644editdlrm
FaqController.php65710644editdlrm
IngredientController.php69540644editdlrm
ItemController.php341500644editdlrm
ItemImportController.php38480644editdlrm
ItemIngredientGroupController.php111050644editdlrm
ItemMappingController.php121600644editdlrm
ItemTypeController.php74450644editdlrm
LanguageController.php38470644editdlrm
LoginController.php16840644editdlrm
LoyalityPointController.php66550644editdlrm
MallProductController.php63980644editdlrm
MetaTagController.php50390644editdlrm
MobileTranslationController.php44510644editdlrm
NewsLetterController.php52070664editdlrm
NewsletterController.php52070644editdlrm
NewsletterSubscriberController.php17470644editdlrm
NotificationController.php83820644editdlrm
OrderController.php937130644editdlrm
OrderMallProductController.php76610644editdlrm
OrderParcelController.php27520644editdlrm
OrderReportController.php39040644editdlrm
ParcelItemTypeController.php43570644editdlrm
PromotionController.php67100644editdlrm
PushNotificationController.php29900644editdlrm
RatingController.php6230644editdlrm
RefundRequestController.php29640644editdlrm
reject-index.php429310644editdlrm
RejectedOrderReportController.php5660644editdlrm
ReportController.php422320644editdlrm
RoleController.php52300644editdlrm
SiteController.php3570644editdlrm
StockController.php20670644editdlrm
TaxController.php45680644editdlrm
TodaySpecialController.php74730644editdlrm
TopOrderItemReportController.php38660644editdlrm
TopupController.php46190644editdlrm
UnitController.php71150644editdlrm
UserController.php135660644editdlrm
UserLevelController.php37870644editdlrm
VendorBankController.php28800644editdlrm
VendorController.php244910644editdlrm
VendorOrderReportController.php51460644editdlrm
VendorPaymentController.php60940644editdlrm
VendorTypeController.php84280644editdlrm
WalletController.php17910644editdlrm
WalletTranscationController.php22820644editdlrm
WebpushNotificationController.php25630644editdlrm
Edit: /var/www/vhosts/nabawater/backend/controllers/UserController.php (13566B)
render('index', [ 'searchModel' => $searchModel, 'dataProvider' => $searchModel->search(Yii::$app->request->queryParams) ] ); } /** * * @return string * * @Title("Create") */ public function actionCreate() { $model = new User(); $post = Yii::$app->getRequest()->post(); $model->setScenario($model::SCENARIO_CREATE); if ($model->load($post) && $model->validate()) { $password = Yii::$app->security->generateRandomString(6); $model->setPassword($password); $model->referral_code = Com::generateRandomString(5, true); $model->save(false); $mailerQueueHelper = MailerQueueHelper::getInstance() ->setTo($model->email) ->setSubject('Customer Registration') ->setView( 'CustomerRegistration', [ 'username'=> $model->first_name.' '.$model->last_name, 'email' => $model->email, 'password' => $password, ]) ->push(); Com::successFlash(Yii::t('backend','Created Successfully')); return $this->redirect(['index']); } return $this->render('create', [ 'model' => $model, ]); } /** * * @param type $id * @return string * * @Title("Update") */ public function actionUpdate($id) { $model = $this->findModel($id); $post = Yii::$app->getRequest()->post(); $model->setScenario($model::SCENARIO_UPDATE); if ($model->load($post) && $model->validate()) { $adminUserData = Yii::$app->getUser()->getIdentity(); $adminUserName = $adminUserData->attributes['user_name']; $customerName = $model->first_name.$model->last_name; ActivityLog::log($adminUserName.' '. 'edited the tabaogo Credits for customer'.' '. $customerName); $model->save(); Com::successFlash(Yii::t('backend','Updated Successfully')); return $this->redirect(['index']); } return $this->render('update', [ 'model' => $model, ]); } /** * * @param type $id * @return string * * @Title("Delete") */ public function actionDelete($id) { $model = $this->findModel($id); if ($model === null) { Com::failureFlash('Unable to find the Item'); return $this->redirect(['index']); } $model->status = User::DELETE; $model->save(false); Com::successFlash(Yii::t('backend','Deleted Successfully')); return $this->redirect(['index']); } /** * * @param type $id * @return $model * @throws NotFoundHttpException */ protected function findModel($id) { if (($model = User::findOne(['user_key' => $id])) !== null) { return $model; } else { throw new NotFoundHttpException('The requested page does not exist.'); } } /** * * @return Json * @throws \yii\base\InvalidParamException * * @Title("User Status") */ public function actionChangeStatus() { $params = ['key', 'status']; $post = Yii::$app->getRequest()->post(); $result = ['status' => STATUS_FAIL, 'msg' => '']; foreach ($params as $param) { if (!array_key_exists($param, $post)) { $result['msg'] = 'Required param missing'; goto skip; } } $model = User::findOne(['user_key' => $post['key']]); if ($model === null) { $result['msg'] = 'Unable to find the Customer'; goto skip; } $model->status = $post['status']; $model->save(false); $result['msg'] = Yii::t('backend','Customer deactivated successfully'); if ((int)$model->status === $model::ACTIVE) { $result['msg'] = Yii::t('backend','Customer activated successfully'); } $result['status'] = STATUS_SUCCESS; skip: return $this->asJson($result); } /** * @return string * @throws \yii\base\InvalidParamException */ public function actionGetCustomerDetails() { $post = Yii::$app->getRequest()->post(); $result = ['status' => STATUS_FAIL, 'msg' => '' , 'model' => '']; if (!array_key_exists('customer_id', $post)) { $result['msg'] = 'Required Param Missing'; goto skip; } $model = User::findOne(['user_id' => $post['customer_id']]); if ($model === null) { $result['msg'] = 'Unable to find the customer details'; goto skip; } $result['model'] = $model; $result['status'] = STATUS_SUCCESS; $result['msg'] = 'Data Fetched Successfully'; skip: return $this->asJson($result); } /** * @return string * @throws \yii\base\InvalidParamException */ public function actionGetCustomerAddressDetails() { $post = Yii::$app->getRequest()->post(); $result = ['status' => STATUS_FAIL, 'msg' => '', 'model' => '']; if (!array_key_exists('customer_address_id', $post)) { $result['msg'] = 'Required Param Missing'; goto skip; } $query= UserAddress::find() ->alias('UA') ->select('UA.*') ->where(['UA.user_address_id' => $post['customer_address_id']]); UserAddress::selectTranslation($query); $model = $query->asArray()->one(); if ($model === null) { $result['msg'] = 'Unable to find Customer Address Details'; goto skip; } $result['status'] = STATUS_SUCCESS; $result['model'] = $model; $result['msg'] = 'Data Fetched Successfully'; skip: return $this->asJson($result); } /** * @return string * @throws \yii\base\InvalidParamException * * @Title("Quick View") */ public function actionQuickView() { $params = ['id']; $post = Yii::$app->getRequest()->post(); $result = ['status' => STATUS_FAIL, 'msg' => '']; foreach ($params as $param) { if ( !array_key_exists($param, $post) ) { $result['msg'] = Yii::t('backend', 'Required param missing'); goto skip; } } $resposeArray = \backend\models\User::find()->where(['user_key' => $post['id']])->one(); if (empty($resposeArray)) { $result['msg'] = Yii::t('backend', 'Invalid user key'); goto skip; } $aData['user'] = [ 'user_key' => $resposeArray->user_key, 'user_id' => $resposeArray->user_id, 'first_name' => $resposeArray->first_name, 'last_name' => $resposeArray->last_name, 'email' => $resposeArray->email, 'mobile_number' => $resposeArray->mobile_number, 'status' => $resposeArray->status, 'wallet_point' => $resposeArray->wallet_point, 'loyality_point' => $resposeArray->loyality_point, ]; $model = \frontend\models\UserAddress::getaddress($resposeArray->user_id); $addresstype = \frontend\models\AddressType::getaddresstype(); $aData['user_address'] = []; if (!empty($model) && count($model) > 0) { foreach ($model as $aKey => $aVal) { $aData['user_address'][$aKey] = [ 'user_address_id' => $aVal['user_address_id'], 'latitude' => $aVal['latitude'], 'longitude' => $aVal['longitude'], 'flat_no' => $aVal['flat_no'], 'apartment' => $aVal['apartment'], 'street_name' => $aVal['street_name'], 'city' => $aVal['city'], 'area' => $aVal['area'], 'company' => $aVal['company'], 'landmark' => $aVal['landmark'], 'address_type_name' => $aVal['address_type_name'], 'full_address' => $aVal['flat_no']. ','.$aVal['apartment'].','.$aVal['street_name'].','.$aVal['city'].','.$aVal['area'].','.$aVal['company'].','.$aVal['landmark'], ]; $fullAddress = str_replace(',', ', ', preg_replace('/,{2,}/',',',$aData['user_address'][$aKey]['full_address'])); $aData['user_address'][$aKey]['full_address'] = substr($fullAddress, 0, -2).'.'; } } $result['status'] = STATUS_SUCCESS; $result['response'] = json_encode($resposeArray->toArray()); $result['data'] = $this->renderPartial('quick-view', ['resposeArray' => $aData]); skip: return $this->asJson($result); } public function actionSms() { $request =""; //initialise the request variable $param['method']= "sendMessage"; $param['send_to'] = "7904070932"; $param['msg'] = "1234 is the OTP to verify your mobile number on OPEN. It will expire in 15 minutes. Do not share it with anyone."; $param['userid'] = "2000189927"; $param['password'] = "Ajeeshis100%"; $param['v'] = "1.1"; $param['msg_type'] = "TEXT"; //Can be "FLASH”/"UNICODE_TEXT"/”BINARY” //$param['auth_scheme'] = "PLAIN";//Have to URL encode the values foreach($param as $key=>$val) { $request.= $key."=".urlencode($val);//we have to urlencode the values $request.= "&";//append the ampersand (&) sign after eachparameter/value pair } $request = substr($request, 0, strlen($request)-1);//remove final (&) sign from the request $url ="http://enterprise.smsgupshup.com/GatewayAPI/rest?".$request; $ch = curl_init($url); curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); $curl_scraped_page = curl_exec($ch); curl_close($ch); print_r($curl_scraped_page); die; echo $curl_scraped_page; } public function actionNotification() { $currentTime = Date('H:i'); $timeslots = []; $userToken = []; $t1 = strtotime('05:00'); $t2 = strtotime('23:00'); while ($t1 < $t2) { $t1 = strtotime('+1 hour', $t1); $timeslots[] = date('H:i', $t1); } if(in_array($currentTime, $timeslots)) { $dateIndex = [ '1' => 'monday_status', '2' => 'tuesday_status', '3' => 'wednesday_status', '4' => 'thursday_status', '5' => 'friday_status', '6' => 'startday_status', '7' => 'sunday_status', ]; $modelUser = User::find()->where(['is_health_advice' => User::ACTIVE, 'status' => User::ACTIVE])->all(); foreach ($modelUser as $key => $user) { $todayDateStatus = $dateIndex[date('w')]; $userReminder = UserReminder::find() ->where([ 'user_id' => $user['user_id'], 'user_reminder_status' => User::ACTIVE ]) ->andwhere(["$todayDateStatus" => User::ACTIVE]) ->one(); if($userReminder != null && $user['device_token']) { $userToken[] = $user['device_token']; } } } if($userToken != []) { try { $oneSignal = OneSignal::getInstance(); $oneSignal->setAppId(Configuration::get(Configuration::PUSH_NOTIFICATION_APP_ID)); $oneSignal->setRestApiKey(Configuration::get(Configuration::PUSH_NOTIFICATION_REST_API_KEY)); $oneSignal->setIcon('http://online.kitokey.com/frontend/web/theme/images/notification.png'); $oneSignal->push( ['en' => 'Order status'], ['en' => 'Hi, now it is your water drinking time.. let`s go for drinking'], $userToken, ['status' => 'Message Sent Successfully'] ); } catch(Exception $e) { echo $e->getMessage(); } } } }