<?php
$table="hr_training_feedback";
$modid=isset($_REQUEST['modid'])?$_REQUEST['modid']:'';
$frmid=isset($_REQUEST['frmid'])?$_REQUEST['frmid']:'';
$rurl="index.php?route=HRModule/training_feedback_index&modid=".$modid."&frmid=".$frmid;
$action=isset($_REQUEST['action'])?$_REQUEST['action']:'';
$ID=isset($_REQUEST['ID'])?(int)$_REQUEST['ID']:0;
$RData=array();
function htf($v){ return htmlspecialchars($v,ENT_QUOTES); }
function tf_req($k){ return isset($_REQUEST[$k])?addslashes(trim($_REQUEST[$k])):''; }
function tf_val($row,$k){ return isset($row[$k])?$row[$k]:''; }
function tf_date($k){ return (isset($_REQUEST[$k]) && trim($_REQUEST[$k])!='')?FormatDateForSQL($_REQUEST[$k]):'0000-00-00'; }
if(isset($_REQUEST['Save'])){
	$status=true;
	if((int)tf_req('training_detail_id')==0){ $msgErr[]='Please Select Training Detail'; $status=false; }
	if($status){
		$data['training_detail_id']=(int)tf_req('training_detail_id');
		$data['employee_id']=(int)tf_req('employee_id');
		$data['overall_rating']=(int)tf_req('overall_rating');
		$data['content_relevance']=tf_req('content_relevance');
		$data['trainer_effectiveness']=tf_req('trainer_effectiveness');
		$data['useful_points']=tf_req('useful_points');
		$data['improvement_suggestion']=tf_req('improvement_suggestion');
		$data['recommend_training']=tf_req('recommend_training');
		$data['feedback_date']=tf_date('feedback_date');
		$data['modified_by']=$_SESSION['UserID'];
		$data['modified_date']=date('Y-m-d');
		if($action=='Edit' && $ID>0){
			$s->RecordEdit($table,$data,"id='".$ID."' and companyid='".$_SESSION['ACGCompanyId']."'");
			$s->pageLocation($rurl."&daction=Updated");
		}else{
			$data['created_by']=$_SESSION['UserID'];
			$data['created_date']=date('Y-m-d');
			$data['companyid']=$_SESSION['ACGCompanyId'];
			$s->RecordInsert($table,$data);
			$s->pageLocation($rurl."&daction=Inserted");
		}
	}
}
if($action=='Edit' && $ID>0){
	$SQL=DB_query("select * from ".$table." where id='".$ID."' and companyid='".$_SESSION['ACGCompanyId']."'",$db);
	$RData=DB_fetch_array($SQL);
}
?>
<link rel="stylesheet" href="css/new_mxerp.css">
<div class="body_contain">
<div class="tab_div">
<h1><strong>Training Feed Back</strong></h1>
<?php if(isset($msgErr)){ ?><div class="error" style="text-align:center;"><?php for($i=0;$i<count($msgErr);$i++){ echo $msgErr[$i].'<br>'; } ?></div><?php } ?>
<form action="" method="post">
<input type="hidden" name="action" value="<?php echo htf($action); ?>">
<input type="hidden" name="ID" value="<?php echo $ID; ?>">
<table width="100%" border="0" cellpadding="3" cellspacing="0">
<tr class="row1">
	<td width="13%" align="right"><strong>Training Detail</strong></td>
	<td width="20%"><select name="training_detail_id" style="width:98%;"><option value="0">Select</option>
		<?php $sel=tf_val($RData,'training_detail_id'); $q=DB_query("select td.id,td.employee_id,td.employee_name,tm.program_name from hr_training_details td left join hr_training_induction_master tm on tm.id=td.training_id where td.companyid='".$_SESSION['ACGCompanyId']."' order by td.id desc",$db); while($r=DB_fetch_array($q)){ ?><option value="<?php echo $r['id']; ?>" <?php echo ($sel==$r['id'])?'selected':''; ?>><?php echo htf($r['program_name'].' - '.$r['employee_name']); ?></option><?php } ?>
	</select></td>
	<td width="13%" align="right"><strong>Employee</strong></td>
	<td width="20%"><select name="employee_id" style="width:98%;"><option value="0">Select</option>
		<?php $sel=tf_val($RData,'employee_id'); $q=DB_query("select id,emp_code,emp_name from empmaster where CompanyId='".$_SESSION['ACGCompanyId']."' order by emp_name",$db); while($r=DB_fetch_array($q)){ ?><option value="<?php echo $r['id']; ?>" <?php echo ($sel==$r['id'])?'selected':''; ?>><?php echo htf($r['emp_code'].' - '.$r['emp_name']); ?></option><?php } ?>
	</select></td>
	<td width="13%" align="right"><strong>Feedback Date</strong></td>
	<td><input type="text" name="feedback_date" class="datepicker" value="<?php echo (tf_val($RData,'feedback_date')!='0000-00-00' && tf_val($RData,'feedback_date')!='')?ConvertSQLDate(tf_val($RData,'feedback_date')):date('d/m/Y'); ?>" style="width:98%;"></td>
</tr>
<tr class="row1">
	<td align="right"><strong>Overall Rating</strong></td>
	<td><select name="overall_rating" style="width:98%;"><?php $v=tf_val($RData,'overall_rating'); for($i=1;$i<=5;$i++){ ?><option value="<?php echo $i; ?>" <?php echo ($v==$i)?'selected':''; ?>><?php echo $i; ?></option><?php } ?></select></td>
	<td align="right"><strong>Content Relevance</strong></td>
	<td><select name="content_relevance" style="width:98%;"><?php $v=tf_val($RData,'content_relevance'); foreach(array('Excellent','Good','Average','Poor') as $o){ ?><option value="<?php echo $o; ?>" <?php echo ($v==$o)?'selected':''; ?>><?php echo $o; ?></option><?php } ?></select></td>
	<td align="right"><strong>Trainer Effectiveness</strong></td>
	<td><select name="trainer_effectiveness" style="width:98%;"><?php $v=tf_val($RData,'trainer_effectiveness'); foreach(array('Excellent','Good','Average','Poor') as $o){ ?><option value="<?php echo $o; ?>" <?php echo ($v==$o)?'selected':''; ?>><?php echo $o; ?></option><?php } ?></select></td>
</tr>
<tr class="row1">
	<td align="right"><strong>Recommend</strong></td>
	<td><select name="recommend_training" style="width:98%;"><?php $v=tf_val($RData,'recommend_training'); foreach(array('Yes','No','Maybe') as $o){ ?><option value="<?php echo $o; ?>" <?php echo ($v==$o)?'selected':''; ?>><?php echo $o; ?></option><?php } ?></select></td>
	<td align="right"><strong>Most Useful</strong></td>
	<td colspan="3"><textarea name="useful_points" style="width:99%;height:50px;"><?php echo htf(tf_val($RData,'useful_points')); ?></textarea></td>
</tr>
<tr class="row1">
	<td align="right"><strong>Suggestion</strong></td>
	<td colspan="5"><textarea name="improvement_suggestion" style="width:99%;height:55px;"><?php echo htf(tf_val($RData,'improvement_suggestion')); ?></textarea></td>
</tr>
<tr class="row1">
	<td colspan="6" align="center">
		<input name="Save" class="search" type="submit" value="Save" <?php if(($action=='Edit' && $_SESSION['frmEdit']=='0') || ($action!='Edit' && $_SESSION['frmcreate']=='0')){ ?>disabled<?php } ?>>
		<a href="<?php echo $rurl; ?>"><input type="button" value="Back" class="search"></a>
	</td>
</tr>
</table>
</form>
</div>
</div>
