/var/www/(Del)pathways.org.hk/MIS20140127/old20140127/Event/Event_AddFrom.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
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
<!DOCTYPE html>
<html>
    <head>
        <?php include_once '../include/DBConnect.php'?>
        <?php require_once '../include/head.php'?>
        <?php require_once '../include/checkuser.php'?>
        <?php require_once '../include/Nav_bar.php'?>  
        <script>
            var student_id,staff_id,row=0,row_staff=0,date;
            $(function(){
                $.fn.modal.Constructor.prototype.enforceFocus = function () {};
                $('#programme_fee').change(function(){
                    var fee = $('#programme_fee').val();
                    $.get('Event_AddFrom_ajax.php?feetype=' + fee, funfee);
                });
                function funfee(res){
                    $('#programme_fee_tr').html(res);
                }         
                $('#generate_event_code').click(function(){
                    var programe = $('#programme_id').val();
                    var subject = $('#subject_id').val();
                    if(programe != "" && subject != "")
                        $.get('Event_addFrom_Generate_event_code_ajax.php?programme='+programe+'&subject='+subject,funprograme);
                    else{
                        alert("Please select Subject and Programme !")
                        return;
                    }
                })
                function funprograme(result){                    
                    $('#code_id').val(result);
                }
                $('#start_date_id').datetimepicker({ autoclose: true,pickTime: false, startDate: new Date() });
                $('#start_date_id').datetimepicker().on('changeDate', function(ev){
                    date = new Date($('#Start_date').val());
                    $('#End_date_id').datetimepicker('setStartDate',date);
                    $('#End_date_id').datetimepicker('setDate',date);
                    $('#End_date_id').datetimepicker('show');
                    $('#start_date_id').datetimepicker('hide');
                    $('#End_date_id').datetimepicker('remove');
                });
                $('.timepicker_start').timepicker({ 'timeFormat': 'H:i','step': 5,'minTime':'6:00','maxTime': '22:00'});
                $('.timepicker_end').timepicker({ 'timeFormat': 'H:i','step': 5,'minTime':'6:00','maxTime': '22:00' });                
                $('#End_date_id').datetimepicker({ autoclose: true,pickTime: false, weekStart: 1,startDate: new Date() });                
                $('#End_date_id').datetimepicker().on('changeDate', function(ev){ $('#End_date_id').datetimepicker('hide'); });
                $('.time_1').focus(function(){ $(this).val(''); });
                $('.time_2').focus(function(){ $(this).val(''); });
                $('.time_1').keyup(function(){
                    if($(this).val() >= 24){
                        $(this).val('');
                    }else {
                        if($(this).val().length == 2)
                            $(this).parent().next().next().children().focus();
                    }                    
                });
                $('.time_2').keyup(function(e){
                    if($(this).val() >= 60 ){
                        $(this).val('');
                    }else {
                        if($(this).val().length == 2)
                            $(this).parent().next().next().next().next().children().focus();
                    }   
                    
                });                 
                $("#commentForm").validate();
                $("#student_name").select2();
                $('#staff_name').select2();
                $("#student_name").on("select2-selecting", function(e) { student_id=e.val.split(","); });
                $('#staff_name').on("select2-selecting", function(e){ staff_id=e.val.split(",") });
                $('#btn_addstudent').click(function(){ row++; $('#student_table').append('<tr id="tr_'+row+'"> <td><button type="button" class="btn"  onclick="displayResult('+row+');"><i class="icon-remove"></i></button></td> <td>'+student_id[0]+'</td> <td>'+student_id[1]+' ( '+student_id[2]+' ) '+'<input type="hidden" name="student_id[]" value="'+student_id[3]+'"/></td> </tr>')  });
                $('#btn_addstaff').click(function() { row_staff++; if($('#Rate_staff').val()!='') $('#staff_table').append('<tr id="row_'+row_staff+'"> <td><button type="button" class="btn" onclick="deleterow('+row_staff+')" ><i class="icon-remove"></i></button></td> <td>'+staff_id[0]+' ( '+staff_id[1]+' ) '+'</td> <td>'+$('#Rate_staff').val()+' <input type="hidden" name="staff_id[]" value="'+staff_id[2]+'" /><input type="hidden" name="staff_rate[]" value="'+$('#Rate_staff').val()+'" /></td> </tr>')  });                
            });
            function displayResult(r){
                var row = document.getElementById("tr_"+r);
                row.parentNode.removeChild(row);
            }
            function deleterow(r){
                var row = document.getElementById("row_"+r);
                row.parentNode.removeChild(row);
            }
            function limit_time(e){
                var arr = $(e).val().split(":")[0] * 3600 + $(e).val().split(":")[1]*60 + 15*60 ;
                $(e).parent().next().next().next().next().children().timepicker('option',{disableTimeRanges: [['6:00',arr]]});
            };
        </script>
    </head>
    <?php
    
if (isset($_POST['Delete'])) {
        
$dbh->query("UPDATE `event` SET `lastupdate`=now(),`deleted`=1 WHERE `event_id`='" $_GET['event_id'] . "' ");
        
$dbh->query("UPDATE `event_lesson` set`lastupdate`=now(),`deleted`=1 WHERE `event_id`='" $_GET['event_id'] . "'");
        
$dbh->query("UPDATE `lesson` set `lastupdate`=now(),`deleted`=1 WHERE `lesson_id` in (select lesson_id from event_lesson WHERE `event_id`='" $_GET['event_id'] . "')");
        
$dbh->query("UPDATE `lesson_attendance` set `lastupdate`=now(),`deleted`=1 WHERE `lesson_id` in (select lesson_id from event_lesson WHERE `event_id`='" $_GET['event_id'] . "')");
        
header("Location: Event_List.php");
    }
    
?>
    <?php
    $code 
'';
    
$class_size '';
    
$programme '';
    
$subject_id '';
    
$school_type '';
    
$primary_ind '';
    
$primary_gp '';
    
$secondary_ind '';
    
$secondary_gp '';
    
$Primary_Package_Fee '';
    
$Primary_Package_discount '';
    
$Secondary_Package_Fee '';
    
$Secondary_Package_discount '';
    
$Programme_fee_type 0;
    
$view 0;
    
?>
    <?php
    
if (isset($_GET['view']))
        
$view $_GET['view'];

    if (isset(
$_POST['Event_Save'])) {
        
$code $_POST['code'];
        
$class_size $_POST['class_size'];
        
$programme $_POST['programme'];
        
$subject_id $_POST['subject_id'];
        if (
$_POST['programme_fee'] == 0) {
            
$primary_ind 0;
            
$primary_gp 0;
            
$secondary_ind 0;
            
$secondary_gp 0;
            
$Primary_Package_Fee 0;
            
$Primary_Package_discount 0;
            
$Secondary_Package_Fee 0;
            
$Secondary_Package_discount 0;
        }
        if (
$_POST['programme_fee'] == 1) {
            
$primary_ind $_POST['primary_ind'];
            
$primary_gp $_POST['primary_gp'];
            
$secondary_ind $_POST['secondary_ind'];
            
$secondary_gp $_POST['secondary_gp'];
            
$Primary_Package_Fee 0;
            
$Primary_Package_discount 0;
            
$Secondary_Package_Fee 0;
            
$Secondary_Package_discount 0;
        }
        if (
$_POST['programme_fee'] == 2) {
            
$primary_ind 0;
            
$primary_gp 0;
            
$secondary_ind 0;
            
$secondary_gp 0;
            
$Primary_Package_Fee $_POST['Primary_Package_Fee'];
            
$Primary_Package_discount $_POST['Primary_Package_Discount'];
            
$Secondary_Package_Fee $_POST['Secondary_Package_Fee'];
            
$Secondary_Package_discount $_POST['Secondary_Package_Discount'];
        }

        if (isset(
$_POST['Event_Save'])) {
            
$sth $dbh->query('UPDATE `event` SET `lastupdate`=now(),`deleted`=1 WHERE `event_id` = ' $_REQUEST['event_id'] . '');
            
$sth $dbh->prepare("INSERT INTO `event`(`createby`, `createdate`, `lastupby`, `lastupdate`, `actived`, `deleted`, 
                `event_code`, `program_id`, `subject_id`, `class_size`, `programme_fee_type`, 
                `primary_individual_price`, `primary_group_price`, `primary_package_price`, 
                `secondary_individual_price`, `secondary_group_price`, `secondary_package_price`, 
                `package_discount`, `sec_package_discount`, `is_free`)
                        Values(1,now(),1,now(),1,0,?,?,?,?,?,?,?,?,?,?,?,?,?,0)"
);
            
$location 'Location: Event_List.php';
        }
        
$sth->bindParam(1$code);
        
$sth->bindParam(2$programme);
        
$sth->bindParam(3$subject_id);
        
$sth->bindParam(4$class_size);
        
$sth->bindParam(5$_POST['programme_fee']);
        
$sth->bindParam(6$primary_ind);
        
$sth->bindParam(7$primary_gp);
        
$sth->bindParam(8$Primary_Package_Fee);
        
$sth->bindParam(9$secondary_ind);
        
$sth->bindParam(10$secondary_gp);
        
$sth->bindParam(11$Secondary_Package_Fee);
        
$sth->bindParam(12$Primary_Package_Fee);
        
$sth->bindParam(13$Secondary_Package_discount);
        
$sth->execute();


        
$tmp_lesson_id = array();
        
$sth $dbh->query("SELECT `lesson_id` FROM `event_lesson` WHERE `event_id`=" $_GET['event_id'] . " and deleted=0 and actived=1");
        while (
$ResultSet $sth->fetch(PDO::FETCH_ASSOC)) {
            
array_push($tmp_lesson_id$ResultSet['lesson_id']);
        }
        
$sth $dbh->query("UPDATE `event_lesson` SET `lastupdate`=now(),`deleted`=1 WHERE `event_id`=" $_GET['event_id'] . "");
        
$sth $dbh->query("select max(event_id) id from event");
        
$event_id $sth->fetch(PDO::FETCH_ASSOC);
        foreach (
$tmp_lesson_id as $tmp) {
            
$sth2 $dbh->query("INSERT INTO `event_lesson`(`event_id`, `createby`, `createdate`, `lastupby`, `lastupdate`, `actived`, `deleted`, `lesson_id`) VALUES (" $event_id['id'] . ",0,now(),0,now(),1,0," $tmp ")");
        }
        
//header($location);
        
echo '<script>location.href = "Event_List.php";</script>';
    }
    if (isset(
$_REQUEST['event_id'])) {
        
$sth $dbh->prepare('SELECT * FROM `event` WHERE `event_id`=?');
        
$sth->bindParam(1$_REQUEST['event_id']);
        
$sth->execute();
        while (
$ResultSet $sth->fetch(PDO::FETCH_ASSOC)) {
            
$code $ResultSet['event_code'];
            
$class_size $ResultSet['class_size'];
            
$programme $ResultSet['program_id'];
            
$subject_id $ResultSet['subject_id'];
            
$primary_ind $ResultSet['primary_individual_price'];
            
$primary_gp $ResultSet['primary_group_price'];
            
$secondary_ind $ResultSet['secondary_individual_price'];
            
$secondary_gp $ResultSet['secondary_group_price'];
            
$Primary_Package_Fee $ResultSet['primary_package_price'];
            
$Primary_Package_discount $ResultSet['package_discount'];
            
$Secondary_Package_Fee $ResultSet['secondary_package_price'];
            
$Secondary_Package_discount $ResultSet['sec_package_discount'];
            
$Programme_fee_type $ResultSet['programme_fee_type'];
        }
    }
    
?>
    <body>
        <!-- line between nav bar and content -->
        <div class="text-right">
            <ul class="breadcrumb">
                <li><a href="Event_List.php">Event</a> <span class="divider">&gt;</span></li>
                <?php if (isset($_GET['event_id'])) { ?>
                    <li class="active">Edit Event</li>
                <?php } else { ?>
                    <li class="active">Add Event</li>
                <?php ?>
            </ul>
        </div>
        <div class="container-fluid pathways-container">
            <?php if (isset($_REQUEST['event_id'])) { ?><h3>Edit Event</h3> <?php } else { ?><h3>Add Event</h3><?php ?>
            <form method="post" action="<?php if (isset($_REQUEST['event_id'])) echo '';else echo 'Event_DetailFrom.php'?>" id="commentForm" autocomplete="off">
                <table>

                    <tr>
                        <!-- Code  -->
                        <?php if (isset($_GET['event_id']) || isset($_GET['view'])) { ?>
                            <td style="width: 200px;text-align: right;"><label for="code_id">Code</label></td>
                            <td style="width: 30px"></td>
                            <td><input readonly   id="code_id"  autocomplete="off" type="text" maxlength="150" placeholder="Code" value="<?= $code ?>" name="code" class="required" /></td>
                        <?php ?>
                        <!-- Class Size -->
                        <td style="width: 200px;text-align: right;"><label for="class_size">Class Size</label></td>
                        <td style="width: 30px"></td>
                        <td><input <?php if ($view == 1) echo"readonly"?> id="class_size"  class="required" type="text" maxlength="150" placeholder="Class Size" value="<?= $class_size ?>" name="class_size" 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) )"/></td>
                    
                        <td style="width: 200px;text-align: right;"><label for="group">Group/Ind</label></td>
                        <td style="width: 30px;"</td>
                        <td>
                            <select name="group" class="required">
                                <option></option>
                                <option value="1">Group</option>
                                <option value="2">Individual</option>
                            </select>
                        </td>
                    </tr>

                    <tr style="height: 15px"></tr>

                    <tr>
                        <!--  programme  -->
                        <td style="width: 200px;text-align: right;"><label for="Programme_id">Programme</label></td>
                        <td style="width: 30px"></td>                            
                        <td>
                            <?php echo '<script>$(function(){ document.getElementById(\'programme_id\').value = ' $programme '}); </script>'?>
                            <?php $sth $dbh->query('SELECT * FROM `program` WHERE `deleted` = 0 order by `sort`'); ?>
                            <select id="programme_id"  name="programme" class="required" <?php if ($view == 1) echo"readonly"?>>
                                <?php echo '<option value=""></option>'?>
                                <?php while ($ResultSet $sth->fetch(PDO::FETCH_ASSOC)) { ?>
                                    <option value="<?= $ResultSet['program_id'?>"><?= $ResultSet['program_code'?></option>
                                <?php ?>
                            </select>
                        </td>

                        <!-- Subject  -->
                        <td style="width: 200px;text-align: right;"><label for="subject_id">Subject</label></td>
                        <td style="width: 30px"></td>
                        <td>
                            <?php echo '<script>$(function(){ document.getElementById(\'subject_id\').value = ' $subject_id '}); </script>'?>
                            <?php $sth $dbh->query('SELECT * FROM `subject` WHERE `deleted` = 0 order by `sort`'); ?> 
                            <select id="subject_id"  name="subject_id" class="required" <?php if ($view == 1) echo"readonly"?> >
                                <?php echo '<option value=""></option>'?>
                                <?php while ($ResultSet $sth->fetch(PDO::FETCH_ASSOC)) { ?>
                                    <option value="<?= $ResultSet['subject_id'?>"><?= $ResultSet['sub_code'?></option>
                                <?php ?>
                            </select>
                        </td>
                    </tr>
                    <!-----------------------------
                    <tr style="height: 15px;"></tr>
                    <tr>
                        <td></td>
                        <td></td>
                        <td><button type="button" class="btn" id="generate_event_code">Generate</button></td>
                    </tr>
                    <!----------------------------->
                    <tr style="height: 15px;display: none;"></tr>                    

                    <tr style="display: none;">

                        <?php
                        
if ($school_type == 1)
                            echo 
'<script>$(function(){ document.getElementById(\'Inschool\').checked = true;}); </script>';
                        if (
$school_type == 2)
                            echo 
'<script>$(function(){ document.getElementById(\'OutsideSchool\').checked = true;}); </script>';
                        
?>

                        <!--  Type of school  -->
                        <td style="width: 200px;text-align: right;"><label for="Type_id">Type</label></td>
                        <td style="width: 30px"></td>    
                        <td><label class="radio inline">In-school<input type="radio" value="1" name="school_type" id="Inschool" class="required"/></label></td>
                        <td><label class="radio inline">Outside school<input type="radio" value="2" name="school_type" id="OutsideSchool" class="required"/></label></td>

                    </tr>

                </table>

                <hr/>            

                <table>
                    <tr>
                        <!--  Programme Fee  -->
                        <td style="width: 200px;text-align: right;" class="required"><label>Programme Fee</label></td>
                        <td style="width: 30px"></td>
                        <td>
                            <?php echo '<script>$(function(){ document.getElementById(\'programme_fee\').value = ' $Programme_fee_type '}); </script>'?>
                            <select id="programme_fee" name="programme_fee" class="required" <?php if ($view == 1) echo"readonly"?> >
                                <option value=""></option>
                                <option value="0">Volunteer</option>
                                <option value="1">Hourly</option>
                                <option value="2">Package</option>
                            </select>
                        </td>
                    </tr>

                    <tr style="height: 15px"></tr>
                    <!--  Programme Fee Type  -->
                    <tbody id="programme_fee_tr">
                        <?php if ($Programme_fee_type == 1) { ?>
                            <tr>
                                <!-- Prinary Ind$ -->
                                <td style="width: 200px;text-align: right;"><label>Primary Ind $</label></td>
                                <td style="width: 30px"></td>
                                <td><input <?php if ($view == 1) echo"readonly"?>  class="required" id="primary_ind"  type="text" maxlength="150" placeholder="Primary Ind $" value="<?= $primary_ind ?>" name="primary_ind" 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) )"/></td>
                                <td style="width: 20px"></td>
                                <!--  Primary Gp$  -->
                                <td style="text-align: right;"><label>Gp $</label></td>
                                <td style="width: 30px"></td>
                                <td><input  <?php if ($view == 1) echo"readonly"?> class="required" id="primary_gp"  type="text" maxlength="150" placeholder="Primary Gp $" value="<?= $primary_gp ?>" name="primary_gp" 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) )"/></td>
                            </tr>

                            <tr style="height: 15px"></tr>

                            <tr>
                                <!-- Secondary Ind$ -->
                                <td style="width: 200px;text-align: right;"><label>Secondary Ind $</label></td>
                                <td style="width: 30px"></td>
                                <td><input <?php if ($view == 1) echo"readonly"?>  class="required" id="secondary_ind"  type="text" maxlength="150" placeholder="Secondary Ind $" value="<?= $secondary_ind ?>" name="secondary_ind" 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) )"/></td>
                                <td style="width: 20px"></td>
                                <!--  Secondary Gp$  -->
                                <td style="text-align: right;"><label>Gp $</label></td>
                                <td style="width: 30px"></td>
                                <td><input <?php if ($view == 1) echo"readonly"?>  class="required" id="secondary_gp"  type="text" maxlength="150" placeholder="Secondary Gp $" value="<?= $secondary_gp ?>" name="secondary_gp" 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) )"/></td>
                            </tr>

                            <tr style="height: 15px"></tr>

                        <?php } if ($Programme_fee_type == 2) { ?>
                            <!--  Package Fee  -->
                            <tr>
                                <td style="width: 200px;text-align: right;"><label>Primary Package Fee</label></td>
                                <td style="width: 30px"></td>
                                <td><input class="required" id="Primary_Package_Fee"  type="text" maxlength="150" placeholder="Primary Package Fee $" value="<?= $Primary_Package_Fee ?>" name="Primary_Package_Fee" 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) )"/></td>
                                <td style="width: 20px"></td>
                                <td><label>Primary Package Discount</label></td>
                                <td style="width: 30px"></td>
                                <td><input class="required" id="Primary_Package_Discount"  type="text" maxlength="150" placeholder="Primary Package Discount" value="<?= $Primary_Package_discount ?>" name="Primary_Package_Discount"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) )"/></td>
                            </tr>
                            <tr style="height: 15px"></tr>
                            <tr>
                                <td style="width: 200px;text-align: right;"><label>Secondary Package Fee</label></td>
                                <td style="width: 30px"></td>
                                <td><input class="required" id="Secondary_Package_Fee"  type="text" maxlength="150" placeholder="Secondary Package Fee $" value="<?= $Secondary_Package_Fee ?>" name="Secondary_Package_Fee" 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) )"/></td>
                                <td style="width: 20px"></td>
                                <td><label>Secondary Package Discount</label></td>
                                <td style="width: 30px"></td>
                                <td><input class="required" id="Secondary_Package_Discount"  type="text" maxlength="150" placeholder="Secondary Package Discount" value="<?= $Secondary_Package_discount ?>" name="Secondary_Package_Discount"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) )"/></td>
                            </tr>
                        <?php ?>
                    </tbody>                    
                </table>

                <hr/>
                <!-- ↑ display on add and edit page -->
                <!-- ↓ display on add page          -->
                <?php if (!isset($_REQUEST['event_id'])) { ?>
                    <h4>Time</h4>
                    <table>
                        <tr>
                            <!--  Start date  -->
                            <td style="width: 200px;text-align: right;"><label>Start Date</label></td>
                            <td style="width: 30px"></td>
                            <td>                            
                                <div class="input-append date-picker" id="start_date_id">                
                                    <input id="Start_date" class="dateISO required" type="text" maxlength="200" placeholder="Start Date" data-format="yyyy-MM-dd" value=" " name="start_date" autocomplete="off">              
                                    <span class="add-on">
                                        <i class="icon-calendar" data-date-icon="icon-calendar" data-time-icon="icon-time"></i>
                                    </span>
                                </div>

                            </td>
                            <td style="width: 20px"></td>
                            <!--  End Date  -->
                            <td style="text-align: right;"><label>End Date</label></td>
                            <td style="width: 30px"></td>
                            <td>
                                <div class="input-append date-picker" id="End_date_id">                
                                    <input id="End_date" class="dateISO required" type="text" maxlength="200" placeholder="End Date" data-format="yyyy-MM-dd" value=" " name="End_date" autocomplete="off">              
                                    <span class="add-on">
                                        <i class="icon-calendar" data-date-icon="icon-calendar" data-time-icon="icon-time"></i>
                                    </span>
                                </div>

                            </td>                        
                        </tr>
                    </table>

                    <div style="height: 15px;"></div>

                    <table>
                        <tr>
                            <!--  Rate  -->
                            <td style = "width: 200px;text-align: right;"><label>Rate</label></td>
                            <td style = "width: 30px"></td>
                            <td>
                                <select name="Rate_select" class="required">
                                    <option value=""></option>
                                    <option value="1">1 week</option>
                                    <option value="2">2 week</option>
                                    <option value="3">3 week</option>
                                    <option value="4">Month</option>
                                </select>
                            </td>
                        </tr>
                    </table>

                    <div style="height: 15px;"></div>
                    <table>
                        <!--  Select Date & Time & RoomID  -->
                        <?php
                        $sth 
$dbh->query('SELECT `room_ID`, `actived`, `deleted` FROM `venue` WHERE `actived`=1 and `deleted`=0 order by 1');
                        
$option '<option value=""></option>';
                        while (
$ResultSet $sth->fetch(PDO::FETCH_ASSOC)) {
                            
$option .= "<option value=" $ResultSet['room_id'] . ">" $ResultSet['room_id'] . "</option>";
                        }
                        
$date = array("Monday""Tuesday""Wednesday""Thursday""Friday""Saturday""Sunday");
                        for (
$i 1$i <= 7$i++) {
                            
$i2 $i 1;
                            
?>                            
                            <tr>
                                <td style = "width: 200px;text-align: right;">
                                    <!-- Date select with checkbox  -->
                                    <label><?= $date[$i2?><input style="margin-left: 8px;margin-bottom: 5px;" class="checkbox_select required" type = "checkbox" id = "<?= $i ?>check_date" name = "check_date[]" value="<?= $i2 ?>" /></label>
                                </td>

                                <td style = "width: 30px"></td>
                                <!-- Start Time  -->
                                <td><label>Start Time</label></td>
                                <td style = "width: 30px"></td>
                                <td><input style="width: 80px;" type="text" class="timepicker_start" id="start_time_<?= $i ?>" name="start_time[]" onchange="limit_time(this);" /></td>

                                <td style = "width: 70px;text-align: center;color: #AAAAAA;padding-bottom: 10px;">(24 Hour)</td>
                                <!--  End Time  -->
                                <td><label>End Time</label></td>
                                <td style = "width: 30px"></td>
                                <td><input style="width: 80px;" type="text" class="timepicker_end" id="end_time_<?= $i ?>" name="end_time[]" onchange="limit_time(this);" /></td>


                                <td style = "width: 70px;text-align: center;color: #AAAAAA;padding-bottom: 10px;">(24 Hour)</td>

                                <td><!--  Room ID  -->
                                    <select name="Room_id[]" autocomplete="off"><?= $option ?></select>
                                </td>
                            </tr>
                        <?php ?>      
                    </table>

                    <hr/>
                    <!--  Submit button that is display in add page  -->
                    <input type="submit" id="Event_Next" name="Event_Next" class="btn btn-danger" value="Next"/>
                    <?php
                    
//--  Submit button that is display edit page  --//
                
} if (isset($_REQUEST['event_id']) && !isset($_GET['view']))
                    echo 
'<input type="submit" id="Event_Save" name="Event_Save" class="btn btn-danger" value="Save"/>' ' ';
                echo 
'<input type="button" value="Back" class="btn btn-danger" onclick="history.back()"/>';
                
?>
                <?php if (isset($_REQUEST['event_id']) && !isset($_GET['view'])) { ?>
                    <input class="btn btn-danger" type="submit" name="Delete" value="Delete"/>
                <?php ?>
            </form>
        </div>
    </div> <!-- /container -->
</body>
</html>