/**
	 * Returns the data model based on the primary key given in the GET variable.
	 * If the data model is not found, an HTTP exception will be raised.
	 * @param integer the ID of the model to be loaded
	 */
	public function loadModel($id)
	{
		$model=Employee_attendence::model()->findByPk($id);
		if($model===null)
			throw new CHttpException(404,'The requested page does not exist.');
		return $model;
	}
	//$result1 = EmployeeInfo::model()->findByAttributes(array('employee_attendance_card_id'=>$var1));
	if(!empty($var1))
	{
	$result1 = Yii::app()->db->createCommand(
		'SELECT * FROM employee_info ef INNER JOIN employee_transaction et ON ef.employee_info_transaction_id = et.employee_transaction_id WHERE ef.employee_attendance_card_id ='.$var1.' AND et.employee_transaction_organization_id ='.Yii::app()->user->getState('org_id'))
	    ->queryRow();

	//print_r($result1); exit;

	$empid = $result1['employee_info_transaction_id'];
	$tr_id = EmployeeTransaction::model()->findByAttributes(array('employee_transaction_id'=>$empid,'employee_transaction_organization_id'=>Yii::app()->user->getState('org_id')));
	$eid = $tr_id['employee_transaction_id'];
	//print_r($leave_date);
	
	$result2 = Employee_attendence::model()->findByAttributes(array('employee_id'=>$eid,'date'=>$exdate));	
	
	if(empty($result2) && !empty($var1))
	{
		if($var6 == null)
			$atte = 'A';
		else
			$atte = 'P';
		if($eid != 0)
		{
		$sql = "INSERT INTO employee_attendence (employee_id,attendence,date,time1,time2,time3,time4,time5,time6,time7,
 time8, time9,time10,total_hour,overtime_hour,csvfile,employee_attendence_organization_id) VALUES 
('$eid','$atte','$exdate','$in1','$out1','$in2','$out2','$in3','$out3','$in4','$out4','$in5','$out5',
'$total','$extra','$filename','$employee_attendence_organization_id')";	
		
		$command=$connection->createCommand($sql);
	 'max'=> 100,
         'title' => array('text' => 'Attendance')
      ),
      'series' => array(
         array('data' => $atte,'showInLegend'=>false),
     

      ),
	'exporting'=> array( 'enabled' => false)
   )
));*/

		$all = Employee_attendence::model()->findAll('month(date)='.date('m').' and year(date)='.date('Y').' and employee_id='.Yii::app()->user->getState('emp_id'));
		$abs = Employee_attendence::model()->findAll('month(date)='.date('m').' and year(date)='.date('Y').' and employee_id='.Yii::app()->user->getState('emp_id').' and attendence="LWP"');
		$wo = Employee_attendence::model()->findAll('month(date)='.date('m').' and year(date)='.date('Y').' and employee_id='.Yii::app()->user->getState('emp_id').' and attendence="WO"');
		$ph = Employee_attendence::model()->findAll('month(date)='.date('m').' and year(date)='.date('Y').' and employee_id='.Yii::app()->user->getState('emp_id').' and attendence="PH"');

		$p = count($all) - count($abs) - count($wo) - count($ph);
		$array = array();

		$array[0] = array("Absent", count($abs));
		$array[1] = array("Week Off", count($wo));
		$array[2] = array("Present", $p);
		$array[3] = array("Public Holidays", count($ph));

$this->Widget('application.extensions.highcharts.HighchartsWidget',
array(
'options'=>array( 
	'chart'=> array(
		    'renderTo'=>'container',
		    'type'=> 'column'            
			}
			else
			{
				print '<td align=center> -- </td>'; 
			}
		$emp_no++;	
		}	
		
		$all_attendance = Employee_attendence::model()->findAll(array('condition'=>'month(date)='.$month_value.' AND employee_id='.$emp['employee_id'].' AND year(date)='.$year));

		$present_attendance = Employee_attendence::model()->findAll(array('condition'=>'month(date)='.$month_value.' AND employee_id='.$emp['employee_id'].' AND year(date)='.$year.' AND attendence = "P"'));

		$present_cl = Employee_attendence::model()->findAll(array('condition'=>'month(date)='.$month_value.' AND employee_id='.$emp['employee_id'].' AND year(date)='.$year.' AND attendence = "CL"'));
		$present_dl = Employee_attendence::model()->findAll(array('condition'=>'month(date)='.$month_value.' AND employee_id='.$emp['employee_id'].' AND year(date)='.$year.' AND attendence = "DL"'));
		$present_sl = Employee_attendence::model()->findAll(array('condition'=>'month(date)='.$month_value.' AND employee_id='.$emp['employee_id'].' AND year(date)='.$year.' AND attendence = "SL"'));
		$present_lwp = Employee_attendence::model()->findAll(array('condition'=>'month(date)='.$month_value.' AND employee_id='.$emp['employee_id'].' AND year(date)='.$year.' AND attendence = "LWP"'));
		
		$cl=count($present_cl);
		$dl=count($present_dl);
		$sl=count($present_sl);
		$lwp=count($present_lwp);
		$present=count($present_attendance);
		$total=count($all_attendance);

		$percentage=0;
		if($total!=0)
		   $percentage = ($present*100)/$total;

		print "<td align=center>"; echo $total; print "</td>";
		print "<td align=center>"; echo $present; print "</td>";
		print "<td align=center>"; echo $cl;	print "</td>";
Example #5
0
<i class="icon-reorder"></i>
 <div class="portlet-title"><span class="box-title">Attendance Report Of <?php echo $emp_name['employee_first_name']."&nbsp;".$emp_name['employee_middle_name']."&nbsp".$emp_name['employee_last_name'];?></span>
</div>
<table class="report-table"  style="font-size: 18px; ">
<tr class="table_header" style="width: 100px;">
<th>Sr.No.</th>
<th>Date</th>
<th>Attendence</th>
<th>In Time</th>
<th>Out Time</th>
</tr>
<?php

for($n=1;$n<=$total_day;$n++)
{
$emp_attendence = Employee_attendence::model()->findAll(array('condition'=>'employee_id='.$emp_id.' AND Day(date) ='.$n.' AND Month(date)='.$month.' AND Year(date)='.$curYear,'order'=>'date ASC'));
if(!empty($emp_attendence))
{	
foreach($emp_attendence as $list)
{
	if(($m%2) == 0)
	{
	  $class = "odd";
	}
	else
	{
	  $class = "even";
	}
   $date1 = $list['date'];
   if($date1 < $currentdate)
   {
	/** @return boolean. Check and delete all other information of the employee from 	      application. Employee profile will delete depend on this value.
	*/
	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_att) || !empty($att_check))
		{
			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;
		}
    	}
	public function beforeSave() {

        $empl_id = $this->employee_id;
        $hdate = $this->date;
        //echo $hdate;
        //exit;
        $holidate=Employee_attendence::model()->findByAttributes(array('employee_id'=>$empl_id,'date'=>$hdate));
        
        if ($this->isNewRecord)
        {
            if($holidate==NULL)
            {
	            return true;
            }
            else{
	            return false;
            }
        }
        else
	     return true;	       
       }