<?php
session_start();
	
include_once("../class/class.MySQL.php");
require '../class/resizeImage.php';
$db=new MySQL();
$action = $_GET['action'];
$data="";
$data1="";
$data2="";
$data3="";
$data4="";
$data5="";
$data6="";
if($action == "fillSubordinate"){
	if(isset($_POST['qst_id']))
	{
		for($i=0;$i<count($_POST['qst_id']);$i++)
		{
			$qst_id = $_POST['qst_id'][$i];	
			$rate_subordinate = $_POST['rate_subordinate'][$i];	
			$query = "UPDATE `performance_question` set emp_rate = '$rate_subordinate' where question_id = $qst_id ";
			$updateperform = $db->fetchQuery($query);		
			$query1 = "UPDATE performance SET completed_status = 'Y' WHERE perform_id = (SELECT perfomance_id FROM performance_question WHERE question_id = '$qst_id') ";
			$updateperform1 = $db->fetchQuery($query1);		
		}
	}
}
if($action == "insertAttribute"){
	$data['attributes'] = $_POST['attribute'];	
	$db->Insert($data,'performance_attribute');	
	$attribute_id   =   $db->LastInsertID();
	echo $attribute_id;
}
if(isset($_POST['employeeid']))
{
	$perform_date=date('Y-m-d',strtotime($_POST['performdate']));
	$data['perform_addate'] = $perform_date;
	$data['perform_unique'] = $_POST['performuniqueid'];	
	$unival = explode("-",$_POST['performuniqueid']);
	$data['perform_unique_id'] = $unival[1];
	$data['emp_id'] = $_POST['employeeid'];
	$data['performemp_id'] = $_POST['imdateperformancesupervisor'];
	$perfomanceadd	=	$db->Insert($data,'performance');
	$perfomance_id   =   $db->LastInsertID();
	//$data=array();
	$question_array = $_POST['question'];
	$question_array_count = count($question_array);
	$attributetype_array = $_POST['attributetype'];
	$attributetype_array_count = count($attributetype_array);
	for($i=0;$i<$question_array_count;$i++){
		$qst_data['question'] = $question_array[$i];	
		$qst_data['attribute_id'] = $attributetype_array[$i];
		$qst_data['perfomance_id'] = $perfomance_id;
		$performance_questionadd	=	$db->Insert($qst_data,'performance_question');
	}
}
	
	
	?>