
<div class="mobile-banner-wrap relative" bis_skin_checked="1">
    <div class="layer" bis_skin_checked="1"></div>
    <img class="mobile-banner" src="assets/images/b-2-mobile.jpg">
</div>

<div id="parallax-wrap" class="parallax-search" data-parallax="scroll" data-position="top" data-bleed="10" data-image-src="/munch/assets/images/b-2.jpg" bis_skin_checked="1">

    <div class="search-wraps" bis_skin_checked="1">
        <h1>Profile</h1>
        <p>Manage your profile,address book, credit card and more</p>
    </div> <!--search-wraps-->

</div> <!--parallax-container--><input type="hidden" value="PH" name="mobile_country_code" id="mobile_country_code">
<div class="sections section-grey2 section-profile" bis_skin_checked="1">
    <div class="container" bis_skin_checked="1">

        <div class="row" bis_skin_checked="1">
        <?php if($this->session->flashdata('success')){ ?>
                <div class="alert alert-success">
                    <?= $this->session->flashdata('success')?>.
                </div>
            <?php } ?>
            <?php if($this->session->flashdata('error')){ ?>
                <div class="alert alert-danger">
                     <?= $this->session->flashdata('error')?>.
                </div>
            <?php } ?>
            <div class="col-md-8 " bis_skin_checked="1">

                <div class="tabs-wrapper" bis_skin_checked="1">
                    <ul id="tabs">
                        <li class="active" id="profile">
                            <i class="ion-android-contact"></i> <span>Profile</span>
                        </li>

                        <li class="address-book" id="address-book">
                            <i class="ion-ios-location-outline"></i> <span>Address Book</span>
                        </li>

                        <li id="order"><i class="ion-ios-book-outline"></i>
                            <span>Order History</span>
                        </li>

                        <?php if($_SESSION['settings']['merchant_tbl_book_disabled'] != 2) { ?>
                        <li>
                            <i class="ion-ios-bookmarks-outline "></i> <span>Booking History</span>
                        </li>
                        <?php } ?>
                        <li class="" id="credit" >
                            <i class="ion-card"></i> <span>Credit Cards</span>
                        </li>


                    </ul>

                    <ul id="tab">
                        <li class="active">

                            <div class="box-grey rounded" style="margin-top:0;" bis_skin_checked="1">

                                <form id="forms" class="forms has-validation-callback" method="POST" action="<?php echo base_url('profile') ?>">

                                    <div class="row bottom10" bis_skin_checked="1">
                                        <div class="col-md-6" bis_skin_checked="1">
                                            <p class="text-small">First Name</p>
                                            <input class="grey-fields full-width" data-validation="required" type="text" value="<?= @$response['details']['data']['first_name']; ?>" name="first_name" id="first_name">
                                        </div>
                                        <div class="col-md-6" bis_skin_checked="1">
                                            <p class="text-small">Last Name</p>
                                            <input class="grey-fields full-width" data-validation="required" type="text" value="<?= @$response['details']['data']['last_name']; ?>" name="last_name" id="last_name">  </div>
                                    </div> <!--row-->


                                    <div class="row bottom10" bis_skin_checked="1">
                                        <div class="col-md-6" bis_skin_checked="1">
                                            <p class="text-small">Email address</p>
                                            <input class="grey-fields full-width" data-validation="required" disabled="disabled" type="text" value="<?= @$response['details']['data']['email_address']; ?>" name="email" id="email">
                                        </div>
                                        <div class="col-md-6" bis_skin_checked="1">
                                            <p class="text-small">Contact phone</p>
                                            <div class="intl-tel-input" bis_skin_checked="1">
                                                <input class="grey-fields full-width mobile_inputs" data-validation="required" type="text" value="<?= @$response['details']['data']['contact_phone']; ?>" name="contact_phone" id="contact_phone" autocomplete="off">
                                            </div>
                                        </div>
                                    </div> <!--row-->



                                    <div class="row" bis_skin_checked="1">
                                        <div class="col-md-6" bis_skin_checked="1">
                                            <input type="submit" value="Save" class="green-button medium">
                                        </div>
                                    </div>


                                </form>
                            </div><!--box-->

                            <!--Change password-->
                            <div class="box-grey rounded" style="margin-top:0;" bis_skin_checked="1">
                           <form method="post" action="site/Changepassword">
                            <div class="row bottom10" bis_skin_checked="1">
                                <div class="col-md-6" bis_skin_checked="1">
                                    <p class="text-small">Current Password</p>
                                    <input class="grey-fields full-width" type="password" value="" name="current_password" id="current_password">  </div>
                                <div class="col-md-6" bis_skin_checked="1">
                                    <p class="text-small">New Password</p>
                                    <input class="grey-fields full-width" type="password" value="" name="password" id="password">  </div>
                                <div class="col-md-6" bis_skin_checked="1">
                                    <p class="text-small">Confirm Password</p>
                                    <input class="grey-fields full-width" type="password" value="" name="cpassword" id="cpassword">  </div>
                            </div> <!--row-->
                               <div class="row" bis_skin_checked="1">
                                   <div class="col-md-6" bis_skin_checked="1">
                                       <input type="submit" value="Changepassword" class="green-button medium">
                                   </div>
                               </div>
                           </form>
                            </div><!--End Change password-->

                        </li>
                        <li class="">

                            <div class="box-grey rounded section-address-book" style="margin-top:0;" bis_skin_checked="1">



                                <div class="bottom10 top10" bis_skin_checked="1">
                                    <a class="green-button inline rounded" href="<?= base_url('addressbook') ?>">
                                        Add New</a>
                                </div>

                                <table id="table_address" class="table table-striped">
                                    <thead>
                                    <tr>
                                        <th width="40%" >Address</th>
                                        <th >Location Name</th>
                                        <th >Default</th>
                                    </tr>
                                    <?php
                                    if(isset($addresslist['data'])){
                                    foreach ($addresslist['data'] as $a) { ?>
                                        <tr>
                                            <td><?= $a['address']; ?>
                                                <div class="options">
                                                <a class="edit_addressbook" href="addressbook?id=<?= $a['id']; ?>"><i style="font-size: 25px;" class="ion-ios-compose-outline"></i></a>
                                                <a href="addressbook/deleteaddressbook?id=<?= $a['id']; ?>" class="delete_addressbook"><i style="font-size: 25px;" class="ion-ios-trash"></i></a>
                                                </div>
                                            </td>
                                            <td ><?= $a['location_name']; ?></td>
                                            <td ><?= (isset($a['as_default']) && $a['as_default']==2)?'<i class="fa fa-check"></i>':'<i class="fa fa-times"></i>'; ?></td>
                                        </tr>
                                    <?php }}else{
                                        echo "<tr><td  colspan='3'>No data available in table</td></tr>";
                                    } ?>
                                    </thead>
                                    <tbody>
                                    </tbody>
                                </table>
                            </div> <!--box-grey-->       </li>
                        <li class="">
                            <div class="box-grey rounded section-order-history" style="margin-top:0;" bis_skin_checked="1">

                                <div class="bottom10" bis_skin_checked="1">
                                    <div class="section-label" bis_skin_checked="1">
                                        <a class="section-label-a">
	                               <span class="bold">
	                                   Your Recent Order</span>
                                            <b></b>
                                        </a>
                                    </div>
                                </div>
                                <?php if(isset($OrderList['data'])) {?>
                                <table class="table table-striped">
                                    <?php foreach($OrderList['data'] as $order ) { 
                                    
                                    ?>
                                    <tr class="tr_mobile">
                                        <td><div class="mytable"><div class="mycol" style="width: 10%;">
                                                    <i style="font-size: 30px;" class="ion-android-arrow-dropright"></i></div><div class="mycol"><div class="mycol ">

                                                        <a href="javascript:;" onclick="viewReceipt(<?= $order['order_id']; ?>)" class="view-receipt-front" data-id=" <?= $order['order_id']; ?>">
                                                            <p>Order#  <?= $order['order_id']; ?></p>
                                                        </a>
                                                        <a href="javascript:;" onclick="addReview(<?= $order['order_id']; ?>)" class="view-receipt-front" >
                                                            <p><?= $order['review_tab']; ?></p>
                                                        </a>

                                                        <p>Placed on
                                                        </p>
                                                        <?= $order['date_created']; ?><p></p>
                                                    </div></div></div>
                                            <td><a class="add-to-cart" href="javascript:;" data-id="<?= $order['order_id']; ?>">
                                                <p><?= $order['merchant_name']; ?></p>
                                            </a></td>
                                            <td><p>TOTAL</p><p><?= $order['total_w_tax']; ?></p> </td>
                                            <td><p>PAYMENT</p><p><?= $order['payment_type']; ?> </p> </td>
                                            <td><a href="javascript:;" class="view-order-history" data-id="<?= $order['order_id']; ?>">
                                                    <p class="green-text top10 "><?= $order['status']; ?></p>
                                                </a></td>
                                    </tr>
                                    <?php } ?>
                                </table>
                                    <?php }else {?>
                                <p class="text-danger">No order history</p>
                                    <?php } ?>

                            </div> <!--box-grey-->
                        </li>
                        
                        <?php if($_SESSION['settings']['merchant_tbl_book_disabled'] != 2) { ?>
                        <li class="">

                            <div class="box-grey rounded section-order-history" style="margin-top:0;">

                                <div class="bottom10">
                                    <div class="section-label">
                                        <a class="section-label-a">
                                            <span class="bold"> Your Recent Booking</span>
                                            <b></b>
                                        </a>
                                    </div>
                                </div>

                                <table class="table table-striped">
                                    <tbody>
                          <?php if(isset($bookingList['data'])){
                              foreach ($bookingList['data'] as $b){
                                  ?><tr class="tr_mobile">
                                      <td>
                                          <div class="mytable">
                                              <div class="mycol" style="width: 10%;"><i style="font-size: 30px;" class="ion-android-arrow-dropright"></i></div>
                                              <div class="mycol ">

                                                  <a href="javascript:;" onclick="bookingDetails(<?= $b['booking_id']; ?>)" >
                                                      <p>Booking ID# <?= $b['booking_id']; ?></p>
                                                  </a>

                                                      <p>No of guest# <?= $b['number_guest']; ?></p>

                                                  <p>Book on
                                                      <?= $b['stic_date_created']; ?></p>
                                              </div>
                                          </div>
                                      </td>

                                      <td>
                                          <p></p>
                                      </td>


                                      <td>
                                          <a href="javascript:;" class="view-order-history" data-id="<?= $b['booking_id']; ?>">
                                              <p class="green-text top10 "> <?= $b['status_raw']; ?></p>
                                          </a>
                                      </td>
                                  </tr>

                                  <?php
                              }
                          } else{?>

                                    <tr class="order-order-history show-history-6">
                                        <td colspan="5">
                                            <p class="text-danger small-text">No history found</p>
                                        </td>
                                    </tr>
                            <?php } ?>
                                    </tbody>
                                </table>


                            </div>   </li>
                            
                            <?php } ?>
                        <li class="">


                            <div class="box-grey rounded section-credit-card" style="margin-top:0;" bis_skin_checked="1">

                                <div class="bottom10 top10" bis_skin_checked="1">
                                <a class="green-button inline rounded" href="<?= base_url('credit_card') ?>">
                                        Add New</a>
                                </div>

                                <table id="table_credit" class="table table-striped">
                                    <thead>
                                    <tr>
                                        <th width="40%" >Card Name</th>
                                        <th >Card Number</th>
                                        <th >Expiration</th>
<!--                                        <th >Action</th>-->
                                    </tr>
                                    <?php if(isset($creditlist['data'])){
                                        foreach ($creditlist['data'] as $c){ ?>
                                            <tr>
                                                <td><?= $c['card_name']; ?>
                                                    <div class="options">
                                                        <a class="edit_credit" href="creditcard?id=<?= $c['id']; ?>"><i style="font-size: 25px;" class="ion-ios-compose-outline"></i></a>
                                                        <a href="creditcard/deletecredit?id=<?= $c['id']; ?>" class="delete_credit"><i style="font-size: 25px;" class="ion-ios-trash"></i></a>
                                                    </div>
                                                </td>
                                                <td ><?= $c['credit_card_number']; ?></td>
                                                <td ><?= $c['expiry_date']; ?></td>
                                            </tr>
                                        <?php }
                                    } else{
                                        echo "<tr><td  colspan='3'>No data available in table</td></tr>";
                                    } ?>
                                    </thead>
                                    <tbody>
                                    </tbody>
                                </table>
                                <div class="clear" bis_skin_checked="1"></div>

                            </div>
                        </li>

                    </ul>
                </div> <!--tabs-wrapper-->


            </div> <!--col-->

            <div class="col-md-4 avatar-section" bis_skin_checked="1">
                <div class="box-grey rounded" style="margin-top:0;" bis_skin_checked="1">

                    <div class="avatar-wrap" bis_skin_checked="1">
                        <img src="<?= @$response['details']['data']['avatar']; ?>" class="img-circle">
                    </div> <!--center-->

                    <!--<div class="center top10">
                    <a href="javascript:;" id="uploadavatar">Browse</a>
                    </div>
                    <DIV  style="display:none;" class="uploadavatar_chart_status" >
                      <div id="percent_bar" class="uploadavatar_percent_bar"></div>
                      <div id="progress_bar" class="uploadavatar_progress_bar">
                        <div id="status_bar" class="uploadavatar_status_bar"></div>
                      </div>
                    </DIV>-->

                    <div class="center top10" bis_skin_checked="1">
                       <!--  <input name="uploadfile1" type="file" onchange="profileImg(this)" style="display: none"/>
                        <label for="uploadfile" data-progress="single_uploadfile_progress" data-preview="avatar-wrap" style="cursor: pointer;"> -->
                           <!--  Browse</label> -->
                           <input type="file" name="profile" class="custom-file-input profileImg" id="validatedCustomFile"  style="display: none" onchange="profileImg(this)">
                            <label class="custom-file-label" for="validatedCustomFile"><span>Browse</span></label>

                    </div>

                    <div class="single_uploadfile_progress" bis_skin_checked="1"></div>

                    <div class="line-top line-bottom center" bis_skin_checked="1">
                        Update your profile picture          </div>
                    <div class="modal fade" id="receiptmodal" role="dialog">

                    </div>
                    <div class="modal fade" id="addreviewmodal" role="dialog">

                    </div>
                    <div class="modal fade" id="bookingtablemodal" role="dialog">

                    </div>
                </div>
            </div> <!--col-->

        </div> <!--row-->
    </div> <!--container-->
</div> <!--sections-->

<script src="https://cdn.datatables.net/1.10.19/js/jquery.dataTables.min.js" crossorigin="anonymous"></script>
<script src="https://cdn.jsdelivr.net/npm/datatables.net-bs4@1.10.19/js/dataTables.bootstrap4.min.js" crossorigin="anonymous"></script>
<script src="https://cdn.datatables.net/responsive/2.2.3/js/dataTables.responsive.min.js" crossorigin="anonymous"></script>
<script src="https://cdn.datatables.net/responsive/2.2.3/js/responsive.bootstrap.min.js" crossorigin="anonymous"></script>

<script>
    $("ul#tabs li").click(function(e){
        if ( $(this).hasClass("noclick") ){
            return;
        }
        if (!$(this).hasClass("active")) {
            var tabNum = $(this).index();
            var nthChild = tabNum+1;
            $("ul#tabs li.active").removeClass("active");
            $(this).addClass("active");
            $("ul#tab li.active").removeClass("active");
            $("ul#tab li:nth-child("+nthChild+")").addClass("active");
        }
        
    });





    function viewReceipt(order_id) {
        $.ajax({
            type: "POST",
            url: 'order/view_receipt',
            data: {order_id:order_id},
            success: function(html){
                 $('#receiptmodal').modal('show');
                 $('#receiptmodal').html(html);
            },
            error: function(){

            }
        });
    }





    $( document ).on( "click", ".add-to-cart", function() {
        var id=$(this).data("id");
        var a=confirm("Add your recent order to cart?");
        if (a){
            $.ajax({
                type: "POST",
                url: 'order/reorder',
                data: {id:id},
                success: function(data){
                    window.location.href= "menu";
                }
            });
        }
    });


    
</script>
