<?php 
$PageSecurity = 11;
include('includes/session.inc');
include('includes/function_lib.php');
include('includes/SQL_CommonFunctions.inc');
$JobCardNo=$_REQUEST['JCARDNO'];
if($JobCardNo!='')
{
$party=DB_query("select * from trouble_ticket_jobcard where id='".$JobCardNo."'",$db);
$partyRow=DB_fetch_array($party);
$PartyName=$s->GetFieldValue('clientmaster',"id='".$partyRow['party_name']."'",'c_name');
$ProductName=$s->GetFieldValue('item_master',"id='".$partyRow['product_name']."'",'item_name');
$TTNO=$s->GetFieldValue('trouble_ticket_creation',"id='".$partyRow['ticket_number']."'",'ticket_number');
$INVOICENO=$s->GetFieldValue('trouble_ticket_creation',"id='".$partyRow['ticket_number']."'",'invoiceNo');
$TECHNICIANNAME=$s->GetFieldValue('technicians',"id='".$partyRow['technician']."'",'technician');

if($partyRow['scope_compaint']=='1')
{$SCOPE='Complaint';}
if($partyRow['scope_compaint']=='2')
{$SCOPE='Installation';}
if($partyRow['scope_compaint']=='3')
{$SCOPE='De-Installation';}
if($partyRow['scope_compaint']=='4')
{$SCOPE='Re-Installation';}
if($partyRow['scope_compaint']=='5')
{$SCOPE='Preventive';}
if($partyRow['scope_compaint']=='6')
{$SCOPE='Service';}
if($partyRow['scope_compaint']=='7')
{$SCOPE='Site Survey';
}
$data1="";
$data1.="<input type='hidden' name='party_name' id='party_name' value='".$partyRow['party_name']."' style='width:100%' />";
$data1.="<input type='text' name='party_name1' id='party_name1' value='".$PartyName."' style='width:100%' />";

$data2="";
$data2.="<input type='hidden' name='tt_no' id='tt_no' value='".$partyRow['ticket_number']."' style='width:100%' />";
$data2.="<input type='text' name='tt_no1' id='tt_no1' value='".$TTNO."' style='width:100%' />";

$data3="";
$data3.="<input type='hidden' name='product_name' id='product_name' value='".$partyRow['product_name']."' style='width:100%;'>";
$data3.="<input type='text' name='product_name1' id='product_name1' value='".$ProductName."' style='width:100%;'>";

$data4="";
$data4.="<input type='text' name='serial_no' id='serial_no' value='".$partyRow['serial_number']."' style='width:100%' />";

$data5="";
$data5.="<input type='text' name='invoice_no' id='invoice_no' value='".$INVOICENO."' style='width:100%' />";

$data6="";
$data6.="<input type='hidden' name='service_scope_no' id='service_scope_no' value='".$partyRow['scope_compaint']."'style='width:100%' />";
$data6.="<input type='text' name='service_scope_no1' id='service_scope_no1' value='".$SCOPE."'style='width:100%' />";

$data7="";
$data7.="<input type='hidden' name='technician' id='technician' value='".$partyRow['technician']."' style='width:100%' />";
$data7.="<input type='text' name='technician1' id='technician1' value='".$TECHNICIANNAME."' style='width:100%' />";

$data8="";
$data8.="<input type='text' name='fault_details' id='fault_details' value='".$partyRow['prob_desc']."' style='width:100%' />";

$data9="";
$data9.="<input name='Total_material_Amt' type='text' value='".$partyRow['materialAmount']."'  style='width:107px;' onfocus='calculatematerialamt()' id='Total_material_Amt' readonly />";


$data10="";
$data10.="<select name='VatCst' id='value3' onchange='calculateVATCST(this.value)' style='width:107px;'>";
$data10.="<option value='' >Select</option>";
$salesSql=DB_query("Select * from sales_tax_master",$db);
while($salesRow=DB_fetch_array($salesSql)){
$sel1='';
if($partyRow['VatCst']==$salesRow['salestax_id'])
$sel1='selected';
$data10.="<option value='".$salesRow['salestax_id']."' ".$sel1.">".$salesRow['tax_code']."</option>";}
$data10.="</select>";
$data10.="<input name='VatCstValue' id='VatCstValue' readonly type='text' value='".$partyRow['VatCstValue']."' style='width:107px;'   onfocus='calculateEditVATCST()' readonly />";
$data10.="<input type='hidden' name='' id='rate' value='".$rate."' />";

$data11="";
$data11.="<input type='text' name='service_total_amt' id='service_total_amt' style='width:107px;' value='".$partyRow['serviceAmount']."' onfocus='calculateserviceamt()' readonly />";

$data12="";
$servSql=DB_query("select * from service_tax_master",$db);
while($servRow=DB_fetch_array($servSql)){
$sel2='';
if($partyRow['serviceTax']==$servRow['id'])
$sel2='selected';
$data12.="<select name='service_tax' id='service_tax' style='width:107px;' onchange='calculateservice(this.value)'>";
$data12.="<option value='0'>Select</option>";
$data12.="<option value='".$servRow['id']."' ".$sel2.">".$servRow['tax_code']."</option>";
$data12.="</select>";
}
$data12.="<input name='service_tax_value' id='service_tax_value' type='text' value='".$partyRow['serviceTaxValue']."' style='width:107px;' readonly onfocus='calculateserv()' />";

$data12.="<input type='hidden' name='' id='service_rate' value='' />";


$data13="";
$data13.="<input name='other_amt' id='other_amt' type='text' style='width:107px;' onfocus=''/>";

$data14="";
$data14.="<input name='grandTotal' id='grandTotal' type='text' value='".$partyRow['grandTotal']."'  style='width:107px;' onfocus='calculateGrand()' readonly='readonly'  />";









$data15="";
$i=0;
$ItemSQL=DB_query("select * from trouble_ticket_jobcard_details where jc_id='".$JobCardNo."'",$db);
$data15.="<table width='806' border='1' cellspacing='0' cellpadding='3'>";
while($ItemList=DB_fetch_array($ItemSQL)){
$data15.="<tr class='row1'>";
$data15.="<td style='width:31px;'><a href='index.php?route=service/technician_visit_entry&action=DelItem&JCID=".$ItemList['id']."&modid=".$_REQUEST['modid']."&frmid=".$_REQUEST['frmid']."'><img src='images/delete.gif' /></a></td>";
$data15.="<td style='width:5px;'><input type='hidden' name='itemid1[]'  id='itemid1_".$i."' value='".$ItemList['itemname']."' size='40'/></td>";
$data15.="<td style='width:190px;'>".$s->GetFieldValue('item_master',"id='".$ItemList['itemname']."'",'item_name')."</td>";
$data15.="<td style='width:23px;'><input type='text' name='rqty1[]'  id='rqty_".$i."' value='".$ItemList['rqty']."' /></td>";
$data15.="<td style='width:23px;'><input type='text' name='price1[]' id='price_".$i."' value='".$ItemList['price']."' /></td>";
$data15.="<td style='width:23px;'><input type='text' name='amt1[]' id='amt_".$i."'  value='".$ItemList['amt']."' onkeyup='calculateTotalAmt(this.id)'/></td>";
$data15.="</tr>";
$i++;}
$data15.="</table>";
$data16="";
$data16.=$i;











//echo "select * from add_service_jobcard where jc_id='".$JobCardNo."'";
$serviceSQL=DB_query("select * from add_service_jobcard where jc_id='".$JobCardNo."'",$db);
$data17="";
if(DB_num_rows($serviceSQL)>0)
$data17.='block';
else
$data17.='none';

$data18="";
$j=0;
$data18.="<table width='806' border='1' cellspacing='0' cellpadding='3'>";
while($serviceList=DB_fetch_array($serviceSQL)){
$data18.="<tr class='row1'>";
$data18.="<td style='width:44px;'><a href='index.php?route=service/technician_visit_entry&action=DelService&JCID=".$serviceList['id']."&modid=".$_REQUEST['modid']."&frmid=".$_REQUEST['frmid']."'><img src='images/delete.gif' /></a></td>";
$data18.="<td style=''><input type='text' name='service1[]' value='".$serviceList['service']."' id='service' style='width:120px;'/></td>";
$serv= DB_query("SELECT * FROM services_type",$db);
$data18.="<td>";
$data18.="<select name='service_type1[]' id='service_type' style='width:137px;'>";
$data18.="<option value=''>--Select--</option>";
while($getServe_type= DB_fetch_array($serv)){
$sel34='';
if($getServe_type['id']==$serviceList['service_type'])
$sel34='selected';
$data18.="<option value='".$getServe_type['id']."' ".$sel34.">".$getServe_type['service_type']."</option>";
}
$data18.="</select>";
$data18.="</td>";
$stype= DB_query("SELECT * FROM services_description",$db);
$data18.="<td>";
$data18.="<select name='service_desc1[]' id='service_desc' style='width:143px;'>";
$data18.="<option value=''>--Select--</option>";
while($getStype= DB_fetch_array($stype)){
$sel43='';
if($getStype['id']==$serviceList['service_desc'])
$sel43='selected';
$data18.="<option value='".$getStype['id']."' ".$sel43.">".$getStype['service_description']."</option>";
}
$data18.="</select>";
$data18.="</td>";

$data18.="<td>";
$data18.="<select name='billable1[]' id='billable' style='width:140px;'>";
$data18.="<option value='Y'".($serviceList['billable']=='Y'?'selected':'').">YES</option>";
$data18.="<option value='N'".($serviceList['billable']=='N'?'selected':'').">NO</option>";
$data18.="</select>";
$data18.="</td>";


$data18.="<td><input type='text' name='service_amt1[]' id='service_amt_".$j."' value='".$serviceList['service_amt']."' style='width:140px;'/></td>";
$data18.="</tr>";
$j++;}
$data18.="</table>";
$data19="";
$data19.=$j;
echo $data=$data1."__".$data2."__".$data3."__".$data4."__".$data5."__".$data6."__".$data7."__".$data8."__".$data9."__".$data10."__".$data11."__".$data12."__".$data13."__".$data14."__".$data15."__".$data16."__".$data17."__".$data18."__".$data19;

}// END IF

?>