<?php session_name('CAKEPHP'); session_start();	
$PageSecurity = 1;
$tabindex=0;
//include('includes/DefinePaymentClass.php');

include('includes/SQL_CommonFunctions.inc');
include('CRM/functions.php');
$s=new db_query();
$deptid=  $s->GetFieldValue('www_users'," id='".$_SESSION['UserID']."' " ,'mst_dpt_heirarchy');
$LowerDeptList=GETLowerDeptUser($_SESSION['UserID'],$deptid,$_SESSION['ACGCompanyId']);
$lowerlist=  UserDeptList($LowerDeptList);
 if(count($lowerlist)>0)
$lowerlist=implode(",",$lowerlist).",".$_SESSION['UserID'];
else
$lowerlist="'".$_SESSION['UserID']."'";
if(isset($_REQUEST['Search']))
{
    $sql="select * from perf_task_assign where 1=1";
    
    if(isset($_REQUEST['site']))
    {
        $sql.=" and branch='".$_REQUEST['site']."' ";
    }
    
    if($_REQUEST['fromdate']=="" && $_REQUEST['todate']=="" )
    {
        $sql.="and task_date between '".$_SESSION['financialYrStart']."' and '".$_SESSION['financialYrEnd']."' ";
    }
    else
    {
        $sql.="and task_date between '".FormatDateFORSQL($_REQUEST['fromdate'])."' and '".FormatDateFORSQL($_REQUEST['todate'])."' ";
    }
}
else
{
    $sql="select * from perf_appraisal_master ";
}

if(count($_REQUEST['deltask'])>0)
{
    for($i=0;$i<count($_REQUEST['deltask']);$i++)
	{
            DB_query("delete from perf_task_assign where id='".$_REQUEST['deltask'][$i]."' ",$db);
	}
	$s->pageLocation("index.php?route=TaskMgt/perf_task_assign_index".$rurl);
}
?>
<script src="TaskMgt/ui/jquery.ui.timepicker.js"></script>
<style>
#showdata {
	display: block;
	background: url(TaskMgt/Default.png) no-repeat;
	top: 0px;
	left: 0px;
	width: 300px;
	min-height: 60px;
	z-index:0;
}
#back {
	display: none;
	top: 0px;
	left: 0px;
	width: 300px;
	min-height: 60px;
	z-index:0;
}
</style>
<link rel="stylesheet" href="css/new_mxerp.css">
<div class="body_contain">
<div class="tab_div"> 
<h1>Appraisal Master</h1>
  <section id="tab2" >
	<form action="" method="post" name="myform" >
	<table width="100%" border="0">
	<tr class="row1">
	<td class="tabledata1">Branch</td>
	<td colspan="3"><select name="site"  style="width:100%;">
	<?php $Sitesql="select * from locations where  CompanyId='".$_SESSION['ACGCompanyId']."' and loccode in('".$_SESSION['AssignedBranch']."')";
	$SiteRes=DB_query($Sitesql,$db);
	while($SiteRow=DB_fetch_array($SiteRes)){?>
            <option value="<?php  echo $SiteRow['loccode'];?>" <?php  echo $_REQUEST['site']==$SiteRow['loccode']?'selected':''?> >
            <?php  echo $SiteRow['locationname'];?>
            </option>
<?php }?>
          </select>
	</td>

	<td class="tabledata1">From</td>
	<td><input name="fromdate" type="text" value="<?php echo $_REQUEST['fromdate'] ?>" style="width:100%; height:100%"  class="datepicker"/></td>
	<td class="tabledata1">To</td>
	<td><input name="todate" type="text" value="<?php echo $_REQUEST['todate'] ?>" style="width:100%; height:100%"  class="datepicker"/></td>
</tr>
<tr class="row1">
	<td style="text-align:center;" colspan="8">
	<input name="Search" type="submit" class="search"  value="Search"/>
	</td>
</tr>
	</table>
	</form>
      
      <form name="delform" id="delform" method="post" action="">
<table width="100%" border="0" cellpadding="3" cellspacing="0">

<tr class="row1">
	<td colspan="8" style="text-align:left"><a href="<?php echo "index.php?route=TaskMgt/perf_appraisal_master".$rurl.'&action=AddNew'?>">
<input type="button" name="Create" value="Add" class="search" /></a>
   </td>
</tr>
<tr class="row1">
	<td colspan="8">
	<table width="100%" border="1" cellpadding="3" cellspacing="0">
<tr class="row1">
          <!--<td class="tabledata"></td>-->
          <td class="tabledata"><strong>Branch</strong></td>
          <td class="tabledata"><strong>Valid From</strong></td>
          <td class="tabledata"><strong>Valid To</strong></td>
          <td class="tabledata"><strong>Period</strong></td>
          <td class="tabledata"><strong>Increment type</strong></td>
          <td class="tabledata"><strong>Salary From</strong></td>
          <td class="tabledata"><strong>Salary To</strong></td>
          <td class="tabledata"><strong>Approved By</strong></td>
          <td class="tabledata"><strong>Prepared By</strong></td>
          <td class="tabledata" style="padding-left: 10px;"><strong>Growth Inbetween(%) &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Appraisal(%)</strong></td>
</tr>
<?php 
$gettt = DB_query($sql,$db);
$_SESSION['Ticket']=$query;
$i=0;
if(DB_num_rows($gettt)>0){
while($row_quotes = DB_fetch_assoc($gettt)){?>
<tr class="row1">
<!--<td style="white-space:nowrap;" valign="top">
   <input name="deltask[]" type="checkbox" id="leadid_<?php echo $i+1; ?>"   value="<?php  echo $row_quotes['id']?>"  /></td>-->
<td valign="top" ><?php  echo $s->GetFieldValue('locations',"loccode='".$row_quotes['branch']."'",'locationname'); ?></td>
<td valign="top" style="white-space:nowrap"><?php echo ConvertSQLDate($row_quotes['valid_from']);?> </td>
<td valign="top" style="white-space:nowrap"><?php echo ConvertSQLDate($row_quotes['valid_to']);?> </td>
<td valign="top"><?php  if($row_quotes['period']=='m'){echo "Monthly"; } else{echo "Annual";} ?></td>
<td valign="top"><?php  if($row_quotes['increment_type']=='i'){echo "Incentive"; } else{echo "Salary";} ?></td><td valign="top"><?php echo $row_quotes['salary_from'];  ?></td><td valign="top"><?php echo $row_quotes['salary_to'];  ?></td>
        <td valign="top"><?php echo $row_quotes['prepared'];  ?></td><td valign="top"><?php echo $row_quotes['approved'];  ?></td>  
        <td style="padding-left: 10px;"><table>
                <?php $details=DB_query("select * from perf_appraisal_master_details where masterid='".$row_quotes['id']."' ",$db); while($details_res=DB_fetch_assoc($details)){ ?>
                <tr><td><?php echo "&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;". $details_res['growth_from']."-".$details_res['growth_to']."&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;".$details_res['appraisal'] ?></td></tr>
                <?php } ?>
            </table></td>
        </tr>
                <?php $i++;} }
                else{ ?>
                    <tr>
                        <td colspan="8">No Result Found.</td>
                    </tr>
               <?php }
                ?>
      </table>
	</td>
</tr>
</table>
      </form>
	</section>
</div></div>
 <script language="javascript" >
function LeadData()
{
	
	myCheckboxArray = document.myform.elements["leadid[]"];
	var t=myCheckboxArray.length;
	//alert(myCheckboxArray);
	if(document.getElementById('leadid').checked==true)
	{	
	if(t==undefined)
	document.getElementById('leadid_'+1).checked=true;		
	for (var i = 1; i <= t; i++)
	{
	document.getElementById('leadid_'+i).checked=true;	
	}	
	}
	else
	{
	if(t==undefined)		
	document.getElementById('leadid_'+1).checked=false;		
	for (var i = 1; i <= t; i++)
	{
	document.getElementById('leadid_'+i).checked=false;	
	}
	}
}

function form_sub()
{
    var conf=confirm('Sure You want to continue?')
    if(conf==true)
    {
    document.getElementById("delform").submit();
    }
    else
        {
            alert("jhkn");
            return false;
        }
    
}
</script>