<? 
include("header.php"); 
include "checksession.php";
$_SESSION['UN'];
?>
  
<div id="content">
  <div class="breadcrumb">
        <a href="index.php">Home</a>
      </div>
      
<div class="box">
<div class="heading">
      <h1><img src="view/image/home.png" alt="" /> Dashboard</h1>
    </div>
    <div class="content">
      <div class="overview" style="width:35%; margin-left:350px;">
        <div class="dashboard-heading">Overview</div>
        <div class="dashboard-content">
        <?php
		$set1=mysql_query("select sum(tot_amount) from orders");
		$fet1=mysql_fetch_array($set1);
		
		$set2=mysql_query("select count(*) as num from orders");
		$fet2=mysql_fetch_array($set2);
		
		$set3=mysql_query("select count(*) as num from user_account where code='1'");
		$fet3=mysql_fetch_array($set3);
		
		$set4=mysql_query("select count(*) as num from user_account where code='0'");
		$fet4=mysql_fetch_array($set4);
		?>
          <table>
            <tr>
              <td>Total Sales:</td>
              <td><?php echo $corrrency;?> <?php echo $fet1[0]; ?></td>
            </tr>
            
            <tr>
              <td>Total Orders:</td>
              <td><?php echo $fet2[num]; ?></td>
            </tr>
            <tr>
              <td>No. of Activated Customers:</td>
              <td><?php echo $fet3[num]; ?></td>
            </tr>
            <tr>
              <td>Not Activated Customers:</td>
              <td><?php echo $fet4[num]; ?></td>
            </tr>
            
          </table>
        </div>
      </div>
      <!--<div class="statistic">
        <div class="range">Select Range:          <select id="range" onchange="getSalesChart(this.value)">
            <option value="day">Today</option>
            <option value="week">This Week</option>
            <option value="month">This Month</option>
            <option value="year">This Year</option>
          </select>
        </div>
        <div class="dashboard-heading">Statistics</div>
        <div class="dashboard-content">
          <div id="report" style="width: 390px; height: 170px; margin: auto;"></div>
        </div>
      </div>-->
      <div class="latest">
        <div class="dashboard-heading">Latest 10 Orders</div>
        <div class="dashboard-content">
          <table class="list">
            <thead>
              <tr>
                <td class="right">Order ID</td>
                <td class="left">Customer</td>
                <td class="left">Status</td>
                <td class="left">Date Added</td>
                <td class="right">Total</td>
                <td class="right">Action</td>
              </tr>
            </thead>
            <tbody>
            <?
            
            $qur="SELECT * FROM ".$ORDER." order by serial desc  LIMIT 0, 10"; 



		$result = mysql_query($qur)or die('Have an error in viewing data'.mysql_error());

		while ($row_section = mysql_fetch_array($result)) 

			{
			    $snum=$row_section['serial'];
				$date=$row_section['date'];
				$cust_id=$row_section['customer_id'];
				$name=$row_section['name'];
				$address=$row_section['address'];
				$product_name=$row_section['product_name'];
				$quantity=$row_section['quantity'];
				$tot_amount=$row_section['tot_amount'];
				$order_id=$row_section['order_id'];
				$awb_num=$row_section['awb_num'];
				$delivery=$row_section['delivery'];
				$payment=$row_section['payment'];
				
			  ?>	    
                 <tr>
                <td class="right"><? echo $order_id; ?></td>
                <td class="left"><? echo $name; ?></td>
                <td class="left"><? if($row_section['awb_num']=='' &&$row_section['delivery']=='') { echo "Pending"; } else { echo "Processed"; }?></td>
                <td class="left"><? echo $date; ?></td>
                <td class="right"><? echo $tot_amount; ?></td>
                <td class="right">                  [ <a href="tot_purchase.php">View</a> ]
                  </td>
              </tr>
              
              <? } ?>
              
              
                                        </tbody>
          </table>
        </div>
      </div>
    </div>
  </div>
</div>
<!--[if IE]>
<script type="text/javascript" src="view/javascript/jquery/flot/excanvas.js"></script>
<![endif]--> 
<script type="text/javascript" src="view/javascript/jquery/flot/jquery.flot.js"></script> 
<script type="text/javascript"><!--
function getSalesChart(range) {
	$.ajax({
		type: 'get',
		url: 'index.php?route=common/home/chart&token=b735cc089ec2d51abb9a8e1901f501fb&range=' + range,
		dataType: 'json',
		async: false,
		success: function(json) {
			var option = {	
				shadowSize: 0,
				lines: { 
					show: true,
					fill: true,
					lineWidth: 1
				},
				grid: {
					backgroundColor: '#FFFFFF'
				},	
				xaxis: {
            		ticks: json.xaxis
				}
			}
			$.plot($('#report'), [json.order, json.customer], option);
		}
	});
}
getSalesChart($('#range').val());
//--></script> 
</div>

<?  include("footer.php"); ?>



