function printTree($tree)
 {
     $output = '';
     if (!is_null($tree) && count($tree) > 0) {
         $output .= '<ul>';
         foreach ($tree as $node) {
             $tmp_subject_type = new SubjectType();
             $tmp_subject_type->load($node['id']);
             $output .= '<li>';
             $output .= $tmp_subject_type->get_link();
             if (!empty($node['children'])) {
                 $output .= $this->printTree($node['children']);
             }
             $output .= '</li>';
         }
         $output .= '</ul>';
     }
     return $output;
 }
$constraint = NULL;
$id = NULL;
if (isset($_GET['constraint'])) {
    $constraint = trim($_GET['constraint']);
}
if (isset($_GET['id'])) {
    $id = trim($_GET['id']);
}
$post_data = 'action: "list_subjects_of_type"';
if (isset($constraint)) {
    $post_data .= ', constraint: "' . $constraint . '"';
}
if (isset($id)) {
    $post_data .= ', id: "' . $id . '"';
}
$current_subject_type = new SubjectType();
$current_subject_type->load($id);
?>
<a href="index.php?p=form_add_subject&subject_type=<?php 
echo $id;
?>
"
	class="btn btn-primary pull-right" style="margin: 10px;">Add a new <?php 
echo $current_subject_type->type_name;
?>
</a>
<h3><?php 
echo $current_subject_type->type_name;
?>
</h3>
<p><?php 
 public function get_parent_name()
 {
     if (empty($this->parent_id)) {
         return;
     } else {
         $parent = new SubjectType();
         $parent->load($this->parent_id);
         $output = $parent->get_link();
         if (!empty($parent->parent_id)) {
             $output .= ' -> ' . $parent->get_parent_name();
         }
         return $output;
     }
 }
		{
		  $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>';
			
		}
$m++;		
}
echo '</table>';
}
else
{
	print  "<h1 style=\"color:red;text-align:center\">No Record To Display</h1>";
}
?>
 public function listSubjectType()
 {
     $subject_type = SubjectType::model()->findAll();
     return $subject_type;
 }
 public function actionListOfSubjectInfo()
 {
     $this->retVal = new stdClass();
     $request = Yii::app()->request;
     if ($request->isPostRequest && isset($_POST)) {
         try {
             $listSubjectData = array('subject_dept' => StringHelper::filterString($_POST['subject_dept']), 'subject_faculty' => StringHelper::filterString($_POST['subject_faculty']), 'subject_type' => StringHelper::filterString($_POST['subject_type']), 'dept_id' => StringHelper::filterString($_POST['subject_dept']), 'faculty_id' => StringHelper::filterString($_POST['subject_faculty']));
             $subject_data = Subject::model()->findAll(array('select' => '*', 'condition' => 'subject_faculty = ' . $listSubjectData['subject_faculty'] . ' AND subject_type = ' . $listSubjectData['subject_type'] . ' AND (subject_general_faculty_id = ' . $listSubjectData['faculty_id'] . ' OR subject_dept = ' . $listSubjectData['subject_dept'] . ')'));
             $subject_type_group = SubjectGroupType::model()->findAllByAttributes(array('subject_group' => $listSubjectData['subject_type'], 'subject_dept' => $listSubjectData['subject_dept'], 'subject_faculty' => $listSubjectData['subject_faculty']));
             //                var_dump($subject_data);
             //                                exit();
             $subject_type_name = SubjectType::model()->findAllByAttributes(array('id' => $listSubjectData['subject_type']));
             $this->retVal->subject_data = $subject_data;
             $this->retVal->subject_group_type = $subject_type_group;
             $dept_data = Dept::model()->findAllByAttributes(array('dept_id' => $listSubjectData['dept_id'], 'dept_faculty' => $listSubjectData['faculty_id']));
             $this->retVal->subject_type = $subject_type_name;
             $this->retVal->message = 1;
         } catch (exception $e) {
             $this->retVal->message = $e->getMessage();
         }
         echo CJSON::encode($this->retVal);
         Yii::app()->end();
     }
 }
Exemple #7
0
	<table class="report-table" style="width:100%">
	<tr class="table_header">
	<th>SI No.</th>
	<th>Subject Name</th>
	<th>Subject Type</th>
	</tr>
<?php 
	$m = 0;
	foreach($sub_model as $list) { 

		if(($m%2) == 0)
		   $class = "odd";
		else
		   $class = "even";
					
		echo '<tr class='.$class.'>'; ?>
		   <td>
			<?php echo ++$m;?>
		   </td>
		   <td>
			<?php echo $list['subject_master_name']; ?>
		   </td>
		   <td>
			<?php echo SubjectType::model()->findByPk($list['subject_master_type_id'])->subject_type_name; ?>
		   </td> 
		</tr>	
		
   <?php } ?>
</table>
</div>
	$present=array();
	foreach($subjectid as $sub)
	{
		echo "<th colspan=2>";
		$sub_name = SubjectMaster::model()->findByAttributes(array('subject_master_id'=>$sub));
		echo $sub_name->subject_master_name."(".SubjectType::model()->findByPk($sub_name->subject_master_type_id)->subject_type_name.")";
		echo "</th>";
		$all_attendance = Attendence::model()->findAll(array('condition'=>'month(attendence_date)='.$month_value.' AND branch_id='.$branch.' AND sub_id='.$sub.' AND year(attendence_date)='.$year,'select'=>'attendence_date,student_attendence_period_id','distinct'=>'true'));
	
		$totalT[$sub]=count($all_attendance);
	}
	foreach($subjectidp as $sub)
	{
		echo "<th colspan=2>";
		$sub_name = SubjectMaster::model()->findByAttributes(array('subject_master_id'=>$sub));
		echo $sub_name->subject_master_name."(".SubjectType::model()->findByPk($sub_name->subject_master_type_id)->subject_type_name.")";
		echo "</th>";			
	$all_attendance = Attendence::model()->findAll(array('condition'=>'month(attendence_date)='.$month_value.' AND branch_id='.$branch.' AND sub_id='.$sub.' AND year(attendence_date)='.$year,'select'=>'attendence_date,student_attendence_period_id','distinct'=>'true'));
			$totalP[$sub]=count($all_attendance);
		
	}
		
		foreach($totalT as $t){
			$tot_t=$tot_t+$t;
		}		
		echo "<th rowspan=2> Total Theory Subjects <br> <br>Out <br>Of ".'<br> ( '.$tot_t.')'."</th> ";
		echo "<th rowspan=2> Total Theory Subjects <br><br><br> % </th>";

		foreach($totalP as $t){
			$tot_p=$tot_p+$t;
		}		
             $output .= '<tr><td>';
             $output .= '<a href="index.php?p=subject_view&id=' . $subject->id . '">' . $subject->name . '</a>';
             $output .= '</td></tr>';
         }
         $output .= '</table>';
         echo $output;
     } else {
         echo "false";
     }
     // end presentation output;
     break;
 case "list_subjects_of_type":
     if (isset($_POST['id'])) {
         // This is our SubjectTypeID
         $id = trim($_POST['id']);
         $current_subject_type = new SubjectType();
         $current_subject_type->load($id);
         $current_subject_type->load_children();
         $sql = "SELECT id FROM subjects WHERE subject_type IN (";
         $sql .= $id;
         foreach ($current_subject_type->children as $child) {
             $sql .= ', ' . $child->id;
         }
         $sql .= ')';
         if ($APP['debug']) {
             var_dump($sql);
         }
         // build the presentation output.
         $query = $db->prepare($sql);
         if ($query->execute()) {
             $subjects_collection = array();
Exemple #10
0
 public function what_am_i()
 {
     $my_subject_type = new SubjectType();
     $my_subject_type->load($this->subject_type_id);
     return $my_subject_type->what_am_i();
 }
	public function actionGetsubject()
        {
           
		$sub = array();
		$data1=array();
	
		
		// for update division

	
		$data1=SubjectMaster::model()->findAll();
                  	
		$data1=CHtml::listData($data1, 'subject_master_id' ,'subject_master_name');
		echo "<option value=''>Select Subject</option>";
		foreach($data1 as $value1=>$name1)
		{
			$sub_mas = SubjectMaster::model()->findByPk($value1);
			$type = SubjectType::model()->findByPk($sub_mas->subject_master_type_id)->subject_type_name;
		   echo  CHtml::tag('option',
		                array('value'=>$value1),CHtml::encode($name1.'('.$type.')'),true);
		}
		
		
		
	}
	public function actionShowallstudentview()
	{
		$model=new Attendence;
		$timetabledetail = new TimeTableDetail;
		$count = 0;
		$row1 = array();
		$div=Division::model()->findByPk($_REQUEST['division_id']);
		$branch_id=$div->branch_id;
		$period_no = $_REQUEST['lec_no'];
		$sub_id=$_REQUEST['subject_id'];
		$sem_id=$div->academic_period_id;
		$date = date('Y-m-d',strtotime($_REQUEST['date']));
		$sem_name = $div->academic_name_id;
		$shift_id=1;
		$div_id=$_REQUEST['division_id'];

		$subject_type = SubjectMaster::model()->findByPk($sub_id)->subject_master_type_id; 
		$subject_type_name = SubjectType::model()->findByPk($subject_type)->subject_type_name;
			
		if($subject_type_name == 'Elective')
		{
			$row1 = Yii::app()->db->createCommand()
			        ->select('student_transaction_id,student_transaction_student_id,student_roll_no, student_enroll_no,student_first_name, student_middle_name, student_last_name')
				->from('student_transaction st')	
				->join('student_info','student_info_transaction_id=student_transaction_id')
				 ->join('elective_subject_details esd','esd.elective_subject_student_id =st.student_transaction_student_id')
				->where('st.student_transaction_division_id='.$div_id.' and esd.elective_subject_sem_id='.$sem_name.' and esd.elective_subject_id='.$sub_id.' order by student_enroll_no')
				->queryAll();
				$all_array = array('branch_id'=>$branch_id,'period_no'=>$period_no,'shift_id'=>$shift_id,'faculty_id'=>$_REQUEST['faculty_id'],'div_id'=>$div_id,'sub_id'=>$sub_id,'sem_id'=>$sem_id,'date'=>$date,'sem_name'=>$sem_name);
				
		}
		else if($_REQUEST['batch']!=0)
		{
			$batch_id=$_REQUEST['batch'];
			$row1 = Yii::app()->db->createCommand()
				->select('student_transaction_id,student_transaction_student_id, student_enroll_no,student_first_name,student_roll_no, student_middle_name, student_last_name')
				->from('student_transaction')
				->join('student_info','student_info_transaction_id=student_transaction_id')
				->where('student_transaction_branch_id='.$branch_id.' and student_transaction_division_id='.$div_id.' and student_transaction_batch_id='.$batch_id.' and student_academic_term_name_id='.$sem_name.' and student_academic_term_period_tran_id ='.$sem_id.' and student_transaction_detain_student_flag in(5, 6) order by student_enroll_no')
				->queryAll();
			$all_array = array('branch_id'=>$branch_id,'period_no'=>$period_no,'shift_id'=>$shift_id,'faculty_id'=>$_REQUEST['faculty_id'],'div_id'=>$div_id,'batch_id'=>$batch_id,'sub_id'=>$sub_id,'sem_id'=>$sem_id,'date'=>$date,'sem_name'=>$sem_name);			
		}
		else
		{
			$row1 = Yii::app()->db->createCommand()
				->select('student_transaction_id,student_transaction_student_id,student_roll_no, student_enroll_no,student_first_name, student_middle_name, student_last_name')
				->from('student_transaction')
				->join('student_info','student_info_transaction_id=student_transaction_id')
				->where('student_transaction_branch_id='.$branch_id.' and student_transaction_division_id='.$div_id.' and student_academic_term_name_id='.$sem_name.' and student_academic_term_period_tran_id ='.$sem_id.' and student_transaction_detain_student_flag in (5, 6) order by student_enroll_no')
				->queryAll();
				$all_array = array('branch_id'=>$branch_id,'shift_id'=>$shift_id,'div_id'=>$div_id,'batch_id'=>"",'sub_id'=>$sub_id,'sem_id'=>$sem_id,'date'=>$date,'sem_name'=>$sem_name,'period_no'=>$period_no,'faculty_id'=>$_REQUEST['faculty_id']);
		}
	
		if($date > date('Y-m-d') || $date < date('Y-m-d', strtotime( '-6 days' )))
		{	
			echo "you can not take attendance of before week date or future date!";
			exit;	
		}
		if($_REQUEST['batch']!=0)
		{
			$check = Attendence::model()->findByAttributes(array('employee_id'=>$_REQUEST['faculty_id'],'batch_id'=>$_REQUEST['batch'],'attendence_date'=>$date,'div_id'=>$div_id,'attendence_organization_id'=>Yii::app()->user->getState('org_id')));
		}
		else
		{			
			$check = Attendence::model()->findByAttributes(array('student_attendence_period_id'=>$period_no,'attendence_date'=>$date,'div_id'=>$div_id,'attendence_organization_id'=>Yii::app()->user->getState('org_id')));
		}
		if($check)
		{
			echo "you can not take attendance more than one time.!";
			exit;	
		}
		$count = count($row1);
			
		if($count == 0)
		{
			Yii::app()->user->setFlash('not-select-attendece', "No Student Found for this Criteria");
		}
		
			Yii::app()->user->setState('stud_array',$row1);	
			Yii::app()->user->setState('all_array',$all_array);	
			

		if(isset($_POST['save']))
		{
			$model->employee_id=$all_array['faculty_id'];				
			$model->branch_id=$all_array['branch_id'];
			$model->shift_id=$all_array['shift_id'];
			$model->div_id=$all_array['div_id'];
			$model->batch_id=$all_array['batch_id'];
			$model->sub_id=$all_array['sub_id'];
			$model->sem_id=$all_array['sem_id'];
			$model->sem_name_id=$all_array['sem_name'];
			$model->attendence_date = $all_array['date'];
			$model->student_attendence_period_id = $all_array['period_no'];			   
			$model->attendence_organization_id = Yii::app()->user->getState('org_id');	
			
			foreach($_POST['Attendence']['st_id'] as $index=>$student_id )
			{
				$model->setIsNewRecord(true);
				$model->attendence = 'A';
				if($student_id!=0)
					$model->attendence = 'P';
				
				$model->st_id = $index;		
				$model->id=null;				
		   		$model->save();	
			}
			$this->redirect(array('admin'));
		}

		$this->render('show_student_view',array(
			'model'=>$model,'row1'=>$row1, 'timetabledetail'=>$timetabledetail,
		));
	}
		$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>";
//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>";
}
		//}
		$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($totalcount==0)
		{
			echo '<tr align=center><td >'.++$i.'</td>';
echo '<td colspan=3 align=left>'.$list['subject_master_name'].'('.SubjectType::model()->findByPk($list['subject_master_type_id'])->subject_type_name.")".'</td>';
echo '<td>'.$sem_name.'</td><td>'.$totalcount.'</td><td>'.$precount.'</td><td>'.$percentage.'%</td></tr>';
			
		}
		else
		{
			$percentage = ($precount*100)/$totalcount;
			echo '<tr align=center ><td>'.++$i.'</td><td align=left colspan=3>'.$list['subject_master_name'].'('.SubjectType::model()->findByPk($list['subject_master_type_id'])->subject_type_name.')'.'</td><td>'.$sem_name.'</td><td>'.$totalcount.'</td><td>'.$precount.'</td><td>'.round($percentage,2).'%</td></tr>';
			
		}
		

}
echo '</table>';
}
else
{
	print  "<h1 style=\"color:red;text-align:center\">No Record To Display</h1>";

}


?>
Exemple #16
0
<?php

return array("fields" => array("doc_id" => array("label" => "Doc ID"), "doc_path" => array("label" => "File", "type" => "_document", "modelFile" => "doc_path_file"), "doc_url" => array("label" => "Preview", "type" => "_image"), "doc_name" => array("label" => "Doc Name"), "doc_description" => array("label" => "Doc Description", "type" => "_textarea"), "doc_author_name" => array("label" => "User upload"), "subject_dept" => array("label" => "Department", "type" => "_dropdown", "_list" => array("primary" => "dept_id", "displayAttr" => "dept_name", "src" => function () {
    $rows = Dept::model()->findAll();
    return $rows;
})), "subject_doc" => array("label" => "Subject", "type" => "_dropdown", "_list" => array("primary" => "subject_id", "displayAttr" => "subject_name", "src" => function () {
    $rows = Subject::model()->findAll();
    return $rows;
})), "subject_faculty" => array("label" => "Faculty", "type" => "_dropdown", "_list" => array("primary" => "faculty_id", "displayAttr" => "faculty_name", "src" => function () {
    $rows = Faculty::model()->findAll();
    return $rows;
})), "subject_type" => array("label" => "Subject Type", "type" => "_dropdown", "_list" => array("primary" => "id", "displayAttr" => "subject_type_name", "src" => function () {
    $rows = SubjectType::model()->findAll();
    return $rows;
})), "doc_dept_name" => array("label" => "Department", "src" => "dept.dept_name")), "columns" => array("doc_id", "doc_url", "doc_name", "doc_description", "doc_author_name", "subject_faculty", "doc_dept_name", "doc_path"), "actions" => array("_view" => true, "_edit" => array("doc_name", "doc_description", "doc_author_name", "subject_dept", "subject_faculty", "subject_type"), "_delete" => true, "_new" => array("type" => "popup", "attr" => array("doc_name", "doc_description", "doc_path", "subject_doc"), "extend" => array("doc_author" => Util::param("ADMIN_ID"), "doc_author_name" => "Admin")), "_search" => array("doc_id", "doc_name"), "_search_advanced" => array("doc_author_name", "subject_dept", "subject_faculty", "doc_name"), "_customButtons" => array()), "default" => array("orderBy" => "doc_id", "orderType" => "desc", "page" => 1, "per_page" => 10, "search" => "", "search_advanced" => ""), "join" => array("dept" => array("table" => "select dept_id, dept_name from tbl_dept", "type" => "left join", "selected_properties" => array("dept_name" => "doc_dept_name"), "on" => array("dept_id" => "t.subject_dept"))), "tableAlias" => "document", "title" => "Document Manager", "condition" => false, "limit_values" => array(10, 20, 30, 40), "model" => "Doc", "primary" => "doc_id", "itemLabel" => "Document", "additionalFiles" => array(), "insertScenario" => "fromAdmin", "updateScenario" => "fromAdmin", "formUpload" => TRUE);
Exemple #17
0
 			':acdm_term_name_id' => $_REQUEST['sem_name_id'],
  			':branch_id' => $_REQUEST['branch_id'],
 			
 			));*/
 $subject = Yii::app()->db->createCommand()->select('*')->from('subject_master')->where('subject_master_id in (select sub_id from attendence where attendence="P" and branch_id=' . $_REQUEST['branch_id'] . ' and sem_name_id=' . $_REQUEST['sem_name_id'] . ' and sem_id=' . $_REQUEST['sem_id'] . ')')->queryAll();
 $i = 1;
 $m = 1;
 foreach ($subject as $sub) {
     if ($m % 2 == 0) {
         $class = "odd";
     } else {
         $class = "even";
     }
     echo "<tr class=" . $class . ">";
     echo "<td>" . $i . "</td>";
     echo "<td>" . $sub['subject_master_name'] . '(' . SubjectType::model()->findByPk($sub['subject_master_type_id'])->subject_type_name . ")</td>";
     $attendence = Yii::app()->db->createCommand()->select('attendence')->from('attendence')->where('attendence="P" and branch_id=' . $_REQUEST['branch_id'] . ' and sem_name_id=' . $_REQUEST['sem_name_id'] . ' and sem_id=' . $_REQUEST['sem_id'] . ' and sub_id=' . $sub['subject_master_id'])->queryAll();
     $totalstudent = Yii::app()->db->createCommand()->select('attendence')->from('attendence')->where('branch_id=' . $_REQUEST['branch_id'] . ' and sem_name_id=' . $_REQUEST['sem_name_id'] . ' and sem_id=' . $_REQUEST['sem_id'] . ' and sub_id=' . $sub['subject_master_id'])->queryAll();
     if (count($attendence) != 0) {
         $present = count($attendence) * 100 / count($totalstudent);
     } else {
         $present = 0;
         $absent = 0;
     }
     echo "<td>" . round($present, 2) . "</td>";
     echo "</tr>";
     $i++;
     $m++;
 }
 echo "</table>";
 //echo "Hi";
 public function actionAttendencedivisionreport()
 {
     $model = new Attendence();
     $model->scenario = 'attendencedivisionreport';
     $this->performAjaxValidation($model);
     if (isset($_POST['Attendence']) || isset($_REQUEST['div_id'])) {
         if (isset($_REQUEST['div_id'])) {
             $div = $_REQUEST['div_id'];
         } else {
             $div = $_POST['Attendence']['div_id'];
         }
         $subject = Attendence::model()->findAll(array('select' => 'sub_id', 'distinct' => true, 'condition' => 'div_id=' . $div));
         $all_data = Attendence::model()->findAll(array('select' => 'st_id', 'distinct' => true, 'condition' => 'div_id=' . $div));
         $subjectid = array();
         $total = array();
         $sub = array();
         $present = array();
         foreach ($subject as $list) {
             $data1 = Attendence::model()->findAll(array('condition' => 'sub_id=' . $list['sub_id']));
             $total[] = count($data1);
             $data2 = Attendence::model()->findAll(array('condition' => 'sub_id=' . $list['sub_id'] . " AND attendence='P'"));
             $present[] = count($data2);
             $sub_mod = SubjectMaster::model()->findByPk($list['sub_id']);
             $sub[] = $sub_mod->subject_master_name . "(" . SubjectType::model()->findByPk($sub_mod->subject_master_type_id)->subject_type_name . ")";
             $subjectid[] = $list['sub_id'];
         }
         if (isset($_REQUEST['pdf'])) {
             Yii::import('application.extensions.tcpdf.*');
             require_once 'tcpdf/tcpdf.php';
             require_once 'tcpdf/config/lang/eng.php';
             $html = $this->renderPartial('attendence_division_pdf', array('total' => $total, 'present' => $present, 'subject' => $sub, 'div_id' => $div), true);
             //$session->close();
             //die($html);
             ob_clean();
             $pdf = new TCPDF();
             $pdf->SetCreator(PDF_CREATOR);
             $pdf->SetAuthor(Yii::app()->name);
             $pdf->SetTitle('Division Attendence Report');
             $pdf->SetSubject('Division Attendence Report');
             $pdf->SetKeywords('example, text, report');
             $pdf->SetHeaderData('', 0, "Division Attendence", '');
             //$pdf->SetHeaderData(PDF_HEADER_LOGO, PDF_HEADER_LOGO_WIDTH, "Example Report by ".Yii::app()->name, "");
             $pdf->setHeaderFont(array('helvetica', '', 8));
             $pdf->setFooterFont(array('helvetica', '', 6));
             $pdf->SetMargins(15, 18, 15);
             $pdf->SetHeaderMargin(5);
             $pdf->SetFooterMargin(10);
             $pdf->SetAutoPageBreak(TRUE, 15);
             $pdf->SetFont('dejavusans', '', 7);
             $resolution = array(150, 150);
             $pdf->AddPage('P', $resolution);
             $pdf->writeHTML($html, true, false, true, false, '');
             $pdf->LastPage();
             $pdf->Output("attendenceDivision.pdf", "I");
         } else {
             if (isset($_REQUEST['excel'])) {
                 Yii::app()->request->sendFile(date('YmdHis') . '.xls', $this->renderPartial('attendence_division_pdf', array('total' => $total, 'present' => $present, 'subject' => $sub, 'div_id' => $div), true));
             } else {
                 if (isset($_REQUEST['studentpdf'])) {
                     Yii::import('application.extensions.tcpdf.*');
                     require_once 'tcpdf/tcpdf.php';
                     require_once 'tcpdf/config/lang/eng.php';
                     $html = $this->renderPartial('divisionwise_student_attendance_pdfexcel', array('total' => $total, 'present' => $present, 'subject' => $sub, 'div_id' => $div, 'sub_id' => $subject, 'all_data' => $all_data, 'subjectid' => $subjectid), true);
                     //$session->close();
                     //die($html);
                     ob_clean();
                     $pdf = new TCPDF();
                     $pdf->SetCreator(PDF_CREATOR);
                     $pdf->SetAuthor(Yii::app()->name);
                     $pdf->SetTitle('Division Attendence Report');
                     $pdf->SetSubject('Division Attendence Report');
                     $pdf->SetKeywords('example, text, report');
                     $pdf->SetHeaderData('', 0, "Division Attendence", '');
                     //$pdf->SetHeaderData(PDF_HEADER_LOGO, PDF_HEADER_LOGO_WIDTH, "Example Report by ".Yii::app()->name, "");
                     $pdf->setHeaderFont(array('helvetica', '', 8));
                     $pdf->setFooterFont(array('helvetica', '', 6));
                     $pdf->SetMargins(15, 18, 15);
                     $pdf->SetHeaderMargin(5);
                     $pdf->SetFooterMargin(10);
                     $pdf->SetAutoPageBreak(TRUE, 15);
                     $pdf->SetFont('dejavusans', '', 7);
                     $resolution = array(150, 150);
                     $pdf->AddPage('P', $resolution);
                     $pdf->writeHTML($html, true, false, true, false, '');
                     $pdf->LastPage();
                     $pdf->Output("StudentAttendance.pdf", "I");
                 } else {
                     if (isset($_REQUEST['studentexcel'])) {
                         Yii::app()->request->sendFile(date('YmdHis') . '.xls', $this->renderPartial('divisionwise_student_attendance_pdfexcel', array('total' => $total, 'present' => $present, 'subject' => $sub, 'div_id' => $div, 'sub_id' => $subject, 'all_data' => $all_data, 'subjectid' => $subjectid), true));
                     } else {
                         if (isset($_REQUEST['subject'])) {
                             $this->render('student_subjectwise', array('subject' => $sub, 'sub_id' => $subject, 'all_data' => $all_data, 'subjectid' => $subjectid));
                         } else {
                             $this->render('attendence_division_report_view', array('total' => $total, 'present' => $present, 'subject' => $sub, 'div_id' => $div, 'sub_id' => $subject, 'all_data' => $all_data, 'subjectid' => $subjectid));
                         }
                     }
                 }
             }
         }
     } else {
         $this->render('attendence_division_report', array('model' => $model));
     }
 }
 public static function toString($type_id)
 {
     $subject_type = new SubjectType();
     return $subject_type->getStringFor($type_id);
 }
 public function actionGetsubject()
 {
     $org_id = Yii::app()->user->getState('org_id');
     $sub = array();
     $data1 = array();
     // for update division
     $data1 = SubjectMaster::model()->findAll(array('condition' => 'subject_master_branch_id=' . (int) $_REQUEST['FeedbackMaster']['feedback_branch_id'] . ' and subject_master_academic_terms_name_id=' . (int) $_REQUEST['FeedbackMaster']['feedback_academic_term_id'] . ' and subject_master_organization_id=' . $org_id));
     $data1 = CHtml::listData($data1, 'subject_master_id', 'subject_master_name');
     echo "<option value=''>Select Subject</option>";
     foreach ($data1 as $value1 => $name1) {
         $sub_mas = SubjectMaster::model()->findByPk($value1);
         $type = SubjectType::model()->findByPk($sub_mas->subject_master_type_id)->subject_type_name;
         echo CHtml::tag('option', array('value' => $value1), CHtml::encode($name1 . '(' . $type . ')'), true);
     }
 }
                $output .= '<thead><tr><td><strong>Subject types</strong></td><td><strong>Description</strong></td></tr></thead>';
                foreach ($subjects_collection as $subject) {
                    $output .= '<tr><td>';
                    $output .= '<a href="index.php?p=list_subjects&constraint=subject_type&id=' . $subject->id . '">' . $subject->type_name . '</a>';
                    $output .= '</td>';
                    $output .= '<td>' . $subject->type_description . '</td>';
                    $output .= '</tr>';
                }
                $output .= '</table>';
                echo $output;
            } else {
                echo "false";
            }
            break;
        case "new_subject_type":
            $new_subject_type = new SubjectType();
            $new_subject_type->type_name = $_POST['type_name'];
            $new_subject_type->type_description = $_POST['type_description'];
            $new_subject_type->aspect_group = $_POST['aspect_group'];
            if ((int) $_POST['parent_id'] > 0) {
                $new_subject_type->parent_id = (int) $_POST['parent_id'];
            }
            $new_subject_type->save();
            echo "successfully saved.";
            break;
        default:
            new LogEntry(__FILE__ . " was hit with an invalid action, from IP: " . $_SERVER['HTTP_X_FORWARDED_FOR']);
            echo 'There was an error.  It has been logged.';
    }
} else {
    new LogEntry(__FILE__ . " was hit with no action, from IP: " . $_SERVER['HTTP_X_FORWARDED_FOR']);