<?php
session_start();
	
include_once("../class/class.MySQL.php");
require '../class/resizeImage.php';
$db=new MySQL();


$data="";
$data1="";
$data2="";
$data3="";
$data4="";
$data5="";
$data6="";
if(isset($_POST['intv_name']))
{
// add data to  employee
$data=array();

/*$collection_date=date('Y-m-d',strtotime($_POST['recdate']));
$data['rect_date'] = $collection_date;*/
$data['name_cand'] = $_POST['intv_name'];
$data['interv_pos'] = $_POST['intv_pos'];
$data['interv_loc'] = $_POST['intv_loc'];
$data['interv_qual'] = $_POST['intv_qual'];
$data['interv_exp'] = $_POST['intv_exp'];
$data['interv_contdt']	= $_POST['intv_cont_dt'];
$data['interv_schd']	= date('Y-m-d H:i:s',strtotime($_POST['intv_schedule']));
$data['interv_status'] = "Not Shortlist";
$data['interv_remark'] = $_POST['intv_remark'];
$data['interv_location'] = $_POST['intv_locn'];
$data['intv_email'] = $_POST['intv_email'];
$data['intv_phone'] = $_POST['intv_phone'];
$data['interv_exp_month'] = $_POST['interv_exp_month'];
$data['interv_dept'] = $_POST['department'];
$data['interv_desg'] = $_POST['recdesg'];
$data['interv_gender'] = $_POST['interv_gender'];



//$data['e_code']	= $_POST['bankcode'];


//mysql_query("insert into employee (e_mname)values($a)");
	$interviewadd	=	$db->Insert($data,'interview');
	$interv_id   =   $db->LastInsertID();
	
	


//upload image and resume and enter it to file

$allowedExts = array("doc", "docx", "pdf" ,"zip","rar","jpg","jpeg","png","txt");
$temp = explode(".", $_FILES["intv_resume"]["name"]);
$extension = end($temp);
if (in_array($extension, $allowedExts))
  {
	  $randnum		=rand(1200,9999);
	  $resumename = $randnum.$_FILES["intv_resume"]["name"];
	  if ($_FILES["intv_resume"]["error"] > 0)
	  {
		echo "Return Code: " . $_FILES["intv_resume"]["error"] . "<br>";
	  }
	  else
	  {
		   "Upload: " . $_FILES["intv_resume"]["name"] . "<br>";
			"Type: " . $_FILES["intv_resume"]["type"] . "<br>";
			"Size: " . ($_FILES["intv_resume"]["size"] / 1024) . " kB<br>";
			"Temp file: " . $_FILES["intv_resume"]["tmp_name"] . "<br>";
	
			if(file_exists("../upload/resume/".$resumename))
			{
		  
				echo "<script>alert('filename already exists.')</script> ";
			}
			else
			{
		  	//echo "inside".  $resumename;
			  move_uploaded_file($_FILES["intv_resume"]["tmp_name"],
			  "../upload/resume/". $resumename);
			   echo "<script>alert('Your Resume has Been Submitted!!')</script> ";
			}
	  }
	  $data2['intv_resume']  = $resumename;
	  $where['interv_id']	 = $interv_id;
	  $db->Update('interview',$data2,$where);
  } 	


	
}
	
	
	?>