public function __construct($id, $module, $config = []) { if ($this->isNeedLogin) { \Yii::$app->session->open(); $model = new AdminUser(); if (!$model->checkUserIsLogin()) { $this->redirect(Variable::$home_url); return; } } parent::__construct($id, $module, $config = []); }
public function actionEditemploy() { $user = new AdminUser(); if (!$user->checkUserIsLogin()) { $this->redirect(Variable::$home_url); return; } $req = Yii::$app->request; //创建一个请求对象 $form = new EmployForm(); $form->setScenario('update'); $id = trim($req->get('id')); if (!is_numeric($id) || $id == 0) { $this->redirect(Variable::$employIndex_url); return; } //修改 if ($form->load($req->post()) && $form->validate()) { $isSuccess = (new Employ())->updateEmploy($id, $form->department, $form->employName, $form->address, $form->employCode, $form->group, $form->count, $form->money, $form->type, $form->category, $form->description, $form->sendEmail, $form->status); if ($isSuccess) { // $form->addError('','更新成功'); // echo Alert::widget([ // 'type' => Alert::TYPE_SUCCESS, // 'options' => [ // 'title' => '', // 'text' => "资料更新成功", // 'confirmButtonText' => "确定", // 'cancelButtonText' => "取消" // ] // ]); Yii::$app->session->setFlash(Variable::$flash_success, '招聘信息修改成功'); } else { // $form->addError('','更新失败'); Yii::$app->session->setFlash(Variable::$flash_error, '招聘信息修改失败,请重试'); } } $employModel = Employ::findOne($id); $form->department = $employModel->department; $form->employName = $employModel->employName; $form->employCode = $employModel->employCode; $form->sendEmail = $employModel->sendEmail; $form->count = $employModel->count; $form->money = $employModel->money; $form->category = $employModel->category; $form->type = $employModel->type; $form->group = $employModel->group; $form->address = $employModel->address; $form->status = $employModel->status; $form->description = $employModel->description; return $this->render(Variable::$editEmploy_view, ['model' => $form, 'employModel' => $employModel]); }
public function actionLogin() { $user = new AdminUser(); if ($user->checkUserIsLogin()) { $this->redirect(Variable::$setting_url); return; } $req = Yii::$app->request; //创建一个请求对象 $model = new AdminUserLoginForm(); //创建一个登陆的表单对象 if ($model->load($req->post()) && $model->validate()) { $user->loginAdminUser($model->username); $this->redirect(Variable::$setting_url); } return $this->render(Variable::$siteLogin_view, ['model' => $model]); }
public function actionDeliverorder() { $user = new AdminUser(); if (!$user->checkUserIsLogin()) { $this->redirect(Variable::$home_url); return; } $req = Yii::$app->request; //创建一个请求对象 $form = new OrderDeliverForm(); $form->setScenario('update'); $id = trim($req->get('id')); if (!is_numeric($id) || $id == 0) { $this->redirect(Variable::$orderManger_url); return; } $orderModel = Order::findOne($id); $orderExpressInfoModel = (new OrderExpressInfo())->findOne(['orderId' => $id]); $userAddressModel = (new UserAddress())->findOne(['id' => $orderModel->addressId]); $orderStyleModel = (new Express())->find()->all(); //修改 if ($form->load($req->post()) && $form->validate()) { $isSuccess = (new OrderExpressInfo())->deliver($id, $form->expressNo, $form->expressStyle, $form->expressChart); if ($isSuccess) { $form->addError('', '订单发货成功'); } else { $form->addError('', '订单发货失败'); } } $form->orderNo = $orderModel->orderNo; $form->orderMoney = $orderModel->orderMoney; $form->orderStatus = $orderModel->orderStatus; $form->orderPayMethod = $orderModel->orderPayMethod; $form->orderStatus = $orderModel->orderStatus; if ($orderExpressInfoModel) { $form->expressNo = $orderExpressInfoModel->expressNo; $form->expressStyle = $orderExpressInfoModel->expressStyle; } return $this->render(Variable::$deliverOrder_view, ['model' => $form, 'orderModel' => $orderModel, 'orderExpressInfoModel' => $orderExpressInfoModel, 'orderStyleModel' => $orderStyleModel, 'userAddressModel' => $userAddressModel]); }
public function actionEditservice() { $user = new AdminUser(); if (!$user->checkUserIsLogin()) { $this->redirect(Variable::$home_url); return; } $req = Yii::$app->request; //创建一个请求对象 $form = new ArticleForm(); $form->setScenario('service'); $id = trim($req->get('id')); if (!is_numeric($id) || $id == 0) { $this->redirect(Variable::$employIndex_url); return; } //修改 if ($form->load($req->post()) && $form->validate()) { $isSuccess = (new Article())->updateArticleByService($id, $form->title, $form->useId, $form->keywords, $form->pic, $form->content); // $isSuccess = (new Employ())->updateEmploy($id,$form->department,$form->employName,$form->address,$form->employCode,$form->group,$form->count,$form->money,$form->type,$form->category,$form->description,$form->sendEmail,$form->status); if ($isSuccess) { Yii::$app->session->setFlash(Variable::$flash_success, '服务项修改成功'); $this->redirect(Variable::$serviceIndex_url); return; } else { Yii::$app->session->setFlash(Variable::$flash_error, '服务项修改失败,请重试'); return; } } $articleModel = Article::findOne($id); $form->title = $articleModel->title; $form->keywords = $articleModel->keywords; $form->pic = $articleModel->pic; $form->useId = $articleModel->useId; $form->content = $articleModel->content; return $this->render(Variable::$editService_view, ['model' => $form, 'articleModel' => $articleModel]); }
public function actionEditactivity() { $user = new AdminUser(); if (!$user->checkUserIsLogin()) { $this->redirect(Variable::$home_url); return; } $req = Yii::$app->request; //创建一个请求对象 $form = new ActivityForm(); $form->setScenario('update'); $id = trim($req->get('id')); if (!is_numeric($id) || $id == 0) { $this->redirect(Variable::$activityList_url); return; } //修改 if ($form->load($req->post()) && $form->validate()) { $isSuccess = (new Activity())->updateActivity($id, $form->name, $form->startTime, $form->endTime, $form->description, $form->rule, $form->isShow, $form->pcUrl, $form->wapUrl, $form->discount, $form->reduceMoney, $form->status); if ($isSuccess) { $form->addError('', '更新成功'); echo Alert::widget(['type' => Alert::TYPE_SUCCESS, 'options' => ['title' => '', 'text' => "资料更新成功", 'confirmButtonText' => "确定", 'cancelButtonText' => "取消"]]); } else { $form->addError('', '更新失败'); } } $activityModel = Activity::findOne($id); $form->name = $activityModel->name; $form->startTime = $activityModel->startTime; $form->endTime = $activityModel->endTime; $form->rule = $activityModel->rule; $form->description = $activityModel->description; $form->isShow = $activityModel->isShow; $form->pcUrl = $activityModel->pcUrl; $form->wapUrl = $activityModel->wapUrl; $form->discount = $activityModel->discount; $form->reduceMoney = $activityModel->reduceMoney; $form->status = $activityModel->status; return $this->render(Variable::$editActivity_view, ['model' => $form, 'activityModel' => $activityModel]); }
public function actionEditbarlist() { $user = new AdminUser(); if (!$user->checkUserIsLogin()) { $this->redirect(Variable::$home_url); return; } // $form=new BarForm(); // $req=Yii::$app->request;//创建一个请求对象 // $form->setScenario('update'); // if($form->load($req->post()) && $form->validate()){ // print_r($form); // } // $form->setScenario('update'); $req = Yii::$app->request; //创建一个请求对象 $id = trim($req->get('id')); if (!is_numeric($id) || $id == 0) { $this->redirect(Variable::$barIndex_url); return; } $barModel = Bar::findOne($id); $barListModel = Bar::find()->where(['parentBar' => $id])->all(); return $this->render(Variable::$editBarList_view, ['barModel' => $barModel, 'barListModel' => $barListModel]); }
public function actionShowarticle() { $user = new AdminUser(); if (!$user->checkUserIsLogin()) { $this->redirect(Variable::$home_url); return; } $req = Yii::$app->request; $id = trim($req->get('id')); if (!is_numeric($id) || $id == 0) { $this->redirect(Variable::$articleManger_url); return; } return $this->render(Variable::$showArticle_view, ['model' => (new Article())->findOne($id)]); }
public function actionEditadminuser() { $user = new AdminUser(); if (!$user->checkUserIsLogin()) { $this->redirect(Variable::$home_url); return; } $req = Yii::$app->request; //创建一个请求对象 $form = new AdminUserForm(); $form->setScenario('update'); $adminUserModel = new AdminUser(); $id = trim($req->get('id')); if (!is_numeric($id) || $id == 0) { $this->redirect(Variable::$adminUserManger_url); return; } //修改 if ($form->load($req->post()) && $form->validate()) { $isSuccess = $adminUserModel->updateAdminUser($id, $form->password, $form->mobile, $form->role, $form->status); if ($isSuccess) { $form->addError('', '资料更新成功'); } else { $form->addError('', '资料更新失败'); } } $adminUserModel = $adminUserModel->findUserByUserId($id); $form->username = $adminUserModel->username; $form->password = $adminUserModel->password; $form->role = $adminUserModel->role; $form->mobile = $adminUserModel->mobile; $form->status = $adminUserModel->status; return $this->render(Variable::$editAdminUser_view, ['model' => $form, 'adminUserModel' => $adminUserModel]); }
public function actionEditprobanner() { $user = new AdminUser(); if (!$user->checkUserIsLogin()) { $this->redirect(Variable::$home_url); return; } $req = Yii::$app->request; //创建一个请求对象 $form = new MaterialForm(); $form->setScenario('probanner'); $id = trim($req->get('id')); if (!is_numeric($id) || $id == 0) { $this->redirect(Variable::$setting_url); return; } $materialModel = Material::findOne($id); $form->materialId = $materialModel->materialId; //修改 if ($form->load($req->post()) && $form->validate()) { $isSuccess = (new Material())->updateMaterial($id, $form->materialId, $form->address, $form->isShow, $form->sort, $form->pcUrl, $form->wapUrl); if ($isSuccess) { Yii::$app->session->setFlash(Variable::$flash_success, '资料更新成功'); } else { Yii::$app->session->setFlash(Variable::$flash_error, '资料更新失败,请刷新重试'); } $this->redirect(Variable::$proBanner_url); return; } $materialModel = Material::findOne($id); $form->materialId = $materialModel->materialId; $form->id = $materialModel->id; $form->address = $materialModel->address; $form->isShow = $materialModel->isShow; $form->sort = $materialModel->sort; $form->pcUrl = $materialModel->pcUrl; $form->wapUrl = $materialModel->wapUrl; return $this->render(Variable::$editProBanner_view, ['model' => $form, 'materialModel' => $materialModel]); }
public function actionAddproductcat() { $user = new AdminUser(); if (!$user->checkUserIsLogin()) { $this->redirect(Variable::$home_url); return; } //请求处理 $req = Yii::$app->request; $name = trim($req->post('name')); $sort = trim($req->post('sort')); $desc = trim($req->post('desc')); if ((new ProductCategory())->addCat($name, $sort, $desc)) { JsonParser::GenerateJsonResult('_0000', '添加成功'); exit; } JsonParser::GenerateJsonResult('_0001', '添加失败'); exit; }
public function actionEditpointimg() { $user = new AdminUser(); if (!$user->checkUserIsLogin()) { $this->redirect(Variable::$home_url); return; } $req = Yii::$app->request; //创建一个请求对象 $form = new CustomerForm(); $form->level = Variable::$customer_type_w; $form->setScenario('img'); $id = trim($req->get('id')); if (!is_numeric($id) || $id == 0) { $this->redirect(Variable::$customerBrand_url); return; } //修改 if ($form->load($req->post()) && $form->validate()) { $isSuccess = (new Customer())->updateCus($id, $form->name, $form->sort, $form->level, $form->blogo, $form->clogo, $form->img1, $form->img2, $form->img3, $form->img4, $form->img5); if ($isSuccess) { Yii::$app->session->setFlash(Variable::$flash_success, '设置成功'); } else { // $form->addError('','更新失败'); Yii::$app->session->setFlash(Variable::$flash_error, '设置失败,请重试'); } } $customerModel = Customer::findOne($id); $form->img1 = $customerModel->img1; $form->img2 = $customerModel->img2; $form->img3 = $customerModel->img3; $form->img4 = $customerModel->img4; $form->img5 = $customerModel->img5; $form->name = $customerModel->name; $form->id = $customerModel->id; $list = []; if (!empty($form->img1)) { array_push($list, $form->img1); } if (!empty($form->img2)) { array_push($list, $form->img2); } if (!empty($form->img3)) { array_push($list, $form->img3); } if (!empty($form->img4)) { array_push($list, $form->img4); } if (!empty($form->img5)) { array_push($list, $form->img5); } return $this->render(Variable::$editPointImg_view, ['model' => $form, 'customerModel' => $customerModel, 'list' => $list]); }