Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
E
EquipmentBooking
Manage
Activity
Members
Labels
Plan
Issues
0
Issue boards
Milestones
Wiki
Code
Merge requests
0
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
xiuql@ihep.ac.cn
EquipmentBooking
Commits
9b25938d
Commit
9b25938d
authored
4 months ago
by
xiuql@ihep.ac.cn
Browse files
Options
Downloads
Patches
Plain Diff
check selected date
parent
354653c6
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
book_equipment.php
+24
-17
24 additions, 17 deletions
book_equipment.php
with
24 additions
and
17 deletions
book_equipment.php
+
24
−
17
View file @
9b25938d
<?php
ini_set
(
'display_errors'
,
1
);
ini_set
(
'display_startup_errors'
,
1
);
...
...
@@ -168,10 +169,10 @@ while ($row = $questions_result->fetch_assoc()) {
<div
class=
"divider"
></div>
<div
id=
"booking-info"
>
<h5>
>> 先从左侧日历选择日期,再选择时间段
<br
\
>
>> 请在时间表上选择起始时间,结束时间必须在开始时间之后,否则会取消所选时间。
<br
\
>
>> 预约的时长=结束时间-起始时间,最短预约时间为半小时。
<br
\
>
>> 例如:如果起始时间为10:00,结束时间是11:00,虽然显示占据了3个格子,但实际预约的时长仅为1小时!
)
>> 先从左侧日历选择日期,再选择时间段
<br
/
>
>> 请在时间表上选择起始时间,结束时间必须在开始时间之后,否则会取消所选时间。
<br
/
>
>> 预约的时长=结束时间-起始时间,最短预约时间为半小时。
<br
/
>
>> 例如:如果起始时间为10:00,结束时间是11:00,虽然显示占据了3个格子,但实际预约的时长仅为1小时!
</h5>
</div>
<div
id=
"timeSlots"
class=
"mt-4"
></div>
...
...
@@ -195,7 +196,7 @@ while ($row = $questions_result->fetch_assoc()) {
<?php
}
?>
<!-- 提交预约 -->
<button
type=
"submit"
class=
"btn btn-success mt-4"
id=
"submitBookingForm"
>
提交预约
</button>
<button
type=
"submit"
class=
"btn btn-success mt-4"
id=
"submitBookingForm"
disabled
>
提交预约
</button>
</form>
</div>
...
...
@@ -224,8 +225,17 @@ $(document).ready(function () {
}
},
dateClick
:
function
(
info
)
{
// 禁止选择今天之前的日期
var
today
=
new
Date
();
today
.
setHours
(
0
,
0
,
0
,
0
);
var
selectedDate
=
new
Date
(
info
.
dateStr
);
if
(
selectedDate
<
today
)
{
alert
(
'
不能选择过去的日期,请选择今天或之后的日期。
'
);
return
;
}
// 用户选择了日期,自动触发检查预约情况
var
selectedDate
=
info
.
dateStr
;
var
equipmentId
=
<?php
echo
$equipment
[
'id'
];
?>
;
// 清空之前的时间段
...
...
@@ -237,12 +247,12 @@ $(document).ready(function () {
type
:
'
POST
'
,
data
:
{
equipment_id
:
equipmentId
,
date
:
selectedDate
date
:
info
.
dateStr
},
success
:
function
(
data
)
{
var
bookings
=
JSON
.
parse
(
data
);
var
startTime
=
new
Date
(
selectedDate
+
'
T08:00:00
'
);
var
endTime
=
new
Date
(
selectedDate
+
'
T21:00:00
'
);
var
startTime
=
new
Date
(
info
.
dateStr
+
'
T08:00:00
'
);
var
endTime
=
new
Date
(
info
.
dateStr
+
'
T21:00:00
'
);
// 以 30 分钟间隔生成时间段
for
(
var
time
=
startTime
;
time
<
endTime
;
time
.
setMinutes
(
time
.
getMinutes
()
+
30
))
{
...
...
@@ -299,8 +309,8 @@ $(document).ready(function () {
if
(
selectedSlots
.
length
>
1
){
var
firstSlot
=
selectedSlots
[
0
];
var
lastSlot
=
selectedSlots
[
selectedSlots
.
length
-
1
];
var
start
=
new
Date
(
selectedDate
+
'
'
+
firstSlot
+
'
:00
'
);
var
end
=
new
Date
(
selectedDate
+
'
'
+
lastSlot
+
'
:00
'
);
var
start
=
new
Date
(
info
.
dateStr
+
'
'
+
firstSlot
+
'
:00
'
);
var
end
=
new
Date
(
info
.
dateStr
+
'
'
+
lastSlot
+
'
:00
'
);
var
duration
=
(
end
-
start
)
/
(
1000
*
60
*
60
);
// 时长,以分钟为单位
...
...
@@ -309,16 +319,14 @@ $(document).ready(function () {
submitButton
.
disabled
=
true
;
}
else
{
// 更新隐藏的表单值
$
(
'
#selectedStartTime
'
).
val
(
selectedDate
+
'
'
+
firstSlot
+
'
:00
'
);
$
(
'
#selectedEndTime
'
).
val
(
selectedDate
+
'
'
+
lastSlot
+
'
:00
'
);
$
(
'
#selectedDate
'
).
val
(
selectedDate
);
$
(
'
#selectedStartTime
'
).
val
(
info
.
dateStr
+
'
'
+
firstSlot
+
'
:00
'
);
$
(
'
#selectedEndTime
'
).
val
(
info
.
dateStr
+
'
'
+
lastSlot
+
'
:00
'
);
$
(
'
#selectedDate
'
).
val
(
info
.
dateStr
);
submitButton
.
disabled
=
false
;
}
}
else
{
submitButton
.
disabled
=
true
;
}
});
},
error
:
function
()
{
...
...
@@ -333,4 +341,3 @@ $(document).ready(function () {
</script>
</body>
</html>
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment