create branch non open door
This commit is contained in:
parent
c8e0bb7795
commit
eac0a940fe
|
@ -583,12 +583,6 @@ class ApiController extends Controller {
|
||||||
if ($value['action'] == "remove_info")
|
if ($value['action'] == "remove_info")
|
||||||
$result = $this->removeInfo($value);
|
$result = $this->removeInfo($value);
|
||||||
|
|
||||||
if ($value['action'] == "insert_door_open")
|
|
||||||
$result = $this->insertSchedule($value);
|
|
||||||
|
|
||||||
if ($value['action'] == "remove_door_open")
|
|
||||||
$result = $this->removeSchedule($value);
|
|
||||||
|
|
||||||
if ($value['action'] == "reset_all") {
|
if ($value['action'] == "reset_all") {
|
||||||
\Yii::$app->db->createCommand()->truncateTable('capture_logs')->execute();
|
\Yii::$app->db->createCommand()->truncateTable('capture_logs')->execute();
|
||||||
\Yii::$app->db->createCommand()->truncateTable('list_management')->execute();
|
\Yii::$app->db->createCommand()->truncateTable('list_management')->execute();
|
||||||
|
@ -599,7 +593,7 @@ class ApiController extends Controller {
|
||||||
if (Yii::$app->params['autoSyncLog'])
|
if (Yii::$app->params['autoSyncLog'])
|
||||||
file_put_contents("logs.txt", $count . "\t" . $value['action'] . "\t" . $value['files_name'][0] . "\t" . ($result ? "true" : "false") . "\t" . $processTime . "\t" . $value['name'] . "\n", FILE_APPEND);
|
file_put_contents("logs.txt", $count . "\t" . $value['action'] . "\t" . $value['files_name'][0] . "\t" . ($result ? "true" : "false") . "\t" . $processTime . "\t" . $value['name'] . "\n", FILE_APPEND);
|
||||||
|
|
||||||
if (in_array($value['action'], ['insert_image', 'remove_image', 'insert_info', 'remove_info', 'reset_all', 'insert_door_open', 'remove_door_open'])) {
|
if (in_array($value['action'], ['insert_image', 'remove_image', 'insert_info', 'remove_info', 'reset_all'])) {
|
||||||
if ($result)
|
if ($result)
|
||||||
$infomation[] = [
|
$infomation[] = [
|
||||||
"obj_Log" => $value['obj_Log'],
|
"obj_Log" => $value['obj_Log'],
|
||||||
|
@ -771,59 +765,6 @@ class ApiController extends Controller {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function insertSchedule($data) {
|
|
||||||
$model = new Schedule();
|
|
||||||
$info = ListManagement::findOne(['staff_id' => $data['id']]);
|
|
||||||
$schedule = Schedule::findOne(['staff_id' => $info->id, 'id_door_calendar' => $data['id_door_calendar']]);
|
|
||||||
if ($schedule) {
|
|
||||||
$schedule->from_time = $data['time_in'];
|
|
||||||
$schedule->to_time = $data['time_out'];
|
|
||||||
$schedule->from_date = $this->formatDateSchedule($data['day_in']);
|
|
||||||
$schedule->to_date = $this->formatDateSchedule($data['day_out']);
|
|
||||||
$schedule->date_of_week = $this->formatDayOfWeekSchedule($data['day_of_week']);
|
|
||||||
return $schedule->save();
|
|
||||||
} else {
|
|
||||||
return $model->create([
|
|
||||||
'staff_id' => $info->id,
|
|
||||||
'from_time' => $data['time_in'],
|
|
||||||
'to_time' => $data['time_out'],
|
|
||||||
'from_date' => $this->formatDateSchedule($data['day_in']),
|
|
||||||
'to_date' => $this->formatDateSchedule($data['day_out']),
|
|
||||||
'date_of_week' => $this->formatDayOfWeekSchedule($data['day_of_week']),
|
|
||||||
'id_door_calendar' => $data['id_door_calendar']
|
|
||||||
]);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public function removeSchedule($data) {
|
|
||||||
$info = ListManagement::findOne(['staff_id' => $data['id']]);
|
|
||||||
if ($info) {
|
|
||||||
$schedule = \app\models\Schedule::findOne([
|
|
||||||
'id_door_calendar' => $data['id_door_calendar'],
|
|
||||||
'staff_id' => $info->id
|
|
||||||
]);
|
|
||||||
if ($schedule)
|
|
||||||
$schedule->delete();
|
|
||||||
}
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
public function formatDateSchedule($date) {
|
|
||||||
$temp = explode(" ", $date);
|
|
||||||
$parse = explode("-", $temp[0]);
|
|
||||||
return $parse[2] . "/" . $parse[1] . "/" . $parse[0];
|
|
||||||
}
|
|
||||||
|
|
||||||
public function formatDayOfWeekSchedule($dayOfWeek) {
|
|
||||||
$days = [];
|
|
||||||
$temp = explode("|", $dayOfWeek);
|
|
||||||
foreach ($temp as $key => $value) {
|
|
||||||
if ($value != "")
|
|
||||||
$days[] = intval($value) + 2;
|
|
||||||
}
|
|
||||||
return implode(",", $days);
|
|
||||||
}
|
|
||||||
|
|
||||||
public function actionCheckOpenDoor() {
|
public function actionCheckOpenDoor() {
|
||||||
if (Yii::$app->request->post()) {
|
if (Yii::$app->request->post()) {
|
||||||
$post = Yii::$app->request->bodyParams;
|
$post = Yii::$app->request->bodyParams;
|
||||||
|
|
Loading…
Reference in New Issue
Block a user