/var/www/(Del)pathways.org.hk/MIS20140127/old20140127/Event/Event_DetailFrom_ajax.php


1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
<?php

include_once '../include/DBConnect.php';

if (isset(
$_GET['lesson_date']) && isset($_GET['starttime']) && isset($_GET['endtime']) && isset($_GET['roomid'])) {
    
$count 0;
    
$event_id $_GET['event_id'];
    
$lessondate $_GET['lesson_date'];
    
$starttime $_GET['starttime'];
    
$endtime $_GET['endtime'];
    
$roomid $_GET['roomid'];
    
$row $_GET['row'] + 1;
//    var_dump($lessondate);echo "<br>";
//    var_dump($roomid);echo "<br>";
//    var_Dump("SELECT `start_time`,`end_time` FROM `lesson` WHERE `actived`=1 and `deleted`=0 and `room_id` = '".$roomid."' and `date` ='".$lessondate."'");
//    echo "<br>";
    
$sth $dbh->prepare("SELECT `start_time`,`end_time` FROM `lesson` WHERE `actived`=1 and `deleted`=0 and `room_id` = ? and `date` = ?");
    
$sth->bindParam(1$roomid);
    
$sth->bindParam(2$lessondate);
    
$sth->execute();
    if (
$sth->rowcount() == 0) {
        
$add "delete_row_lesson(this,$row);";
        echo 
"<tr>
          <td style=\"margin-left:auto;margin-right:auto;\"><button type=\"button\" class=\"btn\"  onclick=\"
$add\"><i class=\"icon-remove\"></i></button></td>          
          <td>
$lessondate<input type=\"hidden\" name=\"lesson_date[]\" value=\"$lessondate\"/></td>
          <td>
$starttime:00<input type=\"hidden\" name=\"start_time[]\" value=\"$starttime\"/></td>
          <td>
$endtime:00<input type=\"hidden\" name=\"end_time[]\" value=\"$endtime\"/></td>
          <td>
$roomid<input type=\"hidden\" name=\"Room_id[]\" value=\"$roomid\"/></td>
          <td>
            <label class=\"radio inline\">Normal Class<input checked='ckecked'  type=\"radio\" id=\"lesson_state_normal_class_
$row ?>\" value=\"0\" name=\"lesson_state_$row\"  onclick=\"checkradio($row)\"/></label>
            <label class=\"radio inline\">Make-up Class<input type=\"radio\" id=\"lesson_state_makeup_class_
$row\" value=\"1\" name=\"lesson_state_$row\" onclick=\"checkradio($row)\" /></label>
          </td>
          <td style=\"width: 100px;text-align: left;\"><button class=\"btn\" data-toggle=\"modal\" data-target=\"#student_modal_
$row\" onclick=\"checkradio($row);\"><i class=\"icon-user\"></i> Student</button></td>
          <td style=\"width: 100px;text-align: left;\"><button class=\"btn\" data-toggle=\"modal\" data-target=\"#staff_modal_
$row\" onclick=\"checkradio2($row);\"><i class=\"icon-leaf\" ></i> Teacher</button></td>
        </tr>"
;
    } else {
        while (
$ResultSet $sth->fetch(PDO::FETCH_ASSOC)) {
            
$count++;
            
$db_starttime mktime(explode(':'$ResultSet['start_time'],0), explode(':'$ResultSet['start_time'],1));
            
$db_endtime mktime(explode(':'$ResultSet['end_time'],0), explode(':'$ResultSet['end_time'],1));
            
$gen_starttime mktime(explode(':'$starttime,0), explode(':'$starttime,1));
            
$gen_endtime mktime(explode(':'$endtime,0), explode(':'$endtime,1));
            
/* S=db start time E=db end time ||=gen start/end time  */
            /* --- case 1 :( | S E | )   --- */
            /* --- case 2 :( | S | E )   --- */
            /* --- case 3 :( S | E | )   --- */
            /* --- case 4 :( S | | E )   --- */
            
if ($db_starttime <= $gen_starttime && $db_endtime >= $gen_starttime) {   // case 1, case 2
                
echo "1234";
                break;
            }
            if (
$db_starttime <= $gen_endtime && $db_endtime >= $gen_endtime) {       // case 3, case 1
                
echo "1234";
                break;
            }
            if (
$db_starttime >= $gen_starttime && $db_endtime <= $gen_endtime) {     // case 4
                
echo "1234";
                break;
            }
            if (
$count == $sth->rowcount()) {
                
$add "delete_row_lesson(this,$row);";
                echo 
"<tr>
          <td style=\"margin-left:auto;margin-right:auto;\"><button type=\"button\" class=\"btn\"  onclick=\"
$add\"><i class=\"icon-remove\"></i></button></td>          
          <td>
$lessondate<input type=\"hidden\" name=\"lesson_date[]\" value=\"$lessondate\"/></td>
          <td>
$starttime<input type=\"hidden\" name=\"start_time[]\" value=\"$starttime\"/></td>
          <td>
$endtime<input type=\"hidden\" name=\"end_time[]\" value=\"$endtime\"/></td>
          <td>
$roomid<input type=\"hidden\" name=\"Room_id[]\" value=\"$roomid\"/></td>
          <td>
            <label class=\"radio inline\">Normal Class<input type=\"radio\" id=\"lesson_state_normal_class_
$row ?>\" value=\"0\" name=\"lesson_state_$row\"  onclick=\"checkradio($row)\"/></label>
            <label class=\"radio inline\">Make-up Class<input type=\"radio\" id=\"lesson_state_makeup_class_
$row\" value=\"1\" name=\"lesson_state_$row\" onclick=\"checkradio($row)\" /></label>
          </td>
          <td style=\"width: 100px;text-align: left;\"><button class=\"btn\" data-toggle=\"modal\" data-target=\"#student_modal_
$row\" onclick=\"checkradio($row);\"><i class=\"icon-user\"></i> Student</button></td>
          <td style=\"width: 100px;text-align: left;\"><button class=\"btn\" data-toggle=\"modal\" data-target=\"#staff_modal_
$row\" onclick=\"checkradio2($row);\"><i class=\"icon-leaf\" ></i> Teacher</button></td>
            </tr>"
;
            }
        }
    }
}

/**/
?>