Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
D
docker-x86-ai-guardian
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
YONG-LIN SU
docker-x86-ai-guardian
Commits
f870efcd
Commit
f870efcd
authored
Oct 04, 2021
by
k54990881
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
update
parent
6c09e045
Changes
19
Hide whitespace changes
Inline
Side-by-side
Showing
19 changed files
with
1540 additions
and
16 deletions
+1540
-16
dump.rdb
data/redis/dump.rdb
+0
-0
device_shift_relation_model.py
flask/notebook/models/device_shift_relation_model.py
+124
-0
influx_model.py
flask/notebook/models/influx_model.py
+2
-0
shift_model.py
flask/notebook/models/shift_model.py
+138
-0
base_resource.py
flask/notebook/resources/base_resource.py
+3
-1
device_shift_relation_resource.py
flask/notebook/resources/device_shift_relation_resource.py
+92
-0
punch_card_resource.py
flask/notebook/resources/punch_card_resource.py
+88
-0
shift_resource.py
flask/notebook/resources/shift_resource.py
+100
-0
run_v1.py
flask/notebook/run_v1.py
+18
-1
20210922.txt
flask/notebook/static/File/20210922.txt
+0
-0
20210930.txt
flask/notebook/static/File/20210930.txt
+4
-0
20211001.txt
flask/notebook/static/File/20211001.txt
+4
-0
.gitignore
laravel-guardian/.idea/.gitignore
+0
-0
vcs.xml
laravel-guardian/.idea/vcs.xml
+1
-0
DeviceController.php
laravel-guardian/app/Http/Controllers/DeviceController.php
+395
-6
Device.blade.php
laravel-guardian/resources/views/Device.blade.php
+2
-2
Shift.blade.php
laravel-guardian/resources/views/Shift.blade.php
+552
-0
contents.blade.php
laravel-guardian/resources/views/contents.blade.php
+7
-6
web.php
laravel-guardian/routes/web.php
+10
-0
No files found.
data/redis/dump.rdb
View file @
f870efcd
No preview for this file type
flask/notebook/models/device_shift_relation_model.py
0 → 100644
View file @
f870efcd
from
mysql_model
import
BaseModel
import
os
,
json
,
base64
,
requests
from
dbsql
import
MySQL
env
=
os
.
environ
host
=
env
[
'MYSQL_HOST'
]
if
'MYSQL_HOST'
in
env
else
"192.168.6.194"
port
=
int
(
env
[
'MYSQL_PORT'
])
if
'MYSQL_PORT'
in
env
else
23306
usr
=
env
[
'MYSQL_USR'
]
if
'MYSQL_USR'
in
env
else
"root"
pwd
=
env
[
'MYSQL_PWD'
]
if
'MYSQL_PWD'
in
env
else
"123456"
db
=
env
[
'MYSQL_DB'
]
if
'MYSQL_DB'
in
env
else
"ecom"
mysql
=
MySQL
(
host
,
port
,
usr
,
pwd
,
db
)
# ========== 機器班別關係資料庫模型 ==========
class
DeviceShiftRelationModel
(
BaseModel
):
def
__init__
(
self
,
ID
=
None
):
super
()
.
__init__
()
self
.
table
=
'device_shift_relation'
if
(
ID
!=
None
):
self
.
data
[
'no'
]
=
ID
if
isinstance
(
ID
,
str
)
else
str
(
ID
)
self
.
data
[
'device_id'
]
=
None
self
.
data
[
'shift_no'
]
=
None
self
.
data
[
'note'
]
=
None
# ===== no ========================================
def
GetNo
(
self
):
return
self
.
data
[
'no'
]
if
'no'
in
self
.
data
else
None
# ===== device_id ========================================
def
SetDeviceId
(
self
,
device_id
):
return
self
.
SetValue
(
'device_id'
,
device_id
,
str
,
False
)
def
GetDeviceId
(
self
):
return
self
.
data
[
'device_id'
]
if
'device_id'
in
self
.
data
else
None
def
GetOldDeviceId
(
self
):
return
self
.
change
[
'device_id'
]
def
HasChangeDeviceId
(
self
):
return
'device_id'
in
self
.
change
# ===== shift_no ========================================
def
SetShiftNo
(
self
,
shift_no
):
return
self
.
SetValue
(
'shift_no'
,
shift_no
,
str
,
False
)
def
GetShiftNo
(
self
):
return
self
.
data
[
'shift_no'
]
if
'shift_no'
in
self
.
data
else
None
def
GetOldShiftNo
(
self
):
return
self
.
change
[
'shift_no'
]
def
HasChangeShiftNo
(
self
):
return
'shift_no'
in
self
.
change
# ===== note ========================================
def
SetNote
(
self
,
note
):
return
self
.
SetValue
(
'note'
,
note
,
str
,
True
)
def
GetNote
(
self
):
return
self
.
data
[
'note'
]
if
'note'
in
self
.
data
else
None
def
GetOldNote
(
self
):
return
self
.
change
[
'note'
]
def
HasChangeNote
(
self
):
return
'note'
in
self
.
change
# ===== operate database ========================================
def
InsertToDB
(
self
,
log
):
keys
=
self
.
data
.
keys
()
values
=
[
self
.
data
[
x
]
for
x
in
keys
]
mysql
.
SetLog
(
log
)
script
=
mysql
.
Insert
(
self
.
table
,
keys
,
values
)
return
script
.
Fetch
()
def
UpdateToDB
(
self
,
log
):
script
=
None
for
k
in
self
.
data
.
keys
():
mysql
.
SetLog
(
log
)
script
=
mysql
.
Update
(
self
.
table
,
k
,
self
.
data
[
k
])
if
script
is
None
else
script
.
Add
(
k
,
self
.
data
[
k
])
script
=
script
.
Where
(
'no'
,
'='
,
self
.
data
[
'no'
])
return
script
.
FetchOne
()
def
DeleteFromDB
(
self
,
log
):
script
=
mysql
.
Delete
(
self
.
table
)
.
Where
(
'no'
,
'='
,
self
.
data
[
'no'
])
mysql
.
SetLog
(
log
)
return
script
.
FetchOne
()
def
ToDict
(
self
):
return
{
'no'
:
self
.
GetNo
(),
'device_id'
:
self
.
GetDeviceId
(),
'shift_no'
:
self
.
GetShiftNo
(),
'note'
:
self
.
GetNote
(),
}
# ===== other ========================================
@
staticmethod
def
FromDB
(
ID
,
log
):
model
=
DeviceShiftRelationModel
(
ID
)
mysql
.
SetLog
(
log
)
script
=
mysql
.
Select
(
'device_shift_relation'
)
.
Where
(
'no'
,
'='
,
ID
)
.
FetchOne
()
if
isinstance
(
script
,
tuple
):
model
.
SetDeviceId
(
script
[
1
])
model
.
SetShiftNo
(
script
[
2
])
model
.
SetNote
(
script
[
3
])
model
.
SetCreated
(
script
[
4
])
model
.
SetUpdated
(
script
[
5
])
model
.
SetDeleted
(
script
[
6
])
model
.
isExist
=
True
return
model
@
staticmethod
def
FromDBByDeviceIdShiftNo
(
DeviceId
,
ShiftNo
,
log
):
model
=
DeviceShiftRelationModel
()
mysql
.
SetLog
(
log
)
script
=
mysql
.
Select
(
'device_shift_relation'
)
.
Where
(
'device_id'
,
'='
,
DeviceId
)
.
And
(
'shift_no'
,
'='
,
ShiftNo
)
.
FetchOne
()
if
isinstance
(
script
,
tuple
):
model
.
SetDeviceId
(
script
[
1
])
model
.
SetShiftNo
(
script
[
2
])
model
.
SetNote
(
script
[
3
])
model
.
SetCreated
(
script
[
4
])
model
.
SetUpdated
(
script
[
5
])
model
.
SetDeleted
(
script
[
6
])
model
.
isExist
=
True
return
model
@
staticmethod
def
AllFromDB
(
log
):
models
=
[]
mysql
.
SetLog
(
log
)
script
=
mysql
.
Select
(
'device_shift_relation'
)
.
FetchAll
()
for
row
in
script
:
model
=
DeviceShiftRelationModel
(
row
[
0
])
model
.
SetDeviceId
(
row
[
1
])
model
.
SetShiftNo
(
row
[
2
])
model
.
SetNote
(
row
[
3
])
model
.
SetCreated
(
row
[
4
])
model
.
SetUpdated
(
row
[
5
])
model
.
SetDeleted
(
row
[
6
])
model
.
isExist
=
True
models
.
append
(
model
)
return
models
\ No newline at end of file
flask/notebook/models/influx_model.py
View file @
f870efcd
...
...
@@ -141,6 +141,8 @@ class PunchInfluxModel(BaseItemInfluxModel):
return
self
.
raw
[
'fields'
][
'name'
]
def
GetType
(
self
):
return
self
.
raw
[
'fields'
][
'type'
]
def
GetDevice
(
self
):
return
self
.
raw
[
'tags'
][
'device'
]
def
GetLocation
(
self
):
return
self
.
raw
[
'tags'
][
'location'
]
def
GetSimilarity
(
self
):
...
...
flask/notebook/models/shift_model.py
0 → 100644
View file @
f870efcd
from
mysql_model
import
BaseModel
import
os
,
json
,
base64
,
requests
from
dbsql
import
MySQL
env
=
os
.
environ
host
=
env
[
'MYSQL_HOST'
]
if
'MYSQL_HOST'
in
env
else
"192.168.6.194"
port
=
int
(
env
[
'MYSQL_PORT'
])
if
'MYSQL_PORT'
in
env
else
23306
usr
=
env
[
'MYSQL_USR'
]
if
'MYSQL_USR'
in
env
else
"root"
pwd
=
env
[
'MYSQL_PWD'
]
if
'MYSQL_PWD'
in
env
else
"123456"
db
=
env
[
'MYSQL_DB'
]
if
'MYSQL_DB'
in
env
else
"ecom"
mysql
=
MySQL
(
host
,
port
,
usr
,
pwd
,
db
)
# ========== 班別資料庫模型 ==========
class
ShiftModel
(
BaseModel
):
def
__init__
(
self
,
ID
=
None
):
super
()
.
__init__
()
self
.
table
=
'shift'
if
(
ID
!=
None
):
self
.
data
[
'no'
]
=
ID
if
isinstance
(
ID
,
str
)
else
str
(
ID
)
self
.
data
[
'name'
]
=
None
self
.
data
[
'start'
]
=
None
self
.
data
[
'end'
]
=
None
self
.
data
[
'note'
]
=
None
# ===== no ========================================
def
GetNo
(
self
):
return
self
.
data
[
'no'
]
if
'no'
in
self
.
data
else
None
# ===== name ========================================
def
SetName
(
self
,
name
):
return
self
.
SetValue
(
'name'
,
name
,
str
,
False
)
def
GetName
(
self
):
return
self
.
data
[
'name'
]
if
'name'
in
self
.
data
else
None
def
GetOldName
(
self
):
return
self
.
change
[
'name'
]
def
HasChangeName
(
self
):
return
'name'
in
self
.
change
# ===== start ========================================
def
SetStart
(
self
,
start
):
return
self
.
SetValue
(
'start'
,
start
,
str
,
False
)
def
GetStart
(
self
):
return
self
.
data
[
'start'
]
if
'start'
in
self
.
data
else
None
def
GetOldStart
(
self
):
return
self
.
change
[
'start'
]
def
HasChangeStart
(
self
):
return
'start'
in
self
.
change
# ===== end ========================================
def
SetEnd
(
self
,
end
):
return
self
.
SetValue
(
'end'
,
end
,
str
,
False
)
def
GetEnd
(
self
):
return
self
.
data
[
'end'
]
if
'end'
in
self
.
data
else
None
def
GetOldEnd
(
self
):
return
self
.
change
[
'end'
]
def
HasChangeEnd
(
self
):
return
'end'
in
self
.
change
# ===== note ========================================
def
SetNote
(
self
,
note
):
return
self
.
SetValue
(
'note'
,
note
,
str
,
True
)
def
GetNote
(
self
):
return
self
.
data
[
'note'
]
if
'note'
in
self
.
data
else
None
def
GetOldNote
(
self
):
return
self
.
change
[
'note'
]
def
HasChangeNote
(
self
):
return
'note'
in
self
.
change
# ===== operate database ========================================
def
InsertToDB
(
self
,
log
):
keys
=
self
.
data
.
keys
()
values
=
[
self
.
data
[
x
]
for
x
in
keys
]
mysql
.
SetLog
(
log
)
script
=
mysql
.
Insert
(
self
.
table
,
keys
,
values
)
return
script
.
Fetch
()
def
UpdateToDB
(
self
,
log
):
script
=
None
for
k
in
self
.
data
.
keys
():
mysql
.
SetLog
(
log
)
script
=
mysql
.
Update
(
self
.
table
,
k
,
self
.
data
[
k
])
if
script
is
None
else
script
.
Add
(
k
,
self
.
data
[
k
])
script
=
script
.
Where
(
'no'
,
'='
,
self
.
data
[
'no'
])
return
script
.
FetchOne
()
def
DeleteFromDB
(
self
,
log
):
script
=
mysql
.
Delete
(
self
.
table
)
.
Where
(
'no'
,
'='
,
self
.
data
[
'no'
])
mysql
.
SetLog
(
log
)
return
script
.
FetchOne
()
def
ToDict
(
self
):
return
{
'no'
:
self
.
GetNo
(),
'name'
:
self
.
GetName
(),
'start'
:
self
.
GetStart
(),
'end'
:
self
.
GetEnd
(),
'note'
:
self
.
GetNote
(),
}
# ===== other ========================================
@
staticmethod
def
FromDB
(
ID
,
log
):
model
=
ShiftModel
(
ID
)
mysql
.
SetLog
(
log
)
script
=
mysql
.
Select
(
'shift'
)
.
Where
(
'no'
,
'='
,
ID
)
.
FetchOne
()
if
isinstance
(
script
,
tuple
):
model
.
SetName
(
script
[
1
])
model
.
SetStart
(
script
[
2
])
model
.
SetEnd
(
script
[
3
])
model
.
SetNote
(
script
[
4
])
model
.
SetCreated
(
script
[
5
])
model
.
SetUpdated
(
script
[
6
])
model
.
SetDeleted
(
script
[
7
])
model
.
isExist
=
True
return
model
@
staticmethod
def
FromDBByName
(
Name
,
log
):
model
=
ShiftModel
()
mysql
.
SetLog
(
log
)
script
=
mysql
.
Select
(
'shift'
)
.
Where
(
'name'
,
'='
,
Name
)
.
FetchOne
()
if
isinstance
(
script
,
tuple
):
model
.
SetName
(
script
[
1
])
model
.
SetStart
(
script
[
2
])
model
.
SetEnd
(
script
[
3
])
model
.
SetNote
(
script
[
4
])
model
.
SetCreated
(
script
[
5
])
model
.
SetUpdated
(
script
[
6
])
model
.
SetDeleted
(
script
[
7
])
model
.
isExist
=
True
return
model
@
staticmethod
def
AllFromDB
(
log
):
models
=
[]
mysql
.
SetLog
(
log
)
script
=
mysql
.
Select
(
'shift'
)
.
FetchAll
()
for
row
in
script
:
model
=
ShiftModel
(
row
[
0
])
model
.
SetName
(
row
[
1
])
model
.
SetStart
(
row
[
2
])
model
.
SetEnd
(
row
[
3
])
model
.
SetNote
(
row
[
4
])
model
.
SetCreated
(
row
[
5
])
model
.
SetUpdated
(
row
[
6
])
model
.
SetDeleted
(
row
[
7
])
model
.
isExist
=
True
models
.
append
(
model
)
return
models
\ No newline at end of file
flask/notebook/resources/base_resource.py
View file @
f870efcd
...
...
@@ -43,4 +43,6 @@ class SendBaseResource(BaseResource):
def
GetExcelResponse
(
self
,
name
,
stream
):
return
send_file
(
stream
,
attachment_filename
=
"{0}.xlsx"
.
format
(
name
),
as_attachment
=
True
)
def
GetWordResponse
(
self
,
name
,
stream
):
return
send_file
(
stream
,
attachment_filename
=
"{0}.docx"
.
format
(
name
),
as_attachment
=
True
)
\ No newline at end of file
return
send_file
(
stream
,
attachment_filename
=
"{0}.docx"
.
format
(
name
),
as_attachment
=
True
)
def
GetTxtResponse
(
self
,
name
,
stream
):
return
send_file
(
stream
,
attachment_filename
=
"{0}.txt"
.
format
(
name
),
as_attachment
=
True
)
\ No newline at end of file
flask/notebook/resources/device_shift_relation_resource.py
0 → 100644
View file @
f870efcd
from
base_resource
import
BaseResource
from
device_shift_relation_model
import
DeviceShiftRelationModel
# from werkzeug.datastructures import FileStorage
import
os
,
werkzeug
,
base64
,
pandas
as
pd
# ========== 新增設備班別關係記錄 ==========
class
DeviceShiftRelationInsert
(
BaseResource
):
def
__init__
(
self
):
super
()
.
__init__
(
"InsertDeviceShiftRelation"
)
self
.
parser
.
add_argument
(
'device_id'
,
required
=
True
,
help
=
"設備編號,上限20字"
)
self
.
parser
.
add_argument
(
'shift_no'
,
required
=
True
,
help
=
"班別編號,上限20字"
)
self
.
parser
.
add_argument
(
'note'
,
help
=
"備註"
)
def
post
(
self
):
args
=
self
.
parser
.
parse_args
()
model
=
DeviceShiftRelationModel
.
FromDBByDeviceIdShiftNo
(
args
[
'device_id'
],
args
[
'shift_no'
],
self
.
log
.
SetMessage
)
if
not
model
.
isExist
:
model
.
SetDeviceId
(
args
[
'device_id'
])
model
.
SetShiftNo
(
args
[
'shift_no'
])
model
.
SetNote
(
args
[
'note'
])
if
model
.
InsertToDB
(
self
.
log
.
SetMessage
):
self
.
message
=
"DeviceShiftRelation:{0}, {1} inserted"
.
format
(
args
[
'device_id'
],
args
[
'shift_no'
])
else
:
self
.
message
=
"DeviceShiftRelation:{0}, {1} insert failed"
.
format
(
args
[
'device_id'
],
args
[
'shift_no'
])
else
:
self
.
message
=
"DeviceShiftRelation:{0}, {1} is exist in database"
.
format
(
args
[
'device_id'
],
args
[
'shift_no'
])
return
self
.
GetResponse
()
# ========== 更新設備班別關係紀錄 ==========
class
DeviceShiftRelationUpdate
(
BaseResource
):
def
__init__
(
self
):
super
()
.
__init__
(
"UpdateDeviceShiftRelation"
)
self
.
parser
.
add_argument
(
'no'
,
required
=
True
,
help
=
"班別編號"
)
self
.
parser
.
add_argument
(
'device_id'
,
required
=
True
,
help
=
"設備編號,上限20字"
)
self
.
parser
.
add_argument
(
'shift_no'
,
required
=
True
,
help
=
"班別編號,上限20字"
)
self
.
parser
.
add_argument
(
'note'
,
help
=
"備註"
)
def
post
(
self
):
args
=
self
.
parser
.
parse_args
()
model
=
DeviceShiftRelationModel
.
FromDB
(
args
[
'no'
],
self
.
log
.
SetMessage
)
if
model
.
isExist
:
model
.
SetDeviceId
(
args
[
'device_id'
])
model
.
SetShiftNo
(
args
[
'shift_no'
])
model
.
SetNote
(
args
[
'note'
])
if
model
.
UpdateToDB
(
self
.
log
.
SetMessage
):
self
.
message
=
[]
if
model
.
HasChangeDeviceId
():
self
.
message
.
append
(
"DeviceId: {0} -> {1}"
.
format
(
model
.
GetOldDeviceId
(),
model
.
GetDeviceId
())
)
if
model
.
HasChangeShiftNo
():
self
.
message
.
append
(
"ShiftNo: {0} -> {1}"
.
format
(
model
.
GetOldShiftNo
(),
model
.
GetShiftNo
())
)
if
model
.
HasChangeNote
():
self
.
message
.
append
(
"Note: {0} -> {1}"
.
format
(
model
.
GetOldNote
(),
model
.
GetNote
())
)
self
.
message
=
", "
.
join
(
self
.
message
)
if
len
(
self
.
message
)
>
0
else
""
else
:
self
.
message
=
"DeviceShiftRelation:{0}, {1} update failed"
.
format
(
args
[
'device_id'
],
args
[
'shift_no'
])
else
:
self
.
message
=
"DeviceShiftRelation:{0}, {1} isn't exist in database"
.
format
(
args
[
'device_id'
],
args
[
'shift_no'
])
return
self
.
GetResponse
()
# ========== 刪除設備班別關係紀錄 ==========
class
DeviceShiftRelationDelete
(
BaseResource
):
def
__init__
(
self
):
super
()
.
__init__
(
"DeleteDeviceShiftRelation"
)
self
.
parser
.
add_argument
(
'no'
,
required
=
True
)
def
post
(
self
):
args
=
self
.
parser
.
parse_args
()
model
=
DeviceShiftRelationModel
.
FromDB
(
args
[
'no'
],
self
.
log
.
SetMessage
)
if
model
.
isExist
:
if
model
.
DeleteFromDB
(
self
.
log
.
SetMessage
):
self
.
message
=
"DeviceShiftRelation:{0} deleted"
.
format
(
args
[
'no'
],
model
.
GetNow
())
else
:
self
.
message
=
"DeviceShiftRelation:{0} delete failed"
.
format
(
args
[
'no'
])
else
:
self
.
message
=
"DeviceShiftRelation:{0} isn't exist in database"
.
format
(
args
[
'no'
])
return
self
.
GetResponse
()
# ========== 查詢所有設備班別關係紀錄 ==========
class
DeviceShiftRelationSelectAll
(
BaseResource
):
def
__init__
(
self
):
super
()
.
__init__
(
"SelectDeviceShiftRelation"
)
def
post
(
self
,
ID
=
None
):
models
=
DeviceShiftRelationModel
.
AllFromDB
(
self
.
log
.
SetMessage
)
if
len
(
models
)
>
0
:
self
.
data
=
[]
for
model
in
models
:
self
.
data
.
append
(
model
.
ToDict
())
self
.
message
=
"{0} selected"
.
format
(
len
(
self
.
data
))
else
:
self
.
message
=
"no data in database"
return
self
.
GetResponse
()
\ No newline at end of file
flask/notebook/resources/punch_card_resource.py
View file @
f870efcd
...
...
@@ -15,6 +15,8 @@ from leave_off_work_model import LeaveOffWorkModel
from
overtime_model
import
OvertimeModel
from
docx
import
Document
from
docx.enum.style
import
WD_STYLE_TYPE
from
device_shift_relation_model
import
DeviceShiftRelationModel
from
shift_model
import
ShiftModel
env
=
os
.
environ
...
...
@@ -206,6 +208,7 @@ class PunchCard1Upload(BaseResource):
print
(
uuid
,
host
,
location
)
punch
=
PunchInfluxModel
(
uuid
,
host
,
location
,
time
)
punch
.
SetID
(
ID
)
punch
.
SetUID
(
ID
)
punch
.
SetName
(
name
)
punch
.
SetType
(
ptype
)
punch
.
SetSimilarity
(
similarity
)
...
...
@@ -308,6 +311,7 @@ class PunchCard2Upload(BaseResource):
a12
=
model
.
GetPosition
()
punch
=
PunchInfluxModel
(
a1
,
a2
,
a9
,
a6
)
punch
.
SetID
(
a3
)
punch
.
SetUID
(
a3
)
punch
.
SetName
(
a4
)
punch
.
SetType
(
a10
)
punch
.
SetSimilarity
(
a11
)
...
...
@@ -2773,3 +2777,87 @@ class PunchCardRecordToday(BaseResource):
}
dataList
.
append
(
record
)
return
dataList
# ========== 班別 ==========
class
ExportShiftPunchCard
(
SendBaseResource
):
def
__init__
(
self
):
super
()
.
__init__
(
'txt'
)
self
.
parser
.
add_argument
(
'start'
)
self
.
parser
.
add_argument
(
'end'
)
def
post
(
self
):
args
=
self
.
parser
.
parse_args
()
devices
=
DeviceModel
.
AllFromDB
(
self
.
log
.
SetMessage
)
person
=
PersonModel
.
AllFromDB
(
self
.
log
.
SetMessage
)
start
=
datetime
.
strptime
(
args
[
'start'
],
'
%
Y-
%
m-
%
d
%
H:
%
M:
%
S'
)
end
=
datetime
.
strptime
(
args
[
'end'
],
'
%
Y-
%
m-
%
d
%
H:
%
M:
%
S'
)
temperature
=
None
punch_card_data
=
PunchInfluxModel
.
AllFromRaw
(
start
,
end
,
temperature
)
stream
=
ExportShiftPunchCard
.
GetFile
(
self
,
devices
,
person
,
punch_card_data
,
start
)
return
self
.
GetTxtResponse
(
"{0}"
.
format
(
start
.
strftime
(
'
%
Y
%
m
%
d'
)),
stream
)
@
staticmethod
def
GetFile
(
self
,
devices
,
person
,
punch_card_data
,
start
):
path
=
'./static/File/{0}.txt'
.
format
(
start
.
strftime
(
'
%
Y
%
m
%
d'
))
file
=
open
(
path
,
'w'
)
person_punch_card
=
{}
for
p
in
person
:
person_punch_card
[
p
.
GetID
()]
=
{}
device_shift
=
{}
for
d
in
devices
:
device_shift
[
d
.
GetID
()]
=
{}
#班別
shift_note
=
{}
shifts
=
ShiftModel
.
AllFromDB
(
self
.
log
.
SetMessage
)
for
s
in
shifts
:
shift_note
[
s
.
GetNo
()]
=
{}
shift_note
[
s
.
GetNo
()][
'name'
]
=
s
.
GetName
()
shift_note
[
s
.
GetNo
()][
'start'
]
=
s
.
GetStart
()
shift_note
[
s
.
GetNo
()][
'end'
]
=
s
.
GetEnd
()
#設備班別關係
device_shift_relation
=
DeviceShiftRelationModel
.
AllFromDB
(
self
.
log
.
SetMessage
)
for
r
in
device_shift_relation
:
device_shift
[
r
.
GetDeviceId
()][
r
.
GetShiftNo
()]
=
{}
device_shift
[
r
.
GetDeviceId
()][
r
.
GetShiftNo
()][
'name'
]
=
shift_note
[
r
.
GetShiftNo
()][
'name'
]
device_shift
[
r
.
GetDeviceId
()][
r
.
GetShiftNo
()][
'start'
]
=
shift_note
[
r
.
GetShiftNo
()][
'start'
]
device_shift
[
r
.
GetDeviceId
()][
r
.
GetShiftNo
()][
'end'
]
=
shift_note
[
r
.
GetShiftNo
()][
'end'
]
for
data
in
punch_card_data
:
ID
=
data
.
GetID
()
if
ID
in
person_punch_card
:
time
=
data
.
GetTime
()
date
=
time
.
strftime
(
'
%
Y-
%
m-
%
d'
)
if
date
not
in
person_punch_card
[
ID
]:
person_punch_card
[
ID
][
date
]
=
{}
datetime
=
time
.
strftime
(
'
%
Y
%
m
%
d
%
H
%
M'
)
only_time
=
time
.
strftime
(
'
%
H:
%
M'
)
device_id
=
data
.
GetDevice
()
shift_name
=
"ERROR"
if
device_id
in
device_shift
:
for
device_shift_no
in
device_shift
[
device_id
]:
shift_start
=
device_shift
[
device_id
][
device_shift_no
][
'start'
]
shift_end
=
device_shift
[
device_id
][
device_shift_no
][
'end'
]
if
(
shift_start
<=
only_time
and
only_time
<=
shift_end
):
shift_name
=
device_shift
[
device_id
][
device_shift_no
][
'name'
]
if
'start'
not
in
person_punch_card
[
ID
][
date
]:
person_punch_card
[
ID
][
date
][
'start'
]
=
'{0}{1}{2}
\n
'
.
format
(
ID
,
datetime
,
shift_name
)
person_punch_card
[
ID
][
date
][
'start_shift'
]
=
shift_name
person_punch_card
[
ID
][
date
][
'end'
]
=
'{0}{1}{2}
\n
'
.
format
(
ID
,
datetime
,
shift_name
)
person_punch_card
[
ID
][
date
][
'end_shift'
]
=
shift_name
# file.write('{0}{1}{2}\n'.format(ID,datetime,shift_name))
write_list
=
[]
for
p
in
person_punch_card
:
for
d
in
person_punch_card
[
p
]:
if
person_punch_card
[
p
][
d
][
'start_shift'
]
!=
'ERROR'
:
write_list
.
append
(
person_punch_card
[
p
][
d
][
'start'
])
else
:
write_list
.
insert
(
0
,
person_punch_card
[
p
][
d
][
'start'
])
if
person_punch_card
[
p
][
d
][
'start'
]
!=
person_punch_card
[
p
][
d
][
'end'
]:
if
person_punch_card
[
p
][
d
][
'end_shift'
]
!=
'ERROR'
:
write_list
.
append
(
person_punch_card
[
p
][
d
][
'end'
])
else
:
write_list
.
insert
(
0
,
person_punch_card
[
p
][
d
][
'end'
])
# file.write(person_punch_card[p][d]['start'])
# file.write(person_punch_card[p][d]['end'])
file
.
writelines
(
write_list
)
file
.
close
()
s_file
=
open
(
path
,
'rb'
)
return
s_file
\ No newline at end of file
flask/notebook/resources/shift_resource.py
0 → 100644
View file @
f870efcd
from
base_resource
import
BaseResource
from
shift_model
import
ShiftModel
# from werkzeug.datastructures import FileStorage
import
os
,
werkzeug
,
base64
,
pandas
as
pd
# ========== 新增班別記錄 ==========
class
ShiftInsert
(
BaseResource
):
def
__init__
(
self
):
super
()
.
__init__
(
"InsertShift"
)
self
.
parser
.
add_argument
(
'name'
,
required
=
True
,
help
=
"班別,上限20字"
)
self
.
parser
.
add_argument
(
'start'
,
required
=
True
,
help
=
"班別開始時間,上限20字"
)
self
.
parser
.
add_argument
(
'end'
,
required
=
True
,
help
=
"班別結束時間,上限20字"
)
self
.
parser
.
add_argument
(
'note'
,
help
=
"班別備註"
)
def
post
(
self
):
args
=
self
.
parser
.
parse_args
()
model
=
ShiftModel
.
FromDBByName
(
args
[
'name'
],
self
.
log
.
SetMessage
)
if
not
model
.
isExist
:
model
.
SetName
(
args
[
'name'
])
model
.
SetStart
(
args
[
'start'
])
model
.
SetEnd
(
args
[
'end'
])
model
.
SetNote
(
args
[
'note'
])
if
model
.
InsertToDB
(
self
.
log
.
SetMessage
):
self
.
message
=
"Shift:{0} inserted"
.
format
(
args
[
'name'
])
else
:
self
.
message
=
"Shift:{0} insert failed"
.
format
(
args
[
'name'
])
else
:
self
.
message
=
"Shift:{0} is exist in database"
.
format
(
args
[
'name'
])
return
self
.
GetResponse
()
# ========== 更新班別紀錄 ==========
class
ShiftUpdate
(
BaseResource
):
def
__init__
(
self
):
super
()
.
__init__
(
"UpdateShift"
)
self
.
parser
.
add_argument
(
'no'
,
required
=
True
,
help
=
"班別編號"
)
self
.
parser
.
add_argument
(
'name'
,
required
=
True
,
help
=
"班別,上限20字"
)
self
.
parser
.
add_argument
(
'start'
,
required
=
True
,
help
=
"班別開始時間,上限20字"
)
self
.
parser
.
add_argument
(
'end'
,
required
=
True
,
help
=
"班別結束時間,上限20字"
)
self
.
parser
.
add_argument
(
'note'
,
help
=
"班別備註"
)
def
post
(
self
):
args
=
self
.
parser
.
parse_args
()
model
=
ShiftModel
.
FromDB
(
args
[
'no'
],
self
.
log
.
SetMessage
)
if
model
.
isExist
:
model
.
SetName
(
args
[
'name'
])
model
.
SetStart
(
args
[
'start'
])
model
.
SetEnd
(
args
[
'end'
])
model
.
SetNote
(
args
[
'note'
])
if
model
.
UpdateToDB
(
self
.
log
.
SetMessage
):
self
.
message
=
[]
if
model
.
HasChangeName
():
self
.
message
.
append
(
"Name: {0} -> {1}"
.
format
(
model
.
GetOldName
(),
model
.
GetName
())
)
if
model
.
HasChangeStart
():
self
.
message
.
append
(
"Start: {0} -> {1}"
.
format
(
model
.
GetOldStart
(),
model
.
GetStart
())
)
if
model
.
HasChangeEnd
():
self
.
message
.
append
(
"End: {0} -> {1}"
.
format
(
model
.
GetOldEnd
(),
model
.
GetEnd
())
)
if
model
.
HasChangeNote
():
self
.
message
.
append
(
"Note: {0} -> {1}"
.
format
(
model
.
GetOldNote
(),
model
.
GetNote
())
)
self
.
message
=
", "
.
join
(
self
.
message
)
if
len
(
self
.
message
)
>
0
else
""
else
:
self
.
message
=
"Shift:{0} update failed"
.
format
(
args
[
'name'
])
else
:
self
.
message
=
"Shift:{0} isn't exist in database"
.
format
(
args
[
'name'
])
return
self
.
GetResponse
()
# ========== 刪除班別紀錄 ==========
class
ShiftDelete
(
BaseResource
):
def
__init__
(
self
):
super
()
.
__init__
(
"DeleteShift"
)
self
.
parser
.
add_argument
(
'no'
,
required
=
True
)
def
post
(
self
):
args
=
self
.
parser
.
parse_args
()
model
=
ShiftModel
.
FromDB
(
args
[
'no'
],
self
.
log
.
SetMessage
)
if
model
.
isExist
:
if
model
.
DeleteFromDB
(
self
.
log
.
SetMessage
):
self
.
message
=
"Shift:{0} deleted"
.
format
(
args
[
'no'
],
model
.
GetNow
())
else
:
self
.
message
=
"Shift:{0} delete failed"
.
format
(
args
[
'no'
])
else
:
self
.
message
=
"Shift:{0} isn't exist in database"
.
format
(
args
[
'no'
])
return
self
.
GetResponse
()
# ========== 查詢所有班別紀錄 ==========
class
ShiftSelectAll
(
BaseResource
):
def
__init__
(
self
):
super
()
.
__init__
(
"SelectShift"
)
def
post
(
self
,
ID
=
None
):
models
=
ShiftModel
.
AllFromDB
(
self
.
log
.
SetMessage
)
if
len
(
models
)
>
0
:
self
.
data
=
[]
for
model
in
models
:
self
.
data
.
append
(
model
.
ToDict
())
self
.
message
=
"{0} selected"
.
format
(
len
(
self
.
data
))
else
:
self
.
message
=
"no data in database"
return
self
.
GetResponse
()
\ No newline at end of file
flask/notebook/run_v1.py
View file @
f870efcd
...
...
@@ -14,7 +14,7 @@ from person_group_relation_resource import PersonGroupRelationInsert,PersonGroup
from
person_group_and_device_group_relation_resource
import
PersonGroupAndDeviceGroupRelationInsert
,
PersonGroupAndDeviceGroupRelationSelectAll
,
PersonGroupAndDeviceGroupRelationDelete
from
grafana_access_json_resource
import
Grafana_Base
,
Grafana_Search
,
Grafana_Query
,
Grafana_Tag_Key
,
Grafana_Tag_Value
from
punch_card_resource
import
PunchCardUpload
,
PunchCard1Upload
,
PunchCard2Upload
,
PunchCardRecord
,
PunchCardSend
,
PunchCardRecordDownload
,
PunchCardRecordAll
,
PunchCardInsert
,
PunchCardFirst
,
PunchCardRecordDownload2
,
PunchCardRecordDownloadGroup
,
PunchCardRecordDownload2Group
,
PunchCardRecordToday
,
PunchCardRecordVerson2
,
PunchCardRecordDownloadVerson2
,
PunchCardRecordDownloadGroupVerson2
,
PunchCardRecordDownload2Verson2
,
PunchCardRecordDownload2GroupVerson2
from
punch_card_resource
import
PunchCardUpload
,
PunchCard1Upload
,
PunchCard2Upload
,
PunchCardRecord
,
PunchCardSend
,
PunchCardRecordDownload
,
PunchCardRecordAll
,
PunchCardInsert
,
PunchCardFirst
,
PunchCardRecordDownload2
,
PunchCardRecordDownloadGroup
,
PunchCardRecordDownload2Group
,
PunchCardRecordToday
,
PunchCardRecordVerson2
,
PunchCardRecordDownloadVerson2
,
PunchCardRecordDownloadGroupVerson2
,
PunchCardRecordDownload2Verson2
,
PunchCardRecordDownload2GroupVerson2
,
ExportShiftPunchCard
from
CM26EWH_resource
import
CM26EWH_Personinfo
,
CM26EWH_subscription_aps
from
version_resource
import
VersionSelect
#from socket_resource import Socket
...
...
@@ -38,6 +38,10 @@ from features_resource import FeaturesInsert,FeaturesUpdate,FeaturesDelete,Featu
from
features_role_relation_resource
import
FeaturesRoleRelationInsert
,
FeaturesRoleRelationUpdate
,
FeaturesRoleRelationDelete
,
FeaturesRoleRelationSelectAll
from
features_user_relation_resource
import
FeaturesUserRelationInsert
,
FeaturesUserRelationUpdate
,
FeaturesUserRelationDelete
,
FeaturesUserRelationSelectAll
from
test_resource
import
SetDateTime
from
shift_resource
import
ShiftInsert
,
ShiftUpdate
,
ShiftDelete
,
ShiftSelectAll
from
device_shift_relation_resource
import
DeviceShiftRelationInsert
,
DeviceShiftRelationUpdate
,
DeviceShiftRelationDelete
,
DeviceShiftRelationSelectAll
...
...
@@ -208,6 +212,19 @@ api.add_resource(LeaveToExcelPersonalVerson2, '/leave/excel/personal/verson2')
api
.
add_resource
(
AnnualLeaveToExcelVerson2
,
'/annual/leave/excel/all/verson2'
)
# ===== 加班相關 =====
api
.
add_resource
(
OvertimeToWordVerson2
,
'/overtime/word/verson2'
)
# ========== 新版本-班別 ==========
# ========== 班別 ==========
api
.
add_resource
(
ShiftInsert
,
'/shift/insert'
)
api
.
add_resource
(
ShiftUpdate
,
'/shift/update'
)
api
.
add_resource
(
ShiftDelete
,
'/shift/delete'
)
api
.
add_resource
(
ShiftSelectAll
,
'/shift/all'
)
# ========== 設備班別關係 ==========
api
.
add_resource
(
DeviceShiftRelationInsert
,
'/device/shift/relation/insert'
)
api
.
add_resource
(
DeviceShiftRelationUpdate
,
'/device/shift/relation/update'
)
api
.
add_resource
(
DeviceShiftRelationDelete
,
'/device/shift/relation/delete'
)
api
.
add_resource
(
DeviceShiftRelationSelectAll
,
'/device/shift/relation/all'
)
# ========== 匯出TXT ==========
api
.
add_resource
(
ExportShiftPunchCard
,
'/device/shift/export'
)
# ----- Socket -----
# socketio = SocketIO(app)
# socketio.on_namespace(Socket('/test'))
...
...
flask/notebook/static/File/20210922.txt
0 → 100644
View file @
f870efcd
flask/notebook/static/File/20210930.txt
0 → 100644
View file @
f870efcd
B10902202109301721ERROR
B10903202109301612ERROR
B10903202109301454ERROR
B10902202109301721A4
flask/notebook/static/File/20211001.txt
0 → 100644
View file @
f870efcd
B10902202110011204ERROR
B10903202110011142ERROR
B10903202110011408B2
B10902202110011409B2
laravel-guardian/.idea/.gitignore
100644 → 100755
View file @
f870efcd
File mode changed from 100644 to 100755
laravel-guardian/.idea/vcs.xml
View file @
f870efcd
<?xml version="1.0" encoding="UTF-8"?>
<project
version=
"4"
>
<component
name=
"VcsDirectoryMappings"
>
<mapping
directory=
"$PROJECT_DIR$/.."
vcs=
"Git"
/>
<mapping
directory=
"$PROJECT_DIR$"
vcs=
"Git"
/>
</component>
</project>
\ No newline at end of file
laravel-guardian/app/Http/Controllers/DeviceController.php
View file @
f870efcd
...
...
@@ -1274,10 +1274,399 @@ class DeviceController extends Controller
return
redirect
()
->
route
(
'relation'
);
}
public
function
set_datetime
_index
(
Request
$request
)
//班別
public
function
shift
_index
(
Request
$request
)
{
$msg
=
request
()
->
session
()
->
get
(
'msg'
);
$request
->
session
()
->
all
();
$username
=
$request
->
session
()
->
get
(
'Tusername'
);
//帳號
$role
=
""
;
$level
=
""
;
$user_id
=
""
;
[
$ret
,
$res
]
=
$this
->
request_server
(
sprintf
(
"http://%s:%s/user/all"
,
env
(
"IMAGE_SERVER_HOST"
),
env
(
"IMAGE_SERVER_PORT"
)),
"POST"
);
$jsondata
=
json_decode
(
$res
->
getBody
()
->
__toString
(),
true
);
foreach
(
$jsondata
[
"Data"
]
as
$user
)
{
if
(
$user
[
"username"
]
==
$username
)
{
$role
=
$user
[
"role"
];
$user_id
=
$user
[
"id"
];
}
}
if
(
$role
==
"7"
)
{
$level
=
"4"
;
}
elseif
(
$role
==
"3"
)
{
$level
=
"3"
;
}
elseif
(
$role
==
"6"
)
{
$level
=
"2"
;
}
elseif
(
$role
==
"5"
)
{
$level
=
"1"
;
}
//取得權限
$authority
=
array
();
[
$ret
,
$res
]
=
$this
->
request_server
(
sprintf
(
"http://%s:%s/features/role/relation/all"
,
env
(
"IMAGE_SERVER_HOST"
),
env
(
"IMAGE_SERVER_PORT"
)),
"POST"
);
$jsondata
=
json_decode
(
$res
->
getBody
()
->
__toString
(),
true
);
if
(
$jsondata
[
"Data"
]
!=
null
)
{
foreach
(
$jsondata
[
"Data"
]
as
$role_authority
)
{
if
(
$role_authority
[
"role_id"
]
==
$role
)
{
array_push
(
$authority
,
array
(
// "no" => $role_authority["no"],
"features_id"
=>
$role_authority
[
"features_id"
],
));
}
}
}
[
$ret
,
$res
]
=
$this
->
request_server
(
sprintf
(
"http://%s:%s/features/user/relation/all"
,
env
(
"IMAGE_SERVER_HOST"
),
env
(
"IMAGE_SERVER_PORT"
)),
"POST"
);
$jsondata
=
json_decode
(
$res
->
getBody
()
->
__toString
(),
true
);
if
(
$jsondata
[
"Data"
]
!=
null
)
{
foreach
(
$jsondata
[
"Data"
]
as
$user_authority
)
{
if
(
$user_authority
[
"user_id"
]
==
$user_id
)
{
array_push
(
$authority
,
array
(
// "no" => $role_authority["no"],
"features_id"
=>
$user_authority
[
"features_id"
],
));
}
}
}
// 取得 Device 資料
$devices
=
array
();
[
$ret
,
$res
]
=
$this
->
request_server
(
sprintf
(
"http://%s:%s/device/select/all"
,
env
(
"IMAGE_SERVER_HOST"
),
env
(
"IMAGE_SERVER_PORT"
)),
"GET"
);
$jsondata
=
json_decode
(
$res
->
getBody
()
->
__toString
(),
true
);
if
(
$jsondata
[
"Data"
]
!=
null
)
{
foreach
(
$jsondata
[
"Data"
]
as
$device
)
{
array_push
(
$devices
,
array
(
"id"
=>
$device
[
"ID"
],
"location"
=>
$device
[
"Location"
],
"shift_list"
=>
""
,
"modify"
=>
sprintf
(
"<button class=
\"
btn btn-outline-dark
\"
style=
\"
margin-right: 10px;
\"
data-toggle=
\"
modal
\"
data-target=
\"
#DeviceShift
\"
onclick=
\"
device_shift_data(this)
\"
>修改班別</button>"
),
));
}
}
//all shift
$shifts
=
array
();
[
$ret
,
$res
]
=
$this
->
request_server
(
sprintf
(
"http://%s:%s/shift/all"
,
env
(
"IMAGE_SERVER_HOST"
),
env
(
"IMAGE_SERVER_PORT"
)),
"POST"
);
$jsondata
=
json_decode
(
$res
->
getBody
()
->
__toString
(),
true
);
if
(
$jsondata
[
"Data"
]
!=
null
)
{
foreach
(
$jsondata
[
"Data"
]
as
$shift
)
{
array_push
(
$shifts
,
array
(
"no"
=>
$shift
[
"no"
],
"name"
=>
$shift
[
"name"
],
"start"
=>
$shift
[
"start"
],
"end"
=>
$shift
[
"end"
],
"note"
=>
$shift
[
"note"
],
));
}
}
//all device shift relation
$device_shift_relations
=
array
();
[
$ret
,
$res
]
=
$this
->
request_server
(
sprintf
(
"http://%s:%s/device/shift/relation/all"
,
env
(
"IMAGE_SERVER_HOST"
),
env
(
"IMAGE_SERVER_PORT"
)),
"POST"
);
$jsondata
=
json_decode
(
$res
->
getBody
()
->
__toString
(),
true
);
if
(
$jsondata
[
"Data"
]
!=
null
)
{
foreach
(
$jsondata
[
"Data"
]
as
$device_shift_relation
)
{
$name
=
""
;
$start
=
""
;
$end
=
""
;
foreach
(
$shifts
as
$shift
)
{
if
(
$device_shift_relation
[
"shift_no"
]
==
$shift
[
"no"
])
{
$name
=
$shift
[
"name"
];
$start
=
$shift
[
"start"
];
$end
=
$shift
[
"end"
];
}
}
array_push
(
$device_shift_relations
,
array
(
"no"
=>
$device_shift_relation
[
"no"
],
"device_id"
=>
$device_shift_relation
[
"device_id"
],
"shift_no"
=>
$device_shift_relation
[
"shift_no"
],
"note"
=>
$device_shift_relation
[
"note"
],
"shift_name"
=>
$name
,
"shift_start"
=>
$start
,
"shift_end"
=>
$end
,
));
}
}
$count
=
0
;
foreach
(
$devices
as
$device
)
{
$shift_note
=
""
;
foreach
(
$device_shift_relations
as
$relation
)
{
if
(
$relation
[
"device_id"
]
==
$device
[
"id"
])
{
//dd($relation["shift_name"]);
if
(
$shift_note
==
""
)
{
$shift_note
=
$relation
[
"shift_name"
];
}
else
{
$shift_note
=
$shift_note
.
","
.
$relation
[
"shift_name"
];
}
//dd($device["shift_list"]);
}
}
$devices
[
$count
][
"shift_list"
]
=
$shift_note
;
$count
++
;
}
//dd($devices);
if
(
$msg
!=
null
){
return
view
(
"Shift"
,[
"title"
=>
"班別管理"
,
"error_msg"
=>
$msg
,
"devices"
=>
$devices
,
"level"
=>
$level
,
'authority'
=>
$authority
,
'shifts'
=>
$shifts
,
'device_shift_relations'
=>
$device_shift_relations
]);
}
else
{
return
view
(
"Shift"
,[
"title"
=>
"班別管理"
,
"devices"
=>
$devices
,
"level"
=>
$level
,
'authority'
=>
$authority
,
'shifts'
=>
$shifts
,
'device_shift_relations'
=>
$device_shift_relations
]);
}
}
public
function
shift_insert
(
Request
$request
)
{
[
$ret
,
$res
]
=
$this
->
request_server
(
sprintf
(
"http://%s:%s/shift/insert"
,
env
(
"IMAGE_SERVER_HOST"
),
env
(
"IMAGE_SERVER_PORT"
)),
"POST"
,
"multipart"
,
[
[
'name'
=>
"name"
,
"contents"
=>
$request
->
name
],
[
'name'
=>
"start"
,
"contents"
=>
$request
->
start
],
[
'name'
=>
"end"
,
"contents"
=>
$request
->
end
],
[
'name'
=>
"note"
,
"contents"
=>
$request
->
note
],
]);
// $jsondata = json_decode($res->getBody()->__toString(), true);
// $error=$jsondata["Message"];
// $msg=explode(" ",$error);
// if (strstr($error,"failed")!=false){
// $error_msg="修改失敗";
// }
// elseif (strstr($error,"exist")!=false)
// {
// $error_msg="編號不存在,修改失敗";
// }
// else{
// $error_msg="修改成功";
// }
return
redirect
()
->
route
(
'shift_index'
);
}
public
function
shift_update
(
Request
$request
)
{
[
$ret
,
$res
]
=
$this
->
request_server
(
sprintf
(
"http://%s:%s/shift/update"
,
env
(
"IMAGE_SERVER_HOST"
),
env
(
"IMAGE_SERVER_PORT"
)),
"POST"
,
"multipart"
,
[
[
'name'
=>
"no"
,
"contents"
=>
$request
->
no
],
[
'name'
=>
"name"
,
"contents"
=>
$request
->
name
],
[
'name'
=>
"start"
,
"contents"
=>
$request
->
start
],
[
'name'
=>
"end"
,
"contents"
=>
$request
->
end
],
[
'name'
=>
"note"
,
"contents"
=>
$request
->
note
],
]);
$jsondata
=
json_decode
(
$res
->
getBody
()
->
__toString
(),
true
);
$error
=
$jsondata
[
"Message"
];
$msg
=
explode
(
" "
,
$error
);
if
(
strstr
(
$error
,
"failed"
)
!=
false
){
$error_msg
=
"修改失敗"
;
}
elseif
(
strstr
(
$error
,
"exist"
)
!=
false
)
{
$error_msg
=
"編號不存在,修改失敗"
;
}
else
{
$error_msg
=
"修改成功"
;
}
return
redirect
()
->
route
(
'shift_index'
)
->
with
([
"msg"
=>
$error_msg
]);
}
public
function
shift_delete
(
Request
$request
)
{
[
$ret
,
$res
]
=
$this
->
request_server
(
sprintf
(
"http://%s:%s/shift/delete"
,
env
(
"IMAGE_SERVER_HOST"
),
env
(
"IMAGE_SERVER_PORT"
)),
"POST"
,
"multipart"
,
[
[
'name'
=>
"no"
,
"contents"
=>
$request
->
no
],
]);
$jsondata
=
json_decode
(
$res
->
getBody
()
->
__toString
(),
true
);
$error
=
$jsondata
[
"Message"
];
$msg
=
explode
(
" "
,
$error
);
if
(
strstr
(
$error
,
"failed"
)
!=
false
){
$error_msg
=
"修改失敗"
;
}
elseif
(
strstr
(
$error
,
"exist"
)
!=
false
)
{
$error_msg
=
"編號不存在,修改失敗"
;
}
else
{
$error_msg
=
"修改成功"
;
}
return
redirect
()
->
route
(
'shift_index'
)
->
with
([
"msg"
=>
$error_msg
]);
}
public
function
device_shift_update
(
Request
$request
)
{
$new_shift
=
$request
->
all
();
$device_id
=
$request
->
device_id
;
//dd($new_shift);
$old_shift
=
array
();
$device_shifts
=
array
();
[
$ret
,
$res
]
=
$this
->
request_server
(
sprintf
(
"http://%s:%s/device/shift/relation/all"
,
env
(
"IMAGE_SERVER_HOST"
),
env
(
"IMAGE_SERVER_PORT"
)),
"POST"
);
$jsondata
=
json_decode
(
$res
->
getBody
()
->
__toString
(),
true
);
if
(
$jsondata
[
"Data"
]
!=
null
)
{
foreach
(
$jsondata
[
"Data"
]
as
$device_shift_relation
)
{
if
(
$device_shift_relation
[
"device_id"
]
==
$device_id
)
{
array_push
(
$old_shift
,
$device_shift_relation
[
"shift_no"
]);
array_push
(
$device_shifts
,
array
(
"no"
=>
$device_shift_relation
[
"no"
],
"shift_no"
=>
$device_shift_relation
[
"shift_no"
],
));
}
}
}
$insert_shift
=
array
();
$delete_shift
=
array
();
$shifts
=
array
();
[
$ret
,
$res
]
=
$this
->
request_server
(
sprintf
(
"http://%s:%s/shift/all"
,
env
(
"IMAGE_SERVER_HOST"
),
env
(
"IMAGE_SERVER_PORT"
)),
"POST"
);
$jsondata
=
json_decode
(
$res
->
getBody
()
->
__toString
(),
true
);
if
(
$jsondata
[
"Data"
]
!=
null
)
{
foreach
(
$jsondata
[
"Data"
]
as
$shift
)
{
array_push
(
$shifts
,
array
(
"no"
=>
$shift
[
"no"
],
));
if
(
in_array
(
$shift
[
"no"
],
$old_shift
))
{
if
(
!
in_array
(
$shift
[
"no"
],
$new_shift
))
{
array_push
(
$delete_shift
,
array
(
"no"
=>
$shift
[
"no"
],
));
}
}
if
(
in_array
(
$shift
[
"no"
],
$new_shift
))
{
if
(
!
in_array
(
$shift
[
"no"
],
$old_shift
))
{
array_push
(
$insert_shift
,
array
(
"no"
=>
$shift
[
"no"
],
));
}
}
}
}
//dd($insert_shift);
//isert
foreach
(
$insert_shift
as
$insert
)
{
[
$ret
,
$res
]
=
$this
->
request_server
(
sprintf
(
"http://%s:%s/device/shift/relation/insert"
,
env
(
"IMAGE_SERVER_HOST"
),
env
(
"IMAGE_SERVER_PORT"
)),
"POST"
,
"multipart"
,
[
[
'name'
=>
"device_id"
,
"contents"
=>
$device_id
],
[
'name'
=>
"shift_no"
,
"contents"
=>
$insert
[
"no"
]
],
[
'name'
=>
"note"
,
"contents"
=>
""
],
]);
}
//delete
foreach
(
$delete_shift
as
$delete
)
{
foreach
(
$device_shifts
as
$device_shift
)
{
if
(
$delete
[
"no"
]
==
$device_shift
[
"shift_no"
])
{
[
$ret
,
$res
]
=
$this
->
request_server
(
sprintf
(
"http://%s:%s/device/shift/relation/delete"
,
env
(
"IMAGE_SERVER_HOST"
),
env
(
"IMAGE_SERVER_PORT"
)),
"POST"
,
"multipart"
,
[
[
'name'
=>
"no"
,
"contents"
=>
$device_shift
[
"no"
]
],
]);
}
}
}
return
redirect
()
->
route
(
'shift_index'
);
}
public
function
shift_punch_card_export
(
Request
$request
)
{
$date
=
""
;
$date_explode
=
explode
(
" "
,
$request
->
start_time
);
$date
=
str_replace
(
"-"
,
""
,
$date_explode
[
0
]);
$filename
=
sprintf
(
"../storage/export/%s.txt"
,
$date
);
$file
=
fopen
(
$filename
,
'w'
);
$client
=
new
\GuzzleHttp\Client
();
$res
=
$client
->
request
(
'POST'
,
sprintf
(
"http://%s:%s/device/shift/export"
,
env
(
"IMAGE_SERVER_HOST"
),
env
(
"IMAGE_SERVER_PORT"
)),[
'form_params'
=>
[
'start'
=>
$request
->
start_time
,
'end'
=>
$request
->
end_time
,
],
'save_to'
=>
$file
]);
return
response
()
->
download
(
$filename
);
}
public
function
set_datetime_index
(
Request
$request
)
{
$msg
=
request
()
->
session
()
->
get
(
'msg'
);
$request
->
session
()
->
all
();
...
...
@@ -1343,7 +1732,7 @@ class DeviceController extends Controller
}
}
}
date_default_timezone_set
(
"Asia/Taipei"
);
//dd(date('Y-m-d H:i:s',time()));
//$msg = request()->session()->get('msg');
...
...
@@ -1410,7 +1799,7 @@ class DeviceController extends Controller
public
function
set_datetime
(
Request
$request
)
{
$user_dt
=
str_replace
(
"-"
,
""
,
$request
->
user_dt
);
//dd(str_replace(" ","-",$user_dt));
[
$ret
,
$res
]
=
$this
->
request_server
(
sprintf
(
"http://%s:%s/set/dt/%s"
,
env
(
"IMAGE_SERVER_HOST"
),
env
(
"IMAGE_SERVER_PORT"
),
str_replace
(
" "
,
"-"
,
$user_dt
)),
"GET"
);
...
...
@@ -1419,7 +1808,7 @@ class DeviceController extends Controller
return
redirect
()
->
route
(
"device_time"
);
}
//取得API資料的方法
private
function
request_server
(
$url
,
$method
,
$data_format
=
null
,
$data
=
null
){
...
...
laravel-guardian/resources/views/Device.blade.php
View file @
f870efcd
...
...
@@ -123,13 +123,13 @@
<div class="
input
-
group
-
prepend
">
<span class="
input
-
group
-
text
" id="
inputGroup
-
sizing
-
default
">設備host</span>
</div>
<input type="
text
" class="
form
-
control
" aria-label="
Default
" aria-describedby="
inputGroup
-
sizing
-
default
" name="
host
" placeholder="
Host
" id="
update_host
">
<input
readonly
type="
text
" class="
form
-
control
" aria-label="
Default
" aria-describedby="
inputGroup
-
sizing
-
default
" name="
host
" placeholder="
Host
" id="
update_host
">
</div>
<div class="
input
-
group
mb
-
3
">
<div class="
input
-
group
-
prepend
">
<span class="
input
-
group
-
text
" id="
inputGroup
-
sizing
-
default
">設備port</span>
</div>
<input type="
text
" class="
form
-
control
" aria-label="
Default
" aria-describedby="
inputGroup
-
sizing
-
default
" name="
port
" placeholder="
Port
" id="
update_post
">
<input
readonly
type="
text
" class="
form
-
control
" aria-label="
Default
" aria-describedby="
inputGroup
-
sizing
-
default
" name="
port
" placeholder="
Port
" id="
update_post
">
</div>
<div class="
input
-
group
mb
-
3
">
<div class="
input
-
group
-
prepend
">
...
...
laravel-guardian/resources/views/Shift.blade.php
0 → 100755
View file @
f870efcd
<?php
session_start
()
?>
@extends('layout.default')
@section('title', '攝影機調閱')
@section('header')
<script
src=
"/js/3.1.1/jquery.min.js"
></script>
<script
src=
"/js/jquery.validate.min.js"
></script>
{{-- 引入bootstrap-table css樣式與js--}}
<link
href=
"https://unpkg.com/bootstrap-table@1.18.3/dist/extensions/group-by-v2/bootstrap-table-group-by.css"
rel=
"stylesheet"
>
<link
href=
"/css/bootstrap-table.css"
rel=
"stylesheet"
>
<script
src=
"/js/tableExport.min.js"
></script>
<script
src=
"/js/bootstrap-table.js"
></script>
<script
src=
"/js/bootstrap-table-zh-TW.min.js"
></script>
<script
src=
"/js/bootstrap-table-export.min.js"
></script>
<script
src=
"https://unpkg.com/bootstrap-table@1.18.3/dist/extensions/group-by-v2/bootstrap-table-group-by.min.js"
></script>
{{--引入 datetimepicker 相關套件--}}
<script
type=
"text/javascript"
src=
"/bower_components/moment/moment.js"
></script>
<script
type=
"text/javascript"
src=
"/bower_components/moment/locale/zh-tw.js"
></script>
<script
type=
"text/javascript"
src=
"/js/tempusdominus-bootstrap-4.min.js"
></script>
<link
rel=
"stylesheet"
href=
"/css/tempusdominus-bootstrap-4.min.css"
/>
<link
href=
"/css/font-awesome.min.css"
rel=
"stylesheet"
>
{{--css 樣式定義--}}
<style
type=
"text/css"
>
/*人臉訊息文字*/
p
.information
{
margin
:
0px
auto
;
font-size
:
8pt
;
text-align
:
center
;
color
:
white
;
}
.seeline
{
border
:
#000000
1px
solid
;
}
/*人臉圖片*/
img
.faceimg
{
border
:
2px
#ccc
solid
;
/*width: 30%;*/
width
:
50px
;
align-self
:
center
;
margin-left
:
2%
;
}
input
.checkbox
{
display
:
block
;
width
:
100%
;
height
:
20px
;
}
/*datetimepicker 字體修正字體修正*/
.datepicker
{
font-size
:
18px
;
}
/* 複寫 fixed-height 已修改固定data高度*/
.fixed-height
{
height
:
75vh
!important
;
}
.error
{
color
:
#66A8CC
;
}
</style>
@endsection
@section('body')
@endsection
@section('content')
{{--主畫面--}}
<div>
<div
class=
"row"
style=
"height: 100vh;margin-left: -0;margin-right: 0px;"
>
{{--左邊功能選單--}}
<div
class=
"collapse p-4 col-2 show"
id=
"navbarToggleExternalContent"
style=
"background: #0271a0"
>
{{--引入功能選單--}}
@include('contents', ['this_page' => '26'])
</div>
{{--右邊主畫面區--}}
<div
id=
"Screen-aria"
class=
"col-10"
style=
"background:#e0e6ec"
>
{{--保留區域--}}
<div
style=
"height: 5vh;width: 100%"
></div>
<div
id=
"Screens"
style=
"height: 85vh;width: 100%;text-align: center"
>
{{--操作列--}}
<form
class=
"row"
id=
"attendance_setting_from"
method=
"post"
action=
"{{ Route('shift_punch_card_export') }}"
style=
"height: 10vh"
>
{{ csrf_field() }}
<div
class=
"col-3"
>
<div
class=
"input-group date"
id=
"datetimepicker1"
data-target-input=
"nearest"
>
<div
class=
"input-group-prepend"
>
<div
class=
"input-group-text"
>
起始時間
</div>
</div>
<input
id=
'start_time'
style=
"text-align: center"
name=
"start_time"
type=
"text"
class=
"form-control datetimepicker-input"
data-target=
"#datetimepicker1"
required
/>
<div
class=
"input-group-append"
data-target=
"#datetimepicker1"
data-toggle=
"datetimepicker"
>
<div
class=
"input-group-text"
><i
class=
"fa fa-calendar"
></i></div>
</div>
</div>
</div>
<div
class=
"col-3"
>
<div
class=
"input-group date"
id=
"datetimepicker2"
data-target-input=
"nearest"
>
<div
class=
"input-group-prepend"
>
<div
class=
"input-group-text"
>
結束時間
</div>
</div>
<input
id=
'end_time'
style=
"text-align: center"
name=
"end_time"
type=
"text"
class=
"form-control datetimepicker-input"
data-target=
"#datetimepicker2"
required
/>
<div
class=
"input-group-append"
data-target=
"#datetimepicker2"
data-toggle=
"datetimepicker"
>
<div
class=
"input-group-text"
><i
class=
"fa fa-calendar"
></i></div>
</div>
</div>
</div>
<div
class=
"col-3"
>
<button
type=
"submit"
class=
"btn btn-outline-dark"
style=
"margin-right: 10px;float: left"
>
匯出
</button>
</div>
<div
class=
"col-3 float-right"
>
<button
type=
"button"
class=
"btn btn-outline-dark float-right"
style=
"margin-right: 10px;"
data-toggle=
"modal"
data-target=
"#Shift"
>
班別編修
</button>
</div>
</form>
<p></p>
{{--表格呈現-列表--}}
<table
class=
"table table-striped table-bordered table-hover"
id=
"tableL01"
style=
"height: 75vh"
></table>
</div>
</div>
</div>
</div>
{{--彈窗區--}}
{{-- 班別編修彈出視窗 --}}
<div
class=
"modal fade "
id=
"Shift"
tabindex=
"-1"
role=
"dialog"
aria-labelledby=
"exampleModalCenterTitle"
aria-hidden=
"true"
style=
"overflow:visible;"
>
<div
class=
"modal-dialog modal-dialog-centered modal-lg"
role=
"document"
>
<div
class=
"modal-content"
style=
"height: 600px"
>
<div
class=
"modal-header"
>
<h5
class=
"modal-title"
id=
"exampleModalLongTitle"
>
班別編修
</h5>
<button
type=
"button"
class=
"close"
data-dismiss=
"modal"
aria-label=
"Close"
>
<span
aria-hidden=
"true"
>
×
</span>
</button>
</div>
<div
class=
"modal-body row"
>
<input
type=
"hidden"
class=
"form-control"
id=
"features_user"
name=
"features_user"
readonly
>
<div
class=
"col-12 text-center"
style=
"height: 420px; overflow: auto"
>
<table
class=
"table table-striped table-bordered table-hover"
id=
"tableL02"
>
<tbody>
<tr>
<td></td>
<td><input
type=
"text"
id=
"i_name"
class=
"form-control"
placeholder=
""
required
></td>
<td><input
type=
"time"
id=
"i_start"
class=
"form-control"
placeholder=
""
required
></td>
<td><input
type=
"time"
id=
"i_end"
class=
"form-control"
placeholder=
""
required
></td>
<td><input
type=
"text"
id=
"i_note"
class=
"form-control"
placeholder=
""
required
></td>
<td>
<button
type=
"button"
class=
"btn btn-outline-success"
onclick=
"insert_shift()"
>
新增
</button>
</td>
</tr>
@foreach($shifts as $shift)
<tr>
<td>
{{$shift["no"]}}
</td>
<td>
<a
id=
"a_{{$shift["
no
"]}}
_name
"
style=
"display: inline; cursor: pointer;"
onclick=
"change_update('{{$shift["
no
"]}}')"
>
{{$shift["name"]}}
</a>
<input
type=
"hidden"
class=
"form-control"
id=
"u_{{$shift["
no
"]}}
_name
"
value=
"{{$shift["
name
"]}}"
required
>
</td>
<td>
<a
id=
"a_{{$shift["
no
"]}}
_start
"
style=
"display: inline; cursor: pointer;"
onclick=
"change_update('{{$shift["
no
"]}}')"
>
{{$shift["start"]}}
</a>
<input
type=
"hidden"
class=
"form-control"
id=
"u_{{$shift["
no
"]}}
_start
"
value=
"{{$shift["
start
"]}}"
required
>
</td>
<td>
<a
id=
"a_{{$shift["
no
"]}}
_end
"
style=
"display: inline; cursor: pointer;"
onclick=
"change_update('{{$shift["
no
"]}}')"
>
{{$shift["end"]}}
</a>
<input
type=
"hidden"
class=
"form-control"
id=
"u_{{$shift["
no
"]}}
_end
"
value=
"{{$shift["
end
"]}}"
required
>
</td>
<td>
<a
id=
"a_{{$shift["
no
"]}}
_note
"
style=
"display: inline; cursor: pointer;"
onclick=
"change_update('{{$shift["
no
"]}}')"
>
{{$shift["note"]}}
</a>
<input
type=
"hidden"
class=
"form-control"
id=
"u_{{$shift["
no
"]}}
_note
"
value=
"{{$shift["
note
"]}}"
required
>
</td>
<td>
<button
type=
"button"
id=
"btn_{{$shift["
no
"]}}
_change
"
class=
"btn btn-outline-info"
style=
"display: inline"
onclick=
"change_update('{{$shift["
no
"]}}')"
>
修改
</button>
<button
type=
"button"
id=
"btn_{{$shift["
no
"]}}
_update
"
class=
"btn btn-outline-info"
style=
"display: none"
onclick=
"update_shift('{{$shift["
no
"]}}')"
>
送出
</button>
<button
type=
"button"
class=
"btn btn-outline-danger"
onclick=
"delete_shift('{{$shift["
no
"]}}')"
>
刪除
</button>
</td>
</tr>
@endforeach
</tbody>
</table>
</div>
</div>
<div
class=
"modal-footer"
>
<button
type=
"button"
class=
"btn btn-primary"
data-dismiss=
"modal"
>
確定
</button>
</div>
</div>
</div>
<div>
</div>
</div>
{{-- 班別編修彈出視窗 --}}
<div
class=
"modal fade"
id=
"DeviceShift"
tabindex=
"-1"
role=
"dialog"
aria-labelledby=
"exampleModalCenterTitle"
aria-hidden=
"true"
style=
"overflow:visible;"
>
<div
class=
"modal-dialog modal-dialog-centered modal-lg"
role=
"document"
>
<div
class=
"modal-content"
style=
"height: 600px"
>
<div
class=
"modal-header"
>
<h5
class=
"modal-title"
id=
"exampleModalLongTitle"
>
班別編修
</h5>
<button
type=
"button"
class=
"close"
data-dismiss=
"modal"
aria-label=
"Close"
>
<span
aria-hidden=
"true"
>
×
</span>
</button>
</div>
<form
id=
"device_shift_relation"
action=
"{{ route("
device_shift_update
")
}}"
method=
"POST"
enctype=
"multipart/form-data"
>
{{ csrf_field() }}
<div
class=
"modal-body row"
>
<div
class=
"col-12 text-center"
style=
"height: 420px; overflow: auto"
>
<input
type=
"hidden"
class=
"form-control"
id=
"device_id"
name=
"device_id"
readonly
>
<table
class=
"table table-striped table-bordered table-hover"
id=
"tableL03"
>
<tbody>
@foreach($shifts as $shift)
<tr>
<td>
<input
id=
"shift_{{$shift["
name
"]}}"
type=
"checkbox"
name=
"device_shift_{{$shift["
no
"]}}"
value=
"{{$shift["
no
"]}}"
/>
</td>
<td>
<a>
{{$shift["name"]}}
</a>
</td>
<td>
<a>
{{$shift["start"]}}
</a>
</td>
<td>
<a>
{{$shift["end"]}}
</a>
</td>
<td>
<a>
{{$shift["note"]}}
</a>
</td>
</tr>
@endforeach
</tbody>
</table>
</div>
</div>
<div
class=
"modal-footer"
>
<button
type=
"submit"
class=
"btn btn-primary"
>
確定
</button>
<button
type=
"button"
class=
"btn btn-secondary"
data-dismiss=
"modal"
>
取消
</button>
</div>
</form>
</div>
</div>
<div>
</div>
</div>
<script>
function
change_update
(
no
)
{
var
name_id
=
"u_"
+
no
+
"_name"
;
document
.
getElementById
(
name_id
).
type
=
"text"
;
var
start_id
=
"u_"
+
no
+
"_start"
;
document
.
getElementById
(
start_id
).
type
=
"time"
;
var
end_id
=
"u_"
+
no
+
"_end"
;
document
.
getElementById
(
end_id
).
type
=
"time"
;
var
note_id
=
"u_"
+
no
+
"_note"
;
document
.
getElementById
(
note_id
).
type
=
"text"
;
var
name_a
=
"a_"
+
no
+
"_name"
;
document
.
getElementById
(
name_a
).
style
.
display
=
"none"
;
var
start_a
=
"a_"
+
no
+
"_start"
;
document
.
getElementById
(
start_a
).
style
.
display
=
"none"
;
var
end_a
=
"a_"
+
no
+
"_end"
;
document
.
getElementById
(
end_a
).
style
.
display
=
"none"
;
var
note_a
=
"a_"
+
no
+
"_note"
;
document
.
getElementById
(
note_a
).
style
.
display
=
"none"
;
var
change_id
=
"btn_"
+
no
+
"_change"
;
var
update_id
=
"btn_"
+
no
+
"_update"
;
document
.
getElementById
(
update_id
).
style
.
display
=
"inline"
;
document
.
getElementById
(
change_id
).
style
.
display
=
"none"
;
}
function
insert_shift
()
{
var
name
=
document
.
getElementById
(
"i_name"
).
value
;
var
start
=
document
.
getElementById
(
"i_start"
).
value
;
var
end
=
document
.
getElementById
(
"i_end"
).
value
;
var
note
=
document
.
getElementById
(
"i_note"
).
value
;
var
form
=
document
.
createElement
(
"form"
);
form
.
setAttribute
(
"method"
,
"post"
);
form
.
setAttribute
(
"action"
,
"{{Route("
shift_insert
")}}"
);
var
input_name
=
document
.
createElement
(
"input"
);
input_name
.
setAttribute
(
"type"
,
"hidden"
);
input_name
.
setAttribute
(
"name"
,
"name"
);
input_name
.
setAttribute
(
"value"
,
name
);
form
.
appendChild
(
input_name
);
var
input_start
=
document
.
createElement
(
"input"
);
input_start
.
setAttribute
(
"type"
,
"hidden"
);
input_start
.
setAttribute
(
"name"
,
"start"
);
input_start
.
setAttribute
(
"value"
,
start
);
form
.
appendChild
(
input_start
);
var
input_end
=
document
.
createElement
(
"input"
);
input_end
.
setAttribute
(
"type"
,
"hidden"
);
input_end
.
setAttribute
(
"name"
,
"end"
);
input_end
.
setAttribute
(
"value"
,
end
);
form
.
appendChild
(
input_end
);
var
input_note
=
document
.
createElement
(
"input"
);
input_note
.
setAttribute
(
"type"
,
"hidden"
);
input_note
.
setAttribute
(
"name"
,
"note"
);
input_note
.
setAttribute
(
"value"
,
note
);
form
.
appendChild
(
input_note
);
var
csrfField
=
document
.
createElement
(
"input"
);
csrfField
.
setAttribute
(
"type"
,
"hidden"
);
csrfField
.
setAttribute
(
"name"
,
"_token"
);
csrfField
.
setAttribute
(
"value"
,
"{{ csrf_token() }}"
);
form
.
appendChild
(
csrfField
);
document
.
body
.
appendChild
(
form
);
form
.
submit
();
}
function
update_shift
(
no
)
{
var
name_id
=
"u_"
+
no
+
"_name"
;
var
name
=
document
.
getElementById
(
name_id
).
value
;
var
start_id
=
"u_"
+
no
+
"_start"
;
var
start
=
document
.
getElementById
(
start_id
).
value
;
var
end_id
=
"u_"
+
no
+
"_end"
;
var
end
=
document
.
getElementById
(
end_id
).
value
;
var
note_id
=
"u_"
+
no
+
"_note"
;
var
note
=
document
.
getElementById
(
note_id
).
value
;
var
form
=
document
.
createElement
(
"form"
);
form
.
setAttribute
(
"method"
,
"post"
);
form
.
setAttribute
(
"action"
,
"{{Route("
shift_update
")}}"
);
var
input_no
=
document
.
createElement
(
"input"
);
input_no
.
setAttribute
(
"type"
,
"hidden"
);
input_no
.
setAttribute
(
"name"
,
"no"
);
input_no
.
setAttribute
(
"value"
,
no
);
form
.
appendChild
(
input_no
);
var
input_name
=
document
.
createElement
(
"input"
);
input_name
.
setAttribute
(
"type"
,
"hidden"
);
input_name
.
setAttribute
(
"name"
,
"name"
);
input_name
.
setAttribute
(
"value"
,
name
);
form
.
appendChild
(
input_name
);
var
input_start
=
document
.
createElement
(
"input"
);
input_start
.
setAttribute
(
"type"
,
"hidden"
);
input_start
.
setAttribute
(
"name"
,
"start"
);
input_start
.
setAttribute
(
"value"
,
start
);
form
.
appendChild
(
input_start
);
var
input_end
=
document
.
createElement
(
"input"
);
input_end
.
setAttribute
(
"type"
,
"hidden"
);
input_end
.
setAttribute
(
"name"
,
"end"
);
input_end
.
setAttribute
(
"value"
,
end
);
form
.
appendChild
(
input_end
);
var
input_note
=
document
.
createElement
(
"input"
);
input_note
.
setAttribute
(
"type"
,
"hidden"
);
input_note
.
setAttribute
(
"name"
,
"note"
);
input_note
.
setAttribute
(
"value"
,
note
);
form
.
appendChild
(
input_note
);
var
csrfField
=
document
.
createElement
(
"input"
);
csrfField
.
setAttribute
(
"type"
,
"hidden"
);
csrfField
.
setAttribute
(
"name"
,
"_token"
);
csrfField
.
setAttribute
(
"value"
,
"{{ csrf_token() }}"
);
form
.
appendChild
(
csrfField
);
document
.
body
.
appendChild
(
form
);
form
.
submit
();
}
function
delete_shift
(
no
)
{
var
form
=
document
.
createElement
(
"form"
);
form
.
setAttribute
(
"method"
,
"post"
);
form
.
setAttribute
(
"action"
,
"{{Route("
shift_delete
")}}"
);
var
input_no
=
document
.
createElement
(
"input"
);
input_no
.
setAttribute
(
"type"
,
"hidden"
);
input_no
.
setAttribute
(
"name"
,
"no"
);
input_no
.
setAttribute
(
"value"
,
no
);
form
.
appendChild
(
input_no
);
var
csrfField
=
document
.
createElement
(
"input"
);
csrfField
.
setAttribute
(
"type"
,
"hidden"
);
csrfField
.
setAttribute
(
"name"
,
"_token"
);
csrfField
.
setAttribute
(
"value"
,
"{{ csrf_token() }}"
);
form
.
appendChild
(
csrfField
);
document
.
body
.
appendChild
(
form
);
form
.
submit
();
}
//device_shift_relation
function
device_shift_data
(
obj
)
{
@
foreach
(
$shifts
as
$shift
)
var
name
=
"shift_"
+
"{{$shift["
name
"]}}"
document
.
getElementById
(
name
).
checked
=
false
;
@
endforeach
let
jdata_index
=
parseInt
(
obj
.
closest
(
'tr'
).
getAttribute
(
"data-index"
));
document
.
getElementById
(
"device_id"
).
value
=
jdata
[
jdata_index
].
id
;
var
shift_list
=
jdata
[
jdata_index
].
shift_list
;
var
shift_array
=
shift_list
.
split
(
","
);
for
(
var
i
=
0
;
i
<
shift_array
.
length
;
i
++
)
{
if
(
shift_array
[
i
]
!=
""
)
{
document
.
getElementById
(
"shift_"
+
shift_array
[
i
]).
checked
=
true
;
}
}
}
</script>
{{-- boostrap tabel js--}}
<script>
// 載入人員資料
@
php
if
(
isset
(
$devices
)){
echo
"var jdata="
.
json_encode
(
$devices
).
";"
;
}
else
{
echo
"var jadata=[];"
;
}
@
endphp
$
(
'#tableL01'
).
bootstrapTable
(
'destroy'
);
//動態載入表格之前,先銷燬表格
var
tableColumns
=
[
// {field: 'state', checkbox: true,},
// {field: 'no',title: '編號',sortable: true},
{
field
:
'id'
,
title
:
'設備編號'
,
sortable
:
true
},
{
field
:
'location'
,
title
:
'設備位置'
,
sortable
:
true
},
{
field
:
'shift_list'
,
title
:
'班別'
,
sortable
:
true
},
{
field
:
'modify'
,
title
:
''
,
sortable
:
false
},
];
$
(
'#tableL01'
).
bootstrapTable
({
//表格初始化
locale
:
"zh-TW"
,
// 地區語系轉換
columns
:
tableColumns
,
//表頭
data
:
jdata
,
//通過ajax返回的資料
width
:
0
,
height
:
1
,
method
:
'get'
,
// pageSize: 5, //每頁3條
// pageNumber: 1, //第1頁
// pageList: "[5,10,all]", //在使用過程中根據情況調整每頁條數.雖然你現在定義的每頁3條,但你可以隨時調整為10條或25條。
cache
:
false
,
//不快取
striped
:
true
,
pagination
:
false
,
sidePagination
:
'client'
,
search
:
false
,
showRefresh
:
false
,
showExport
:
false
,
showFooter
:
false
,
exportTypes
:
[
'csv'
,
'txt'
,
'xml'
,
'excel'
],
clickToSelect
:
true
,
sortName
:
'location'
,
// 預設排序
groupBy
:
false
,
groupByField
:
'group'
});
var
tableColumns2
=
[
{
field
:
'no'
,
title
:
'編號'
,
sortable
:
false
},
{
field
:
'name'
,
title
:
'班別'
,
sortable
:
false
,
width
:
80
},
{
field
:
'start'
,
title
:
'開始時間'
,
sortable
:
false
,
width
:
170
},
{
field
:
'end'
,
title
:
'結束時間'
,
sortable
:
false
,
width
:
170
},
{
field
:
'note'
,
title
:
'備註'
,
sortable
:
false
,
width
:
100
},
{
field
:
''
,
title
:
''
,
sortable
:
false
},
];
$
(
'#tableL02'
).
bootstrapTable
({
//表格初始化
locale
:
"zh-TW"
,
// 地區語系轉換
columns
:
tableColumns2
,
//表頭
// width:0.3*Math.max(document.documentElement.clientWidth, window.innerWidth || 0),
//height:1,
method
:
'get'
,
// pageSize: 5, //每頁3條
// pageNumber: 1, //第1頁
// pageList: "[5,10,all]", //在使用過程中根據情況調整每頁條數.雖然你現在定義的每頁3條,但你可以隨時調整為10條或25條。
cache
:
false
,
//不快取
striped
:
true
,
pagination
:
false
,
sidePagination
:
'client'
,
search
:
false
,
showRefresh
:
false
,
showExport
:
false
,
showFooter
:
false
,
exportTypes
:
[
'csv'
,
'txt'
,
'xml'
,
'excel'
],
clickToSelect
:
true
,
sortName
:
'no'
,
// 預設排序
});
var
tableColumns3
=
[
//{field: 'no',title: '編號',sortable: false,},
{
field
:
''
,
title
:
''
,
sortable
:
false
,
width
:
50
},
{
field
:
'name'
,
title
:
'班別'
,
sortable
:
false
},
{
field
:
'start'
,
title
:
'開始時間'
,
sortable
:
false
},
{
field
:
'end'
,
title
:
'結束時間'
,
sortable
:
false
},
{
field
:
'note'
,
title
:
'備註'
,
sortable
:
false
},
];
$
(
'#tableL03'
).
bootstrapTable
({
//表格初始化
locale
:
"zh-TW"
,
// 地區語系轉換
columns
:
tableColumns3
,
//表頭
// width:0.3*Math.max(document.documentElement.clientWidth, window.innerWidth || 0),
// height:0.3*Math.max(document.documentElement.clientHeight, window.innerHeight || 0),
method
:
'get'
,
// pageSize: 5, //每頁3條
// pageNumber: 1, //第1頁
// pageList: "[5,10,all]", //在使用過程中根據情況調整每頁條數.雖然你現在定義的每頁3條,但你可以隨時調整為10條或25條。
cache
:
false
,
//不快取
striped
:
true
,
pagination
:
false
,
sidePagination
:
'client'
,
search
:
false
,
showRefresh
:
false
,
showExport
:
false
,
showFooter
:
false
,
exportTypes
:
[
'csv'
,
'txt'
,
'xml'
,
'excel'
],
clickToSelect
:
true
,
sortName
:
'name'
,
// 預設排序
});
</script>
<!-- 上班時間 (datetimepicker1物件) -->
<script
type=
"text/javascript"
>
$
(
function
()
{
$
(
'#datetimepicker1'
).
datetimepicker
({
locale
:
'zh-tw'
,
// format: 'YYYY-MM-DD a hh:mm:ss ',
format
:
'YYYY-MM-DD HH:mm:ss'
,
weekStart
:
1
,
autoclose
:
1
,
todayHighlight
:
1
,
inline
:
false
,
allowInputToggle
:
true
,
sideBySide
:
false
,
stepping
:
0
,
minView
:
0
,
maxView
:
0
,
maxDate
:
new
Date
().
setHours
(
23
,
59
,
59
),
startView
:
0
,
// 0 =月曆 1=月份 2 =年份
date
:
new
Date
(
"{{ old('start_time',date("
Y
-
m
-
d
")."
00
:
00
:
00
") }}"
),
// 初始值
});
});
</script>
<!-- 下班時間 (datetimepicker2物件) -->
<script
type=
"text/javascript"
>
$
(
function
()
{
$
(
'#datetimepicker2'
).
datetimepicker
({
locale
:
'zh-tw'
,
// format: 'YYYY-MM-DD a hh:mm:ss ',
format
:
'YYYY-MM-DD HH:mm:ss'
,
weekStart
:
1
,
autoclose
:
1
,
todayHighlight
:
1
,
inline
:
false
,
allowInputToggle
:
true
,
sideBySide
:
false
,
stepping
:
0
,
minView
:
0
,
maxView
:
0
,
maxDate
:
new
Date
().
setHours
(
23
,
59
,
59
),
startView
:
0
,
// 0 =月曆 1=月份 2 =年份
date
:
new
Date
(
"{{old('end_time',date("
Y
-
m
-
d
")."
23
:
59
:
59
") }}"
)
// 初始值
});
});
</script>
@endsection
laravel-guardian/resources/views/contents.blade.php
View file @
f870efcd
...
...
@@ -2,7 +2,7 @@
<
a
href
=
"{{ Route("
comparison
") }}"
style
=
"text-decoration:none;"
><
h2
class
="
text
-
dark
" style="
font
-
size
:
20
pt
;
text
-
align
:
center
;
background
:
white
">人員管理</h2></a>
@elseif(
$this_page
=="
7
" ||
$this_page
=="
8
" ||
$this_page
=="
17
" ||
$this_page
=="
9
" ||
$this_page
=="
23
" ||
$this_page
=="
22
" ||
$this_page
=="
10
" ||
$this_page
=="
11
")
<a href="
{{
Route
(
"attendance"
)
}}
" style="
text
-
decoration
:
none
;
"><h2 class="
text
-
dark
" style="
font
-
size
:
20
pt
;
text
-
align
:
center
;
background
:
white
">差勤管理</h2></a>
@elseif(
$this_page
=="
12
" ||
$this_page
=="
13
" ||
$this_page
=="
14
" ||
$this_page
=="
15
" ||
$this_page
=="
16
")
@elseif(
$this_page
=="
12
" ||
$this_page
=="
13
" ||
$this_page
=="
14
" ||
$this_page
=="
15
" ||
$this_page
=="
16
"
||
$this_page
=="
26
"
)
<a href="
{{
Route
(
"device_time"
)
}}
" style="
text
-
decoration
:
none
;
"><h2 class="
text
-
dark
" style="
font
-
size
:
20
pt
;
text
-
align
:
center
;
background
:
white
">設備管理</h2></a>
@endif
<div style="
height
:
5
vh
"></div>
...
...
@@ -30,11 +30,12 @@
{{
--
<
a
id
=
"11"
class
="
nav
-
link
" href="
{{
Route
(
"graph_attendance"
)
}}
" style="
color
:
#ffffff;display: none">差勤圖表</a>--}}
</
div
>
</
div
>
<
a
id
=
"title_device"
class
="
nav
-
linggk
"
data-toggle="
collapse
" href="
#collapseDevice" role="button" aria-expanded="false" aria-controls="collapseDevice" href="#" style="color: #ffffff;display: none">設備管理</a>
<
a
id
=
"title_device"
class
="
nav
-
link
"
data-toggle="
collapse
" href="
#collapseDevice" role="button" aria-expanded="false" aria-controls="collapseDevice" href="#" style="color: #ffffff;display: none">設備管理</a>
<
div
class
="
collapse
" id="
collapseDevice
">
<div class="
card
card
-
body
" style="
background
:
rgba
(
255
,
255
,
255
,
0
);
font
-
size
:
17
px
;
">
{{-- <a id="
12
" class="
nav
-
link
" href="
{{
Route
(
"device"
)
}}
" style="
color
:
#ffffff;display: none">設備管理</a>--}}
{{
--
<
a
id
=
"13"
class
="
nav
-
link
" href="
{{
Route
(
"type"
)
}}
" style="
color
:
#ffffff;display: none">類型管理</a>--}}
<a id="
12
" class="
nav
-
link
" href="
{{
Route
(
"device"
)
}}
" style="
color
:
#ffffff;display: none">設備管理</a>
{{
--
<
a
id
=
"13"
class
="
nav
-
link
" href="
{{
Route
(
"type"
)
}}
" style="
color
:
#ffffff;display: none">類型管理</a>--}}
<
a
id
=
"26"
class
="
nav
-
link
" href="
{{
Route
(
"shift_index"
)
}}
" style="
color
:
#ffffff;display: none">班別<a>
{{
--
<
a
id
=
"14"
class
="
nav
-
link
" href="
{{
Route
(
"group"
)
}}
" style="
color
:
#ffffff;display: none">群組管理</a>--}}
{{
--
<
a
id
=
"15"
class
="
nav
-
link
" href="
{{
Route
(
"relation"
)
}}
" style="
color
:
#ffffff;display: none">設備群組關係</a>--}}
<
a
id
=
"16"
class
="
nav
-
link
" href="
{{
Route
(
"device_time"
)
}}
" style="
color
:
#ffffff;display: none">設備時間</a>
...
...
@@ -75,7 +76,7 @@
var attendance=document.getElementById("
title_attendance
");
attendance.style.display="";
}
if(
{
{$auth["features_id"]}
}
=='12' ||
{
{$auth["features_id"]}
}
=='13' ||
{
{$auth["features_id"]}
}
=='14' ||
{
{$auth["features_id"]}
}
=='15' ||
{
{$auth["features_id"]}
}
=='16')
if(
{
{$auth["features_id"]}
}
=='12' ||
{
{$auth["features_id"]}
}
=='13' ||
{
{$auth["features_id"]}
}
=='14' ||
{
{$auth["features_id"]}
}
=='15' ||
{
{$auth["features_id"]}
}
=='16'
||
{
{$auth["features_id"]}
}
=='26'
)
{
var device=document.getElementById("
title_device
");
device.style.display="";
...
...
@@ -93,7 +94,7 @@
{
$('#collapseLeave').collapse('show');
}
if(
{
{$this_page}
}
=='12' ||
{
{$this_page}
}
=='13' ||
{
{$this_page}
}
=='14' ||
{
{$this_page}
}
=='15' ||
{
{$this_page}
}
=='16')
if(
{
{$this_page}
}
=='12' ||
{
{$this_page}
}
=='13' ||
{
{$this_page}
}
=='14' ||
{
{$this_page}
}
=='15' ||
{
{$this_page}
}
=='16'
||
{
{$this_page}
}
=='26'
)
{
$('#collapseDevice').collapse('show');
}
...
...
laravel-guardian/routes/web.php
View file @
f870efcd
...
...
@@ -37,6 +37,16 @@ Route::group(['prefix'=>'/Device','middleware'=>'auth'],function (){
Route
::
get
(
'/time'
,
"DeviceController@set_datetime_index"
)
->
name
(
'device_time'
);
Route
::
post
(
'/time'
,
"DeviceController@set_datetime"
)
->
name
(
'set_device_time'
);
});
//班別管理
Route
::
group
([
'prefix'
=>
'/Shift'
,
'middleware'
=>
'auth'
],
function
(){
Route
::
get
(
'/'
,
"DeviceController@shift_index"
)
->
name
(
'shift_index'
);
Route
::
post
(
'/insert'
,
"DeviceController@shift_insert"
)
->
name
(
'shift_insert'
);
Route
::
post
(
'/update'
,
"DeviceController@shift_update"
)
->
name
(
'shift_update'
);
Route
::
post
(
'/delete'
,
"DeviceController@shift_delete"
)
->
name
(
'shift_delete'
);
Route
::
post
(
'/device/relation/update'
,
"DeviceController@device_shift_update"
)
->
name
(
'device_shift_update'
);
Route
::
post
(
'/device/export'
,
"DeviceController@shift_punch_card_export"
)
->
name
(
'shift_punch_card_export'
);
});
// 設備管理
//Route::group(['prefix'=>'/Camera','middleware'=>'auth'],function (){
// Route::get('/',"CameraController@index")->name('camera');
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment