<?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 (get_magic_quotes_gpc()) {
    $_POST = array_map('stripslashes_deep', $_POST);
    $_GET = array_map('stripslashes_deep', $_GET);
    $_COOKIE = array_map('stripslashes_deep', $_COOKIE); 
} 

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


if(isset($_GET["txtSearch"]) and $_GET["txtSearch"]!=""){
	$txtSearch = $_GET["txtSearch"];
	$cmbSearchType = $_GET["cmbSearchType"];
}else if(isset($_POST["txtSearch"]) and $_POST["txtSearch"]!=""){
	$txtSearch = $_POST["txtSearch"];
	$cmbSearchType = $_POST["cmbSearchType"];
}


$chkorders = $_POST["chkorders"];

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


$qryopt="";
if($txtSearch != ""){
   if($cmbSearchType == "username"){
   		$qryopt .= "  AND  u.user_name like '" . addslashes($txtSearch) . "%'";
   }else if($cmbSearchType == "dateordered"){
   		$dt = $txtSearch;
		$arrdt = explode("/",$dt) ;
		$day = $arrdt[1];
		$month = $arrdt[0];
		$year = $arrdt[2];
		$dt = $year."-". $month ."-".$day;
		$qryopt .= "  AND  o.order_date like '" . addslashes($dt) . "%'";
   }else if($cmbSearchType == "email"){
            $qryopt .= "  AND  u.email like '" . addslashes($txtSearch) . "%'";
   }
}
$sql=" SELECT o.*, u.user_name, u.email, od.product_discount,sum((od.product_price-(od.product_price*product_discount/100)) * od.product_quantity) as total FROM ".$tableprefix."orders o 
		INNER JOIN " . $tableprefix . "users u ON o.user_id = u.user_id 
		INNER JOIN " . $tableprefix . "order_details od ON o.order_id = od.order_id 
		WHERE od.artist_id = '".addslashes($artistid)."' 
		AND od.item_status = '4'
		AND od.artist_payment_status = '3' 
		" . $qryopt . " GROUP BY o.order_id ORDER BY o.order_date DESC    ";
		
	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);
	
	$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);
	
include "../includes/htmltop.php";

?>
<script language="JavaScript" type="text/JavaScript">
function clickSearch()
{
	document.frmFeedbacks.submit();
}
function changeStatus(id){
	var frm = document.frmFeedbacks;
	if(Confirm("<?php echo QTN_CHNG_ST;?>")){
		document.frmFeedbacks.submit();
	}
}
</script>

<body>
		
		<center>
		
		<div align="left" id="layout">
		
		
				
				
				<!--header area start -->
<?php

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

?>
				
				<!--header area end -->
				
				
				
				
				<div align="left" class="main_body">
				<!--main body start -->
				
				
				
<?php
		include_once("../includes/artisttopmenu.php")
?>		
																					
								
					<div align="left" class="content_area">
					
					<!--content area start -->
							
					<div align="left" class="page_title"><?php echo TEXT_REQ_PAY_APPR;?></div>
					<div align="center" class="text_information grey_tr"><?php echo $message?></div>
            		<br>
											
					<div align="left">		
					
					<form action="" method="post" name="frmFeedbacks">
																										
					<table width="100%" border="0" cellpadding="0" cellspacing="0" class="manage_top">
						<tr>
							<td width="90%" align=left valign="baseline"  class="toplinksCopy"><?php echo TEXT_SEARCH;?>::
								<select name="cmbSearchType" class="textarea">
									<option value="username"  <?php if($cmbSearchType == "username" || $cmbSearchType == ""){ echo("selected"); } ?>><?php echo TEXT_USER_NAME;?></option>
									<option value="email"  <?php if($cmbSearchType == "email"){ echo("selected"); } ?>><?php echo TEXT_EMAIL;?></option>
									<option value="dateordered"  <?php if($cmbSearchType == "dateordered"){ echo("selected"); } ?>><?php echo TEXT_ORDER_DATE;?></option>
								</select> &nbsp;
								<input type="text" name="txtSearch" size="20" maxlength="50" value="<?php echo(htmlentities($txtSearch)); ?>"  onKeyPress="if(window.event.keyCode == '13'){ return false; }" class="textarea">
                                                                <a href="javascript:clickSearch();" class="go_button"><?php echo BTN_SEARCH; ?></a>
						  </td>
						</tr>
					</table>

					</form>
					
					</div>
						
					<div align="left">					
					
																	

					<table border="0" width="100%" cellpadding="0" cellspacing="0" class="manage_table">
					
					<form action="" method="post" name="frmFeedbacks1">
					<tr class="form_header">
						<th width="4%">#</th>
						<th width="17%"><?php echo TEXT_USER_NAME;?></th>
						<th width="24%"><?php echo TEXT_EMAIL;?></th>
						<th width="22%"><?php echo TEXT_ORDER_DATE;?></th>
						<th width="20%"><?php echo TEXT_ORDER_TOTAL;?></th>
						<th width="13%"><?php echo TEXT_ORDER_TOTAL;?></th>
					</tr>
<?php
if(mysql_num_rows($result) > 0 )
{
	$i = 1;
	while($row = mysql_fetch_array($rs))
	{
		$link = "<a class='links' href='vieworder.php?orderid=".$row["order_id"]."'>";
		$check = "<input class='checkbox' type='checkbox' name='chkorders[]' value='" . $row["order_id"] . "' > ";
	
	
?>
					<tr> 
						<td width="4%"><?php echo $i;?></td>
						<td width="17%"><?php echo $link .htmlentities($row["user_name"])."</a>";?></td>
						<td width="24%"><?php echo $link .htmlentities($row["email"])."</a>";?></td>
						<td width="22%"><?php echo $link .dateFormat($row["order_date"], "Y-m-d", "m/d/Y")."</a>";?></td>
						<td width="20%"><?php echo $link .$adminCurrency['currency_symbol'].htmlentities(number_format($row["total"], 2, '.', ''))."</a>";?></td>
						<td><?php echo $link .htmlentities(getArtistOrderStatus($row["order_id"],$artistid))."</a>";?></td>
					</tr>
					
					
					
					
<?php
	$i++;
	}
	
?>

<?php 
					if(isNotNull($check))
					{
?>
<?php
 
 					}
 
 ?>		

<?php	

}

else
{
										
?>					
							<tr>
									<td align="center" valign="middle" colspan="6"  class="text_information"><?php echo TEXT_NO_RECORD;?></td>
							</tr>					
<?php										
}
?>
							</form>
<?php					
if($page > 1)
{
	$pageprev = $page-1;
	
	$previous_page = "<a href=".$_SERVER['PHP_SELF']."?page=$pageprev alt='Previous' border='0' class='small_gray_button'>prev</a>";
	
}
																				
													
if($page < $numofpages)
{
	$pagenext = ($page + 1);
	
	$next = "<a href=".$_SERVER['PHP_SELF']."?page=$pagenext alt='Next' border='0' class='small_gray_button'>next</a>";
	
}	
?>
										<form action="" method="post" name="frmFeedbacks1">
										<tr>
										  <td class="page_nos"  align="center" colspan="3">&nbsp;</td>
										  <td align="right" valign="middle" class="page_nos" colspan="2">&nbsp;</td>
										  <td align="left" class="btn_gotbl"
 valign="middle">&nbsp;</td>
										  </tr>
										  <?php
										  if($page < $numofpages || $page > 1){
										  ?>
										<tr>
											<td align="center" colspan="6">
											<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">
														Page(s) <?php echo $page ?>/<?php echo $numofpages?>&nbsp;&nbsp;Goto
													</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.frmFeedbacks1.submit();" class="go_button_2">Go</a>
													</td>
													<td width="41%" align="center"><?php echo $next?></td>
												</tr>
											</table>											
										    </td>
										  </tr>
										<?php
										}
										?>
										</form>
										</table>
					  </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>
<?php
	include "../includes/footer.php";
?>