File: /home/cafsindia/refimac_cafsjobs_com/ajax/loaddata_bk15feb2017.php
<?php
include_once('../dbconnect.php');
$pageid=$_REQUEST['pageid'];
$type=$_REQUEST['type'];
$searchby=$_REQUEST['searchby'];
$searchtext=$_REQUEST['searchtext'];
if($pageid=="2_1_1")
{
if($type=="1")
{
?>
<div class="col-md-12">
<h4 class="heading">View / Search / Update Pages </h4>
<table class="table table-striped table-bordered table-hover dt-responsive" style="width:100% !important" id="sample" >
<thead>
<tr>
<th>S.No. </th>
<th>option</th>
<th>Name</th>
<th>Address </th>
<th>Area</th>
<th>Surround Area/City</th>
<th>Phone</th>
<th>Mobile</th>
<th>Contact Person</th>
<th>Pincode</th>
</tr>
</thead>
<tbody>
<?php
// use serial no to get customer code
if($searchby=="SERIALNO")
{
$sqls="SELECT GROUP_CONCAT(distinct(CUSTOMER_code)) as custcode FROM sales inner join service on service.SALES_ID=sales.SALES_ID where SERIALNO like '%".$searchtext."%' ORDER BY sales.SALES_ID";
//echo $sqls; die;
$qus=mysql_query($sqls);
$fetch=mysql_fetch_array($qus);
$customer_code=str_replace(',',"','",$fetch['custcode']);
$sql1="select CUSTOMER_NAME,CUSTOMER_ADDRESS,CUSTOMER_AREA,CUSTOMER_SURROUND_AREA,CUSTOMER_CITY,CUSTOMER_PINCODE,CUSTOMER_PHONE,CUSTOMER_MOBILE,CUSTOMER_CONTACT_PERSON from customer where CUSTOMER_code in ('".$customer_code."')";
//echo $sql1; die;
}
else
{
$sql1="select CUSTOMER_code, CUSTOMER_NAME,CUSTOMER_ADDRESS,CUSTOMER_AREA,CUSTOMER_SURROUND_AREA,CUSTOMER_CITY,CUSTOMER_PINCODE,CUSTOMER_PHONE,CUSTOMER_MOBILE,CUSTOMER_CONTACT_PERSON from customer where ".$searchby." like '%".$searchtext."%'";
}
//echo $sql1; die;
//$sql1="select CUSTOMER_NAME,CUSTOMER_ADDRESS,CUSTOMER_AREA,CUSTOMER_SURROUND_AREA from customer limit 1,10";
$qu1=mysql_query($sql1);
$i=1;
while($rd=mysql_fetch_array($qu1))
{
?>
<tr>
<td><?php echo $i;?></td>
<td><a id"viewmachine" alt="<?php echo $rd['CUSTOMER_code'];?>" onclick="viewmachine('<?php echo $rd['CUSTOMER_code'];?>')" title="View Machine"><span class="icon-pencil" style="cursor: pointer;" ></a> <a id"booknew" alt="<?php echo $rd['CUSTOMER_code'];?>" onclick="bookcomplaint('<?php echo $rd['CUSTOMER_code'];?>')"><span class="icon-plus" style="cursor: pointer;" title="Book New Complaint"></a> <a id"viewcomplaints" alt="<?php echo $rd['CUSTOMER_code'];?>" onclick="viewcomplaints('<?php echo $rd['CUSTOMER_code'];?>')"><span class="icon-call-in" style="cursor: pointer;" id"viewcomplaints" alt="<?php echo $rd['CUSTOMER_code'];?>" title="View Complaint History"></a></td>
<td ><?php echo $rd['CUSTOMER_NAME'];?></td>
<td ><?php echo $rd['CUSTOMER_ADDRESS'];?></td>
<td ><?php echo $rd['CUSTOMER_AREA'];?></td>
<td class="center" ><?php echo $rd['CUSTOMER_SURROUND_AREA'].'-'. $rd['CUSTOMER_CITY']; ?></td>
<!--<td class="center" ><?php echo $rd['CUSTOMER_CITY']; ?></td> -->
<td class="center" ><?php echo $rd['CUSTOMER_PHONE']; ?></td>
<td class="center" ><?php echo $rd['CUSTOMER_MOBILE']; ?></td>
<td class="center"><?php echo $rd['CUSTOMER_CONTACT_PERSON']; ?></td>
<td class="center"><?php echo $rd['CUSTOMER_PINCODE']; ?></td>
</tr>
<?php $i++; }?>
</tbody>
</table>
</div>
<?php
}
elseif($type=="2")
{
$custcode=$_REQUEST['custcode'];
$serviceno=$_REQUEST['serviceno'];
$salesid=$_REQUEST['salesid'];
$sql_cust="select CUSTOMER_NAME,CUSTOMER_ADDRESS,CUSTOMER_AREA,CUSTOMER_SURROUND_AREA,CUSTOMER_CITY,CUSTOMER_PINCODE,CUSTOMER_PHONE,CUSTOMER_MOBILE,CUSTOMER_CONTACT_PERSON from customer where CUSTOMER_CODE='".$custcode."'";
//echo $sql_cust; die;
$qu=mysql_query($sql_cust);
$fvc=mysql_fetch_array($qu);
$CUSTOMER_CODE=$custcode;
$CUSTOMER_NAME=$fvc['CUSTOMER_NAME'];
$CUSTOMER_ADDRESS=$fvc['CUSTOMER_ADDRESS'];
$CUSTOMER_AREA=$fvc['CUSTOMER_AREA'];
$CUSTOMER_SURROUND_AREA=$fvc['CUSTOMER_SURROUND_AREA'];
$CUSTOMER_CITY=$fvc['CUSTOMER_CITY'];
$CUSTOMER_PINCODE=$fvc['CUSTOMER_PINCODE'];
$CUSTOMER_PHONE=$fvc['CUSTOMER_PHONE'];
$CUSTOMER_MOBILE=$fvc['CUSTOMER_MOBILE'];
$CUSTOMER_CONTACT_PERSON=$fvc['CUSTOMER_CONTACT_PERSON'];
// sales info
if($salesid!="")
{
$sql_sales="select from sales where SALES_ID='".$salesid."' and CUSTOMER_CODE='".$custcode."'";
//echo $sql_cust; die;
$qusales=mysql_query($sql_sales);
$fvs=mysql_fetch_array($qusales);
$make_id=$fvs['MAKE_ID'];
$salesid=$salesid;
}
?>
<div class="portlet light">
<form id="cust_form" method="post">
<!-- Customer info start-->
<div class="customerinfo">
<div class="row">
<div class="col-md-12">
<div class="col-md-3">
<label><strong>Customer Info</strong></label>
</div>
</div>
</div>
<div class="row">
<div class="col-md-12">
<div class="col-md-3">
<label>Customer Name <span class="f_req">*</span></label>
<input name="CUSTOMER_NAME" type="text" class="form-control" id="CUSTOMER_NAME" value="<?php echo $CUSTOMER_NAME; ?>" />
<input name="CUSTOMER_CODE" type="hidden" class="form-control" id="CUSTOMER_CODE" value="<?php echo $USTOMER_CODE; ?>" />
<span class="help-block">Enter customer name </span>
</div>
<div class="col-md-3">
<label>Customer Address <span class="f_req">*</span></label>
<input name="CUSTOMER_ADDRESS" type="text" class="form-control" id="CUSTOMER_ADDRESS" value="<?php echo $CUSTOMER_ADDRESS; ?>" />
<span class="help-block">Enter customer Address </span>
</div>
<div class="col-md-3">
<label>Customer Area <span class="f_req">*</span></label>
<input name="CUSTOMER_AREA" type="text" id="CUSTOMER_AREA" class="form-control" value="<?php echo $CUSTOMER_AREA; ?>" />
<!--class="form-control date-picker" data-date-format="dd-mm-yyyy"-->
</div>
<div class="col-md-3">
<label>Surround Area <span class="f_req">*</span></label>
<select name="CUSTOMER_SURROUND_AREA" class="form-control select2 col-md-12" id="cust_area" style="max-height:400px;" >
<option value="">Select</option>
<?php
$sql="select area_name from area where area_update=1";
$qu=mysql_query($sql);
while($r=mysql_fetch_array($qu))
{
?>
<option <?php if($CUSTOMER_SURROUND_AREA==$r['area_name']) echo "selected='selected'";?> value="<?php echo $r['area_name'];?>"><?php echo $r['area_name'];?></option>
<?php }?>
</select>
</div>
</div>
</div>
<div class="row">
<div class="col-md-12">
<div class="col-md-3">
<label>City<span class="f_req">*</span></label>
<input name="CUSTOMER_CITY" type="text" class="form-control" id="CUSTOMER_CITY" value="<?php echo $CUSTOMER_NAME; ?>" />
<span class="help-block">Enter city </span>
</div>
<div class="col-md-3">
<label>Customer Pincode <span class="f_req">*</span></label>
<input name="CUSTOMER_PINCODE" type="text" class="form-control" id="CUSTOMER_PINCODE" value="<?php echo $CUSTOMER_NAME; ?>" />
</div>
<div class="col-md-3">
<label>Phone <span class="f_req">*</span></label>
<input name="CUSTOMER_PHONE" type="text" class="form-control" id="CUSTOMER_PHONE" value="<?php echo $CUSTOMER_PHONE; ?>" />
</div>
<div class="col-md-3">
<label>Mobile<span class="f_req">*</span></label>
<input name="CUSTOMER_MOBILE" type="text" class="form-control" id="CUSTOMER_MOBILE" value="<?php echo $CUSTOMER_MOBILE; ?>" />
<!--class="form-control date-picker" data-date-format="dd-mm-yyyy"-->
</div>
</div>
</div>
<div class="row">
<div class="col-md-12">
<div class="col-md-3">
<label>Contact Person<span class="f_req">*</span></label>
<input name="CUSTOMER_CONTACT_PERSON" type="text" class="form-control" id="CUSTOMER_CONTACT_PERSON" value="<?php echo $CUSTOMER_CONTACT_PERSON; ?>" />
</div>
</div>
</div>
</div>
<div class="complaintinfo">
<div class="row">
<div class="col-md-12">
<div class="col-md-3">
<label><strong>Complaint Info</strong></label>
</div>
</div>
</div>
<div class="row">
<div class="col-md-12">
<div class="col-md-3">
<label>Call Type <span class="f_req">*</span></label>
<select name="select" class="form-control select2 col-md-12" id="call_type" style="max-height:400px;" >
<option value="">Select</option>
<option value="Installation">Installation</option>
<option value="Breakdown">Breakdown</option>
<option value="AMC">AMC</option>
<option value="PMS">PMS</option>
</select>
<span class="help-block">Select call type</span>
</div>
<div class="col-md-3">
<label>Brand <span class="f_req">*</span></label>
<select name="brand_name" class="form-control select2 col-md-12" id="brand_name" style="max-height:400px;" >
<option value="">Select</option>
<?php
$sql="select make_name,make_id from make";
$qu=mysql_query($sql);
while($r=mysql_fetch_array($qu))
{
?>
<option <?php if($make_id==$r['make_id']) echo "selected='selected'";?> value="<?php echo $r['make_id'];?>"><?php echo $r['make_name'];?></option>
<?php }?>
</select>
<span class="help-block">Select brand name</span>
</div>
<div class="col-md-3">
<label>Product <span class="f_req">*</span></label>
<select name="cust_product" class="form-control select2" id="cust_product" style="max-height:400px;" >
<option value="">Select</option>
<?php
$sql="select product_id,product_name from serviceapp_product where status=1";
$qu=mysql_query($sql);
while($r=mysql_fetch_array($qu))
{
?>
<option <?php if($product_id==$r['product_id']) echo "selected='selected'";?> value="<?php echo $r['product_id'];?>"><?php echo $r['product_name'];?></option>
<?php }?>
</select>
<!--class="form-control date-picker" data-date-format="dd-mm-yyyy"-->
</div>
<div class="col-md-3">
<label>Fault Reported <span class="f_req">*</span></label>
<input name="fault_report" type="text" class="form-control " id="fault_report" />
</div>
</div>
</div>
<div class="row">
<div class="col-md-12">
<div class="col-md-3">
<label>Machine Location<span class="f_req">*</span></label>
<input name="location" type="text" class="form-control" id="location" />
<span class="help-block">Enter Service Requested Date & Time </span>
</div>
<div class="well">
<div id="datetimepicker1" class="input-append date">
<input data-format="dd/MM/yyyy hh:mm:ss" type="text"></input>
<span class="add-on">
<i data-time-icon="icon-time" data-date-icon="icon-calendar">
</i>
</span>
</div>
</div>
<script type="text/javascript">
$(function() {
$('#datetimepicker1').datetimepicker({
language: 'pt-BR'
});
});
</script>
<div class="col-md-3">
<label>Service Requested Date & Time <span class="f_req">*</span></label>
<input name="service_req_datetime" type="text" class="form-control" id="service_req_datetime" />
<span class="help-block">Enter Service Requested Date & Time </span>
</div>
<div class="col-md-3">
<label>Technecian <span class="f_req">*</span></label>
<select name="cust_product" class="form-control select2" id="cust_product" style="max-height:400px;" >
<option value="">Select</option>
<?php
$sql="select EMP_ID,EMP_NAME from employee where EMP_UPDATE=1";
$qu=mysql_query($sql);
while($r=mysql_fetch_array($qu))
{
?>
<option <?php if($EMP_ID==$r['EMP_ID']) echo "selected='selected'";?> value="<?php echo $r['EMP_ID'];?>"><?php echo $r['EMP_NAME'];?></option>
<?php }?>
</select>
</div>
<div class="col-md-3">
<label>Remarks<span class="f_req">*</span></label>
<textarea name="comp_remarks" class="form-control" id="comp_remarks"></textarea>
</div>
</div>
</div>
</div>
<div class="form-actions">
<div class="row">
<div class="col-md-offset-3 col-md-9">
<button type="submit" class="btn green">Submit</button>
<button type="button" class="btn dark btn-outline" data-dismiss="modal">Close</button>
</div>
</div>
</div>
</form>
</div>
<?php
}
elseif($type=="3")
{
$custcode=$_REQUEST['custcode'];
?>
<div class="col-md-12">
<div id="serviceinfo" style="display:none;height:300px; overflow:scroll;">
</div>
<h4 class="heading">View / Search Machine </h4>
<table class="table table-striped table-bordered table-hover dt-responsive" style="width:100% !important" id="viewmachineinfo" >
<thead>
<tr>
<th>S.No.</th>
<th>option</th>
<th>Name</th>
<th>Serial No.</th>
<th>Compressor No</th>
<th>Installation Date</th>
<th>Maturity date</th>
<th>Invoice date</th>
<th>Servicemode</th>
<th>Capacity</th>
</tr>
</thead>
<tbody>
<?php
$sql1="SELECT *,(select SERVICE_MODE_NAME FROM service_mode where service_mode.SERVICE_MODE_ID=sales.SERVICEMODE_ID) as SERVICEMODENAME ,(select PURCHASE_SERIALNUMBER FROM purchase where purchase.PURCHASE_ID=sales.PURCHASE_ID order by SALES_ID limit 0,1) as SERIALNO from sales inner join customer on sales.CUSTOMER_CODE=customer.CUSTOMER_CODE where customer.CUSTOMER_CODE='".$custcode."'";
//echo $sql1; die;
//$sql1="select CUSTOMER_NAME,CUSTOMER_ADDRESS,CUSTOMER_AREA,CUSTOMER_SURROUND_AREA from customer limit 1,10";
$qu1=mysql_query($sql1);
$i=1;
while($rd=mysql_fetch_array($qu1))
{
?>
<tr>
<td><?php echo $i;?></td>
<td><a id"viewserviceinfo" alt="<?php echo $rd['SALES_ID'];?>" onclick="viewserviceinfo('<?php echo $rd['SALES_ID'];?>')" title="View Service Info"><span class="icon-pencil" style="cursor: pointer;" ></a> <a id"booknew" alt="<?php echo $rd['CUSTOMER_CODE'];?>" onclick="bookcomplaint('<?php echo $rd['CUSTOMER_CODE'];?>')"><span class="icon-plus" style="cursor: pointer;" title="Book New Complaint"></a> <a><span class="icon-call-in" style="cursor: pointer;" id"viewmachine" alt="<?php echo $rd['CUSTOMER_CODE'];?>" title="View Complaint History"></a></td>
<td ><?php echo $rd['CUSTOMER_NAME'];?></td>
<td ><?php echo $rd['SERIALNO'];?></td>
<td ><?php echo $rd['COMPRESSORNO'];?></td>
<td ><?php echo $rd['INSTALLATION_DATE'];?></td>
<td class="center" ><?php echo $rd['MATURITY_DATE']; ?></td>
<td class="center" ><?php echo $rd['INVOICE_DATE']; ?></td>
<td class="center" ><?php echo $rd['SERVICEMODENAME']; ?></td>
<td class="center"><?php echo $rd['CAPACITY']; ?></td>
</tr>
<?php $i++; }?>
</tbody>
</table>
</div>
<?php
}
elseif($type=="4")
{
$salesid=$_REQUEST['salesid'];
?>
<button class="btn red" id="hideservice" onclick="hideservice()">Hide Service (-)</button></br>
<div class="col-md-12">
<table class="table table-striped table-bordered table-hover dt-responsive" style="width:100% !important" id="viewserviceinfo" >
<thead>
<tr>
<th>S.No.</th>
<th>option</th>
<th>Serial No.</th>
<th>Employee Name</th>
<th>Slip No.</th>
<th>Date</th>
<th>Month</th>
<th>Year</th>
<th>Service No</th>
<th>Service Status</th>
<th>Service Report</th>
</tr>
</thead>
<tbody>
<?php
$sql1="SELECT *,(select EMP_NAME from employee where employee.EMP_ID=service.EMPLOYEE_ID) as EMP_NAME FROM `service` WHERE `SALES_ID` = '".$salesid."' ";
//echo $sql1; die;
//$sql1="select CUSTOMER_NAME,CUSTOMER_ADDRESS,CUSTOMER_AREA,CUSTOMER_SURROUND_AREA from customer limit 1,10";
$qu1=mysql_query($sql1);
$i=1;
while($rd=mysql_fetch_array($qu1))
{
?>
<tr>
<td><?php echo $i;?></td>
<td><a id"booknew" alt="<?php echo $rd['CUSTOMER_CODE'];?>" onclick="bookcomplaintwithservice('<?php echo $rd['CUSTOMER_CODE'] ?>','<?php echo $salesid;?>','<?php echo $rd['LIST_INDEX'] ?>')"><span class="icon-plus" style="cursor: pointer;" title="Book New Complaint"></a> </td>
<td ><?php echo $rd['SERIALNO'];?></td>
<td ><?php echo $rd['EMP_NAME'];?></td>
<td ><?php echo $rd['SLIPNO'];?></td>
<td class="center" ><?php echo $rd['DATE']; ?></td>
<td class="center" ><?php echo $rd['MONTH']; ?></td>
<td class="center" ><?php echo $rd['YEAR']; ?></td>
<td class="center"><?php echo $rd['LIST_INDEX']; ?></td>
<td class="center"><?php if($rd['COMPLETED']=='Y') echo "completed"; else echo "Upcoming/Pending"; ?></td>
<td><a href="<?php echo "#"; ?>" id"servicereport" target="_blank" title="View Service Report">View Report</a></td>
</tr>
<?php $i++; }?>
</tbody>
</table>
</div>
<?php
}
elseif($type=="5")
{
$custcode=$_REQUEST['custcode'];
?>
<div class="col-md-12">
<table class="table table-striped table-bordered table-hover dt-responsive" style="width:100% !important" id="viewtablecomplaintinfo" >
<thead>
<tr>
<th>S.No.</th>
<th>option</th>
<th>Complaint No</th>
<th>Complaint Date & Time</th>
<th>Customer Name</th>
<th>Phone No.</th>
<th>Mobile No.</th>
<th>Call Type</th>
<th>Brand Name</th>
<th>Product</th>
<th>Service Requested Date & Time</th>
<th>Fault Report</th>
<th>View Service</th>
</tr>
</thead>
<tbody>
<?php
$sql1="SELECT reg_id,cust_code,CUSTOMER_NAME,CUSTOMER_ADDRESS,CUSTOMER_AREA,CUSTOMER_SURROUND_AREA,CUSTOMER_CITY,CUSTOMER_PINCODE,CUSTOMER_PHONE,CUSTOMER_MOBILE,CUSTOMER_CONTACT_PERSON,complaint_no,complaint_date,complaint_time,call_type,brand_name,product,fault_report,location,service_req_datetime,tech_name,remarks FROM `serviceapp_callreg` WHERE `cust_code` = '".$custcode."' and status='1' ";
//$sql1="select CUSTOMER_NAME,CUSTOMER_ADDRESS,CUSTOMER_AREA,CUSTOMER_SURROUND_AREA from customer limit 1,10";
$qu1=mysql_query($sql1);
$i=1;
while($rd=mysql_fetch_array($qu1))
{
?>
<tr>
<td><?php echo $i;?></td>
<td><a id"booknew" alt="<?php echo $rd['CUSTOMER_CODE'];?>" onclick="bookcomplaintwithservice('<?php echo $rd['CUSTOMER_CODE'] ?>','<?php echo $salesid;?>','<?php echo $rd['LIST_INDEX'] ?>')"><span class="icon-plus" style="cursor: pointer;" title="Book New Complaint"></a> </td>
<td ><?php echo $rd['complaint_no'];?></td>
<td ><?php echo $rd['complaint_date'].' '.$rd['complaint_time'];?></td>
<td ><?php echo $rd['CUSTOMER_NAME'];?></td>
<td class="center" ><?php echo $rd['CUSTOMER_PHONE']; ?></td>
<td class="center" ><?php echo $rd['CUSTOMER_MOBILE']; ?></td>
<td class="center"><?php echo $rd['call_type']; ?></td>
<td class="center"><?php echo $rd['brand_name']; ?></td>
<td class="center"><?php echo $rd['product']; ?></td>
<td class="center"><?php echo $rd['service_req_datetime']; ?></td>
<td class="center"><?php echo $rd['fault_report']; ?></td>
<td><a href="print_service.php?number=<?php echo $rd['complaint_no']; ?>" id"servicereport" target="_blank" title="View Service Report">View Report</a></td>
</tr>
<?php $i++; }?>
</tbody>
</table>
</div>
<?php
}
}
?>