<html>
<head><title>Managing and controlling your shiping orders</title>

<script language="JavaScript">
function newWindow(mypage,myname,w,h,features) {
  if(screen.width){
  var winl = (screen.width-w)/2;
  var wint = (screen.height-h)/2;
  }else{winl = 0;wint =0;}
  if (winl < 0) winl = 0;
  if (wint < 0) wint = 0;
  var settings = 'height=' + h + ',';
  settings += 'width=' + w + ',';
  settings += 'top=' + wint + ',';
  settings += 'left=' + winl + ',';
  settings += features;
  win = window.open(mypage,myname,settings);
  win.window.focus();
}</script>
</head>
<body>
<?php
/***************************************************************************
 *			shipping_mng.php                                   *
 *                     	          				           *
 *   File Info:		  Shipping Manager                                 *
 *   Copyright:       Copyright 2003 http://www.128concepts.com            *
 *						                           *
 ***************************************************************************/
include("./tests.php");
include("./config.php");
include("./your-header.inc");

if ($_SESSION['admin'] == NULL)
{
echo("<br><br><center><img src=images/line.gif border=0 width=550></center><br><center><img src=images/keybord1.gif border=0></center><center><b>You have not log in. If you are an existing member please click the <a href =./shop_viewpages.php>Login</a> link!</b><br>If you are a new user click the <a href=./newpass.php>Register Me</a> link.</center><br><center><img src=images/line.gif border=0 width=550></center><br><br>");
include_once("./your-footer.inc");
exit();
}

if ($_SERVER['REQUEST_METHOD'] == "POST") 
  {
        # escape data and set variables
        $search= addslashes($_POST["search"]);
    
}


// limit value for records to be shown

$table = "history";
$conn = @mysql_connect($server,$user,$password)
	or die("Unable to connect to SQL database...");
$rss = @mysql_select_db($database,$conn) 
	or die("Unable to select the database...Please press 'Create Database' to create new database.");

$limit = 10;
$search = "payment received";
$query_count = "SELECT * from $table where stat = '$search'";
$res_count = mysql_query($query_count,$conn);
$totalrows = mysql_num_rows($res_count);
if (empty($page))
$page = 1;
$limitv = $page * $limit - ($limit);

if ($search == NULL or $search == "view all")
$sql = " SELECT * from $table LIMIT $limitv,$limit";
else
$sql = " SELECT * from $table where stat = '$search' LIMIT $limitv,$limit";
$rs = mysql_query($sql,$conn)
	or die("Could not execute SQL query!!! Possibly SQL query already been executed.");
$count_result = mysql_num_rows($rs);

$numpages = ceil($totalrows / $limit);
echo "<center><img src=images/searching.gif border=0></center><center><strong><font face = Verdana color = navy size=3>Viewing all shipping orders by page number(s)</font></strong></center><img src=images/line.gif border=0 width=100%>";
echo "<p><center><b><font face=verdana size=2>Found $totalrows</b> customer order result(s) </font></center></p>";
$from = $limit*$page-$limit+1;
$to = $from+$count_result-1;
if ($style == 1) #style 1
{
echo "<table align=\"center\" width=\"90%\" border=\"0\" cellspacing=\"0\" cellpadding=\"0\">
            <tr><td width=\"50%\" bgcolor=\"$backcolor\" align=\"left\">";if($numpages>1){echo"<font face=verdana size=2>Showing item(s): $from to $to</font></td><td width=\"50%\" bgcolor=\"$backcolor\" align=\"right\"><b><font face=verdana size=2>Go to page:</font></b> ";} 
}
if ($style == 2) #style 2
{
echo "<table align=\"center\" width=\"60%\" border=\"0\" cellspacing=\"0\" cellpadding=\"0\">
            <tr><td width=\"50%\" bgcolor=\"$backcolor\" align=\"left\">";if($numpages>1){echo"<font face=verdana size=2>Showing item(s): $from to $to</font></td><td width=\"50%\" bgcolor=\"$backcolor\" align=\"right\"><b><font face=verdana size=2>Go to page:</font></b> ";} 
}
if($page != 1){ 
$pageprev = $page - 1; 
echo("<a href=\"$PHP_SELF?page=$pageprev\"><img src = ./images/back.gif  width = 16 height = 20 border=0></a>&nbsp;"); 
} 

// display page nos if not 1 
for($i = 1; $i <= $numpages; $i++){ 
if($numpages>1){
if($i == $page) 
echo("&nbsp;".$i."&nbsp;"); 
else
echo("&nbsp;<a href=\".\orders_mng.php?page=$i\">$i</a>&nbsp;"); 
}}

// display next page link if there is more than one
if(($totalrows - ($limit * $page)) > 0){ 
$pagenext = $page + 1; 
echo("<a href=\"$PHP_SELF?page=$pagenext\"><img src = ./images/next.gif width = 16 height = 20 border=0></a>"); 

}
echo "</td><tr></table><br>";
echo"<table align=\"center\" valign=\"top\" width=\"90%\" border=\"0\" cellspacing=\"0\" cellpadding=\"0\">
<tr bgcolor=\"$backcolor\"><td>
			<table cellpadding=\"2\" border=\"0\" cellspacing=\"1\" valign=\"top\" width=\"100%\" align=\"center\">
				<tr bgcolor=\"#FFFFFF\">
					<td background=\"images/bevel_bg.gif\" height=\"20\"><b><font face=verdana size=2>Order No</font></b></td>
					<td background=\"images/bevel_bg.gif\" height=\"20\"><b><font face=verdana size=2>Status</font></b></td>
					<td background=\"images/bevel_bg.gif\" height=\"20\"><b><font face=verdana size=2>Date/Time</font></b></td>
					<td background=\"images/bevel_bg.gif\" height=\"20\"><b><font face=verdana size=2>Total</font></b></td>
					<td background=\"images/bevel_bg.gif\" height=\"20\"><b><font face=verdana size=2>Information</font></b></td></tr>";

	while($row = mysql_fetch_array($rs))
	{
	$orderid = $row["orderid"];
	$full = $row["fullname"];
	$stats = $row["stat"];
	$tot = $row["total"];
	$date_added = $row["rtime"];
	if ($wcurrency == "NO")
	echo"<tr bgcolor=\"#FFFFFF\">
            <td><font face=verdana size=2>$orderid</font></td>
            <td><font face=verdana size=2>$stats</font></td>
            <td><font face=verdana size=2>$date_added</font></td>
             <td><font face=verdana size=2>$currency$tot</font></td>
            <td><a href=\"view_cust.php?$orderid\" target=\"_self\"><img src=\"images/moreinfo.gif\" border=\"0\"></a><img src =\"images\web1.gif\" width = 32 height = 24><a href = javascript:newWindow('./chg_ship.php?$orderid','acePopup',650,500,'scrollbars=yes')><font face=verdana size=2>Shipping</font></a></td>
             </tr>";
	if ($wcurrency != "NO")
	echo"<tr bgcolor=\"#FFFFFF\">
            <td><font face=verdana size=2>$orderid</font></td>
            <td><font face=verdana size=2>$stats</font></td>
            <td><font face=verdana size=2>$date_added</font></td>
             <td><font face=verdana size=2>($wcurrency)$tot</font></td>
            <td><a href=\"view_cust.php?$orderid\" target=\"_self\"><img src=\"images/moreinfo.gif\" border=\"0\"></a><img src =\"images\web1.gif\" width = 32 height = 24><a href = javascript:newWindow('./chg_ship.php?$orderid','acePopup',650,500,'scrollbars=yes')><font face=verdana size=2>Shipping</font></a></td>
             </tr>";
	}
echo "</table></tr></td></table><br><img src=images/line.gif border=0 width=100%>";
echo "<br><center><p align = justify><font face=verdana size=2>NOTE to USERS: Click the SHIPPING button to manage your shipping. You can create a shipping record, edit a shipping record from the Shipping Manager.</font></p></center>";
echo "<br><center><a href=javascript:history.back()><img src=images/back.gif border = 0 alt=Back></a></center>";
include("./your-footer.inc");?>
</body>
</html>