<?php
require_once ("../config.inc.php");
require_once ("../includes/adminlogincheck.inc.php");
require_once ("../includes/mysql.inc.php");
require_once ("../includes/arrays.inc.php");
require_once ("../classes/miscellaneous.class.php");
require_once ("../includes/Pager/Pager.php");

$message	= "";
$pages		= "";
$data		= array();
$array		= array();
$page		= isset($_REQUEST['page'])	?	trim($_REQUEST['page'])	:	"1";
$title		= isset($_REQUEST['title'])	?	trim($_REQUEST['title'])	:	"";
$order		= isset($_REQUEST['order'])	?	trim($_REQUEST['order'])	:	"";

$image='<img src="../images/bgar.gif"></img>';
if($order=='DESC') {

    $image='<img src="../images/descar.gif"></img>';
}

else if($order=='ASC') {

    $image='<img src="../images/ascrar.gif" ></img>';

}

if (!isset($_REQUEST['page'])) {
	$_SESSION['api_search']	= "";
}

if (!$objDB) {
	$message	= "Unable to Locate Database Server.";
} else {
	$objM		= new miscellaneous($objDB);
	
	if (isset($_POST['SearchNow'])) {
		$array		= $objM->search_payments($_POST, true);
	} else {
		$array		= $objM->search_payments($_SESSION,false,$sort=$title.' '.$order);
	}
//	$array		= $objM->get_all_payments();
	$params 	= array(
		'mode'      => 'Sliding',
		'perPage'   => PAGESIZE,
		'urlVar'    => 'page',
		'extraVars' => array(),
		'itemData'  => $array
	);
	$objP 		= & Pager::factory($params);
	$data  		= $objP->getPageData();
	if (empty($data))
		$message	.= "No record(s) exists.<br>";
}

include_once('title.inc.php');
?>
<script type="text/javascript" src="../scripts/calendar.js"></script>
<script type="text/javascript" src="../scripts/calendar-setup.js"></script>
<script type="text/javascript" src="../scripts/calendar-en.js"></script>
<link href="../scripts/calendar.css" rel="stylesheet" type="text/css">
<script type="text/javascript" src="../js/jquery.js"></script>
<script type="text/javascript" src="../js/jquery.autocomplete.js"></script>
<link href="../js/searchstyle.css" rel="stylesheet" type="text/css">
<script language="javascript" type="text/javascript">
function confirm_check()
{
 var where_to= confirm("Do you really want to delete these success stories for permenantly??");
 if (where_to== true)
 {
   return true;
 }
 else
 {
  return false;
  }
}
</script>
<?php include_once('tophtml.php');?>
<table width="100%"  border="0" cellspacing="0" cellpadding="0">
    <tr>
        <td valign="top" class="white">
            <table width="100%"  border="0" cellspacing="0" cellpadding="0">
                <tr>
                    <td width="72%" valign="top">
                        <table width="100%"  border="0" cellspacing="0" cellpadding="5">
                            <tr>
                                <td height="10">&nbsp;</td>
                            </tr>
                            <tr>
                                <td class="headings1">Payments</td>
                                        </tr>
                        </table>
                        <div class="bordernew padding2">
                            <table width="100%"  border="0" cellspacing="0" cellpadding="0">

                                <tr>
                                    <td>
                                        <table width="100%"  border="0" cellspacing="0" cellpadding="0">
                                        <tr>
                                            <td >&nbsp;</td>
                                                <td align="right" class="maintext">
                                                    <table width="100%" border="0" cellpadding="0" cellspacing="0" class="search_wrapper_tbl_admin">
													                        <form action="<?php echo $_SERVER['PHP_SELF']?>" method="post" name="frmSearch">
						 <tr>
                                                                <td align="right">
                     User <input name="user" id="user" type="text" maxlength="100" value="<?php echo isset($objM->arrSearch['user'])?stripslashes($objM->arrSearch['user']):""?>" class="searchwidth1"> 
                       Trans ID  <input name="trans" type="text" maxlength="100" value="<?php echo isset($objM->arrSearch['trans'])?stripslashes($objM->arrSearch['trans']):""?>" class="searchwidth1">
                          Date<input name="date" id="date" type="text" value="<?php echo isset($objM->arrSearch['date'])?stripslashes($objM->arrSearch['date']):""?>" maxlength="50" readonly class="searchwidth1">     
                        
                        
                         <input type="button" value="v" id="button1" name="button1"  class="button_stylenew" style=" width:30px;">                            <script type="text/javascript" language="javascript">
															  Calendar.setup({
																inputField    : "date",
																button        : "button1",
																//ifFormat      : "%Y-%m-%d",       // format of the input field
                                                                                                                                ifFormat      : "%m/%d/%Y",       // format of the input field
																showsTime     : false,
																timeFormat    : "24"
															  });
														</script>
                         <input name="imageField" type="image" class="nuller" src="../images/search.gif" width="63" height="27" align="absmiddle" border="0">                            <input type="hidden" name="SearchNow" value="SearchNow">                          
						 </td>
                        </tr>
<script type="text/javascript">
$(document).ready(function() {
	$("#user").autocomplete("takeusernames.php", { minChars:1, matchSubset:1, matchContains:1, selectOnly:1 });
});
</script>
						</form>
                        </table>
                                                </td>
                                            </tr>
                                        </table>
                                    </td>
                            </tr>
                        </table>
			<form name="form1" method="post" action="" onSubmit="return confirm_check();">
          <table width="100%"  border="0" cellspacing="0" cellpadding="5">
            <tr>
                <td><table width="100%"  border="0" cellspacing="1" cellpadding="0" class="listing_tbl_admin">
					<?php 	if(isset($message) && $message!='')
							{
					?>
                <tr align="left">
                  <td align="center" class="maintext2">&nbsp;</td>
                  <td colspan="8" class="maintext2 warning"><?php echo $message;?></td>
                  </tr>
					<?php  	}//end if
				      if ($objDB) 
					  { 
                 			if (!empty($data)) 
							{ 
				?>
                <tr align="left">
                  <th  align="center" class="maintext2">#</td>
                  <th class="maintext2">User<a href="payments.php?title=vLogin&order=<?php echo $order == 'ASC' ? 'DESC' : 'ASC'?>"><?php echo $image ?></a></th>
                  <th class="maintext2">Amount<a href="payments.php?title=fAmount&order=<?php echo $order == 'ASC' ? 'DESC' : 'ASC'?>"><?php echo $image ?></a></th>
                  <th class="maintext2">Transaction ID<a href="payments.php?title=vTxn_Id&order=<?php echo $order == 'ASC' ? 'DESC' : 'ASC'?>"><?php echo $image ?></a> </th>
                  <th class="maintext2">Date<a href="payments.php?title=dDay&order=<?php echo $order == 'ASC' ? 'DESC' : 'ASC'?>"><?php echo $image ?></a></th>
                  <th class="maintext2">Reason<a href="payments.php?title=vReason&order=<?php echo $order == 'ASC' ? 'DESC' : 'ASC'?>"><?php echo $image ?></a></th>
                  <th class="maintext2">Method<a href="payments.php?title=vMethod&order=<?php echo $order == 'ASC' ? 'DESC' : 'ASC'?>"><?php echo $image ?></a></th>
                </tr>
					<?php  	
							foreach ($data as $key => $value) 
							{ 
								switch($value['vMethod'])
								{
									case "PP":
										$ppMethod='Paypal';
									break;

									case "GC":
										$ppMethod='Google Checkout';
									break;

									case "WP":
										$ppMethod='Worldpay';
									break;

									case "UP":
										$ppMethod='Yourpay';
									break;

									default:
										$ppMethod=$value['vMethod'];
									break;
								}//end switch
				?>
                <tr align="left">
                  <td width="3%" align="center" class="maintext2"><?php echo $key+1?></td>
                  <td width="22%" class="maintext2"><?php echo htmlspecialchars(stripslashes($value['vLogin']))?></td>
                  <td width="11%" class="maintext2">$<?php echo $value['fAmount']?></td>
                  <td width="22%" class="maintext2"><?php echo htmlspecialchars(stripslashes($value['vTxn_Id']))?></td>
                  <td width="14%" class="maintext2"><?php echo date("m/d/Y",strtotime($value['dDay']))?></td>
                  <td width="14%" class="maintext2"><?php echo (stripslashes($value['vReason']))?></td>
                  <td width="14%" class="maintext2"><?php echo htmlspecialchars(stripslashes($ppMethod))?></td>
                </tr>
				<?php 			}//end foreach
					 		}//end if
						}//end first if
				?>
              </table>
				<?php if(!empty($data))
					  {
				?>
                 <table width="100%"  border="0" cellspacing="0" cellpadding="0">
                                                <tr>
                                                    <td width="82%">&nbsp;</td>
                                                    <td width="18%" align="right">
						<table width="100%"  border="0" cellspacing="0" cellpadding="2" class="pagination_style">
							<tr><td>&nbsp;</td></tr>
							<tr align="center" class="textbox">
								<td><?php echo $objP->links;?></td>
							</tr>
						</table>
                                                    </td>
                                                </tr>
                                            </table><?php }//end if?>
                <table width="100%"  border="0" cellspacing="0" cellpadding="0">
                                            </table> </td>
            </tr>
          </table></form>
			</div>
			</td>
          </tr>
        </table>
		</td>
        </tr>
    </table>      
    </td>
  </tr>
</table><?php include("bottomhtml.php");?>
<div class="calendar_widget" id="calendar_widget" style="display:none "><iframe id='calendar_widget_iframe' name='calendar_widget_iframe' style="border: none;" width=100% height=100% src="../date/calendar_widget.html" /></div>
