update phân quyền chi tiết
This commit is contained in:
@@ -58,6 +58,12 @@ class StaffController extends Controller {
|
||||
public function actionCreate() {
|
||||
$model = new Staff();
|
||||
Yii::$app->response->format = "json";
|
||||
if (!Yii::$app->user->can(Yii::$app->controller->id . "Create"))
|
||||
return [
|
||||
"title" => Html::tag("i", "", ["class" => "fa fa-info-circle"]) . " Cảnh báo",
|
||||
"form" => "Bạn không có quyền truy cập"
|
||||
];
|
||||
|
||||
if (Yii::$app->request->post()) {
|
||||
$data = Yii::$app->request->post();
|
||||
$check = Staff::findOne(['code' => $data['Code']]);
|
||||
@@ -90,6 +96,12 @@ class StaffController extends Controller {
|
||||
public function actionUpdate($id) {
|
||||
$model = $this->findModel($id);
|
||||
Yii::$app->response->format = "json";
|
||||
if (!Yii::$app->user->can(Yii::$app->controller->id . "Update"))
|
||||
return [
|
||||
"title" => Html::tag("i", "", ["class" => "fa fa-info-circle"]) . " Cảnh báo",
|
||||
"form" => "Bạn không có quyền truy cập"
|
||||
];
|
||||
|
||||
if (Yii::$app->request->post()) {
|
||||
$data = Yii::$app->request->post();
|
||||
$check = Staff::findOne(['code' => $data['Code']]);
|
||||
@@ -135,6 +147,12 @@ class StaffController extends Controller {
|
||||
}
|
||||
|
||||
public function actionDelete() {
|
||||
if (!Yii::$app->user->can(Yii::$app->controller->id . "Delete"))
|
||||
return [
|
||||
"title" => Html::tag("i", "", ["class" => "fa fa-info-circle"]) . " Cảnh báo",
|
||||
"form" => "Bạn không có quyền truy cập"
|
||||
];
|
||||
|
||||
if (Yii::$app->request->post()) {
|
||||
$lists = Yii::$app->request->post("lists");
|
||||
Staff::deleteAll(["IN", "id", $lists]);
|
||||
@@ -151,6 +169,9 @@ class StaffController extends Controller {
|
||||
}
|
||||
|
||||
public function actionExport() {
|
||||
if (!Yii::$app->user->can(Yii::$app->controller->id . "Export"))
|
||||
throw new \yii\web\HttpException(403, 'Bạn không có quyền truy cập nội dung này');
|
||||
|
||||
$objPHPExcel = new \PHPExcel();
|
||||
$objPHPExcel->setActiveSheetIndex(0);
|
||||
$toExcelFile[] = ["Mã nhân viên", "Tên nhân viên", "Số thẻ", "Phòng ban", "Giới tính", "Ngày sinh", "Email", "Điện thoại", "Ngày bắt đầu làm việc", "Địa chỉ"];
|
||||
@@ -259,6 +280,9 @@ class StaffController extends Controller {
|
||||
}
|
||||
|
||||
public function actionImport() {
|
||||
if (!Yii::$app->user->can(Yii::$app->controller->id . "Import"))
|
||||
throw new \yii\web\HttpException(403, 'Bạn không có quyền truy cập nội dung này');
|
||||
|
||||
if (Yii::$app->request->post()) {
|
||||
$post = Yii::$app->request->post("lists");
|
||||
$datas = [];
|
||||
|
||||
Reference in New Issue
Block a user