<?php 
$active = 'Related Services';
$pageName = 'Liasoning';

require_once('config/config.php');
require_once(CLASS_DIR.'dbClass.php');
require_once(INCLUDES_DIR.'header.php');

include('hitCounter.php');

$obj = new DBClass();
$obj1 = new DBClass();
?>
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.4.2/jquery.min.js"></script>
<script src="JqueryLoader.js" type="text/javascript"></script>
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/mootools/1.2.5/mootools-yui-compressed.js"></script>
<script type="text/javascript" src="citySelection.js"></script>
<script type="text/javascript">
function changeOrigin(val) {
	if(val=='Indian') {
		document.getElementById('area').style.display='';
		document.getElementById('area2').style.display='';
		document.getElementById('port').style.display='none';
	}
	else {
		document.getElementById('area').style.display='none';
		document.getElementById('area2').style.display='none';
		document.getElementById('port').style.display='';
	}
}

</script>


<!--workarea start------------------------->
<div class="workarea">
	<div class="workareatop">
		<img src="images/workareatopcorner_03.PNG" alt="" />
	</div>
	<!--workareamid start--------------------->
	<div class="workareamid">
		<div id="floatleft" style="width:590px; float:left;">
			<div class="welcomediv">

                        <h2>Liasoning & Lifting</h2>

<div id="preloader" style="margin-top:35px; margin-left:160px"><img src="ajax_loader.gif" style="border:none;"/></div>	

<form action="" method="post">
	<table border="0" cellspacing="0" cellpadding="0">
			<tr>
					<td colspan="3"><div class="err_msg"><?php ShowError($error); ShowInfo($info);?></div></td>
			</tr>
			<tr>
					<td>
							<select name="origin" class="txt_box2" style="width:160px;" onchange="changeOrigin(this.value)">
								<option value="">--Select Origin--</option>
								<option value="Indian">Indian</option>
								<option value="Imported">Imported</option>					
							</select>
					</td>
					<!-- For Indian -->
					<td id="area" <?php if($_POST['origin'] == 'Imported'){ ?> style="display:none;"<?php } ?>>
							<select name="area" id="area" class="txt_box2" style="width:165px;" >
									<option value="">--Select Area/Mines--</option>
									<?php 
									$sql2 = "SELECT DISTINCT(area) as area FROM ".TBL_LIASONING." where `area`!='' order by area ASC";
									$rs2 = $obj1->executeQry($sql2,$link);
									while($row2 = $obj1->fetchrow()){ 
									?>          
									<option value="<?php echo $row2['area'];?>" <?php if($_POST['area'] == $row2['area']) echo 'selected'; ?>><?php echo $row2['area'];?></option>
									<?php } ?>
							</select>
					</td>
					<td id="area2" <?php if($_POST['origin'] == 'Imported'){ ?> style="display:none;"<?php } ?>>
							<select id="sub_area" name="sub_area" class="txt_box2" style="width:165px;">
									<option value="">--Select Sub Area--</option>
							</select>
					</td>
					<!-- For Imported -->
					<td id="port" <?php if(($_POST['origin'] != 'Imported') || ($_POST['origin'] == '')) { ?> style="display:none;"<?php } ?>>
							<select name="mines" class="txt_box2" style="width:140px;">
									<option value="">--Select Ports--</option>
									<?php
									$sql2 = "SELECT DISTINCT(mines) as mines FROM ".TBL_LIASONING." where `mines`!='' order by mines ASC";
									$rs2 = $obj1->executeQry($sql2,$link);
									while($row2 = $obj1->fetchrow()){ 
									?>
									<option value="<?php echo $row2['mines'];?>" <?php if($_POST['mines'] == $row2['mines']) echo 'selected'; ?>><?php echo $row2['mines'];?></option>
									<?php } ?>

							</select>
					</td>
					<td width="70" align="right"><input type="submit" name="submit" class="login_btn" style="width:55px;height: 22px;" value="Find"/></td>
			</tr>
	</table>
</form>      
<br /><br />
<?php 
if(isset($_POST['submit']) && $_POST['submit'] == 'Find'){
	if(isset($_POST['origin']) && $_POST['origin'] == 'Imported'){
		$valid = validmess($_POST['mines'], "mines"); if(isset($valid) && $valid != ''){ $error[] = $valid;}
	}
	else{	
		$valid = validmess($_POST['area'], "Area/Mines"); if(isset($valid) && $valid != ''){ $error[] = $valid;}	
		$valid = validmess($_POST['sub_area'], "Sub Area"); if(isset($valid) && $valid != ''){ $error[] = $valid;} 	
	}
	if($error != ''){ ?>
	<div class="err_msg"><?php ShowError($error); ShowInfo($info);?></div>
	<?php  } else {
	if(isset($_POST['submit'])) {
		$con = "";			
		if($_POST['origin']!='') {
			$con = " AND origin = '".$_POST['origin']."' ";	
		}
		
		if($_POST['area']!='') {
			$con .= " AND area = '".$_POST['area']."' ";	
		}
		
		if($_POST['sub_area']!='') {
			$con .= " AND sub_area = '".$_POST['sub_area']."' ";	
		}
		
		if($_POST['mines']!='') {
			$con .= " AND mines = '".$_POST['mines']."' ";	
		}	

	$sql = "SELECT * FROM ".TBL_LIASONING." WHERE status = '0' $con limit 0,4";
	$rs = $obj->executeQry($sql,$link);
	$i=1;
	} ?>
	<table class="main" width="100%" border="0" cellspacing="0" cellpadding="0">
		<tr>
		     <td class="bdr1">
        		<table width="100%"  border="0" cellspacing="0" cellpadding="0">
					<?php if($i==1) { ?>
					<tr>
					  <td bgcolor="#990066" colspan="2" class="form_head" style="padding-left:5px;font-size: small;font-family: Tahoma;color:#000000;"><b>Liasoner and Lifter</b></td>
					</tr>
					<?php } if($obj->getrow()>0) { 	?>
					<tr class="bg_td1">
						<?php	while($row = $obj->fetchrow()) { ?>
						<td class="list_link" width="49%" align="left" valign="top" style="margin:5px;padding:5px;">
								<table>	
									<tr>
										<td colspan="2"  style="text-align: left;font-size: small;font-family: Tahoma;color:#000000;"><?php echo $row['person_name'].' ('.$row['organisation_name'].')';?></td>
									</tr>
									<tr>
										<td style="font-size: x-small;font-family: Tahoma;color:#000000;" valign="top"><b>Address</b></td>
										<td style="font-size: x-small;font-family: Tahoma;color:#000000;"><?php echo $row['address'];?>, <?php echo $row['district'];?>, <?php echo $row['state'];?> - <?php echo $row['pincode'];?></td>
									</tr>
									<tr>
										<td style="font-size: x-small;font-family: Tahoma;color:#000000;"><b>Phone</b></td>
										<td style="font-size: x-small;font-family: Tahoma;color:#000000;"><?php echo $row['phone'];?></td>
									</tr>
									<tr>
										<td style="font-size: x-small;font-family: Tahoma;color:#000000;"><b>Fax</b></td>
										<td style="font-size: x-small;font-family: Tahoma;color:#000000;"><?php echo $row['fax'];?></td>
									</tr>
									<tr>
										<td style="font-size: x-small;font-family: Tahoma;color:#000000;"><b>Mobile</b></td>
										<td style="font-size: x-small;font-family: Tahoma;color:#000000;"><?php echo $row['mobile1'];?>, <?php echo $row['mobile2'];?></td>
									</tr>
									<tr>
										<td style="font-size: x-small;font-family: Tahoma;color:#000000;"><b>Email</b></td>
										<td style="font-size: x-small;font-family: Tahoma;color:#000000;"><?php echo $row['email1'];?>, <?php echo $row['email2'];?></td>
									</tr>
									<tr>
										<td style="font-size: x-small;font-family: Tahoma;color:#000000;"><b>Website</b></td>
										<td style="font-size: x-small;font-family: Tahoma;color:#000000;"><?php echo $row['website'];?></td>
									</tr>
								</table>
						</td>
							<?php 	if($i%2==0) {
								echo '</tr><tr>';	
							} 
							$i++;
							} ?>
					</tr>
					<?php } else { ?>
					<tr>
							<td colspan="2" align="center" style="padding-left:5px;color:#D40000;">No Record found!</td>
					</tr>
					<?php  }?>
				</table>
			</td>
		</tr>
	</table>
	<table>							
		<tr>
			<td height="10" style="border:none"></td>
		</tr>
	</table>	
<?php } }?>
                   


						</div>
				</div>
				<?php require_once(INCLUDES_DIR.'left_bar.php');?>
                <!--floatright close-------------------->
                <div style="clear:both;"></div>
            </div>
            <!--workareamid close--------------------->
            <div class="workareabottom">
                <img src="images/workareabottomcorner_03.PNG" alt="" />
            </div>
        </div>
    <!--workarea close------------------------->
<?php require_once(INCLUDES_DIR.'footer.php');?>