<?php
require_once('../config/config.php');
require_once(CLASS_DIR.'dbClass.php');
$obj = new DBClass();
$dat = date('Y-m-d');
$headin = 'Add Jobs';
$buton = 'Add Jobs';
$cpage = basename($_SERVER['PHP_SELF']).'?'.$_SERVER['QUERY_STRING'];
$sql1 = "SELECT * FROM ".jobs;
$rs1 = $obj->executeQry($sql1,$link);
$row1 = $obj->fetchrow();	 
$cupage = 'jobs';

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

		$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;}
 
	if($error == ''){
		if($_POST['submit'] == 'Post Requirment'){
			
			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 jobs (company_name,designation,description,keyskills,experince,name,mobile,mailid,date,website) VALUES ('".trim($_POST['company_name'])."','".trim($_POST['designation'])."','".trim($_POST['description'])."','".trim($_POST['keyskills'])."','".trim($experince)."','".trim($_POST['name'])."','".trim($_POST['mobile'])."','".trim($_POST['mailid'])."','".date("Y-m-d")."','".trim($_POST['website'])."') ";
		
			$rs2 = $obj->executeQry($sqll,$link);	
          
			if($rs2){
			
				 @header('Location: jobs.php?action=add');
			     exit;
			    }
                else{ 
			     @header('Location: jobs.php?action=error');   
				exit;
               }
			}
	}	
		
}

require_once(INCLUDES_DIR.ADMHEADER); 
include_once(ABS_ROOT_PATH."fckeditor/fckeditor.php") ;
?>
<link href="<?=EDITOR_DIR;?>sample.css" rel="stylesheet" type="text/css" />
<table border="0" cellspacing="0" cellpadding="0">
  <tr>
    <td height="29" align="center" class="submenu"><a href="jobs.php">Manage Jobs</a></td>
    <td align="center" class="submenu">Add Jobs</td>
  </tr>
</table>
<table width="1000" border="0" cellspacing="0" cellpadding="0">
  <tr>
    <td height="17"></td>
  </tr>
  <tr>
    <td>
		<table width="910" border="0" align="center" cellpadding="0" cellspacing="0">
      		<tr>
        		<td class="pagehead">
					<table width="900" border="0" cellspacing="0" cellpadding="0">
			         	 <tr>
            				<td width="315" height="35"><?php echo $headin;?></td>
           			 	 </tr>
					</table>
				</td>
		   </tr>
     	   <tr>
        		<td valign="top" bgcolor="#FFFFFF" class="innermain">
					<table width="800" border="0" align="center" cellpadding="0" cellspacing="0">
          				<tr>
            				<td height="25"><?php ShowError($error); ShowInfo($info);?></td>
          				</tr>

						<tr>
            				<td valign="top" class="bdr4">
								<table width="800" border="0" cellspacing="0" cellpadding="0">
									 <tr>
										<td bgcolor="#990066" class="form_head">Job Details</td>
									 </tr>
            						  <tr>
                						<td valign="top" class="form_bg">
											<table width="500" border="0" cellpadding="0" cellspacing="0" class="form_txt1">
												<form method="post" action="">
				<tr height="30">
					<td >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>Designation*</td>
					<td><input type="text" class="txt_box2" name="designation" id="designation" style="width:135px;"/></td>
				</tr>
				<tr height="30">
					<td>Description*</td>
					<td><textarea name="description" id="description" class="txt_box2" style="width:135px;"></textarea></td>
				</tr>
				<tr height="30">
					<td>Key Skills*</td>
					<td><textarea class="txt_box2" name="keyskills" id="keyskills" style="width:135px;"></textarea></td>
				</tr>
				<tr height="30">
					<td >Experince*</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>&nbsp;&nbsp;&nbsp;<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>Contact Person*</td>
					<td><input type="text" class="txt_box2" name="name" id="name" style="width:135px;"/></td>
				</tr>
				<tr height="30">
					<td >Mobile No.*</td>
					<td><input type="text" class="txt_box2" name="mobile" id="mobile" style="width:135px;"/></td>
				</tr>
				<tr height="30">
					<td>Mail Id*</td>
					<td><input type="text" class="txt_box2" name="mailid" id="mailid" style="width:135px;"/></td>
				</tr>
				<tr height="30">
					<td>Web Site*</td>
					<td><input type="text" class="txt_box2" name="website" id="website" style="width:135px;"/></td>
				</tr>
						
                 
                        					</table>
										</td>
              						  </tr>
              
              
                				</table>
							</td>
              			</tr>
              			<tr>
                		<td align="right" valign="top" class="form_bg">
							<table width="500" border="0" cellpadding="0" cellspacing="0">
                  				<tr>
                    				<td align="center">
										<input name="submit" type="submit" class="bg_bt" id="button"value="Post Requirment" />
									</td>
                  				</tr>
                  			</table>
						</td>
              			</tr>
</form>
              		</table>
				</td>
          </tr>
      </table>
   </td>
  </tr>
</table>
</td>
</tr>
<tr>
  <td height="40">&nbsp;</td>
</tr>
</table>

<?php require_once(INCLUDES_DIR.ADMFOOTER); ?>