/var/www/hkosl.com/m.musiccircle/order_form.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
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
<?php
    
include('_init.php');

    if (
$_SESSION["is_student"] != && $_SESSION["is_tutor"] != 1) {
        
header("Location: index.php");
        exit;
    }

    
$page_settings['domain'] = "order";

    
$sql         "select profile_id,user_id
            from `profile_user` as tb where user_id = ? and deleted = ? LIMIT 1"
;
    
$parameters  = array($_SESSION['cmsloginid'], 0);
    
$row_profile bind_pdo($sql$parameters"selectone");

    
$order get_order((int)$_GET["id"]);

    if (
$row_profile['profile_id'] == 4) {
        
$sql99        "select id from `student_main` where cmsloginid = ? LIMIT 1";
        
$parameters99 = array((int)$row_profile['user_id']);
        
$row_user     bind_pdo($sql99$parameters99"selectone");
        if (
$row_user['id'] != $order['studentmain_id']) {
            
$path $page_settings['domain'] . '_index.php';
            @
header("Location: {$path}");
            echo 
"<script language='JavaScript'>window.location='{$path}'</script>";
        }
    } else if (
$row_profile['profile_id'] == 3) {
        
$sql99        "select id from `tutor_main` where cmsloginid = ? LIMIT 1";
        
$parameters99 = array((int)$row_profile['user_id']);
        
$row_user     bind_pdo($sql99$parameters99"selectone");
        if (
$row_user['id'] != $order['tutormain_id']) {
            
$path $page_settings['domain'] . '_index.php';
            @
header("Location: {$path}");
            echo 
"<script language='JavaScript'>window.location='{$path}'</script>";
        }
    }

    if (
$order) {
        
$action 'Modify'// Add or Modify

        
$sql99        "SELECT * FROM sys_cms_login WHERE cmsloginid=?";
        
$parameters99 = array((int)$row{'cmsloginid'});
        
$row_user     bind_pdo($sql99$parameters99"selectone");
    } else {
        
//$action = 'Add'; // Add or Modify
        
$path $page_settings['domain'] . '_index.php';
        @
header("Location: {$path}");
        echo 
"<script language='JavaScript'>window.location='{$path}'</script>";
        exit();
    }
    
$sql         "select id,datetime,tutor_status,student_status,solution_status from order_detail where order_id = ?";
    
$parameters  = array($order['id']);
    
$rows_detail bind_pdo($sql$parameters"selectall");

    if (
$order['order_type'] == 'course') {
        
$sql        "select id, postjob_no,mas_instrument,address_cn, course_hours, course_count from tutor_postjob where id = ? and deleted = ?";
        
$parameters = array($order['job_id'], 0);
        
$row_job    bind_pdo($sql$parameters"selectone");
    } else {
        
$sql        "select id,postjob_no,mas_instrument from student_postjob where id = ? and deleted = ?";
        
$parameters = array($order['job_id'], 0);
        
$row_job    bind_pdo($sql$parameters"selectone");
    }
    
$sql        "select tutor_no,nickname as name from tutor_main where id = ? and deleted = ?";
    
$parameters = array($order['tutormain_id'], 0);
    
$row_tutor  bind_pdo($sql$parameters"selectone");

    
$sql         "select student_no,contactname as name from student_main where id = ? and deleted = ?";
    
$parameters  = array($order['studentmain_id'], 0);
    
$row_student bind_pdo($sql$parameters"selectone");

    
$sql              "select name_cn from master_type_code where id = ? and typeid = ? and deleted = ?";
    
$parameters       = array($order['mas_residencecode'], 'TEACH_POSITIONCODE'0);
    
$row_positioncode bind_pdo($sql$parameters"selectone");

    
$sql        "select name_cn from master_type_code where id = ? and typeid = ? and deleted = ?";
    
$parameters = array($order['course_venus'], 'TEACH_VENUS'0);
    
$row_venus  bind_pdo($sql$parameters"selectone");

    if (!empty(
$row_job['mas_instrument'])) {
        
$mas_instrument_id $row_job['mas_instrument'];
    } else {
        
$mas_instrument_id $order["mas_instrument"];
    }
    
$sql            "select name_en,name_cn from master_type_code where id = ? and typeid = 'INSTRUMENT' LIMIT 1";
    
$parameters     = array($mas_instrument_id);
    
$row_instrument bind_pdo($sql$parameters"selectone");

    
$paypal_link "";
    if (
$row_profile['profile_id'] == 4) {
        if (
$order['status'] == 'approved') {

            
$shipping_price 0;
            
$amount         intval($order['total_fee']) - intval($order['coupon_fee']);
            
$invoiceNo      $order['order_no'];
            
//$amount = 0.1;
            
$extra_url    EXTRA_URL;
            
$paypal_url   PAYPAL_URL;
            
$paypal_array = array('cmd'           => '_xclick',
                                  
'upload'        => '1',
                                  
'custom'        => $order['id'],
                                  
'invoice'       => $invoiceNo,
                                  
'business'      => PAYPAL_BUSINESS,
                                  
'item_name'     => $row_instrument['name_en'] . ' - Course Fee',
                
//'item_name'        =>'a',
                                  
'item_number'   => $invoiceNo,
                                  
'currency_code' => 'HKD',
                                  
'shipping'      => $shipping_price,
                                  
'no_shipping'   => 1,
                                  
'amount'        => $amount,
                
//'image_url'        =>$GLOBALS['site_info']['full_path'].'images/logo.png',
                                  
'return'        => 'http://' $_SERVER['HTTP_HOST'] . '/' $extra_url 'webadmin/order_form.php?id=' $order['id'],
                                  
'notify_url'    => 'http://' $_SERVER['HTTP_HOST'] . '/' $extra_url 'paypal_notify.php',
                                  
'cancel_return' => 'http://' $_SERVER['HTTP_HOST'] . '/' $extra_url 'order_form.php?id=' $order['id']
            );
            
$array        = array();
            foreach (
$paypal_array as $name => $data) {
                
$array[] = $name '=' urlencode($data);
            }
            
$paypal_link $paypal_url '?' implode('&'$array);
        }
    }

    if (!empty(
$_GET["click_paypal"]) && $_GET["click_paypal"] == && !empty($paypal_link)) {
        
header("Location: " $paypal_link);
        exit;
    }

    
//read notification
    
$sql        "update notification set `read` = ?, read_date = ? where table_name = ? and table_id = ? and cmsloginid = ? and deleted = ? and `read` = ? and read_date is null";
    
$parameters = array(1date("Y-m-d"), "order", (int)$_GET["id"], $_SESSION["cmsloginid"], 00);
    
bind_pdo($sql$parameters);
?>
<!DOCTYPE html>
<html lang="en">
<head>
    <?php include('_head.php'); ?>
    <link href="css/style_k.css?v=<?=time();?>" type="text/css" rel="stylesheet">
</head>

<body>
<?php include('_header.php'?>

<?php include('_dialog.php'?>

<div class="ProfileContent">
    <div class="Profilecontainer">
        <div class="row">
            <div class="col-md-12 faq">
                <form action="<?= $page_settings['domain'?>_<? if ($order['status'] == 'process') { ?>action<? } elseif ($order['status'] == 'paid' || ($order['status'] != 'paid' && ($row_profile['profile_id'] == || $row_profile['profile_id'] == 2))) { ?>process<? ?>.php" class="myform" id="myform" method="<? if ($order['status'] == 'process') { ?>get<? } elseif ($order['status'] == 'paid' || ($order['status'] != 'paid' && ($row_profile['profile_id'] == || $row_profile['profile_id'] == 2))) { ?>post<? ?>" enctype="multipart/form-data">
                    <? if ($order['id']) { ?>
                        <input type="hidden" name="id" value="<?= _h($order['id']) ?>"/>
                        <? if ($order['status'] == 'process') { ?>
                            <input type="hidden" name="action" value="approved"/>
                        <? ?>
                    <? ?>
                    <div class="row">
                        <div class="col-xs-12">
                            <div class="box">
                                <div class="box-header">
                                    <div class="col-md-4">
                                        <div class="btn-group">
                                            <!--<a href="order_index.php" class="btn btn-default"><i class="fa fa-chevron-left" aria-hidden="true"></i>
                                                <?/*= _lang('Back') */?>
                                            </a>-->
                                            <?
                                                
if ($order['order_type'] == 'course') {
                                                    if (
$order['status'] == 'process') {
                                                        
$order['status'] = 'approved';
                                                    }
                                                }
                                            
?>
                                            <? if ($order['status'] == 'process' || $order['status'] == 'approved' || $order['status'] == 'reject') { ?>
                                                <? if ($row_profile['profile_id'] == 3) { ?>
                                                    <? if ($order['status'] == 'approved' || $order['status'] == 'reject') { ?>
                                                        <span class="btn btn-default"><i class="fa fa-paypal" aria-hidden="true"></i>
                                                            <? if ($order['status'] == 'approved') { ?>
                                                                等待學生付款中
                                                            <? } else if ($order['status'] == 'reject') { ?>
                                                                <? if ($order['form_type'] == 'tutor') { ?>
                                                                    學生已拒絕你的邀請
                                                                <? } else { ?>
                                                                    你已拒絕學生的邀請
                                                                <? ?>
                                                            <? ?>
                                                        </span>
                                                    <? } else { ?>
                                                        <? if ($order['from_type'] == 'student') { ?>
                                                            <a href="<?= $page_settings['domain'?>_action.php?id=<?= $order['id'?>&action=approved" class="btn btn-default btn-success" style="color:#FFF;" onClick="return <? if ($order['status'] == 'process') { ?>submitfrom();<? } else { ?>confirm('你確認嗎?');<? ?>">
                                                                <i class="glyphicon glyphicon-ok-sign" aria-hidden="true"></i>
                                                                <?= _lang("Accept"?>
                                                            </a>
                                                            <a href="<?= $page_settings['domain'?>_action.php?id=<?= $order['id'?>&action=reject" class="btn btn-default btn-warning" style="color:#FFF;" onClick="return confirm('你確認嗎?')">
                                                                <i class="glyphicon glyphicon-remove-sign" aria-hidden="true"></i>
                                                                <?= _lang("Reject"?>
                                                            </a>
                                                        <?php } else if ($order['from_type'] == 'tutor') { ?>
                                                            <a href="<?= $page_settings['domain'?>_action.php?id=<?= $order['id'?>&action=cancel" class="btn btn-default btn-warning" style="color:#FFF;" onClick="return confirm('你確認嗎?')">
                                                                <i class="glyphicon glyphicon-remove-sign" aria-hidden="true"></i>
                                                                <?= _lang("取消邀請"?>
                                                            </a>
                                                        <? ?>
                                                    <? ?>
                                                <? } else if ($row_profile['profile_id'] == 4) { ?>
                                                    <? if ($order['status'] == 'approved' || $order['status'] == 'reject') { ?>
                                                        <? if ($order['status'] == 'approved') { ?>
                                                            <a href="<?= $paypal_link ?>" class="btn btn-default btn-success" style="color:#FFF;" id="payment_btn">
                                                                <i class="fa fa-paypal" aria-hidden="true"></i>
                                                                <?= _lang("付款"?>
                                                            </a>

                                                            <? if ($order["order_type"] == "course") { ?>
                                                                <a href="<?= $page_settings['domain'?>_action.php?id=<?= $order['id'?>&action=cancel" class="btn btn-default btn-warning" style="color:#FFF;" onClick="return confirm('你確認嗎?')">
                                                                    <i class="glyphicon glyphicon-remove-sign" aria-hidden="true"></i>
                                                                    <?= _lang("取消"?>
                                                                </a>
                                                            <?php ?>
                                                        <? } else if ($order['status'] == 'reject') { ?>
                                                            <span class="btn btn-default"><i class="fa fa-paypal" aria-hidden="true"></i>
                                                                <? if ($order['form_type'] == 'student') { ?>
                                                                    你已拒絕導師的邀請
                                                                <? } else { ?>
                                                                    導師已拒絕你的邀請
                                                                <? ?>
                                                            </span>
                                                        <? ?>
                                                    <? } else { ?>
                                                        <? if ($order['from_type'] == 'tutor') { ?>
                                                            <a href="<?= $page_settings['domain'?>_action.php?id=<?= $order['id'?>&action=approved" class="btn btn-default btn-success" style="color:#FFF;" onClick="return confirm('你確認嗎?')">
                                                                <i class="glyphicon glyphicon-ok-sign" aria-hidden="true"></i>
                                                                <?= _lang("Accept"?>
                                                            </a>
                                                            <a href="<?= $page_settings['domain'?>_action.php?id=<?= $order['id'?>&action=reject" class="btn btn-default btn-warning" style="color:#FFF;" onClick="return confirm('你確認嗎?')">
                                                                <i class="glyphicon glyphicon-remove-sign" aria-hidden="true"></i>
                                                                <?= _lang("Reject"?>
                                                            </a>
                                                        <?php } else if ($order['from_type'] == 'student') { ?>
                                                            <a href="<?= $page_settings['domain'?>_action.php?id=<?= $order['id'?>&action=cancel" class="btn btn-default btn-warning" style="color:#FFF;" onClick="return confirm('你確認嗎?')">
                                                                <i class="glyphicon glyphicon-remove-sign" aria-hidden="true"></i>
                                                                <?= _lang("取消邀請"?>
                                                            </a>
                                                        <?php ?>
                                                    <? ?>
                                                <? ?>
                                            <? ?>
                                            <? /*if (($order['status'] == 'paid' && ($row_profile['profile_id'] == 3 || $row_profile['profile_id'] == 1 || $row_profile['profile_id'] == 2)) || ($order['status'] != 'paid' && ($row_profile['profile_id'] == 1 || $row_profile['profile_id'] == 2))) { ?>
                                                <button type="button" class="btn btn-primary" onClick="submitfrom()">
                                                    <i class="fa fa-floppy-o" aria-hidden="true"></i> <?= _lang('Save') ?>
                                                </button>
                                            <? } */
?>
                                        </div>
                                    </div>
                                    <? /*if ($order['status'] == 'paid') { ?>
                                        <div class="col-md-2" style="float:right;">
                                            <div class="btn-group" style="float:right;">
                                                <span onclick="printDiv('printableArea')" class="btn btn-default">
                                                    <i class="fa fa-print" aria-hidden="true"></i>
                                                    <?= _lang("Print") ?>
                                                </span></div>
                                        </div>
                                    <? } */
?>

                                </div>

                                <!-- /.box-header -->
                                <div class="box-body" id="printableArea">
                                    <br>
                                    <table width="100%" border="0" cellpadding="0" cellspacing="2">
                                        <?php //if($order['status'] != "paid"){ ?>
                                            <tr>
                                                <th width="120" align="right" valign="top" style="text-align:right;">狀態</th>
                                                <td width="5" valign="top" class=''>:&nbsp;</td>
                                                <td class=''>
                                                    <div class="col-sm-12 form-group">
                                                        <?= get_order_status($order['status']) ?>
                                                    </div>
                                                </td>
                                            </tr>
                                        <?php //} ?>

                                        <? if ($order['status'] == 'paid' || $order['status'] == 'fail' || $order['status'] == 'refunded') { ?>
                                            <tr>
                                                <th width="120" align="right" valign="top" class='' style="text-align:right;">
                                                    Paypal 編號
                                                </th>
                                                <td width="5" valign="top" class=''>:&nbsp;</td>
                                                <td class=''>
                                                    <div class="col-sm-12 form-group">
                                                        <?= $order['paypal_id'?>
                                                    </div>
                                                </td>
                                            </tr>
                                            <tr>
                                                <th width="120" align="right" valign="top" class='' style="text-align:right;">
                                                    Paypal 處理日期
                                                </th>
                                                <td width="5" valign="top" class=''>:&nbsp;</td>
                                                <td class=''>
                                                    <div class="col-sm-12 form-group">
                                                        <?= $order['paypal_date'?>
                                                    </div>
                                                </td>
                                            </tr>
                                        <? }?>
                                        <tr>
                                            <th width="120" align="right" valign="top" height="40" style="text-align:right;"><?= lang("Post No."?></th>
                                            <td valign="top" class=''>&nbsp;</td>
                                            <td valign="top" class=''>
                                                <div class="col-sm-12 form-group">
                                                    <?php $row_job['postjob_no'] = "J".str_pad($row_job["id"], 5"0"STR_PAD_LEFT); if ($order["order_type"] == 'course') { ?>
                                                        <?= $row_job['postjob_no'] ? $row_job['postjob_no'] : '-' ?>
                                                    <?php } else { ?>
                                                        <a href="chat_index.php?first_chat_id=<?= $order['first_chat_id'?>" target="_blank">
                                                            <?= $row_job['postjob_no'] ? $row_job['postjob_no'] : '-' ?>
                                                        </a>
                                                    <?php ?>
                                                </div>
                                            </td>
                                        </tr>

                                        <tr>
                                            <th width="120" align="right" valign="top" height="40" style="text-align:right;"><?= lang("Order No."?></th>
                                            <td valign="top" class=''>&nbsp;</td>
                                            <td valign="top" class=''>
                                                <div class="col-sm-12 form-group">
                                                    <?= short_code($order['order_no'], 2, -5?>
                                                </div>
                                            </td>
                                        </tr>

                                        <tr>
                                            <th width="120" align="right" valign="top" height="40" style="text-align:right;">
                                                學生
                                            </th>
                                            <td width="5" valign="top" class=''>:&nbsp;</td>
                                            <td class=''>
                                                <div class="col-sm-12 form-group">
                                                    <?php if ($_SESSION["is_tutor"] == 1) { ?>
                                                        <a href="chat_index.php?first_chat_id=<?= $order['first_chat_id'?>" target="_blank">
                                                            <?= $row_student['student_no'?>
                                                            <?= $row_student['name'?>
                                                        </a>
                                                    <?php } else { ?>
                                                        <?= $row_student['student_no'?>
                                                        <?= $row_student['name'?>
                                                    <?php ?>
                                                </div>
                                            </td>
                                        </tr>
                                        <tr>
                                            <th width="120" align="right" valign="top" height="40" style="text-align:right;">
                                                導師
                                            </th>
                                            <td width="5" valign="top" class=''>:&nbsp;</td>
                                            <td class=''>
                                                <div class="col-sm-12 form-group">
                                                    <?php if ($_SESSION["is_student"] == 1) { ?>
                                                        <a href="chat_index.php?first_chat_id=<?= $order['first_chat_id'?>" target="_blank">
                                                            <?= $row_tutor['tutor_no'?>
                                                            <?= $row_tutor['name'?>
                                                        </a>
                                                    <?php } else { ?>
                                                        <?= $row_tutor['tutor_no'?>
                                                        <?= $row_tutor['name'?>
                                                    <?php ?>
                                                </div>
                                            </td>
                                        </tr>
                                        <!--<tr>
                                            <td width="120" align="right" valign="top" class=''>課堂類型</td>
                                            <td width="5" valign="top" class=''>:&nbsp;</td>
                                            <td class=''>
                                                <div class="col-sm-12 form-group">
                                                    <?/* if ($order["order_type"] == 'course') {
                                                        echo "小組音樂班";
                                                    } else if ($order["order_type"] == "formal") {
                                                        echo "正堂";
                                                    } else if ($order["order_type"] == "try") {
                                                        echo "試堂";
                                                    }
                                                    */
?>
                                                </div>
                                            </td>
                                        </tr>-->
                                        <tr>
                                            <td width="120" align="right" valign="top" class=''>上課地區</td>
                                            <td width="5" valign="top" class=''>:&nbsp;</td>
                                            <td class=''>
                                                <div class="col-sm-12 form-group">
                                                    <? if ($order["order_type"] == 'course') { ?>
                                                        <?= $row_job['address_cn'] ? $row_job['address_cn'] : '-' ?>
                                                    <? } else { ?>
                                                        <?= $row_positioncode["name_cn"] ? $row_positioncode["name_cn"] : '-' ?>
                                                    <? ?>
                                                </div>
                                            </td>
                                        </tr>
                                        <? if ($order["order_type"] != 'course') { ?>
                                            <tr>
                                                <td width="120" align="right" valign="top" class=''>上課場地</td>
                                                <td width="5" valign="top" class=''>:&nbsp;</td>
                                                <td class=''>
                                                    <div class="col-sm-12 form-group">
                                                        <?= $row_venus['name_cn'] ? $row_venus['name_cn'] : '-' ?>
                                                    </div>
                                                </td>
                                            </tr>
                                        <? ?>

                                        <tr>
                                            <td width="120" align="right" valign="top" class=''>樂器</td>
                                            <td width="5" valign="top" class=''>:&nbsp;</td>
                                            <td class=''>
                                                <div class="col-sm-12 form-group">
                                                    <?= $row_instrument['name_cn']; ?>
                                                </div>
                                            </td>
                                        </tr>

                                        <tr>
                                            <td width="120" align="right" valign="top" class=''>學習級別</td>
                                            <td width="5" valign="top" class=''>:&nbsp;</td>
                                            <td class=''>
                                                <div class="col-sm-12 form-group">
                                                    <?
                                                        
if ($order['order_type'] == 'try') {
                                                            if (
$order['level'] == 1) {
                                                                echo 
'1 - 2';
                                                            } elseif (
$order['level'] == 2) {
                                                                echo 
'3 - 5';
                                                            } elseif (
$order['level'] == 3) {
                                                                echo 
_lang("6 or above 6");
                                                            }
                                                        } else if (
$order['order_type'] == 'formal') {
                                                            if (
$order['level'] < 8) {
                                                                echo 
$order['level'];
                                                            } else if (
$order['level'] == 9) {
                                                                echo 
'8級以上';
                                                            }
                                                        } else if (
$order['order_type'] == 'course') {
                                                            if (
$order['level'] == 1) {
                                                                echo 
"初級";
                                                            } else if (
$order['level'] == 3) {
                                                                echo 
"中級";
                                                            }
                                                        }
                                                    
?>
                                                    &nbsp;
                                                </div>
                                            </td>
                                        </tr>

                                        <tr>
                                            <td width="120" align="right" valign="top" class=''>學習時間長度</td>
                                            <td width="5" valign="top" class=''>:&nbsp;</td>
                                            <td class=''>
                                                <div class="col-sm-12 form-group">
                                                    <?php
                                                        
if ($order["order_type"] == 'course') {
                                                            echo 
$row_job["course_hours"];
                                                        } else {
                                                            echo 
$order['course_length'];
                                                        }

                                                        echo 
_lang("mins");
                                                    
?>
                                                </div>
                                            </td>
                                        </tr>
                                        <tr>
                                            <td width="120" align="right" valign="top" class=''>學習堂數</td>
                                            <td width="5" valign="top" class=''>:&nbsp;</td>
                                            <td class=''>
                                                <div class="col-sm-12 form-group">
                                                    <?php
                                                        
if ($order["order_type"] == 'course') {
                                                            echo 
$row_job["course_count"];
                                                        } else {
                                                            echo 
$order['course_count'];
                                                        }
                                                    
?>
                                                </div>
                                            </td>
                                        </tr>

                                        <? if ($order['order_type'] == 'try' || ($order['order_type'] == 'formal' && $order['status'] == 'paid') || $order['order_type'] == 'course') {

                                            
?>
                                            <tr>
                                                <td width="120" align="right" valign="top" class=''>上課日期 / 時間</td>
                                                <td width="5" valign="top" class=''>:&nbsp;</td>
                                                <td class=''>
                                                    <div class="col-sm-12 form-group">
                                                        <? if ($order['order_type'] == 'formal' || ($order['order_type'] == 'try' && !$row_job['postjob_no'])) { ?>
                                                            <? for ($i 0$i $order['course_count']; $i++) { ?>
                                                                <?
                                                                $sql        
"select * from order_detail as tt where order_id = ? and sort = ? LIMIT 1";
                                                                
$parameters = array($order['id'], $i);
                                                                
$row_detail bind_pdo($sql$parameters"selectone");
                                                                
?>
                                                                <div style="margin-bottom:5px;">
                                                                    <? if ($row_profile['profile_id'] == || $row_profile['profile_id'] == || $row_profile['profile_id'] == 1) { ?>
                                                                        <? $time = new DateTime();
                                                                        if (
$row_detail['datetime'] && ($time->modify("+ 1 day")->format("Y-m-d H:i:s") >= $row_detail['datetime'])) {
                                                                            
$end_datetime = new DateTime($row_detail['datetime']);
                                                                            
$end_datetime->modify("+" $order['course_length'] . " minute");
                                                                            
?>
                                                                            <table width="100%" border="0" cellpadding="0" cellspacing="0">
                                                                                <tr>
                                                                                    <td width="100%">
                                                                                        <?= ($i 1?>
                                                                                        .
                                                                                        <?= $row_detail['datetime'] . " 至 " $end_datetime->format("Y-m-d H:i:s"?>
                                                                                        <input type="hidden" name="datetime[<?= $i ?>]" value="<?= $row_detail['datetime'?>">
                                                                                    </td>
                                                                                    <?php  ?>
                                                                                    <td style="padding-left:19px;">
                                                                                        <div class="orderdetailbtn">
                                                                                            <? if ($order['status'] == 'paid') { ?>
                                                                                                <a href="course_form.php?id=<?= $row_detail['id'?>" class="btn <? if ($row_detail['student_status'] == 1) { ?><? if ($row_detail['solution_status'] == 1) { ?>btn-success<? } else { ?>btn-warning<? ?><? } elseif ($row_detail['tutor_status'] == 1) { ?>btn-success<? } else { ?>btn-default<? ?>"><i class="fa fa-link" aria-hidden="true"></i>
                                                                                                    課堂資料
                                                                                                    <? if ($row_detail['student_status'] == 1) { ?>
                                                                                                        (已投訴)
                                                                                                        <? if ($row_detail['solution_status'] == 1) { ?>
                                                                                                            (已解決)
                                                                                                        <? ?>
                                                                                                    <? } elseif ($row_detail['tutor_status'] == 1) { ?>
                                                                                                        (已上課)
                                                                                                    <? ?>
                                                                                                </a>
                                                                                            <? ?>
                                                                                        </div>
                                                                                    </td>
                                                                                    <?php  ?>
                                                                                </tr>
                                                                            </table>
                                                                        <? } else { ?>
                                                                            <?= ($i 1?>
                                                                            .
                                                                            <input type="text" class="form-control datetimepicker" name="datetime[<?= $i ?>]" value="<?= $row_detail['datetime'?>" style="width:100%; display:inline-block;" placeholder="請輸入上課日期/時間">
                                                                            <div id="dateError<?= $i ?>_1" style="color:#F00; display:none;" class="error">
                                                                                請輸入上課日期/時間
                                                                            </div>
                                                                            <div id="dateError<?= $i ?>_2" style="color:#F00; display:none;" class="error">
                                                                                不能輸入相同上課日期/時間
                                                                            </div>
                                                                            <?php if (!empty($row_detail['datetime'])) { ?>
                                                                                <a href="course_form.php?id=<?= $row_detail['id'?>" class="btn <? if ($row_detail['student_status'] == 1) { ?><? if ($row_detail['solution_status'] == 1) { ?>btn-success<? } else { ?>btn-warning<? ?><? } elseif ($row_detail['tutor_status'] == 1) { ?>btn-success<? } else { ?>btn-default<? ?>"><i class="fa fa-link" aria-hidden="true"></i>
                                                                                    課堂資料
                                                                                    <? if ($row_detail['student_status'] == 1) { ?>
                                                                                        (已投訴)
                                                                                        <? if ($row_detail['solution_status'] == 1) { ?>
                                                                                            (已解決)
                                                                                        <? ?>
                                                                                    <? } elseif ($row_detail['tutor_status'] == 1) { ?>
                                                                                        (已上課)
                                                                                    <? ?>
                                                                                </a>
                                                                            <?php ?>

                                                                        <? ?>
                                                                    <? } else { ?>
                                                                        <? if ($row_detail['datetime']) {

                                                                            
$end_datetime = new DateTime($row_detail['datetime']);
                                                                            
$end_datetime->modify("+" $order['course_length'] . " minute");
                                                                            
?>
                                                                            <table width="100%" border="0" cellpadding="0" cellspacing="0">
                                                                                <tr>
                                                                                    <td width="100%"><?= ($i 1?>
                                                                                        .
                                                                                        <?= $row_detail['datetime'] . " 至 " $end_datetime->format("Y-m-d H:i:s"?>
                                                                                    </td>
                                                                                    <?php  ?>
                                                                                    <td>
                                                                                        <div class="orderdetailbtn">
                                                                                            <? if ($order['status'] == 'paid') { ?>
                                                                                                <a href="course_form.php?id=<?= $row_detail['id'?>" class="btn <? if ($row_detail['student_status'] == 1) { ?><? if ($row_detail['solution_status'] == 1) { ?>btn-success<? } else { ?>btn-warning<? ?><? } elseif ($row_detail['tutor_status'] == 1) { ?>btn-success<? } else { ?>btn-default<? ?>"><i class="fa fa-link" aria-hidden="true"></i>
                                                                                                    課堂資料
                                                                                                    <? if ($row_detail['student_status'] == 1) { ?>
                                                                                                        (已投訴)
                                                                                                        <? if ($row_detail['solution_status'] == 1) { ?>
                                                                                                            (已解決)
                                                                                                        <? ?>
                                                                                                    <? } elseif ($row_detail['tutor_status'] == 1) { ?>
                                                                                                        (已上課)
                                                                                                    <? ?>
                                                                                                </a>
                                                                                            <? ?>
                                                                                        </div>
                                                                                    </td>
                                                                                    <?php  ?>
                                                                                </tr>
                                                                            </table>
                                                                        <? } else { ?>
                                                                            <?= ($i 1?>
                                                                            . -
                                                                        <? ?>
                                                                    <? ?>
                                                                </div>
                                                            <? ?>
                                                        <? } else if ($order['order_type'] == 'try' || $order['order_type'] == 'course') { ?>
                                                            <? foreach ($rows_detail as $i => $row_detail) {
                                                                
$end_datetime = new DateTime($row_detail['datetime']);
                                                                if (
$order['order_type'] == 'try') {
                                                                    
$end_datetime->modify("+" $order['course_length'] . " minute");
                                                                } else {
                                                                    
$end_datetime->modify("+" $row_job['course_hours'] . " minute");
                                                                }


                                                                
?>
                                                                <table width="100%" border="0" cellpadding="0" cellspacing="0">
                                                                    <tr>
                                                                        <td width="100%">
                                                                            <div>

                                                                                <?= ($i 1?>
                                                                                .
                                                                                <?= $row_detail['datetime'] . " 至 " $end_datetime->format("Y-m-d H:i:s"?>
                                                                            </div>
                                                                        </td>

                                                                        <?php ?>
                                                                        <td>
                                                                            <div class="orderdetailbtn">
                                                                                <? if ($order['status'] == 'paid') { ?>
                                                                                    <a href="course_form.php?id=<?= $row_detail['id'?>" class="btn <? if ($row_detail['student_status'] == 1) { ?><? if ($row_detail['solution_status'] == 1) { ?>btn-success<? } else { ?>btn-warning<? ?><? } elseif ($row_detail['tutor_status'] == 1) { ?>btn-success<? } else { ?>btn-default<? ?>"><i class="fa fa-link" aria-hidden="true"></i>
                                                                                        課堂資料
                                                                                        <? if ($row_detail['student_status'] == 1) { ?>
                                                                                            (已投訴)
                                                                                            <? if ($row_detail['solution_status'] == 1) { ?>
                                                                                                (已解決)
                                                                                            <? ?>
                                                                                        <? } elseif ($row_detail['tutor_status'] == 1) { ?>
                                                                                            (已上課)
                                                                                        <? ?>
                                                                                    </a>
                                                                                <? ?>
                                                                            </div>
                                                                        </td>
                                                                        <?php  ?>
                                                                    </tr>
                                                                </table>
                                                            <? ?>
                                                        <? ?>
                                                    </div>
                                                </td>
                                            </tr>
                                        <? ?>
                                        <?
                                            
if ($order['order_type'] == 'formal') {
                                                
$sql        "select mas_instrument from student_postjob as tt where id = ? and deleted = ?";
                                                
$parameters = array($order['job_id'], 0);
                                                
$row_job    bind_pdo($sql$parameters"selectone");
                                                if (
$order['course_venus'] == 6) {
                                                    
$sql           "select studenhome_addcharge as fee from tutor_teachareacode as tt where mas_teachareacode = ? and tutormain_id = ? and deleted = ?";
                                                    
$parameters    = array($order['mas_residencecode'], $order['tutormain_id'], 0);
                                                    
$row_addcharge bind_pdo($sql$parameters"selectone");
                                                }
                                                
$sql        "select id from tutor_charge as tt where tutormain_id = ? and mas_instrument = ? and deleted = ?";
                                                
$parameters = array($order['tutormain_id'], $row_job['mas_instrument'], 0);
                                                
$row_charge bind_pdo($sql$parameters"selectone");

                                                
$sql              "select charge_" $order['course_length'] . "min as fee from tutor_expectcharge where type = ? and charge_id = ? and grade = ? and deleted = ?";
                                                
$parameters       = array('tfee'$row_charge['id'], $order['level'], 0);
                                                
$row_expectcharge bind_pdo($sql$parameters"selectone");

                                                
$jsonReturnArr['fee_min'] = (intval($row_expectcharge['fee']) + intval($row_addcharge['fee'])) * 0.8;
                                                
$jsonReturnArr['fee_max'] = (intval($row_expectcharge['fee']) + intval($row_addcharge['fee'])) * 1.2;

                                            }
                                        
?>
                                        <? if ($order["order_type"] != 'course') { ?>
                                            <tr>
                                                <td width="120" align="right" valign="top" class=''>每堂上課費用
                                                    <? if ($row_profile['profile_id'] == 3) { ?>
                                                        <br>
                                                        ($
                                                        <?= $jsonReturnArr['fee_min'?>
                                                        ~ $
                                                        <?= $jsonReturnArr['fee_max'?>
                                                        )
                                                    <? ?></td>
                                                <td width="5" valign="top" class=''>:&nbsp;</td>
                                                <td class=''>
                                                    <div class="col-sm-4 form-group">
                                                        <? if ($order['order_type'] == 'formal' && $order['status'] == 'process' && $_SESSION["is_tutor"] == 1) { ?>
                                                            $
                                                            <input type="text" class="form-control" name="fee" value="<?= $order['fee'] ? intval($order['fee']) : '' ?>" style="width:50%; display:inline-block;" min="<?= $jsonReturnArr['fee_min'?>" max="<?= $jsonReturnArr['fee_max'?>">
                                                            <br>
                                                            <font color="#0012ff" style="font-size:12px; ">每堂學費按導師於iMusicCircle內所訂立的收費作指標,導師可按個別學生的情況調整學費,調整幅度為
                                                                +/- 20%。我們建議導師先跟學生議定價格。</font>

                                                            <div style="color:#F00; display:none;" class="error" id="feeError">
                                                                請輸入每堂收費
                                                            </div>
                                                            <div style="color:#F00; display:none;" class="error" id="feeError2">
                                                                請輸入每堂收費不能少於<span></span></div>
                                                            <div style="color:#F00; display:none;" class="error" id="feeError3">
                                                                請輸入每堂收費不能多於<span></span></div>
                                                            <div style="color:#F00; display:none;" class="error" id="feeError4">
                                                                請先選擇地區/地方/級數/時間長度
                                                            </div>
                                                        <? } else { ?>
                                                            $<?= intval($order['fee']) ?>
                                                        <? ?>
                                                    </div>
                                                </td>
                                            </tr>
                                        <? ?>
                                        <? if ($order['order_type'] == 'try') { ?>
                                            <tr>
                                                <td width="120" align="right" valign="top" class=''>每堂上門附加費</td>
                                                <td width="5" valign="top" class=''>:&nbsp;</td>
                                                <td class=''>
                                                    <div class="col-sm-12 form-group"> $
                                                        <?= intval($order['extra_fee']) ?>.00
                                                    </div>
                                                </td>
                                            </tr>
                                        <? ?>
                                        <tr>
                                            <td width="120" align="right" valign="top" class=''>總費用</td>
                                            <td width="5" valign="top" class=''>:&nbsp;</td>
                                            <td class=''>
                                                <div class="col-sm-12 form-group" id="totalbox">
                                                    <? if ($row_profile['profile_id'] != 3) { ?>
                                                        <span <? if (intval($order['admin_fee'])) { ?> style="text-decoration:line-through;"<? ?>>
                                                            <? if (intval($order['coupon_fee']) > 0) { ?>
                                                                <span style="text-decoration:line-through;">
                                                                $<?= intval($order['total_fee']) ?>.00</span><? ?>
                                                            $<?= intval($order['total_fee']) - intval($order['coupon_fee']) ?>
                                                            .00 </span>
                                                    <? } else { ?>
                                                        <span> $<?= intval($order['total_fee']) ?>
                                                        </span>
                                                    <? ?>
                                                </div>
                                            </td>
                                        </tr>
                                        <? if ((intval($order['admin_fee']) == && $order['order_type'] == 'try') || $order['order_type'] == 'formal') { ?>

                                            <? if ($row_profile['profile_id'] != && ($order['order_type'] == 'try' || $order['order_type'] == 'formal')) { ?>
                                                <? /*if ($order['status'] == 'approved' || $order['status'] == 'paid') { ?>
                                                    <tr>
                                                        <td width="120" align="right" valign="top" class=''>優惠劵</td>
                                                        <td width="5" valign="top" class=''>:&nbsp;</td>
                                                        <td class=''>
                                                            <? if ($order['status'] == 'paid') { ?>
                                                                <div class="col-sm-12 form-group">
                                                                    $ <?= $order['coupon_fee'] ?> (<?= $order['coupon_code'] ?>)
                                                                </div>
                                                            <? } else if ($order['status'] == 'approved') { ?>
                                                                <div class="col-sm-2 form-group" id="couponbox2" <? if (!$order['coupon_code']){ ?>style="display:none;"<? } ?>>
                                                                    - $ <span>
                                                                        <?= intval($order['coupon_fee']) ?>
                                                                    </span></div>
                                                                <div id="couponbox1" <? if ($order['coupon_code']){ ?>style="display:none;"<? } ?>>
                                                                    <div class="col-sm-2 form-group">
                                                                        <input name="coupon" class="form-control" placeholder="如有" value="" maxlength="10">
                                                                        <div style="color:#F00; display:none;" class="error" id="couponError">
                                                                            <?= _lang('請輸入正確的優惠劵號碼') ?>
                                                                        </div>
                                                                        <div style="color:#F00; display:none;" class="error" id="couponError2">
                                                                            *$20優惠已滿額,多謝支持。有興趣學習音樂的同學,可以輸入 "INKY50"
                                                                            以半價體驗兩堂音樂班。
                                                                        </div>
                                                                    </div>
                                                                    <button type="button" class="btn btn-block btn-success " id="LiCouponBtn">
                                                                        <i class="glyphicon glyphicon-ok-sign" aria-hidden="true"></i>
                                                                        <?= _lang('確認優惠劵') ?>
                                                                    </button>
                                                                </div>
                                                            <? } ?>
                                                        </td>
                                                    </tr>
                                                <? } */
?>
                                            <? ?>
                                        <? ?>
                                        <? if ($row_profile['profile_id'] == || $row_profile['profile_id'] == 2) { ?>
                                            <tr>
                                                <td width="120" align="right" valign="top" class=''>調整價格</td>
                                                <td width="5" valign="top" class=''>:&nbsp;</td>
                                                <td class=''>
                                                    <div class="col-sm-4 form-group">$
                                                        <input type="text" class="form-control" name="admin_fee" style="width:90%; display:inline-block;" value="<?= $order['admin_fee'?>">
                                                    </div>
                                                </td>
                                            </tr>
                                        <? ?>
                                    </table>
                                    <!-- End Content -->
                                    <br><br><br><br>
                                </div>
                                <!-- /.box-body -->
                            </div>
                            <!-- /.box -->
                        </div>
                        <!-- /.col -->
                    </div>
                    <!-- /.row -->
                </form>
            </div>
        </div>
    </div>
</div>
<? include('_footer.php'?>
<script type="text/javascript" src="webadmin/js/jquery-ui-1.11.4/jquery-ui.min.js"></script>
<link rel="stylesheet" href="webadmin/js/jquery-ui-1.11.4/jquery-ui.min.css">
<script type="text/javascript" src="webadmin/js/jquery-ui-sliderAccess.js"></script>
<script type="text/javascript" src="webadmin/js/jquery-ui-timepicker-addon.js"></script>
<link type="text/css" href="webadmin/css/jquery-ui-timepicker-addon.css" rel="stylesheet"/>
<script type="text/javascript">
    $(function () {
        var opt = {
            //
            dayNames: ["星期日", "星期一", "星期二", "星期三", "星期四", "星期五", "星期六"],
            dayNamesMin: ["日", "一", "二", "三", "四", "五", "六"],
            monthNames: ["一月", "二月", "三月", "四月", "五月", "六月", "七月", "八月", "九月", "十月", "十一月", "十二月"],
            monthNamesShort: ["一月", "二月", "三月", "四月", "五月", "六月", "七月", "八月", "九月", "十月", "十一月", "十二月"],
            prevText: "上月",
            nextText: "次月",
            weekHeader: "週",
            timeOnlyTitle: "選擇時分秒",
            timeText: "時間",
            hourText: "時",
            minuteText: "分",
            secondText: "秒",
            millisecText: "毫秒",
            timezoneText: "時區",
            currentText: "現在時間",
            closeText: "確定",
            amNames: ["上午", "AM", "A"],
            pmNames: ["下午", "PM", "P"],
            //
            dateFormat: 'yy-mm-dd',
            stepMinute: 5,
            minDate: new Date(2016, 9, 1),
            timeFormat: 'HH:mm:ss',
            hourMin: 9,
            hourMax: 22,
            //minDate: 0
        };
        $(".datetimepicker").datetimepicker(opt);
    });
</script>
<script type="text/javascript">
    function printDiv(divName) {
        $('.orderdetailbtn').hide();
        var printContents = document.getElementById(divName).innerHTML;
        var originalContents = document.body.innerHTML;

        document.body.innerHTML = printContents;

        window.print();
        $('.orderdetailbtn').show();
        document.body.innerHTML = originalContents;
    }
    function submitfrom() {
        var table = $('#myform');
        var error = false;
        $('.error').hide();
        <? if($order['status'] != 'paid' && ($row_profile['profile_id'] == || $row_profile['profile_id'] == 2)){ ?>
        if (error == false) {
            table.submit();
        }
        <? }else{ ?>
        <? if($order['status'] == 'paid'){?>
        $('.datetimepicker').each(
            function (index) {
                var value = $(this).val();
                var count = 0;
                if (!$(this).val()) {
                    $('#dateError' + index + '_1').show();
                    error = true;
                } else {
                    $('.datetimepicker').each(
                        function () {
                            if (value == $(this).val()) {
                                count++;
                            }
                        }
                    );
                    if (count > 1) {
                        $('#dateError' + index + '_2').show();
                        error = true;
                    }
                }
            }
        );
        if (error == false) {
            table.submit();
        }
        <? }else if($order['status'] == 'process'){?>
        <?php if($order["order_type"] == "formal"){ ?>
        if (!$('input[name="fee"]', table).val()) {
            error = true;
            $('#feeError', table).show();
        } else {
            if (!($('input[name="fee"]', table).attr('min') && $('input[name="fee"]', table).attr('max'))) {

                error = true;
                $('#feeError4', table).show();

            } else {
                if (Number($('input[name="fee"]', table).val()) < Number($('input[name="fee"]', table).attr('min'))) {
                    error = true;
                    $('#feeError2 span', table).html($('input[name="fee"]', table).attr('min'));
                    $('#feeError2', table).show();
                } else if (Number($('input[name="fee"]', table).val()) > Number($('input[name="fee"]', table).attr('max'))) {
                    error = true;
                    $('#feeError3 span', table).html($('input[name="fee"]', table).attr('max'));
                    $('#feeError3', table).show();
                }
            }
        }<?php ?>
        if (error == false) {
            table.submit();
        }
        <? }?>
        <? }?>
        return false;
    }
    $('input[name="fee"]').change(
        function () {
            $('#totalbox span').html($('input[name="fee"]').val() *<?= $order['course_count'?>);
        }
    );
    $('#LiCouponBtn').click(
        function () {
            var error = false;
            $('#couponError').hide();
            $('#couponError2').hide();
            if (!$('input[name="coupon"]').val()) {
                error = true;
                $('#couponError').show();
            }
            if (error == false) {
                var coupon_code = $('input[name="coupon"]').val();
                jQuery.ajax({
                    url: '_ajax.php',
                    type: 'POST',
                    data: {
                        ajax: "coupon",
                        id: <?=$order['id']?>,
                        limit_type: '<?=$order["order_type"] == 'formal' 'normal' 'try'?>',
                        coupon: coupon_code
                    },
                    dataType: 'html', //dataType (default: Intelligent Guess (xml, json, script, or html))
                    timeout: 1000,
                    error: function (result) {
                        //alert('Error Occur. Please try again.');
                        //console.log(result.responseText);
                    },
                    success: function (json) {
                        var json = JSON.parse(json);
                        if (json.status == false) {
                            if (coupon_code.toUpperCase() == "INKY20" || coupon_code.toUpperCase() == "IMC$20") {
                                $('#couponError2').show();
                            } else {
                                $('#couponError').show();
                            }

                        } else if (json.status == true) {
                            location.reload();
                            return;
                            $('#totalbox span').html(json.total);
                            $('#couponbox2').show();
                            $('#couponbox2 span').html(json.discount);
                            $('#couponbox1').hide();
                        }
                        console.log(json);
                    }
                });
            }
        }
    );

</script>
</body>
</html>