<?php
@session_start();
include_once("../class/class.MySQL.php");
require '../class/resizeImage.php';
include_once("showpath.php");
$db	=new MySQL();
$action = $_GET['action'];
//error_reporting(-1);
if($action == 'insertDetails'){

	
	$data['emp_id'] = $_REQUEST['empid'];
	$data['resign_submit_dt'] =date(('Y-m-d'),strtotime($_REQUEST['resigned_submit_dt']));
	$data['reason_leaving'] = $_REQUEST['reason_leaving'];
	$data['notice_prd_y_n'] = $_REQUEST['notice_period'];
	$data['notice_days'] = $_REQUEST['notice_day'];
	$data['tentaive_leave_dt'] = date(('Y-m-d'),strtotime($_REQUEST['tentative_leave_dt']));
	$data['resign_remark'] = $_REQUEST['resigned_remark'];
	
	$data['terminate_leave_dt'] = date(('Y-m-d'),strtotime($_REQUEST['date_leaving']));
	$data['terminate_reason_leave'] = $_REQUEST['reason_leaving_service'];
	$data['pf_leave_dt'] = date(('Y-m-d'),strtotime($_REQUEST['date_leaving_pf']));
	
	$data['term_regin_type'] = $_REQUEST['type'];
	
	
	
	$wheres['emp_id']			= $_GET['empid'];
	$terminate_resignlistcnt = $db->fetchAll('emp_terminate_resign',$wheres);
	//$terminate_resignlistcnt = $db->fetchAll('select * from emp_terminate_resign where emp_id = '.$_REQUEST['empid'].'');
	

	if(count($terminate_resignlistcnt)>0)
	{
		$empwhere['emp_id'] = $_REQUEST['empid'];
		$db->Update('emp_terminate_resign',$data,$empwhere);
	}
	else
	{
		$db->Insert($data,'emp_terminate_resign');
	}	

	
}

if($action == 'loadstst'){

	$wheres['emp_id']			= $_GET['empids'];
	$deductions = $db->fetchAll('emp_terminate_resign',$wheres);
	//$terminate_resignlist = $db->fetchAll('emp_terminate_resign');
	echo '{"terminateresignlist":'.json_encode($deductions).'}';
	
}

if($action == 'checkdetails'){

	$wheres['emp_id']			= $_GET['empids'];
	$checkdts = $db->fetchAll('emp_terminate_resign',$wheres);
	echo '{"terminateresigndts":'.json_encode($checkdts).'}';
	
}

?>