/var/www/hkosl.com/innoutstorage/webadmin/bk20220830/floor_plan_room_info.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
317
318
319
320
321
322
323
324
325
326
<?php
    
require_once('check_login.php');

    
$room_info        get_room_by_code($_GET["room_code"]);
    
$master_room_info get_master_room($room_info["master_room_id"]);
    
$status_info      get_master_type_code("ROOM_STATUS"$room_info["status"]);
    
$master_room_price_info get_master_room_price($room_info["master_room_id"]);
?>


<!DOCTYPE html>
<html>
<head>
    <?php require_once('html_head.php'); ?>
    <style>
        body {
            font-family: arial, 'Microsoft JhengHei', sans-serif;
            text-align: center;
            background: none;
        }

        .title {
            text-align: center;
            font-size: 20px;
            font-weight: bold;
        }

        #room_detail {
            border-collapse: collapse;
            margin: 0 auto;
            margin-top: 20px;
            text-align: left;
        }

        #room_detail td {
            border: 1px solid #000000;
            padding: 8px;
        }

        .room_info_btn {
            font-size: 18px;
            font-family: arial, 'Microsoft JhengHei', sans-serif;
            padding: 5px 15px;
            font-weight: bold;
            background-color: #4CAF50; /* Green */
            border: none;
            color: white;
            text-align: center;
            text-decoration: none;
            display: inline-block;
        }
    </style>

    <script type="text/javascript">
        function ajax_floor_plan_rent_room(go_to_warehousing, room_id, master_room_id, room_code) {

            var xmlhttp;

            if (window.XMLHttpRequest) {// code for IE7+, Firefox, Chrome, Opera, Safari
                xmlhttp = new XMLHttpRequest();
            }
            else {// code for IE6, IE5
                xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
            }
            xmlhttp.onreadystatechange = function () {
                if (xmlhttp.readyState == 4 && xmlhttp.status == 200) {
                    var result = $.trim(xmlhttp.responseText);

                    console.log(result);

                    if(result == "success" && go_to_warehousing != 1){
                        //alert("你已將這個倉庫單位加入租用列表,你可前往租倉程序或加入更多的倉庫單位。");
                        $("#go_to_warehousing").show();

                        //console.log($("#go_to_warehousing .cancel_room").length);
                        if($("#go_to_warehousing .cancel_room").length > 1){
                            $(".rent_current_room").text(", "+room_code+" [刪除]");
                        }else{
                            $(".rent_current_room").text(room_code+" [刪除]");
                        }

                    }

                    if(go_to_warehousing == 1){
                        window.top.location.href='warehousing_step1.php';
                    }
                }
            }

            xmlhttp.open("POST", "_ajax.php?for=floor_plan_rent_room", true);
            xmlhttp.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
            xmlhttp.send("go_to_warehousing="+go_to_warehousing+"&room_id=" + room_id + "&master_room_id=" + master_room_id + "&room_code=" + room_code);

        }


        function ajax_delete_rent_room(room_id) {

            var xmlhttp;

            if (window.XMLHttpRequest) {// code for IE7+, Firefox, Chrome, Opera, Safari
                xmlhttp = new XMLHttpRequest();
            }
            else {// code for IE6, IE5
                xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
            }
            xmlhttp.onreadystatechange = function () {
                if (xmlhttp.readyState == 4 && xmlhttp.status == 200) {
                    var result = $.trim(xmlhttp.responseText);
                    alert("你已將這個倉庫單位從租用列表中刪除。");
                    if($("#" + room_id).hasClass("rent_current_room")){
                        $("#" + room_id).empty();
                    }else{
                        $("#" + room_id).remove();
                    }

                }
            }

            xmlhttp.open("POST", "_ajax.php?for=floor_plan_delete_room", true);
            xmlhttp.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
            xmlhttp.send("room_id=" + room_id);

        }

        $(function () {
            $(".cancel_room").on("click", function () {
                ajax_delete_rent_room(this.id);
            });
        })
    </script>
</head>

<body>
<div class="title">
    倉庫單位資料
</div>

<table id="room_detail">
    <tr>
        <td>單位編號:</td>
        <td colspan="3" style="text-align: left">
            <?php
                
if($room_info["code"]=="K44"){
                    echo 
"K44 K54";
                }elseif(
$room_info["code"]=="L30"){
                    echo 
"L30 L41";
                }elseif(
$room_info["code"]=="L32"){
                    echo 
"L32 L43";
                }elseif(
$room_info["code"]=="L39"){
                    echo 
"L39 L50";
                }elseif(
$room_info["code"]=="L51"){
                    echo 
"L51 L61";
                }elseif(
$room_info["code"]=="N28"){
                    echo 
"N28 N37";
                }elseif(
$room_info["code"]=="N29"){
                    echo 
"N29 N38";
                }elseif(
$room_info["code"]=="O02"){
                    echo 
"O02 O13";
                }elseif(
$room_info["code"]=="O05"){
                    echo 
"O05 O16";
                }else {
                    echo 
$room_info["code"] ;
                }
            
?>
        </td>
    </tr>

    <?php if($master_room_info["has_discounted_price"] == 1){ ?>
    <tr>
        <td>原價(月):</td>
        <td>$<?= numberformat($master_room_price_info["retail_price"]) ?></td>

        <td>優惠價(月):</td>
        <td>$<?= numberformat($master_room_price_info["discounted_price"]) ?></td>
    </tr>

    <tr>
        <td>優惠價生效期:</td>
        <td><?= $master_room_price_info["effectivedate_from"?></td>

        <td>優惠價完結期:</td>
        <td><?= $master_room_price_info["effectivedate_to"?></td>
    </tr>
    <?php } else { ?>
        <tr>
            <td>原價(月):</td>
            <td>$<?= numberformat($master_room_price_info["retail_price"]) ?></td>

            <td>優惠價(月):</td>
            <td>-</td>
        </tr>
    <?php ?>

    <tr>
        <td>尺寸:</td>
        <td><?= $master_room_info["display_size"]; //$master_room_info["length"] . " X " . $master_room_info["width"] . " X " . $master_room_info["height"] ?></td>

        <td>區域:</td>
        <td><?= $room_info["zone"?></td>
    </tr>

    <tr>
        <td>狀態:</td>
        <td colspan="3" style="text-align: left">
            <?= $status_info["name_tc"?>
            <?php
                $order_room_info 
get_order_room_by_room_id($room_info["id"]);
                if(!empty(
$order_room_info)){
                    
$order_info      get_order($order_room_info["order_id"]);
                    if(
date("Y-m-d") > $order_info["enddate"]){
                        echo 
" (合約已完結,但仍未退倉)";
                    }
                }
                
?>
        </td>
    </tr>

    <?php
        
if ($room_info["status"] == "RENTED" || $room_info["status"] == "SUSPENDED") {

            
$order_room_info get_order_room_by_room_id($room_info["id"]);
            if(!empty(
$order_room_info)){
                
$order_info      get_order($order_room_info["order_id"]);
                
$customer_info   get_customer($order_info["customer_id"]);
                
$customer_name   get_customer_name(rsa_crypt($customer_info["firstname"], 2), rsa_crypt($customer_info["lastname"], 2));
                echo 
'<tr>
                    <td>客戶姓名:</td>
                    <td>' 
$customer_name '</td>

                    <td>客戶編號:</td>
                    <td><a href="customer_modifyform.php?id=' 
$customer_info["id"] . '" target="_blank">' $customer_info["code"] . '</a></td>
                </tr>'
;


                echo 
'<tr>
                    <td>合約編號:</td>
                    <td colspan="3" style="text-align: left"><a href="order_modifyform.php?order_id=' 
$order_info["id"] . '" target="_blank">' $order_info["code"] . '</a> </td>
                </tr>'
;

                echo 
'<tr>
                    <td>合約生效日期:</td>
                    <td>' 
$order_info["startdate"] . '</td>

                    <td>合約完結日期:</td>
                    <td>' 
$order_info["enddate"] . '</td>
                </tr>'
;
            }
        }


        if (
$room_info["status"] == "RESERVED") {
            echo 
'<tr>
                    <td>預約人:</td>
                    <td colspan="3">' 
$room_info["reserve_by_name"] . '</td>
                </tr>'
;

            echo 
'<tr>
                    <td>聯絡電話:</td>
                    <td>' 
$room_info["reserve_by_tel"] . '</td>

                    <td>聯絡電郵:</td>
                    <td>'
.$room_info["reserve_by_email"].'</td>
                </tr>'
;

            echo 
'<tr>
                    <td>預約期:</td>
                    <td colspan="3">' 
$room_info["reservedate_from"]." 到 ".$room_info["reservedate_to"] . '</td>
                </tr>'
;
        }


        if (
$room_info["status"] == "OPEN" || $room_info["status"] == "RESERVED" ) {
            echo 
'<tr>
                    <td></td>
                    <td colspan="3">
                        <button class="room_info_btn" type="button" onclick="ajax_floor_plan_rent_room(0, ' 
$room_info["id"] . ',' $room_info["master_room_id"] . ',\'' $room_info["code"] . '\');">立即租用</button>';

            if (isset(
$_SESSION["floor_plan_rent_room"])) {
                
$display "block";
            }else{
                
$display "none";
            }

            echo 
'<div id="go_to_warehousing" style="display: '.$display.'"><br>
            <div>已選擇單位: '
;

            
$room_list "";
            if(!empty(
$_SESSION["floor_plan_rent_room"])){
                foreach(
$_SESSION["floor_plan_rent_room"] as $rent_room){
                    
$room_list .= "<span class='cancel_room' id='".$rent_room["room_id"]."'>".$rent_room["room_code"]." [刪除], </span>";
                }

                
$room_list substr_replace($room_list"", -91);

                echo 
$room_list;
            }


            echo 
'<span class="cancel_room rent_current_room" id="'.$room_info["id"].'"></span></div>
            <br>
            <div onclick="ajax_floor_plan_rent_room(1, ' 
$room_info["id"] .','.$room_info["master_room_id"].',\''.$room_info["code"].'\');" style="text-decoration: underline; cursor: pointer;">前往租倉程序
            </div>'
;

            echo 
'</td>
                </tr>'
;
    } else if (
$room_info["status"] == "RENTED") {
        
$order_room_info get_order_room_by_room_id($room_info["id"]);
        if (!empty(
$order_room_info)) {
            
$order_info get_order($order_room_info["order_id"]);
            echo 
'<tr>
                    <td></td>
                    <td colspan="3">
                        <a href="warehousing_step1.php?renew=1&contract_id='
.$order_room_info['order_id'].'&customer_id='.$order_info["customer_id"].'" target="_top"><button class="room_info_btn" type="button">續租</button></a>
                        </td>
                </tr>'
;
        }
        }
    
?>

</table>


</body>

</html>