/var/www/(Del)pathways.org.hk/MIS20140127/old20140407/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
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
<?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'];
    
$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>
            <input class=\"required\" type=\"text\" value=\"" 
. ((strtotime($endtime) - strtotime($starttime)) / 60) . "\" style=\"margin-left: 1px;margin-right: 1px;width: 85%\" name=\"teaching_hour[]\" autocomplete=\"off\" onkeydown=\"return ( event.ctrlKey || event.altKey || (47<event.keyCode && event.keyCode<58 && event.shiftKey==false) || (95<event.keyCode && event.keyCode<106) || (event.keyCode==8) || (event.keyCode==9) || (event.keyCode>34 && event.keyCode<40) || (event.keyCode==46) )\"/>
            (Minutes)
          </td>
          <td>
$roomid<input type=\"hidden\" name=\"Room_id[]\" value=\"$roomid\"/></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><label id=\"student_label_0" . ($row 1) . "\"></label> </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><label id=\"staff_label_0" . ($row 1) . "\"></label> </td>
        </tr>"
;
    } else {
        while (
$ResultSet $sth->fetch(PDO::FETCH_ASSOC)) {
            
$count++;
            
$resultset_start_time explode(':'$ResultSet['start_time']);
            
$resultset_end_time explode(':'$ResultSet['end_time']);
            
$starttime_exp explode(':'$starttime);
            
$endtime_exp explode(':'$endtime);
            
$db_starttime mktime($resultset_start_time[0], $resultset_start_time[1]);
            
$db_endtime mktime($resultset_end_time[0], $resultset_end_time[1]);
            
$gen_starttime mktime($starttime_exp[0], $starttime_exp[1]);
            
$gen_endtime mktime($endtime_exp[0], $endtime_exp[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>
            <input class=\"required\" type=\"text\" value=\"" 
. ((strtotime($endtime) - strtotime($starttime)) / 60) . "\" style=\"margin-left: 1px;margin-right: 1px;width: 85%\" name=\"teaching_hour[]\" autocomplete=\"off\" onkeydown=\"return ( event.ctrlKey || event.altKey || (47<event.keyCode && event.keyCode<58 && event.shiftKey==false) || (95<event.keyCode && event.keyCode<106) || (event.keyCode==8) || (event.keyCode==9) || (event.keyCode>34 && event.keyCode<40) || (event.keyCode==46) )\"/>
            (Minutes)
          </td>
          <td>
$roomid<input type=\"hidden\" name=\"Room_id[]\" value=\"$roomid\"/></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>
            <label id=\"student_label_0" 
. ($row 1) . "\"></label> 
          </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>
            <label id=\"staff_label_0" 
. ($row 1) . "\"></label> 
          </td>
            </tr>"
;
            }
        }
    }
}

if (isset(
$_GET['event_id']) && isset($_GET['root_id'])){
    
$event_id $_GET['event_id'];
    
$root_id $_GET['root_id'];
    
$sth $dbh->query("select date,lesson_id from lesson_attendance where actived = 1 and deleted = 0 and stu_linking_id = $root_id and state = 3 and lesson_id in (select lesson_id from event_lesson where actived = 1 and deleted = 0 and event_id = $event_id) order by 1");
    while(
$result $sth->fetch(PDO::FETCH_ASSOC)){
        echo 
"<option value=\"".$result["date"].",".$result['lesson_id']."\">".$result['date']."</option>";
    }
    
}
?>