<?php
/* vim: set expandtab tabstop=4 shiftwidth=4 softtabstop=4: */
// +----------------------------------------------------------------------+
// | PHP version 4/5                                                      |
// +----------------------------------------------------------------------+
// | This source file is a part of iScripts Multicart                     |
// +----------------------------------------------------------------------+
// | Authors: Programmer<programmer@armia.com>        		              |
// +----------------------------------------------------------------------+
// | Copyrights Armia Systems, Inc and iScripts.com � 2005                |
// | All rights reserved                                                  |
// +----------------------------------------------------------------------+
// | This script may not be distributed, sold, given away for free to     |
// | third party, or used as a part of any internet services such as      |
// | webdesign etc.                                                       |
// +----------------------------------------------------------------------+
?>
<?php
include "../includes/config.php";
include "../includes/session.php";
include "../includes/functions.php";

if(isset( $_SESSION["sess_adminname"]) and $_SESSION["sess_adminname"]!= "") {
    $adminname = $_SESSION["sess_adminname"];
}else {
    header("Location:login.php");
    exit;
}


if(isset($_POST['gotoPage'])) {

    header("Location:".$_SERVER['PHP_SELF']."?page=".$_POST['gotoPage']);


}

if(isset($_POST['btnSubmit'])) {
//echo $_POST['txtFromDate'];
    $from_date 	= dateFormat($_POST['txtFromDate'],"m/d/Y","Y-m-d");
    $to_date 	= dateFormat($_POST['txtToDate'],"m/d/Y","Y-m-d");
    $query_string = "AND order_date >= ".GetSQLValueString($from_date,"text").
            " AND order_date <= ".GetSQLValueString($to_date,"text").
            " ORDER BY ord.order_date ";

}
else if(isset($_POST['btnSubmitOrder'])) {


    $query_string = " AND ord.order_id = '".$_POST['productOrder']."'";

}
else {
    $query_string = "";
}

$sql = " SELECT ord.order_id,ord.order_date,ord.order_total_price,ord.vorder_currency,
				usr.first_name,usr.last_name   
		  FROM ".$tableprefix."orders ord,".$tableprefix."users usr
		  WHERE ord.user_id = usr.user_id
		   AND  ord.vpayment_status IN('C','')";


if(!(isset($pagenum))) {
    $pagenum = 1;
} 

$limit = getSettingsValue('npagination_limit');

$page = isset($_GET['page'])? trim($_GET['page']):1;


if(empty($page)) {
    $page = 1;
}

$result=mysql_query($sql) or die(mysql_error());						

$totalrows = mysql_num_rows($result);

$sql_qr		=$sql.$query_string;	

$resultRows	= @mysql_num_rows(mysql_query($sql_qr));

$limitvalue = ($page - 1) * $limit;

$query_string .= " LIMIT $limitvalue, $limit";

$sql = $sql.$query_string;

$rs = mysql_query($sql) or die(mysql_error());

$numofpages = ceil($totalrows / $limit);

//echo $sql;
include "../includes/htmltop.php";


?>
<body topmargin="0">
    <script src="../js/calendar2.js"></script>
    <script>
        function checkTotalSalesForm()
        {

            var form_name = new Array('txtFromDate','txtToDate');
            var display_name = new Array('<?php echo FDATE;?>','<?php echo TDATE;?>');
            var count = 2;

            if(check_fields('frmTotalSales',form_name,display_name,count))
            {


                smonth = document.frmTotalSales.txtFromDate.value;
                emonth = document.frmTotalSales.txtToDate.value;
                flagdate = compareDates(smonth,emonth);

                if(flagdate == 1)
                {

                    return confirm("<?php echo TO_GT_FROM;?>");
                    return false;

                }
                else
                {

                    return true;


                }


            }
            else
            {

                return false;

            }

        }
    </script>

<body>
    <center>

        <div align="left" id="layout">




            <!--header area start -->
            <?php

            include_once("../includes/topheader_admin.php")

                    ?>

            <!--header area end -->




            <div align="left" class="main_body">
                <!--main body start -->



                <?php
                include_once("../includes/admintopmenu.php")
                        ?>


                <div align="left" class="content_area">

                    <!--content area start -->

                    <div align="left" class="page_title"><?php echo PRO_SALES_REPORT;?></div>
                    <div align="center" class="text_information grey_tr"><?php echo $message?></div>
                    <br>

                    <div align="left">
                        <table><tr><td height="35"><?php include_once("../includes/reportmenu.php")?></td>	</tr></table>
                        <form name="frmTotalSales" method="post" onSubmit="return checkTotalSalesForm();">

                            <table width="100%" border="0" cellpadding="0" cellspacing="0">

                                <tr>
                                    <td colspan="5">&nbsp;</td>
                                </tr>
                                <tr>
                                    <td width="10%" valign="top">&nbsp;<?php echo FDATE;?></td>
                                    <td width="31%" valign="top">
                                        <input type="text" name="txtFromDate" class="textarea" readonly="readonly">
                                        <a href="javascript:cal1.popup();"><img src="../images/cal.gif" width="16" height="16" border="0" Title="Click Here to Pick up From Date"></a>
                                    </td>
                                    <td width="7%" valign="top"><?php echo TDATE;?></td>
                                    <td width="30%" valign="top">
                                        <input type="text" name="txtToDate" class="textarea" readonly="readonly">
                                        <a href="javascript:cal2.popup();"><img src="../images/cal.gif" width="16" height="16" border="0" Title="Click Here to Pick up To Date"></a>
                                    </td>
                                    <td width="22%" align="left"><input type="submit" name="btnSubmit" value="<?php echo BTN_GET_REPORT;?>" class="button"></td>
                                </tr>
                            </table>

                        </form>

                        <form name="frmTotalSalesByOrder" method="post">

                            <table width="100%" border="0" cellpadding="0" cellspacing="0">
                                <tr>
                                    <td colspan="6">&nbsp;</td>
                                </tr>

                                
                                <tr>
                                    <td width="9%" valign="top">&nbsp;<?php echo ORDER_ID;?></td>
                                    <td width="6%" valign="top">


                                        <select class="textarea2" name="productOrder">

                                            <?php

                                            $select_order = "SELECT DISTINCT o.order_id FROM ".$tableprefix."orders o
						INNER JOIN  ".$tableprefix."order_details od ON od.order_id=o.order_id  WHERE o.vpayment_status IN('C','') ";

                                            $result_order=mysql_query($select_order) or die(mysql_error());
                                            if(mysql_num_rows($result_order) > 0) {

                                                while($order_row = mysql_fetch_array($result_order)) {

                                                    if($_POST['productOrder'] == $order_row['order_id']) {
                                                        $order_selected = " selected";
                                                    }
                                                    else {
                                                        $order_selected = "";
                                                    }



                                                    ?>
                                            <option value="<?php echo $order_row['order_id']?>" <?php echo $order_selected?>><?php echo $order_row['order_id']?></option>
                                                    <?php

                                                }

                                            }

                                            ?>

                                        </select>

                                    </td>

                                    <td width="42%" align="left"><input type="submit" name="btnSubmitOrder" value="<?php echo BTN_GET_REPORT;?>" class="button">
                                    </td>
                                    <td width="43%" align="right"><?php if(mysql_num_rows($result) > 0 ) {?><a  style="cursor:pointer" href="total_sales_report_print.php?qstring=<?php echo $query_string?>" target="_blank">
                                            <b><?php echo PRINT1;?></b></a>&nbsp;&nbsp;
                                        <a style="cursor:pointer" href="total_sales_report_excel.php?qstring=<?php echo $query_string?>">
                                            <b><?php echo EXP_EXC;?></b></a><?php }?></td>
                                </tr>
                            </table>
                            <br>

                        </form>

                        <table width="100%" cellpadding="0" cellspacing="0">
                            <tr>
                                    <td > <h4><b><?php echo GRAND_OT;?> :  [<?php echo GRANDTOTAL;?>] </b></h4></td>
                                </tr>
                                
                                <tr>
                                    <td > <h4><b><?php echo NET_INCOME;?> :  [ <?php echo COMMISSION_TOTAL;?> ] </b> </h4></td>
                                </tr>

                               
                        </table>


                        <form name="frmTotalSales1" method="post">


                            <?php

                            $i = 1;

                            $total_income = 0;

                            if(mysql_num_rows($result) > 0 ) // start of first if loop
                            {


                                while($row = mysql_fetch_array($rs)) // start of first while loop
                                {

                                    ?>

                            <table width="100%" border="0" cellpadding="0" cellspacing="0" class="manage_table">


                                <tr align="left" class="form_header">
                                    <th width="25%"><?php echo ORDER_NO;?></th>
                                    <th width="26%"><?php echo CUSTOMER;?></th>
                                    <th colspan="5"><?php echo ORDER_DATE;?></th>
                                </tr>

                                        <?php


                                        /*------selecting the product details-------*/

                                     $select_product_details = "SELECT det.product_name,det.product_price,det.product_quantity,det.product_discount,det.artist_id,
											  det.order_id,SUM((det.product_price-(det.product_price * det.product_discount/100)) * det.product_quantity) as total, sum(det.product_tax)as producttax,
											  art.artist_name,art.first_name,art.last_name
										FROM ".$tableprefix."order_details det,".$tableprefix."artists art
										WHERE det.order_id = ".$row["order_id"].
                                                " AND art.artist_id = det.artist_id
										 GROUP BY det.product_id ";

                                        $result_product_details = mysql_query($select_product_details) or die(mysql_error());

                                        ?>
                                <tr align="left">
                                    <td>[<?php echo htmlentities($row["order_id"])?>]</td>
                                    <td><?php echo (stripslashes($row["first_name"]))?>&nbsp;<?php echo (stripslashes($row["last_name"]))?></td>
                                    <td colspan="5"><?php echo dateFormat($row["order_date"],"Y-m-d","m/d/Y");?></td>
                                </tr>




                                <!--Product Details Section--->



                                <tr>
                                    <td colspan="7">&nbsp;</td>
                                </tr>

                                <tr>
                                    <td colspan="7">
                                        <table cellpadding="0" cellspacing="0" width="100%" border="0">
                                            <tr>
                                                <td colspan="7"><b><?php echo PRO_DETAILS;?></b></td>
                                            </tr>
                                            <tr class="grey_tr">
                                                <td width="28%"><?php echo PRODUCT_NAME;?>&nbsp;/&nbsp;<?php echo SELLER;?></td>
                                                <td width="18%" align="center"><?php echo PRO_PRICE;?></td>
                                                <td width="17%" align="center"><?php echo PRO_QTY;?></td>
                                                <td width="13%" align="center"><?php echo PRO_DISCOUNT;?></td>
                                                <td width="7%">&nbsp;</td>
                                                <td width="3%">&nbsp;</td>
                                                <td width="14%" colspan="4"><?php echo TOT_AMT;;?> </td>
                                            </tr>


                                                    <?php


                                                    if(mysql_num_rows($result_product_details) > 0) // start of product if loop
                                                    {

                                                        $product_grant_total = 0;

                                                        $product_tax_total = 0;

                                                        while($product_details_row = mysql_fetch_array($result_product_details)) // start of product while loop
                                                        {


                                                            $product_grant_total = $product_grant_total + $product_details_row['total'];

                                                            $product_tax_total = $product_tax_total + $product_details_row['producttax'];

                                                            ?>



                                            <tr>
                                                <td><?php echo stripslashes($product_details_row['product_name'])?>&nbsp;/&nbsp;<b>[<?php echo stripslashes(ucwords($product_details_row['artist_name']))?>]</b></td>
                                                <td align="center"> <?php echo $adminCurrency['currency_symbol'];?> &nbsp;<?php echo $product_details_row['product_price']?></td>
                                                <td align="center"><?php echo $product_details_row['product_quantity']?></td>
                                                <td align="center"><?php echo $product_details_row['product_discount']?>&nbsp;%</td>
                                                <td>&nbsp;</td>
                                                <td>&nbsp;</td>
                                                <td colspan="4" align="left"><?php echo $adminCurrency['currency_symbol'];?> &nbsp;<?php echo $product_details_row['total']?></td>
                                            </tr>
                                            <tr>
                                                <td colspan="8">&nbsp;</td>
                                            </tr>


                                                            <?php
                                                            /* seller commission details starts--*/

                                                            /*$select_seller_details = "SELECT art.first_name,art.last_name,ap.commission_percentage,ap.total_amount,ap.amount_paid
											  FROM ".$tableprefix."artists art,".$tableprefix."artist_payments ap
											   WHERE art.artist_id = ap.artist_id
												AND ap.order_id = ".$product_details_row["order_id"].
												" AND ap.artist_id = ".$product_details_row["artist_id"] ;*/

                                                        $select_seller_details = "SELECT art.artist_name,art.first_name,art.last_name,ap.commission_percentage,ap.total_amount,ap.admin_commision_amount,ap.amount_paid
											  FROM ".$tableprefix."artists art LEFT JOIN ".$tableprefix."artist_payments ap
											   ON art.artist_id = ap.artist_id
												WHERE ap.order_id = ".$product_details_row["order_id"];

                                                        $result_seller_details = mysql_query($select_seller_details) or die(mysql_error());


                                                        } // end of product if loop

                                                    } // end of product while loop


                                                    ?>

                                            <!--End of product table-->

                                            <tr>
                                                <td colspan="7"><hr></td>
                                            </tr>
                                            <tr>
                                                <td><b><?php echo PRO_TOTAL;?>&nbsp;:</b></td>
                                                <td>&nbsp;</td>
                                                <td>&nbsp;</td>
                                                <td>&nbsp;</td>
                                                <td>&nbsp;</td>
                                                <td>&nbsp;</td>
                                                <td class="amount_clrs"><font color="#FF0000"><?php echo $adminCurrency['currency_symbol'];?> &nbsp; <?php echo number_format(round($product_grant_total,3),2,".",",")?></font>&nbsp;<b></b></td>
                                            </tr>
                                        </table>
                                    </td>
                                </tr>
                                <tr>
                                    <td colspan="7">&nbsp;</td>
                                </tr>

                                <!--End of product table-->


                                <tr>

                                    <td colspan="7">

                                        <!--Seller Commission table starts-->

                                                <?php

                                                if(mysql_num_rows($result_seller_details) > 0) // start of seller if loop
                                                {

                                                    ?>

                                        <table cellpadding="0" cellspacing="0" width="100%" border="0">
                                            <tr>
                                                <td colspan="8"><b><?php echo COM_DETAILS;?></b></td>
                                            </tr>
                                            <tr class="grey_tr">
                                                <td width="20%"><?php echo SELLER_NAME;?></td>
                                                <td width="30%"><?php echo COM_PERCENT;?> </td>

                                                <td width="36%"><?php echo TOT_AMT;?></td>
                                                <td colspan="3"><?php echo COMMISSION;?></td>
                                            </tr>

                                                        <?php
                                                             $commission_amount =0;
                                                             $total_seller_commission =0;
                                                             $grand_total_admin_income =0;
                                                        while($seller_details_row = mysql_fetch_array($result_seller_details)) // start of seller while loop
                                                        {

                                                            $commission_amount =$seller_details_row["admin_commision_amount"];
                                                            ?>

                                            <tr>
                                                <td><?php echo stripslashes(ucwords($seller_details_row["artist_name"]))?></td>
                                                <td align="center"><?php echo $seller_details_row["commission_percentage"]?>&nbsp;%</td>
                                                <td> <?php echo $adminCurrency['currency_symbol'];?> &nbsp; <?php echo $seller_details_row["total_amount"]?></td>
                                                <td colspan="3" align="left"><?php echo $adminCurrency['currency_symbol'];?> &nbsp;<?php echo number_format(round($commission_amount,3),2,".",",")?> </td>
                                            </tr>
                                            <tr>
                                                <td colspan="7">&nbsp;</td>
                                            </tr>

                                                            <?php 
                                                            $total_amount = $seller_details_row["total_amount"];
                                                            $total_seller_commission = $total_seller_commission + ($seller_details_row["admin_commision_amount"]);
                                                            $total_income += ($seller_details_row["admin_commision_amount"]);

                                                           $grand_total_admin_income +=$total_seller_commission;


                                                        } // end commission while loop


                                                        ?>

                                            <tr>
                                                <td colspan="7"><hr></td>
                                            </tr>
                                            <tr>
                                                <td><b><?php echo COMMISSION_TOTAL;?>&nbsp;:</b></td>
                                                <td>&nbsp;</td>
                                                <td>&nbsp;</td>
                                                <td width="14%"  class="amount_clrs"align="left"><font color="#FF0000"> <?php echo $adminCurrency['currency_symbol'];?> &nbsp; <?php echo number_format(round($total_seller_commission,3),2,".",",")?></font>&nbsp;<b></b></td>
                                            </tr>
                                           
                                            <tr>
                                                <td colspan="7">&nbsp;</td>
                                            </tr>

                                            <!--End of commission table-->

                                        </table>
                                    </td>
                                </tr>

                                            <?php

                                        } else {// end commission if loop
                                            ?>
                                
                                            <?php
                                            $total_seller_commission=0;
                                        }
                                        ?>

                                <!--End of commission table-->


                                        <?php


                                        /*--Shipping Details Section Starts--*/

                                        $shippping_heading = "SELECT ".$tableprefix."shipping_details.vshipping_name
                                                        FROM ".$tableprefix."shipping_details
                                                       WHERE ".$tableprefix."shipping_details.norder_id = '".$row["order_id"]."'
                                                    GROUP BY ".$tableprefix."shipping_details.norder_id";
                                        $rslt = mysql_query($shippping_heading) or die(mysql_error());
                                        if(mysql_num_rows($rslt)> 0) {
                                            $head = mysql_fetch_object($rslt);
                                            $ship_name =$head->vshipping_name;

                                        }

                                        /*$select_shipping_details = "SELECT shipping.vshipping_name,shipping.nshp_productid,shipping.nshipping_cost,shipping.nshipping_weight,
                                                                   shipping.vshipping_currency,prd.product_name,cm.nexchange_price
                                                        FROM ".$tableprefix."shipping_details shipping,".$tableprefix."products prd,
                                                                 ".$tableprefix."currency_master cm
                                                        WHERE shipping.norder_id = ".$row["order_id"].
                                                        " AND shipping.vshipping_currency = cm.vcurrency_code
                                                         AND shipping.nshp_productid = prd.product_id";	*/

                                        $select_shipping_details = "SELECT shipping.vshipping_name,shipping.nshp_productid,shipping.nshipping_cost,shipping.nshipping_weight,
                                                                   shipping.vshipping_currency,prd.product_name,cm.nexchange_price
                                                        FROM ".$tableprefix."shipping_details shipping,".$tableprefix."products prd,
                                                                 ".$tableprefix."currency_master cm
                                                        WHERE shipping.norder_id = ".$row["order_id"]."
                                                         AND shipping.nshp_productid = prd.product_id
                                                        GROUP BY shipping.nshp_productid";

                                        /* $select_shipping_details = "SELECT shipping.vshipping_name,shipping.nshp_productid,shipping.nshipping_weight,
								  shipping.vshipping_currency,prd.product_name,cm.nexchange_price,
                                                                  CASE WHEN shipping.vshipping_name = 'flat rate shipping'
                                                                      THEN ".$tableprefix."order_details.product_quantity * shipping.nshipping_cost
                                                                       ELSE shipping.nshipping_cost END as nshipping_cost
								   FROM ".$tableprefix."shipping_details shipping,".$tableprefix."order_details,
                                                                        ".$tableprefix."products prd,
									".$tableprefix."currency_master cm
                                                                  WHERE shipping.norder_id = ".$row["order_id"].
                                                                  " AND shipping.vshipping_currency = cm.vcurrency_code
                                                                    AND shipping.nshp_productid = prd.product_id
                                                               GROUP BY shipping.nshp_productid";*/



                                        $result_shipping_details = mysql_query($select_shipping_details) or die(mysql_error());

                                        if(mysql_num_rows($result_shipping_details) > 0) // start of shipping if statement
                                        {


                                            ?>


                                <tr>
                                    <td colspan="7">
                                        <table cellpadding="0" cellspacing="0" border="0" width="100%">
                                            <tr>
                                                <td colspan="3"><b><?php echo SHIPPING_DETAILS;?></b></td>
                                            </tr>
                                            <tr class="grey_tr">
                                                <td width="26%"><?php echo SHPNG_NAME;?>&nbsp;/&nbsp;<?php echo PRODUCT;?></td>
                                                <td width="60%"><?php echo SW;?></td>
                                                <td width="14%"><?php echo SHIPPING_COST;?></td>
                                            </tr>
                                                        <?php
                                                        $total_ups_shipping_cost = 0;
                                                        while($shipping_details_row = mysql_fetch_array($result_shipping_details)) { // start while shipping

                                                            $shipping_names =  $shipping_details_row['vshipping_name'];
                                                            if(strtolower($shipping_names) == 'flat rate shipping') {
                                                                $sql_flat_rate_cnt  = "SELECT product_quantity
                                                                         FROM ".$tableprefix."order_details
                                                                        WHERE ".$tableprefix."order_details.product_id = '".$shipping_details_row['nshp_productid']."'
                                                                          AND ".$tableprefix."order_details.order_id = '".$row["order_id"]."'";
                                                                $rslt_cnt = mysql_query($sql_flat_rate_cnt) or die(mysql_error());
                                                                if(mysql_num_rows($rslt_cnt) > 0) {
                                                                    $rslt_set = mysql_fetch_object($rslt_cnt);
                                                                    $product_cnt = $rslt_set->product_quantity;

                                                                }
                                                                $shipping_tot = ($shipping_details_row['nshipping_cost']);
                                                            }
                                                            else {
                                                                $shipping_tot = $shipping_details_row['nshipping_cost'];
                                                            }
                                                            $shipping_tot = $shipping_tot/$shipping_details_row['nexchange_price'];

                                                            ?>

                                            <tr>
                                                <td><?php echo stripslashes($shipping_details_row['vshipping_name'])?>&nbsp;/&nbsp;<b>[<?php echo stripslashes($shipping_details_row['product_name'])?>]</b></td>
                                                <td><?php echo stripslashes($shipping_details_row['nshipping_weight'])?>&nbsp;LBS</td>
                                                <td colspan="3"> <?php echo $adminCurrency['currency_symbol'];?> &nbsp;<?php echo number_format(round($shipping_tot,3),2,".",","); ?></td>
                                            </tr>
                                            <tr>
                                                <td colspan="3">&nbsp;</td>
                                            </tr>

                                                            <?php
                                                            //echo $shipping_details_row['nshipping_cost'].'<br />';
                                                            $total_ups_shipping_cost += $shipping_tot;

                                                            $shipped_currency = $shipping_details_row['vshipping_currency'];

                                                        } // end while shipping

                                                        ?>

                                            <tr>
                                                <td colspan="7"><hr></td>
                                            </tr>
                                            <tr>
                                                <td><b><?php echo SHIPPING_TOTAL;?>&nbsp;:</b></td>
                                                <td>&nbsp;</td>
                                                <td width="12%" class="amount_clrs"><font color="#FF0000" > <?php echo $adminCurrency['currency_symbol'];?> &nbsp; <?php echo number_format(round($total_ups_shipping_cost,3),2,".",",")?></font>&nbsp;<b></b></td>
                                            </tr>

                                            <tr>
                                                <td><b><?php echo TAX_TOTAL;?>&nbsp;:</b></td>
                                                <td>&nbsp;</td>
                                                <td width="12%" class="amount_clrs"><font color="#FF0000" > <?php echo $adminCurrency['currency_symbol'];?> &nbsp; <?php echo number_format(round($product_tax_total,3),2,".",",")?></font>&nbsp;<b></b></td>
                                            </tr>
                                            <tr>
                                                <td colspan="7">&nbsp;</td>
                                            </tr>

                                        </table>
                                    </td>
                                </tr>

                                            <?php


                                        } // end of shipping if statement

                                        /*--Shipping Details Section Ends--*/

                                       

                                        $grand_total_amount = $product_grant_total + $total_ups_shipping_cost +$product_tax_total;


                                        ?>

                                <!-- Details of one order ends-->


                                <tr>
                                    <td colspan="7"><hr></td>
                                </tr>
                                <tr>
                                    <td colspan="4"><b><?php echo GRAND_OT;?> [<?php echo GRANDTOTAL;?>]&nbsp;:</b></td>
                                    
                                    <td width="9%">&nbsp;</td>
                                    <td width="14%" align="left" class="amount_clrs"><font color="#FF0000">  <?php echo $adminCurrency['currency_symbol'];?>&nbsp; <?php echo number_format(round($grand_total_amount,3),2,".",",");?></font>&nbsp;<b></b></td>
                                </tr>
                                <!--

                                                                <tr>
                                                                        <td colspan=""><b>Seller Commission&nbsp;:</b></td>
                                                                        <td>&nbsp;</td>
                                                                        <td width="23%">&nbsp;</td>
                                                                        <td>&nbsp;</td>
                                                                        <td width="1%">&nbsp;</td>
                                                                        <td width="2%">&nbsp;</td>
                                                                        <td width="5%" align="left"><?php //echo round($total_seller_commission,2)?></td>
                                                                        <td width="9%">&nbsp;</td>
				</tr>



                                                                <tr>
                                                                        <td colspan="8"><hr></td>
				</tr>

                                -->


                                <tr>
                                    <td colspan="6"> <hr> </td>
                                </tr>

                              

                           
                            <br>

                                    <?php


                                } // end of first while loop

                        ?>
                              <tr>
                                    <td colspan="4"><b> <h3><?php echo NET_INCOME;?> [ <?php echo COMMISSION_TOTAL;?> ] &nbsp;:</h3></b></td>
                                  <td width="9%">&nbsp;</td>
                                    <td align="left" class="amount_clrs"><font color="#FF0000"><?php echo $adminCurrency['currency_symbol'];?> &nbsp;<?php echo number_format(round($total_income,3),2,".",",")?></font>&nbsp;</td>
                              </tr> </table>
                            <?php

                            }	// end of first if loop

                            else {

                                ?>

                            <table width="100%" border="0" cellpadding="0" cellspacing="0" class="manage_table">
                                <tr>
                                    <td align="center" valign="middle" colspan="8" class="text_information"><?php echo NO_RECORDS_FOUND;?> !!</td>
                                </tr>
                            </table>




                                <?php

                            }


                            if($resultRows>$limit) {


                                if($page > 1) {
                                    $pageprev = $page-1;

                                    $previous_page = "<a href=".$_SERVER['PHP_SELF']."?page=$pageprev alt='Previous' border='0' class='small_gray_button'>".TEXT_PREV."</a>";

                                }


                                if($page < $numofpages) {
                                    $pagenext = ($page + 1);

                                    $next = "<a href=".$_SERVER['PHP_SELF']."?page=$pagenext alt='Next' border='0' class='small_gray_button'>".TEXT_NEXT."</a>";

                                }


                                ?>
                            <table cellpadding="0" cellspacing="0" width="100%" border="0">
                                <tr>
                                    <td align="center">
										<table width="100%" border="0" cellspacing="10" cellpadding="0">
											<tr align="left" valign="middle">
												<td width="21%" align="right"><?php echo $previous_page?></td>
												<td width="23%" align="right">
													<?php echo PAGE."(".S.")";?> <?php echo $page ?>/<?php echo $numofpages?>&nbsp;&nbsp;
													<?php echo GO_TO;?>
												</td>
												<td width="8%" align="right">
													<select class="textarea2" name="gotoPage" style="padding:4px 5px; margin-bottom:1px; ">
                                                <?php
                                                for($i=1;$i<=$numofpages;$i++) {


                                                    if($i == $_GET['page']) {
                                                        $page_selected = "selected";
                                                    }
                                                    else {
                                                        $page_selected = "";
                                                    }


                                                    ?>
                                            <option value="<?php echo $i?>" <?php echo $page_selected?>><?php echo $i?></option>

                                                    <?php
                                                }

                                                ?>
                                        </select>
												</td>
												<td width="7%">
													<a onClick="Javascript:document.frmTotalSales1.submit();" class="go_button_2"><?php echo GO; ?></a>
													<a  style="cursor:pointer" href="total_sales_report_print.php?qstring=<?php echo $query_string?>" target="_blank"></a>
												</td>
												<td width="41%" align="center"><?php echo $next?></td>
											</tr>
										</table>
									</td>
                                </tr>
                                <tr>
                                    <td align="center">

                                    </td>
                                </tr>
                            </table>
                                <?php } ?>

                        </form>

                    </div>


                    <!--content area end-->

                </div>


                <div align="left" class="clear_float"><img src="<?php echo $imagefolder;?>/clear.gif" alt="" width="1" height="1" /></div>
                <!--main body end -->
            </div>





            <script>
                var cal1 = new calendar2(document.forms['frmTotalSales'].elements['txtFromDate']);
                cal1.year_scroll = true;
                cal1.time_comp = false;

                var cal2 = new calendar2(document.forms['frmTotalSales'].elements['txtToDate']);
                cal2.year_scroll = true;
                cal2.time_comp = false;
            </script>
            <?php

            include "../includes/footer.php";
            ?>




