<?php
/*
asaancart - easy shopping cart solution
---------------------------------------
Copyright 2009 Nasir Ahmad Khan
Email: hide@address.com
This file is part of asaancart - open source easy shopping cart solution.
asaancart is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
asaancart is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with asaancart. If not, see <http://www.gnu.org/licenses/>.
*/
include("../config/config.php");
include("includes/chk_login_status_inc.php");
$smarty->assign('username',$_SESSION['username']);
//manage
$sql = "SELECT * FROM products ORDER BY product_name LIMIT 0,5";
$results = mysql_query($sql);
$total_products = mysql_num_rows($results);
$smarty->assign('total_products', $total_products);
while($row = mysql_fetch_assoc($results) )
{
$all_product_list[] = $row;
//get pro image
$sql_img = "SELECT * FROM product_images WHERE product_id='".$row['product_id']."' ORDER BY is_main";
$results_img = mysql_query($sql_img);
$img_cnt = 0;
while($row_img = mysql_fetch_assoc($results_img) )
{
if($img_cnt<1){
$product_images[] = $row_img;
$img_cnt++;
}
}
// end pro img
}
$smarty->assign('product_images', $product_images);
$smarty->assign('all_product_list', $all_product_list);
//$smarty->assign('rss_inno', $rss_inno);
//end manage
//mini reports
$sql = "SELECT count(product_id) FROM products";
$results = mysql_query($sql);
while($row = mysql_fetch_array($results) )
{
$totalProducts = $row[0];
}
$smarty->assign('totalProducts', $totalProducts);
//total cat
$sql = "SELECT count(category_id) FROM category";
$results = mysql_query($sql);
while($row = mysql_fetch_array($results) )
{
$totalCategories = $row[0];
}
$smarty->assign('totalCategories', $totalCategories);
//end total cat
$sql = "SELECT count(customer_id) FROM customers";
$results = mysql_query($sql);
while($row = mysql_fetch_array($results) )
{
$totalCustomers = $row[0];
}
$smarty->assign('totalCustomers', $totalCustomers);
//
//get total content pages
$sql = "SELECT count(page_id) FROM content_page";
$results = mysql_query($sql);
while($row = mysql_fetch_array($results) )
{
$totalPages = $row[0];
}
$smarty->assign('totalPages', $totalPages);
//end get content
$sql = "SELECT count(product_category.product_id) as a, product_category.category_id as b, category.category_name as c FROM product_category, category WHERE product_category.category_id=category.category_id GROUP BY product_category.category_id";
$results = mysql_query($sql);
$d1="";
$d2="";
$cntd = -1;
$lg = 0;
$legend = "";
while($row = mysql_fetch_array($results) )
{
$lg = $lg+1;
$productsInCategory[] = $row;
if($cntd==-1){
$d1 = $row['a'];
$d2 = $lg;//$row['c'];
$legend = $legend.$lg . " = " .$row['c'];
$cntd = 0;
}else{
$d1 = $d1 . "," . $row['a'];
$d2 = $d2 . "|" . $lg;//$row['c'];
$legend = $legend.", ".$lg . " = " . $row['c'];
}
}
$smarty->assign('gsrc', "http://chart.apis.google.com/chart?chs=250x150&chd=t:$d1&cht=p3&chl=$d2");
$smarty->assign('d1', $d1);
$smarty->assign('d2', $d2);
$smarty->assign('legend', $legend);
$smarty->assign('productsInCategory', $productsInCategory);
//order
$sql = "SELECT count(order_id) FROM orders WHERE order_status='pending'";
$results = mysql_query($sql);
while($row = mysql_fetch_array($results) )
{
$totalPendingOrders = $row[0];
}
$smarty->assign('totalPendingOrders', $totalPendingOrders);
//end order
//end mini reports
$smarty->display('index.tpl');
?>