<?php 
include('config.php');
include('includes/ConnectDB.inc');
include('includes/LanguageSetup.php');
include('includes/DateFunctions.inc');
class db_query
{
 function getField($table,$condition,$val,$field)
{
   global $db;
  //echo "select ".$field." from ".$table." where ".$condition." ='".$val."'";
   	 $sql=DB_query("select ".$field." from ".$table." where ".$condition." ='".$val."'",$db);
	 $r=DB_fetch_array($sql);
	//echo "select ".$field." from ".$table." where ".$condition." ='".$val."'"; 
   	return ($r[$field]);
}
 function GetFieldValue($table,$condition ,$field)
{
   global $db;
  //echo "select ".$field." from ".$table." where  $condition ";
   //echo "<br>";
   	 $sql=DB_query("select ".$field." from ".$table." where  $condition  ",$db);
	 $r=DB_fetch_array($sql);
   	return ($r[$field]);
}
}
$s=new db_query();
$sql_fetch=DB_query("select * from indent_so_main where id='".$_REQUEST['SOrderId']."'",$db);
$sql_fetch_data=DB_fetch_array($sql_fetch);
extract($sql_fetch_data);
session_name('CAKEPHP'); session_start();
?>
<center><h2 style="font-family:Arial; font-size:18px; color:#003399;"><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</h2>
</center>
<!--<link rel="stylesheet" href="css/new_mxerp.css">
-->

<div class="body_contain">
<div class="tab_div">
<fieldset>
<table width="100%" cellpadding="3" cellspacing="0" border="1" style="border-collapse:collapse;">
<tr class="row1">
	<!--<td class="tabledata1"><strong>Branch</strong></td>
	<td><?php echo $s->getField('locations','loccode',$site,'locationname'); ?></td>-->
	<td class="tabledata1"><strong>Indent No.</strong></td>
	<td><?php echo $indent_no; ?></td>
	<td class="tabledata1"><strong>Indent Date<font size="3" color="#FF0000"></font></strong></td>
	<td><?php echo $indent_date; ?></td>
	<td class="tabledata1"><strong>Type of Order</strong></td>
	<td><?php echo $order_type; ?></td>
</tr>
<tr class="row1">
	<!--<td class="tabledata1"><strong>Format</strong></td>
	<td><?php echo $format; ?></td>-->
	
</tr>
<tr class="row1">
	<td class="tabledata1"><strong>Client</strong></td>
	<td><?php echo $s->getField('clientmaster','id',$client,'c_name'); ?></td>
	<td class="tabledata1"><strong>Work Order No</strong></td>
	<td><?php echo $work_order_no; ?></td>
	<td class="tabledata1"><strong>Order Date</strong></td>
	<td><?php echo $order_date; ?></td>
</tr>
<tr class="row1">
	<td class="tabledata1"><strong>P.O. No</strong></td>
	<td><?php echo $po_no; ?></td>
	<td class="tabledata1"><strong>Po. Date</strong></td>
	<td><?php echo $po_date; ?></td>
	<td class="tabledata1"><strong>Delivery Date</strong></td>
	<td><?php echo $delivery_date; ?></td>
</tr>
<tr class="row1">
	<td class="tabledata1"><strong>Consignee<font size="3" color="#FF0000"></font></strong></td>
	<td>
	<?php  
	$ss113_sql=DB_query("select consignee_name from clientmaster_consignee_address where id='".$consignee."'",$db);
	$ss113_res=DB_fetch_array($ss113_sql);
	
	echo $ss113_res['consignee_name']; ?>
	
	</td>
	<td class="tabledata1"><strong>Consignee Address<font size="3" color="#FF0000"></font></strong></td>
	<td><?php echo  $s->getField('clientmaster_consignee_address','id',$consignee,'consignee_Address'); ?></td>
	<td class="tabledata1"><strong>Cont. Person</strong></td>
	<td><?php echo $s->getField('contact_information_master','id',$cont_person,'person'); ?></td>
	<td class="tabledata1"><strong>Mobile No.</strong></td>
	<td><?php echo $mobile_no; ?></td>
	
</tr>
<!--<tr class="row1">
	<td class="tabledata1"><strong>Credit Limit </strong></td>
	<td><?php echo $credit_limit; ?></td>
	<td class="tabledata1"><strong>Current Bal.</strong></td>
	<td><?php echo $current_bal; ?></td>
	<td class="tabledata1"><strong>Credit Days</strong></td>
	<td><?php echo $credit_days; ?></td>
</tr>-->
<tr class="row1">
	<td class="tabledata1"><strong>Handled By<font size="3" color="#FF0000"></font></strong></td>
	<td><?php echo $s->getField('empmaster','id',$handled_by,'emp_name');  ?></td>
	<td class="tabledata1"><strong>Fabrication No</strong></td>
	<td><?php 
	$sh_sql=DB_query("select sheet_no from faberication_main where id='".$faberication."'",$db);
	$sh_res=DB_fetch_array($sh_sql);
	
	echo $sh_res['sheet_no']; ?>
	</td>
	 <td class="tabledata1"><strong>MMS No</strong></td>
	<td ><?php 
	$s_sql=DB_query("select mms_no from measurment_sheet_main where id='".$mms."'",$db);
	$s_res=DB_fetch_array($s_sql);
	
	echo $s_res['mms_no']; ?></td>
	
	<td colspan="4"></td>
</tr>
</table>
</fieldset>
<tr class="row1">
	<td class="tabledata1" colspan="6">
		<table width="100%" border="1" cellpadding="2" cellspacing="1" style="border-collapse:collapse;">
		<tr class="row1">
			<td class="tabledata"><strong>Sr. No.</strong></td>
			<td class="tabledata"><strong>Part Code</strong></td>
			<td class="tabledata"><strong>Description of Material</strong></td>
			<!--<td class="tabledata">Size</td>-->
			<!--<td class="tabledata">Grade</td>-->
			<td class="tabledata"><strong>Unit</strong></td>
			<td class="tabledata"><strong>Qty.</strong></td>
			<td class="tabledata"><strong>Rate</strong></td>
			<td class="tabledata"><strong>Amount</strong></td>
		</tr>
		<?php $i=0;
		 $sqlDetails=DB_query("select * from indent_so_main_details where parent_id='".$_REQUEST['SOrderId']."'",$db);
		while($salesDetails=DB_fetch_array($sqlDetails)) {
		$itemCode=$s->GetFieldValue('item_master',"id='".$salesDetails['mst_itemid']."'",'StockID');
		$itemName=$s->GetFieldValue('item_master',"id='".$salesDetails['mst_itemid']."'",'item_name');
		$Unitid=$s->GetFieldValue('item_master',"id='".$salesDetails['mst_itemid']."'",'mst_unitid');
		$unitname=$s->GetFieldValue('unitsofmeasure',"unitid='".$Unitid."'",'unitname');?>
		<tr class="row1">
			<td><?php echo $i+1; ?></td>
			<td><?php echo $itemCode; ?></td>
			<td><?php echo $itemName; ?>-<?php echo $s->getField('size_master','id',$salesDetails['size'],'size'); ?></td>
			<td><?php echo $unitname; ?></td>
			<td><?php echo $salesDetails['qty']; ?></td>
			
			<td><?php echo $salesDetails['rate']; ?></td>
			<td><?php echo $salesDetails['amount']; ?></td>
		</tr>
		<?php $i++;} ?>
		
		<?php 
			 
			 $sql_hrd=DB_query("select * from indent_so_main_hrditem_details where parent_id='".$_REQUEST['SOrderId']."'",$db);
			while($row=DB_fetch_array($sql_hrd))
			{
			
			$item_Codeas=$s->GetFieldValue('item_master',"id='".$row['mst_itemid']."'",'StockID');
			$item_names=$s->GetFieldValue('item_master',"id='".$row['mst_itemid']."'",'item_name');
			?>
		<tr class="row1">
			<td><?php echo $i+1; ?></td>
			<td><?php echo $item_Codeas; ?></td>
			<td><?php echo $item_names; ?></td>
			<td><?php echo $row['perunit']; ?></td>
			<td><?php echo $row['qty']; ?></td>			
			<td><?php echo $row['price']; ?></td>

			<td><?php echo $row['amount']; ?></td>	
				</tr>		<?php $i++;} ?>
				
				
				
		
</table>
	</td>
</tr>
</table>

<table width="100%" cellpadding="3" cellspacing="0" border="1">
<tr class="row1">
	<td width="50%" valign="top">
		<table width="100%" border="1" cellspacing="0" cellpadding="3" align="left" style="border-collapse:collapse;">
			<tr class="row1">
				<td class="tabledata1" style="text-align:center;" colspan="2"><strong>Terms And Conditions</strong></td>
			</tr>
			<?php $t=0;
			$SQLTerms=DB_query("SELECT * FROM terms_condition where parant_id=0 and frm_id='".$_REQUEST['frmid']."'",$db); 
			while($TermsAndCond=DB_fetch_array($SQLTerms)){?>
			<tr class="row1">
			<td style="white-space:nowrap;" class="tabledata"><?php echo $t; ?></td>
				<td class="tabledata1"><?php echo $TermsAndCond['terms_conditions']; ?></td>
					<td><?php $SQLCond=DB_query("SELECT * FROM terms_condition where parant_id='".$TermsAndCond['id']."'",$db);
						$GetCond=DB_fetch_array($SQLCond);
						 echo $GetCond['terms_conditions']; ?></td>
					
			</tr>
<?php $t++;}?>
		</table>
	</td>
	<td width="50%">
		<table width="100%" border="1" cellspacing="0" cellpadding="3" align="right" style="border-collapse:collapse;">
			<tr class="row1">
				<td class="tabledata1" style="text-align:center;" colspan="4"><strong>Amount And Taxes</strong></td>
			</tr>
			
		<tr class="row1">
			<td class="tabledata1">Basic Amount<label><font color="#FF0000"></font></label></td>
			<td><?php echo $basic; ?></td>
		</tr>
		<tr class="row1">
			<td class="tabledata1">Discount<label><font color="#FF0000"></font></label></td>
			<tr class="row1">
			<td class="tabledata1">Discount Amount<label><font color="#FF0000"></font></label></td>
		</tr>
		<tr class="row1">
			<td class="tabledata1">Excise Duty</td>
			<td><?php echo $s->getField('excise_tax','id',$excise_id,'def_rate'); ?> % = 
			<?php echo $excise_amt ?>		</td>
		</tr>
		<tr class="row1">
			<td class="tabledata1">E-Cess</td>
			<td><?php echo $s->getField('excise_tax','id',$ECessID,'def_rate'); ?> % = 
			<?php echo $ecess_amt ?></td>
		</tr>
		<tr class="row1">
			<td class="tabledata1">SHE Cess </td>
				<td><?php echo $s->getField('excise_tax','id',$SHECessId,'def_rate'); ?> % = 
			<?php echo $sah_amt ?></td>
		</tr>
		<tr class="row1">
			<td class="tabledata1">Taxable Amount<label><font color="#FF0000"></font></label></td>
			<td><?php echo $taxable_amt; ?></td>
		</tr>
		<tr class="row1">
			<td class="tabledata1">Saletax<label><font color="#FF0000"></font></label></td>
			<td></td>
		</tr>
		<tr class="row1">
			<td class="tabledata1">Total1<label><font color="#FF0000"></font></label></td>
			<td></td>
		</tr>
		<tr class="row1">
			<td class="tabledata1">Taxable<label><font color="#FF0000"></font></label></td>
			<td></td>
		</tr>
		<tr class="row1">
			<td class="tabledata1">Saletax<label><font color="#FF0000"></font></label></td>
			<td></td>
		</tr>
	 	<tr class="row1">
		   	<td class="tabledata1">HardWare Amt</td>
			<td><?php echo $hardware_amt; ?></td>
		</tr>
		<tr class="row1">
			<td class="tabledata1">VAT/CST</td>
			<td><?php echo $s->getField('sales_tax_master','salestax_id',$vat_cst,'taxrate'); ?> % = 
			<?php echo $vat_cst_amt ?>		
			
			</td>
		</tr>
		<tr class="row1">
		<td class="tabledata1">Freight Amount<label><font color="#FF0000"></font></label></td>
		<td><?php echo $freight;?></td>
	</tr>
	<tr class="row1" style="background-color:#CCCCCC">
		<td class="tabledata1"><strong>Grand Total</strong><label><font color="#FF0000"></font></label></td>
		<td><?php echo $grand_total; ?></td>
	</tr>
		</table>
	</td>
</tr>
</table></td>
</tr>
</table>
<br />
<div align="center" id="foo">
	<a href="#" onclick="toggle_visibility(this.id)" id="print" style="text-decoration:none"><input type="button" value="Print" id="print" /></a>
	
</div>
	<script type="text/javascript" language="javascript">
  function toggle_visibility(id) {
 
	
       var e = document.getElementById("print");
            
	       e.style.display = 'none';
		       //alert(e.style.display);
			   window.print();
    }
</script>

</form>
</div>
</div>
