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



$data=array();

$collection_date=date('Y-m-d');
$data['rect_date'] = $collection_date;
$data['rect_source'] = $_POST['recsource'];
$data['rect_resume'] = $_POST['noresumes'];
/*$data['rect_num_cand'] = $_POST['recnocandintr'];
$data['rec_sel_cand'] = $_POST['recselcand'];
$data['rect_cost'] = $_POST['recost'];
$data['rect_costratio']	= $_POST['recostratio'];*/
$data['rect_desg'] = $_POST['recdesg'];
$data['rect_dept'] = $_POST['department'];
//$data['e_code']	= $_POST['bankcode'];
//print_r($data);
	$recruitmentadd	 =	$db->Insert($data,'recruitment');
	$rect_id  		 =   $db->LastInsertID();
	
	


//upload image and resume and enter it to file




$g=0;		
foreach ( $_FILES['resume']['name']  as $values)
{

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




	
		

	
	
	?>