<?php  
error_reporting(0);
require '../class/resizeImage.php';

session_start();
include_once("../class/class.MySQL.php");
$db	=new MySQL(); 
 
$data="";
$data1="";
$data2="";
$data3="";
if(isset($_REQUEST['hid']))
{
	$id=$_REQUEST['hid'];
	
$data=array();

	$data['e_fname']  	 = $_POST['fname'];
	$data['e_mname'] = $_POST['mname'];
	$data['e_lname'] = $_POST['lname'];
	$data['e_add']	 = $_POST['address'];
	$data['e_country']= $_POST['country'];
	$data['e_state'] = $_POST['state'];
	$data['e_zip']	= $_POST['zip'];
	$data['e_dob']	= $_POST['dob'];
	$data['e_phone']=$_POST['phone'];
	$data['e_mob']=$_POST['mobile'];
	$data['e_gender']=$_POST['gender'];
	$data['e_mail']=$_POST['email'];
	$data['e_rname']=$_POST['rname'];
	$data['e_relation']=$_POST['relation'];
	$data['e_contact']=$_POST['contact'];
	$data['e_rlocation']=$_POST['loc'];
	//$data['e_post']=$_POST['pa'];
	$data['e_plocation']=$_POST['jloc'];
	$data['e_dstart']=$_POST['dstart'];
	$data['e_dweek']=$_POST['dw'];
	$data['e_qualification']=$_POST['level'];
	$data['e_course']=$_POST['course'];
	$data['e_english']=$_POST['se'];
	$data['e_account']=$_POST['accountname'];
	$data['e_bank']=$_POST['bank'];
	$data['e_accountno']=$_POST['accountno'];
	$data['e_bankadd']=$_POST['bankadd'];
	$data['e_code']=$_POST['bankcode'];
	
	$data['employee_id']	=$_POST['emp_id'];
	$data['date_join']		=$_POST['dt_join'];
	$data['blood_group']	=$_POST['blood_grp'];
	$data['pf_accnum']		=$_POST['pf_ac_no'];
	$data['pf_nominee']		=$_POST['pf_nominee'];
	$data['esi_details']	=$_POST['esi_details'];
		
	$data['hist_dt_join']	  =$_POST['history_dt_join'];
	$data['hist_emptype']	  =$_POST['emptype'];
	$data['hist_dt_prev_pay'] =$_POST['dt_prev_pay_revision'];
	$data['hist_dt_pay']	  =$_POST['dt_pay_revised'];
	$data['hist_comp_prob']	  =$_POST['comp_probation'];
	
	$data['e_eng_rd']	  =$_POST['radio_eng1'];
	$data['e_eng_wt']	  =$_POST['radio_eng2'];
	$data['e_eng_sp'] 	  =$_POST['radio_eng3'];
	
	$data['e_mal_rd']	  =$_POST['radio_mal1'];
	$data['e_mal_wt']	  =$_POST['radio_mal2'];
	$data['e_mal_sp']	  =$_POST['radio_mal3'];
	
	$data['e_tam_rd']	  =$_POST['radio_tam1'];
	$data['e_tam_wt']	  =$_POST['radio_tam2'];
	$data['e_tam_sp']	  =$_POST['radio_tam3'];
	
	$data['e_hin_rd']	  =$_POST['radio_hin1'];
	$data['e_hin_wt']	  =$_POST['radio_hin2'];
	$data['e_hin_sp']	  =$_POST['radio_hin3'];
	
	$data['overtime_status']	  =$_POST['overtime'];
	$data['emp_status']	  =$_POST['empstat'];
	
	$where['e_id']			= $id;
	$employee	=	$db->Update('employee',$data,$where);
	//print_r($employee);
	
	//echo '{"employee":'.json_encode($employee).'}';
	//exit;
	
	$x=0;


$data2=array();


$allowedExts = array("doc", "docx", "pdf");
$temp = explode(".", $_FILES["resume"]["name"]);

$extension = end($temp);

if (in_array($extension, $allowedExts))
  {
  $randnum		=rand(1200,9999);
  $resumename = $randnum.$_FILES["resume"]["name"];
$data2['resume']=$resumename;

  if ($_FILES["resume"]["error"] > 0)
    {
    echo "Return Code: " . $_FILES["resume"]["error"] . "<br>";
    }
  else
    {
	
   "Upload: " . $_FILES["resume"]["name"]. "<br>";
    "Type: " . $_FILES["resume"]["type"] . "<br>";
    "Size: " . ($_FILES["resume"]["size"]/ 1024) . " kB<br>";
    "Temp file: " . $_FILES["resume"]["tmp_name"] . "<br>";


    if(file_exists("upload/resume/". $resumename))
      {
	  echo "<script>alert('$filename already exists.')</script> ";
      }
    else
      {
	  echo $_FILES["resume"]["name"];
      copy($_FILES["resume"]["tmp_name"],"../upload/resume/". $resumename);
      
	   echo "<script>alert('Your Resume has Been Submitted!!')</script> ";
      }
	  
    }
  }

		if(isset($_FILES['photo']['name']) && $_FILES['photo']['name']!=''){
		$randnum		=rand(1200,9999);
		$image			=$randnum.$_FILES['photo']['name'];
		$data2['photo']		=$image;
		$paththumb= "../upload/thumb/".$randnum.$_FILES['photo']['name'];
		$pathimg= "../upload/image/".$randnum.$_FILES['photo']['name'];
		
		try {
	
				$image = new ImageResize($_FILES['photo']['tmp_name']);
				
				//// Save thumb
				$image->resize(230,110);
				$image->save($paththumb);
				
				/// Save Image
				$image1 = new ImageResize($_FILES['photo']['tmp_name']);
				$image1->resizeToWidth(500);
				$image1->save($pathimg);

		} catch (Exception $e) {

		}
		}
	$where['e_id']			= $id;


		$db->Update('file',$data2,$where);

//Id Proof

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

$data3=array();
$data3['filetype']=$values;

if(isset($_FILES['idproof']['name']) && $_FILES['idproof']['name']!=''){
		$randnum		=rand(1200,9999);
		$image			=$randnum.$_FILES['idproof']['name'][$g];
		$data3['file']		=$image;
		$pathimg= "../upload/image/".$randnum.$_FILES['idproof']['name'][$g];
		
		try {
	
				$image = new ImageResize($_FILES['idproof']['tmp_name'][$g]);
				
				//// Save thumb
				
				
				/// Save Image
				$image1 = new ImageResize($_FILES['idproof']['tmp_name'][$g]);
				$image1->resizeToWidth(500);
				$image1->save($pathimg);

		} catch (Exception $e) {

		}
		}
$where['e_id']			= $id;
		$db->Update('idproof',$data3,$where);		
			////upload sertificatees and save to the  idproof
			}
		$k=0;

  foreach ( $_POST['refer'] as $value)
  {
  
   
 $data4=array();

	$data4['refer']  	 = $value;
	$data4['emp'] = $_POST['emp'][$k];
	$data4['phno'] = $_POST['phno'][$k];
	$data4['email']	 = $_POST['email'][$k];
	$data4['from']= $_POST['from'][$k];
	$data4['to'] = $_POST['to'][$k];
	$data4['posi']	= $_POST['posi'][$k];
	$data4['sal']	= $_POST['sal'][$k];
	$data4['rfl']=$_POST['rfl'][$k];
	
	$where['e_id']			= $id;
	$db->Update('employee_expirence',$data4,$where);
$k++;
}	
exit;
//Empl Experience



}			
			

