diff --git a/Apollo/api/application/controllers/Batch_Controller.php b/Apollo/api/application/controllers/Batch_Controller.php new file mode 100644 index 00000000..09156b66 --- /dev/null +++ b/Apollo/api/application/controllers/Batch_Controller.php @@ -0,0 +1,115 @@ +methods['addBatchDetails_get']['limit'] = 500; // 500 requests per hour per user/key + $this->methods['addBatchDetails_post']['limit'] = 100; // 100 requests per hour per user/key + $this->methods['addBatchDetails_delete']['limit'] = 50; // 50 requests per hour per user/key + $this->methods['getBatchDetails_post']['limit'] = 500; // 50 requests per hour per user/key + $this->methods['updateBatchDetails_post']['limit'] = 500;// 500 requests per hour per user/key + // load the model + $this->load->model('Batch_model', 'batch_model'); + + } + + /* + * This method used to add batch details + * created by srk + * */ + + public function addBatchDetails_post() + { + + $details['BatchCode'] = $this->post('batchcode'); + $details['BatchName'] = $this->post('batcheName'); + $details['UniversityID'] = $this->post('universityName'); + $details['CreatedBy'] = $this->post('createdBy'); + $details['IsActive'] = $this->post('status'); + $batchDetails = $this->batch_model->addBatch($details);// Check if the users data store contains users (in case the database result returns NULL) + if ($batchDetails) + { + $batchDetails['status'] = REST_Controller::HTTP_OK; + // Set the response and exit + $this->response($batchDetails, REST_Controller::HTTP_OK); // OK (200) being the HTTP response code + } + else + { + // Set the response and exit + $this->response([ + 'message' => 'Something went wrong.please try again!', + 'status' => REST_Controller::HTTP_NOT_FOUND + ], REST_Controller::HTTP_NOT_FOUND); // NOT_FOUND (404) being the HTTP response code + } + + + } + /* + * get Batch details + * created by srk + * */ + public function getBatchDetails_post() + { + $requestedBy = $this->post('requestedBy'); + $getBatch = $this->batch_model->getBatch($requestedBy); + if ($getBatch) + { + $getBatch['status'] = REST_Controller::HTTP_OK; + // Set the response and exit + $this->response($getBatch, REST_Controller::HTTP_OK); // OK (200) 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 + } + + + } + /* + * update the batch details + * created by srk + * */ + public function updateBatchDetails_post() + { + $details['BatchCode'] = $this->post('batchCode'); + $details['BatchName'] = $this->post('batchName'); + $details['IsActive'] = $this->post('status'); + $details['UpdatedBy'] = $this->post('updatedBy'); + $details['UpdatedOn'] = date("Y-m-d", time()); + $updateDetails = $this->batch_model->updateBatch($details);// Check if the users data store contains users (in case the database result returns NULL) + + if ($updateDetails) + { + $updateDetails['status'] = REST_Controller::HTTP_OK; + // Set the response and exit + $this->response($updateDetails, REST_Controller::HTTP_OK); // OK (200) being the HTTP response code + } + else + { + // Set the response and exit + $this->response([ + 'message' => 'Something went wrong.please try again!', + 'status' => REST_Controller::HTTP_NOT_FOUND + ], REST_Controller::HTTP_NOT_FOUND); // NOT_FOUND (404) being the HTTP response code + } + + + } + + +} \ No newline at end of file diff --git a/Apollo/api/application/models/Batch_model.php b/Apollo/api/application/models/Batch_model.php new file mode 100644 index 00000000..e827cad0 --- /dev/null +++ b/Apollo/api/application/models/Batch_model.php @@ -0,0 +1,111 @@ +db->select('BatchCode'); + $this->db->where('BatchCode', $arrayDetails['BatchCode']); + if($this->db->get(T_BATCHMASTER)->first_row()){ + $result['batchStatus'] = false; + $result['message'] = "This batch Code is already exist!"; + } else { + $this->db->insert(T_BATCHMASTER, $arrayDetails); + if ($this->db->affected_rows() == '1') { + + $result['batchStatus'] = true; + $result['message'] = "Successfully Batch details added"; + } else { + $result['batchStatus'] = false; + $result['message'] = "Something went wrong.please try again"; + } + } + return $result; + + } + + + /* + * Get batch details + * parama id + * created by srk + * */ + + public function getBatch() + { + $this->db->select('CU.BatchCode,CU.BatchName,CU.IsActive,US.UniversityID,US.UniversityName'); + $this->db->from(T_BATCHMASTER.' as CU'); + $this->db->join(UNIVERSITY.' as US', 'US.UniversityID = CU.UniversityID'); + $this->db->order_by('CU.CreatedOn','DESC'); + $batchDetails = $this->db->get(); + + if($batchDetails->result()){ + + $result['batchStatus'] = true; + $result['details'] = $batchDetails->result(); + } + else { + $result['batchStatus'] = false; + $result['message'] = "No records found!"; + } + + $result['universityDetails'] = $this->getUniversityDetails(); + + return $result; + + } + + /* + * update batch details + * created by Srk + * */ + public function updateBatch($arrayDetails=null) + { + $this->db->where('BatchCode',$arrayDetails['BatchCode']); + $upateStatus=$this->db->update(T_BATCHMASTER, $arrayDetails); + if($upateStatus){ + + $result['batchStatus'] = true; + $result['message'] = "Successfully Batch details updated"; + } + + else { + $result['batchStatus'] = false; + $result['message'] = "Something went wrong.please try again"; + + } + + + return $result; + + } + /* + * Get university details + * created by Srk + * */ + public function getUniversityDetails()//doubt + { + $this->db->select('UniversityID,UniversityName'); + $this->db->order_by('UniversityID','ASC'); + $this->db->order_by('IsActive','1'); + $universityDetails = $this->db->get(UNIVERSITY); + return $universityDetails->result(); + } + + + +} \ No newline at end of file diff --git a/Apollo/assets/js/controllers/batchCtrl.js b/Apollo/assets/js/controllers/batchCtrl.js new file mode 100644 index 00000000..3dc68394 --- /dev/null +++ b/Apollo/assets/js/controllers/batchCtrl.js @@ -0,0 +1,208 @@ +'use strict'; +/** + * controllers for ng-table + * Simple table with sorting and filtering on AngularJS + */ + +app.controller('batchCtrl', ["$scope","$rootScope","toaster", "$filter", "ngTableParams", "API_POINTS", "$localStorage", "$http", "$state", function ($scope,$rootScope,toaster, $filter, ngTableParams, apiPoint, $localStorage, $http, $state) { + $scope.myModel = { + "batchCode": "", + "batchName": "", + "universityName":"", + "switchsetting": true + }; + + + /* + * edit batch details + * created by subaram + * */ + $scope.editId = -1; + $scope.setEditId = function (pid) { + + $scope.editId = pid; + $scope.viewId = -1; + }; + + /* + * cancel edit div + * created by subaram + * */ + $scope.cancel = function () { + $scope.init(); + $scope.editId = -1; + + }; + + // sorting function for table params + $scope.sort = function(keyname){ + $scope.sortKey = keyname; //set the sortKey to the param passed + $scope.reverse = !$scope.reverse; //if true make it false and vice versa + } + + /* + * Submit,update and reset batch details + * @params myModel + * created by subaram + * */ + $scope.batchForm = { + + submit: function (form, myModel,loading) { + var firstError = null; + if (form.$invalid) { + var field = null, firstError = null; + for (field in form) { + if (field[0] != '$') { + if (firstError === null && !form[field].$valid) { + firstError = form[field].$name; + } + if (form[field].$pristine) { + form[field].$dirty = true; + } + } + } + angular.element('.ng-invalid[name=' + firstError + ']').focus(); + // swal("The form cannot be submitted because it contains validation errors!", "Errors are marked with a red, dashed border!", "error"); + } else { + + $scope.ldloading1 = {}; + + $scope.ldloading1[loading.replace('-', '_')] = true; + + + var addBatch = { + method: 'POST', + url: apiPoint.url + 'addBatchDetails/', + headers: { + 'Content-Type': 'application/json' + }, + data: { + batchcode: myModel.batchCode, + batcheName: myModel.batchName, + universityName: myModel.universityName, + status: myModel.switchsetting, + createdBy: JSON.parse(localStorage.getItem('localObj')).localUserID + } + }; + $http(addBatch).then(function (response) { + if (response.data.status==200 && response.data.batchStatus) { + $scope.ldloading1[loading.replace('-', '_')] = false; + swal("Success!", response.data.message, "success"); + $state.go($state.current, {}, {reload: true}); + } else { + $scope.ldloading1[loading.replace('-', '_')] = false; + swal("Failed!", response.data.message, "error"); + } + }); + + + } + }, + reset: function (form) { + + $scope.myModel = angular.copy($scope.master); + form.$setPristine(true); + } + }; + /* + * update the batch details + * created by subaram + * */ + $scope.updateBatch = function (myModel, form, loading) { + + var firstError = null; + if (form.$invalid) { + var field = null, firstError = null; + for (field in form) { + if (field[0] != '$') { + if (firstError === null && !form[field].$valid) { + firstError = form[field].$stop_name; + } + + if (form[field].$pristine) { + form[field].$dirty = true; + } + } + } + angular.element('.ng-invalid[name=' + firstError + ']').focus(); + } else { + $scope.ldloading = {}; + + $scope.ldloading[loading.replace('-', '_')] = true; + + + var update = { + method: 'POST', + url: apiPoint.url + 'updateBatchDetails/', + headers: { + 'Content-Type': 'application/json' + }, + data: { + batchCode: myModel.BatchCode, + batchName: myModel.BatchName, + status: myModel.IsActive, + createdBy: JSON.parse(localStorage.getItem('localObj')).localUserID + } + }; + $http(update).then(function (response) { + if (response.data.status==200 && response.data.batchStatus) { + $scope.ldloading[loading.replace('-', '_')] = false; + $scope.editId = -1; + $scope.init(); + swal("Success!", response.data.message, "success"); + + + } else { + $scope.ldloading[loading.replace('-', '_')] = false; + swal("Failed!", response.data.message, "error"); + } + }); + } + }; + /* + *get Batch details when page loading called from view file + * + * created by Srk + * */ + $scope.loader=''; + + $scope.emptyData=''; + + $rootScope.init = function () { + + var getBranch = { + method: 'POST', + url: apiPoint.url + 'getBatchDetails/', + headers: { + 'Content-Type': 'application/json' + }, + data: { + requestedBy: JSON.parse(localStorage.getItem('localObj')).localUserID + } + }; + + $http(getBranch).then(function (response) { + if (response.data.status==200 && response.data.batchStatus) { + + $scope.emptyData=true; + $scope.loader=true; + + $scope.data = response.data.details; + + $scope.university=response.data.universityDetails; + + + + } else { + $scope.emptyData=false; + $scope.loader=false; + $scope.university=response.data.universityDetails; + + } + }); + }; + + + + +}]); diff --git a/Apollo/assets/views/batch.html b/Apollo/assets/views/batch.html new file mode 100644 index 00000000..1cc22c06 --- /dev/null +++ b/Apollo/assets/views/batch.html @@ -0,0 +1,229 @@ + + +
+
+
+

+ +
+
+
+
+ + +
+
+ + +
+
+
+ +
Please Wait...
+
+
+ +
+

oops! No + records found...

+
+
+
+ +
+ +

+
+ + +
+ +
+
+ + + + + + + + + + + + + + + + + + + + + + + + + + + +
Batch Code + + Batch Name + + University Name + + Action
{{p.BatchCode}}{{p.BatchName}}{{p.UniversityName}} + + + + +
+ + +
+
+ +
+
+
+ + +
+ + + +
+
+
+ +
+
+ + Add New Batch Details + + +
+
+ + + + Batch code is required + Invalid course id + +
+ + +
+ + + + Batch name is required + Invalid batch name + + +
+ +
+ + + University is required + +
+
+ +
+
+ + +
+
+ + +
+ + +
+ + +
+
+ +
+
+
+
+ + + +
+
+
+
+
+
+
+
+
+
+
+ + + + + +