/var/www/hkosl.com/innoutstorage2019/tc/rent.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
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
<?php
    
require_once ('../webadmin/basic_info.php');

    if(!isset(
$_GET["id"]) || (int)$_GET["id"] <= 0){
        echo 
"<script>alert('請選擇單位尺碼。'); window.location.href='pricing.php';</script>";
        exit;
    }

    
$master_room_info get_master_room_info_web();

    
uasort($master_room_info'sorting_by_LWH');

    
$product_info get_product();

    
$customer_type get_master_type_code("CUSTOMER_TYPE");
?>
<!DOCTYPE html>
<html dir="ltr" lang="en-US">
<head>

    <?php require_once ("html_head.php"?>

    <script type="text/javascript" src="../js/jquery-ui-1.11.4/jquery-ui.min.js"></script>
    <!--<script type="text/javascript" src="../js/jquery-ui-1.11.4/datepicker-zh-HK.js"></script>-->
    <link type="text/css" href="../js/jquery-ui-1.11.4/jquery-ui.css" rel="stylesheet"/>
    <link rel="stylesheet" href="../js/jquery-ui-1.11.4/jquery-ui.theme.min.css">

    <?php
        
if($langcode == "tc"){
            
$recaptcha_langcode "zh-HK";
        }else{
            
$recaptcha_langcode "en";
        }

    
?>
    <script src='https://www.google.com/recaptcha/api.js?hl=<?=$recaptcha_langcode?>'></script>

    <script type="text/javascript">
        function numberWithCommas(x) {
            return x.toString().replace(/\B(?=(?:\d{3})+(?!\d))/g, ",");
        }

        function select_room_size() {
            var email = $("#billing-form-email").val();
            var phone = $("#billing-form-phone").val();
            var master_room_id = $("#billing-form-master-room-id").val();
            var rent_month = $("#billing-form-month").val();
            var prepaid = 0;
            $("#recurring-payment").show();
            if($("#billing-form-prepaid").prop("checked") == true){
                prepaid = 1;
                $("#recurring-payment").hide();
            }

            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 == "0"){
                        alert("這個單位尺碼的迷你倉已租滿。");

                        $(".cart-product-name .product-price").html("");
                        $(".cart-product-prepaid .product-prepaid").html("");
                        $(".cart-product-name .product-price1").html("");
                        $(".cart-product-name .product-price-total_amt").html("");
                        $(".cart-product-first-month .product-price1").html("");

                    }else{
                        // To decode (This produces an object)
                        var obj = JSON.parse(result);
                        /*console.log(obj.price_text);
                        console.log(result);*/

                        $(".cart-product-name .product-price").html(obj.price_text);
                        $(".cart-product-prepaid .product-prepaid").html(obj.discount_text);
                        $(".cart-product-name .product-price1").html("HK$"+numberWithCommas(obj.deposit.toFixed(2)));
                        $(".cart-product-name .product-price-total_amt").html("HK$"+numberWithCommas(obj.total_amount.toFixed(2)));

                        if(parseFloat(obj.first_month_half_price) > 0){
                            $("#first_month_deduct").show();
                            $(".cart-product-first-month .product-price1").html("-HK$"+numberWithCommas(obj.first_month_half_price.toFixed(2)));
                        }else{
                            $("#first_month_deduct").hide();
                            $(".cart-product-first-month .product-price1").html("-HK$0.00");
                        }

                        if(parseFloat(obj.warehousing_date_range) == 1){
                            $("#billing-form-moveindate").show();
                            $("#billing-form-moveindate").removeAttr("disabled");
                            $("#billing-form-moveindate_now").hide();
                        }else{
                            $("#billing-form-moveindate").hide();
                            $("#billing-form-moveindate").attr("disabled", true);
                            $("#billing-form-moveindate_now").show();
                        }
                    }
                }
            }
            xmlhttp.open("POST", "_ajax.php?for=select_room_size", true);
            xmlhttp.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
            xmlhttp.send("master_room_id=" + (master_room_id) + "&rent_month="+rent_month + "&prepaid="+prepaid + "&email="+email+ "&phone="+phone);
        }

        $(function () {

            $("#billing-form-master-room-id, #billing-form-month, #billing-form-email").on("change", function () {
                select_room_size();
            });

            $("#billing-form-prepaid").on("click", function () {
                select_room_size();
            });

            select_room_size(<?=(int)$_GET["id"]?>);


            $("#billing-form-transervice").on("click", function () {
                if($(this).prop("checked") == true){
                    $(".transervice").show();
                    $("#billing-form-service-date").datepicker({dateFormat: 'yy-mm-dd', minDate : '0'});
                }else{
                    $(".transervice").hide();
                }
            });

            $("#billing-form-customer-type").on("change", function () {
                if($(this).val() == "BUSINESS"){
                    $(".BUSINESS").show();
                }else{
                    $(".BUSINESS").hide();
                }
            });
            

            $(".plus").on("click", function () {
                var qty = parseFloat($(this).closest(".cart-product-quantity").find(".qty").val());
                qty += 1;

                $(this).closest(".cart-product-quantity").find(".qty").val(qty);

                var price = parseFloat($(this).closest(".cart-product-quantity").find(".sp-price_int").val());
                $(this).closest(".cart-product-quantity").find(".sp-price").text("HK$"+numberWithCommas((price*qty).toFixed(2)));

                //console.log(price);

            });

            $(".minus").on("click", function () {
                var qty = parseFloat($(this).closest(".cart-product-quantity").find(".qty").val());
                if(qty > 0)
                    qty -= 1;

                $(this).closest(".cart-product-quantity").find(".qty").val(qty);

                if(qty == 0){
                    var price = parseFloat($(this).closest(".cart-product-quantity").find(".sp-price_int").val());
                    $(this).closest(".cart-product-quantity").find(".sp-price").text("HK$"+numberWithCommas((price).toFixed(2)));
                }else{
                    var price = parseFloat($(this).closest(".cart-product-quantity").find(".sp-price_int").val());
                    $(this).closest(".cart-product-quantity").find(".sp-price").text("HK$"+numberWithCommas((price*qty).toFixed(2)));
                }
            });

        })
    </script>

    <style>
        .transervice{
            display: none;
        }
    </style>
</head>

<body class="stretched no-transition">

<?php require_once ("google_analysis.php"); ?>

<!-- Document Wrapper
============================================= -->
<div id="wrapper" class="clearfix">

    <!-- Header
    ============================================= -->
    <?php require_once ("html_header.php"?>
    <!-- Content
    ============================================= -->
    <section id="content">

        <div class="content-wrap">

            <div class="container clearfix">

                <div class="heading-block center">
                    <h1>租用迷你倉</h1>
                </div>

                <form class="nobottommargin" id="billing-form" name="billing-form" action="rent_post.php" method="post">

                <div class="col-md-12 reserve">
                    <h4>你的詳細</h4>
                    <div class="table-responsive">
                        <table class="table cart">
                            <tbody>
                            <tr class="cart_item">
                                <td class="cart-product-name noborder">
                                    <strong>單位尺碼(長x闊x高):</strong>
                                </td>

                                <td class="cart-product-name noborder">
                                    <select id="billing-form-master-room-id" name="billing-form-master-room-id" class="sm-form-control required">
                                        <?php
                                            
foreach($master_room_info as $master_room){
                                                if((int)
$_GET["id"] == $master_room["master_room_id"])
                                                    
$selected "selected";
                                                else
                                                    
$selected "";

                                                echo 
"<option value='".$master_room["master_room_id"]."' ".$selected.">".$master_room["size"]."</option>";
                                            }
                                        
?>
                                    </select>
                                </td>
                            </tr>
                            <tr class="cart_item">
                                <td class="cart-product-name noborder">
                                    <strong>單位費用(月):</strong>
                                </td>

                                <td class="cart-product-name noborder">
                                    <span class="product-price"></span>
                                </td>
                            </tr>
                            <tr class="cart_item">
                                <td class="cart-product-name noborder" style="vertical-align:top !important;">
                                    <strong>租月期:</strong>
                                </td>

                                <td class="cart-product-month noborder">
                                    <select id="billing-form-month" name="billing-form-month" class="sm-form-control required">
                                        <?php
                                            
for($i 1$i <= 36$i++){
                                                if(isset(
$_SESSION["warehousing_web"]["rent_month"]) && $_SESSION["warehousing_web"]["rent_month"] == $i)
                                                    
$selected "selected";
                                                else
                                                    
$selected "";

                                                echo 
'<option value="'.$i.'" '.$selected.'>'.$i.'</option>';
                                            }
                                        
?>
                                    </select>
                                </td>
                            </tr>
                            <tr class="cart_item">
                                <td class="cart-product-name noborder">
                                    <strong>預繳所有費用:</strong>

                                </td>

                                <td class="cart-product-prepaid noborder">
                                    <span class="product-price1">
                                        <input type="checkbox" name="billing-form-prepaid" id="billing-form-prepaid" value="1" <?php if(isset($_SESSION["warehousing_web"]["prepaid"]) && $_SESSION["warehousing_web"]["prepaid"] == 1) echo "checked"?>>
                                    </span>
                                    <br>
                                    <span class="product-prepaid"></span>
                                </td>
                            </tr>

                            <tr class="cart_item" style="display: none;" id="first_month_deduct">
                                <td class="cart-product-name noborder">
                                    <strong>首月費用:</strong>
                                </td>

                                <td class="cart-product-first-month noborder">
                                    <span class="product-price1"></span>
                                </td>
                            </tr>

                            <tr class="cart_item">
                                <td class="cart-product-name noborder">
                                    <strong>按金(2個月月費):</strong>
                                </td>

                                <td class="cart-product-name noborder">
                                    <span class="product-price1"></span>
                                </td>
                            </tr>
                            <tr class="cart_item">
                                <td class="cart-product-name noborder">
                                    <span class="product-price-total">單位總金額:</span>
                                </td>

                                <td class="cart-product-name noborder">
                                    <span class="product-price-total_amt"></span>
                                </td>
                            </tr>
                            </tbody>

                        </table>

                    </div>

                    <div class="line"></div>

                    <h4>購買儲存用品</h4>

                    <div class="row">

                        <?php
                            
foreach($product_info as $product){
                                if(
$product["status"] == || $product["show_frontend"] == 0)
                                    continue;

                                
$product_image_info get_product_images($product["id"]);
                        
?>
                        <div class="col-md-3 col-sm-6 bottommargin">

                            <div class="team">
                                <div class="team-image">
                                    <?php
                                        
if(!empty($product_image_info[0]["photo"])){
                                            echo 
'<img src="../images/product_images/thumb/'.$product_image_info[0]["photo"].'" alt="'.$product["name_".$langcode].'">';
                                        }else{
                                            echo 
'<img src="../images/product_images/thumb/no_image.png" alt="'.$product["name_".$langcode].'">';
                                        }
                                    
?>
                                </div>
                                <div class="team-desc cart-product-quantity">
                                    <div class="sp-name"><?=$product["name_".$langcode]?></div>
                                    <div class="sp-price">
                                        HK$<?=numberformat($product["price"]); ?>
                                    </div>

                                    <input type="hidden" name="price_int" value="<?=numberformat($product["price"]); ?>"
                                           class="sp-price_int"/>
                                    <div class="quantity clearfix">
                                        <input type="hidden" name="product_id[<?=$product["id"]?>]" value="<?=$product["id"]?>">
                                        <input type="hidden" name="product_price[<?=$product["id"]?>]" value="<?=numberformat($product["price"]);?>">
                                        <input type="button" value="-" class="minus">
                                        <?php
                                            
if(isset($_SESSION["warehousing_web"]["order_product"][$product["id"]]["qty"]) && $_SESSION["warehousing_web"]["order_product"][$product["id"]]["qty"] > 0){
                                                
$qty $_SESSION["warehousing_web"]["order_product"][$product["id"]]["qty"];
                                            }else{
                                                
$qty 0;
                                            }
                                        
?>
                                        <input type="text" name="quantity[<?=$product["id"]?>]" value="<?=$qty?>" class="qty" />
                                        <input type="button" value="+" class="plus">
                                    </div>
                                </div>
                            </div>

                        </div>
                        <?php ?>



                    </div>

                    <div class="clear"></div>

                    <!--<div class="col_full">
                        <span class="product-price-total">Product Total Amount:</span>
                        <span class="product-price-total_amt">123</span>
                    </div>-->

                    <div class="line"></div>

                    <h4>帳單資料</h4>

                    <p></p>


                        <div class="form-process"></div>

                        <div class="col_one_third">
                            <label for="billing-form-title">頭銜: *</label>
                            <select id="billing-form-title" name="billing-form-title" class="sm-form-control required">
                                <option value="">-- 請選擇 --</option>
                                <option value="Mr" <?php if(isset($_SESSION["warehousing_web"]["title"]) && $_SESSION["warehousing_web"]["title"] == "Mr") echo "selected"?>>先生</option>
                                <option value="Mrs" <?php if(isset($_SESSION["warehousing_web"]["title"]) && $_SESSION["warehousing_web"]["title"] == "Mrs") echo "selected"?>>女士</option>
                                <option value="Ms" <?php if(isset($_SESSION["warehousing_web"]["title"]) && $_SESSION["warehousing_web"]["title"] == "Ms") echo "selected"?>>小姐</option>

                            </select>
                        </div>

                        <div class="col_one_third">
                            <label for="billing-form-lastname">姓氏: *</label>
                            <input type="text" id="billing-form-lastname" name="billing-form-lastname" value="<?php if(isset($_SESSION["warehousing_web"]["firstname"])) echo $_SESSION["warehousing_web"]["firstname"]; ?>" class="sm-form-control required" placeholder="姓氏" />
                        </div>

                        <div class="col_one_third col_last">
                            <label for="billing-form-firstname">名字: *</label>
                            <input type="text" id="billing-form-firstname" name="billing-form-firstname" value="<?php if(isset($_SESSION["warehousing_web"]["lastname"])) echo $_SESSION["warehousing_web"]["lastname"]; ?>" class="sm-form-control required" placeholder="名字" />

                        </div>

                        <div class="clear"></div>


                        <div class="col_one_third">
                            <label for="billing-form-customer-type">客戶類型: *</label>
                            <select id="billing-form-customer-type" name="billing-form-customer-type" class="sm-form-control required">
                                <?php
                                    
foreach($customer_type as $type){
                                        if(isset(
$_SESSION["warehousing_web"]["customer_type"]) && $_SESSION["warehousing_web"]["customer_type"] == $type["code"])
                                            
$selected "selected";
                                        else
                                            
$selected "";

                                        echo 
'<option value="'.$type["code"].'" '.$selected.'>'.$type["name_".$langcode].'</option>';
                                    }
                                
?>

                            </select>
                        </div>

                        <div class="clear"></div>

                        <div class="col_full BUSINESS" style="display: none;">
                            <label for="billing-form-companyname">公司名稱: *</label>
                            <input type="text" id="billing-form-companyname" name="billing-form-companyname" value="<?php if(isset($_SESSION["warehousing_web"]["companyname"])) echo $_SESSION["warehousing_web"]["companyname"]; ?>" class="sm-form-control required" placeholder="Company Name" />
                        </div>

                        <div class="col_half">
                            <label for="billing-form-phone">聯絡電話: *</label>
                            <input type="text" id="billing-form-phone" name="billing-form-phone" value="<?php if(isset($_SESSION["warehousing_web"]["tel"])) echo $_SESSION["warehousing_web"]["tel"]; ?>" class="sm-form-control required" placeholder="聯絡電話" />
                        </div>

                        <div class="col_half col_last">
                            <label for="billing-form-email">電郵: *</label>
                            <input type="email" id="billing-form-email" name="billing-form-email" value="<?php if(isset($_SESSION["warehousing_web"]["email"])) echo $_SESSION["warehousing_web"]["email"]; ?>" class="sm-form-control required" placeholder="電郵" />
                        </div>

                        <div class="clear"></div>

                        <div class="col_full">
                            <label for="billing-form-address">帳單地址: *</label>
                            <input type="text" id="billing-form-address" name="billing-form-address" value="<?php if(isset($_SESSION["warehousing_web"]["address"])) echo $_SESSION["warehousing_web"]["address"]; ?>" class="sm-form-control required" placeholder="帳單地址" />
                        </div>

                        <!--<div class="col_full">
                            <input type="text" id="billing-form-address2" name="billing-form-adress" value="" class="sm-form-control" />
                        </div>-->

                        <div class="col_half">
                            <label for="billing-form-title">搬入日期: *</label>
                            <?php
                                
echo "<div id='billing-form-moveindate_now'>".date("Y-m-d")."</div>";
                            
?>

                            <select id="billing-form-moveindate" name="billing-form-warehousing-date" class="sm-form-control required" style="display: none;" disabled>
                                <option value="">-- 請選擇 --</option>
                                <?php
                                    
for($i=1$i<=7$i++){
                                        
$date = new DateTime();
                                        
$date->modify('+'.$i.' day');

                                        if(isset(
$_SESSION["warehousing_web"]["warehousing_date"]) && $_SESSION["warehousing_web"]["warehousing_date"] == $date->format("Y-m-d"))
                                            
$selected "selected";
                                        else
                                            
$selected "";

                                        echo 
'<option value="'.$date->format("Y-m-d").'" '.$selected.'>'.$date->format("Y-m-d").'</option>';
                                    }
                                
?>
                            </select>
                        </div>
                        <div class="clear"></div>

                        <div class="col_full">
                            如你需要運輸安排服務,請按如下<br />
                            <label for="billing-form-transervice"><input id="billing-form-transervice" name="billing-form-transervice" type="checkbox" value="1" <?php if(isset($_SESSION["warehousing_web"]["transervice"]) && $_SESSION["warehousing_web"]["transervice"] == 1) echo "checked";?>/> <span style="font-size:18px;">運輸服務</span></label>
                        </div>


                        <div class="col_full transervice">
                            <label for="billing-form-service-date">運輸日期: *</label>
                            <input type="text" id="billing-form-service-date" name="billing-form-service-date" value="<?php if(isset($_SESSION["warehousing_web"]["service_date"])) echo $_SESSION["warehousing_web"]["service_date"]; ?>" class="sm-form-control required" placeholder="運輸日期" />
                        </div>

                        <div class="col_half transervice">
                            <label for="billing-form-delivery-from">運輸地址: *</label>
                            <input type="text" id="billing-form-delivery-from" name="billing-form-delivery-from" value="<?php if(isset($_SESSION["warehousing_web"]["delivery_from"])) echo $_SESSION["warehousing_web"]["delivery_from"]; ?>" class="sm-form-control required" placeholder="運輸地址" />
                        </div>

                        <div class="col_half col_last transervice">
                            <label for="billing-form-delivery-to">運輸目的地: *</label>
                            <input type="text" id="billing-form-delivery-to" name="billing-form-delivery-to" value="<?php if(isset($_SESSION["warehousing_web"]["delivery_to"])) echo $_SESSION["warehousing_web"]["delivery_to"]; ?>" class="sm-form-control required" placeholder="運輸目的地" />
                        </div>

                        <!--<div class="col_full" id="recurring-payment">
                            如果你想使用PayPal定期自動付款服務,請按如下<br />
                            <label for="billing-form-recurring-payment"><input id="billing-form-recurring-payment" name="billing-form-recurring-payment" type="checkbox" value="1" /> <span style="font-size:18px;">定期自動付款服務</span></label>
                        </div>-->

                        <div class="col_full">
                            <b>付款方式:</b><br /> <img src="../images/visa_mastercard_logo_<?=$langcode?>.png" height="30"></div>


                        <div class="col_full">
                            <b>租用條款:</b><br />
                            您在此同意條款與細則。您清楚知道您有責任準時支付所有相關費用,並提供有效的付款方式給出入易迷你倉。<br /><br />
                            您的結算日為您開始搬入迷你倉的那天。您同意繳付兩個月按金及至少一個月租用費才能使用出入易迷你倉服務。通過線上繳付系統,您將會在每月的結算日自動支付儲存月費。
                        </div>

                        <div class="col_full">
                            <label for="billing-form-agree"><input id="billing-form-agree" name="billing-form-agree" type="checkbox" value="1" class="required" /> <span style="font-size:18px;">我同意租用條款與細則</span></label>
                            <label for="billing-form-agree" class="error" style="display: block !important;"></label>
                        </div>

                        <div class="col_full">
                            <label for="template-contactform-message">驗證 <small>*</small></label>
                            <div class="g-recaptcha" data-theme="light" data-sitekey="<?=$google_recaptcha_site_key?>"></div>

                        </div>

                        <div class="col_full center">
                            <button class="button nomargin" type="submit" id="billing-form-submit" name="billing-form-submit" value="submit">下一步</button>
                        </div>


                    <script type="text/javascript">

                        $("#billing-form").validate({
                            messages: {
                                'billing-form-agree': "請同意租用條款與細則。"
                            }

                        });

                    </script>
                </div>

                </form>
            </div>

        </div>

    </section><!-- #content end -->

    <!-- Footer
    ============================================= -->
    <?php require_once ("html_footer.php"); ?>

</div><!-- #wrapper end -->

<!-- Go To Top
============================================= -->
<div id="gotoTop" class="icon-angle-up"></div>

<!-- Footer Scripts
============================================= -->
<script type="text/javascript" src="../js/functions.js"></script>

</body>
</html>