<link href="css/tender_project.css" rel="stylesheet" type="text/css" />
<?php

session_name('CAKEPHP'); session_start();
ob_start();

$PageSecurity = 3;
	
include ('includes/session.inc');
include ('includes/function_lib.php');
include('includes/fun-php.php');
include('includes/fun-HRClass.php');
 ?>
 <script type="text/javascript" language="javascript">
  function toggle_visibility(id) {
       var e = document.getElementById(id);
	      // e.style.display = 'none';
		       //alert(e.style.display);
			   window.print();
    }
  
</script>
<?php 
//$mpdf=new mPDF();
//$mpdf->Bookmark('Start of the document');
$Compamies=DB_query("select * from companies",$db);
$CompamiesRow=DB_fetch_array($Compamies);

if($_REQUEST['itemname']!=''){
?>


<?php } ?>
<div style="width:100%; color:#006699; font-size:16px; font-weight:900; padding:10px; text-align:center;"><?php echo $CompamiesRow['CompanyName']?> <br />
MRN Register</div>

 <p id="foo" align="right" style="padding-right:10px;"> <a href="#" onclick="javascript:toggle_visibility('foo');" >Print</a> </p>


<table width="1720px;" cellpadding="0" cellspacing="0" border="1" style="border-collapse:collapse;">
<tr style="background-color:#CCCCCC; height: 30px">
	<?php if($_REQUEST['site']!='0'){?><td class="jjrs_tablehead"><strong>Site :<?php echo $s->GetFieldValue('locations',"loccode='".$_REQUEST['site']."'",'locationname'); ?></strong></td><?php } ?>
	<?php if($_REQUEST['store_code']!='0'){?><td class="jjrs_tablehead"><strong>Store :<?php echo $s->GetFieldValue('storetype',"id='".$_REQUEST['store_code']."'",'StoreName'); ?></strong></td><?php } ?>
	<?php if($_REQUEST['fromdate']!=''){?><td class="jjrs_tablehead"><strong>Fromdate :<?php echo $_REQUEST['fromdate']; ?></strong></td><?php } ?>
	<?php if($_REQUEST['todate']!=''){?><td class="jjrs_tablehead"><strong>Todate :<?php echo $_REQUEST['todate']; ?></strong></td><?php } ?>
	<?php if($_REQUEST['vendor_id']!='000'){?><td class="jjrs_tablehead"><strong>Vender :<?php echo $s->GetFieldValue('suppliers',"id='".$_REQUEST['vendor_id']."'",'vendor_name');?></strong></td><?php } ?>
	<?php if($_REQUEST['itemname']!=''){?><td class="jjrs_tablehead"><strong>Item Name :<?php echo $s->GetFieldValue('item_master',"StockID='".$_REQUEST['itemname']."'",'item_name');?></strong></td><?php } ?>
  </tr>
</table>
<table width="1720px" cellpadding="0" cellspacing="0" border="1" style="border-collapse:collapse;">
  <tr style="background-color:#CCCCCC; height: 30px">
	<td class="jjrs_tablehead"><strong>Date</strong></td>
     <td class="jjrs_tablehead"><strong>MRN no.</strong></td>
     <td class="jjrs_tablehead"><strong>Bill No.</strong></td>
	 <td class="jjrs_tablehead"><strong>PO/Direct/PR No.</strong></td>
     <td class="jjrs_tablehead"><strong>Vendor</strong></td>


     <td style="width:114px;" class="jjrs_tablehead"><strong><?php if($_REQUEST['itemname']==''){?>Item Name<?php } ?></strong></td>
     <td style="width:49px;" class="jjrs_tablehead"><strong>UOM</strong></td>
	 <td style="width:76px;" class="jjrs_tablehead"><strong>Qty</strong></td>
     <td  style="width:77px;" class="jjrs_tablehead"><strong>Rate</strong></td>
	 <td  style="width:77px;" class="jjrs_tablehead"><strong>Total Price</strong></td>
	 <td  style="width:54px;" class="jjrs_tablehead"><strong>Total Discount</strong></td>
     <td  style="width:55px;" class="jjrs_tablehead"><strong>Excise</strong></td>
	 <td  style="width:55px;" class="jjrs_tablehead"><strong>E-Cess</strong></td>
	  <td  style="width:45px;" class="jjrs_tablehead"><strong>SAH-Cess</strong></td>
	 <td  style="width:55px;" class="jjrs_tablehead"><strong>Total Excise Amt.</strong></td>


	 <td style="width:99px;" class="jjrs_tablehead"><strong>Taxable Amount</strong></td>
	 <td class="jjrs_tablehead"><strong>Cancel Status</strong></td>   
	 <td class="jjrs_tablehead"><strong>Pkg. Charges</strong></td>   
	 <td class="jjrs_tablehead"><strong>VAT/CST Amt.</strong></td>
	 <td class="jjrs_tablehead"><strong>Freight</strong></td>
	 <td class="jjrs_tablehead"><strong>Grand Total</strong></td>
  </tr>
  <?php 
  //zecho $sql;
  $sql=$_SESSION['mrnreport'];
  $result=DB_query($sql,$db);
  while($myrow=DB_fetch_array($result))
  {
  ?>
  <tr bgcolor="#FFFFFF">
	<td  style="width:50px;" class="jjrs_tablehead"><?php echo ConvertSQLDate($myrow['MRNDate']);?></td>
	<td  style="width:120px;" class="jjrs_tablehead"><?php echo $myrow['MRNNo'];?></td>
	<td  style="width:60px;" class="jjrs_tablehead"><?php echo $myrow['BillNo'];?></td>
	<td  style="width:150px;" class="jjrs_tablehead"><?php 
	if($myrow['ReceivedAgainst']=='PO'){
			echo $s->GetFieldValue('purchorders',"orderno='".$myrow['PO_WO_MTO']."'",'PO_Orderno');
		}
	elseif(
		$myrow['ReceivedAgainst']=='Without PO'){if($myrow['req_no']!='' && $myrow['req_no']!=0){
			echo $s->GetFieldValue('materialrequisitions',"requisitionno='".$myrow['req_no']."'",'Reqno');}else{echo "Direct";}}	?>
	</td>
	<td  style="width:120px;" class="jjrs_tablehead"><?php echo $s->GetFieldValue('suppliers',"id='".$myrow['ReceivedFrom']."'",'vendor_name');?></td>
	<td colspan="11">
	<table width="100%" border="0" cellpadding="3" cellspacing="0" style="border-collapse:collapse; font-size:12px;">
	<?php 
	if($_REQUEST['itemname']!='')
	{
		$details_sql="Select * from addmrnqty where issue_id=".$myrow['main_id']." and itemcode='".$_REQUEST['itemname']."'";
	}
	else
	{
		$details_sql="Select * from addmrnqty where issue_id=".$myrow['main_id']." and reciveqty!='0.00'";
	}
	
	$details_res=DB_query($details_sql,$db);
	$tot_received='';
	$tot_rate='';
	$tot_price='';
	$tot_disc='';
	$tot_excise='';
	$tot_ecess='';
	$tot_sahcess='';
	$tot_exciseAmt='';
	$tot_Amount='';
	if(DB_num_rows($details_res)>0){
	while($details_row=DB_fetch_array($details_res)){?>
	<tr bgcolor="99CCCC">
		<td style="width:100px;" class="jjrs_tabledata1"><?php if($_REQUEST['itemname']==''){?><strong><?php echo $details_row['description'];?></strong><?php } ?></td>
		<td style="width:43px;" class="jjrs_tabledata1"><?php $unit_id= $s->GetFieldValue('item_master',"id='".$details_row['mst_itemid']."'",'unit'); echo $s->GetFieldValue('unitsofmeasure',"unitid='".$unit_id."'",'unitname');?></td>
		<td  style="width:70px;" class="jjrs_tabledata1">
		<?php echo $details_row['reciveqty']; $tot_received[]=$details_row['reciveqty'];?></td>
		<td  style="width:70px;" class="jjrs_tabledata1"><?php echo $details_row['itemprice']; $tot_rate[]=$details_row['itemprice'];?></td>
		<td  style="width:70px;" class="jjrs_tabledata1"><?php echo $details_row['item_total_rate']; $tot_price[]=$details_row['item_total_rate'];?></td>
		<td  style="width:50px;" class="jjrs_tabledata1"><?php echo $x=$details_row['discount_amount']+$details_row['sp_disc_amt']; $tot_disc[]=$x;?></td>
		<td  style="width:50px;" class="jjrs_tabledata1"><?php echo $details_row['excise_val']; $tot_excise[]=$details_row['excise_val'];?></td>
		<td  style="width:50px;" class="jjrs_tabledata1"><?php echo $details_row['e_cess_val']; $tot_ecess[]=$details_row['e_cess_val'];?></td>
		<td  style="width:50px;" class="jjrs_tabledata1"><?php echo $details_row['sah_val']; $tot_sahcess[]=$details_row['sah_val'];?></td>
		<td  style="width:50px;" class="jjrs_tabledata1"><?php echo $y=$details_row['excise_val']+$details_row['e_cess_val']+$details_row['sah_val']; $tot_exciseAmt[]=$y;?></td>
		<td  style="width:90px;" class="jjrs_tabledata1"><?php echo $details_row['total_amt_with_tax']; $tot_Amount[]=$details_row['total_amt_with_tax'];?></td>
	</tr>
	<?php } ?>
	<tr bgcolor="#e7e7e7" style="height: 25px">
	<td class="jjrs_tabledata1"><strong></strong></td>
		<td class="jjrs_tabledata1"><strong>Total</strong></td>
		<td class="jjrs_tabledata1"><strong><?php echo $a[]=array_sum($tot_received);?></strong></td>
		<td class="jjrs_tabledata1"><strong><?php //echo $b[]=array_sum($tot_rate);?></strong></td>
		<td class="jjrs_tabledata1"><strong><?php echo $c[]=array_sum($tot_price);?></strong></td>
		<td class="jjrs_tabledata1"><strong><?php echo $d[]=array_sum($tot_disc);?></strong></td>
		<td class="jjrs_tabledata1"><strong><?php echo $e[]=array_sum($tot_excise);?></strong></td>
		<td class="jjrs_tabledata1"><strong><?php echo $f[]=array_sum($tot_ecess);?></strong></td>
		<td class="jjrs_tabledata1"><strong><?php echo $g[]=array_sum($tot_sahcess);?></strong></td>
		<td class="jjrs_tabledata1"><strong><?php echo $h[]=array_sum($tot_exciseAmt);?></strong></td>
		<td class="jjrs_tabledata1"><strong><?php echo $m[]=array_sum($tot_Amount);?></strong></td>
	</tr><?php } ?>
	</table>
	</td>
	<td  style="width:45px;" class="jjrs_tablehead"><?php echo $myrow['Cancel_Status'];?></td>
	<td style="width:45px;" class="jjrs_tablehead"><?php echo $myrow['pkg_charges']; $pkg_array[]=$myrow['pkg_charges'];?></td>
	<td  style="width:60px;" class="jjrs_tablehead"><?php echo $myrow['vat_cst_val']; $vat_array[]=$myrow['vat_cst_val'];?></td>
	<td class="jjrs_tablehead"><?php echo $myrow['tot_freight']; $fr_array[]=$myrow['tot_freight'];?></td>
	<td  style="width:70px;" class="jjrs_tablehead"><?php echo $myrow['grandtotal']; $gr_array[]=$myrow['grandtotal'];?></td>
  </tr>
  <?php } ?>
</table>

<!--<table width="100%" cellpadding="3" cellspacing="0" border="1" style="border:solid 1px #666666;">
  	<tr bgcolor="#CCCCCC">
  	<td><strong>Total Qty</strong></td>
  	<td><strong>Total Discount</strong></td>
  	<td><strong>Total Excise</strong></td>
  	<td><strong>Total E-Cess</strong></td>
  	<td><strong>Total SAH-Cess</strong></td>
  	<td><strong>Total Excise Amt.</strong></td>
  	<td><strong>Total Taxable Amt.</strong></td>
	<td><strong>Total Pkg. Charges</strong></td>
  	<td><strong>Total VAT/CST</strong></td>
  	<td><strong>Total Freight</strong></td>
  	<td><strong>Grand Total</strong></td>
  </tr>
  <tr bgcolor="#FFFFFF">
  	<td><strong><?php if($a!='')echo array_sum($a);?></strong></td>
  	<td><strong><?php if($d!='')echo array_sum($d);?></strong></td>
  	<td><strong><?php if($e!='')echo array_sum($e);?></strong></td>
  	<td><strong><?php if($f!='')echo array_sum($f);?></strong></td>
  	<td><strong><?php if($g!='')echo array_sum($g);?></strong></td>
  	<td><strong><?php if($h!='')echo array_sum($h);?></strong></td>
  	<td><strong><?php if($m!='')echo array_sum($m);?></strong></td>
	<td><strong><?php if($pkg_array!='')echo array_sum($pkg_array);?></strong></td>
  	<td><strong><?php if($vat_array!='')echo array_sum($vat_array);?></strong></td>
  	<td><strong><?php if($fr_array!='')echo array_sum($fr_array);?></strong></td>
  	<td><strong><?php if($gr_array!='')echo array_sum($gr_array);?></strong></td>
  </tr>
</table> -->

  <?php  

?>

