/var/www/(Del)pathways.org.hk/MIS20140127/old20140414/System/editVenue.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

<!DOCTYPE html>
<html>
    <head>
        <?php require_once '../include/head.php'?>
        <?php require_once '../include/checkuser.php'?>
        <?php require_once '../include/Nav_bar.php'?>
        <?php include_once '../include/DBConnect.php'?>
        <?php $room_id $_GET['id']; ?>
        <script>
            $(function() {
                $("#shortf").keypress(function(event) {
                    var ew = event.which;
                    if (65 <= ew && ew <= 90)
                        return true;
                    return false;
                });
            });
        </script>
    </head>
    <body>
        <?php
        
if (isset($_POST['editvenue'])) {
            
$sort 0;
            
$newroom_id $_POST['room_id'];
            
$campus $_POST['campus'];
            
$check FALSE;
            
$query "Select room_id from venue where room_id <> '$room_id'";
            
$result $dbh->query($query);
            
$result->setFetchMode(PDO::FETCH_OBJ);
            while (
$row $result->fetch()) {
                if (
$newroom_id == $row->room_id)
                    
$check TRUE;
            }
            if (
$check) {
                echo 
"<script>alert('There have same room!')</script>";
            } else {

                
$sth $dbh->prepare("UPDATE `venue` SET `lastupby`= 1,`lastupdate`= now(),`room_id`=?,`campus_id`=? WHERE deleted = 0 and room_id = '$room_id'");
                
$sth->bindParam(1$newroom_id);
                
$sth->bindParam(2$campus);
                
$sth->execute();

                echo 
"<script>alert('edit data successful.')</script>";
                echo(
"<script>location.href = 'Venue.php';</script>");
            }
        }
        
?>
        <!-- line between nav bar and content -->
        <div class="text-right">
            <ul class="breadcrumb">
                <li class="active">Edit Venue</li>
            </ul>
        </div>

        <div class="container-fluid pathways-container">
            <div>
                <table border="0" width="100%">
                    <tr>
                        <td><h2>Edit Venue</h2></td>
                    </tr>
                </table>
            </div>
            <form action="" method="POST" enctype="multipart/form-data" id="form">
                <table border="0" class="table table-bordered table-hover table-condensed">
                    <?php
                    $searchdata 
"select room_id, campus_id from venue where deleted = 0 and room_id = '$room_id' group by room_id";
                    
$result $dbh->query($searchdata);
                    
$result->setFetchMode(PDO::FETCH_OBJ);
                    while (
$row $result->fetch()) {
                        
?>
                        <tr>
                            <td width="20%">
                                Room Name
                            </td>
                            <td>
                                <input type="text" width="200px" name="room_id" value="<?=$row->room_id?>" required>
                            </td>
                        </tr>
                        <tr>
                            <td width="20%">
                                Campus
                            </td>
                            <td>
                                <select name="campus" required="true">
                                    <?php
                                    $query 
"Select campus_id,campus_name from campus";
                                    
$result $dbh->query($query);
                                    
$result->setFetchMode(PDO::FETCH_OBJ);
                                    while (
$row2 $result->fetch()) {
                                        
?><option <?php if($row->campus_id == $row2->campus_id) {?> selected <?php ?> value="<?=$row2->campus_id?>"><?=$row2->campus_name?></option>
                                    <?php ?>
                            </select>
                        </td>
                    </tr>
                    <?php }?>
                </table>
                <div class="input-append date-picker">
                    <button class="btn" name="editvenue" value="editvenue" style="margin-left:30px" type="submit">Edit</button>
                </div>
            </form>
        </div> <!-- /container -->
    </body>
</html>