{
	         $class = "even";
	   }	
	   echo '<tr class='.$class.'>';
	   echo '<td>';
	   echo ++$m;
	   echo '</td>';
	   echo "<td>";

		echo $emp['title'].''.$emp['employee_first_name'].' '.$emp['employee_last_name'].' ( '.$emp['employee_name_alias'].' )';
	   echo "</td>";
	$org = Yii::app()->user->getState('org_id');
	foreach($leave as $lv)
	{
	$count=0;
	$totalLeave=EmployeeLeaveApplication::model()->findAll(array('condition'=>
	'(month(employee_leave_application_leave_start_date)='.$month_value.' OR month(employee_leave_application_leave_end_date)='.$month_value.') AND (year(employee_leave_application_leave_start_date)='.$yr.' OR year(employee_leave_application_leave_end_date)='.$yr.') AND employee_leave_application_employee_code='.$emp['employee_id'].' AND employee_leave_application_leave_code='.$lv['leave_master_id'].' AND employee_leave_application_status_2=2'
	 ));
	 foreach($totalLeave as $leave_app)
	 {
	       $startdate_month=date_format(new DateTime($leave_app->employee_leave_application_leave_start_date), 'm');
	       $enddate_month=date_format(new DateTime($leave_app->employee_leave_application_leave_end_date), 'm');
		if($startdate_month==$enddate_month)
			$count+=$leave_app->employee_leave_application_days;
		else
                {
		    $month_days=cal_days_in_month(CAL_GREGORIAN,$month_value, $yr);
                    $start_date=date_format(new DateTime($leave_app->employee_leave_application_leave_start_date), 'd');
		    $count+=$month_days-$start_date;		    	 			
		}		
		
 public function beforeDelete()
 {
     $id = $this->employee_transaction_id;
     $emp_leave = EmployeeLeaveMaster::model()->findAll(array('condition' => 'empid=' . $id));
     $att_check = Attendence::model()->findAll(array('condition' => 'employee_id=' . $id));
     $emp_att = Employee_attendence::model()->findAll(array('condition' => 'employee_id=' . $id));
     $emp_leave_app = EmployeeLeaveApplication::model()->findAll(array('condition' => 'employee_leave_application_employee_code=' . $id . ' OR employee_leave_application_approved_by_code=' . $id . ' OR employee_leave_application_approved_by_code_2=' . $id));
     $emp_rep = EmployeeReportingTable::model()->findAll(array('condition' => 'emp_reporting_table_user_id=' . $id . ' OR emp_reporting_table_reporting_level_1=' . $id . ' OR emp_reporting_table_reporting_level_2=' . $id));
     $emp_sal = EmployeeSalaryStructure::model()->findAll(array('condition' => 'employee_id=' . $id));
     $ass_sub = AssignSubject::model()->findAll(array('condition' => 'subject_faculty_id=' . $id));
     $time_table = TimeTableDetail::model()->findAll(array('condition' => 'faculty_emp_id=' . $id));
     if (!empty($emp_leave) || !empty($att_check) || !empty($emp_att) || !empty($emp_leave_app) || !empty($emp_rep) || !empty($emp_sal) || !empty($ass_sub) || !empty($time_table)) {
         Yii::app()->user->setFlash('error', "You can not delete this record because it is used in another table.");
         return false;
     } else {
         Yii::app()->user->setFlash('success', "Deleted Sucessfully");
         return true;
     }
 }