<?php
if($_REQUEST['Save']!='')
{
	$insert1="Insert into party_form_master set
					 site='".$_REQUEST['site']."',     
					 party='".$_REQUEST['party']."',  
					 formNo='".$_REQUEST['formNo']."',  
					 formDate='".FormatDateForSQL($_REQUEST['formDate'])."',  
					 createdDate='".date('Y-m-d')."',  
					 createdBy='".$_SESSION['UserID']."'   ";
	$result1=DB_query($insert1,$db);	
	
prnMsg( _('Record Inserted Successfully'),'success');
echo "<script>location.href='index.php?route=party_form_receive&modid=".$_REQUEST['modid']."&frmid=".$_REQUEST['frmid']."'</script>";	
}
?>
<p>
<h2 align="center">Enquiry Register</h2></p>
<form action="" method="post">

<table width="65%"><tr><td bgcolor="#CCCCCC">
<table width="100%" border="0"><tr><td bgcolor="#FFFFFF">
<table width="100%" border="0" cellspacing="1" cellpadding="0" align="center">
  <tr>
  	<th width="17%">Branch</th>
  	<td ><select name="site" id="site" style="width: 100%" onchange="getDispatch(this.value)">
  		<option value="0">Select</option>
  		<?php 
  		$site_sql=DB_query("Select loccode, locationname from locations",$db);
		while($site_row=DB_fetch_array($site_sql))
		{?>
		<option value="<?php echo $site_row['loccode']?>"<?php echo($_REQUEST['site']==$site_row['loccode']?'selected':'')?>><?php echo $site_row['locationname']?></option>
		<?php 	
		}
  		?>
  	</select></td>
    <th width="21%" nowrap="nowrap" scope="row">Form Date</th>
    <td width="24%" nowrap="nowrap"><input name="formDate" id="formDate" type="text" value="<?php echo date('d/m/Y');?>" class="datepicker" style="width:100%;" /></td>
    
  </tr>
  <tr>
    <th>Party </th>
    <td><select name="party"  style="width:100%;">
      <option value="0">---Select---</option>
      <?php 
	$vendor_sql=DB_query("select id,client_code,c_name from clientmaster",$db);
	while($vendor=DB_fetch_array($vendor_sql))
	{
	?>
      <option value="<?php echo $vendor['id'];?>"<?php echo ($_REQUEST['party']==$vendor['client_code']?'selected':'')?>><?php echo $vendor['c_name'];?></option>
      <?php } ?>
    </select></td>
    <th width="26%"><strong>Form/Permit No.</strong></th>
    <td width="29%"><input name="formNo" type="text" value="<?php echo $_REQUEST['formNo'];?>" size="12" style="width:100%;"/></td>
  </tr>
</table>
</td></tr></table></td></tr></table>


<p align="center"><input type="submit" name="Save" value="Save" /></p>
</form>

<table width="70%" cellpadding="1" cellspacing="1">
	<tr>
		<th>Branch</th>
		<th>Party</th>
		<th>Form No.</th>
		<th>Form Date</th>
	</tr>
	<?php 
	$sql=DB_query("Select * from party_form_master",$db);
	while($myrow=DB_fetch_array($sql))
	{?>
		<tr bgcolor="#FFFFFF">
		<td><?php 
		echo $s->getField('locations','loccode',$myrow['site'],'locationname');?></td>
		<td><?php 
		echo $s->getField('clientmaster','id',$myrow['party'],'c_name');?></td>
		<td><?php echo $myrow['formNo'];?></td>
		<td><?php echo $myrow['formDate'];?></td>
		</tr>
	<?php 	
	}
	?>
</table>
