Server IP : 185.86.78.101 / Your IP : 216.73.216.124 Web Server : Apache System : Linux 675867-vds-valikoshka1996.gmhost.pp.ua 5.4.0-150-generic #167-Ubuntu SMP Mon May 15 17:35:05 UTC 2023 x86_64 User : www ( 1000) PHP Version : 7.4.33 Disable Function : passthru,exec,system,putenv,chroot,chgrp,chown,shell_exec,popen,proc_open,pcntl_exec,ini_alter,ini_restore,dl,openlog,syslog,readlink,symlink,popepassthru,pcntl_alarm,pcntl_fork,pcntl_waitpid,pcntl_wait,pcntl_wifexited,pcntl_wifstopped,pcntl_wifsignaled,pcntl_wifcontinued,pcntl_wexitstatus,pcntl_wtermsig,pcntl_wstopsig,pcntl_signal,pcntl_signal_dispatch,pcntl_get_last_error,pcntl_strerror,pcntl_sigprocmask,pcntl_sigwaitinfo,pcntl_sigtimedwait,pcntl_exec,pcntl_getpriority,pcntl_setpriority,imap_open,apache_setenv MySQL : OFF | cURL : ON | WGET : ON | Perl : ON | Python : OFF | Sudo : ON | Pkexec : OFF Directory : /www/wwwroot/mifepriston.org/modules/admin/controllers/ |
Upload File : |
<?php namespace app\modules\admin\controllers; use Yii; use yii\web\Controller; use yii\web\BadRequestHttpException; use app\models\Status; use app\models\OrderStatuses; use app\models\ShippingMethod; /** * Default controller for the `admin` module */ class DefaultController extends Controller { /** * @inheritdoc */ public function behaviors() { return [ 'contentType' => [ 'class' => 'yii\filters\ContentNegotiator', 'except' => ['index'], 'formats' => [ 'application/json' => \yii\web\Response::FORMAT_JSON ] ], ]; } /** * Renders the index view for the module * @return string */ public function actionIndex() { return $this->render('index'); } /** * Retrievers the orders * @return JSON array */ public function actionGetData() { $state = (int) Yii::$app->request->get('state'); $query = (new \yii\db\Query()) ->select([ 'o.*', 's.status_date', 's.status_id', 's.message']) ->from('orders o') ->innerJoin('order_statuses s', 's.order_id = o.id and s.status_date = (select max(status_date) from order_statuses where order_id = s.order_id)'); if ($state) $query->where('s.status_id = :state', [':state' => $state]); $query->orderBy('o.id DESC'); return $query->all(); } /** * Retrieves the `status` dictionary * @return array */ public function actionGetStatuses() { return Status::find()->orderBy('id')->all(); } /** * Retrieves the `shipping_methods` dictionary * @return array */ public function actionGetShipping() { return ShippingMethod::find()->orderBy('id')->all(); } public function actionStatusTranslation() { $result = []; $category = 'status'; foreach (array_keys(Yii::$app->params['languages']) as $lang) { Yii::$app->language = $lang; $fileMap = Yii::$app->i18n->getMessageSource($category)->fileMap; $file = require(Yii::getAlias(Yii::$app->i18n->getMessageSource($category)->basePath . '/' . $lang . '/' . $fileMap[$category])); foreach ($file as $src => $translation) { $result[] = [ 'lang' => $lang, 'src' => $src, 'translation' => $translation, ]; } } return $result; } public function actionSendStatus() { $model = new OrderStatuses; if ($model->load(Yii::$app->request->post())) { if ($model->save()) { if (intval(Yii::$app->request->post('sendMsg'))) { try { $sms = Yii::$app->smsGate->sendSMS($model->phone, $model->message); } catch (\Exception $exc) { $sms = $exc->getMessage(); } } else $sms = ''; return [ 'result' => 'OK', 'status_id' => $model->status_id, 'status_date' => $model->status_date, 'message' => $model->message, 'sms' => $sms, ]; } } throw new BadRequestHttpException('Invalid status sent'); } public function actionStatusHistory() { $order_id = (int) Yii::$app->request->get('order_id'); return OrderStatuses::find()->where('order_id = :order_id', [':order_id' => $order_id])->orderBy('status_date ASC')->all(); } }