从MySQL禁用时间选择器 [英] Disable time picker from mysql
问题描述
目前,我正在使用html 时间选择器,但是不会请改用Javascript/Jquery/Ajax.我要解决的问题是:
Currently I'm using html time picker, but wouldn't mind using Javascript/Jquery/Ajax instead. The problem I'm trying to solve is this:
您是客户,您从员工那里订购了x. x具有持续时间(start_time-end_time).时间表数据保存在$customer_time
中.请注意,我必须将日期存储为varchar.但是我的问题不是日期,而是时间.
you are a customer, you ordered x from an employee. that x has a duration (start_time - end_time). The time form data is saved in $customer_time
. Note that I had to store the days as varchar. but my issue is not with date, it's with time.
我拥有的sql查询是这样(如果可以的话,请随时进行改进)
The sql query I have is this (feel free to make it better if you could)
SELECT employee_id, product_start_time, product_end_time, date FROM orders
WHERE NOT (
employee_id ='$employee_id'
AND res_date = '$res_date'
AND $customer_time =TIMEDIFF ('product_start_time','product_end_time')
)
我想我写的timediff是正确的,如果不正确,请更正它,因为我以前从未使用过它,这个主意是
I guess I wrote timediff right, if not please correct it as I have never used it before, the idea is
$customer_time = start_time - end_time
无论如何,如果员工有空,则客户可以继续预订,否则,应禁用time_ picker字段.我需要一个类似html的时间选择器,但是我可以使用它并禁用时间.我不想从时间间隔列表中选择默认时间的时间选择器.
Anyhow, if the employee is free, then the customer can proceed with the reservation, otherwise, the time_ picker field should be disabled. I need a time picker like the html one, but one that I can work with and disable the time. I don't want a time picker where I select default time from a list of intervals.
所以请
- 检查我的mysql查询是否正确
- 推荐时间选择器
- 高度赞赏示例植入
更新
也许我查询的一个更好的版本是使用INTERVAL而不是timediff,因为每个产品的持续时间以分钟为单位,很少有持续时间以小时为单位,但是大多数都是分钟.
Perhaps a better version of my query is to use INTERVAL instead of timediff, since every product has a duration in minutes, few have durations in hours, but mostly minutes.
我最初的想法是创建一个持续检查可用性的时间字段,就像您在使用ajax的用户名字段中检查可用的用户名一样,不知道这样是否行得通.
My initial idea was to create a time field that keeps checking for availability, like you check for available usernames, in a username field using ajax, don't know if that would work though.
推荐答案
@Lynob,这里是带有禁用时间的时间选择器.您需要在禁用的阵列中放置更多时间,它将起作用.
@Lynob here is timepicker with disabled times. You need to put more time in the disabled array and it will work.
var input = $('#input-a');
var dissabledTime = ["11:00", "12:00", "13:00", "14:00"];
input.clockpicker({
autoclose: true,
afterDone: function() {
console.log(dissabledTime.indexOf($('#input-a').val()));
if(dissabledTime.indexOf($('#input-a').val()) != -1)
{
alert("My dear select other time i'm busy :)");
$('#input-a').val('');
}
},
});
这是整个小提琴
此致
乔治
这篇关于从MySQL禁用时间选择器的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!