<link rel="stylesheet" type="text/css" href="css/professional/table_frize.css">
<?php
error_reporting("E_ALL");
$PageSecurity = 5;
?>

<link rel="stylesheet" href="css/new_mxerp.css">
<link rel="stylesheet" type="text/css" href="css/professional/table_frize.css">
<link rel="stylesheet" href="css/jquery.ui.all.css" />
<script src="js/jquery-1.5.1.js"></script>
<script src="ui/jquery.ui.core.js"></script>
<script src="ui/jquery.ui.widget.js"></script>


<?php
$sql=DB_query("select * from log_po where id='".$_REQUEST['SID']."'",$db);
$myrow1=DB_fetch_array($sql);

 
?>
	
			<form action="" method="post">
				<div style="width:auto; margin-left:auto; margin-right:auto;">


					<table width="96%" border="1" cellpadding="3" cellspacing="0">
			 <tr> <?php 
				  $sql="SELECT sitecode, requisition_site, prdate FROM materialrequisitions WHERE requisitionno='".$reqno."' and status='1'";
				  $result=DB_query($sql,$db);
				  $myrow = DB_fetch_array($result);
        
				  ?>
		<th width="11%" class="tabledata1">Location </th>
    <td width="17%"><table width="100%" border="0" cellspacing="0" cellpadding="0">
	<tr>
	  <td><?php
	if($_SESSION['AssignedBranch']!='')
	  {	  	
      $ss="Select loccode, locationname from locations  where CompanyId='".$_SESSION['ACGCompanyId']."'
    and loccode in('".$_SESSION['AssignedBranch']."')";
	  	 $site_sql=DB_query($ss,$db);
	  }
	  else
	  {
		$ss="Select loccode,locationname from locations where CompanyId='".$_SESSION['ACGCompanyId']."'";
		$site_sql=DB_query($ss,$db);
	  }?>
     <select name="site" disabled="disabled" id="sitecode" style="width:70px"    >
      <option value="0">---Select---</option>
      <?php
	while($site_row=DB_fetch_array($site_sql))
	{
	?>
      <option value="<?php echo $site_row['loccode'];?>"<?php echo ($myrow1['site']==$site_row['loccode']?'selected':'')?>><?php echo $site_row['loccode'];?></option>
      <?php } ?>
    </select></td>
	  <td><div id="txtsite">
	    <?php
	
	$site_sql="Select locationname from locations where loccode ='".$myrow1['site']."'";
	$site_res=DB_query($site_sql,$db);
	$site_row=DB_fetch_array($site_res);
	if(isset($myrow1['site']))
	{
	?>
	    <input name="sitename" type="text" id="sitename"  value="<?php echo $site_row['locationname'];?>" size="20" readonly="true">
	<?php } else {?>
	<input name="sitename" type="text" id="sitename"  value="<?php echo $sitename;?>" size="20" readonly="true">
	<?php } ?>
	<input type="hidden" name="hidden_site" id="hidden_site" value="<?php echo $_REQUEST['hidden_site'];?>"/></div></td>
	</tr>
	<tr></tr>
	</table>
	</td>
	<th width="14%" class="tabledata1">Warehouse</td>
    <td width="16%" id="storedata">
	<table width="100%" border="0" cellspacing="0" cellpadding="0">
      <tr>
		<td>	
		<?php
		$sql_store = "select id, StoreCode, StoreName from storetype where CompanyId='".$_SESSION['ACGCompanyId']."' and Store_Site in ('".$_SESSION['AssignedBranch']."') order by StoreCode ASC";
		$resultStkLocs = DB_query($sql_store,$db);
		?>
		<select id="storecode" name="storecode"  style="width:100%" disabled="disabled">
		<option value="000">Select</option> 
		<?php 
		while ($myrow=DB_fetch_array($resultStkLocs))
		{
				$p='';
				if($myrow1['store']==$myrow['id'])
				$p="selected";
		?>
			<option Value="<?php echo $myrow['id']; ?>" <?php echo $p; ?>><?php echo $myrow['StoreName']; ?></option>
		<?php }
		?>
		</select>		</td>
        <!--<td><div id="txtid"><input type="text" name="storename" id="storename" size="20" readonly="true" value="<?php echo $storename; ?>"></div></td>-->
      </tr>
    </table></td>

		<th width="15%"><strong>PO Number</strong></th>
		<td width="27%"> <input type="text" name="prno" value="<?php echo $myrow1['pr_no']; ?>" style="width:100%;" readonly="readonly" ></td>
			 </tr>
			 <tr>
			 <th nowrap="nowrap"><strong>PO Date</strong></th>
			<td><input type="text" name="prdate"  style="width:100%;" readonly="true" value="<?php echo ConvertSQLDate($myrow1['pr_date']); ?>" /></td>
			<th><strong>Vendor Name</strong></th>
			<td> 
			<select name="mst_supplierno" id="mst_supplierno" style="width:100%" disabled="disabled"  >
			<option value="0">Select</option>
			<?php
			$sql="select id  ,vendor_code, vendor_name from suppliers";
			$result = DB_query($sql, $db);
			while($myrow = DB_fetch_array($result))
			{ 
			$p='';
			if($myrow1['vender_id']==$myrow['id'])
			$p="selected";
			?>
			 <option  value="<?php echo $myrow['id']; ?>"<?php echo $p;?> ><?php echo str_replace(array("M/s ","M/S"),'',$myrow['vendor_name']); ?></option>
		<?php }
			?>
			</select>			</td>
			<th><strong>Vendor Code</strong></th>
			<td><div id="vendor">
			<input type="text" name="VenderCode" value="<?php echo $s->GetFieldValue('suppliers','id="'.$myrow1['vender_id'].'"','vendor_code'); ?>" style="width:100%;"  readonly="true" />
			</div>			</td>
			
			
			</tr>
			  <tr>
			  <th><strong>Mobile No </strong></th>
			<td><div id="mob">
              <input type="text" name="mobile" id="mobile" value="<?php echo $s->GetFieldValue('suppliers','id="'.$myrow1['vender_id'].'"','mobile'); ?>" style="width:100%"  readonly="true"/>
            </div></td>
				<th height="31" nowrap="nowrap"><strong>Address1</strong></th>
				<td><div id="add1">
				<input type="text" name="address1" value="<?php echo $s->GetFieldValue('suppliers','id="'.$myrow1['vender_id'].'"','adrress1'); ?>" style="width:100%;"; readonly></div></td>
			<th nowrap="nowrap"><strong>Address2</strong></th>
            <td><div id="add2"><input type="text" name="address2" value="<?php echo $s->GetFieldValue('suppliers','id="'.$myrow1['vender_id'].'"','adrress2'); ?>" style="width:100%;" readonly></div></td>

             </tr>
			 <tr>
			 <th><strong>Contact Person</strong></th>
<td><input type="text" name="contact_name" id="contact_name" value="<?php echo $myrow1['contact_name']; ?>" style="width:100%" readonly="true" /></td>
				<th nowrap="nowrap"><strong>Delivery Date</strong></th>
				<td><input type="text" name="delivery_date" value="<?php echo ConvertSQLDate($myrow1['delivery_date']); ?>" style="width:100%;" readonly="true"></td>
			<th nowrap="nowrap"><strong>Delivery Place</strong></th>
            <td><input type="text" name="delivery_place" value="<?php echo $myrow1['delivery_place']; ?>" style="width:100%;" readonly="true" ></td>
             </tr>
			 <tr>
			 <th><strong>Payment Mode</strong></th>
<td><select name="PayMode" id="PayMode" style="width:100%;" disabled="disabled">
  <option value="000">---Select Payment Mode---</option>
  <?php 
					$sql='SELECT paymentmethods.paymentid, paymentmethods.paymentname FROM paymentmethods';
					$result=DB_query($sql, $db);
					while($myrow = DB_fetch_array($result))
						{ 
							$p='';
							if($myrow1['payment_mode'] == $myrow['paymentid'])
							$p="selected";
						?>
  <option value="<?php echo $myrow['paymentid'];?>"<?php echo $p;?>><?php echo $myrow['paymentname'];?></option>
  <?php 	} ?>
</select></td>
			 <th>Type</th>
			<td>
				<select name="ptype" id="ptype"	style="width:150px;" disabled="disabled">
					<option value="0" <?php if($myrow1['ptype']==0){echo "selected";}?>>Select</option>
					<option value="1" <?php if($myrow1['ptype']==1){echo "selected";}?>>Local</option>
					<option value="2" <?php if($myrow1['ptype']==2){echo "selected";}?>>Import</option>
				</select>
			</td>
				<th nowrap="nowrap">&nbsp;</th>
				<td>&nbsp;</td>
			 </tr>
			      </table>
				   
									
				
				</div>
				   <br />
				 
<p align="left" style="padding-left:10px;">
 
</p>		 
<h3><center>Item Details</center></h4>

  <div style="overflow:auto; width:825px; height:auto">
 	<div id="itemdata">
 	<table width="100%" border="1" cellpadding="3" cellspacing="0">
         <tr>
          <th><strong>S. No.</strong></th>
          <th></th>
          <th><strong>Item Code</strong></th>
          <th><strong>Item Name</strong></th>
          <th><strong>UOM</strong></th>
          <th><strong>Qty</strong></th>
		   <th><strong>Rate</strong></th>
		    <th><strong>Total Amt</strong></th>
        </tr>
            <?php 
 $i=0;
$sql_edit=DB_query("Select * from log_po_details where parent_id='".$_REQUEST['SID']."' and del_status=0 ",$db);
while($record_edit=DB_fetch_array($sql_edit))
{
$j=$i+1;
if($i%2==0)
{$bg="#CCCCCC";}
else
$bg="#C8BECB";
	?>
<td>
	<?php echo $j; ?>
</td>
<td>
	<input  type="hidden"   readonly=""  id="itemdataid1_<?php echo $i; ?>"  name="itemdataid[]"  value="<?php echo $record_edit['mst_itemid']; ?>" />
</td>
<td>
	<?php echo $s->getField('item_master','id',$record_edit['mst_itemid'],'StockID'); ?>
</td>
<td>
	<?php echo $s->getField('item_master','id',$record_edit['mst_itemid'],'item_name'); ?>
</td>
<td>
	<?php $unit= $s->getField('item_master','id',$record_edit['mst_itemid'],'mst_unitid'); ?>
	<?php echo $s->getField('unitsofmeasure','unitid',$unit,'unitname');  ?>       	 
</td>
<td>
	<input readonly="true"  type="text" name="poqty[]"  id="poqty1_<?php echo $i; ?>" size="30"   value="<?php  echo $record_edit['qty'];	?>"  /></td>
<td>
	<input readonly="true"  type="text" name="porate[]"  id="porate1_<?php echo $i; ?>" size="30"  value="<?php  echo $record_edit['rate'];?>" />
</td>
<td>
	<input readonly="true"  type="text" name="totalamt[]"  id="itemtotalrate1_<?php echo $i; ?>" size="30"   value="<?php  echo $record_edit['amt'];	?>"  />
</td>
</tr>
<?php $i++; } ?>
    </table>
    
    </div>
  </div>
 <br />	
<div align="right">			
			<table width="40%" border="0">
			
			<tr><td>
		      <table width="40%" border="1" cellspacing="0" cellpadding="3" align="right">
                <tr>
                  <td><strong>TOTAL AMOUNT <font color="#FF0000">*</font></strong> </td>
                  <td >
				 
				  <input type="text" name="total_item_amount" id="total_item_amount" style="width:100%;" value="<?php echo $myrow1['total_amt'];?>" readonly="true"/>
				
				  </td>
               </tr>
              <tr>
                  <td><strong>Pkg Charges</strong> </td>
                  <td>
				  <input type="text" name="pkg_perc" id="pkg_perc" value="<?php echo $myrow1['pkg_per'];?>" size="5" readonly="true" />
				  <input name="pkg_charges" id="pkg_charges1" type="text" value="<?php echo $myrow1['pkg_amt'];?>" size="28"  readonly="true" /></td>
                </tr>
				<tr>
					<td><strong>Excise</strong></td>
					<td>
				  <select name="EDBillRate" id="EDRate" style="width:150px;" disabled="disabled"  >
				<option value="0">--Select--</option>
				<?php
				$ServiceSql="select * from  excise_tax WHERE caption LIKE '%excise%'" ;
				$ServiceRes=DB_query($ServiceSql,$db);
				while($ServiceRow=DB_fetch_array($ServiceRes))
				{
				?>
				<option value="<?php echo $ServiceRow['id']?>" <?php if($ServiceRow['id']==$myrow1['excise_id']){echo "selected";}?>><?php echo $ServiceRow['caption']?></option>
				<?php	
				}
				
				?>
				</select>
				
				<input name="totalDiscountedPrice" id="totalDiscountedPrice" type="text"  style="width:100%;" readonly="true" value="<?php echo $myrow1['excise_amt'];?>"/>
				</td>
			    </tr>
			<?php 
			$cessSql=DB_query("Select caption from excise_tax where caption like '%cess%'",$db);
			$k=1;
			while($cessRow=DB_fetch_array($cessSql))
			{
			$caption[$k]=$cessRow['caption']; 
			
			$rate_sql=DB_query("Select def_rate from excise_tax where caption='".$caption[$k]."'",$db);
			while($rate_row=DB_fetch_array($rate_sql))
			{
			$rate[$k]=$rate_row['def_rate'];
			}
			$k++;
			} 
			?>
			<tr>
					<td><strong>E-Cess</strong></td>
					<td><input name="ECessPercentage" id="ECessPercentage" type="text" value="<?php echo $rate[1];?>" style="width:60px;" readonly="true" />
						<input name="ECessValue1" id="ECessValue" type="text" value="<?php echo $myrow1['ecess_amt'];?>" style="width:120px;" readonly="true"/></td>
				</tr>
			<tr >
					<td><strong>SAH-E Cess</strong> </td>
					<td><input name="SAHCessPercentage" id="SAHCessPercentage" type="text" value="<?php echo $rate[2];?>" style="width:60px;" readonly/>
						<input name="SAHCessValue1" id="SAHCessValue" type="text" value="<?php echo $myrow1['sah_amt'];?>" style="width:120px;" readonly/></td>
				</tr>
					<tr>
					<td><strong>Total Excise Amount</strong></td>
					<td><input type="text" name="total_excise_amount" id="total_item_amount1" style="width:150px;" readonly="true" value="<?php echo $myrow1['total_excise_amt'];?>" /></td>
					
					</tr>
                <tr>
                  <td><strong>Vat/Cst(discription) </strong> </td>
                  <?php
				$Taxsql='SELECT salestax_id ,tax_code, taxrate FROM sales_tax_master';
				$Taxresult=DB_query($Taxsql,$db);
				
				
     	?>
              <td><select id="taxname" name="vat_cst" onchange="tax_rate1(this.value)" style="width:100%;" disabled="disabled">
	          <option value="0">---Select---</option>
                  <?php 
			while($Taxmyrow=DB_fetch_array($Taxresult)){
			?>
                  <option  value="<?php echo $Taxmyrow['salestax_id']; ?>"<?php echo ($myrow1['vat_cst']==$Taxmyrow['salestax_id']?'selected':'')?>><?php echo $Taxmyrow['tax_code']." --- ".$Taxmyrow['taxrate']."%"; ?></option>
                  <?php } ?>
              </select></td>
              </tr>
              <?php  $taxdata=$s->getField('sales_tax_master','salestax_id',$venddata['vat_cst_per'],'taxrate'); ?>
              <tr>
              	<td><strong>Tax Value</strong></td>
              <td><div id="taxval">
                  <input type="text" name="taxvalue" id="taxvalue" style="width:100%;" value="<?php echo $myrow1['vat_cst_amt'];?>" readonly="true" />
              </div>

	</td>
                </tr>
                <tr>
                  <td><strong>Surcharge Amount</strong> </td>
                  <td><input readonly="true" type="text" name="sur_oct_per" id="sur_oct_per" value="<?php echo $myrow1['sur_per'];?>"  size="10"/>
				  <input readonly="true" name="sur_oct_amt" type="text" id="sur_oct_amt" value="<?php echo $myrow1['sur_amt'];?>" style="width:60%;" /></td>
                </tr>
                <tr>
                  <td><strong>Freight</strong> </td>
                  <td><input readonly="true" type="text" name="tot_freight" id="TotalCharge" style="width:100%;" value="<?php echo $myrow1['freight'];?>"     /></td>
                </tr>
				<tr>
                  <td><strong>Loading /Unloading</strong> </td>
                  <td><input readonly="true" type="text" name="loading" id="loading1" style="width:100%;" value="<?php echo $myrow1['loading'];?>"     /></td>
                </tr>
                <tr>
                  <td><strong>Additional Duties </strong> </td>
                  <td><input readonly="true" name="add_charges" id="additionalCharges" type="text" value="<?php echo $myrow1['additional_charge'];?>" size="25" style="width:100%;" /></td>
                </tr>
				
                <tr>
				<td><strong>Grand Total <font color="#FF0000">*</font></strong></td>
                  <td><input readonly="true" type="text" name="grandtotal" id="GrandTotal"  size="12" value="<?php echo $myrow1['grand_total'];?>"/></td>
                </tr>
			  </table></td></tr>
		 
			</table>
</div>