<link href="css/tender_project.css" rel="stylesheet" type="text/css" />
<?php
if($_REQUEST['save'])
{
	
	if($_REQUEST['sub_contractor_definition']['contractor_name']!='')
	{
		extract($_REQUEST['sub_contractor_definition']);
		
		if($s->RecordInsert('sub_contractor_definition',$_REQUEST['sub_contractor_definition']))
		{ 
			//print_r($_REQUEST['sub_contractor_definition']);die;
		
		}
				unset($_REQUEST['sub_contractor_definition']);	
				
				$_SESSION['success_msg']="Saved Successfully";	
				echo "<script>location.href='index.php?route=PMS/Maintenance/Contractor_Definition_index&modid=".$_REQUEST['modid']."&frmid=".$_REQUEST['frmid']."'</script>";

	}
	else
	{
		echo "<script>alert('Try Again');</script>";
	}

}


	if($_REQUEST['action']=='edit' && !empty($_REQUEST['scon']))
	{	
		$recEdit=DB_fetch_array($s->GetRecordById('sub_contractor_definition','id='.$_REQUEST['scon']));
		extract($recEdit);
		
	}

if(isset($_REQUEST['update']))
{
	 $s->RecordEdit('sub_contractor_definition',$_REQUEST['sub_contractor_definition'],"id=".$_REQUEST['scon']);
		$_SESSION['success_msg']="Update Successfully";
		
		echo "<script>location.href='index.php?route=PMS/Maintenance/Contractor_Definition_index&modid=".$_REQUEST['modid']."&frmid=".$_REQUEST['frmid']."'</script>";
}



?>
<style>
.label{
background-color: #B7B7B7;
    color: #000000;
    font-size: 10.5px;
    font-weight: bold !important;
    padding: 5px 10px;
    text-align: left;
}
</style>
<div class="tender_main_page">
<h1>Contractor Definition</h1>
<script>
	function generate_cont_code(str)
	{
	
	if (str=="")
	 {
	  document.getElementById("txtHint").innerHTML="";
	  return;
	}
	if (window.XMLHttpRequest)
    {// code for IE7+, Firefox, Chrome, Opera, Safari
	  xmlhttp=new XMLHttpRequest();
	}
	else
	{// code for IE6, IE5
	  xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
	}
	xmlhttp.onreadystatechange=function()
	 {
	  if (xmlhttp.readyState==4 && xmlhttp.status==200)
	  {
		document.getElementById("txtHint").innerHTML=xmlhttp.responseText;
	  }
	 }
	xmlhttp.open("GET","get_cont_code.php?q="+str,true);
	xmlhttp.send();
}

function showcity(str)
{
	
var xmlhttp;
if (window.XMLHttpRequest)
  {// code for IE7+, Firefox, Chrome, Opera, Safari
  xmlhttp=new XMLHttpRequest();
  }
else
  {// code for IE6, IE5
  xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
  }
xmlhttp.onreadystatechange=function()
  {
  if (xmlhttp.readyState==4 && xmlhttp.status==200)
    {
	document.getElementById("hid-Godown-div1").innerHTML=xmlhttp.responseText;
	
    }
	
  }
  var k=document.getElementById("state").value;
  xmlhttp.open("GET","getlocation.php?state="+str+"&country="+k,true);
	xmlhttp.send();

	
}
</script>

<form method="post" action="">
<table width="100%" border="1" cellspacing="0" cellpadding="3">
  <tr>
 
    <td width="22%" class="tabledata">Contractor  <font color="#FF0000" size="3"> * </font> </td>
    <td width="25%"><input type="text" name="sub_contractor_definition[contractor_name]" id="contractor" value="<?php echo $contractor_name;?>" size="30" onblur="generate_cont_code(this.value)" /></td>
    <td width="19%" class="tabledata">Short Name</td>
    <td width="34%"><input type="text" name="sub_contractor_definition[short_name]" id="short_name" value="<?php echo $short_name;?>" size="30" /></td>
  </tr>
  <tr>
    <td class="tabledata">Class <font color="#FF0000" size="3"> * </font></td>
    <td><select name="sub_contractor_definition[class]" id="class">
		<option value="">Select Class</option>
	</select>	</td>
    <td class="tabledata">User Code</td>
    <td><input type="text" name="sub_contractor_definition[user_code]" id="user_code" value="<?php echo $user_code;?>" size="30" /></td>
  </tr>
  <tr>
    <td class="tabledata">Credit Days</td>
    <td><input type="text" name="sub_contractor_definition[credit_days]" id="credit_days" value="<?php echo $credit_days;?>" size="30" /></td>
    <td class="tabledata">Bank</td>
    <td><input type="text" name="sub_contractor_definition[bank]" id="bank" value="<?php echo $bank;?>" size="30" /></td>
  </tr>
  <tr>
    <td class="tabledata">Ledger Advance</td>
    <td><select name="sub_contractor_definition[ledger_advance]" id="ledger_advance" >
		<option value="">Select Ledger Advance</option>
	</select>	</td>
    <td class="tabledata">Ledger Retention</td>
    <td><select name="sub_contractor_definition[ledger_retention]" id="ledger_retention" >
		<option value="">Ledger Retention</option>
	</select>	</td>
  </tr>
  <tr>
    <td class="tabledata">Bank Account No.</td>
    <td><input type="text" name="sub_contractor_definition[bank_account_no]" id="bank_account_no" value="<?php echo $bank_account_no;?>" size="30" /></td>
    <td class="tabledata">Ledger Payable</td>
    <td><select name="sub_contractor_definition[ledger_payable]" id="ledger_payable" >
		<option value="">Ledger Payable</option>
	</select>	</td>
  </tr>
  <tr>
    <td colspan="4">&nbsp;</td>
  </tr>
  <tr>
    <td colspan="4"><h3>Previous Exp Details</h3></td>
  </tr>
  <tr>
    <td class="tabledata">Remarks</td>
    <td colspan="6"><textarea name="sub_contractor_definition[remarks]" style="width:400; height:80;"><?php echo $remarks;?></textarea></td>
  </tr>
  <tr>
    <td class="tabledata">Contractor Code</td>
    <td>
		<div id="txtHint">
		  <input type="text" name="sub_contractor_definition[contractor_category]" id="contractor_category" value="<?php echo $contractor_category;?>" size="30" />
		</div>
	<!--<select name="sub_contractor_definition[contractor_category]" id="contractor_category">
		<option value="">Contractor Category</option>
		<?php
		$sqlcategory=DB_query("select * from tbl_subcontractor_contractor_category",$db);
		while($category_row=DB_fetch_array($sqlcategory))
		{
				$s='';
				if($contractor_category==$category_row['id'])
				$s="selected";
		?>
		 <option value="<?php echo $category_row['id'];?>" <?php echo $s;?>><?php echo $category_row['Contractor_category_name'];?></option>
		<?php } ?>
		</select>-->	</td>
    <td class="tabledata">Contact Person</td>
    <td><input type="text" name="sub_contractor_definition[contact_person]" id="contact_person" value="<?php echo $contact_person;?>" size="30" /></td>
  </tr>
   <tr>
      
    <td colspan="2" align="center"></td>
	<td colspan="2"><input type="checkbox" name="sub_contractor_definition[active]" id="active" /> Is Active</td>
  </tr>
   <tr>
    <td colspan="4"><h3>Address and Other Details</h3></td>
  </tr>
  <tr>
  
  
    <td width="22%" class="tabledata">State  <font color="#FF0000" size="3"> * </font> </td>
    <td width="25%"><select name="sub_contractor_definition[state]" id="state" onchange='showcity(this.value)'>
      <option value="">Select State</option>
      <?php
		$state_sql = "select * from state_master ";
   		$state_result = DB_query($state_sql,$db);
		while($state_row = DB_fetch_array($state_result))
   		{		
			$p = '';
			if($state_row['id']== $state)
			$p = 'selected';
		?>
      <option value="<?php echo $state_row['id']?>" <?php echo $p;?>><?php echo $state_row['state'] ?></option>
      <?php } ?>
    </select></td>
    <td width="19%" class="tabledata">Tin</td>
    <td width="34%"><input type="text" name="sub_contractor_definition[tin]" id="tin" value="<?php echo $tin;?>" size="30" /></td>
  </tr>
  <tr>
    <td class="tabledata">Location<font color="#FF0000" size="3"> * </font></td>
    <td>
	<div id="hid-Godown-div1">
	<select name="sub_contractor_definition[location]" id="location">
		<option value="">Select Location</option>
		<?php 
		$city_sql = "Select * from city_master";
   		$city_result = DB_query($city_sql,$db);
		$q = '';
		while($city_row = DB_fetch_array($city_result))
   		{
			if($city_row['id']== $location)
			$q = 'selected';
		?>
			<option value="<?php echo $city_row['id']?>" <?php echo $q;?>><?php echo $city_row['city'] ?></option>
		<?php }   
   		?> 
	</select>
	</div>	</td>
	<td class="tabledata">CST</td>
    <td><input type="text" name="sub_contractor_definition[cst]" id="cst" value="<?php echo $cst;?>" size="30" /></td>
  </tr>
  <tr>
    <td class="tabledata">Address <font color="#FF0000" size="3"> * </font></td>
    <td><textarea name="sub_contractor_definition[address]"><?php echo $address;?></textarea></td>
    <td class="tabledata">PAN <font color="#FF0000" size="3"> * </font></td>
    <td><input type="text" name="sub_contractor_definition[pan]" id="pan" value="<?php echo $pan;?>" size="30" /></td>
  </tr>
  <tr>
    <td class="tabledata">Email Id</td>
    <td><input type="text" name="sub_contractor_definition[email_id]" id="email_id" value="<?php echo $email_id;?>" size="30" /></td>
    <td class="tabledata">Office Mobile</td>
    <td><input type="text" name="sub_contractor_definition[office_mobile]" id="office_mobile" value="<?php echo $office_mobile;?>" size="30" /></td>
  </tr>
  <tr>
    <td class="tabledata">VAT / TIN</td>
    <td><input type="text" name="sub_contractor_definition[vat_tin]" id="vat_tin" value="<?php echo $vat_tin;?>" size="30" /></td>
    <td class="tabledata">Service Tax No.</td>
    <td><input type="text" name="sub_contractor_definition[service_tax_no]" id="service_tax_no" value="<?php echo $service_tax_no;?>" size="30" />	</td>
  </tr>
  <tr>
    <td class="tabledata">Fax</td>
    <td><input type="text" name="sub_contractor_definition[fax]" id="fax" value="<?php echo $fax;?>" size="30" /></td>
    <td class="tabledata">TDS Account No.</td>
    <td><input type="text" name="sub_contractor_definition[tds_account_no]" id="tds_account_no" value="<?php echo $tds_account_no;?>" size="30" />	</td>
  </tr>

  <tr><td>&nbsp;</td><td colspan="3" align="center"><input type="submit" value="Save" name="<?php if($_REQUEST['action']=='edit') echo 'update'; else echo 'save'; ?>" class="add">
  
  <input type="reset" name="cancel" value="Reset" /><a href="index.php?route=PMS/Maintenance/Contractor_Definition_index&modid=<?php echo $_REQUEST['modid'];?>&frmid=<?php echo $_REQUEST['frmid'];?>">
  
  <input type="button" name="back" value="Cancel" /></a></td></tr>
</table>
</form>
</div>