<?php defined('BASEPATH') OR exit('No direct script access allowed');?>
<!-- new admin data -->
<div class="container">
    <div class="row">
        <div class="col-12 text-center mt-3 " style="border-bottom:1px solid #d9d9d9;">
            <h3 class="pink"><?php echo display('member_area'); ?></h3>
        </div>
    </div>
</div>
<div class="container display-table">
    <div class="row display-table-row">
        <div class="col-md-2 col-sm-1 hidden-xs display-table-cell v-align box" id="navigation">
             <?php
$this->load->view('web/customer/include/customer_menu');
?>


            <!-- <p>member area</p> -->
        </div>
        <!-- end column 2 -->

        <!-- inner column -->
        <div class="col-10" >
            <div class="container">
                <div class="row">
                    <div class="col-12 pt-5">
                        <!-- <?php echo "customer_id"; ?>
                        <?php $customer_id = $this->session->userdata('customer_id');
echo $customer_id;?> -->
                        <?php //var_dump($total_order);?>
                        <?php //var_dump($order_list);?>
                        <!-- show datatable -->
    <table class="display responsive" width="100%" id="orderTable" >
        <thead>

            <th class="desktop tablet-l tablet-p mobile-l mobile-p" style="width: 10%"><?php
if ($this->session->userdata('language') == "english") {
	?>Order Date and Time
 <?php
}
?>
<?php
if ($this->session->userdata('language') == "chinese") {
	?>
    訂單日期和時間
        <?php
}
?>
<?php
if ($this->session->userdata('language') == "indonesian") {
	?>Tanggal dan waktu pemesanan
<?php
}
?></th>
            <th class="desktop tablet-l tablet-p mobile-l mobile-p" style="width: 10%">
<?php
if ($this->session->userdata('language') == "english") {
	?>Order Number
 <?php
}
?>
<?php
if ($this->session->userdata('language') == "chinese") {
	?>
   訂單編號
        <?php
}
?>
<?php
if ($this->session->userdata('language') == "indonesian") {
	?>Jumlah Order
<?php
}
?></th>
            <th class="desktop tablet-l tablet-p mobile-l mobile-p" style="width: 30%"><?php
if ($this->session->userdata('language') == "english") {
	?>Product Name

 <?php
}
?>
<?php
if ($this->session->userdata('language') == "chinese") {
	?>
   產品名稱
        <?php
}
?>
<?php
if ($this->session->userdata('language') == "indonesian") {
	?>Nama Produk
<?php
}
?></th>
            <th class="desktop tablet-l tablet-p mobile-l mobile-p" style="width: 10%"><?php
if ($this->session->userdata('language') == "english") {
	?>Total
 <?php
}
?>
<?php
if ($this->session->userdata('language') == "chinese") {
	?>
   總計
        <?php
}
?>
<?php
if ($this->session->userdata('language') == "indonesian") {
	?>Total
<?php
}
?></th>
            <th class=" desktop tablet-l tablet-p" style="width: 10%"><?php
if ($this->session->userdata('language') == "english") {
	?>Payment Method
 <?php
}
?>
<?php
if ($this->session->userdata('language') == "chinese") {
	?>
   付款方式
        <?php
}
?>
<?php
if ($this->session->userdata('language') == "indonesian") {
	?>Cara Pembayaran
<?php
}
?></th>
            <th class=" desktop tablet-l tablet-p" style="width: 10%"><?php
if ($this->session->userdata('language') == "english") {
	?>Status
 <?php
}
?>
<?php
if ($this->session->userdata('language') == "chinese") {
	?>
   狀態
        <?php
}
?>
<?php
if ($this->session->userdata('language') == "indonesian") {
	?>Status
<?php
}
?></th>
            <th class=" desktop tablet-l tablet-p" style="width: 10%"><?php
if ($this->session->userdata('language') == "english") {
	?>Details
 <?php
}
?>
<?php
if ($this->session->userdata('language') == "chinese") {
	?>
   詳情
        <?php
}
?>
<?php
if ($this->session->userdata('language') == "indonesian") {
	?>Rincian
<?php
}
?></th>
        </thead>
        <tbody>
        <?php
if (!empty($order_list)) {

	foreach ($order_list as $order_list_details) {
		?>


           <tr>

            <td><?php echo $order_list_details['final_date'] ?></td>
            <td><?php echo '#' . $order_list_details['order'] ?></td>
            <td><?php //var_dump($order_list_details['customer_order_details']);?>
                <?php
foreach ($order_list_details['customer_order_details'] as $orderdetails) {

			if ($this->session->userdata('language') == "english") {
				echo $orderdetails['product_name'] . ' - ' . $orderdetails['variant_name'];
			}
			if ($this->session->userdata('language') == "chinese") {
				echo $orderdetails['product_name_ch'] . ' - ' . $orderdetails['variant_name'];
			}
			if ($this->session->userdata('language') == "indonesian") {
				echo $orderdetails['product_name_in'] . ' - ' . $orderdetails['variant_name'];
			}
			echo "<br>";
		}
		?>


            </td>
            <td>$<?php echo $order_list_details['total_amount'] ?></td>
            <td><?php echo $order_list_details['customer_order_paymentmethod'] ?></td>
            <td><?php echo $order_list_details['customer_order_status'] ?></td>
            <td><a class="d-inline-block removetext" href="<?php echo base_url('customer/order_record_detail/' . $order_list_details['order_id']); ?>"><?php echo display('views'); ?></a>
            <a class="d-inline-block removetext" href="<?php echo base_url('customer/order_detail_pdf/' . $order_list_details['order_id']); ?>"><?php echo display('billing'); ?> <i class="fas fa-file-pdf fa-lg"></i></a></td>
        </tr>

        <?php
} //foreach ($order_list as $order_list_details) {
} //if(!empty($order_list)){
else {
	?>
         <tr>
            <td colspan="7"><?php echo display('no_data'); ?></td>
        </tr>
<?php
} //else {
?>
        </tbody>
    </table>
                        <?php

?>

                        <!-- end show datatable -->
                    </div>
                </div>
            </div>
        </div>
        <!-- end inner column -->
    </div>
</div>
</div>
<!-- end new admin data -->

<!-- Admin Home Start -->
 <!-- <div class="content-wrapper"> -->
    <!-- Content Header (Page header) -->
   <!--  <section class="content-header">
        <div class="header-icon">
            <i class="pe-7s-world"></i>
        </div>
        <div class="header-title">
            <h1><?php echo display('dashboard') ?></h1>
            <small><?php echo display('home') ?></small>
            <ol class="breadcrumb">
                <li><a href="#"><i class="pe-7s-home"></i> <?php echo display('home') ?></a></li>
                <li class="active"><?php echo display('dashboard') ?></li>
            </ol>
        </div>
    </section> -->
    <!-- Main content -->
    <!-- <section class="content"> -->
        <!-- Alert Message -->
        <?php
// $message = $this->session->userdata('message');
// if (isset($message)) {
// 	$this->session->unset_userdata('error_message');
?>
       <!--  <div class="alert alert-info alert-dismissable">
            <button type="button" class="close" data-dismiss="alert" aria-hidden="true">×</button>
            <?php echo $message ?>
        </div> -->
        <?php
// $this->session->unset_userdata('message');
// }
// $error_message = $this->session->userdata('error_message');
// if (isset($error_message)) {
// 	$this->session->unset_userdata('message');
?>
<!--         <div class="alert alert-danger alert-dismissable">
            <button type="button" class="close" data-dismiss="alert" aria-hidden="true">×</button>
            <?php echo $error_message ?>
        </div> -->
        <?php
// $this->session->unset_userdata('error_message');
// }
?>
        <!-- First Counter -->
        <!-- <div class="row">
            <div class="col-xs-12 col-sm-6 col-md-6 col-lg-3">
                <div class="panel panel-bd">
                    <div class="panel-body">
                        <div class="statistic-box">
                            <h2><span class="count-number"><?php echo html_escape($total_invoice) ?></span><span class="slight"><i class="fa fa-play fa-rotate-270 text-warning"> </i></span></h2>
                            <div class="small"><?php echo display('total_invoice') ?></div>
                            <div class="sparkline1 text-center"></div>
                        </div>
                    </div>
                </div>
            </div>
            <div class="col-xs-12 col-sm-6 col-md-6 col-lg-3">
                <div class="panel panel-bd">
                    <div class="panel-body">
                        <div class="statistic-box">
                            <h2><span class="count-number"><?php echo html_escape($total_order) ?></span> <span class="slight"><i class="fa fa-play fa-rotate-270 text-warning"> </i></span></h2>
                            <div class="small"><?php echo display('total_order') ?></div>
                            <div class="sparkline1 text-center"></div>
                        </div>
                    </div>
                </div>
            </div>
        </div>
    </section> -->

    <!-- /.content -->
<!-- </div>  -->

<!-- /.content-wrapper -->
<!-- Admin Home end -->

<script>
$(document).ready(function() {
    // $('#orderTable').DataTable();
    var table = $('#orderTable').DataTable( {
        rowReorder: {
            selector: 'td:nth-child(2)'
        },
        responsive: true
    } );

    // Add event listener for opening and closing details
    $('#orderTable tbody').on('click', 'td.details-control', function () {
        var tr = $(this).closest('tr');
        var row = table.row( tr );

        if ( row.child.isShown() ) {
            // This row is already open - close it
            row.child.hide();
            tr.removeClass('shown');
        }
        else {
            // Open this row
            row.child( format(row.data()) ).show();
            tr.addClass('shown');
        }
    } );

});
</script>
<style>
    td.details-control {
    background: url('https://datatables.net/examples/resources/details_open.png') no-repeat center center;
    cursor: pointer;
}
tr.shown td.details-control {
    background: url('https://datatables.net/examples/resources/details_close.png') no-repeat center center;
}
</style>

<link rel="stylesheet" type="text/css" href="//cdn.datatables.net/1.10.21/css/jquery.dataTables.min.css"/>
<!-- <script src="//cdnjs.cloudflare.com/ajax/libs/jquery/3.5.1/jquery.min.js"></script> -->
<script type="text/javascript" src="//cdn.datatables.net/1.10.21/js/jquery.dataTables.min.js"></script>
<script type="text/javascript" src="//cdn.datatables.net/rowreorder/1.2.8/js/dataTables.rowReorder.min.js"></script>
<script type="text/javascript" src="//cdn.datatables.net/responsive/2.2.8/js/dataTables.responsive.min.js"></script>
