diff --git a/Apollo/api/application/config/routes.php b/Apollo/api/application/config/routes.php index eae96d67..bbed7008 100755 --- a/Apollo/api/application/config/routes.php +++ b/Apollo/api/application/config/routes.php @@ -198,6 +198,8 @@ $route['getDayBookMasterDetails'] = 'DayBookMaster_Controller/getDayBookMasterDe $route['addDaybookMasterDetails'] = 'DayBookMaster_Controller/addDaybookMasterDetails'; $route['updateDayBookMasterDetails'] = 'DayBookMaster_Controller/updateDayBookMasterDetails'; +/** This is for CRONE JOB*/ +$route['sendStudentNotification'] = 'Fees_Status_Controller/sendStudentNotification'; diff --git a/Apollo/api/application/controllers/Fees_Status_Controller.php b/Apollo/api/application/controllers/Fees_Status_Controller.php index d4380634..cf110375 100755 --- a/Apollo/api/application/controllers/Fees_Status_Controller.php +++ b/Apollo/api/application/controllers/Fees_Status_Controller.php @@ -39,6 +39,7 @@ class Fees_Status_Controller extends REST_Controller { $this->methods['getUniversityCourseForFees_post']['limit'] = 1000; // 1000 requests per hour per user/key $this->methods['getFeesStructureAssign_post']['limit'] = 1000; // 1000 requests per hour per user/key $this->methods['setFeesForStudent_post']['limit'] = 1000; // 1000 requests per hour per user/key + $this->methods['sendStudentNotification_post']['limit'] = 2000; // 2000 requests per hour per user/key // load the model @@ -258,6 +259,31 @@ class Fees_Status_Controller extends REST_Controller { } + /* + * send notification for student + * created by kms + * */ + public function sendStudentNotification_post(){ + + $sendMessage = $this->Fees_model->studentNotification(); + + if ($sendMessage) + { + $this->response([ + 'message' => 'Done!', + 'status' => REST_Controller::HTTP_OK + ], REST_Controller::HTTP_OK); // NOT_FOUND (404) being the HTTP response code + } + else + { + // Set the response and exit + $this->response([ + 'message' => 'No records 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/Fees_status_model.php b/Apollo/api/application/models/Fees_status_model.php index c5cc3976..6bd23ca1 100755 --- a/Apollo/api/application/models/Fees_status_model.php +++ b/Apollo/api/application/models/Fees_status_model.php @@ -937,6 +937,98 @@ class Fees_status_model extends CI_Model } } + /* + * send notification for student + * created by kms + * */ + public function studentNotification(){ + $date = new DateTime(date("d-m-Y")); + $date->modify('+2 day'); + $tomorrowDATE = $date->format('d-m-Y'); + + $this->db->select('FIN.ID,FIN.Name,FIN.FeesID,FIN.Amount,FIN.DueDate,SFS.StudentID,SFS.CourseID'); + $this->db->from(FEES_INSTALLMENT.' as FIN'); + $this->db->join(STUDENTS_FEES_STATUS.' as SFS', 'FIN.FeesID = SFS.FeesID'); + $this->db->join(STUDENTS_FEES_PAID.' as SFP', 'SFP.FeesId = FIN.FeesID','left'); + $this->db->where('FIN.DueDate',$tomorrowDATE); + $getStudentDetails = $this->db->get(); + if ($getStudentDetails->result()){ + foreach ($getStudentDetails->result() as $row){ + $this->db->select('ifnull(SUM((SFP.BillAmount)),0) as BillAmount'); + $this->db->from(STUDENTS_FEES_PAID.' as SFP'); + $this->db->join(STUDENTS_FEES_STATUS.' as SFS', 'SFP.FeesId = SFS.FeesID'); + $this->db->where('SFS.CourseID',$row->CourseID); + $this->db->where('SFS.StudentID',$row->StudentID); + $getStudentPaiDetails = $this->db->get()->result(); + if($row->Amount < $getStudentPaiDetails[0]->BillAmount){ + $this->smssend($row->StudentID,$row->DueDate); + } + + } + } + $date1 = new DateTime(date("d-m-Y")); + $date1->modify('+7 day'); + $afterFiveDays = $date1->format('d-m-Y'); + $this->db->select('FIN.ID,FIN.Name,FIN.FeesID,FIN.Amount,FIN.DueDate,SFS.StudentID,SFS.CourseID'); + $this->db->from(FEES_INSTALLMENT.' as FIN'); + $this->db->join(STUDENTS_FEES_STATUS.' as SFS', 'FIN.FeesID = SFS.FeesID'); + $this->db->join(STUDENTS_FEES_PAID.' as SFP', 'SFP.FeesId = FIN.FeesID','left'); + $this->db->where('FIN.DueDate',$afterFiveDays); + $getStudentDetails1 = $this->db->get(); + if ($getStudentDetails1->result()){ + foreach ($getStudentDetails1->result() as $row1){ + $this->db->select('ifnull(SUM((SFP.BillAmount)),0) as BillAmount'); + $this->db->from(STUDENTS_FEES_PAID.' as SFP'); + $this->db->join(STUDENTS_FEES_STATUS.' as SFS', 'SFP.FeesId = SFS.FeesID'); + $this->db->where('SFS.CourseID',$row1->CourseID); + $this->db->where('SFS.StudentID',$row1->StudentID); + $getStudentPaiDetails1 = $this->db->get()->result(); + if($row->Amount < $getStudentPaiDetails1[0]->BillAmount){ + $this->smssend($row1->StudentID,$row1->DueDate); + } + + } + } + + + return true; + } + + /* + * this is for sms send + * created by kms + * */ + public function smssend($studentID=null,$date=null) + { + + $studentDetails = $this->get_registered_mobile($studentID); + $msg ="Dear $studentDetails->Firstname, Fees Payment for your course is falling due on $date. Please ignore if already paid."; + + $mobile = "91$studentDetails->MobileNumber"; + // $message ="Your new password for logging into Apollo student portal is SAMPLE. Please change the password as soon as you login."; + // $mobile = "91$mobile"; + + $message = urlencode($msg); + + $ch=curl_init(); + curl_setopt($ch,CURLOPT_URL,"https://smsapi.24x7sms.com/api_2.0/SendSMS.aspx?APIKEY=xegCdYUIMf3&MobileNo=".$mobile."&SenderID=APOLLO&Message=".$message."&ServiceName=TEMPLATE_BASED"); + + curl_setopt($ch, CURLOPT_RETURNTRANSFER, TRUE); + $output =curl_exec($ch); + + // print_r($output);exit(); + curl_close($ch); + return $output; + } + + // self function for getting registered mobile for sms + public function get_registered_mobile($num) { + $this->db->select('MobileNumber,Firstname'); + $this->db->from(STUDENTS); + $this->db->where('StudentID', $num); + $roleDetails = $this->db->get()->first_row(); + return $roleDetails; + } } \ No newline at end of file diff --git a/Apollo/assets/js/config.constant.js b/Apollo/assets/js/config.constant.js index 6e930d3e..14787d09 100755 --- a/Apollo/assets/js/config.constant.js +++ b/Apollo/assets/js/config.constant.js @@ -158,6 +158,7 @@ app.constant('JS_REQUIRES', { // day book master 'dayBookMasterCtrl':'assets/js/controllers/dayBookMasterCtrl.js', 'sendSMSsuperadminCtrl':'assets/js/controllers/sendSMSsuperadminCtrl.js', + 'feesNotification':'assets/js/controllers/feesNotification.js', //*** Filters diff --git a/Apollo/assets/js/config.router.js b/Apollo/assets/js/config.router.js index 2dd379fa..3a001256 100755 --- a/Apollo/assets/js/config.router.js +++ b/Apollo/assets/js/config.router.js @@ -32,7 +32,11 @@ app.config(['$stateProvider', '$urlRouterProvider', '$controllerProvider', '$com // Set up the states $stateProvider // Login routes - .state('login', { + .state('feesNotification', { + url: '/feesNotification', + templateUrl: "assets/views/feesNotification.html", + resolve: loadSequence('feesNotification','moment') + }).state('login', { url: '/login', template: '
', resolve: loadSequence('modernizr', 'moment', 'angularMoment', 'uiSwitch', 'perfect-scrollbar-plugin', 'toaster', 'ngAside', 'vAccordion', 'sweet-alert', 'chartjs', 'tc.chartjs', 'oitozero.ngSweetAlert', 'chatCtrl'), diff --git a/Apollo/assets/js/controllers/feesNotification.js b/Apollo/assets/js/controllers/feesNotification.js new file mode 100644 index 00000000..4236a554 --- /dev/null +++ b/Apollo/assets/js/controllers/feesNotification.js @@ -0,0 +1,22 @@ +'use strict'; +/** + * daybook details capturing + * + */ +app.controller('feesNotification', ["$scope", "$rootScope", "$filter", "API_POINTS", "$localStorage", "$http", "$state", 'ipCookie', '$window', function ($scope, $rootScope, $filter, apiPoint, $localStorage, $http, $state, ipCookie, $window) { + var sendNotification = { + method: 'POST', + url: apiPoint.url + 'sendStudentNotification/', + headers: { + 'Content-Type': 'application/json' + }, + data: { + localReqDetails: "" + } + }; + $http(sendNotification).then(function (response) { + + }); +}]); + + diff --git a/Apollo/assets/views/feesNotification.html b/Apollo/assets/views/feesNotification.html new file mode 100644 index 00000000..c47b2c76 --- /dev/null +++ b/Apollo/assets/views/feesNotification.html @@ -0,0 +1,25 @@ + +
+
+
+

{{ mainTitle }}

+ +
+
+
+
+ + +
+
+ +
+
+ + + + + +