dpziir0079 2015-11-29 14:35
浏览 15
已采纳

从mysql中禁用时间选择器

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:

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.

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')

)

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

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.

So please

  • Check if my mysql query is correct
  • Recommend a time picker
  • An example implantation is highly appreciated

Update

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.

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.

  • 写回答

2条回答 默认 最新

  • doumu1951 2015-12-06 17:03
    关注

    @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('');
                             }
                        },
    });
    

    Here is the whole fiddle

    Regards,

    George

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(1条)

报告相同问题?

悬赏问题

  • ¥15 运筹学中在线排序的时间在线排序的在线LPT算法
  • ¥30 求一段fortran代码用IVF编译运行的结果
  • ¥15 深度学习根据CNN网络模型,搭建BP模型并训练MNIST数据集
  • ¥15 lammps拉伸应力应变曲线分析
  • ¥15 C++ 头文件/宏冲突问题解决
  • ¥15 用comsol模拟大气湍流通过底部加热(温度不同)的腔体
  • ¥50 安卓adb backup备份子用户应用数据失败
  • ¥20 有人能用聚类分析帮我分析一下文本内容嘛
  • ¥15 请问Lammps做复合材料拉伸模拟,应力应变曲线问题
  • ¥30 python代码,帮调试,帮帮忙吧