Example #1
0
<?php
$this->breadcrumbs=array(
	'Chart Report',
);


?>

<?php 
	
	$acdm_name=AcademicTerm::model()->findAll(array('condition'=>'academic_term_period_id='.$acdm_period));
	//print_r($acdm_name);
	//exit;

		$branch = Attendence::model()->findAll(array(
    				'select'=>'branch_id',
				'condition'=>'sem_id='.$acdm_period,
 				'distinct'=>true,
							));
$m=1;	
if($branch)
{
?>

<div class="portlet box yellow" style="width:100%;margin-top:20px;">
    <i class="icon-reorder"></i>
    <div class="portlet-title"><span class="box-title"> Student Attendance Chart wise Report</span>
    	<div class="operation">
	  <?php echo CHtml::link('Back', array('/student/attendence/ChartReport'), array('class'=>'btnback'));?>	
	  
	</div>
<?php

$this->breadcrumbs = array('Chart Report');
echo CHtml::link('GO BACK', Yii::app()->createUrl('attendence/ChartReport'));
?>

<?php 
$acdm_name = AcademicTerm::model()->findAll(array('condition' => 'academic_term_period_id=' . $acdm_period . ' and  academic_term_organization_id=' . Yii::app()->user->getState('org_id')));
//print_r($acdm_name);
//exit;
$branch = Attendence::model()->findAll(array('select' => 'branch_id', 'condition' => 'sem_id=' . $acdm_period . ' and attendence_organization_id=' . Yii::app()->user->getState('org_id'), 'distinct' => true));
$m = 1;
if ($branch) {
    ?>

<table class="table_data" align=center border="1" style="width:960px; font-size:12px;">
	
<th colspan="11" style="font-size: 18px; color: rgb(255, 255, 255);">
		Attendance Chart Table


        </th>	
<tr class="table_header">
<th>Branch Name\Semester</th>
<?php 
    foreach ($acdm_name as $ac) {
        ?>

<th>
<?php 
        echo "Sem-" . $ac['academic_term_name'];
 /**
  * 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 = Attendence::model()->findByPk($id);
     if ($model === null) {
         throw new CHttpException(404, 'The requested page does not exist.');
     }
     return $model;
 }
				
				}
				print "</td>";
				
			}
			else
			{?>
				<td> -- </td>
		<?php	}
		$stud_no++;	
	
	}
	// total & present.
	$all_attendance = Attendence::model()->findAll(array('condition'=>'month(attendence_date)='.$month_value.' AND st_id='.$stud_tran_id.' AND sub_id='.$selsub.' AND year(attendence_date)='.$year));	
	$percentage=0;
			$present_attendance = Attendence::model()->findAll(array('condition'=>'month(attendence_date)='.$month_value.' AND st_id='.$stud_tran_id.' AND sub_id='.$selsub.' AND year(attendence_date)='.$year.' AND attendence = "P"'));	
			$total=count($all_attendance);
			$present=count($present_attendance);
			if($total!=0)
			$percentage = ($present*100)/$total;
			print "<td>";
				 echo $total;
			print "</td>";
			print "<td>";
				 echo $present;
			print "</td>";
			print "<td>";
				 echo round($percentage,2).'%';
			print "</td>";
	
		 echo '</center>';		
			$percentage=0;
			if($totalT[$sub]!=0)
				$percentage=($present*100)/$totalT[$sub];
		
			echo "<td > $present </td>";
			echo "<td>";
			echo round($percentage,2).'%';
			echo "</td>";
			$tot=$tot+$present;			
			$tot_percentage=0;
			if($tot!=0)
				$tot_percentage=($tot*100)/$tot_t;
		}
		foreach($subjectidp as $sub)
		{			
			$present_attendance = Attendence::model()->findAll(array('condition'=>'month(attendence_date)='.$month_value.' AND branch_id='.$branch.' AND sub_id='.$sub.' AND year(attendence_date)='.$year.' AND attendence = "P" AND st_id='.$s));
		
			$present=count($present_attendance);			
			$percentage=0;
			if($totalP[$sub]!=0)
				$percentage=($present*100)/$totalP[$sub];
		
			echo "<td > $present </td>";
			echo "<td>";
			echo round($percentage,2).'%';
			echo "</td>";

			$totp=$totp+$present;
			$totp_percentage=0;
			if($totp!=0)
				$totp_percentage=($totp*100)/$tot_p;			
 if (!empty($_REQUEST['sb_id']) && $_REQUEST['sb_id'] != '') {
     echo '<table class="table_data" >';
     foreach ($all_data as $list) {
         if ($t % 2 == 0) {
             $class = "odd";
         } else {
             $class = "even";
         }
         if ($t == -1) {
             echo '<tr class="table_header"><th>Sr No.</th><th>En.No.</th><th>Name</th>';
             echo '<th>Total</th><th>Present</th><th>%</th>';
             echo '</tr>';
             ++$t;
         }
         $tcon = count(Attendence::model()->findAll(array('condition' => 'sub_id=' . $_REQUEST['sb_id'] . ' and st_id=' . $list['st_id'] . ' and month(attendence_date) in(' . $sel_month . ')')));
         $pcon = count(Attendence::model()->findAll(array('condition' => 'sub_id=' . $_REQUEST['sb_id'] . ' and st_id=' . $list['st_id'] . ' and attendence="P" and month(attendence_date) in(' . $sel_month . ')')));
         $perc = 0;
         if ($pcon > 0) {
             $perc = (double) ($pcon * 100 / $tcon);
             $perc = round($perc, 2);
         }
         $stud_model = StudentInfo::model()->findByAttributes(array('student_info_transaction_id' => $list['st_id']));
         if ($_REQUEST['less'] * 5 >= $perc && $_REQUEST['greate'] * 5 <= $perc) {
             echo '<tr class=' . $class . '><td>' . ++$t . '</td><td>' . $stud_model->student_enroll_no . '</td><td>' . $stud_model->student_first_name . '</td>';
             echo '<td>' . $tcon . '</td><td>' . $pcon . '</td><td>' . $perc . '%</td>';
             echo '</tr>';
             continue;
         }
     }
     echo '</table>';
 }
//exit;
//print_r($subject_data);
//exit;
if ($subject_data) {
    echo '<table class="table_data" >';
    echo "<th colspan=\"6\" style=\"font-size: 18px; color: rgb(255, 255, 255);\">";
    echo 'Attendance Report From-Date:' . date("d-m-Y", strtotime($start)) . " To-Date: " . date("d-m-Y", strtotime($end));
    echo '</th><tr class="table_header"><th>SI No.</th><th>Subject Name</th><th>Semester</th><th>Total</th><th>Present</th><th>Attendance %</th></tr>';
    foreach ($subject_data as $list) {
        if ($m % 2 == 0) {
            $class = "odd";
        } else {
            $class = "even";
        }
        $total_att = Attendence::model()->findAll(array('condition' => 'st_id=' . $student_data['student_transaction_id'] . ' AND sub_id=' . $list['subject_master_id'] . ' AND month(attendence_date)=' . $month_value . ' AND year(attendence_date)=' . $year));
        $pre_att = Attendence::model()->findAll(array('condition' => 'st_id=' . $student_data['student_transaction_id'] . ' AND attendence="P"' . ' AND sub_id=' . $list['subject_master_id'] . ' AND month(attendence_date)=' . $month_value . ' AND year(attendence_date)=' . $year));
        $sem_name = AcademicTerm::model()->findByPk($list['subject_master_academic_terms_name_id'])->academic_term_name;
        $percentage = 0;
        $totalcount = count($total_att);
        $precount = count($pre_att);
        if (count($total_att) == 0) {
            echo '<tr class=' . $class . '><td>' . ++$i . '</td><td><u>' . CHtml::link($list['subject_master_name'] . '(' . SubjectType::model()->findByPk($list['subject_master_type_id'])->subject_type_name . ")", array('monthview', 'month' => $month_value, 'year' => $year, 'student_id' => $student_data['student_transaction_id'], 'sub_id' => $list['subject_master_id']), array('class' => 'link', 'target' => '_blank')) . '</u></td><td>' . $sem_name . '</td><td>' . count($total_att) . '</td><td>' . count($pre_att) . '</td><td>' . $percentage . '%</td></tr>';
        } else {
            $percentage = count($pre_att) * 100 / count($total_att);
            echo '<tr class=' . $class . '><td>' . ++$i . '</td><td><u>' . CHtml::link($list['subject_master_name'] . '(' . SubjectType::model()->findByPk($list['subject_master_type_id'])->subject_type_name . ")", array('monthview', 'month' => $month_value, 'year' => $year, 'student_id' => $student_data['student_transaction_id'], 'sub_id' => $list['subject_master_id']), array('class' => 'link', 'target' => '_blank')) . '</u></td><td>' . $sem_name . '</td><td>' . count($total_att) . '</td><td>' . count($pre_att) . '</td><td>' . round($percentage, 2) . '%</td></tr>';
        }
        $m++;
    }
    echo '</table>';
} else {
    print "<h1 style=\"color:red;text-align:center\">No Record To Display</h1>";
 public function actionStudMonthlyAllsubjectAttendenceReport()
 {
     $baseUrl = Yii::app()->baseUrl;
     $cs = Yii::app()->getClientScript();
     $cs->registerCssFile($baseUrl . '/css/report.css');
     $model = new Attendence();
     $this->performAjaxValidation($model);
     $month = null;
     $month_value = null;
     $student = array();
     $subject_data = array();
     $sid = array();
     $subject = 0;
     $subjectp = 0;
     $subjectidp = array();
     $subjectid = array();
     $batch = 0;
     if (!empty($_POST['months']) && !empty($_REQUEST['Attendence']['batch_id']) && isset($_POST['Attendence']) || isset($_REQUEST['batch_id'])) {
         //print_r ($_POST['Attendence']);exit;
         $query = null;
         if (!empty($_REQUEST['batch_id'])) {
             $batch = $_REQUEST['batch_id'];
             $query .= "batch_id=" . $batch . " AND ";
         } else {
             $batch = $_POST['Attendence']['batch_id'];
             $query .= "batch_id=" . $batch . " AND ";
         }
         if (!empty($_POST['months']) || !empty($_REQUEST['month'])) {
             if (!empty($_REQUEST['month'])) {
                 $month = $_REQUEST['month'];
             } else {
                 $month = $_POST['months'];
             }
             $student = Yii::app()->db->createCommand()->selectDistinct('st_id')->from('attendence a')->join('student_transaction st', 'a.st_id=st.student_transaction_student_id')->where($query . '  st.student_transaction_detain_student_flag NOT IN (1,2)')->queryAll();
             //print_r($student);exit;
             foreach ($student as $s) {
                 //student name
                 $data3 = Attendence::model()->findAll(array('condition' => 'st_id=' . $s['st_id']));
                 $stud_name = StudentInfo::model()->findByPk($s['st_id']);
                 $sid[] = $s['st_id'];
             }
             $subject = Yii::app()->db->createCommand()->selectDistinct('sub_id')->from('attendence a')->join('subject_master sub', 'a.sub_id=sub.subject_master_id')->where('subject_master_type_id=1')->queryAll();
             $subject_p = Yii::app()->db->createCommand()->selectDistinct('sub_id')->from('attendence a')->join('subject_master sub', 'a.sub_id=sub.subject_master_id')->where('subject_master_type_id=2')->queryAll();
             foreach ($subject as $sub) {
                 $sub_name = SubjectMaster::model()->findByPk($sub['sub_id']);
                 $subjectid[] = $sub['sub_id'];
             }
             foreach ($subject_p as $sub) {
                 $sub_name = SubjectMaster::model()->findByPk($sub['sub_id']);
                 $subjectidp[] = $sub['sub_id'];
             }
         }
         // .......export excel.....
         if (isset($_REQUEST['excel'])) {
             Yii::app()->request->sendFile(date('YmdHis') . '.xls', $this->renderPartial('stud_monthly_allsubject_attendence_report_excel', array('month' => $month, 'sid' => $sid, 'batch' => $batch, 'subjectid' => $subjectid, 'subjectidp' => $subjectidp), true));
         } else {
             $this->render('stud_monthly_allsubject_attendence_report_view', array('model' => $model, 'month' => $month, 'sid' => $sid, 'batch' => $batch, 'subjectid' => $subjectid, 'subjectidp' => $subjectidp));
         }
     } else {
         $this->render('stud_monthly_allsubject_attendence_report_view', array('model' => $model, 'month' => $month, 'sid' => $sid, 'batch' => $batch, 'subjectid' => $subjectid, 'subjectidp' => $subjectidp));
     }
 }
echo "<tr align=center> <th  colspan = 60 style=text-align:left;> ".CHtml::image(Yii::app()->controller->createUrl('/site/loadImage', array('id'=>$org_data->organization_id)),'No Image',array('width'=>80,'height'=>55,'style'=>'float:left;margin-left:200px;')) ."
	 <big> <b>".$org_data->organization_name ."</big><br>". $org_data->address_line1." ".$org_data->address_line2."</br>"  . City::model()->findBypk($org_data->city)->city_name.", ".State::model()->findBypk($org_data->state)->state_name.", ".Country::model()->findBypk($org_data->country)->name."." ." </th> <br>	 </tr>";
	echo "<th colspan=\"6\" style=\"font-size: 18px; color: rgb(255, 255, 255);\">";
	echo 'Attendance Report From-Date:'.date("d-m-Y", strtotime($start))." To-Date: ".date("d-m-Y", strtotime($end));
        echo '</th></tr><tr class="table_header"><th>SI No.</th><th>Subject Name</th><th>Semester</th><th>Total</th><th>Present</th><th>Attendance %</th></tr>';
foreach($subject_data as $list) {
		if(($m%2) == 0)
		{
		  $class = "odd";
		}
		else
		{
		  $class = "even";
		}
		$total_att = Attendence::model()->findAll(array('condition'=>'st_id='.$student_data['student_transaction_id'].' AND sub_id='.$list['subject_master_id'].' AND attendence_date BETWEEN "'.$start.'" AND "'.$end.'"'));
		$pre_att = Attendence::model()->findAll(array('condition'=>'st_id='.$student_data['student_transaction_id'].' AND attendence="P"'.' AND sub_id='.$list['subject_master_id'].' AND attendence_date BETWEEN "'.$start.'" AND "'.$end.'"'));
		$sem_name = AcademicTerm::model()->findByPk($list['subject_master_academic_terms_name_id'])->academic_term_name;	
		$percentage=0;
		$totalcount=count($total_att);
		$precount=count($pre_att);
		if(count($total_att)==0)
		{
			
			echo '<tr class='.$class.'><td>'.++$i.'</td><td>'.$list['subject_master_name'].'('.SubjectType::model()->findByPk($list['subject_master_type_id'])->subject_type_name.")".'</td><td>'.$sem_name.'</td><td>'.count($total_att).'</td><td>'.count($pre_att).'</td><td>'.$percentage.'%</td></tr>';
			
		}
		else
		{
			$percentage = (count($pre_att)*100)/count($total_att);
			echo '<tr class='.$class.'><td>'.++$i.'</td><td>'.$list['subject_master_name'].'('.SubjectType::model()->findByPk($list['subject_master_type_id'])->subject_type_name.")".'</td><td>'.$sem_name.'</td><td>'.count($total_att).'</td><td>'.count($pre_att).'</td><td>'.round($percentage,2).'%</td></tr>';
			
Example #10
0
	public function actionStudentAttendenceReport()	//done by Ravi B
    	{
	       $model=new Attendence;

			
		if((!empty($_POST['Attendence']['start_date']) && !empty($_POST['Attendence']['end_date'])) || (!empty($_POST['months']) || !empty($_REQUEST['month'])))
		{

			$month = null;
			if(!empty($_REQUEST['en_no']))
			    $en = $_REQUEST['en_no'];
		
			 if(!empty($_REQUEST['month']))
				$month = $_REQUEST['month'];
			   else if(!empty($_POST['months']))
				$month = $_POST['months'];
			  
			$student_data= Yii::app()->db->createCommand()
					->select('*')
					->from('student_transaction stud')
					->join('student_info stud_info', 'stud_info.student_id = stud.student_transaction_student_id')
					->where('stud_info.student_info_transaction_id="'.$_REQUEST['id'].'" and stud.student_transaction_organization_id='.Yii::app()->user->getState('org_id'))
					->queryRow();



			if(!empty($_POST['studentradio']) && $_POST['studentradio']=='1' )
			{
			
		   	   $start=null;
			   $end=null;
			
			   if(empty($student_data))
			   {
			      Yii::app()->user->setFlash('no_student_found', "No Student Found for this Enrollment no.");
			      $this->redirect(array('/studentAttendenceReport','id'=>$_REQUEST['id']));  
			   }				
			   else if(strtotime($_POST['Attendence']['start_date']) > strtotime($_POST['Attendence']['end_date']))
			   {
			      Yii::app()->user->setFlash('no_student_found', "Start-Date must be less than End-Date.");	
			      $this->redirect(array('/studentAttendenceReport','id'=>$_REQUEST['id'])); 		
			   }	
			   else
			   {
				$new_start=$_POST['Attendence']['start_date'];
				$new_end=$_POST['Attendence']['end_date'];
					
				$start = date("Y-m-d", strtotime($new_start));
				$end = date("Y-m-d", strtotime($new_end));
				$att_info = Attendence::model()->findAll(array(
					'select'=>'sem_name_id',
					'distinct'=>true,
					'condition'=>'attendence_date >=:date_start and attendence_date <= :date_end and st_id = :stu_id',
					'params'=>array(':date_start'=>$start,':date_end'=>$end,'stu_id'=>$student_data['student_transaction_id'])
));				
				$sem_data = array();	
				
				foreach($att_info as $list)
					$sem_data[] = $list['sem_name_id'];
				if($sem_data){
				$sem_array = implode(',',$sem_data);

				$subject_data = Yii::app()->db->createCommand()
		        	->select('*')
				->from('subject_master')
				->where('subject_master_id in (select sub_id from attendence where branch_id='.$student_data['student_transaction_branch_id'].' and sem_id='.$student_data['student_academic_term_period_tran_id'].') and subject_master_academic_terms_name_id IN('.$sem_array.')')
				->queryAll();

			
				
			$this->render('student_report_view',array(
				       'subject_data'=>$subject_data,'student_data'=>$student_data,'start'=>$start,'end'=>$end,));		
				     }


				else
				{
					Yii::app()->user->setFlash('no_student_found', "No Data Found for this Date range.");
					$this->redirect(array('studentAttendenceReport','id'=>$_REQUEST['id'])); 
				}

			     }
							
			}
			if((!empty($_POST['studentradio']) && $_POST['studentradio']=="2") || $month)
			{
				
			   if(strlen($month) == 1)
				$month = "0".$month;

				$year = date('Y');
				$num = cal_days_in_month(CAL_GREGORIAN, $month, date('Y'));
				$month_start = '01-'.$month.'-'.$year;
				$month_end = $num.'-'.$month.'-'.$year;
   			 
				$start=null;
				$end=null;

			
			   if(empty($student_data))
			   {
				
			      Yii::app()->user->setFlash('no_student_found', "No Student Found for this Enrollment no.");
			      $this->redirect(array('/studentAttendenceReport','id'=>$_REQUEST['id'])); 
				
			   }
			   else 
			   {
				 
				  $att_info = Attendence::model()->findAll(array(
					'select'=>'sem_name_id',
					'distinct'=>true,
					'condition'=>'month(attendence_date) =:month and year(attendence_date) = :year and st_id = :stu_id',
					'params'=>array(':month'=>$month,':year'=>$year,'stu_id'=>$student_data['student_transaction_id'])
));				
				   $sem_data = array();
				
				   foreach($att_info as $list)
					$sem_data[] = $list['sem_name_id'];
				
				   $sem_array = implode(',',$sem_data);


				if($sem_data)
				{
					
				   $subject_data = Yii::app()->db->createCommand()
		        	   		->select('*')
						->from('subject_master')
						->where('subject_master_id in (select sub_id from attendence where branch_id='.$student_data['student_transaction_branch_id'].' and sem_id='.$student_data['student_academic_term_period_tran_id'].') and subject_master_academic_terms_name_id IN('.$sem_array.') AND subject_master_organization_id='.Yii::app()->user->getState('org_id'))
						->queryAll();
				
				   $new_start=$month_start;
				   $new_end=$month_end;
					
				   $start = date("Y-m-d", strtotime($new_start));
				   $end = date("Y-m-d", strtotime($new_end));
			
				
				   $this->render('monthwise_student_attend',array(
				       'subject_data'=>$subject_data,'student_data'=>$student_data,'start'=>$start,'end'=>$end,'month_value'=>$month,'year'=>$year));	
				}
				else
				{
					Yii::app()->user->setFlash('no_student_found', "No Attendence Found for this Criteria.");
				$this->redirect(array('studentAttendenceReport','id'=>$_REQUEST['id']));  	
				}
			    
			   }		
			}
	
		}//!empty($_POST['Attendence']['student_enroll_no']) if end
		
		else 
		{	
               	$this->render('student_attendence_report',array(
                       'model'=>$model,
               		));		
		}    
       	}
 protected function report()
 {
     global $user;
     global $objPDO;
     $student = new student($objPDO, $user->getuserId());
     $headMenu = array("username" => $student->getName());
     if ($user->checkAdmin() == true || $student->checkTeacher() || $student->checkStudent()) {
         $role = $student->getacctType();
         $sid = NULL;
         if ($student->checkStudent()) {
             include_once $_SERVER['DOCUMENT_ROOT'] . '/cloud/model/student_profile_class.php';
             $sid = $student->getID();
         } else {
             if (isset($_GET['uid'])) {
                 $sid = $_GET['uid'];
             }
         }
         if ($sid) {
             include_once $_SERVER['DOCUMENT_ROOT'] . '/cloud/model/student_profile_class.php';
             include_once $_SERVER['DOCUMENT_ROOT'] . '/cloud/model/attendence_class.php';
             include_once $_SERVER['DOCUMENT_ROOT'] . '/cloud/model/student_section_class.php';
             include_once $_SERVER['DOCUMENT_ROOT'] . '/cloud/model/section_class.php';
             $stu = new StudentProfile($objPDO);
             $stu->loadByUserId($sid);
             $roll_number = $stu->getRollNo();
             $name = $stu->getName();
             $section = new StudentSection($objPDO);
             $section_id = $section->getByStudentId($sid);
             $sec = new Section($objPDO, $section_id);
             $section_name = $sec->getCode();
             $att = new Attendence($objPDO);
             $total_days = $att->getBySectionId($section_id);
             $attendance = $att->getByStudentId($stu->getID());
             $present = 0;
             $absent = 0;
             foreach ($attendance as $key => $value) {
                 if ($value['presence'] == 1) {
                     $present++;
                 } else {
                     if ($value['presence'] == 0) {
                         $absent++;
                     }
                 }
             }
             include $_SERVER['DOCUMENT_ROOT'] . '/cloud/view/report_view.php';
         } else {
             echo 'error';
         }
     } else {
         header('Location:http://localhost/cloud');
     }
 }
Example #12
0
 function loadAttendences($state = null)
 {
     $loader = new Attendence($this->{$db});
     $this->setAttendences($loader->loadWhere('eventId=?', [$this->getId()]));
     return $this->getAttendences();
 }
Example #13
0
	for($i = 1; $i<=$num; $i++) {
	print '<th>'.$i.'</th>';
	}
?>
</tr>
<tr class='odd'>
<th>Present/Absent</th>
<?php 

	for($i = 1; $i<=$num; $i++) {
	
	if(strlen($i) == 1)
		$i = "0".$i;
	$date = $i.'-'.$month_value.'-'.date('Y');
	$attend_date = date("Y-m-d", strtotime($date));
	$result1 = Attendence::model()->findAll(array('condition'=>'month(attendence_date)='.$month_value.' AND st_id='.$student_id.' AND sub_id='.$subject_id.' AND day(attendence_date)='.$i.' AND year(attendence_date)='.$year));
	
	if(count($result1) !=0)		
	{	
		print "<td>";
		$a = 1;
		foreach($result1 as $result){
		$myclass = $result->attendence == 'P' ? 'green' : 'red'; 
		if($a == count($result1))
		print "<b style=color:$myclass>".$result->attendence."</b>";
		else
		print "<b style=color:$myclass>".$result->attendence."</br></b>";
		$a+=1;
		}
		print "</td>";
	}
 public function beforeDelete()
 {
     $id = $this->student_transaction_id;
     $fees_check = FeesPaymentTransaction::model()->findAll(array('condition' => 'fees_student_id=' . $id));
     $att_check = Attendence::model()->findAll(array('condition' => 'st_id=' . $id));
     $mis_fees = MiscellaneousFeesPaymentTransaction::model()->findAll(array('condition' => 'student_fees_id=' . $id));
     $left_check = LeftDetainedPassStudentTable::model()->findAll(array('condition' => 'student_id=' . $id));
     $st_archive = StudentArchiveTable::model()->findAll(array('condition' => 'student_archive_stud_tran_id=' . $id));
     if (!empty($fees_check) || !empty($att_check) || !empty($mis_fees) || !empty($left_check) || !empty($st_archive)) {
         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;
     }
 }
		  }
                $result1=Attendence::model()->findByAttributes(array('st_id'=>		$s,'attendence_date'=>"$date",'student_attendence_period_id'=>$lectures[$l],'sub_id'=>$subject[$l],'employee_id'=>$faculty[$l]));
		if(count($result1) !=0)		
		{
		  $myclass = $result1->attendence == 'P' ? 'green' : 'red';
		  print "<b>"."<font color=".$myclass.">".$result1->attendence."</font>"."</b>";
                }	
		else
		  print "  --  "; 		
		$l++;
		}	  
		$l--;		
	      }
	      else 
	      {
		   $result1=Attendence::model()->findByAttributes(array('st_id'=>$s,'attendence_date'=>"$date",'student_attendence_period_id'=>$lectures[$l],'employee_id'=>$faculty[$l]));
		if(count($result1) !=0)		
		{						  	
			$myclass = $result1->attendence == 'P' ? 'green' : 'red'; 
			print "<td align=center><b >"."<font color=".$myclass.">".$result1->attendence."</font>"."</b>"."</td>";
		}	
		else
			print "<td align=center> - </td>"; 
		
	      }
        }	
      else 
      {
		print "<td> -- </td>"; 
      }
      $cs++;		
	public function beforeDelete()
	{
		$id = $this->student_transaction_id;
		$att_check = Attendence::model()->findAll(array('condition'=>'st_id='.$id));

		if(!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;
		}


    	}
	/** @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;
		}
    	}