/var/www/(Del)pathways.org.hk/MIS20140127/old20140407/Receipt/receipt_Edit.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
<!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 require_once '../include/Classes/PHPExcel.php' ?>
        <?php require_once '../include/Classes/PHPExcel/IOFactory.php' ?>
        <?php require_once '../include/Classes/PHPExcel/Writer/Excel2007.php' ?>
        <?php $edit_id $_GET['id']; ?>
        <script>
            $(function() {
                $('.date-picker').datetimepicker({pickTime: false});
            });
        </script>
    </head>
    <style>
        .table{
            background:#feffde;
        }
    </style>
    <body>
        <?php
        $today 
date('Y-m-d');
        
$paydate date('Y-m-d');
        if (isset(
$_POST['go'])) {
            
$name $_POST['name'];
            
$money $_POST['money'];
            
$payof $_POST['payof'];
            
$payway $_POST['payway'];
            
$paywaytxt $_POST['paywaytxt'];
            
$campus $_POST['campus'];
            
$type $_POST['type'];
            
$paydate $_POST['paydate'];
            
$dontinsert false;
            
$loadname;
            
$receiptNo '0001';
            if (
$dontinsert == false) {
                
$sth $dbh->prepare("INSERT INTO `receive`(`receive_code`, `createby`, `createdate`, `lastupby`, `lastupdate`, `actived`, `deleted`, `receive_date`, `invoice_id`, `receive_from`, `payment_of`, `total_amount`, `is_cash`, `pay_txt`, `is_normal`, `campus_id`) VALUES (?,1,now(),1,now(),1,0,?,0,?,?,?,?,?,?,?)");
                
$sth->bindParam(1$receiptNo);
                
$sth->bindParam(2$paydate);
                
$sth->bindParam(3$name);
                
$sth->bindParam(4$payof);
                
$sth->bindParam(5$money);
                
$sth->bindParam(6$payway);
                
$sth->bindParam(7$paywaytxt);
                
$sth->bindParam(8$type);
                
$sth->bindParam(9$campus);
                
$sth->execute();

                
$sth $dbh->prepare("UPDATE `receive` SET `lastupby`=1,`lastupdate`=now(),`deleted` = 1 WHERE receive_id = '$edit_id'");
                
$sth->execute();

                echo 
"<script>alert('Edit data successful.')</script>";
                echo(
"<script>location.href ='receipt_index.php';</script>");
            }
        }
        if (isset(
$_POST['delete'])) {
            
$sth $dbh->prepare("UPDATE `receive` SET `lastupby`=1,`lastupdate`=now(),`deleted` = 1 WHERE receive_id = '$edit_id'");
            
$sth->execute();

            echo 
"<script>alert('delete data successful.')</script>";
            echo(
"<script>location.href ='receipt_index.php';</script>");
        }
        
?>
        <!-- line between nav bar and content -->
        <div class="text-right">
            <ul class="breadcrumb">
                <li class="active">Receipt</li>
            </ul>
        </div>
        <!-- line between nav bar and content -->
        <div class="container-fluid pathways-container">
            <form id="search_form" class="form-inline" action="" method="POST">
                <table border="0" class="table table-bordered table-hover table-condensed">
                    <tr>
                        <td><h3>Edit Receipt</h3></td>
                    </tr>
                    <?php
                    $query 
"Select receive_code, receive_date, receive_from, payment_of, total_amount, is_cash, pay_txt, is_normal, campus_id from receive where deleted = 0 and receive_id = '$edit_id'";
                    
$result $dbh->query($query);
                    
$result->setFetchMode(PDO::FETCH_OBJ);
                    while (
$row $result->fetch()) {
                        
$receiptNo $row->receive_code;
                        
$paydate $row->receive_date;
                        
$name $row->receive_from;
                        
$money $row->total_amount;
                        
$payof $row->payment_of;
                        
$paywaytxt $row->pay_txt;
                        
$payway $row->is_cash;
                        
$type $row->is_normal;
                        
?>
                        <tr>
                            <td width="20%"><label>Type</label></td>
                            <td><label>Normal</label><input type="radio" name="type" value="0" <?php if ($type == 0) { ?>checked<?php ?>>     <label>Community Chest</label><input type="radio" name="type" value="1" <?php if ($type == 1) { ?>checked<?php ?>></td>
                        </tr>
                        <tr>
                            <td width="20%"><label>Date</label></td>
                            <td><div class="input-append date-picker">                
                                    <input id="start_date" class="dateISO" type="text" maxlength="200" data-format="yyyy-MM-dd" name="paydate" value="<?= $today ?>" style="width:90px" required>              
                                    <span class="add-on">
                                        <i class="icon-calendar" data-date-icon="icon-calendar" data-time-icon="icon-time"></i>
                                    </span>
                                </div></td>
                        </tr>
                        <tr>
                            <td width="20%"><label>Received from:</label></td>
                            <td><input type="text" value="<?= $name ?>" name="name"></td>
                        </tr>
                        <tr>
                            <td width="20%"><label >The sum of Hong Kong Dollars:</label></td>
                            <td><input type="text" value="<?= $money ?>"name="money"></td>
                        </tr>
                        <tr>
                            <td width="20%"><label>Payment of:</label></td>
                            <td><input type="text" value="<?= $payof ?>" name="payof"></td>
                        </tr>
                        <tr>
                            <td  width="20%"><label>By cash</label><input type="radio" name="payway" value="0" <?php if ($payway == 0) { ?>checked<?php ?>>     <label>By cheque</label><input type="radio" name="payway" value="1" <?php if ($payway == 1) { ?> checked <?php ?>></td>
                            <td><input type="text" name="paywaytxt" value="<?= $paywaytxt ?>"></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 (
$row $result->fetch()) {
                                        if (
$row->campus_id == $campus)
                                            print 
'<option selected value=' $row->campus_id '>' $row->campus_name '</option>';
                                        if (
$row->campus_id != $campus)
                                            print 
'<option value=' $row->campus_id '>' $row->campus_name '</option>';
                                    }
                                    
?>
                                </select>
                            </td>
                        </tr>
                    <?php ?>
                </table>
                <div class="pathways-inline-block">
                    <button class="btn" name="go" value="go"  type="submit">Save</button>
                </div>
                <div class="pathways-inline-block">
                    <a href="receipt_Export.php?id=<?= $edit_id ?>" class="btn">Export</a>
                </div>
                <div class="pathways-inline-block">
                    <button class="btn" name="delete" value="delete"  type="submit">Delete</button>
                </div>
                <div class="pathways-inline-block">
                    <a href="receipt_index.php" class="btn">Back</a>
                </div>
            </form>
        </div> <!-- /container -->
    </body>
</html>