<?php include_once "template/common.php" ?>

<link href="<?php echo base_url();?>assets/libs/sweetalert2/sweetalert2.min.css" rel="stylesheet" type="text/css" />

<link rel="stylesheet" href="<?php echo base_url();?>files/assets/css/style.ed12.css">


<style type="text/css">
      
        .disabled-color {
            cursor: not-allowed;
            background: #d3d3d3 !important;
            border: #d3d3d3 !important;
        }
</style>

<div class="body-content">
    <div class="body-content-shape-one">
        <!-- <img class="d-sm-block d-none object-point-none" src="<?php echo base_url();?>files/assets/images/shape/body-shape-one.png" alt="shape"> -->
        <!-- <img class="d-sm-none object-point-none" src="<?php echo base_url();?>files/assets/images/shape/profile-mobile-bg.png" alt="shape"> -->
    </div>
    
    <div class="top-area d-none d-lg-block">
        <div class="search-box d-flex flex-wrap align-items-center">
            <h3 class="title bg-white d-inline-block profile-title rounded">Profile</h3>
        </div>
    </div>

    <div class="user-wrapper mx-auto d-flex flex-wrap justify-content-center align-items-center mt-md-4 mb-md-4 mb-3">
        <div class="user-thumb d-none d-md-block">
            <!-- <img src="<?php echo base_url();?>files/assets/images/thumb/user.png" alt="thumb"> -->
        </div>
        <div class="user-thumb-mobile d-md-none">
            <!-- <img src="<?php echo base_url();?>files/assets/images/thumb/mobile-user.png" alt="thumb"> -->
        </div>

        <div class="user-content text-center text-md-start me-3">
            <p class="fs--16px d-md-none text-white"><?php echo $userdata['email'];?> || ID : <?php echo $userdata['id'];?></p>
            <div class="d-none d-md-block">
                <ul class="user-info-list d-flex flex-wrap justify-content-center align-items-center gap-3">
                    <li class="text-white"><span class="pe-3"><img src="<?php echo base_url();?>files/assets/images/icon/user.png" alt="icon"></span> <?php echo $userdata['id'];?></li>
                    <li class="text-white"><span class="pe-3"><img src="<?php echo base_url();?>files/assets/images/icon/mail.png" alt="icon"></span> <?php echo $userdata['email'];?></li>
                </ul>
            </div>
        </div>
    </div>

       <?php $this->load->view('template/message.php');?>

    <ul class="nav mobile-order-filter d-lg-none">
        <li class="nav-item">
            <a href="" class="nav-link active" style="border-radius: 15px;" data-bs-toggle="tab" data-bs-target="#orders">Orders<span class="count-number"><?=count($order_list)?></span></a>
        </li>
        <li class="nav-item">
            <a href="" class="nav-link" style="border-radius: 15px;" data-bs-toggle="tab" data-bs-target="#orders-two">Packages<span class="count-number"><?=count($package_list)?></span></a>
        </li>

         <?php
                    $totalSel = 0;
                    if(!empty($getGuest->photo_url))
                    {
                        $totalSel = 1;
                    }

                    $finalTotal = count($getExtraFace) + $totalSel; 
                ?>

        <li class="nav-item">
            <a href="" class="nav-link" style="border-radius: 15px;" data-bs-toggle="tab" data-bs-target="#orders-three">Selfies<span class="count-number"><?=$finalTotal?></span></a>
        </li>
    </ul>
    <div class="order-listing d-lg-none">
        <div class="tab-content">
            <div class="tab-pane fade show active" id="orders">

                <?php 
                if(count($order_list) > 0)
                {
                  foreach($order_list as $key => $val)
                  {
                ?>
                <div class="pricing-item">
                    <div class="pricing-item__content">
                        <div class="top-content d-flex justify-content-between">
                            <div>
                                <p class="pricing-item__content-title mb-0"><span class="number-listing"><?=$key+1?></span> #<?php echo $val['orderID'];?></p>
                            </div>
                            <div class="pricing-item__icon">
                                <i class="las la-angle-down"></i>
                            </div>
                        </div>
                    </div>
                    <div class="pricing-collapse-content" style="display: none;">
                        <div class="d-flex justify-content-between mt-4">
                           
                            <div class="right-content">
                                <h6 class="title text--warning text--warning-two"><?php echo $val['currency'].' '.number_format($val['total_price'], 2)?></h6>
                            </div>
                        </div>
                        <div class="d-flex justify-content-between my-4">
                            <div class="left-content">
                                <h6 class="title mb-1">Delivery</h6>
                                <p class="mb-0"><?php
                                          if($val['isDelivery'] == 0)
                                          {
                                              echo "Pick Up";
                                          }
                                          else
                                          {
                                              echo "Delivery";
                                          }
                                      ?></p>
                            </div>
                            <div class="right-content">
                                <h6 class="title">Date</h6>
                                <p class="mb-0"><?php echo date("Y-n-j", strtotime($val["created_at"]));?></p>
                            </div>
                        </div>


                           <?php 
                                    if($val['is_paid']==0)
                                    { 
                                    ?>
                                            <div class="w-100 badge badge--three text-white" style="background: #BEDD5C;border: #BEDD5C;">Not Paid</div>
                                     <?php
                                    }

                                      else if($val['refund_status'] == 0){
                                        $curtimestamp = strtotime(date('Y-m-d H:i:s'));
                                        $createdtimestamp = strtotime($val['created_at']);
                                        $hour = abs($curtimestamp - $createdtimestamp)/(60*60);
                                      ?>
                                        <a href="javascript:;" class="w-100 badge badge--three text-white" style="background: #BEDD5C; border-color: #BEDD5C; color: black !important;" onclick="order_refund_func('<?php echo $val["id"];?>')">
                                                  Apply
                                         </a>
                                      <?php
                                         }else if($val['refund_status'] == 1){
                                      ?>

                                        <div class="w-100 badge badge--three text-white" style="background: #737f9e;border: #737f9e;">
                                                  Pending
                                        </div>

                                      <?php
                                         }else if($val['refund_status'] ==2){
                                      ?>

                                       <div class="w-100 badge badge--three text-white" style="background: #aa3939;border: #aa3939;">
                                                  Rejected
                                        </div>
                                        
                                      <?php
                                         }else if($val['refund_status'] == 3){
                                      ?>

                                        <div class=" w-100badge badge--three text-white" style="background: #BEDD5C;border: #BEDD5C;">
                                                  Approved
                                        </div>
                                         
                                      <?php
                                         }
                                      ?>
                                    



                    </div>
                </div>
            <?php }
                }
            ?>

            </div>
            <div class="tab-pane fade" id="orders-two">

                 <?php
                if(count($package_list) > 0)
                {
                    foreach($package_list as $key => $val)
                    {
                ?>

                <div class="pricing-item">
                    <div class="pricing-item__content">
                        <div class="top-content d-flex justify-content-between">
                            <div>
                                <p class="pricing-item__content-title mb-0"><span class="number-listing"><?=$key+1?></span> #<?php echo $val['id'];?></p>
                            </div>
                            <div class="pricing-item__icon">
                                <i class="las la-angle-down"></i>
                            </div>
                        </div>
                    </div>
                    <div class="pricing-collapse-content" style="display: none;">
                        <div class="d-flex justify-content-between mt-4">
                            <div class="left-content">
                                <h6 class="title mb-1">Package</h6>
                                <p class="mb-0"><?php echo $val['package'];?></p>
                            </div>
                            <div class="right-content">

                                <?php 
                                 if($val['refund_status'] == 0 || $val['refund_status'] == 2)
                                 {
                                    if(date('Y-m-d', strtotime($val["from_date"])) <= date("Y-m-d") && date('Y-m-d', strtotime($val["to_date"])) >= date("Y-m-d"))
                                    {                                        
                                         echo '<a href="javascript:;" class="btn btn--outline-danger cmn--btn btn--sm w-100 btn--secondary text-center fw-normal" style="color: #55ac47;border: 1px solid #55ac47;">Active</a>';
                                    }
                                    else
                                    {
                                            echo '<a href="javascript:;" class="btn btn--outline-danger cmn--btn btn--sm w-100 btn--secondary text-center fw-normal">Inactive</a>';
                                    }
                                 }
                                 else
                                 {
                                     echo '<a href="javascript:;" class="btn btn--outline-danger cmn--btn btn--sm w-100 btn--secondary text-center fw-normal">Inactive</a>';
                                 }
                              ?> 

                                
                            </div>
                        </div>
                        <div class="d-flex justify-content-between mt-4">
                            <div class="left-content">
                                <h6 class="title mb-1">From</h6>
                                <p class="mb-0"><?php echo(date("Y-m-d", strtotime($val["from_date"]))); ?></p>
                            </div>
                            <div class="right-content">
                                <h6 class="title">To</h6>
                                <p class="mb-0"><?php echo(date("Y-m-d", strtotime($val["to_date"]))); ?></p>
                            </div>
                        </div>
                        <div style="margin-top: 10px;">

                            <?php                    
                                 if($val['refund_status'] == 0) {
                                     $curtimestamp = strtotime(date('Y-m-d H:i:s'));
                                     $createdtimestamp = strtotime($val['created_at']);
                                     $hour = abs($curtimestamp - $createdtimestamp)/(60*60);
                              ?> 
                              <a href="javascript:;" class="w-100 prevent_redirect" onclick="package_refund_func('<?php echo $val['txn_id'];?>')">
                                 <div class="w-100 badge badge--three text-white">
                                       Apply
                                 </div>
                              </a>
                              
                              <?php
                                 }else if($val['refund_status'] == 1){
                              ?>
                                    <div class="w-100 badge badge--three text-white" style="background: #737f9e;border: #737f9e;">
                                          Pending
                                    </div>
                                 
                              <?php
                                 }else if($val['refund_status'] == 2){
                              ?>
                                    <div class="w-100 badge badge--three text-white" style="background: #aa3939;border: #aa3939;">
                                          Rejected
                                    </div>
                                 
                              <?php
                                 }else if($val['refund_status'] == 3){
                              ?>
                                    <div class="w-100 badge badge--three text-white" style="background: #BEDD5C;border: #BEDD5C;">
                                          Approved
                                    </div>
                                 
                              <?php
                                 }  else {
                                 
                                 }
                             ?>
                        </div>
                        

                    </div>
                </div>
                <?php }
                }
                ?>


            
            </div>
            <div class="tab-pane fade" id="orders-three">
            <?php
                if($finalTotal < $TotalImageUpload)
                {
                                ?>
                <a style="width: 100%;margin-bottom: 10px;" class="badge badge--three text-white theme-button" href="<?=base_url('addface/'.$userdata['id'])?>">Add Selfie</a>

            <?php }
            ?>

                <?php
                $i = 1;
                if(!empty($getGuest->photo_url))
                {
                ?>

                <div class="pricing-item">
                    <div class="pricing-item__content">
                        <div class="top-content d-flex justify-content-between">
                            <div>
                                <p class="pricing-item__content-title mb-0"><span class="number-listing"><?=$i++?></span></p>
                            </div>
                            <div class="pricing-item__icon">
                                <i class="las la-angle-down"></i>
                            </div>
                        </div>
                    </div>
                    <div class="pricing-collapse-content collapse-content<?php echo $getGuest->id; ?>" style="display: none;">
                        <div class="mobile-user-thumb">
                            <img src="http://d38x82mkkml5o1.cloudfront.net/<?=$getGuest->photo_url?>" style="width: 85px;" alt="thumb">
                        </div>
                        <a onclick="guest_face_delete(<?php echo $getGuest->id; ?>)" class="btn cmn--btn w-100 text-center remove-bg-color guest_face_remove<?=$getGuest->id?>" >Remove</a>
                    </div>
                </div>
            <?php }
            ?>

           <?php
            foreach($getExtraFace as $e_value)
            {
            ?>

                <div class="pricing-item">
                    <div class="pricing-item__content">
                        <div class="top-content d-flex justify-content-between">
                            <div>
                                <p class="pricing-item__content-title mb-0"><span class="number-listing"><?=$i++?></span></p>
                            </div>
                            <div class="pricing-item__icon">
                                <i class="las la-angle-down"></i>
                            </div>
                        </div>
                    </div>
                    <div class="pricing-collapse-content collapse-content<?php echo $e_value->id; ?>" style="display: none;">
                        <div class="mobile-user-thumb">
                            <img src="http://d38x82mkkml5o1.cloudfront.net/<?=$e_value->photo_url?>" style="width: 85px;" alt="thumb">
                        </div>
                        <a onclick="extra_face_delete(<?php echo $e_value->id; ?>)" class="btn cmn--btn w-100 text-center remove-bg-color guest_face_remove<?=$e_value->id?>">Remove</a>
                    </div>
                </div>
            <?php }
            ?>

             
            </div>
        </div>
    </div>

    <div class="d-none d-lg-block bg-white mb-4 px-4 py-3 font-poppins" style="border-radius: 10px 10px 0 0;">
        <h5 class="mb-4">Online Purchased Packages</h5>
        <table class="table border-0 w-full table--responsive--md shadow-sm">
            <thead>
                <tr>
                    <th>Package name</th>
                    <th>From</th>
                    <th>To</th>
                    <th>Status</th>
                    <th>Refund</th>
                </tr>
            </thead>
            <tbody>
                  <?php
                if(count($package_list) > 0){
                    foreach($package_list as $key => $val){
                ?>
                <tr>
                        <td data-label="Package"><?php echo $val['package'];?></td>
                        <td data-label="From"><?php echo(date("Y-m-d", strtotime($val["from_date"]))); ?></td>
                        <td data-label="To"><?php echo(date("Y-m-d", strtotime($val["to_date"]))); ?></td>
                        <td data-label="Status">
                             <?php 
                                 if($val['refund_status'] == 0 || $val['refund_status'] == 2)
                                 {
                                    if(date('Y-m-d', strtotime($val["from_date"])) <= date("Y-m-d") && date('Y-m-d', strtotime($val["to_date"])) >= date("Y-m-d"))
                                    {                                        
                                         echo '<font color="#40dcfd">Active</font>';
                                    }
                                    else
                                    {
                                            echo '<font color="#f46a6a">Inactive</font>';
                                    }
                                 }
                                 else
                                 {
                                     echo '<font color="#f46a6a">Inactive</font>';
                                 }
                              ?> 
                        </td>
                        <td data-label="Refund">
                              <?php                    
                                 if($val['refund_status'] == 0) {
                                     $curtimestamp = strtotime(date('Y-m-d H:i:s'));
                                     $createdtimestamp = strtotime($val['created_at']);
                                     $hour = abs($curtimestamp - $createdtimestamp)/(60*60);
                              ?> 
                              <a href="javascript:;" class="prevent_redirect" onclick="package_refund_func('<?php echo $val['txn_id'];?>')">
                                 <div class="badge badge--three text-white">
                                       Apply
                                 </div>
                              </a>
                              
                              <?php
                                 }else if($val['refund_status'] == 1){
                              ?>
                                    <div class="badge badge--three text-white" style="background: #737f9e;border: #737f9e;">
                                          Pending
                                    </div>
                                
                              <?php
                                 }else if($val['refund_status'] == 2){
                              ?>
                                    <div class="badge badge--three text-white" style="background: #aa3939;border: #aa3939;">
                                          Rejected
                                    </div>
                                
                              <?php
                                 }else if($val['refund_status'] == 3){
                              ?>
                                    <div class="badge badge--three text-white" style="background: #BEDD5C;border: #BEDD5C;">
                                          Approved
                                    </div>
                                
                              <?php
                                 }  else {
                                     echo '-';
                                 }
                             ?>
                           </td>
                    </tr>

            
            <?php
                    }
                }
                else
                {
                    ?>

                    <tr>
                        <td data-label="Package">-</td>
                        <td data-label="From">-</td>
                        <td data-label="To">-</td>
                        <td data-label="Status">-</td>
                    </tr>

                    <?php
                }
                ?>
                
            </tbody>
        </table>
    </div>
    <div class="table-two-wrapper d-none d-lg-block" style="background: white; border-radius: 0 0 10px 10px;">
        <div class="row gy-4 gx-4">
            <div class="col-xxl-6">
                <div class="package-table shop-table rounded bg-white">
                    <h5 class="mb-4">Shop Order</h5>
                    <table class="table border-0 w-100 table--responsive--md shadow-sm">
                        <thead>
                            <tr>
                                <th>Order#</th>
                                <th>Date</th>
                                <th>Delivery</th>
                                <th>Price</th>
                                <th>Refund</th>
                            </tr>
                        </thead>
                        <tbody>
                             <?php 
                               if(count($order_list) > 0){
                                  foreach($order_list as $key => $val){
                            ?>
                            <tr>
                                <td data-label="Order#"><a href="javascript:;" onclick="view_detail_func('<?php echo $val['id'];?>', '<?php echo $val['isDelivery'];?>')" style="color: #212529;"><?php echo $val['orderID'];?></a></td>
                                <td data-label="Date"><?php echo date("Y-n-j", strtotime($val["created_at"]));?></td>
                                <td data-label="Delivery">
                                    <?php
                                          if($val['isDelivery'] == 0)
                                          {
                                              echo "Pick Up";
                                          }
                                          else
                                          {
                                              echo "Delivery";
                                          }
                                      ?>
                                </td>
                                <td data-label="Price"><?php echo $val['currency'].' '.number_format($val['total_price'], 2)?></td>
                                <td data-label="Refund">
                                     <?php 
                                    if($val['is_paid']==0)
                                    { 
                                    ?>
                                            <div class="badge badge--three text-white" style="background: #aa3939;border: #aa3939;">Not Paid</div>
                                     <?php
                                    }

                                      else if($val['refund_status'] == 0){
                                        $curtimestamp = strtotime(date('Y-m-d H:i:s'));
                                        $createdtimestamp = strtotime($val['created_at']);
                                        $hour = abs($curtimestamp - $createdtimestamp)/(60*60);
                                      ?>
                                        <a href="javascript:;" class="badge badge--three text-white" onclick="order_refund_func('<?php echo $val["id"];?>')">
                                                  Apply
                                         </a>
                                      <?php
                                         }else if($val['refund_status'] == 1){
                                      ?>

                                        <div class="badge badge--three text-white" style="background: #737f9e;border: #737f9e;">
                                                  Pending
                                        </div>

                                      <?php
                                         }else if($val['refund_status'] ==2){
                                      ?>

                                       <div class="badge badge--three text-white" style="background: #aa3939;border: #aa3939;">
                                                  Rejected
                                        </div>
                                        
                                      <?php
                                         }else if($val['refund_status'] == 3){
                                      ?>

                                        <div class="badge badge--three text-white" style="background: #BEDD5C;border: #BEDD5C;">
                                                  Approved
                                        </div>
                                         
                                      <?php
                                         }
                                      ?>
                                    

                                </td>
                            </tr>
                            <?php }
                            }
                            else
                            {
                                ?>
                                <tr>
                                    <td colspan="100%">No Order Data</td>
                                </tr>
                                <?php
                            }
                            ?>
                            
                        </tbody>
                    </table>
                </div>
            </div>
            <div class="col-xxl-6">
                <div class="package-table shop-table rounded bg-white">
                    <div style="display: grid; grid-template-columns: 50% 50%;">
                        <h5 class="mb-4">Selfies</h5>
                        <div style="text-align: right;">
                            <?php
                            if($finalTotal < $TotalImageUpload)
                            {
                                ?>
                                <a class="badge badge--three text-white" href="<?=base_url('addface/'.$userdata['id'])?>">Add Selfie</a>
                                <?php
                            }
                            ?>
                            
                        </div>
                    </div>
                    <table class="table border-0 w-100 mt-2 table--responsive--md shadow-sm">
                        <thead>
                            <tr>
                                <th>Face Number</th>
                                <th>Face</th>
                                <th>Action</th>
                            </tr>
                        </thead>
                        <tbody>
                            <?php
                            $i = 1;
                            if(!empty($getGuest->photo_url))
                            {
                            ?>
                            <tr>
                                <td data-label="Face Number"><?=$i++?></td>
                                <td data-label="File name">
                                    <img style="width: 100px;" src="http://d38x82mkkml5o1.cloudfront.net/<?=$getGuest->photo_url?>">
                                </td>
                                <td data-label="Action"><a onclick="guest_face_delete(<?php echo $getGuest->id; ?>)" class="badge text-white guest_face_remove<?=$getGuest->id?>"  style="background: #BEDD5C;cursor: pointer;r">Remove</a></td>
                                <!--<td data-label="Action"><a href="<?=base_url()?>account-profile-delete/<?=$getGuest->id?>?quest=true" class="badge text-white" style="background: #BEDD5C">Remove</a></td>-->
                            </tr>
                            <?php }
                            ?>

                            <?php
                            foreach($getExtraFace as $e_value)
                            {
                            ?>
                            <tr>
                                <td data-label="Face Number"><?=$i++?></td>
                                <td data-label="File name">
                                    <img style="width: 100px;" src="http://d38x82mkkml5o1.cloudfront.net/<?=$e_value->photo_url?>">
                                </td>
                                <td data-label="Action"><a onclick="extra_face_delete(<?php echo $e_value->id; ?>)" class="badge text-white guest_face_remove<?=$e_value->id?>" style="background: #BEDD5C;cursor: pointer;">Remove</a></td>
                                <!--<td data-label="Action"><a href="<?=base_url()?>account-profile-delete/<?=$e_value->id?>?quest=" class="badge text-white" style="background: #BEDD5C">Remove</a></td>-->
                            </tr>
                            <?php }
                            ?>
                        </tbody>
                    </table>
                </div>
            </div>          
        </div>
    </div>
</div>


<div class="modal fade" id="confirmRejectModal" tabindex="-1" aria-labelledby="exampleModalLabel" aria-hidden="true">
    <div class="modal-dialog modal-dialog-centered">
        <div class="modal-content bg-transparent border-0">
            <div class="modal-body p-0">
                <div class="popup-wrapper logout-modal">
                    <div class="text-center">
                        <img src="<?=base_url()?>files/assets/images/icon/alert.png" alt="thumb" class="mw-100">
                        <h4 class="mb-4 mb-sm-5 mt-4">Are You Sure ?</h4>
                    </div>
                    <a href="javascript:void(0)" id="" class="cmn--btn btn--lg d-block text-center mt-3 mt-sm-4 ConfirmAction">Confirm</a>
                    <a href="javascript:void(0)" data-bs-dismiss="modal" class="cmn--btn d-block text-center mt-3 active modal-cancel">Cancel</a>
                </div>
            </div>
        </div>
    </div>
</div>


<div class="modal fade" id="confirmRejectShopOrderModal" tabindex="-1" aria-labelledby="exampleModalLabel" aria-hidden="true">
    <div class="modal-dialog modal-dialog-centered">
        <div class="modal-content bg-transparent border-0">
            <div class="modal-body p-0">
                <div class="popup-wrapper logout-modal">
                    <div class="text-center">
                        <img src="<?=base_url()?>files/assets/images/icon/alert.png" alt="thumb" class="mw-100">
                        <h4 class="mb-4 mb-sm-5 mt-4">Are You Sure ?</h4>
                    </div>
                    <a href="javascript:void(0)" id="" class="cmn--btn btn--lg d-block text-center mt-3 mt-sm-4 ConfirmActionShopOrder">Confirm</a>
                    <a href="javascript:void(0)" data-bs-dismiss="modal" class="cmn--btn d-block text-center mt-3 active modal-cancel">Cancel</a>
                </div>
            </div>
        </div>
    </div>
</div>


 <div class="modal fade viewModal" tabindex="-1" role="dialog" aria-labelledby="exampleModalLabel" aria-hidden="true">
     <div class="modal-dialog modal-dialog-centered" role="document">
        <div class="modal-content" style="width: auto;">
           <div class="modal-header">
              <h5 class="modal-title" id="exampleModalLabel">Details</h5>
           </div>
           <div class="modal-body">
              <p class="mb-2">Order ID: <span class="text-primary" id="order_id"></span></p>
              <p class="mb-4">Shipping Method: <span class="text-primary" id="shipping_method"></span></p>
              <div class="table-responsive">
                 <table class="table table-centered table-nowrap">
                    <thead>
                       <tr>
                          <th scope="col">Merchandise</th>
                          <th scope="col">Title</th>
                          <th scope="col">Size</th>
                          <th scope="col">Price</th>
                       </tr>
                    </thead>
                    <tbody id="detail_tbody"></tbody>
                 </table>
              </div>
           </div>
           <div class="modal-footer">
              <button type="button" class="btn btn-secondary" data-bs-dismiss="modal">Close</button>
           </div>
        </div>
     </div>
  </div>



<script src="<?php echo base_url();?>files/assets/js/lib/jquery-3.6.0.min.js"></script>
<script src="<?php echo base_url();?>assets/libs/sweetalert2/sweetalert2.min.js"></script>


<script type="text/javascript">

       

    $('#confirmRejectModal').delegate('.ConfirmAction', 'click', function() {
          var txnID = $(this).attr('id');
          $.ajax({
                 method: "POST",
                 url: "<?php echo base_url();?>AccountController/package_refund",
                 data: {
                     txn_id: txnID
                 }
             })
             .done(function(data) {                        
                 var shtml = '';                        
                 if(data == 'success')
                 {
                        alert('Your refund request was received successfully!');
                        setTimeout("location.reload();", 1500);
                 }
             });
    });

     function package_refund_func(txnID)
     {
        $('.ConfirmAction').attr('id', txnID);
        $("#confirmRejectModal").modal('show');                
     }



    $('#confirmRejectShopOrderModal').delegate('.ConfirmActionShopOrder', 'click', function() {
            var ID = $(this).attr('id');
            $.ajax({
                 method: "POST",
                 url: "<?php echo base_url();?>AccountController/order_refund",
                 data: {
                     id: ID
                 }
             })
             .done(function(data) {
                 
                 var shtml = '';
                 
                 if(data == 'success'){
                     alert('Your refund request was received successfully!');
                     location.reload();
                 }
             });
    });

    function guest_face_delete(guest_id) {

        $('.guest_face_remove'+guest_id).html('Removing...');
        $('.collapse-content'+guest_id).removeClass('pricing-collapse-content');

        SiteDataStore('Remove Face', 'Remove Face');
        
        $.ajax({
                method: "POST",
                url: "https://makeabl.net/api/face_delete",
                data: {
                    guest_id: guest_id
                }
            })
            .done(function(msg) {
                setTimeout(function() {
                    window.location.reload();
                }, 1500);
            });
    };

    function extra_face_delete(extra_face_id) {
        $('.guest_face_remove'+extra_face_id).html('Removing...');
        $('.guest_face_remove'+extra_face_id).addClass('disabled-color');
        $('.guest_face_remove'+extra_face_id).prop("disabled", true); 
        
        $('.collapse-content'+extra_face_id).removeClass('pricing-collapse-content');
        
        $.ajax({
                method: "POST",
                url: "https://makeabl.net/api/face_delete?extra_face=true",
                data: {
                    guest_id: extra_face_id
                }
            })
            .done(function(msg) {
                setTimeout(function() {
                    window.location.reload();
                }, 1500);
            });
    };



     function order_refund_func(ID){
        $('.ConfirmActionShopOrder').attr('id', ID);
        $("#confirmRejectShopOrderModal").modal('show');     
     }



      function view_detail_func(order_id, isDelivery){
             $("#order_id").html(order_id);
             if(isDelivery == 0)
                 $("#shipping_method").html("Pick Up");
             else
                 $("#shipping_method").html("Delivery");
                 
             $.ajax({
                 method: "POST",
                 url: "<?php echo base_url();?>AccountController/get_order_info",
                 data: {
                     order_id: order_id
                 }
             })
             .done(function(data) {
                 var json_obj = JSON.parse(data);
                 
                 var shtml = '';
                 var sum = 0;
                 
                 if(json_obj.length > 0){
                     for(var i = 0; i < json_obj.length; i++){
                         shtml += '<tr>';
                         shtml += '    <th scope="row">';
                         shtml += '        <div>';
                         shtml += '            <img src="http://d38x82mkkml5o1.cloudfront.net/'+json_obj[i].comp_photo_url+'" alt="" class="avatar-sm">';
                         shtml += '        </div>';
                         shtml += '    </th>';
                         shtml += '    <td>';
                         shtml += '        <div>';
                         shtml += '            <h5 class="text-truncate font-size-14">'+json_obj[i].title+'</h5>';
                         shtml += '            <p class="text-muted mb-0">'+json_obj[i].symbol+' ';
                         if(json_obj[i].discount != 0){
                             var discount_price = json_obj[i].price * json_obj[i].discount / 100;
                             shtml += json_obj[i].price - discount_price;
                         }else{
                             shtml += json_obj[i].price;
                         }
                         shtml += ' x '+json_obj[i].quantity+'</p>';
                         shtml += '        </div>';
                         shtml += '    </td>';
                         shtml += '    <td></td>';
                         shtml += '    <td>'+json_obj[i].symbol+' ';
                         if(json_obj[i].discount != 0){
                             shtml += parseFloat((json_obj[i].price - discount_price)*json_obj[i].quantity).toFixed(2);
                         }else{
                             shtml += parseFloat((json_obj[i].price)*json_obj[i].quantity).toFixed(2);
                         }
                         shtml += '   </td>';
                         shtml += '</tr>';
                         if(json_obj[i].discount != 0){
                             sum += (json_obj[i].price - discount_price)*json_obj[i].quantity;
                         }else{
                             sum += (json_obj[i].price)*json_obj[i].quantity;
                         }
                     }
                     
                     if(isDelivery == 1){
                         shtml += '<tr>';
                         shtml += '    <td colspan="3">';
                         shtml += '        <h6 class="m-0 text-right">Sub Total:</h6>';
                         shtml += '    </td>';
                         shtml += '    <td>';
                         shtml += json_obj[0].symbol+' '+parseFloat(sum).toFixed(2);
                         shtml += '    </td>';
                         shtml += '</tr>';
                         shtml += '<tr>';
                         shtml += '    <td colspan="3">';
                         shtml += '        <h6 class="m-0 text-right">Shipping:</h6>';
                         shtml += '    </td>';
                         shtml += '    <td>';
                         shtml += json_obj[0].symbol+' 10.00';
                         shtml += '    </td>';
                         shtml += '</tr>';
                         shtml += '<tr>';
                         shtml += '    <td colspan="3">';
                         shtml += '        <h6 class="m-0 text-right">Total:</h6>';
                         shtml += '    </td>';
                         shtml += '    <td>';
                         shtml += json_obj[0].symbol+' '+parseFloat(sum + 10.00).toFixed(2);
                         shtml += '    </td>';
                         shtml += '</tr>';
                     }else{
                         shtml += '    <td colspan="3">';
                         shtml += '        <h6 class="m-0 text-right">Total:</h6>';
                         shtml += '    </td>';
                         shtml += '    <td>';
                         shtml += json_obj[0].symbol+' '+parseFloat(sum).toFixed(2);
                         shtml += '    </td>';
                         shtml += '</tr>';
                     }
                 }else{
                     shtml += '<tr>';
                     shtml +=    '<td class="text-center" colspan="4">No Data</th>';
                     shtml += '</tr>';
                 }
                 
                 $("#detail_tbody").html(shtml);
             }); 
             $(".viewModal").modal('show');
         }



        function SiteDataStore(type, desc) 
        {
            $.ajax({
                    url : '<?=base_url()?>SiteDataStoreController/SiteDataStore',
                    type : 'POST',
                    data : {
                        id: '',
                        type : type,
                        desc : desc,
                    },
                    success : function(msg){
                      
                    }
                });

        }
         
</script>