/var/www/hkosl.com/innoutstorage/webadmin/invoice_index.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
<?php
require_once("check_login.php");

$_SESSION["index_url_parameter"] = get_index_url_parameter();

if (!isset(
$_GET["filter1"]) && !isset($_GET["filter2"]) && !isset($_GET["all"])) {
    
$invoice_info = array();

    
$filter_sql " and createdate BETWEEN DATE_SUB(CURRENT_DATE(), INTERVAL 2 WEEK) AND DATE_SUB(CURRENT_DATE(), INTERVAL -1 DAY) ";
    
$parameters NULL;
} else {
    
$filter_sql "";

    if (isset(
$_GET["all"]) && (int)$_GET["all"] == 1) {
        
$filter_sql "";
        
$parameters NULL;

    } else {
        if (isset(
$_GET["filter1"]) && isset($_GET["filter2"])) {
            if (
$_GET["filter1"] == 0) {  //order_id
                
$filter_sql "and invoice.order_id = ?";
            }

            if (
$_GET["filter1"] == 1) {  //customer_id
                
$filter_sql "and invoice.customer_id = ?";
            }

            if (
$_GET["filter1"] == 2) {  //deposit status
                
$filter_sql "and invoice.status = ?";
            }
            
$parameters = array($_GET["filter2"]);
        }
    }
}

$sql "select *,
                                    invoice.id as invoice_id,
                                    invoice.status as invoice_status,
                                    invoice.code as invoice_code,
                                    invoice.docdate as invoice_docdate,
                                    invoice.duedate as invoice_duedate,
                                    invoice.lastupdate as invoice_lastupdate,
                                    invoice.lastupby as invoice_lastupby
                                from `invoice` invoice
                                where invoice.deleted = 0 " 
$filter_sql " order by invoice.id DESC";

$invoice_info bind_pdo($sql$parameters"selectall");

foreach (
$invoice_info as $key => $invoice) {
    
$customer_id $invoice["customer_id"];
    
$invoice_info[$key]["customer_id"] = $invoice["customer_id"];

    
$customer_info get_customer($customer_id);
    
$invoice_info[$key]["customer_code"] = $customer_info["code"];
    
$invoice_info[$key]["customer_name"] = $customer_info["customer_name"];

    if (!empty(
$invoice["order_id"])) {
        
$order_info get_order($invoice["order_id"]);

        
$invoice_info[$key]["order_code"] = $order_info["code"];
        
$invoice_info[$key]["customer_name"] = $order_info["customer_name"];
    }

    
$invoice_status get_master_type_code("INVOICE_STATUS"$invoice["invoice_status"]);
    if (!empty(
$invoice_status["name_tc"])) {
        
$invoice_info[$key]["invoice_status"] = $invoice_status["name_tc"];
    } else {
        
$invoice_info[$key]["invoice_status"] = "";
    }
}

$filter_order "";
$filter_customer "";
$filter_status "";

//$all_customer_info = get_customer();
$all_customer_info get_customer2();
//$all_order_info = get_order(NULL, 0);
$all_order_info get_order2();
$status_info get_master_type_code("INVOICE_STATUS");

foreach (
$all_customer_info as $key => $customer) {
    
$filter_customer[$key][0] = $customer["id"];
    
$filter_customer[$key][1] = $customer['customer_name'] . " (" $customer["code"] . ")";
}

foreach (
$all_order_info as $key => $order) {
    
$filter_order[$key][0] = $order["id"];
    
$filter_order[$key][1] = $order["code"];
}

foreach (
$status_info as $key => $status) {
    
$filter_status[$key][0] = $status["code"];
    
$filter_status[$key][1] = $status["name_tc"];
}

$filter1_info = array("合約""客戶""狀態");
$filter2_info = array(=> $filter_order=> $filter_customer=> $filter_status);

?>
<!DOCTYPE html>
<html>
<head>
    <?php require_once("html_head.php"); ?>

    <script type="text/javascript" src="js/chosen_v1.4.1/chosen.jquery.min.js"></script>
    <link rel="stylesheet" href="js/chosen_v1.4.1/chosen.min.css">

    <script type="text/javascript">

        $(function () {

            $("#filter1").chosen({width: "100px", search_contains: true});
            $("#filter2_0").chosen({width: "250px", search_contains: true});
            $("#filter2_1").chosen({width: "250px", search_contains: true});
            $("#filter2_2").chosen({width: "250px", search_contains: true});

            $("#filter2_0_chosen").css("display", "none");
            $("#filter2_1_chosen").css("display", "none");
            $("#filter2_2_chosen").css("display", "none");

            <?php
            
if (isset($_GET["filter1"])) {
                echo 
'$("#filter2_"+' $_GET["filter1"] . '+"_chosen").css("display", "inline-block");';
            }
            
?>

            $("#filter1").change(function () {
                var filter_1_key = $(this).val();
                $(".filter2").css("display", "none");
                $("#filter2_0_chosen").css("display", "none");
                $("#filter2_1_chosen").css("display", "none");
                $("#filter2_2_chosen").css("display", "none");

                $("#filter2_" + filter_1_key + "_chosen").css("display", "inline-block");


            });
        });

        function filter() {
            var filter1 = $("select[name='filter1']").val();
            var filter2 = $("#filter2_" + filter1).val();

            if (filter1 != "" && filter2 != "") {
                top.location.href = 'invoice_index.php?filter1=' + filter1 + '&filter2=' + filter2;
            } else {
                alert("請選擇篩選方式。");
            }
        }
    </script>
</head>

<body>
<table width="1200" height="600" border="0" cellpadding="0" cellspacing="0">
    <tr>
        <td width="200" align="left" valign="top">
            <table width="200" border="0" cellpadding="0" cellspacing="0">
                <tr>
                    <td height="70" align="left" valign="middle">&nbsp;</td>
                </tr>
                <tr>
                    <td width="200" align="left" valign="top"><!-- Main Menu -->
                        <?php require("menu.php"); ?><!-- End Main Menu --></td>
                </tr>
            </table>
        </td>
        <td width="1000" align="left" valign="top">
            <table width="1000" border="0" cellpadding="0" cellspacing="0">
                <tr>
                    <td>
                        <table width="1000" border="0" cellspacing="0" cellpadding="0">
                            <tr>
                                <td height="70" class="pagetitletxt">&nbsp;&nbsp;</td>
                                <td width="50" align="center" class="icontxt">
                                    <a href="invoice_addform.php"><img src="images/iconNew.png" alt="Add" width="32" height="32" border="0"/><br/>&nbsp;新增&nbsp;&nbsp;
                                    </a>
                                </td>
                            </tr>
                        </table>
                    </td>
                </tr>
                <tr>
                    <td class="pagetitletxt">
                        &nbsp;&nbsp;<b><img src="images/iconList.jpg" width="48" height="48" align="absmiddle"/> 租金及其他發票
                        </b></td>
                </tr>
                <tr>
                    <td height="25" align="left" valign="middle" class="msg"><?php if (isset($_GET["msg"])) echo $_GET['msg']; ?></td>
                </tr>

                <tr>
                    <td align="left" valign="middle">
                        <div>篩選: <select name="filter1" id="filter1">
                                <option value="">---請選擇---</option>
                                <?php
                                
foreach ($filter1_info as $key => $filter1) {
                                    if (isset(
$_GET["filter1"]))
                                        
$selected matched_option($key$_GET["filter1"], "select");

                                    echo 
'<option value="' $key '" ' $selected '>' $filter1 '</option>';
                                }
                                
?>
                            </select>

                            <select name="filter2" id="filter2_0" class="filter2 ">
                                <option value="">---請選擇---</option>
                                <?php

                                
foreach ($filter2_info[0] as $data) {
                                    if (isset(
$_GET["filter2"]))
                                        
$selected matched_option($data[0], $_GET["filter2"], "select");

                                    echo 
'<option value="' $data[0] . '" ' $selected ' class="' $key '">' $data[1] . '</option>';
                                }

                                
?>
                            </select>

                            <select name="filter2" id="filter2_1" class="filter2 ">
                                <option value="">---請選擇---</option>
                                <?php
                                
foreach ($filter2_info[1] as $data) {
                                    if (isset(
$_GET["filter2"]))
                                        
$selected matched_option($data[0], $_GET["filter2"], "select");

                                    echo 
'<option value="' $data[0] . '" ' $selected ' class="' $key '">' $data[1] . '</option>';
                                }


                                
?>
                            </select>

                            <select name="filter2" id="filter2_2" class="filter2 ">
                                <option value="">---請選擇---</option>
                                <?php

                                
foreach ($filter2_info[2] as $data) {
                                    if (isset(
$_GET["filter2"]))
                                        
$selected matched_option($data[0], $_GET["filter2"], "select");

                                    echo 
'<option value="' $data[0] . '" ' $selected ' class="' $key '">' $data[1] . '</option>';
                                }

                                
?>
                            </select>

                            <button type="button" onclick="filter();">送出</button>

                            <button type="button" onclick="window.location.href='invoice_index.php?all=1';" style="margin-left: 15px;">
                                全部發票
                            </button>
                        </div>

                        <br>

                        <form action="invoice_invoice_update.php" method="post" name="invoice_invoice_update" id="invoice_invoice_update" enctype="multipart/form-data">
                            <table width="1000" border="0" cellpadding="0" cellspacing="0">

                                <tr>
                                    <td width="10" class="listtitletxt"></td>
                                    <td width="130" class="listtitletxt">發票編號</td>
                                    <td width="130" class="listtitletxt">合約編號</td>
                                    <td width="130" class="listtitletxt">客戶編號</td>
                                    <td width="150" class="listtitletxt">客戶姓名</td>
                                    <td width="80" class="listtitletxt">發票日期</td>
                                    <td width="80" class="listtitletxt">發票到期</td>
                                    <td width="100" class="listtitletxt">金額</td>
                                    <td width="50" class="listtitletxt">狀態</td>
                                    <td width="20" class="listtitletxt"></td>
                                </tr>

                                <?php
                                
foreach ($invoice_info as $invoice) {
                                    print 
"<tr>";
                                    print 
"<td class='listtxt' style='padding-left:5'>&nbsp;</td>";
                                    print 
"<td class='listtxt' style='padding-left:5'>" $invoice{'invoice_code'} . "</td>";

                                    if (!empty(
$invoice{'order_id'})) {
                                        
//$order_info = get_order($invoice["order_id"]);
                                        
print "<td class='listtxt' style='padding-left:5'><a href='order_modifyform.php?order_id=" $invoice["order_id"] . "' target='_blank'> " $invoice{'order_code'} . "</a></td>";
                                    } else {
                                        print 
"<td class='listtxt' style='padding-left:5'>-</td>";
                                    }

                                    print 
"<td class='listtxt' style='padding-left:5'><a href='customer_modifyform.php?id=" $invoice["customer_id"] . "' target='_blank'> " $invoice{'customer_code'} . "</a></td>";

                                    print 
"<td class='listtxt' style='padding-left:5'><a href='customer_modifyform.php?id=" $invoice["customer_id"] . "' target='_blank'>" $invoice{'customer_name'} . "</a></td>";

                                    print 
"<td class='listtxt' style='padding-left:5'>" $invoice{'invoice_docdate'} . "</td>";
                                    print 
"<td class='listtxt' style='padding-left:5'>" $invoice{'invoice_duedate'} . "</td>";

                                    print 
"<td class='listtxt' style='padding-left:5'>$" numberformat($invoice{'amount'}) . "</td>";

                                    print 
"<td class='listtxt' style='padding-left:5'>" $invoice["invoice_status"] . "</td>";
                                    
// Modify
                                    
print "<td class='listtxt' align='center'><a href='#' onClick=\"window.location='invoice_modifyform.php?id=" $invoice{'invoice_id'} . "'\"><img src='images/btnModify.png' title='Modify' alt='Modify' hspace='2' border='0'></a></td>";

                                    print 
"</tr>";

                                }
                                
?>

                            </table>

                            <br> <br> <br> <br>
                        </form>
                    </td>
                </tr>
            </table>
        </td>
    </tr>
</table>
</body>
</html>