From e784725a169b3bf923d2ddda507dcaef886b365d Mon Sep 17 00:00:00 2001 From: resicovenba Date: Thu, 30 Nov 2017 18:17:44 +0530 Subject: [PATCH] total student get for dashboard- backend --- Apollo/api/application/config/config.php | 1 + Apollo/api/application/config/routes.php | 2 + .../controllers/Dashboard_Controller.php | 74 +++++++++++++++++++ .../application/models/Dashboard_model.php | 53 +++++++++++++ Apollo/assets/js/controllers/studentCtrl.js | 46 +++++++++++- .../assets/views/student/student_details.html | 16 ++-- 6 files changed, 180 insertions(+), 12 deletions(-) create mode 100644 Apollo/api/application/controllers/Dashboard_Controller.php create mode 100644 Apollo/api/application/models/Dashboard_model.php diff --git a/Apollo/api/application/config/config.php b/Apollo/api/application/config/config.php index f1102abc..f2dbc7a0 100644 --- a/Apollo/api/application/config/config.php +++ b/Apollo/api/application/config/config.php @@ -479,6 +479,7 @@ $config['compress_output'] = FALSE; | */ $config['time_reference'] = 'local'; +date_default_timezone_set('Asia/Kolkata'); /* |-------------------------------------------------------------------------- diff --git a/Apollo/api/application/config/routes.php b/Apollo/api/application/config/routes.php index e5099bd2..2677b15b 100644 --- a/Apollo/api/application/config/routes.php +++ b/Apollo/api/application/config/routes.php @@ -122,6 +122,8 @@ $route['updateAnnouncementDetails'] = 'Announcement_Controller/updateAnnouncemen // dash board $route['getDashboardCallTrack'] = 'Call_Tracking_Controller/getDashboardCallTrack'; +$route['getTotalStudent'] = 'Dashboard_Controller/getTotalStudent'; +$route['getTotalEmployee'] = 'Dashboard_Controller/getTotalEmployee'; diff --git a/Apollo/api/application/controllers/Dashboard_Controller.php b/Apollo/api/application/controllers/Dashboard_Controller.php new file mode 100644 index 00000000..fdd7a12d --- /dev/null +++ b/Apollo/api/application/controllers/Dashboard_Controller.php @@ -0,0 +1,74 @@ +load->model('Dashboard_model', 'dashboard_model'); + } + + public function getTotalStudent_post() { + $data = $this->post('data'); + $totalStudents = $this->dashboard_model->get_total_students( $data );// Check if the employee exist + if ($totalStudents) { + $totalStudents['status'] = REST_Controller::HTTP_OK; + // Set the response and exit + $this->response($totalStudents, REST_Controller::HTTP_OK); // OK (200) being the HTTP response code + } + else + { + // Set the response and exit + $this->response([ + 'message' => 'No users were found', + 'status' => REST_Controller::HTTP_NOT_FOUND + ], REST_Controller::HTTP_NOT_FOUND); // NOT_FOUND (404) being the HTTP response code + } + } + + public function getTotalEmployee_post() { + $data = $this->post('data'); + $totalEmployee = $this->dashboard_model->get_total_employee( $data );// Check if the employee exist + if ($totalEmployee) { + $totalEmployee['status'] = REST_Controller::HTTP_OK; + // Set the response and exit + $this->response($totalEmployee, REST_Controller::HTTP_OK); // OK (200) being the HTTP response code + } + else + { + // Set the response and exit + $this->response([ + 'message' => 'No users were found', + 'status' => REST_Controller::HTTP_NOT_FOUND + ], REST_Controller::HTTP_NOT_FOUND); // NOT_FOUND (404) being the HTTP response code + } + } +} diff --git a/Apollo/api/application/models/Dashboard_model.php b/Apollo/api/application/models/Dashboard_model.php new file mode 100644 index 00000000..a6ba70be --- /dev/null +++ b/Apollo/api/application/models/Dashboard_model.php @@ -0,0 +1,53 @@ +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; + } + + +} \ No newline at end of file diff --git a/Apollo/assets/js/controllers/studentCtrl.js b/Apollo/assets/js/controllers/studentCtrl.js index 7d3178b4..7e097692 100644 --- a/Apollo/assets/js/controllers/studentCtrl.js +++ b/Apollo/assets/js/controllers/studentCtrl.js @@ -45,14 +45,24 @@ app.controller('studentCtrl', ["$scope", "toaster", "$filter", "ngTableParams", 'enrollmentid': '' }; - $scope.addStudentView = function () { - $scope.myModelCourse = { + $scope.myModelCourseAdd = { 'university': '', 'course': '', 'batch': '', 'dateofjoining': '', 'enrollmentid': '' }; + + $scope.addStudentView = function () { + // $scope.myModelCourseAdd = { + // 'university': '', + // 'course': '', + // 'batch': '', + // 'dateofjoining': '', + // 'enrollmentid': '' + // }; + // $scope.courseDataAdd = ''; + // $scope.batchDataAdd = ''; } @@ -359,6 +369,34 @@ app.controller('studentCtrl', ["$scope", "toaster", "$filter", "ngTableParams", }); } + + $scope.onSlecetUnivAdd = function () { + $scope.courseDataAdd = ''; + $scope.batchDataAdd = ''; + $scope.myModelCourseAdd.course = ''; + $scope.myModelCourseAdd.batch = ''; + $scope.courseLoading = true; + var univListreq = { + method: 'POST', + url: apiPoint.url + 'getCourseBatchForUniv/', + headers: { + 'Content-Type': 'application/json' + }, + data: { + data: $scope.myModelCourseAdd.university + } + }; + $http(univListreq).then(function (response) { + if (response.data.courseStatus) { + $scope.courseLoading = false; + $scope.courseDataAdd = response.data.course_details; + $scope.batchDataAdd = response.data.batch_details; + } else { + $scope.courseLoading = false; + } + }); + } + // check mobile number existing $scope.checkMobileExist = function () { var checkReq = { @@ -405,7 +443,7 @@ app.controller('studentCtrl', ["$scope", "toaster", "$filter", "ngTableParams", // add student $scope.studentFORM = { - submit: function (form, myModel, myModelCourse) { + submit: function (form, myModel, myModelCourseAdd) { var firstError = null; if (form.$invalid) { var field = null, firstError = null; @@ -435,7 +473,7 @@ app.controller('studentCtrl', ["$scope", "toaster", "$filter", "ngTableParams", }, data: { data: $scope.myModel, - coursedata: $scope.myModelCourse, + coursedata: $scope.myModelCourseAdd, loginBranch: localDetails.localBranchID, createdBy: localDetails.localUserID, } diff --git a/Apollo/assets/views/student/student_details.html b/Apollo/assets/views/student/student_details.html index 4ef9e509..78dab80b 100644 --- a/Apollo/assets/views/student/student_details.html +++ b/Apollo/assets/views/student/student_details.html @@ -412,8 +412,8 @@ University - @@ -429,10 +429,10 @@ fetching...
-
Course is required @@ -448,10 +448,10 @@ fetching...
-
Batch is required @@ -464,7 +464,7 @@ Enrollment ID Enrollment ID required @@ -479,7 +479,7 @@ /*top: -225px !important;*/ } -