Exemplo n.º 1
0
 public function deleteEmploy($id)
 {
     $model = Employ::findOne($id);
     if (!$model) {
         return false;
     }
     if ($model->delete()) {
         return true;
     }
     return false;
 }
Exemplo n.º 2
0
 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]);
 }