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
|
<?php require_once('check_login.php');
$date_alert = 21;
$sql = "select id, rent_month, warehousing_date, customer_id, code, total_discounted_price from `order` where status = ? and deleted = ?"; $parameters = array("NEW", 0); $order_info = bind_pdo($sql, $parameters, "selectall");
$non_created_rent_invoice = array(); foreach($order_info as $order){ for($i = 1; $i <= $order["rent_month"]; $i++){ $sql = "select inv.id from invoice inv INNER JOIN invoice_dtl inv_dtl where inv_dtl.invoice_id = inv.id and inv.order_id = ? and inv_dtl.type = ? and inv_dtl.month = ? and inv_dtl.deleted = ? and inv.deleted = ?"; $parameters = array($order["id"], "RENT", $i, 0, 0); $result = bind_pdo($sql, $parameters, "selectone");
if(empty($result)){ //non-created rent invoice, alert admin to create this invoice $date = new DateTime($order["warehousing_date"]); $date->modify('+'.($i-1).' month');
$non_created_rent_invoice_duedate = $date->format("Y-m-d");
/*var_dump($non_created_rent_invoice_duedate); var_dump(date('Y-m-d', strtotime($nowdate ." +".$date_alert." days")));*/
$date2 = new DateTime(); $date2->modify('+'.$date_alert.' day');
if($date2->format("Y-m-d") >= $non_created_rent_invoice_duedate){ $customer_info = get_customer($order["customer_id"]); $customer_name = get_customer_name(rsa_crypt($customer_info["firstname"], 2), rsa_crypt($customer_info["lastname"], 2));
//$non_created_rent_invoice[] = array("order_id" => $order["id"], "month" => $i); $non_created_rent_invoice[] = array( "order_id" => $order["id"], //"rent_month" => $i-1, //start from 0 "rent_month" => $i, //start from 1 "order_code" => $order["code"], "customer_id" => $customer_info["id"], "customer_code" => $customer_info["code"], "customer_name" => $customer_name, "invoice_duedate" => $non_created_rent_invoice_duedate, "amount" => $order["total_discounted_price"], "status" => "未建立" ); } } } }
//var_dump($non_created_rent_invoice); ?> <!DOCTYPE html> <html> <head> <?php require_once("html_head.php"); ?>
</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"> </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"> </td> <td width="50" align="center" class="icontxt">
</td> </tr> </table> </td> </tr> <tr> <td class="pagetitletxt"> <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"> <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="150" class="listtitletxt">客戶姓名</td> <td width="80" class="listtitletxt">發票到期</td> <td width="100" class="listtitletxt">金額</td> <td width="50" class="listtitletxt">狀態</td> <td width="50" class="listtitletxt"></td> </tr>
<?php foreach ($non_created_rent_invoice as $invoice) { print '<tr> <form action="invoice_add.php" method="post" name="modifyform" enctype="multipart/form-data" class="form_field">';
print "<input type='hidden' name='invoice_type' value='RENT'><input type='hidden' name='rent_month[".$invoice["rent_month"]."]' value='".$invoice["rent_month"]."'><input type='hidden' name='rent_amount[".$invoice["rent_month"]."]' value='".$invoice["amount"]."'><input type='hidden' name='rent_duedate[".$invoice["rent_month"]."]' value='".$invoice["invoice_duedate"]."'><input type='hidden' name='rent_remark[".$invoice["rent_month"]."]' value=''><input type='hidden' name='order_id' value='".$invoice["order_id"]."'>";
print "<td class='listtxt' style='padding-left:5'> </td>";
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>";
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_duedate'} . "</td>";
print "<td class='listtxt' style='padding-left:5'>$" . numberformat($invoice{'amount'}) . "</td>";
print "<td class='listtxt' style='padding-left:5'>" . $invoice["status"] . "</td>";
print "<td class='listtxt' style='padding-left:5'><button type='submit' >立即建立</button></td>";
print "</form></tr>";
} ?>
</table>
<br> <br> <br> <br>
</td> </tr> </table> </td> </tr> </table> </body> </html>
|