<?php
$PageSecurity = 11;
 //echo $_SERVER['QUERY_STRING'];exit;
 include('includes/SQL_CommonFunctions.inc');
 include('includes/function_lib.php');
 include('includes/session.inc');
 global $db;
 if($_REQUEST['desig']!=""){
  $criteria= DB_fetch_array(DB_query("select * from hr_job_criteria where branch='".$_REQUEST['branch']."' and job_type='".$_REQUEST['type']."' and companyid='".$_SESSION['ACGCompanyId']."' ",$db));
  if($criteria['designation']!="0"){
$sql_po= "select b.*,a.id as mainid from hr_job_criteria a ,hr_job_criteria_details b Where a.id=b.masterid and a.branch='".$_REQUEST['branch']."' and a.designation='".$_REQUEST['desig']."' and a.job_type='".$_REQUEST['type']."' and a.companyid='".$_SESSION['ACGCompanyId']."' ";
  }
  else{
      $sql_po= "select b.*,a.id as mainid from hr_job_criteria a ,hr_job_criteria_details b Where a.id=b.masterid and a.branch='".$_REQUEST['branch']."' and a.job_type='".$_REQUEST['type']."' and a.companyid='".$_SESSION['ACGCompanyId']."' ";
  }
$data1='<table width="100%" border="1" cellpadding="3" cellspacing="0" style="border:#808080 1px solid; border-collapse:collapse;">
    <tr>
	<th width="10%">Sequence Number</th>
	<th width="20%">Parameter Name</th>
	<th colspan="2">Profile Details</th></tr>';
        $result=DB_query($sql_po,$db);
        $i=0;
        while($myrow=DB_fetch_array($result))
        {
              $data1.='<tr bgcolor="#fff">
			  <td>'.$myrow['seq_no'].'</td>';
         $data1.=' <td>'.$myrow['parameter'].'</td>';
        $criteria=DB_fetch_array(DB_query("SELECT * FROM `hr_criteria_form_table` where parameter_id='".$myrow['id']."' ",$db));
        
         $data1.=' <td colspan="2" valign="top" style="padding:0;"><div id="amc-tab">
		 <table width="100%" border="0" cellpadding="3" cellspacing="0">';
         $label= explode(',',$criteria['label_value']);
         $label_val= explode('__',$criteria['field_value']);
         //print_r($label_val);
         foreach($label as $key=> $value)
          {
             if($label_val[$key]=="0")
             { $p='<input type="text" name="profile_value['.$criteria[id].'][]" value="" style="width:98%;" >';
             $type='<input type="hidden" name="type['.$criteria[id].'][]" value="input" >';}
                 else
                 {
                   $type='<input type="hidden" name="type['.$criteria[id].'][]" value="select" >';
                   $p= '<select name="profile_value['.$criteria[id].'][]" style="width:98%;">';
                   $val= explode(",",$label_val[$key]);
                   foreach($val as $k=>$v)
                   { 
                     $p.='<option value="'.$v.'">'.$v.'</option>';  
                   }    
                    $p.='</select>';
                 }   
            $data1.='<tr><td width="10%">'.$value.'</td><td>'.$p.'</td>'.$type.'</tr>';
          }
         $data1.='</table></div></td>';
         $data1.='</tr>';
        $i++;}
        
echo $data1; 
 }
?>
