<link rel="stylesheet" type="text/css" href="script/tabcontent.css" />
<script type="text/javascript" src="script/tabcontent.js"></script>
<script type="text/javascript" src="script/jquery-1.4.2.min.js"></script>
<script type="text/javascript" src="js/dynamicRow.js"></script>

<script type="text/javascript">
function showbalance(str)
{
     
    var StockBalance=document.getElementById("stockbal").value;	
	var Issuequantity=document.getElementById("issueqty").value;	
	var RemaningBalance =StockBalance-Issuequantity;
	document.getElementById('remaningbalance').value =RemaningBalance;
	
}

</script>
<script language="javascript">
 var xmlHttp
function showsitename(str)
{ 
 
   xmlHttp=GetXmlHttpObject();
		if (xmlHttp==null)
		  {
		    alert ("Your browser does not support AJAX!");
		    return;
		  } 
	var url="sitename.php";
	url=url+"?site_name="+str;
	xmlHttp.onreadystatechange=change1;
	xmlHttp.open("GET",url,true);
	xmlHttp.send(null);
}
function change1() 
{ 
	if (xmlHttp.readyState==4)
	{ 
	   document.getElementById("txtsite").innerHTML=xmlHttp.responseText;
	}
}
function GetXmlHttpObject()
{
	var xmlHttp=null;
	try
	  {
	  // Firefox, Opera 8.0+, Safari
	  xmlHttp=new XMLHttpRequest();
	  }
	catch (e)
	  {
	  // Internet Explorer
	  try
		{
		xmlHttp=new ActiveXObject("Msxml2.XMLHTTP");
		}
	  catch (e)
		{
		xmlHttp=new ActiveXObject("Microsoft.XMLHTTP");
		}
	  }
	return xmlHttp;
}
</script>
<?php

/* $Revision: 1.31 $ */

/*
*      addreturnslip.php
*
*      webERP Linux-Apache-MySQL-PHP based accounting system
*      Copyright Logic Works Ltd - 2007 - Contact: info@acgil.com
*
*  This program is free software; you can redistribute it and/or modify
*  it under the terms of the GNU General Public License as published by
*  the Free Software Foundation; either version 2 of the License, or
*  (at your option) any later version.
*
*  This program is distributed in the hope that it will be useful,
*  but WITHOUT ANY WARRANTY; without even the implied warranty of
*  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
*  GNU General Public License for more details.
*
*  You should have received a copy of the GNU General Public License
*  along with this program; if not, write to the Free Software
*  Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
*  MA 02110-1301, USA.
*
*
*  modifications and add-ons started from:
*   Revision: 1.18
*  by Thomas Pulina
*  <hollerland@nord-com.net>|<thomas.pulina@wagner-bremen.de>
*  2008
*
*/

$PageSecurity = 4;
ob_start();
include('includes/DefinePOClass.php');
include('includes/session.inc');
if (isset($_GET['ModifyOrderNumber']) and $_SESSION[UserStockLocation]== "HO01")  {
	$title = _('Modify Purchase Order') . ' ' . $_GET['ModifyOrderNumber'];
} else {
	//$title = _('Add Issue Slip');

}

$title = _('View Return Slip');

include('includes/header.inc');
//include('includes/SQL_CommonFunctions.inc');

/*If the page is called is called without an identifier being set then
 * it must be either a new order, or the start of a modification of an
 * order, and so we must create a new identifier.
 * 
 * The identifier only needs to be unique for this php session, so a 
 * unix timestamp will be sufficient.
 */
 
  /*$date1=date('M-Y');
  $date2=date('Y-m-d');*/
 
		if (empty($_GET['identifier'])) {
			 $identifier=date('U');
		} else {
			 $identifier=$_GET['identifier'];
			
		}
		
		/*Page is called with NewOrder=Yes when a new order is to be entered
		 * the session variable that holds all the PO data $_SESSION['MR'][$identifier] 
		 * is unset to allow all new details to be created */
		///////////////////////////////////////////// Add IUssue Slip  Form  By Amit Kumar////////////////////////////////////////
		 $date = date($_SESSION['DefaultDateFormat']);
		 
if(isset($_POST['Update']))
{
	//echo "<pre>";print_r($_POST); 	
	 $_POST['PRDate']=Date($_SESSION['DefaultDateFormat']);
	$_POST['DatePrinted']=Date($_SESSION['DefaultDateFormat']);
	ConvertSQLDate($_SESSION['MR'.$identifier]->Orig_OrderDate);
	$qty=$_REQUEST['itemcode'];
	 $qty1=count($qty);
	  				$sql = "UPDATE Addreturnslip SET 
	  									   `SiteCode`='".$_POST['sitecode']."', 
										   `SiteName`='".$_POST['sitename']."', 
										   `ReturnDate`='".FormatDateForSQL($_POST['returndate'])."', 
										   `IssueSlipRef`='".$_POST['issueslipref']."', 
										   `IssueDate`='".FormatDateForSQL($_POST['issuedate'])."',
										   `StockType`='".$_POST['stocktype']."', 
										   `IssueCategory`='".$_POST['issuecategory']."', 
										   `Jobno`='".$_POST['jobno']."',
										   `ReceiptFrom`='".$_POST['receiptfrom']."', 
										   `ReferredBy`='".$_POST['refferedby']."', 
											`ReferredName`='".$_POST['referredname']."', 
											`PartyCode`='".$_POST['partycode']."', 
											`PCworkorder`='".$_POST['pcworkorder']."', 
											`OrderDate`='".FormatDateForSQL($_POST['orderdate'])."', 
											`StoreCode`='".$_POST['storecode']."', 
											`StoreName`='".$_POST['storename']."', 
											`remark`='".$_POST['remark']."', 
											`createdby`='".$_SESSION[UserID]."'
											where id='".$_GET['ReturnId']."'";
          	 	$ErrMsg = _('An error occurred Record Note Save') . '. ' . _('The error says');
				$UpdateResult = DB_query($sql,$db,$ErrMsg);
			 	//$Lastreq_id=DB_Last_Insert_ID($db,'Addreturnslip',$ErrMsg);
			
			$Select_sql = "Select * from addreturnqty Where Returnid='".$_REQUEST['ReturnId']."'";
			$Showrow = DB_query($Select_sql,$db,$ErrMsg);
			$i=1;
			while($result =DB_fetch_array($Showrow))
			{		
				                     $sql ="UPDATE addreturnqty SET
									`ItemCode`='".$_POST['itemcode'][$i]."', 
									`Description`='".$_POST['desc'][$i]."',
									`Make`='".$_POST['make'][$i]."', 
									`Color`='".$_POST['color'][$i]."', 
									`Grade`='".$_POST['gread'][$i]."', 
									`UOM`='".$_POST['uom'][$i]."', 
									`ItemStatus`='".$_POST['itemstatus'][$i]."', 
									`ReturnQty`='".$_POST['returnqty'][$i]."', 
									`DebitableAmt`='".$_POST['debitableamt'][$i]."'	
									 WHERE id='".$result['id']."'"; 
									$ErrMsg = _('An error occurred Record Note Save') . '. ' . _('The error says');
									$Result = DB_query($sql,$db);
								  $i++; 
								if($Result == true)
								 {
								 	 header('location:Return_Slip_show.php?NewOrder=Yes');
								 }
			}
				
			 
			
 }
 
$sql = 'SELECT addreturnslip.id, 
                addreturnslip.SiteCode,
				addreturnslip.SiteName,
				addreturnslip.ReturnSlipNo,
				addreturnslip.ReturnDate,   
				addreturnslip.IssueSlipRef,  
				addreturnslip.IssueDate,     
				addreturnslip.StockType,  
				addreturnslip.IssueCategory,  
				addreturnslip.Jobno,
				addreturnslip.ReceiptFrom,
				addreturnslip.ReferredBy,
				addreturnslip.ReferredName,   
				addreturnslip.PartyCode,  
				addreturnslip.PCworkorder,     
				addreturnslip.OrderDate,  
				addreturnslip.StoreCode,  
				addreturnslip.StoreName,
				addreturnslip.remark,
				addreturnslip.createdby   
				FROM addreturnslip where id ='.$_GET['ReturnId'].'';
				 $showresult = DB_query($sql,$db);
				 $mysqlrow=DB_fetch_array($showresult);
				 $StockType      = $mysqlrow['StockType'];
				 $site_code      = $mysqlrow['SiteCode'];
				 $ReceiptFrom    = $mysqlrow['ReceiptFrom'];
				 $IssueCategory  = $mysqlrow['IssueCategory'];
				 $StoreCode      = $mysqlrow['StoreCode'];
 

 ?>
<form name="form1"  action="" method="post">
<table width="90%" border="2" cellspacing="0" cellpadding="0">

  <tr>
    <td height="40" colspan="5" align="center" bgcolor="#999999"> <div align="center"><b><font color="#FFFFFF"><?php echo $title; ?></font></b></div> </td>
  </tr>
  <tr>
    <td height="20" colspan="5" align="center" bgcolor="#999999"> <div align="Left"><b><font color="#FFFFFF">General Details</font></b></div> </td>
  </tr>
  
  <tr>
    <td width="16%">Site Code </td>
    <td width="16%"><?php echo $mysqlrow['SiteCode']; ?>	   	</td>
    <td width="18%" id="txtsite" >&nbsp;</td>
    <td width="15%">Store Code </td>
    <td width="35%"><table width="100%" border="0" cellspacing="0" cellpadding="0">
      <tr>
        <td width="39%"><?php echo $StoreCode; ?></td>
        <td width="61%" id="txtid">&nbsp;</td>
      </tr>
    </table></td>
  </tr>
  <tr>
    <td>Site Name </td>
    <td colspan="2"><?php echo $mysqlrow['SiteName']; ?></td>
    <td>Store Name </td>
    <td><?php echo $mysqlrow['StoreName']; ?></td>
  </tr>
  <tr>
    <td>Return  Slip No </td>
    <td colspan="2"><?php echo $mysqlrow['ReturnSlipNo']; ?></td>
    <td>Return  Date </td>
    <td><?php echo ConvertSQLDate($mysqlrow['ReturnDate']); ?></td>
  </tr>
  <tr>
    <td>Issue  Slip Ref. </td>
    <td colspan="2"><?php echo $mysqlrow['IssueSlipRef']; ?>"</td>
    <td>Issue Date</td>
    <td id="txtreqid" ><?php echo ConvertSQLDate($mysqlrow['IssueDate']); ?></td>
  </tr>
  <tr>
    <td>Stock Type </td>
    <td colspan="2"><?PHP echo $StockType; ?>		</td>
    <td>Issue Category </td>
    <td><table width="100%" border="0" cellpadding="0" cellspacing="0">
      <tr>
        <td width="42%">
		<?php echo $IssueCategory; ?>	</td>
        <td width="17%">Job No. </td>
        <td width="41%"><?php echo $mysqlrow['Jobno']; ?></td>
      </tr>
    </table></td>
  </tr>
  <tr>
    <td>Receipt From  </td>
    <td colspan="2"><?php echo $ReceiptFrom;?>	</td>
    <td>Referred By </td>
    <td><table width="100%" border="0" cellspacing="0" cellpadding="0">
      <tr>
        <td width="45%"><?php  echo  $mysqlrow['ReferredBy']; ?></td>
        <td width="55%"><?php echo $mysqlrow['ReferredName']; ?></td>
      </tr>
    </table></td>
  </tr>
  <tr>
    <td>Party Code </td>
    <td colspan="2"><?php echo PartyCode;  ?></td>
    <td>PC Work Order No. </td>
    <td><?php echo $mysqlrow['PCworkorder']; ?></td>
  </tr>
  <tr>
    <td>Order Date </td>
    <td colspan="2"><?php echo ConvertSQLDate($mysqlrow['OrderDate']); ?></td>
    <td>&nbsp;</td>
    <td>&nbsp;</td>
  </tr>
  
  <tr>
    <td>&nbsp;</td>
    <td colspan="2">&nbsp;</td>
    <td>&nbsp;</td>
    <td>&nbsp;</td>
  </tr>
  
  <tr>
    <td colspan="5">&nbsp;</td>
  </tr>
  <tr>
    <td colspan="5" bgcolor="#999999"><b><font color="#FFFFFF">Item Details</font></b> </td>
  </tr>
  <tr>
    <td colspan="5">



<table width="100%" border="1" cellspacing="0" cellpadding="0" id="txtdetail">
  <tr>
  <td width="16%">Item Code</td>
    <td width="12%">Description</td>
    <td width="6%">Make</td>
    <td width="6%">Color</td>
    <td width="6%">Grade</td>
    <td width="6%">UOM</td>
    <td width="9%">Item Status</td>
    <td width="11%">Return  Qty </td>
    <td width="9%">Debitable Amt For NOK Qty (if any) </td>
	</tr>
   <tr>

     <td colspan="9"><div style="float:left">
	 <!--<input type="button" class="crmbutton small delete"  onclick="addRow('dataTable')" value="Add" />&nbsp;
	 <input type="button" class="crmbutton small delete"  onclick="deleteRow('dataTable')" value="Delete" />-->
	 </div>	 </td>
     </tr>
    <tr>
 <td colspan="9"><table width="100%" border="0" cellspacing="0" cellpadding="0">
 <?php 
 
 $Returnid = $_REQUEST['ReturnId'];
  $sql = 'SELECT addreturnqty.id, 
                addreturnqty.Returnid,
				addreturnqty.ItemCode,
				addreturnqty.Description,
				addreturnqty.Make,   
				addreturnqty.Color,  
				addreturnqty.Grade,
				addreturnqty.UOM,
				addreturnqty.ItemStatus,
				addreturnqty.ReturnQty,
				addreturnqty.DebitableAmt   
				FROM addreturnqty where Returnid='.$Returnid.'';
				 $showresult = DB_query($sql,$db);
				$i=1;
				while($Resultrow = DB_fetch_array($showresult))
				{   
				 $slelect_make     = $Resultrow['Make']; 
				 $slelect_color    = $Resultrow['Color'];
				 $slelect_Grade    = $Resultrow['Grade'];
				 $slelect_UOM 	   = $Resultrow['UOM'];
				
 ?>
 
   <tr>
     <td width="17%"><div align="center"><?php echo $Resultrow['ItemCode']; ?></div></td>
     <td width="15%"><div align="center"><?php echo $Resultrow['Description']; ?></div></td>
     <td width="9%"><div align="center"><?php echo $slelect_make;?></div></td>
     <td width="8%"><div align="center"><?php echo $Resultrow['Color']; ?></div></td>
     <td width="8%"> <div align="center"><?php echo $slelect_Grade; ?></div></td>
     <td width="9%"> <div align="center"><?php echo $slelect_UOM; ?></div></td>
     <td width="11%"><div align="center"><?php echo $Resultrow['ItemStatus']; ?></div></td>
     <td width="13%"><div align="center"><?php echo $Resultrow['ReturnQty']; ?></div></td>
     <td width="10%"><div align="center"><?php echo $Resultrow['DebitableAmt']; ?></div></td>
     </tr>
   <?php  $i++; }  ?>
 </table></td>
  </tr>
  
  
     <td>&nbsp;</td>
     <td>&nbsp;</td>
     <td>&nbsp;</td>
     <td>&nbsp;</td>
     <td>&nbsp;</td>
     <td>&nbsp;</td>
     <td>&nbsp;</td>
     <td>&nbsp;</td>
     <td>&nbsp;</td>
	  </tr>
  </table></td>
  </tr>
  
  <tr>
    <td colspan="5">&nbsp;</td>
  </tr>
  <tr>
    <td colspan="5"><table width="100%" border="0" cellspacing="0" cellpadding="0">
      <tr>
        <td height="10"  bgcolor="#999999"><b><font color="#FFFFFF">Other Details</font> </b></td>
        </tr>
    </table></td>
    </tr>
   <tr>
    <td height="40">Remarks </td>
    <td colspan="4" align="center" height="40"><div align="center"><?php echo $mysqlrow['remark']; ?></div></td>
  </tr>
  <tr>
    <td>&nbsp;</td>
    <td colspan="2" align="right">&nbsp;</td>
    <td>&nbsp;&nbsp;</td>
    <td>&nbsp;</td>
  </tr>
  <tr>
    <td>&nbsp;</td>
    <td colspan="2" align="right">&nbsp;    </td>
    <td>&nbsp;&nbsp;<input type="reset" name="Submit2" value="Cancel" onclick="javascript:history.go(-1)"></td>
    <td>&nbsp;</td>
  </tr>
</table>

</form>

 <?
include('includes/footer.inc');
?>


<script type="text/javascript">

var countries=new ddtabcontent("countrytabs")
countries.setpersist(true)
countries.setselectedClassTarget("link") //"link" or "linkparent"
countries.init()

</script>
<script language="javascript">
function openPopupProfile(i)
				{
		window.open("issu_searchpopup.php?rowcount="+i,"profiles_popup_window","height=425,width=640,toolbar=no,menubar=no,dependent=yes,resizable =no");
	}

 var xmlHttp
function changestorename(str)
{ 
 
 // alert('hi');
   xmlHttp=GetXmlHttpObject();
		if (xmlHttp==null)
		  {
		    alert ("Your browser does not support AJAX!");
		    return;
		  } 
	var url="storename.php";
	url=url+"?store_code="+str;
	//alert(url);
	//url=url+"&sid="+Math.random();
	xmlHttp.onreadystatechange=NumberChanged1;
	xmlHttp.open("GET",url,true);
	xmlHttp.send(null);
}
function NumberChanged1() 
{ 
	if (xmlHttp.readyState==4)
	{ 
	   document.getElementById("txtid").innerHTML=xmlHttp.responseText;
	}
}
function GetXmlHttpObject()
{
	var xmlHttp=null;
	try
	  {
	  // Firefox, Opera 8.0+, Safari
	  xmlHttp=new XMLHttpRequest();
	  }
	catch (e)
	  {
	  // Internet Explorer
	  try
		{
		xmlHttp=new ActiveXObject("Msxml2.XMLHTTP");
		}
	  catch (e)
		{
		xmlHttp=new ActiveXObject("Microsoft.XMLHTTP");
		}
	  }
	return xmlHttp;
}
</script>

<script language="javascript">
 var xmlHttp
function requisition_detail(str)
{ 
   
   xmlHttp=GetXmlHttpObject();
		if (xmlHttp==null)
		  {
		    alert ("Your browser does not support AJAX!");
		    return;
		  } 
	var url="reqdetail.php";
	url=url+"?req_number="+str;
	
	//url=url+"&sid="+Math.random();
	xmlHttp.onreadystatechange=changedetail;
	
	xmlHttp.open("GET",url,true);
	xmlHttp.send(null);
}
function changedetail() 
{ 
	if (xmlHttp.readyState==4)
	{ 
	   var responsestr = xmlHttp.responseText;
	   resstr = responsestr.split("@@##@");
	   document.getElementById("reqdate").value=resstr[0];
	   document.getElementById("txtdetail").innerHTML=resstr[1];
	  
	}
}

function GetXmlHttpObject()
{
	var xmlHttp=null;
	try
	  {
	  // Firefox, Opera 8.0+, Safari
	  xmlHttp=new XMLHttpRequest();
	  }
	catch (e)
	  {
	  // Internet Explorer
	  try
		{
		xmlHttp=new ActiveXObject("Msxml2.XMLHTTP");
		}
	  catch (e)
		{
		xmlHttp=new ActiveXObject("Microsoft.XMLHTTP");
		}
	  }
	return xmlHttp;
}
</script>

