<?php
if($_REQUEST['print']!=''){
 $PageSecurity = 3;
error_reporting(0);	
if($_REQUEST['route']=='' )
{
include('includes/SQL_CommonFunctions.inc');
include('includes/session.inc');
include('includes/function_lib.php');
}
}
  echo '<link href="'.$rootpath. '/css/'. $_SESSION['Theme'] .'/default.css" rel="stylesheet" type="text/css" />';
?>
<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 
	$condition="id='".$_REQUEST['tvid']."'";
	$GetRec=$s->GetRecordById('technician_visit_entry',  $condition);
	$GetRecRow=DB_fetch_array($GetRec);
	extract($GetRecRow);
?>
<div style="width:814px; float:left; padding:10px; margin-left:90px;">

<link rel="stylesheet" href="css/new_mxerp.css">
<div class="body_contain">
<div class="tab_div">

<h1>Job Card</h1>

<div style="width:800px; margin-left:auto; margin-right:auto;">
<table width="100%" border="1" cellpadding="3" cellspacing="0" style="border-collapse:collapse; border:#666666 solid 1px;">
<tr>
  <td class="tabledata1"><strong>Job Card No.</strong></td>
	  <td style="width:317px;"><?php echo $s->GetFieldValue('trouble_ticket_jobcard',"id='".$job_card_no."'",'job_card_number'); ?></td>
<td class="tabledata1"><strong>Date</strong></td>
<td><?php echo $s->GetFieldValue('trouble_ticket_jobcard',"id='".$job_card_no."'",'job_card_date'); ?></td>
</tr>  

<tr>
  <td class="tabledata1"><strong>Customer Name</strong></td>
	  <td><?php echo $s->GetFieldValue('clientmaster',"id='".$party_name."'",'c_name'); ?></td>
<td class="tabledata1">&nbsp;</td>
<td>&nbsp;</td>
</tr>  
</table>
</div>


<div style="width:800px; overflow:auto; margin-left:auto; margin-right:auto;">
<table width="100%" border="1" cellpadding="3" cellspacing="0" style="border-collapse:collapse; border:#666666 solid 1px;">
  <tr>
    <td class="tabledata" style="width:5%;">S. No.</td>
    <td class="tabledata" style="width:40%;">Materials</td>
    <td class="tabledata" style="width:15%;">Part No.</td>
    <td class="tabledata" style="width:15%;">No. of Unit</td>
    <td class="tabledata" style="width:10%;">Unit Cost</td>
    <td class="tabledata" style="width:15%;">Material Charge</td>
  </tr>
  <?php 
		$i=0;
		$part_amt = 0.00;
		$ItemList=DB_query("select * from technician_visit_entry_details where parant_id='".$_REQUEST['tvid']."'",$db);			  
		while($ItemRow=DB_fetch_array($ItemList)) {?>
	<tr>
    <td><?php echo $i+1; ?></td>
    <td><?php echo $s->GetFieldValue('item_master',"id='".$ItemRow['item_name']."'",'item_name'); ?></td>
    <td>&nbsp;</td>
    <td><?php echo $ItemRow['req_qty']; ?></td>
    <td><?php echo $ItemRow['price']; ?></td>
    <td><?php echo $ItemRow['tptal_amt']; 
		$part_amt += $ItemRow['tptal_amt'];
	  ?></td>
	</tr> 
	<?php $i++;} ?>
	<?php for(;$i<10;$i++){?>
	<tr>
		<td><?php echo $i+1; ?></td>
		<td>&nbsp;</td>
		<td>&nbsp;</td>
		<td>&nbsp;</td>
		<td>&nbsp;</td>
		<td>&nbsp;</td>
	</tr> 
	<?php } ?>
  <tr>
    <td>&nbsp;</td>
    <td>&nbsp;</td>
    <td>&nbsp;</td>
    <td class="tabledata" colspan="2">Total Materials Amount</td>
    <td><?php echo $part_amt; ?></td>
  </tr>
</table>
</div>



<div style="width:800px; overflow:auto; margin-left:auto; margin-right:auto;">
<table width="100%" border="1" cellpadding="3" cellspacing="0" style="border-collapse:collapse; border:#666666 solid 1px;">
  <tr>
    <td class="tabledata" style="width:5%">S. No.</td>
    <td class="tabledata" style="width:40%;">Service</td>
    <td class="tabledata" style="width:15%;">Service Type</td>
	<td class="tabledata" style="width:15%;">Service Description</td>
    <td class="tabledata" style="width:10%;" >Billable?</td>
    <td class="tabledata" style="width:15%;">Billing Value</td>

  </tr>
<?php  $Service = DB_query("SELECT * FROM technician_service_visit where parant_id='".$_REQUEST['tvid']."'",$db);
			 if(DB_num_rows($Service)>0){ 
			 $i=0;
			 $ser_amt = 0.00;
			 while($ServiceRow=DB_fetch_array($Service)) {
			 ?>
	<tr>
    <td><?php echo $i+1; ?></td>
    <td><?php echo $ServiceRow['service_name']; ?></td>
    <td><?php echo $s->GetFieldValue('services_type',"id='".$ServiceRow['service_type']."'",'service_type'); ?></td>
	<td><?php echo $s->GetFieldValue('services_description',"id='".$ServiceRow['service_description']."'",'service_description'); ?></td>
    <td>&nbsp;</td>
    <td><?php echo $ServiceRow['service_amt']; 
		$ser_amt += $ServiceRow['service_amt'];
	?></td>
	</tr> 
<?php $i++;}} ?>
 <?php for(;$i<10;$i++){?>
	<tr>
		<td><?php echo $i+1; ?></td>
		<td>&nbsp;</td>
		<td>&nbsp;</td>
		<td>&nbsp;</td>
		<td>&nbsp;</td>
		<td>&nbsp;</td>
	</tr> 
	<?php } ?>
  <tr>
    <td>&nbsp;</td>
    <td>&nbsp;</td>
	<td>&nbsp;</td>
    <td class="tabledata" colspan="2">Total Service Cost </td>
    <td><?php echo $ser_amt; ?></td>
  </tr>
</table>
</div>





<div style="width:800px; overflow:auto; margin-left:auto; margin-right:auto;">
<table width="100%" border="0" cellpadding="5" cellspacing="0" style="border-collapse:collapse; border:#666666 solid 1px;">
 <tr>
    <td>&nbsp;</td>
    <td>&nbsp;</td>
    <td class="tabledata" style="border-bottom:#000000 solid 1px;text-align:right">Total Materials</td>
    <td style="border-bottom:#000000 solid 1px;text-align:right; width:15%"><?php echo $part_amt; ?></td>
  </tr>
  
  <tr>
    <td>&nbsp;</td>
    <td>&nbsp;</td>
    <td class="tabledata" style="border-bottom:#000000 solid 1px;text-align:right">Vat/Cst</td>
    <td style="border-bottom:#000000 solid 1px;text-align:right"><?php echo $VatCstValue; ?></td>
  </tr>
 
	<tr>
    <td><strong>Sign</strong></td>
    <td style="width:398px;">__________________________________________</td>
    <td class="tabledata" style="border-bottom:#000000 solid 1px; text-align:right">Total Labour</td>
    <td style="border-bottom:#000000 solid 1px;text-align:right; width:50px;"><?php echo $ser_amt; ?></td>
	</tr> 
	<tr>
    <td><strong>Sign</strong></td>
    <td style="width:398px;">__________________________________________</td>
    <td class="tabledata" style="border-bottom:#000000 solid 1px; text-align:right">Service Tax</td>
    <td style="border-bottom:#000000 solid 1px;text-align:right; width:50px;"><?php echo $service_tax_value; ?></td>
	</tr> 

  <tr>
	<td><strong>Approved</strong></td>
    <td>__________________________________________</td>
	<td class="tabledata" style="border-bottom:#000000 solid 1px;text-align:right">Other Amount</td>
    <td style="border-bottom:#000000 solid 1px;text-align:right"><?php if($other_charges==''){echo "0";}else{echo $other_charges;}?></td>
  </tr>
  <tr>
    <td>&nbsp;</td>
    <td>&nbsp;</td>
    <td class="tabledata" style="border-bottom:#000000 solid 1px;text-align:right">Total Charge</td>
    <td style="border-bottom:#000000 solid 1px;text-align:right"><?php echo $grand_total; ?></td>
  </tr>



</table>
</div>
<div id="foo"><p align="center">
<a href="#" onclick="javascript:toggle_visibility('foo');" >Print</a>  
</div>
</div></div>
</div>

