158 lines
5.7 KiB
PHP
Executable File
158 lines
5.7 KiB
PHP
Executable File
<?php
|
|
/**
|
|
* Date: 11/9/17
|
|
* Time: 5:28 PM
|
|
*/
|
|
defined('BASEPATH') OR exit('No direct script access allowed');
|
|
|
|
class Dashboard_model extends CI_Model
|
|
{
|
|
/*
|
|
* dashboard model
|
|
*
|
|
*/
|
|
/*
|
|
* get Dashboard Details
|
|
*/
|
|
|
|
// get total number of users
|
|
public function get_total_users( $data ) {
|
|
$sql1 = "SELECT * from ".STUDENTS."";
|
|
$count1 = $this->db->query($sql1);
|
|
$sql2 = "SELECT * from ".STAFF."";
|
|
$count2 = $this->db->query($sql2);
|
|
|
|
if( $count2->num_rows() > 0) {
|
|
$result['status'] = true;
|
|
$result['total_student'] = $count1->num_rows();
|
|
$result['total_staff'] = $count2->num_rows();
|
|
$result['message'] = "Total Number of Users";
|
|
} else {
|
|
$result['status'] = true;
|
|
$result['total_student'] = $count1->num_rows();
|
|
$result['total_staff'] = $count2->num_rows();
|
|
$result['message'] = "No student Users";
|
|
}
|
|
return $result;
|
|
}
|
|
|
|
// get total number of students
|
|
public function get_total_students($data) {
|
|
// print_r($data);exit();
|
|
$sql = "SELECT * from ".STUDENTS."";
|
|
$count = $this->db->query($sql);
|
|
if( $count->num_rows() > 0) {
|
|
$result['status'] = true;
|
|
$result['total_student'] = $count->num_rows();
|
|
$result['message'] = "Total Number of Students";
|
|
} else {
|
|
$result['status'] = true;
|
|
$result['total_student'] = $count->num_rows();
|
|
$result['message'] = "No student exist";
|
|
}
|
|
return $result;
|
|
}
|
|
|
|
// get total number of employees
|
|
public function get_total_employee($data) {
|
|
// print_r($data);exit();
|
|
$sql = "SELECT * from ".STAFF."";
|
|
$count = $this->db->query($sql);
|
|
if( $count->num_rows() > 0) {
|
|
$result['status'] = true;
|
|
$result['total_employee'] = $count->num_rows();
|
|
$result['message'] = "Total Number of Employee";
|
|
} else {
|
|
$result['status'] = true;
|
|
$result['total_employee'] = $count->num_rows();
|
|
$result['message'] = "No Employee exist";
|
|
}
|
|
return $result;
|
|
}
|
|
/*
|
|
* get university registerd student details
|
|
* created by kms
|
|
* */
|
|
public function get_univ_registered_student($details){
|
|
$this->db->distinct();
|
|
$this->db->select('UniversityID,UniversityName');
|
|
$this->db->from(UNIVERSITY);
|
|
$this->db->order_by('ID','DESC');
|
|
$this->db->where('BranchCode',$details['localBranchID']);
|
|
$getUnivDetails = $this->db->get();
|
|
if($getUnivDetails->result()){
|
|
$resultDetails['resultStatus']=true;
|
|
foreach ($getUnivDetails->result() as $rows){
|
|
$fetchDetails['UniversityID']=$rows->UniversityID;
|
|
$fetchDetails['UniversityName']=$rows->UniversityName;
|
|
$this->db->select('StudentID');
|
|
$this->db->from(STUDENTCOURSE);
|
|
$this->db->where('BranchID',$details['localBranchID']);
|
|
$this->db->where('UniversityID',$rows->UniversityID);
|
|
$getRegisterDetails = $this->db->get();
|
|
if($getRegisterDetails->num_rows()>0){
|
|
$fetchDetails['StudentCounts']=$getRegisterDetails->num_rows();
|
|
}
|
|
else{
|
|
$fetchDetails['StudentCounts']=0;
|
|
}
|
|
$getArray[]=$fetchDetails;
|
|
$getFeesArray[]= $this->getUniversityFeesPending($rows->UniversityName,$rows->UniversityID,$details['localBranchID']);
|
|
}
|
|
$resultDetails['details']=$getArray;
|
|
$resultDetails['universityFeesDetails']=$getFeesArray;
|
|
}
|
|
else{
|
|
$resultDetails['resultStatus']=false;
|
|
$resultDetails['Message']="No records found!";
|
|
}
|
|
return $resultDetails;
|
|
}
|
|
/*
|
|
* get university pending fees details
|
|
* created by kms
|
|
* */
|
|
public function getUniversityFeesPending($universityName=null,$universityID=null,$branchCode=null){
|
|
$feesDetails=array();
|
|
$feesDetails['UniversityID']=$universityID;
|
|
$feesDetails['UniversityName']=$universityName;
|
|
|
|
$this->db->select("SUM(SFS.CourseFees) as PayableFees");
|
|
$this->db->from( STUDENTS_FEES_STATUS . ' as SFS');
|
|
$this->db->join( COURSE . ' as CU', 'CU.CourseID = SFS.CourseID');
|
|
$this->db->where('CU.UniversityID',$universityID);
|
|
$this->db->where('CU.BranchCode',$branchCode);
|
|
$this->db->order_by('CU.CourseID','DESC');
|
|
$getUnivFeesDetails = $this->db->get();
|
|
if($getUnivFeesDetails->result()){
|
|
foreach ($getUnivFeesDetails->result() as $payableRow){
|
|
$feesDetails['PayableFees']=$payableRow->PayableFees;
|
|
}
|
|
}
|
|
else{
|
|
$feesDetails['PayableFees']=0;
|
|
}
|
|
$this->db->select("SUM(SFP.BillAmount) as PaidFees");
|
|
$this->db->from( STUDENTS_FEES_PAID . ' as SFP');
|
|
$this->db->join( STUDENTS_FEES_STATUS . ' as SFS', 'SFS.FeesID = SFP.FeesId');
|
|
$this->db->join( COURSE . ' as CU', 'CU.CourseID = SFS.CourseID');
|
|
$this->db->where('CU.UniversityID',$universityID);
|
|
$this->db->where('CU.BranchCode',$branchCode);
|
|
$this->db->order_by('CU.CourseID','DESC');
|
|
$getUnivPaidFeesDetails = $this->db->get();
|
|
if($getUnivPaidFeesDetails->result()){
|
|
foreach ($getUnivPaidFeesDetails->result() as $paidRow){
|
|
$feesDetails['PaidFees']=$paidRow->PaidFees;
|
|
}
|
|
}
|
|
else{
|
|
$feesDetails['PaidFees']=0;
|
|
}
|
|
|
|
return $feesDetails;
|
|
|
|
|
|
}
|
|
|
|
|
|
} |