<?php
$PageSecurity = 11;
 //echo $_SERVER['QUERY_STRING'];exit;
 include('includes/SQL_CommonFunctions.inc');
 include('includes/function_lib.php');
 include('includes/session.inc');
 global $db;
 $data1='
  
    
<table width="100%" border="1" cellpadding="3" cellspacing="0">
		<tr class="row1">
		<td colspan="7"><strong>Vacancy Details</strong></td>
		</tr>
        <tr>
            <th width="2%">Select</th>
            <th width="17%">Designation</th>
            <th width="13%">Department</th>
            <th width="5%">Availability</th>
            <th width="3%">Required</th>
            <th width="43%">Job Description</th>
            <th>Profile</th>
        </tr>';
        
$desigsql=DB_query("select * from desigmaster where CompanyId='".$_SESSION['ACGCompanyId']."' ",$db);
$i=0;
while($desigres=DB_fetch_assoc($desigsql)) {  
  $dept= $s->GetFieldValue('deptmaster',"id='".$desigres['mst_departmentid']."'",'deptname');
 $availcount=DB_query("SELECT * FROM empmaster  WHERE  CompanyId=5 AND dol='0000-00-00' AND department='".$desigres['mst_departmentid']."' and designation='".$desigres['id']."' and emp_site='".$_REQUEST['branch']."' ",$db);
    $data1.= '<tr>
            <td><input name="delitem['.$i.']" value="'.$i.'" type="checkbox"  id="delitem_'.$i.'" onclick="javascript:remove_attr('.$i.')" /></td>
                <input type="hidden" name="desig['.$i.']" value="'.$desigres['id'].'">
            <td><input type="text" value="'.$desigres['designame'].'" style="width:100%;"></td>
            <td><input type="text" readonly value="'.$dept.'" id="dept" style="width:100%;"></td>
            <td><input type="text" readonly value="'.DB_num_rows($availcount).'" id="avail" style="width:100%;"></td>
            <td><input type="text"  value="" maxlength="3" onkeypress="javascript:return isNumberKey(event)" readonly id="required_'.$i.'" name="required['.$i.']" style="width:100%;"></td>
            <td><input type="text" name="job_desc[]" id="job_desc_'.$i.'"  readonly style="width:100%;" /></td>';
           $data1.=  '<td> <select name="profile['.$i.']" >';
           $vdate=FormatDateForSQL($_REQUEST['vdate']);
           if($_REQUEST['type']=="")
           {
               $profile=DB_query("SELECT * FROM hr_profile_master WHERE branch='".$_REQUEST['branch']."' AND valid_from <='".$vdate."' AND valid_to>='".$vdate."' and CompanyId='".$_SESSION['ACGCompanyId']."' and designation='".$desigres['id']."' and department='".$desigres['mst_departmentid']."' ",$db);
           }
               else
               {    
$profile=DB_query("SELECT * FROM hr_profile_master WHERE branch='".$_REQUEST['branch']."' AND valid_from <='".$vdate."' AND valid_to>='".$vdate."' and CompanyId='".$_SESSION['ACGCompanyId']."' and designation='".$desigres['id']."' and job_type='".$_REQUEST['type']."' and department='".$desigres['mst_departmentid']."' ",$db);
               }
             while($profile_res=DB_fetch_assoc($profile))
             {
              $data1.='<option value="'.$profile_res['id'].'">'.$profile_res['profile_code'].'</option>';  
             }
             $data1.='</select> </td></tr> ';
             $i++; } 
      $data1.=  '<tr><td colspan="7" style="text-align:center"><input type="submit" clsss="search" value="Save" name="save"></td></tr></table><input type="hidden" value="'.$i.'" name="childcount" id="childcount" > ';
echo $data1;
      ?>
