fix lỗi đồng bộ dữ liệu không xóa các dữ liệu cũ
This commit is contained in:
@@ -91,7 +91,13 @@ class AssignController extends Controller {
|
||||
public function actionSetSchedule() {
|
||||
if (Yii::$app->request->post()) {
|
||||
$post = Yii::$app->request->post();
|
||||
Staff::updateAll(["schedule_id" => $post["schedule"], "door_access" => json_encode($post["doors"])], ["IN", "id", $post["staffs"]]);
|
||||
$lists = Staff::find()->andWhere(["IN", "id", $post["staffs"]])->all();
|
||||
foreach ($lists as $key => $value) {
|
||||
$value->schedule_id = $post["schedule"];
|
||||
$value->door_access_old = $value->door_access;
|
||||
$value->door_access = json_encode($post["doors"]);
|
||||
$value->save();
|
||||
}
|
||||
$doors = [];
|
||||
foreach ($post["doors"] as $key => $value) {
|
||||
$doors[] = Door::findOne($value)->name;
|
||||
|
||||
Reference in New Issue
Block a user