<!doctype html>
<html lang="en">
    <head>
        <meta charset="utf-8" />
        <title><?php echo $title;?></title>
        <meta name="viewport" content="width=device-width, initial-scale=1.0">
        <meta content="Premium Multipurpose Admin & Dashboard Template" name="description" />
        <meta content="Themesbrand" name="author" />
        <!-- App favicon -->
        <link rel="shortcut icon" href="<?php echo base_url();?>assets/img/ic_launcher_round.png">
        
        <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/4.7.0/css/font-awesome.min.css">

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

        <!-- Lightbox css -->
        <link href="<?php echo base_url();?>assets/libs/magnific-popup/magnific-popup.css" rel="stylesheet" type="text/css" />
        <!-- Bootstrap Css -->
        <link href="<?php echo base_url();?>assets/css/bootstrap.min.css" id="bootstrap-style" rel="stylesheet" type="text/css" />
        <link href="<?php echo base_url();?>assets/libs/bootstrap-touchspin/jquery.bootstrap-touchspin.min.css" rel="stylesheet" />
        <!-- DataTables -->
        <link href="<?php echo base_url();?>assets/libs/datatables.net-bs4/css/dataTables.bootstrap4.min.css" rel="stylesheet" type="text/css" />
        <link href="<?php echo base_url();?>assets/libs/datatables.net-buttons-bs4/css/buttons.bootstrap4.min.css" rel="stylesheet" type="text/css" />
        <link href="<?php echo base_url();?>assets/libs/bootstrap-datepicker/css/bootstrap-datepicker.min.css" rel="stylesheet">
        <!-- Responsive datatable examples -->
        <link href="<?php echo base_url();?>assets/libs/datatables.net-responsive-bs4/css/responsive.bootstrap4.min.css" rel="stylesheet" type="text/css" />     
        <!-- Icons Css -->
        <link href="<?php echo base_url();?>assets/css/icons.min.css" rel="stylesheet" type="text/css" />
        <link href="<?php echo base_url();?>assets/css/gallery/gallery.css" rel="stylesheet">
        <link href="<?php echo base_url();?>assets/css/style.css" rel="stylesheet">
        <link href="<?php echo base_url();?>assets/libs/dropzone/min/dropzone.min.css" rel="stylesheet">
        <!-- App Css-->
        <link href="<?php echo base_url();?>assets/css/app.min.css" id="app-style" rel="stylesheet" type="text/css" />
        <style>
            body{
                background-color: #fff;
            }
            
            .form-control {
                border-radius: 1.25rem;
            }
        </style>
    </head>

    <body data-sidebar="dark" data-sidebar-size="small">

        <!-- Begin page -->
        <div id="layout-wrapper">

            <header id="page-topbar">
                <div class="navbar-header">
                    <div class="d-flex">
                        <!-- LOGO -->
                        <div class="navbar-brand-box">
                            <a href="<?php echo base_url('sgallery');?>" class="logo logo-light">
                                <span class="logo-sm">
                                    <img src="<?php echo base_url();?>assets/images/favicon.png" alt="" height="22">
                                </span>
                                <span class="logo-lg">
                                    <img src="<?php echo $site_logo;?>" alt="" style="width: 70%; height: 30%;">
                                </span>
                            </a>
                        </div>

                        <button type="button" class="btn btn-sm px-3 font-size-16 header-item waves-effect" id="vertical-menu-btn">
                            <i class="fa fa-fw fa-bars"></i>
                        </button>
                    </div>

                    <div class="d-flex" style="padding-right: 15px;">
                        <div class="dropdown d-inline-block">
                            <div class="btn header-item waves-effect" onclick="qrdetail('<?php echo $guest_detail['qr_url']?>')">
                                <?php 
                                    if($guest_detail['photo_url'] == "" && $guest_detail['qr_url'] != ""){
                                ?>
                                    <img class="rounded-circle header-profile-user" src="<?php echo $guest_detail['qr_url'];?>" alt="<?php echo $guest_detail['email'];?>" style="border: solid 1px #40dcfd;">
                                <?php
                                    }else if($guest_detail['photo_url'] != "" && $guest_detail['qr_url'] == ""){
                                ?>
                                    <img class="rounded-circle header-profile-user" src="http://d1z6a3vjnfowyr.cloudfront.net/<?php echo $guest_detail['photo_url'];?>" alt="<?php echo $guest_detail['email'];?>" style="border: solid 1px #40dcfd;">
                                <?php
                                    }else{
                                ?>
                                    <img class="rounded-circle header-profile-user" src="http://d1z6a3vjnfowyr.cloudfront.net/<?php echo $guest_detail['photo_url'];?>" alt="<?php echo $guest_detail['email'];?>" style="border: solid 1px #40dcfd;">
                                <?php
                                    }
                                ?>
                                <span class="d-none d-xl-inline-block ml-1"><?php echo $guest_detail['email'];?></span>
                            </div>
                        </div>
                        
                        <div class="dropdown d-inline-block">
                            <button type="button" class="btn header-item noti-icon waves-effect" id="page-header-notifications-dropdown"
                                data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">
                                <i class="bx bx-bell bx-tada"></i>
                                <span class="badge badge-danger badge-pill"><?php echo $new_notification_count;?></span>
                            </button>
                            <div class="dropdown-menu dropdown-menu-lg dropdown-menu-right p-0"
                                aria-labelledby="page-header-notifications-dropdown">
                                <div class="p-3">
                                    <div class="row align-items-center">
                                        <div class="col">
                                            <h6 class="m-0"> Notifications </h6>
                                        </div>
                                    </div>
                                </div>
                                <div data-simplebar style="max-height: 230px;">
                                    <?php
                                        if(count($notification_list) > 0){
                                            foreach ($notification_list as $key => $val) {
                                                if($val['isShow'] == 0){
                                    ?>
                                                    <a href="<?php echo base_url();?>notification" class="text-reset notification-item">
                                                        <div class="media">
                                                            <div class="avatar-xs mr-3">
                                                                <span class="avatar-title bg-primary rounded-circle font-size-16">
                                                                    <i class="<?php echo $val['class_info'];?>"></i>
                                                                </span>
                                                            </div>
                                                            <div class="media-body">
                                                                <h6 class="mt-0 mb-1"><?php echo $val['notification'];?></h6>
                                                                <div class="font-size-12 text-muted">
                                                                    <p class="mb-0"><i class="mdi mdi-clock-outline"></i> <?php echo $val['created_at'];?></p>
                                                                </div>
                                                            </div>
                                                        </div>
                                                    </a>
                                    <?php
                                                }else{
                                    ?>
                                    
                                    <?php
                                                }
                                            }
                                        }
                                    ?>
                                </div>
                                <div class="p-2 border-top">
                                    <a class="btn btn-sm btn-link font-size-14 btn-block text-center" href="<?php echo base_url();?>notification" style="color: #40dcfd;">
                                        <i class="mdi mdi-arrow-right-circle mr-1"></i> View All
                                    </a>
                                </div>
                            </div>
                        </div>
                    </div>
                </div>
            </header>
             <div class="qrviewModals" role="dialog" aria-labelledby="exampleModalLabel" style="position:absolute; z-index:100000000;display:none;top:0;" >
                  <div class="modal-dialog modal-dialog-centered" role="document">
                        <div class="modal-content">
                            <div class="modal-header">
                                <h5 class="modal-title" id="exampleModalLabel">Details</h5>
                                <button type="button" class="close" data-dismiss="modal" onclick="closeqr()" aria-label="Close">
                                    <span aria-hidden="true">&times;</span>
                                </button>
                            </div>
                            <div class="modal-body">
                                <img src="" id="qrImgs" style="width: 100%;">
                            </div>
                            <div class="modal-footer">
                                <button type="button" class="btn btn-secondary" onclick="closeqr()"  data-dismiss="modal">Close</button>
                            </div>
                        </div>
                    </div>
                </div>
            <style>
                .icon_img{
                    border: 0;
                    max-width: 100%;
                }
            </style>
            
            <!-- ========== Left Sidebar Start ========== -->
            <div class="vertical-menu" style="position:absolute; left:0px;">

                <div data-simplebar class="h-100">

                    <!--- Sidemenu -->
                    <div id="sidebar-menu">
                        <!-- Left Menu Start -->
                        <ul class="metismenu list-unstyled" id="side-menu">
                            <?php 
                                if($is_single_gallery == 1){
                            ?>
                                <li>
                                    <a href="<?php echo base_url('sgallery');?>" class="waves-effect">
                                        <div style="padding: 0px 35px;">
                                            <img src="<?php echo base_url();?>assets/images/icon/gallery.png" class="icon_img">
                                        </div>
                                        <div>
                                            <span>My Gallery</span>
                                        </div>
                                    </a>
                                </li>
                            <?php
                                }else{
                            ?>
                                <li>
                                    <a href="<?php echo base_url('mgallery');?>" class="waves-effect">
                                        <div style="padding: 0px 35px;">
                                            <img src="<?php echo base_url();?>assets/images/icon/gallery.png" class="icon_img">
                                        </div>
                                        <div>
                                            <span>My Gallery</span>
                                        </div>
                                    </a>
                                </li>
                            <?php
                                }
                            ?>
                            <li>
                                <a href="<?php echo base_url('account');?>" class="waves-effect">
                                    <div style="padding: 0px 35px;">
                                        <img src="<?php echo base_url();?>assets/images/icon/account.png" class="icon_img">
                                    </div>
                                    <div>
                                        <span>My Account</span>
                                    </div>
                                </a>
                            </li>
                            <li>
                                <a href="<?php echo base_url('purchase');?>" class="waves-effect">
                                    <div style="padding: 0px 35px;">
                                        <img src="<?php echo base_url();?>assets/images/icon/purchase.png" class="icon_img">
                                    </div>
                                    <div>
                                        <span>Digital Pass</span>
                                    </div>
                                </a>
                            </li>
                            <li>
                                <a href="<?php echo base_url('merchandise');?>" class="waves-effect">
                                    <div style="padding: 0px 30px;">
                                        <img src="<?php echo base_url();?>assets/images/icon/merchandise.png" class="icon_img">
                                    </div>
                                    <div>
                                        <span>Merchandise</span>
                                    </div>
                                </a>
                            </li>
                            <li>
                                <a href="<?php echo base_url('cart');?>" class="waves-effect">
                                    <div style="padding: 0px 35px;">
                                        <img src="<?php echo base_url();?>assets/images/icon/cart.png" class="icon_img">
                                    </div>
                                    <div>
                                        <span>Cart</span>
                                    </div>
                                </a>
                            </li>
                            <li>
                                <a href="<?php echo base_url('faqs');?>" class="waves-effect">
                                    <div style="padding: 0px 35px;">
                                        <img src="<?php echo base_url();?>assets/images/icon/help.png" class="icon_img">
                                    </div>
                                    <div>
                                        <span>Help</span>
                                    </div>
                                </a>
                            </li>
                            <li>
                                <a href="<?php echo base_url('logout');?>" class="waves-effect">
                                    <div style="padding: 0px 35px;">
                                        <img src="<?php echo base_url();?>assets/images/icon/logout.png" class="icon_img">
                                    </div>
                                    <div>
                                        <span>Logout</span>
                                    </div>
                                </a>
                            </li> 
                        </ul>
                    </div>
                    <!-- Sidebar -->
                </div>
            </div>
            <!-- Left Sidebar End -->
    
            <!-- ============================================================== -->
            <!-- Start right Content here -->
            <!-- ============================================================== -->
            <div class="main-content">

                <div class="page-content">
                    <div class="container-fluid">

                        <!-- start page title -->
                        <div class="row">
                            <div class="col-md-12">
                                <div class="page-title-box d-flex align-items-center justify-content-between">
                                    <h3 style="color: #40dcfd; text-transform: lowercase;">My Account</h3>
                                </div>
                            </div>
                            <div class="col-md-12 text-right mb-3">
                                <button type="button" class="btn btn-primary waves-effect waves-light" style="border-radius: 50px;" onclick="openQRModal()">
                                    Scan QR
                                    <i class="fa fa-qrcode"></i>
                                </button>
                            </div>
                        </div>
                        
                        <!-- end page title -->

                        <div class="row">
                            <div class="col-xl-4">
                                <div class="card overflow-hidden">
                                    <div class="bg-soft-primary">
                                        <div class="row">
                                            <div class="col-12">
                                                <div class="text-primary p-4">
                                                    <h5 class="text-primary" style="color: #fff !important;">Welcome Back !</h5>
                                                </div>
                                            </div>
                                        </div>
                                    </div>
                                    <div class="card-body pt-0">
                                        <div class="row">
                                            <?php 
                                                if($guest_detail['qr_url'] == "" && $guest_detail['photo_url'] != ""){
                                            ?>
                                                <div class="col-sm-3">
                                                    <div class="avatar-md profile-user-wid mb-4">
                                                        <img src="http://d1z6a3vjnfowyr.cloudfront.net/<?php echo $guest_detail['photo_url'];?>" alt="" class="img-thumbnail rounded-circle" style="border: solid 1px #40dcfd;">
                                                    </div>
                                                </div>
                                            <?php 
                                                }else if($guest_detail['qr_url'] != "" && $guest_detail['photo_url'] == ""){
                                            ?>
                                                <div class="col-sm-3">
                                                    <div class="avatar-md profile-user-wid mb-4">
                                                        <img src="<?php echo $guest_detail['qr_url'];?>" alt="" class="img-thumbnail rounded-circle" style="border: solid 1px #40dcfd; cursor: pointer;" onclick="show_qr_func('<?php echo $guest_detail['qr_url'];?>')">
                                                    </div>
                                                </div>
                                            <?php 
                                                }else{
                                            ?>
                                                <div class="col-sm-3">
                                                    <div class="avatar-md profile-user-wid mb-4">
                                                        <img src="http://d1z6a3vjnfowyr.cloudfront.net/<?php echo $guest_detail['photo_url'];?>" alt="" class="img-thumbnail rounded-circle" style="border: solid 1px #40dcfd;">
                                                    </div>
                                                </div>
                                                <div class="col-sm-3">
                                                    <div class="avatar-md profile-user-wid mb-4">
                                                        <img src="<?php echo $guest_detail['qr_url'];?>" alt="" class="img-thumbnail rounded-circle" style="border: solid 1px #40dcfd; cursor: pointer;" onclick="show_qr_func('<?php echo $guest_detail['qr_url'];?>')">
                                                    </div>
                                                </div>  
                                            <?php
                                                }
                                            ?>
                                            <div class="col-sm-12">
                                                <h5 class="font-size-15 text-truncate"><?php echo $guest_detail['email'];?></h5>
                                            </div>
                                        </div>
                                    </div>
                                </div>
                                <!-- end card -->

                                <div class="card">
                                    <div class="card-body">
                                        <h4 class="card-title mb-4" style="color: #40dcfd;">My Information</h4>

                                        <div class="table-responsive">
                                            <table class="table table-nowrap mb-0">
                                                <tbody>
                                                    <tr>
                                                        <th scope="row">Mobile :</th>
                                                        <td><?php echo $guest_detail['phone'];?></td>
                                                    </tr>
                                                    <tr>
                                                        <th scope="row">E-mail :</th>
                                                        <td><?php echo $guest_detail['email'];?></td>
                                                    </tr>
                                                    <tr>
                                                        <th scope="row">Address :</th>
                                                        <td><?php echo $guest_detail['address'];?></td>
                                                    </tr>
                                                </tbody>
                                            </table>
                                        </div>
                                    </div>
                                </div>
                                <!-- end card -->
                            </div>
                            
                            <div class="col-xl-8">

                                <div class="row">
                                    <div class="col-md-4">
                                        <div class="card mini-stats-wid">
                                            <div class="card-body">
                                                <div class="media">
                                                    <div class="media-body">
                                                        <p class="text-muted font-weight-medium" style="color: #40dcfd !important;">Photo</p>
                                                        <h4 class="mb-0"><?php echo $photo_count;?></h4>
                                                    </div>

                                                    <div class="mini-stat-icon avatar-sm align-self-center">
                                                        <span class="avatar-title">
                                                            <img src="<?php echo base_url();?>assets/images/icon/photo.png" class="icon_img">
                                                        </span>
                                                    </div>
                                                </div>
                                            </div>
                                        </div>
                                    </div>
                                    <div class="col-md-4">
                                        <div class="card mini-stats-wid">
                                            <div class="card-body">
                                                <div class="media">
                                                    <div class="media-body">
                                                        <p class="text-muted font-weight-medium" style="color: #40dcfd !important;">Video</p>
                                                        <h4 class="mb-0"><?php echo $video_count;?></h4>
                                                    </div>

                                                    <div class="avatar-sm align-self-center mini-stat-icon">
                                                        <span class="avatar-title">
                                                            <img src="<?php echo base_url();?>assets/images/icon/video.png" class="icon_img">
                                                        </span>
                                                    </div>
                                                </div>
                                            </div>
                                        </div>
                                    </div>
                                    <div class="col-md-4">
                                        <div class="card mini-stats-wid">
                                            <div class="card-body">
                                                <div class="media">
                                                    <div class="media-body">
                                                        <p class="text-muted font-weight-medium" style="color: #40dcfd !important;">Album</p>
                                                        <h4 class="mb-0"><?php echo $album_count;?></h4>
                                                    </div>

                                                    <div class="avatar-sm align-self-center mini-stat-icon">
                                                        <span class="avatar-title">
                                                            <img src="<?php echo base_url();?>assets/images/icon/gallery.png" class="icon_img">
                                                        </span>
                                                    </div>
                                                </div>
                                            </div>
                                        </div>
                                    </div>
                                </div>

                                <div class="row">
                                    <div class="col-12">
                                        <div class="card">
                                            <div class="card-body">
                                                <div class="row mb-2">
                                                    <div class="col-sm-4">
                                                        <h5 style="color: #40dcfd;">My Detail</h5>
                                                    </div>
                                                </div>
                                                <?php echo form_open('', array('class'=>'form-horizontal', 'method'=>'post'));?>
                                                    <div class="form-group row">
                                                        <label class="col-md-2 col-form-label">Password</label>
                                                        <div class="col-md-10">
                                                            <input class="form-control" type="password" value="" name="password">
                                                        </div>
                                                    </div>
                                                    <div class="form-group row">
                                                        <label class="col-md-2 col-form-label">Mobile</label>
                                                        <div class="col-md-10">
                                                            <input class="form-control" type="text" value="<?php echo $guest_detail['phone'];?>" name="phone">
                                                        </div>
                                                    </div>
                                                    <div class="form-group row">
                                                        <label class="col-md-2 col-form-label">Address</label>
                                                        <div class="col-md-10">
                                                            <input class="form-control" type="text" value="<?php echo $guest_detail['address'];?>" name="address">
                                                        </div>
                                                    </div>
                                                    <div class="form-group row">
                                                        <div class="col-md-12 text-right">
                                                            <button class="btn btn-primary" name="save_btn" value="ok" style="border-radius: 50px;">Save & Change</button>
                                                        </div>
                                                    </div>
                                                </form>
                                            </div>
                                        </div>
                                    </div> <!-- end col -->
                                </div>

                                <div class="row">
                                    <div class="col-12">
                                        <div class="card">
                                            <div class="card-body">
                                                <div class="row mb-2">
                                                    <div class="col-sm-4">
                                                        <h5 style="color: #40dcfd;">My Package</h5>
                                                    </div>
                                                    <div class="col-sm-8 text-right" style="padding-bottom: 5px;">
                                                        <button class="btn btn-primary" onclick="go_purchase();" style="border-radius: 50px;">Purchase Pass</button>
                                                    </div>
                                                </div>
                                                
                                                <div id="package_refund_msg"></div>
                                                
                                                <div class="table-responsive">
                                                    <table class="table table-centered table-nowrap">
                                                        <thead>
                                                            <tr>
                                                                <th style="width: 20px;">#</th>
                                                                <th class="text-center">Package</th>
                                                                <th class="text-center">Price</th>
                                                                <th class="text-center">Type</th>
                                                                <th class="text-center">From</th>
                                                                <th class="text-center">To</th>
                                                                <th class="text-center">Validity Period</th>
                                                                <th class="text-center">Status</th>
                                                                <th class="text-center">Venue</th>
                                                                <th class="text-center">Refund</th>
                                                            </tr>
                                                        </thead>
                                                        <tbody>
                                                            <?php
                                                                if(count($package_list) > 0){
                                                                    foreach($package_list as $key => $val){
                                                            ?>
                                                                        <tr>
                                                                            <td class="text-center">
                                                                                <?php echo $key +1;?>
                                                                            </td>
                                                                            <td class="text-center"><?php echo $val['package'];?></td>
                                                                            <td class="text-center" style="color: #f46a6a;"><?php echo $val['symbol'].$val['price'];?></td>
                                                                            <td class="text-center">
                                                                                <?php 
                                                                                    if($val['type'] == 0)
                                                                                        echo 'Limited';
                                                                                    else
                                                                                        echo 'Unlmited';
                                                                                ?>
                                                                            </td>
                                                                            <td class="text-center"><?php echo(date("Y-m-d", strtotime($val["from_date"]))); ?></td>
                                                                            <td class="text-center"><?php echo(date("Y-m-d", strtotime($val["to_date"]))); ?></td>
                                                                            <td class="text-center">
                                                                                <?php echo $val["validity"];?> Hours
                                                                            </td>
                                                                            <td class="text-center">
                                                                                <?php 
                                                                                    if($val['refund_status'] == 0 || $val['refund_status'] == 2){
                                                                                        if($val["s_from_date"] <= date("Y-m-d H:i:s") and $val["s_to_date"] >= date("Y-m-d H:i:s"))
                                                                                            echo '<font color="#40dcfd">Active</font>';
                                                                                        else
                                                                                            echo '<font color="#f46a6a">Deactive</font>';
                                                                                    }else{
                                                                                        echo '<font color="#f46a6a">Deactive</font>';
                                                                                    }
                                                                                ?>
                                                                            </td>
                                                                            <td class="text-center" style="color: #93C100;">
                                                                                <?php echo $val['site'];?>
                                                                            </td>
                                                                            <td class="text-center">  
                                                                                <?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);
                                                                                ?>
                                                                                        <button type="button" class="btn btn-primary" title="Refund" onclick="package_refund_func('<?php echo $val['txn_id'];?>')" style="border-radius: 50px;">
                                                                                            <i class="fa fa-money"></i>
                                                                                        </button>
                                                                                <?php
                                                                                    }else if($val['refund_status'] == 1){
                                                                                        echo '<span>Pending</span>';
                                                                                    }else if($val['refund_status'] == 2){
                                                                                        echo '<span class="text-danger">Declined</span>';
                                                                                    }else if($val['refund_status'] == 3){
                                                                                        echo '<span class="text-primary">Accepted</span>';
                                                                                    }
                                                                                ?>
                                                                            </td>
                                                                        </tr> 
                                                            <?php
                                                                    }
                                                                }else{
                                                            ?>
                                                                <tr>
                                                                    <td colspan="11" class="text-center">
                                                                        <span class="font-size-12">No Package Data</span>
                                                                    </td>
                                                                </tr>
                                                            <?php
                                                                }
                                                            ?>
                                                        </tbody>
                                                    </table>
                                                </div>
                                            </div>
                                        </div>
                                    </div>
                                </div>
                                <!-- end row -->
                                
                                <div class="row">
                                    <div class="col-12">
                                        <div class="card">
                                            <div class="card-body">
                                                <div class="row mb-2">
                                                    <div class="col-sm-12">
                                                        <h5 style="color: #40dcfd;">Pre-paid QR Package</h5>
                                                    </div>
                                                </div>
                                                
                                                <div id="package_refund_msg"></div>
                                                
                                                <div class="table-responsive">
                                                    <table class="table table-centered table-nowrap">
                                                        <thead>
                                                            <tr>
                                                                <th style="width: 20px;">#</th>
                                                                <th class="text-center">QR Code</th>
                                                                <th class="text-center">Package</th>
                                                                <th class="text-center">Price</th>
                                                                <th class="text-center">Type</th>
                                                                <th class="text-center">From</th>
                                                                <th class="text-center">To</th>
                                                                <th class="text-center">Validity Period</th>
                                                                <th class="text-center">Status</th>
                                                                <th class="text-center">Venue</th>
                                                            </tr>
                                                        </thead>
                                                        <tbody>
                                                            <?php
                                                                if(count($prepackage_list) > 0){
                                                                    foreach($prepackage_list as $key => $val){
                                                            ?>
                                                                        <tr>
                                                                            <td class="text-center">
                                                                                <?php echo $key +1;?>
                                                                            </td>
                                                                            <td class="text-center">
                                                                                <img src="<?php echo 'https://makeablmoments.com/uploads/prepaidQR/'.$val['filePath'];?>" style="width: 50px; height: 50px;"/>
                                                                            </td>
                                                                            <td class="text-center"><?php echo $val['package'];?></td>
                                                                            <td class="text-center" style="color: #f46a6a;"><?php echo $val['symbol'].$val['price'];?></td>
                                                                            <td class="text-center">
                                                                                <?php 
                                                                                    if($val['type'] == 0)
                                                                                        echo 'Limited';
                                                                                    else
                                                                                        echo 'Unlmited';
                                                                                ?>
                                                                            </td>
                                                                            <td class="text-center"><?php echo(date("Y-m-d", strtotime($val["from_date"]))); ?></td>
                                                                            <td class="text-center"><?php echo(date("Y-m-d", strtotime($val["to_date"]))); ?></td>
                                                                            <td class="text-center">
                                                                                <?php echo $val["validity"];?> Hours
                                                                            </td>
                                                                            <td class="text-center">
                                                                                <?php 
                                                                                    if($val["s_from_date"] <= date("Y-m-d H:i:s") and $val["s_to_date"] >= date("Y-m-d H:i:s"))
                                                                                        echo '<font color="#40dcfd">Active</font>';
                                                                                    else
                                                                                        echo '<font color="#f46a6a">Deactive</font>';
                                                                                ?>
                                                                            </td>
                                                                            <td class="text-center" style="color: #93C100;">
                                                                                <?php echo $val['site'];?>
                                                                            </td>
                                                                        </tr> 
                                                            <?php
                                                                    }
                                                                }else{
                                                            ?>
                                                                <tr>
                                                                    <td colspan="11" class="text-center">
                                                                        <span class="font-size-12">No Pre-paid QR Package Data</span>
                                                                    </td>
                                                                </tr>
                                                            <?php
                                                                }
                                                            ?>
                                                        </tbody>
                                                    </table>
                                                </div>
                                            </div>
                                        </div>
                                    </div>
                                </div>
                                <!-- end row -->

                                <div class="row">
                                    <div class="col-12">
                                        <div class="card">
                                            <div class="card-body">
                                                <div class="row mb-2">
                                                    <div class="col-sm-4">
                                                        <h5 style="color: #40dcfd;">My Order</h5>
                                                    </div>
                                                </div>
                                                
                                                <div id="order_refund_msg"></div>
                        
                                                <div class="table-responsive">
                                                    <table class="table table-centered table-nowrap">
                                                        <thead>
                                                            <tr>
                                                                <th style="width: 20px;">#</th>
                                                                <th class="text-center">Order ID</th>
                                                                <th class="text-center">Shipping Method</th>
                                                                <th class="text-center">Price</th>
                                                                <th class="text-center">Venue</th>
                                                                <th class="text-center">Order Date</th>
                                                                <th class="text-center">Refund</th>
                                                            </tr>
                                                        </thead>
                                                        <tbody>
                                                            <?php
                                                                if(count($order_list) > 0){
                                                                    foreach($order_list as $key => $val){
                                                            ?>
                                                                <tr>
                                                                    <td class="text-center">
                                                                        <?php echo $key +1;?>
                                                                    </td>
                                                                    <td class="text-center">
                                                                        <a href="javascript:;" onclick="view_detail_func('<?php echo $val['id'];?>', '<?php echo $val['isDelivery'];?>')" style="color: #40dcfd;"><?php echo $val['orderID'];?></a>
                                                                    </td>
                                                                    <td class="text-center">
                                                                        <?php
                                                                            if($val['isDelivery'] == 0){
                                                                                echo "Pick Up";
                                                                            }else{
                                                                                echo "Delivery";
                                                                            }
                                                                        ?>
                                                                    </td>
                                                                    <td class="text-center"><?php echo $val['currency'].' '.number_format($val['total_price'], 2)?></td>
                                                                    <td class="text-center" style="color: #93C100;">
                                                                        <?php echo $val['site_name'];?>
                                                                    </td>
                                                                    <td class="text-center">
                                                                        <?php echo date("Y-n-j", strtotime($val["created_at"]));?>
                                                                    </td>
                                                                    <td class="text-center">
                                                                        <?php if($val['is_paid']==0){ 
                                                                        ?>
                                                                        Not Paid
                                                                        
                                                                        <?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);
                                                                        ?>
                                                                                <button type="button" class="btn btn-primary" title="Refund" onclick="order_refund_func('<?php echo $val["id"];?>')" style="border-radius: 50px;">
                                                                                    <i class="fa fa-money"></i>
                                                                                </button>
                                                                        <?php
                                                                            }else if($val['refund_status'] == 1){
                                                                                echo '<span>Refund Pending</span>';
                                                                            }else if($val['refund_status'] == 2){
                                                                                echo '<span class="text-danger">Refund Declined</span>';
                                                                            }else if($val['refund_status'] == 3){
                                                                                echo '<span class="text-primary">Refund Completed</span>';
                                                                            }
                                                                        ?>
                                                                    </td>
                                                                </tr> 
                                                            <?php
                                                                    }
                                                                }else{
                                                            ?>
                                                                <tr>
                                                                    <td colspan="7" class="text-center">
                                                                        <span class="font-size-12">No Order Data</span>
                                                                    </td>
                                                                </tr>
                                                            <?php
                                                                }
                                                            ?>
                                                        </tbody>
                                                    </table>
                                                </div>
                                            </div>
                                        </div>
                                    </div>
                                </div>
                                <!-- end row -->
                            </div>
                        </div>
                        <!-- end row -->
                    </div> <!-- container-fluid -->
                </div>
                <!-- End Page-content -->
                
                <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">
                            <div class="modal-header">
                                <h5 class="modal-title" id="exampleModalLabel">Details</h5>
                                <button type="button" class="close" data-dismiss="modal" aria-label="Close">
                                <span aria-hidden="true">&times;</span>
                                </button>
                            </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-dismiss="modal">Close</button>
                            </div>
                        </div>
                    </div>
                </div>
                
                <div class="modal fade qrviewModal" tabindex="-1" role="dialog" aria-labelledby="exampleModalLabel" aria-hidden="true">
                    <div class="modal-dialog modal-dialog-centered" role="document">
                        <div class="modal-content">
                            <div class="modal-header">
                                <h5 class="modal-title" id="exampleModalLabel">Details</h5>
                                <button type="button" class="close" data-dismiss="modal" aria-label="Close">
                                    <span aria-hidden="true">&times;</span>
                                </button>
                            </div>
                            <div class="modal-body">
                                <img src="" id="qrImg" style="width: 100%;">
                            </div>
                            <div class="modal-footer">
                                <button type="button" class="btn btn-secondary" data-dismiss="modal">Close</button>
                            </div>
                        </div>
                    </div>
                </div>
                
                <div class="modal fade openQRModal" tabindex="-1" role="dialog" aria-labelledby="exampleModalLabel" aria-hidden="true">
                    <div class="modal-dialog modal-dialog-centered" role="document">
                        <div class="modal-content">
                            <div class="modal-header">
                                <h5 class="modal-title" id="exampleModalLabel">Scan QR</h5>
                                <button type="button" class="close" data-dismiss="modal" aria-label="Close">
                                    <span aria-hidden="true">&times;</span>
                                </button>
                            </div>
                            <div class="modal-body">
                                <div id="msg"></div>
                                <div class="row">
                                    <div id="qr-reader" class="col-md-12"></div>
                                    <div id="qr-reader-results"></div>
                                </div>
                            </div>
                            <div class="modal-footer">
                                <button type="button" class="btn btn-secondary" data-dismiss="modal">Close</button>
                            </div>
                        </div>
                    </div>
                </div>
                
                <footer style="background:white;" class="footer">
                    <div class="container-fluid">
                        <div class="row">
                            <div class="col-sm-12 text-right">
                                <script>document.write(new Date().getFullYear())</script> © makeabl
                            </div>
                        </div>
                    </div>
                </footer>
            </div>
            <!-- end main content-->

        </div>
        <!-- END layout-wrapper -->

        <!-- Right bar overlay-->
        <div class="rightbar-overlay"></div>

        <!-- JAVASCRIPT -->
        <script src="<?php echo base_url();?>assets/libs/jquery/jquery.min.js"></script>
        <script src="<?php echo base_url();?>assets/libs/bootstrap/js/bootstrap.bundle.min.js"></script>
        <script src="<?php echo base_url();?>assets/libs/metismenu/metisMenu.min.js"></script>
        <script src="<?php echo base_url();?>assets/libs/simplebar/simplebar.min.js"></script>
        <script src="<?php echo base_url();?>assets/libs/node-waves/waves.min.js"></script>
        <!-- toastr plugin -->
        <script src="<?php echo base_url();?>assets/libs/toastr/build/toastr.min.js"></script>
        <script type="text/javascript" src="<?php echo base_url();?>assets/js/webcam.min.js"></script>

        <!-- toastr init -->
        <script src="<?php echo base_url();?>assets/js/pages/toastr.init.js"></script>
        
        <!-- Sweet Alerts js -->
        <script src="<?php echo base_url();?>assets/libs/sweetalert2/sweetalert2.min.js"></script>

        <!-- Sweet alert init js-->
        <script src="<?php echo base_url();?>assets/js/pages/sweet-alerts.init.js"></script>

        <script src="<?php echo base_url();?>assets/js/app.js"></script>
        <script src="<?php echo base_url();?>assets/js/html5-qrcode.min.js"></script>

        <script>
            function go_purchase(){
                document.location.href = '<?php echo base_url();?>purchase';
            }
            
            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://d1z6a3vjnfowyr.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 package_refund_func(txnID){
                Swal.fire({
                    title: "Are you sure?",
                    type: "warning",
                    showCancelButton: !0,
                    confirmButtonColor: "#34c38f",
                    cancelButtonColor: "#f46a6a",
                    confirmButtonText: "Confirm"
                }).then(function(t) {
                    if(t.value == true){
                        $.ajax({
                            method: "POST",
                            url: "<?php echo base_url();?>AccountController/package_refund",
                            data: {
                                txn_id: txnID
                            }
                        })
                        .done(function(data) {
                            
                            var shtml = '';
                            
                            if(data == 'success'){
                                shtml += '<div class="alert alert-success fade in alert-dismissible show">';
                                shtml += '  <button type="button" class="close" data-dismiss="alert" aria-label="Close">';
                                shtml += '      <span aria-hidden="true" style="font-size:20px">×</span>';
                                shtml += '  </button>';
                                shtml += '  Your refund request was received successfully!';
                                shtml += '</div>';
                                
                                $("#package_refund_msg").html(shtml);
                                
                                setTimeout("location.reload();", 1500);
                            }
                        });
                    }
                })
            }
            
            function order_refund_func(ID){
                Swal.fire({
                    title: "Are you sure?",
                    type: "warning",
                    showCancelButton: !0,
                    confirmButtonColor: "#34c38f",
                    cancelButtonColor: "#f46a6a",
                    confirmButtonText: "Confirm"
                }).then(function(t) {
                    if(t.value == true){
                        $.ajax({
                            method: "POST",
                            url: "<?php echo base_url();?>AccountController/order_refund",
                            data: {
                                id: ID
                            }
                        })
                        .done(function(data) {
                            
                            var shtml = '';
                            
                            if(data == 'success'){
                                shtml += '<div class="alert alert-success fade in alert-dismissible show">';
                                shtml += '  <button type="button" class="close" data-dismiss="alert" aria-label="Close">';
                                shtml += '      <span aria-hidden="true" style="font-size:20px">×</span>';
                                shtml += '  </button>';
                                shtml += '  Your refund request was received successfully!';
                                shtml += '</div>';
                                
                                $("#order_refund_msg").html(shtml);
                                
                                setTimeout("location.reload();", 1500);
                            }
                        });
                    }
                })
            }
            
            function show_qr_func(url){
                $("#qrImg").attr('src',url);
                $(".qrviewModal").modal('show');
            }
            
            function openQRModal(){
                $(".openQRModal").modal('show');
            }
            
            function docReady(fn) {
                // see if DOM is already available
                if (document.readyState === "complete"
                    || document.readyState === "interactive") {
                    // call on next available tick
                    setTimeout(fn, 1);
                } else {
                    document.addEventListener("DOMContentLoaded", fn);
                }
            }
        
             docReady(function () {
                var resultContainer = document.getElementById('qr-reader-results');
                var lastResult, countResults = 0;
                function onScanSuccess(decodedText, decodedResult) {
                    if(decodedText.startsWith("http")){
                        $(".openQRModal").modal('hide');
                        console.log("---------------------");
                         $.ajax({
                            method: "POST",
                            url: "https://mymakeabl.com/api/collect_kiosk_image",
                            data: {
                                image_url:decodedText,
                                guest_id:"<?php echo $guest_detail['id'];?>"
                            }
                        })
                        .done(function(res) {
                            if(res["result"]="success"){
                                $('#msg').html("Success");
                            //   $(".openQRModal").modal('hide');
            						window.location.reload();
                            }
                            else {
                                $('#msg').html("Failed please try again.");
                                setTimeout(function(){
                                    $(".openQRModal").modal('hide');
            						window.location.reload();
            					}, 3000);
                            }
                        });
                    }
                    else if (decodedText !== lastResult) {
                        ++countResults;
                        lastResult = decodedText;
                     
                        $.ajax({
                            method: "POST",
                            url: "<?php echo base_url();?>AccountController/buy_prepackage_qr",
                            data: {
                                token: JSON.parse(decodedText).token
                            }
                        })
                        .done(function(res) {
                            var json_obj = JSON.parse(res);
                            $('#msg').html(json_obj.msg);
                            setTimeout(function(){
                                $(".openQRModal").modal('hide');
        						window.location.reload();
        					}, 3000);
                        });
                    }
                    
                    
                }
        
                var html5QrcodeScanner = new Html5QrcodeScanner(
                    "qr-reader", { fps: 10, qrbox: 250 });
                html5QrcodeScanner.render(onScanSuccess);
            });
      
                function qrdetail(url){
                    $(".qrviewModals").css("display","block");
                    $("#qrImgs").attr('src',url);
                    $(".qrviewModals").modal('show');
                }
                function closeqr()
                {
                    $(".qrviewModals").css("display","none");
                  
                }
            </script>
              
            
    </body>
    <style>
        .qrviewModals{
            left:40%;
        }
        
        @media only screen and (max-width: 600px) {
            .qrviewModals{
            left:10%;
          }
        }
    </style>
</html>