<?php
session_start();
include_once "../config.php";
require_once '../database1.php';
require_once "../check_admin.php";

class userOrder extends database
{
    public function index()
    { 
		$sql = " SELECT SUM(ci.cl_amount) AS total_amount, c.cl_created_at FROM tb_checkout c INNER JOIN tb_checkout_item ci ON c.cl_id=ci.cl_checkout_id WHERE c.cl_deleted_at IS NULL AND ci.cl_deleted_at IS NULL AND c.cl_status!='Cancelled' AND c.cl_status!='Money refunded' AND c.cl_status!='Payment Cancelled' AND c.cl_status!='Session Expired' GROUP BY MONTH(c.cl_created_at) ";
		return $this->callQuery($sql);
	}
	 public function getUser($uid)
    { 
		$where['id']=$uid;
		return $this->fetchRow('user',$where);
	}
}
$msg='';
if(isset($_GET['message']))
{
	$msg=$_GET['message'];
}

$obj = new userOrder();	
$userOrders = $obj->index();


include '../header.php';
?>
            <!-- MAIN CONTENT-->
            <div class="main-content">
                <div class="section__content section__content--p30">
                    <div class="container-fluid">
                        <div class="row">
                            <div class="col-md-12">
                                <div class="overview-wrap">
                                    <h2 class="title-1">Monthly Sales Report</h2>
                                    
                                </div>
								
                            </div>
                        </div>
                        
                        <div class="row m-t-25 m-row">
							<div class="col-lg-12">
                                                         
                                <div class="table-responsive table--no-card m-b-30 top-margin pull-left">
                                    <table class="table table-borderless table-data3 ACP_table" style="width: 100%">
                                        <thead>
                                            <tr>
												
                                               
												<th>Month & Year</th>
												<th>Total AMount (Amount excluding Cancelled, Money refunded, Payment Cancelled, Session Expired)</th>
											
                                            </tr>
                                        </thead>
                                        <tbody>
                                           <?php
											foreach($userOrders AS $orders)
											{
												
											?>
											<tr class="action-container">
												
												
												<td>
													<?php echo htmlspecialchars(date("M Y", strtotime($orders['cl_created_at']))); ?>
												</td>
												<td>
													<?php echo htmlspecialchars($orders['total_amount']); ?>
												</td>
											</tr>
											<?php
											}
											?>
                                           
                                        </tbody>
                                    </table>
									
                                </div>
                            </div>
                            
                          
                        </div>
                        
                       <script>
						$(document).ready(function(){
							$('.active').removeClass('active');
							$('#customer-menu').addClass('active');
						}); 
						</script>               

  <?php
  include '../footer.php';
  ?>