<?php
	//Start session
	session_start();
	
	//Check whether the session variable SESS_MEMBER_ID is present or not
	if(!isset($_SESSION['SESS_MEMBER_ID']) || (trim($_SESSION['SESS_MEMBER_ID']) == '')) {
		header("location: index.html");
		exit();
	}
?>
<!--
To change this template, choose Tools | Templates
and open the template in the editor.
-->
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>Master Edit</title>
<meta name="description" content=""/>
<meta name="keywords" content=""/>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1"/>
<script type="text/javascript" src="../javascript/jquery.js"></script>
<script type="text/javascript" src="../javascript/jquery.autocomplete.js"></script>
<script type="text/javascript" src="../javascript/jNotify.jquery.min.js"></script>
<script type="text/javascript" src="../javascript/jNotify.jquery.js"></script>
<link rel="stylesheet" href="../css/jNotify.jquery.css">
<link rel="stylesheet" href="../css/jquery.autocomplete.css" type="text/css" >
</link>
<link rel="stylesheet" href="../css/style.css"  type="text/css">
</link>
<style type="text/css">
input[type=text],textarea{
	width:100%
}
</style>
<script type="text/javascript">
$(document).ready(function(){	
$("#close").click(function(){
	window.close();
	if (window.opener != null && !window.opener.closed) {
            var txtName = window.opener.document.getElementById("jobcode");
            txtName.value = document.getElementById("compid").value;
        }	
						   


  });
  
  $("#new").click(function(){
						   
window.location='mastercmpedit.php';

  });
  
   $("#update").click(function(){
			$('#transperent').show();			   
$.post("master_cmp_crud.php?mode=update",$('#form_vehextra').serialize(),function(result){
	
		 jSuccess(result);
			$('#transperent').hide();		
	 });

  });
  
  $("#save").click(function(){
$('#transperent').show();						   
$.post("master_cmp_crud.php?mode=insert",$('#form_vehextra').serialize(),function(result){
	var str=result.split('###');
	 $('#ID').val(str[1]);
		 jSuccess(str[0]);
					
	 });$('#transperent').hide();

  });
});
</script>

</head>

<body>
<div id="transperent" >
</div>
<div class="main">

  <div class="page">
 <div>
      <?php 
	    
		
  include '../db_connect.php';
  
if(isset($_GET['ID'])){
	$id=$_GET['ID'];
	$querypart="where commst.id='$id'";
	}
	else{  
	$id=$_GET['compid'];
	$querypart="where commst.compid='$id'";}
if(($result = mysqli_query($con,"SELECT * FROM commst  $querypart"))&&(!empty($id)))
{
$row = mysqli_fetch_array($result);
}

?>

<form  id="form_vehextra" action=""  method=""  >
  <table  cellspacing="5"  style="border: 1px solid;padding: 5px;border-radius: 5px; width:99%"  >
  <tr>
    <td><table  cellspacing="5"  style="border: 1px solid;padding: 5px;border-radius: 5px; width:99%"  >
      <tr>
        <td width="15%" align="left"><span class="field_bc">COMPID</span></td>
        <td colspan="4" align="center"><input type="text" name="compid" id="compid"  /></td>
      </tr>
      <tr>
        <td align="left"> ADDRESS</td>
        <td colspan="4" rowspan="2"><textarea name="address" rows="3" id="address" ></textarea></td>
      </tr>
      <tr align="right">
        <td>&nbsp;</td>
      </tr>
      <tr>
        <td align="left">ADDRESS 1</td>
        <td colspan="4"><textarea name="address1" rows="3" id="address1" ></textarea></td>
      </tr>
      <tr>
        <td align="left">ADDRESS 2</td>
        <td colspan="4"><textarea name="address2" rows="3" id="address2" ></textarea></td>
      </tr>
      <tr>
        <td align="left">NAME</td>
        <td colspan="4"><input type="text" name="name" id="name"  /></td>
      </tr>
      
      <tr>
        <td align="left">CITY</td>
        <td width="31%" align="center"><input type="text" name="city" id="city"/></td>
        <td width="20%" align="left">PINCODE</td>
        <td colspan="2" align="center"><input type="text" name="pincode" id="pincode" /></td>
      </tr>
      <tr>
        <td align="left">CONT. PERSON</td>
        <td align="center" colspan="4"><input type="text" name="conper" id="conper" /></td>
        <td align="left" style="display:none">VAT</td>
        <td colspan="2" align="center" style="display:none"><input type="text" name="vat" id="vat" /></td>
      </tr>
       <tr>
        <td align="left">TELEPHONE</td>
        <td><input type="text" name="telephone" id="telephone"/></td>
        <td align="left">EMAIL</td>
        <td colspan="2"><input type="text" name="email" id="email" style="width:100%" class="nocaps"  /></td>
      </tr>
      <tr>
        <td align="left">GST OPTION</td>
        <td width="31%" align="center"><input type="text" name="incstax" id="incstax"/></td>
        <td width="20%" align="left">TAX</td>
        <td colspan="2" align="center"><input type="text" name="tax" id="tax" /></td>
      </tr>
      <tr>
        <td align="left">GSTIN</td>
        <td align="center"><input type="text" name="gstin" id="gstin"/></td>
        <td align="left">GST TYPE</td>
        <td colspan="2" align="center"><input type="text" name="gsttype" id="gsttype"/></td>
      </tr>
      <tr>
        <td align="left">STATE</td>
        <td><input type="text" name="state" id="state"/></td>
        <td align="left">STATE CODE</td>
        <td colspan="2"><input type="text" name="statecode" id="statecode"/></td>
      </tr>
      <tr>
        <td align="left">TIN NO</td>
        <td><input type="text" name="tin" id="tin" /></td>
        <td align="left">PAN NO</td>
        <td colspan="2"><input type="text" name="panno" id="panno" /></td>
      </tr>
      <tr>
        <td align="left">TYPE</td>
        <td>
        <input type="text" name="type" id="type" class="type" />
        <!--<select type="text" name="type" id="type" style="width:100%">
          <option value="CUSTOMER"> CUSTOMER</option>
          <option value="AGENT"> AGENT</option>
          <option value="TRANSPORT"> TRANSPORT</option>
          <option value="JOBBER"> JOBBER</option>
          <option value="DISTRIBUTOR"> DISTRIBUTOR</option>
        </select>-->
          <input type="hidden" name="ID" id="ID" readonly/></td>
        <td align="left">Rate Type</td>
        <td width="20%"><input type="text" name="rateonp" id="rateonp" class="rateonp"/></td>
        <td width="14%"><input type="text" name="rtvalue" id="rtvalue" class="rtvalue"/></td>
      </tr>
      <tr>
        <td align="left">Distributor</td>
        <td><input type="text" name="broker" id="broker" class="broker"/></td>
        <td colspan="3"><input type="text" name="brokername" id="brokername" class="brokername"/></td>
      </tr>
      <tr>
        <td align="left">Agent</td>
        <td><input type="text" name="agent" id="agent" class="agent"/></td>
        <td colspan="3"><input type="text" name="agentname" id="agentname" class="agentname"/></td>
      </tr>
      <tr>
        <td align="left">FORM TYPE</td>
        <td><input type="text" name="ftype" id="ftype" /></td>
        <td align="left">Ship Via</td>
        <td colspan="2"><input type="text" name="consignee" id="consignee" class="consignee"/></td>
      </tr>
      <tr>
        <td align="left">Discount</td>
        <td><input type="text" name="discount" id="discount" class="discount"/></td>
         <td align="left"></td>
        <td colspan="2"></td>
      </tr>
      <tr>
        <td align="left">&nbsp;</td>
        <td>&nbsp;</td>
        <td colspan="3"><input type="button" class="button" id="update" value="UPDATE" style="display:none" />
          <input type="button" class="button" id="save" value="SAVE" />
          <input type="button" class="button" id="new"  value="NEW" />
          <input type="button" class="button" id="close"  value="CLOSE" /></td>
      </tr>
    </table></td>
  </tr>
  </table>
</form>
 <div id="message" style="width:100%; text-align: center;font-weight: bold;color: #0064D1;"> </div>
    </div>


  </div>
  </div>
</div>
<script type="text/javascript">
$(document).ready(function(){
	
	
		
		
	
<?php if($id!='')
{?>
$('#save').hide();
$('#update').show();
$('#compid').prop('readonly',true);
$('#ID').val('<?php echo clean($con,$row['id']); ?>');
$('#compid').val('<?php echo clean($con,$row['compid']); ?>');
$('#name').val('<?php echo clean($con,$row['name']); ?>');
$('#address').val('<?php echo clean($con,$row['address']); ?>');
$('#address1').val('<?php echo clean($con,$row['address1']); ?>');
$('#address2').val('<?php echo clean($con,$row['address2']); ?>');
$('#city').val('<?php echo clean($con,$row['cmpcity']); ?>');
$('#pincode').val('<?php echo clean($con,$row['pincode']); ?>');
$('#incstax').val('<?php echo clean($con,$row['incstax']); ?>');
$('#inctoll').val('<?php echo clean($con,$row['inctoll']); ?>');
$('#telephone').val('<?php echo clean($con,$row['telephone']); ?>');
$('#email').val('<?php echo clean($con,$row['email']); ?>');
$('#conper').val('<?php echo clean($con,$row['conper']); ?>');
$('#vat').val('<?php echo clean($con,$row['vat']); ?>');
$('#rateonp').val('<?php echo clean($con,$row['rtmst']); ?>');
$('#tin').val('<?php echo clean($con,$row['tin']); ?>');
$('#panno').val('<?php echo clean($con,$row['panno']); ?>');
$('#type').val('<?php echo clean($con,$row['type']); ?>');
$('#broker').val('<?php echo clean($con,$row['broker']); ?>');
$('#tax').val('<?php echo clean($con,$row['tax']); ?>');
$('#ftype').val('<?php echo clean($con,$row['ftype']); ?>');

$('#gstin').val('<?php echo clean($con,$row['gstin']); ?>');
$('#gsttype').val('<?php echo clean($con,$row['gsttype']); ?>');
$('#state').val('<?php echo clean($con,$row['state']); ?>');
$('#statecode').val('<?php echo clean($con,$row['statecode']); ?>');

$('#consignee').val('<?php echo clean($con,$row['consignee']); ?>');
$('#agent').val('<?php echo clean($con,$row['agent']); ?>');

$('#rateonp').val('<?php echo clean($con,$row['rtmst']); ?>');
$('#rtvalue').val('<?php echo clean($con,$row['rtvalue']); ?>');
$('#discount').val('<?php echo clean($con,$row['discount']); ?>');
<?php }
else{?>
$('#type').val('<?php echo $_GET['type']; ?>');	
	
<?php 	}

?>

$("#type").autocomplete(
		 "comtype.php?",
	  {
  			delay:10,
  			minChars:1,
  			matchSubset:1,
  			matchContains:1,
  			cacheLength:10,
			mustMatch:1,
  			autoFill:false
  		});
		
		
		$(".rateonp").autocomplete(
		 "../attend_by_fill.php?mode=rateonp",
	  {
  			delay:10,
  			minChars:1,
  			matchSubset:1,
  			matchContains:1,
  			cacheLength:10,
			mustMatch:1,
			onItemSelect:function(row){
				if(row.data[0]!='undefined')
				$('#rtvalue').val(row.data[0]);			
				
								
			},
			showResult:function(row,data) {
    			return row+"|"+data[0];
  			},
  			autoFill:false
  		});
		
	
	});
	
	

	  $(window).load(function() {
    $('#transperent').hide();
	
	
	  });
	  

        
   
	  
</script>


</body>
</html>