= ? and startdate <= ?";
$parameters[] = $_GET["startdate_min"];
$parameters[] = $_GET["startdate_max"];
}
if (!empty($_GET["createdate_min"]) && !empty($_GET["createdate_max"])) {
$filter_sql .= " and createdate >= ? and createdate <= ?";
$parameters[] = $_GET["createdate_min"];
$parameters[] = $_GET["createdate_max"];
}
if (!empty($_GET["code"])) {
$filter_sql .= " and id = ?";
$parameters[] = $_GET["code"];
}
if (!empty($_GET["customer_code"]) || !empty($_GET["customer_name"]) || !empty($_GET["customer_tel"])) {
$filter_sql .= " and customer_id IN (?)";
$ids = array($_GET["customer_code"], $_GET["customer_name"], $_GET["customer_tel"]);
$parameters[] = implode(",", array_filter($ids));
}
if (!empty($_GET["order_room"])) {
$room_ids = array();
$room_list = get_order_by_room_id($_GET["order_room"]);
foreach ($room_list as $rl) {
$room_ids[] = $rl['order_id'];
}
$filter_sql .= " and id IN (" . implode(",", $room_ids) . ")";
}
if (!empty($_GET["status"])) {
$filter_sql .= " and status = ?";
$parameters[] = $_GET["status"];
}
} else if (empty($_GET["all"])) { // no filter when all = 1
$filter_sql .= " and createdate >= DATE_SUB(CURRENT_DATE(), INTERVAL 2 WEEK) AND createdate <= '".date('Y-m-d 23:59:59')."'";
}
//pagination
// how many records should be displayed on a page?
$records_per_page = 20;
// instantiate the pagination object
$pagination = new Zebra_Pagination();
// records per page
$pagination->records_per_page($records_per_page);
try{
$sql = "select count(*) as count from `order` where deleted = 0 " . $filter_sql;
$order_info = bind_pdo($sql, $parameters, "selectone");
}catch(Exception $e){
header('Location: order_index.php?msg=租用單位不存在');
exit;
}
// the number of total records is the number of records in the array
$pagination->records($order_info['count']);
$sql = "select * from `order` where deleted = 0 " . $filter_sql . " order by id DESC";
$sql .= ' LIMIT ' . (($pagination->get_page() - 1) * $records_per_page) . ', ' . $records_per_page ;
$order_info = bind_pdo($sql, $parameters, "selectall");
foreach ($order_info as $key => $order) {
$order_id = $order["id"];
$order_info[$key]["order_code"] = $order["code"];
/*$customer_info = get_customer($order["customer_id"]);
$order_info[$key]["customer_code"] = $customer_info["code"];
$order_info[$key]["customer_name"] = $customer_info["customer_name"];*/
$customer_name = get_customer_name(rsa_crypt($order["customer_firstname"], 2), rsa_crypt($order["customer_lastname"], 2));
$order_info[$key]["customer_code"] = $order["customer_code"];
$order_info[$key]["customer_name"] = $customer_name;
$order_info[$key]["customer_tel"] = rsa_crypt($order_info[$key]["customer_tel"], 2);
}
$filter_order_code = "";
$filter_customer_code = "";
$filter_customer_name = "";
$filter_customer_tel = "";
$filter_status = "";
$filter_startfrom = "";
$filter_room = "";
$all_order_info = get_order2();
foreach ($all_order_info as $key => $order) {
$filter_order_code[$key][0] = $order["id"];
$filter_order_code[$key][1] = $order["code"];
}
$all_order_info = get_customer2();
foreach ($all_order_info as $key => $customer) {
$filter_customer_code[$key][0] = $customer["id"];
$filter_customer_code[$key][1] = $customer["code"];
$filter_customer_name[$key][0] = $customer["id"];
$filter_customer_name[$key][1] = $customer["customer_name"];
$filter_customer_tel[$key][0] = $customer["id"];
$filter_customer_tel[$key][1] = $customer["tel"];
}
$all_room_info = get_room();
foreach ($all_room_info as $key => $room) {
$filter_room[$key][0] = $room["id"];
$filter_room[$key][1] = $room["code"];
}
$status_info = get_master_type_code("ORDER_STATUS");
foreach ($status_info as $key => $status) {
$filter_status[$key][0] = $status["code"];
$filter_status[$key][1] = $status["name_tc"];
}
$filter2_info = array(0 => $filter_order_code, 1 => $filter_customer_code, 2 => $filter_customer_name, 3 => "user_input", 4 => $filter_status, 5 => "user_input", 6 => $filter_customer_tel, 7 => $filter_room);
?>
|
|
|
|
合約
|
|
|
合約編號 |
門卡號碼 |
客戶姓名 |
聯絡電話 |
租用單位 |
租用期(月) |
生效日期 |
結束日期 |
狀態 |
轉倉 |
退倉 |
詳情 |
";
print " | ";
print "" . $order['order_code'] . " | ";
print "" . $order['room_key'] . " | ";
/*$customer_type = get_master_type_code("CUSTOMER_TYPE", $order["customer_typeid"]);
if($order["customer_typeid"] == "BUSINESS"){
print "" . $customer_type["name_tc"] . " ".$order["customer_companyname"]." | ";
}else if($order["customer_typeid"] == "PERSONAL"){
print "" . $customer_type["name_tc"] . " | ";
}*/
print "" . $order['customer_name'] . " (" . $order['customer_code'] . ") | ";
print "" . $order['customer_tel'] . " | ";
$order_room_info = get_order_room($order["id"]);
$order_room_list = "";
$deposit_info = get_order_deposit($order["id"]);
foreach ($order_room_info as $detail) {
$room_info = get_room($detail["room_id"]);
$order_room_list .= check_combine_room($room_info["code"]) . ", ";
}
$order_room_list = substr_replace($order_room_list, "", -2);
print "" . $order_room_list . " | ";
print "" . $order['rent_month'] . " | ";
print "" . $order['startdate'] . " | ";
print "" . $order['enddate'] . " | ";
$order_status = get_master_type_code("ORDER_STATUS", $order["status"]);
print "" . $order_status["name_tc"] . " | ";
if ($order["status"] == "NEW") {
print " | ";
} else {
print "不適用 | ";
}
if ($order["status"] == "NEW") {
print " | ";
} elseif ($deposit_info["deposit_id"]) {
// print "不適用 | ";
// print "已退倉 | ";
print "
已退倉 | ";
} else {
print "
已退倉 | ";
}
// Modify
print " | ";
print "";
}
?>
render();
?>
|
|