<?php

session_start();
header("Content-type: text/html; charset=".$_SESSION['encodingmode']);
if($_SESSION['dbName']==""){
header("location:../index.php");

}


include("config.inc.php");
include("Functions_Trans.php");
//include("Forms_DataGrid.php");
include("Forms_RMA_DataGrid.php");

$connection = mysql_connect($config['dbServer'],$config['dbUser'],$config['dbPass']) or die("Could not connect to DB");
mysql_select_db($_SESSION['dbName'],$connection) or die("Could not find DB");

if(	$_SESSION['encodingmode'] == 'utf8' || $_SESSION['encodingmode'] == 'utf-8'){
	mysql_query("SET NAMES 'utf8'"); 
	mysql_query('SET CHARACTER SET utf8'); 
	mysql_set_charset('utf8', $connection);
}
$query_language  = "select user_account, Language from ".$_SESSION['dbLabel'].".login  where user_account = '".$_SESSION['useraccount']."'";
$result_language = mysql_query($query_language, $connection); 
$row_language    = mysql_fetch_array($result_language);
extract($row_language);

$query_journal_labels  = "select Language, label0 as Ref1, TypeRef as TypeRef1, label3 as Folio1, label2 as Date1, label1 as Type1, Project as Project1, Disp_2_1 as Costcenter2, Remark as Remark1, ManualNo as ManualNo1, Disp_1 as LedgerNo1, LedgerName as LedgerName1, Disp_4_1 as DescX, Disp_3 as Curr1, D_C as DC1, Disp_5 as Amount1, Disp_1_3 as ValueDate1, ManualNo as ManualNo1, Desc1 as Desc1,
                          NoRecords, Perpage, Page, Disp_2_2 as Perce, Disp_1_1 as CheckNo, Disp_1_2 as Bankk, Label4 as Debitt, Label5 as Creditt, Disp_4 as Balancee
                          from ".$_SESSION['dbLabel'].".journal_label
                          where Language = '".$Language."'";
$result_journal_labels = mysql_query($query_journal_labels, $connection);
$row_journal_labels    = mysql_fetch_array($result_journal_labels);
extract($row_journal_labels);

$_SESSION['query_journal_labels'] = $query_journal_labels;

$query_navigator = "SELECT LANGUAGE,
       ClearPage,
       Excel,
       Save,
       Print,
       Addd,
       Search,
       Pending,
       CopyJV,
       PaymentRequests,
       ExportExcel,
	   cancell
FROM ".$_SESSION['dbLabel'].".mainform_label
WHERE LANGUAGE = '".$Language."'";
$result_navigator = mysql_query($query_navigator, $connection);
$row_navigator    = mysql_fetch_array($result_navigator);
extract($row_navigator);

//echo $Costcenter1; exit;
$query_project  = "select Journal as Journal1, ResultsPage as ResultsPage1
                   from ".$_SESSION['dbLabel'].".mainform_label
				   where Language = '".$Language."'";
$result_project = mysql_query($query_project, $connection);
$row_project    = mysql_fetch_array($result_project);
extract($row_project);

$querylog="SELECT FA_Journal as loginaccess from ".$_SESSION['dbLabel'].".login where user_account='".$_SESSION['useraccount']."' 	and Upper(Login_Schema) = Upper('".$_SESSION['dbName']."')	";
$resultlog=mysql_query($querylog,$connection) or die(mysql_error());
while($rows=mysql_fetch_array($resultlog)){
	extract($rows);
}
if ($loginaccess=='' or $loginaccess==0)
	header("location:menu.php");
	
$querylog=" select ifNull(FA_JournalApp,0) As FA_JournalApp, ifNull(Login_FastPrint,0) As Login_FastPrint, ifNull(FA_LedgerAccess,0) As FA_LedgerAccess ".
		  " from ".$_SESSION['dbLabel'].".login where user_account='".$_SESSION['useraccount']."' and Upper(Login_Schema) = Upper('".$_SESSION['dbName']."')  ";
$resultlog=mysql_query($querylog,$connection) or die(mysql_error());
while($rows=mysql_fetch_array($resultlog)){
	extract($rows);
}

	
//Read From Setup Table							
$querysetup= " select DecimalBase, DecimalBase1, DecimalBase2, base1, base2, grid_color1, grid_color2, Journal_DefaultCur ".
             " from setup ";
$resultsetup=mysql_query($querysetup,$connection) or die(mysql_error());
while($rowsetup=mysql_fetch_array($resultsetup)){
	extract($rowsetup);
}

//Read From Module Table
$querymodule=" Select ifNull(Module_Project,0) As Module_Project, ifNull(Module_Costcenter,0) As Module_CostCenter, ".
			 " ifNull(Module_RestrictProjCost,0) As Module_RestrictProjCost, ifNull(Module_RestrictCost,0) As Module_RestrictCost, ".
			 " ifNull(Module_ProjectDt,0) As Module_ProjectDt, ifNull(Module_CostCenterDt,0) As Module_CostCenterDt, ".
			 " ifNull(module_referencebycostcenter,0) As Module_ReferenceByCostCenter, ".
			 " ifNull(module_checks,0) As Module_checks, ".
			 " ifNull(Module_ShowBalance,0) As Module_ShowBalance, ifNull(Module_ImportExcell,0) As Module_ImportExcell, ifNull(Module_bill,0) As Module_bill ".
			" ,ifNull(module_journalRate,0) As module_journalRate,ifNull(module_ledgerrestrictcur,0) As module_ledgerrestrictcur  ".	
			" From Module";
$resultmodule=mysql_query($querymodule,$connection) or die(mysql_error());
while($rowmodule=mysql_fetch_array($resultmodule)){
	extract($rowmodule);
}

//Read From TransSetup Table							
$querytranssetup= " select DefaultCur, DefaultProject as StpDefaultProject, DefaultCostcenter as StpDefaultCostcenter, ifnull(Hide_ValueDate,0) Hide_ValueDate,  ifnull(Hide_Base2,0) Hide_Base2
					from transsetup where JournalType = 'JV'";
$resulttranssetup=mysql_query($querytranssetup,$connection) or die(mysql_error());
while($rowtranssetup=mysql_fetch_array($resulttranssetup)){
	extract($rowtranssetup);
}

/// Journal Type
$queryjourtype="select type_name from jourtype where ifnull(type_visible,0) = 1 ";
$resultjourtype=mysql_query($queryjourtype,$connection)	or die( mysql_error($connection));



//Get Default Project
$querydflproject="select project_code as defaultproject from ".$_SESSION['dbLabel'].".loginstk where user_account='".$_SESSION['useraccount']."' and default_project=1 ";
$resultdflproject=mysql_query($querydflproject,$connection) or die(mysql_error());
while($rows=mysql_fetch_array($resultdflproject)){
	extract($rows);
}

//Get Default Coscenter
$querydflcostcent="select costcent_code as defaultcostcent from ".$_SESSION['dbLabel'].".loginstk where user_account='".$_SESSION['useraccount']."' and default_costcenter=1 ";
$resultdflcostcent=mysql_query($querydflcostcent,$connection) or die(mysql_error());
while($rows=mysql_fetch_array($resultdflcostcent)){
	extract($rows);
}

$vMainCompanyName=explode('_',$_SESSION['dbName']);  
$DirCompany  = $vMainCompanyName[0];
preg_match_all('!\d+!', $vMainCompanyName[1] ,$DirYears );
$fromdate =  '01/01/'.$DirYears[0][0];
$todate = date('d/m/Y'); 


print <<<HERE
<head>
<meta http-equiv="Content-Type" content="text/html; charset=windows-1256" />
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1"> 
<meta name="viewport" content="width=device-width, initial-scale=1.0"> 


<meta http-equiv="Content-Type" content="text/html; charset=windows-1256" />
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />


<link rel="stylesheet" type="text/css" media="all" href="css-v2/style.css">
<link type="text/css" rel="stylesheet" href="js/calendar/dhtmlgoodies_calendar.css?random=20051112" media="screen"></LINK>
<SCRIPT type="text/javascript" src="js/calendar/dhtmlgoodies_calendar.js?random=20060118"></script>

<link rel="stylesheet" type="text/css" media="all" href="js/grid/UI_DataGrid_V1.css">
<script type="text/javascript" src="js/grid/UI_DataGrid.js"></script>
<script type="text/javascript" src="js/grid/jquery-1.9.1.js"></script>

<script type="text/javascript" src="js/tabsClass/tabber.js"></script>
<link rel="stylesheet" href="js/tabsClass/tabber.css" type="text/css" />

<link type="text/css" href="js/calendar/jquery.datepick.css" rel="stylesheet">
<script type="text/javascript" src="js/calendar/jquery.datepick.js"></script>

<link type="text/css" href="js/grid/scripts/jquery-ui.css" rel="stylesheet">
<script type="text/javascript" src="js/grid/scripts/jquery-ui.min.js"></script>

<script type="text/javascript" language="javascript">
$(document).ready(function() { 
		
		$(document).on('focus', '.date', function() {
			$('.date').datepick({showTrigger: '#calImg'});
		});
		
		$(document).on('focusin', '.table-focus-g1', function() {
			AutoSaveRecordGrid(this.id,'SelectedRec','ModRec_G1','imgSubmit');
			selRecordColor(this,'SelectedRec','SelectedRecColor');
		});
		$(document).on('focusin', '.table-focus-g2', function() { 
			AutoSaveRecordGrid(this.id,'SelectedRec_G2','ModRec_G2','imgSubmit_D');
			selRecordColor(this,'SelectedRec_G2','SelectedRecColor_G2');
		});
		$(document).on('focusin', '.table-focus-g3', function() {
			AutoSaveRecordGrid(this.id,'SelectedRec_G3','ModRec_G3','imgSubmit_C');
			selRecordColor(this,'SelectedRec_G3','SelectedRecColor_G3');
		});
		$(document).on('focusin', '.table-focus-g4', function() {
			AutoSaveRecordGrid(this.id,'SelectedRec_G4','ModRec_G4','imgSubmit_B');
			selRecordColor(this,'SelectedRec_G4','SelectedRecColor_G4');
		});
});	
function changeValue(rmadt_id){
	if(document.getElementById('chk_rmadt_id_'+rmadt_id).checked){
		document.getElementById('rmadt_id').value = rmadt_id;
	}
}
function receive(){
	var rmadt_id = document.getElementById('rmadt_id').value;
	if(rmadt_id == ""){
		alert("Please choose a record!");
	}
	else{
	var receive_date = document.getElementById('receive_date').value;
	var c = confirm("Are you sure?");
	if(c){
	var start = document.getElementById('start_par').value;
	var pagenumber = document.getElementById('pagenumber_par').value;
	var filter_by = document.getElementById('filter_by').value;
	var str = "Form_ListReturnRMAPendingItems_Actions.php?actionmode=receive&rmadt_id="+rmadt_id+"&receive_date="+receive_date+"&start="+start+"&pagenumber="+pagenumber+"&filter_by="+filter_by;
	var xhttp = new XMLHttpRequest();
    xhttp.onreadystatechange = function() {
    if (xhttp.readyState == 4 && xhttp.status == 200) { 
		var data = xhttp.responseText.split('[BRK]');
		document.getElementById('list_pending').innerHTML = data[0];
		document.getElementById('receive_usercode').value = data[2];
		document.getElementById('receive_date').value = data[1];
		document.getElementById('receive_usercode').readOnly = true;
		document.getElementById('receive_date').readOnly = true;
		document.getElementById('chk_rmadt_id_'+rmadt_id).checked = true;
	  }
   };
    xhttp.open("GET", str, true);
    xhttp.send();
	}
  }
}
function deliver(){
	var rmadt_id = document.getElementById('rmadt_id').value;
	if(rmadt_id == ""){
		alert("Please choose a record!");
	}
	else{
	var deliver_date = document.getElementById('deliver_date').value;
	var c = confirm("Are you sure?");
	if(c){
	var start = document.getElementById('start_par').value;
	var pagenumber = document.getElementById('pagenumber_par').value;
	var filter_by = document.getElementById('filter_by').value;
	var str = "Form_ListRMAPendingItems_Actions.php?actionmode=deliver&rmadt_id="+rmadt_id+"&deliver_date="+deliver_date+"&start="+start+"&pagenumber="+pagenumber+"&filter_by="+filter_by;
	var xhttp = new XMLHttpRequest();
    xhttp.onreadystatechange = function() {
    if (xhttp.readyState == 4 && xhttp.status == 200) { 
		var data = xhttp.responseText.split('[BRK]');
		document.getElementById('list_pending').innerHTML = data[0];
		document.getElementById('deliver_usercode').value = data[1];
		document.getElementById('deliver_date').value = data[2];
		document.getElementById('deliver_usercode').readOnly = true;
		document.getElementById('deliver_date').readOnly = true;
		document.getElementById('chk_rmadt_id_'+rmadt_id).checked = true;
	  }
   };
    xhttp.open("GET", str, true);
    xhttp.send();
	}
  }
}
function displayDate(rmadt_id){
	var str = "Form_ListReturnRMAPendingItems_Actions.php?actionmode=displaydates&rmadt_id="+rmadt_id;
	var xhttp = new XMLHttpRequest();
    xhttp.onreadystatechange = function() {
    if (xhttp.readyState == 4 && xhttp.status == 200) {
		var data = xhttp.responseText.split('[BRK]');
		document.getElementById('receive_usercode').value = data[0];
		document.getElementById('receive_date').value = data[1];
		document.getElementById('receive_usercode').readOnly = true;
		document.getElementById('receive_date').readOnly = true;
		document.getElementById('rmadt_ReturnInvNo').value = data[2];
		document.getElementById('rmadt_ReturnDate').value = data[3];
		document.getElementById('rmadt_ReturnCur').value = data[4];
		document.getElementById('rmadt_ReturnAmount').value = data[5];
		document.getElementById('rmadt_transferno').value = data[6];
		document.getElementById('rmadt_NewInvNo').value = data[7];
		document.getElementById('rmadt_NewDate').value = data[8];
		document.getElementById('rmadt_NewCur').value = data[9];
		document.getElementById('rmadt_NewAmount').value = data[10];
		document.getElementById('item_coderep').value = data[11];
		document.getElementById('serial_numberRep').value = data[12];
		document.getElementById('rmadt_RejectedRemark').value = data[13];
	  }
   };
    xhttp.open("GET", str, true);
    xhttp.send();
}
function chkFilter(value){
	document.getElementById('start_par').value = 0;
	document.getElementById('pagenumber_par').value = 1;
	var start = document.getElementById('start_par').value;
	var pagenumber = document.getElementById('pagenumber_par').value;
	var str = "Form_ListReturnRMAPendingItems_Actions.php?actionmode=gofilterby&filter_by="+value+"&start="+start+"&pagenumber="+pagenumber;
	document.getElementById('filter_by').value = value;
	var xhttp = new XMLHttpRequest();
    xhttp.onreadystatechange = function() {
    if (xhttp.readyState == 4 && xhttp.status == 200) {
		var data = xhttp.responseText.split('[BRK]');
		document.getElementById('list_pending').innerHTML = data[0];
	}
   };
    xhttp.open("GET", str, true);
    xhttp.send();
}
function openCreditNote(){
	document.getElementById('credit_note').style.display = "block";
	document.getElementById('replacement').style.display = "none";
	document.getElementById('rejected').style.display = "none";
}
function openReplacement(){
	document.getElementById('credit_note').style.display = "none";
	document.getElementById('replacement').style.display = "block";
	document.getElementById('rejected').style.display = "none";
}
function openRejected(){
	document.getElementById('credit_note').style.display = "none";
	document.getElementById('replacement').style.display = "none";
	document.getElementById('rejected').style.display = "block";
}
function saveCreditNote(){
	var rmadt_id = document.getElementById('rmadt_id').value;
	if(rmadt_id == ""){
		alert("Please choose a record!");
	}
	else{
		var rmadt_ReturnInvNo = document.getElementById('rmadt_ReturnInvNo').value;
		var rmadt_ReturnDate = document.getElementById('rmadt_ReturnDate').value;
		var rmadt_ReturnCur = document.getElementById('rmadt_ReturnCur').value;
		var rmadt_ReturnAmount = document.getElementById('rmadt_ReturnAmount').value;
		var rmadt_transferno = document.getElementById('rmadt_transferno').value;
		var start = document.getElementById('start_par').value;
		var pagenumber = document.getElementById('pagenumber_par').value;
		var filter_by = document.getElementById('filter_by').value;
		var str = "Form_ListReturnRMAPendingItems_Actions.php?actionmode=savecreditnote&rmadt_id="+rmadt_id+"&rmadt_ReturnInvNo="+rmadt_ReturnInvNo+"&rmadt_ReturnDate="+rmadt_ReturnDate+"&rmadt_ReturnCur="+rmadt_ReturnCur+"&rmadt_ReturnAmount="+rmadt_ReturnAmount+"&rmadt_transferno="+rmadt_transferno+"&start="+start+"&pagenumber="+pagenumber+"&filter_by="+filter_by;
		var xhttp = new XMLHttpRequest();
        xhttp.onreadystatechange = function() {
        if (xhttp.readyState == 4 && xhttp.status == 200) {
		    var data = xhttp.responseText.split('[BRK]');
		    document.getElementById('list_pending').innerHTML = data[0];
	    }
       };
       xhttp.open("GET", str, true);
       xhttp.send();
	}
}
function saveReplacement(){
	var rmadt_id = document.getElementById('rmadt_id').value;
	if(rmadt_id == ""){
		alert("Please choose a record!");
	}
	else{
		var rmadt_NewInvNo = document.getElementById('rmadt_NewInvNo').value;
		var rmadt_NewDate = document.getElementById('rmadt_NewDate').value;
		var rmadt_NewCur = document.getElementById('rmadt_NewCur').value;
		var rmadt_NewAmount = document.getElementById('rmadt_NewAmount').value;
		var item_coderep = document.getElementById('item_coderep').value;
		var serial_numberRep = document.getElementById('serial_numberRep').value;
		var start = document.getElementById('start_par').value;
		var pagenumber = document.getElementById('pagenumber_par').value;
		var filter_by = document.getElementById('filter_by').value;
		var str = "Form_ListReturnRMAPendingItems_Actions.php?actionmode=savereplacement&rmadt_NewInvNo="+rmadt_NewInvNo+"&rmadt_NewDate="+rmadt_NewDate+"&rmadt_NewCur="+rmadt_NewCur+"&rmadt_NewAmount="+rmadt_NewAmount+"&item_coderep="+item_coderep+"&serial_numberRep="+serial_numberRep+"&rmadt_id="+rmadt_id+"&start="+start+"&pagenumber="+pagenumber+"&filter_by="+filter_by;
		var xhttp = new XMLHttpRequest();
        xhttp.onreadystatechange = function() {
        if (xhttp.readyState == 4 && xhttp.status == 200) {
		    var data = xhttp.responseText.split('[BRK]');
		    document.getElementById('list_pending').innerHTML = data[0];
	    }
       };
       xhttp.open("GET", str, true);
       xhttp.send();
	}
}
function openListItems(){
	var str = "List_SorItems.php?frm=18&ItemType=All";
	window.open(str, 'myWindow2', 'toolbar=no,location=no,status=yes,menubar=no,scrollbars=yes,resizable=yes,width=871,height=500,top=50');
}
function saveRejected(){
	var rmadt_id = document.getElementById('rmadt_id').value;
	if(rmadt_id == ""){
		alert("Please choose a record!");
	}
	else{
		var rmadt_RejectedRemark = document.getElementById('rmadt_RejectedRemark').value;
		var start = document.getElementById('start_par').value;
		var pagenumber = document.getElementById('pagenumber_par').value;
		var filter_by = document.getElementById('filter_by').value;
		var str = "Form_ListReturnRMAPendingItems_Actions.php?actionmode=saverejected&rmadt_RejectedRemark="+rmadt_RejectedRemark+"&rmadt_id="+rmadt_id+"&start="+start+"&pagenumber="+pagenumber+"&filter_by="+filter_by;
		var xhttp = new XMLHttpRequest();
        xhttp.onreadystatechange = function() {
        if (xhttp.readyState == 4 && xhttp.status == 200) {
		    var data = xhttp.responseText.split('[BRK]');
		    document.getElementById('list_pending').innerHTML = data[0];
	     }
        };
        xhttp.open("GET", str, true);
        xhttp.send();
	}
}
function clearStatus(){
	document.getElementById('credit_note').style.display = "none";
	document.getElementById('replacement').style.display = "none";
	document.getElementById('rejected').style.display = "none";
	var c = confirm("Are you sure?");
	if(c){
		var rmadt_id = document.getElementById('rmadt_id').value;
		if(rmadt_id == ""){
		alert("Please choose a record!");
	    }
	    else{
		//var rmadt_RejectedRemark = document.getElementById('rmadt_RejectedRemark').value;
		var start = document.getElementById('start_par').value;
		var pagenumber = document.getElementById('pagenumber_par').value;
		var filter_by = document.getElementById('filter_by').value;
		var str = "Form_ListReturnRMAPendingItems_Actions.php?actionmode=clearstatus&rmadt_id="+rmadt_id+"&start="+start+"&pagenumber="+pagenumber+"&filter_by="+filter_by;
		var xhttp = new XMLHttpRequest();
        xhttp.onreadystatechange = function() {
        if (xhttp.readyState == 4 && xhttp.status == 200) {
		    var data = xhttp.responseText.split('[BRK]');
		    document.getElementById('list_pending').innerHTML = data[0];
	     }
        };
        xhttp.open("GET", str, true);
        xhttp.send();
	   }
	}
	//document.getElementById('start_par').value = 0;
	//document.getElementById('pagenumber_par').value = 1;
}
function moveNext(){
	document.getElementById('start_par').value = Number(document.getElementById('start_par').value) + 20;
	document.getElementById('pagenumber_par').value = Number(document.getElementById('pagenumber_par').value) + 1;
	var start = document.getElementById('start_par').value;
	var pagenumber = document.getElementById('pagenumber_par').value;
	var filter_by = document.getElementById('filter_by').value;
	var str = "Form_ListReturnRMAPendingItems_Actions.php?actionmode=movenext&start="+start+"&pagenumber="+pagenumber+"&filter_by="+filter_by;
	var xhttp = new XMLHttpRequest();
	xhttp.onreadystatechange = function() {
	if (xhttp.readyState == 4 && xhttp.status == 200) {
		var data = xhttp.responseText.split('[BRK]');
		document.getElementById('list_pending').innerHTML = data[0];
	}
   };
    xhttp.open("GET", str, true);
    xhttp.send();
}
function movePrev(){
	document.getElementById('start_par').value = Number(document.getElementById('start_par').value) - 20;
	document.getElementById('pagenumber_par').value = Number(document.getElementById('pagenumber_par').value) - 1;
	var start = document.getElementById('start_par').value;
	var pagenumber = document.getElementById('pagenumber_par').value;
	var filter_by = document.getElementById('filter_by').value;
	var str = "Form_ListReturnRMAPendingItems_Actions.php?actionmode=moveprev&start="+start+"&pagenumber="+pagenumber+"&filter_by="+filter_by;
	var xhttp = new XMLHttpRequest();
	xhttp.onreadystatechange = function() {
	if (xhttp.readyState == 4 && xhttp.status == 200) {
		var data = xhttp.responseText.split('[BRK]');
		document.getElementById('list_pending').innerHTML = data[0];
	}
   };
    xhttp.open("GET", str, true);
    xhttp.send();
}
function expectedDate(){
	var rmadt_expectedDate = document.getElementById('rmadt_expectedDate').value;
	var rmadt_id = document.getElementById('rmadt_id').value;
	var start = document.getElementById('start_par').value;
	var pagenumber = document.getElementById('pagenumber_par').value;
	var filter_by = document.getElementById('filter_by').value;
	if(rmadt_id == ""){
		alert("Please choose a record!");
	}
	else
	if(rmadt_expectedDate == ""){
		alert("Please add the expected date!");
	}
	else{
		var str = "Form_ListReturnRMAPendingItems_Actions.php?actionmode=expecteddate&rmadt_expectedDate="+rmadt_expectedDate+"&rmadt_id="+rmadt_id+"&start="+start+"&pagenumber="+pagenumber+"&filter_by="+filter_by;
		var xhttp = new XMLHttpRequest();
	xhttp.onreadystatechange = function() {
	if (xhttp.readyState == 4 && xhttp.status == 200) {
		var data = xhttp.responseText.split('[BRK]');
		document.getElementById('list_pending').innerHTML = data[0];
	}
   };
    xhttp.open("GET", str, true);
    xhttp.send();
	}
}
</script>

<title>List of Pending Items</title>
</head>
<body>
<input type='hidden' name='actionmode' id='actionmode' value='insert'>
<input type='hidden' name='RMA_Id' id='RMA_Id' value=''>
HERE;




echo"<table cellpadding='0' cellspacing='0' border='0'  align='center' class='layout-width'>";
include_once("header.php");
echo" <tr><td  valign='top'>";

include_once("sidemenu.php");
echo"  </td></tr>";

echo" <tr style='height:16px;'>
		<td  valign='top' id='content-top'>
			<table border='0' cellpadding='0' cellspacing='0' style='table-layout:fixed; height:26px;' class='layout-width'>
			<tr style='height:16px;'>
				<td style='width:38px;'>&nbsp;</td>
				<td valign='middle' style='width:300px; height:26px;'><span class='title'>List of Pending Items</span></td>
				<td class='message' valign='middle' style='height:26px;'>".htmlspecialchars($message, ENT_QUOTES)."</td>
			</tr></table>
		</td>
	  </tr>";
	  

echo"<tr>
		<td  height='13'  valign='top' id='content-top2'>
			<table border='0' cellpadding='0' cellspacing='0' class='layout-width'>
			<tr>
				
				<td>";
	


echo"   </td></tr>";
echo"	</table>";
echo"</td></tr>";

$strt = $_SESSION['StartFinancial_Date'];
$end = $_SESSION['EndFinancial_Date'];
$curr_date = date("d/m/Y");

$query_setup  = "select base1, base2 from setup";
$result_setup = mysql_query($query_setup, $connection); 
$row_setup    = mysql_fetch_array($result_setup);
extract($row_setup);
$date = date("d/m/Y");
echo"<tr><td id='content-body' style='text-align: left'>

&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span style='font-size: 14px'>
  <b><u>Filter By:</u></b>
  <input type='radio' name='filter_by' id='filter_by_all' onclick=\"chkFilter('all')\" value='all' style='cursor: pointer' checked /> All 
  <input type='radio' name='filter_by' id='filter_by_C' onclick=\"chkFilter('C')\" value='C' style='cursor: pointer' /> C: Credit
  <input type='radio' name='filter_by' id='filter_by_P' onclick=\"chkFilter('P')\" value='P' style='cursor: pointer' /> P: Replacement 
  <input type='radio' name='filter_by' id='filter_by_X' value='X' onclick=\"chkFilter('X')\" style='cursor: pointer' />X : Rejected
<input type='hidden' id='filter_by' value='all' />
		</span>
<div style='height: 10px;'></div>
<div style='margin-left: 48px; width:500px; display: inline-block'>
<table width=500>
<tr>
<td style='width: 100px; font-size: 14px; font-weight: bold'>Received</td>
<td style='width: 100px'><input type='text' id='receive_usercode' style='width: 100%' /></td>
<td style='width: 200px'><input type='text' id='receive_date' style='width: 88%' value='$date' /> <A HREF='#' onClick=\"displayCalendar(document.getElementById('receive_date'),'dd/mm/yyyy',this);  return false; \" NAME=\"anchor1\" ID=\"anchor1\"><img src='./img/cal.gif' border=0 align=center></A></td>
<td style='width: 100px'><button id='received' onclick=\"receive()\"><span><span>Received</span></span></button></td>
</tr>
<tr>
<td></td>
<td style='text-align: center; font-size: 12px'>User</td>
<td style='text-align: center; font-size: 12px'>Date</td>
</tr> 
</table>
<div style='margin-left: 44px; margin-top: 15px;'>
<button onclick=\"openCreditNote()\"><span><span>C: Credit Note</span></span></button> <button onclick=\"openReplacement()\"><span><span>P: Replacement</span></span></button> <button onclick=\"openRejected()\"><span><span>X:Rejected</span></span></button> <button onclick=\"clearStatus()\"><span><span>Clear Status</span></span></button>
</div>
</div>
<div id='main_whole' style='margin-left: 48px; width:400px; display: inline-block; vertical-align: top; font-size: 12px;'>

<div id='credit_note' style='display: none'>
<table width=350>
<tr>
<td style='font-size: 12px; font-weight: bold'>Return Invoice No.</td>
<td><input type='text' name='rmadt_ReturnInvNo' id='rmadt_ReturnInvNo' style='width: 150px' /></td>
</tr>
<tr>
<td style='font-size: 12px; font-weight: bold'>Return Date</td>
<td><input type='text' name='rmadt_ReturnDate' id='rmadt_ReturnDate' value='$date' style='width: 150px' /> <A HREF='#' onClick=\"displayCalendar(document.getElementById('rmadt_ReturnDate'),'dd/mm/yyyy',this);  return false; \" NAME=\"anchor1\" ID=\"anchor1\"><img src='./img/cal.gif' border=0 align=center></A></td>
</tr>
<tr>
<td style='font-size: 12px; font-weight: bold'>Return Amount</td>
<td><select name='rmadt_ReturnCur' id='rmadt_ReturnCur' style='width: 70px'>
<option value=''></option>";
$query_currency  = "select currency_code as CurrencyCode from currency";
$result_currency = mysql_query($query_currency, $connection); 
while($row_currency = mysql_fetch_array($result_currency)){
	extract($row_currency);
	if($CurrencyCode == $base1){
		$selected = "selected='selected'";
	}
	else{
		$selected = "";
	}
	echo "<option value='$CurrencyCode' $selected>$CurrencyCode</option>";
}
echo"</select><input type='text' name='rmadt_ReturnAmount' id='rmadt_ReturnAmount' style='width: 80px' /></td>
</tr>
<tr>
<td style='font-size: 12px; font-weight: bold'>Transfer No.</td>
<td><input type='text' name='rmadt_transferno' id='rmadt_transferno' style='width: 150px' /></td>
</tr>
<tr>
<td></td>
<td style='text-align: right'><button onclick=\"saveCreditNote()\"><span><span>Save</span></span></button>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</td>
</tr>
</table>
</div>

<div id='replacement' style='display: none'>
<table width=350>
<tr>
<td style='font-size: 12px; font-weight: bold'>New Invoice No.</td>
<td><input type='text' name='rmadt_NewInvNo' id='rmadt_NewInvNo' style='width: 150px' /></td>
</tr>
<tr>
<td style='font-size: 12px; font-weight: bold'>New Date</td>
<td><input type='text' name='rmadt_NewDate' id='rmadt_NewDate' style='width: 150px' value='$date' /> <A HREF='#' onClick=\"displayCalendar(document.getElementById('rmadt_NewDate'),'dd/mm/yyyy',this);  return false; \" NAME=\"anchor1\" ID=\"anchor1\"><img src='./img/cal.gif' border=0 align=center></A></td>
</tr>
<tr>
<td style='font-size: 12px; font-weight: bold'>New Amount</td>
<td><select name='rmadt_NewCur' id='rmadt_NewCur' style='width: 70px'>
<option value=''></option>";
$query_currency  = "select currency_code as CurrencyCode from currency";
$result_currency = mysql_query($query_currency, $connection); 
while($row_currency = mysql_fetch_array($result_currency)){
	extract($row_currency);
	if($CurrencyCode == $base1){
		$selected = "selected='selected'";
	}
	else{
		$selected = "";
	}
	echo "<option value='$CurrencyCode' $selected>$CurrencyCode</option>";
}
echo"</select><input type='text' name='rmadt_NewAmount' id='rmadt_NewAmount' style='width: 80px' /></td>
</tr>
<tr>
<td style='font-size: 12px; font-weight: bold'>New Part No.</td>
<td><input type='text' name='item_coderep' id='item_coderep' style='width: 150px' /> <img src='img/btnopen.jpg' width=17 style='cursor: pointer' onclick=\"openListItems()\" /></td>
</tr>
<tr>
<td style='font-size: 12px; font-weight: bold'>New Serial No.</td>
<td><input type='text' name='serial_numberRep' id='serial_numberRep' style='width: 150px' /></td>
</tr>
<tr>
<td></td>
<td style='text-align: right'><button onclick=\"saveReplacement()\"><span><span>Save</span></span></button>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</td>
</tr>
</table>
</div>

<div id='rejected' style='display: none'>
<table width=550>
<tr>
<td style='font-size: 12px; font-weight: bold'>Rejected Remark</td>
<td><input type='text' id='rmadt_RejectedRemark' name='rmadt_RejectedRemark' style='width: 350px' /></td>
</tr>
<tr>
<td></td>
<td style='text-align: right'><button onclick=\"saveRejected()\"><span><span>Save</span></span></button>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</td>
</tr>
</table>
</div>

</div>

<div style='height: 20px;'></div>";
echo "<div style='margin-left: 48px; font-size: 12px; font-weight: bold'>Expected Date: <input type='text' name='rmadt_expectedDate' id='rmadt_expectedDate' value='$date' /> <A HREF='#' onClick=\"displayCalendar(document.getElementById('rmadt_expectedDate'),'dd/mm/yyyy',this);  return false; \" NAME=\"anchor1\" ID=\"anchor1\"><img src='./img/cal.gif' border=0 align=center></A> <button onclick=\"expectedDate()\"><span><span>Submit</span></span></button></div>";
echo"<div style='height: 20px;'></div>";
echo"<div id='list_pending'>";
drawReturnRMAPendingItems($connection);
echo"</div>		
</td></tr>";

echo" <tr height='30'><td align='center' id='content-bottom' ></td></tr>";
include("footer.php");	
echo" </table>  ";//end of last table menu





print <<<HERE


</body>
</html>

HERE;

?>