<?php
include('config.php');
include('includes/ConnectDB.inc');
include('includes/LanguageSetup.php');
include('includes/DateFunctions.inc');

session_name('CAKEPHP'); session_start();
?> 
<style>
.border1{border:#666666 1px solid; border-left:none; border-top:none; font-family:Arial; font-size:12px; color:#000000;}
.border_bottom{border-bottom:#666666 1px solid; font-family:Arial; font-size:12px; color:#000000;}
.f12{font-family:Arial; font-size:10px; color:#000000; font-weight:bold;}
.f11{font-family:Arial; font-size:12px; color:#000000;}
</style>
<link rel="stylesheet" href="css/new_mxerp.css">
<center><h3 style="text-align:center; font-size:18px;"><u><?php //echo"<pre>"; print_r($_SESSION);
$company_name=DB_fetch_assoc(DB_query("select CompanyName from companies where CompanyId='".$_SESSION[ACGCompanyId]."'",$db)); 
echo strtoupper($company_name[CompanyName]);?></u></h3></center>
<center> <h2 style="font-family:Arial; font-size:18px; color:#003399;">Indent Sheet Report</h2>
</center>
<center><h3 style="text-align:center; font-size:16px;"> Date : <span style="font-family:Arial; font-size:16px; color:#003399;"> <?php if($_REQUEST['fromdate']!="" && $_REQUEST['todate']!="") 
 					echo $_REQUEST['fromdate'] . " to " .$_REQUEST['todate']; 
	 		  else 
 					echo date("d/m/Y", strtotime($_SESSION['financialYrStart'])) . " to " .date("d/m/Y", strtotime($_SESSION['financialYrEnd'])); ?></span> </h3></center>
		<br />
<div class="body_contain">

<div id="foo"><p style="font-size:12px;" align="right"><a href="javascript:toggle_visibility('foo');">PRINT</a></p></div>
<div style="width:980px; overflow:auto; margin:auto;" id="hide1" >			
<table width="100%" border="1" cellpadding="2" cellspacing="0" style="border-collapse:collapse;">
<?php 
//$s=new db_query();

if($_REQUEST['action']=='print'){
	$todate=FormatDateForSQL1($_REQUEST['todate']);
	$todate = str_replace('/', '-', $todate);
	$fromdate=FormatDateForSQL1($_REQUEST['fromdate']);
	$fromdate = str_replace('/', '-', $fromdate);
	$site=$_REQUEST['site'];
	$client=$_REQUEST['client'];
	if($_REQUEST['todate']!='' && $_REQUEST['fromdate']!='' )
	{
	$filter[]="indent_date between '".$fromdate."' and '".$todate."'";
	}
	if($_REQUEST['site']!='0')
	{
	$filter[]="site='".$site."'";
	}
	if($_REQUEST['client']!='0')
	{
	$filter[]="client='".$client."'";
	}
	if($_REQUEST['site']=='0')
	{
	$GetSales= "select * from Indent_so_main";
	$getlead=DB_query("select * from Indent_so_main where CompanyID='".$_SESSION['ACGCompanyId']."'
	  order by id desc ",$db);
	}
	if($filter!='')
	{
	$filter1=implode(" and ",$filter);
	 $GetSales="select * FROM Indent_so_main where CompanyID='".$_SESSION['ACGCompanyId']."'  and $filter1 ";

	$getlead=DB_query($GetSales,$db);
	}else{
	$i=1;
	
	  $GetSales="SELECT * FROM Indent_so_main where CompanyID='".$_SESSION['ACGCompanyId']."' ORDER BY id DESC";
		  
	$getlead=DB_query($GetSales,$db);
	}



  
$lop=0;
 if(DB_num_rows($getlead)>0)
{
	
	
    
	 ?>
<tr  style="border:1px thin;">
    <td style="white-space:nowrap;" valign="top">
	
<table width="100%" border="1" cellpadding="2" cellspacing="0" style="border-collapse:collapse;">
  <tr>
    <td width="32" class="tabledata"><strong>Sr.No</strong></td>
	<td width="80" class="tabledata"><strong>Indent Date</strong></td>
	<td width="32" class="tabledata"><strong>Indent No</strong></td>
    <td class="tabledata" width="150"><strong>Client</strong></td>
	<td class="tabledata" width="150"><strong>Work Order No</strong></td>
	<td class="tabledata" width="40"><strong>Order Date</strong></td>
	<td class="tabledata" width="40"><strong>P.O. No.</strong></td>	
	<td class="tabledata" width="40"><strong>Po Date</strong></td>
	<td class="tabledata" width="60"><strong>Consignee</strong></td>
	<td class="tabledata" width="40"><strong>Type of Order</strong></td>	
	<td class="tabledata" width="40"><strong>Fabrication No</strong></td>
	<td class="tabledata" width="160"><strong>MMS No</strong></td>
	
</tr>
 
  <?php
  $t=1;
	while($row=DB_fetch_array($getlead))
	{
	$a = $row['id'];
	?>
<tr>
    <td class="f11"class="f11"><?php echo $t; ?></td>	
	<td class="f11"class="f11"><?php echo  $row['indent_date']; ?></td>
	<td class="f11"class="f11"><?php echo ConvertSQLDate($row['indent_no']); ?></td>
	<td class="f11"class="f11"><?php  
	$cl_sql=DB_query("select c_name from clientmaster where id='".$row['client']."'",$db);
	$cl_res=DB_fetch_array($cl_sql);
	
	echo $cl_res['c_name'];  ?></td>
	<td class="f11"class="f11"><?php echo $row['work_order_no']; ?></td>
	<td class="f11"class="f11"><?php echo $row['order_date']; ?></td>
	<td class="f11"class="f11"><?php echo $row['po_no']; ?></td>
	<td class="f11"class="f11"><?php echo $row['po_date']; ?></td>
	<td class="f11"class="f11"><?php echo $row['consignee']; ?></td>
	<td class="f11"class="f11"><?php echo $row['order_type']; ?></td>
	<td class="f11"class="f11"><?php  
	$cw_sql=DB_query("select sheet_no from faberication_main where id='".$row['faberication']."'",$db);
	$cw_res=DB_fetch_array($cw_sql);
	
	echo $cw_res['sheet_no'];  ?></td>
	<td class="f11"class="f11"><?php  
	$cw1_sql=DB_query("select mms_no from measurment_sheet_main where id='".$row['mms']."'",$db);
	$cw1_res=DB_fetch_array($cw1_sql);
	
	echo $cw1_res['mms_no'];  ?></td>
	<td colspan="7" style="padding:0px;"></td>		
	</tr> 
	<?php
	$t++;}
	?> 
	<?php 
	}}?>
	
	</table>
	</table>
	</div>
<script>
function toggle_visibility(id) {
  var msg=confirm("Please Use Mozilla Firefox For Better Print");
  if(msg)
  {
       var e = document.getElementById(id);
	       e.style.display = 'none';
		       //alert(e.style.display);
			   window.print();
	}
    }
</script>
	

	 