<?php 
$active = 'Buy Fuel';
$pageName = 'expert help';

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

include('hitCounter.php');

$obj9 = new DBClass();
$obj = new DBClass();

if(isset($_POST['submit']) && $_POST['submit'] == 'Send'){

        $valid = validmess($_POST['commodity'], "Commodity"); if(isset($valid) && $valid != ''){ $error[] = $valid;}
        $valid = validmess($_POST['origin'], "Origin"); if(isset($valid) && $valid != ''){ $error[] = $valid;}
        $valid = validmess($_POST['gcv'], "Gross Calorifie Value"); if(isset($valid) && $valid != ''){ $error[] = $valid;}        
        $valid = validmess($_POST['supply_destination'], "Supply Destination"); if(isset($valid) && $valid != ''){ $error[] = $valid;}		
		$valid = checkName($_POST['name'], "Name"); if(isset($valid) && $valid != ''){ $error[] = $valid;}        
        $valid = validmess($_POST['contact'], "Mobile / Phone"); if(isset($valid) && $valid != ''){ $error[] = $valid;}
        $valid = checkEmail($_POST['email'], "Email Id"); if(isset($valid) && $valid != ''){ $error[] = $valid;}        
        $valid = validmess($_POST['address'], "Address"); if(isset($valid) && $valid != ''){ $error[] = $valid;}

		
     if(($_POST['port'] == 'other')) {            
          $valid = validmess($_POST['otherport'], "port"); if(isset($valid) && $valid != ''){ $mess[] = $valid;} 
          $port = $_POST['otherport'];
        }
        else {
          $port = $_POST['port'];
        }
        
     
     if(($_POST['commodity'] == 'other')) {            
          $valid = validmess($_POST['othercommudity'], "Commudity"); if(isset($valid) && $valid != ''){ $mess[] = $valid;} 
          $commodity = $_POST['othercommudity'];
        }
        else {
          $commodity = $_POST['commodity'];
        }
	 

	if($error == ''){
		
		if($_REQUEST['commodity'] =='Coal') {
			if($_REQUEST['origin'] =='Indian') {
				// COAL INDIAN
				$port = '';
				$_POST['noncoal_state'] = '';
				$_POST['noncoal_district'] = '';
				$_POST['noncoal_port'] = '';				
			}
			else {
				// COAL IMPORTED
				$_POST['area'] = '';
				$_POST['noncoal_state'] = '';
				$_POST['noncoal_district'] = '';
				$_POST['noncoal_port'] = '';
				$_POST['mines_name'] = '';
			}
		}
		else {
			if($_REQUEST['origin'] =='Indian') {
				// NON COAL INDIAN
				$_POST['area'] = '';
				$port = '';
				$_POST['noncoal_port'] = '';
				$_POST['mines_name'] = '';
			}
			else {
				// NON COAL IMPORTED
				$_POST['area'] = '';
				$port = '';
				$_POST['mines_name'] = '';
			}			
		}
        $sql5 = "INSERT INTO ".TBL_EXPERT." (name,organizaion,contact,address,email,commodity,origin,mines_name,area,port,noncoal_state,noncoal_district,noncoal_port,size, gcv,tm,ash,sulpher,supply_destination,comment) VALUES ('".trim($_POST['name'])."','".trim($_POST['organizaion'])."','".$_POST['contact']."','".trim($_POST['address'])."','".trim($_POST['email'])."','".trim($commodity)."','".trim($_POST['origin'])."','".trim($_POST['mines_name'])."','".trim($_POST['area'])."','".trim($port)."','".trim($_POST['noncoal_state'])."','".trim($_POST['noncoal_district'])."','".trim($_POST['noncoal_port'])."','".trim($_POST['size'])."','".trim($_POST['gcv'])."','".trim($_POST['tm'])."','".trim($_POST['ash'])."','".trim($_POST['sulpher'])."','".trim($_POST['supply_destination'])."','".trim($_POST['comment'])."') ";
    	
        $rs2 = $obj->executeQry($sql5,$link);
        
      	if($rs2){			
			// *********************** start  mail to admin *****************
			$to        	= 	'shrinetrainfotech@gmail.com';
			$subject	=	"Expert help require ".@$_POST['name'];
			$message	= 	"The Details are  :-               <br>".
			"--------------------------------------------------------------------------------<br>".
			"Name		: ".@$_POST['name']. "  		<br>".
			"Email Address 	: ".@$_POST['email']. "  	  <br>".		
			"Mobile / Phone		 	: ".@$_POST['contact']. "  	  <br>".		
			"Address		 	: ".@$_POST['address']. "  	  <br>".		
			"Organization 	: ".@$_POST['organizaion']. "  	  <br>".		
			"Message	: ".@$_POST['comment']. "  	<br>".
			"--------------------------------------------------------------------------------<br>";
			// To send HTML mail, the Content-type header must be set
			$headers  = 'MIME-Version: 1.0' . "\r\n";
			$headers .= 'Content-type: text/html; charset=iso-8859-1' . "\r\n";
			// Additional headers
			//$headers .= 'To: ' "\r\n";
			$headers .= 'From: '.$_POST['name'].'<'.$_POST['email'].'>' . "\r\n";
			@$sended=mail($to, $subject, $message, $headers);	
			
			@header('Location: expert.php?action=done');
			exit;
			
		}
	}
}

?>
<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>
<style>
#whitebox{width: 600px;margin:0;overflow: hidden;}
</style>
<!--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 style="margin-bottom: 0;">Easy Discusses</h2>
						
<iframe src="http://coalbazaar.com/forum/" style="width: 600px;height: 700px;border: none;" scrolling="no"></iframe>

						</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');?>