<?php 
$pageName = 'Coal Jobs';

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

include('hitCounter.php');

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

$memberID = ($_SESSION['memberID']=='')?$_COOKIE['memberID']:$_SESSION['memberID'];

if(isset($_POST['submit']) && $_POST['submit'] == 'Post Profile'){
	
		$valid = validmess($_POST['functional'], "Functional Area"); if(isset($valid) && $valid != ''){ $error1[] = $valid;}		
		$valid = validmess($_POST['designation'], "Designation"); if(isset($valid) && $valid != ''){ $error1[] = $valid;}		
		$valid = validmess($_POST['organization'], "Current Organization"); if(isset($valid) && $valid != ''){ $error1[] = $valid;}		
		$valid = validmess($_POST['keyskills'], "Key Skills"); if(isset($valid) && $valid != ''){ $error1[] = $valid;}		
		$valid = validmess($_POST['exyear'], "Experince Year"); if(isset($valid) && $valid != ''){ $error1[] = $valid;}			
		$valid = validmess($_POST['exmonth'], "Experince Month"); if(isset($valid) && $valid != ''){ $error1[] = $valid;}		
		$valid = validmess($_POST['name'], "Full Name"); if(isset($valid) && $valid != ''){ $error1[] = $valid;}		
		$valid = validmess($_POST['mobile'], "Mobile Number"); if(isset($valid) && $valid != ''){ $error1[] = $valid;}		
		$valid = checkEmail($_POST['mailid'], "Email"); if(isset($valid) && $valid != ''){ $error1[] = $valid;}
		
		$designation = ChangeFormat($_POST['designation']);
		$organization = ChangeFormat($_POST['organization']);
		$name = ChangeFormat($_POST['name']);
		
		if($_FILES['resume_upload']['name'] != '') {
			$fileName = $_FILES['resume_upload']['name'];
			$fileType = $_FILES['resume_upload']['type'];
			$file_info = pathinfo($_FILES['resume_upload']['name']);
			$random_digit=rand(00,99);
			$extension = $file_info['extension'];
			$newFileName = strtolower($_POST['name'])."_resume".$random_digit.".".$extension;
			$path = RESUME_DIR.$newFileName;
		}
		
		$sql9 = "SELECT * FROM ".TBL_JOBSEEKER;
		$rs9 = $obj9->executeQry($sql9,$link);
		while($row9 = $obj9->fetchrow()) {
			if($newFileName == $row9['File_Name'] ) { $error[] = "File already exist";}
		}
		
		if($error1 == ''){
			
			if($_REQUEST['exmonth'] == '1'){
				$month = " Month";
			}
			else {
				$month = " Months";
			}
			
			if($_REQUEST['exyear'] == '1'){
				$year = " Year";
			}
			else {
				$year = " Years";
			}
						
			if($_REQUEST['exmonth'] == '0'){			
				$experince = $_REQUEST['exyear']." years";
			}
			else {
			$experince = $_REQUEST['exyear'].$year." and ".$_REQUEST['exmonth'].$month;
			}
		
			move_uploaded_file($_FILES["resume_upload"]["tmp_name"], $path);
			
			$sqll = "INSERT INTO ".TBL_JOBSEEKER." (functional,designation,organization,keyskills,experince,resume,File_Name,File_Type,File_Extension,name,mobile,mailid,date) VALUES ('".trim($_POST['functional'])."','".trim($designation)."','".trim($organization)."','".trim($_POST['keyskills'])."','".trim($experince)."','".trim($_POST['resume'])."','".trim($newFileName)."','".trim($fileType)."','".trim($file_info['extension'])."','".trim($name)."','".trim($_POST['mobile'])."','".trim($_POST['mailid'])."','".date("Y-m-d")."')";
			$rs2 = $obj->executeQry($sqll,$link);	
			if($rs2){
				 @header('Location: coaljobs.php?action=done');
			     exit;
			}
		}
}

if(isset($_POST['submit']) && $_POST['submit'] == 'Post Requirment'){
	
	$obj8 = new DBClass();
	$sql8 = "SELECT * FROM ".TBL_USER." WHERE id = '".$memberID."'";
	$rs8 = $obj8->executeQry($sql8,$link);
	$rownum8 = $obj8->getRow();
	if($rownum8 < 1){
		@header('Location: members.php?msg=logerror');
	} else{

			$valid = validmess($_POST['company_name'], "Comapny Name"); if(isset($valid) && $valid != ''){ $error[] = $valid;}		
			$valid = validmess($_POST['designation'], "Designation"); if(isset($valid) && $valid != ''){ $error[] = $valid;}		
			$valid = validmess($_POST['description'], "Description"); if(isset($valid) && $valid != ''){ $error[] = $valid;}		
			$valid = validmess($_POST['keyskills'], "Key Skills"); if(isset($valid) && $valid != ''){ $error[] = $valid;}		
			$valid = validmess($_POST['ey'], "Experince Year"); if(isset($valid) && $valid != ''){ $error[] = $valid;}			
			$valid = validmess($_POST['em'], "Experince Month"); if(isset($valid) && $valid != ''){ $error[] = $valid;}		
			$valid = validmess($_POST['name'], "Contact Person Name"); if(isset($valid) && $valid != ''){ $error[] = $valid;}		
			$valid = checkEmail($_POST['mailid'], "Email"); if(isset($valid) && $valid != ''){ $error[] = $valid;}
			$valid = validmess($_POST['website'], "Web Site"); if(isset($valid) && $valid != ''){ $error[] = $valid;}
			
			$company_name = ChangeFormat($_POST['company_name']);
			$designation = ChangeFormat($_POST['designation']);
			$description = ChangeFormat($_POST['description']);
			$name = ChangeFormat($_POST['name']);
		
			if($error == ''){				
					if($_REQUEST['em'] == '1'){
						$month = " Month";
					}
					else {
						$month = " Months";
					}
					
					if($_REQUEST['ey'] == '1'){
						$year = " Year";
					}
					else {
						$year = " Years";
					}
								
					if($_REQUEST['em'] == '0'){			
						$experince = $_REQUEST['ey'].$year;
					}
					else {			
						$experince = $_REQUEST['ey'].$year." and ".$_REQUEST['em'].$month;
					}
					
					$sqll = "INSERT INTO ".TBL_JOBS." (company_name,designation,description,keyskills,experince,name,mobile,mailid,date,website) VALUES ('".trim($company_name)."','".trim($designation)."','".trim($description)."','".trim($_POST['keyskills'])."','".trim($experince)."','".trim($name)."','".trim($_POST['mobile'])."','".trim($_POST['mailid'])."','".date("Y-m-d")."','".trim($_POST['website'])."') ";
					$rs2 = $obj->executeQry($sqll,$link);	
					if($rs2){
						@header('Location: coaljobs.php?action=done');
						 exit;
					}
			}				
	}
}
?>
<style type="text/css">
<!--
.style8 {
	font-family: "Times New Roman", Times, serif; 
	color: #000000; 
	font-size: 18px;
}

.style54 {
	font-family: "Times New Roman", Times, serif;
	font-size: 14px;
	color: #0000FF;
}
-->
</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>Coal Jobs</h2>
						<?php 
						if(isset($_REQUEST['action']) || ($_REQUEST['action'] == 'done')) {
						echo '<b class="style8">Your request submitted successfully</b>';
						} ?>
						<br /><br />
<table width="580" align="center"> 
	
	<tr>
		<td width="285" style="border:solid;border-width:1px;border-color:gray;" valign="top">
			<table cellpadding="2" cellspacing="2" width="280">
				<tr height="45">
					<td colspan="2" class="style8">For Employees</td>
				</tr>
				<tr height="40">
					<td colspan="2">
						<table cellpadding="0" cellspacing="0">
							<tr>
								<td class="style8" valign="middle">Current Opening</td>
								<td ><a href="opening.php" title="Current pening"><img src="images/click.PNG" height="30" width="100" style="border:none;margin-left:10px;"/></a></td>
							</tr>
						</table>
					</td>
				</tr>
				
				<tr>
					<td colspan="2"><div class="err_msg" style="margin-left:10px;"><?php ShowError($error1); ShowInfo($info);?></div></td>
				</tr>
				<tr>
					<td colspan="2" class="style8">Want to post your resume??</td>
				</tr>				
				<tr>
					<td colspan="2"><hr width="260" align="left"/></td>
				</tr>
				<tr height="30">
					<td colspan="2"><strong>Profile</strong></td>
				</tr>
				<form name="employee" action="" method="post" enctype="multipart/form-data">
				<input type="hidden" name="MAX_FILE_SIZE" value="1000000">
				<tr height="30">
					<td class="formtxt" style="width:105px;">Functional Area*</td>
					<td><select name="functional" class="txt_box2" style="width:137px;">
							<option value="">Select</option>
							<?php 

									$obj1 = new DBClass();
									
									$sql2 = "SELECT * FROM ".TBL_OPTIONS." where `option`='functionality' and `value`!='' and `status`=0 ORDER BY value ASC";
									
									$rs2 = $obj1->executeQry($sql2,$link);
									
									while($row2 = $obj1->fetchrow()){ 

							?>          

						<option value="<?php echo $row2['value'];?>" <?php if($_POST['functional'] == $row2['value']) echo 'selected'; ?>><?php echo $row2['value'];?></option>

<?php } ?>	
								</select>
					</td>
				</tr>
				<tr height="30">
					<td class="formtxt" style="width:105px;">Designation*</td>
					<td><input type="text" class="txt_box2" name="designation" id="designation" style="width:135px;"/></td>
				</tr>
				<tr height="30">
							<td class="formtxt" style="width:105px;">Organization*</td>
							<td><input type="text" class="txt_box2" name="organization" id="organization" style="width:135px;"/></td>
						</tr>
						<tr height="30">
							<td class="formtxt" style="width:105px;">Key Skills*</td>
							<td><textarea class="txt_box2" name="keyskills" id="keyskills" style="width:135px;"></textarea></td>
						</tr>
						<tr height="30">
							<td class="formtxt" style="width:105px;">Experience*</td>
							<td><select name="exyear" class="txt_box2" style="width:60px;">
								<option value="">Year</option>
    								<?php for($i=01;$i<100;$i++){ ?>
    					<option value="<?php echo $i; ?>"><?php echo $i; ?></option>
    				<?php } ?>
    							</select><select name="exmonth" class="txt_box2" style="width:65px;">
								<option value="">Month</option>
    								<?php for($i=0;$i<12;$i++){ ?>
    					<option value="<?php echo $i; ?>"><?php echo $i; ?></option>
    				<?php } ?>
    							</select></td>
						</tr>
						<tr height="30">
							<td class="formtxt" style="width:105px;">Paste resume</td>
							<td><textarea name="resume" id="resume" class="txt_box2" style="width:135px;"></textarea></td>
						</tr>
						<tr><td colspan="2" align="center">Or</tr>
						<tr height="30">
							<td colspan="2">Resume
							<input type="file" name="resume_upload" id="resume_upload" device="files" accept="text/*" style="width:50px;"/></td>
						</tr>
						<tr height="30">
							<td colspan="2"><strong>Contact Details</strong></td>
						</tr>
						<tr height="30">
							<td class="formtxt" style="width:105px;">Full name*</td>
							<td><input type="text" class="txt_box2" name="name" id="name" style="width:135px;"/></td>
						</tr>
						<tr height="30">
							<td class="formtxt" style="width:105px;">Mobile No.*</td>
							<td><input type="text" class="txt_box2" name="mobile" id="mobile" style="width:135px;"/></td>
						</tr>
						<tr height="30">
							<td class="formtxt" style="width:105px;">Mail id*</td>
							<td><input type="text" class="txt_box2" name="mailid" id="mailid" style="width:135px;"/></td>
						</tr>
						<tr height="60">
							<td colspan="2" align="right"><input type="submit" name="submit" class="login_btn" value="Post Profile" style="width:140px;height:40px;margin-right:8px;"/></td>
						</tr>
				</form>
			</table>
		</td>
		<td width="9">&nbsp;</td>
		
		<td width="285" style="border:solid;border-width:1px;border-color:gray;" valign="top">
			<table cellpadding="2" cellspacing="2" width="280">
				<tr height="45">
					<td class="style8">For Employer</td>
					<td align="right"><span class="style54">Please login first</span></td>
				</tr>
				<tr height="40">
					<td colspan="2">
						<table cellpadding="0" cellspacing="0">
							<tr>
								<td class="style8" valign="middle">Employees Database</td>
								<td ><a href="<?php if(isset($memberID) || ($memberID != '')) { ?>employee.php<?php } else { ?>members.php?msg=logerror&from=coaljobs<?php } ?>" title="Current pening"><img src="images/click.PNG" height="30" width="100" style="border:none;margin-left:10px;"/></a></td>
							</tr>
						</table>
					</td>
				</tr>
				<tr>
					<td colspan="2"><div class="err_msg" style="margin-left:10px;"><?php ShowError($error); ShowInfo($info);?></div></td>
				</tr>
				<tr>
					<td colspan="2" class="style8">Want to post your Requirements??</td>
				</tr>
				<tr>
					<td colspan="2"><hr width="260" align="left"/></td>
				</tr>
				<tr height="30">
					<td colspan="2"><strong>Job Details</strong></td>
				</tr>
				<form method="post" action="">
				<tr height="30">
					<td class="formtxt" style="width:105px;">Company Name*</td>
					<td><input type="text" class="txt_box2" name="company_name" id="company_name" style="width:135px;"/></td>
				</tr>
				<tr height="30">
					<td class="formtxt" style="width:105px;">Designation*</td>
					<td><input type="text" class="txt_box2" name="designation" id="designation" style="width:135px;"/></td>
				</tr>
				<tr height="30">
					<td class="formtxt" style="width:105px;">Description*</td>
					<td><textarea name="description" id="description" class="txt_box2" style="width:135px;"></textarea></td>
				</tr>
				<tr height="30">
					<td class="formtxt" style="width:105px;">Key Skills*</td>
					<td><textarea class="txt_box2" name="keyskills" id="keyskills" style="width:135px;"></textarea></td>
				</tr>
				<tr height="30">
					<td class="formtxt" style="width:105px;">Experience*</td>
					<td><select name="ey" class="txt_box2" style="width:60px;">
								<option value="">Year</option>
    								<?php for($i=01;$i<100;$i++){ ?>
    					<option value="<?php echo $i; ?>"><?php echo $i; ?></option>
    				<?php } ?>
    							</select><select name="em" class="txt_box2" style="width:65px;">
								<option value="">Month</option>
    								<?php for($i=0;$i<12;$i++){ ?>
    					<option value="<?php echo $i; ?>"><?php echo $i; ?></option>
    				<?php } ?>
    				</select></td>
				</tr>
				<tr height="30">
					<td colspan="2"><strong>Contact Details</strong></td>
				</tr>
				<tr height="30">
					<td class="formtxt" style="width:105px;">Contact Person*</td>
					<td><input type="text" class="txt_box2" name="name" id="name" style="width:135px;"/></td>
				</tr>
				<tr height="30">
					<td class="formtxt" style="width:105px;">Mobile No.*</td>
					<td><input type="text" class="txt_box2" name="mobile" id="mobile" style="width:135px;"/></td>
				</tr>
				<tr height="30">
					<td class="formtxt" style="width:105px;">Mail Id*</td>
					<td><input type="text" class="txt_box2" name="mailid" id="mailid" style="width:135px;"/></td>
				</tr>
				<tr height="30">
					<td class="formtxt" style="width:105px;">Web Site*</td>
					<td><input type="text" class="txt_box2" name="website" id="website" style="width:135px;"/></td>
				</tr>
				<tr height="50">
					<td colspan="2" align="right"><input type="submit" name="submit" class="login_btn" value="Post Requirment" style="width:140px;height:40px;margin-right:8px;"/></td>
				</tr>
				</form>
			</table>
		</td>
	</tr>

 						  
</table> <!-- /Main Table -->



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