From 867177d498fbae0bc46d9d4779d87cce082adbca Mon Sep 17 00:00:00 2001 From: resicovenba Date: Sat, 23 Dec 2017 12:46:14 +0530 Subject: [PATCH 1/2] update daybook details: kdk --- Apollo/api/application/config/constants.php | 2 + Apollo/api/application/config/routes.php | 11 + .../controllers/DayBook_Controller.php | 217 +++++++ .../api/application/models/DayBook_model.php | 145 +++++ Apollo/assets/js/config.constant.js | 7 +- Apollo/assets/js/config.router.js | 19 +- Apollo/assets/js/controllers/daybookCtrl.js | 272 +++++++++ .../assets/js/controllers/daybookadminCtrl.js | 530 ++++++++++++++++++ .../js/controllers/daybooksuperadminCtrl.js | 524 +++++++++++++++++ Apollo/assets/views/daybook/daybook.html | 276 +++++++++ Apollo/assets/views/daybook/daybookadmin.html | 240 ++++++++ .../views/daybook/daybooksuperadmin.html | 237 ++++++++ Apollo/assets/views/partials/nav.html | 36 ++ 13 files changed, 2514 insertions(+), 2 deletions(-) create mode 100644 Apollo/api/application/controllers/DayBook_Controller.php create mode 100644 Apollo/api/application/models/DayBook_model.php create mode 100644 Apollo/assets/js/controllers/daybookCtrl.js create mode 100644 Apollo/assets/js/controllers/daybookadminCtrl.js create mode 100644 Apollo/assets/js/controllers/daybooksuperadminCtrl.js create mode 100644 Apollo/assets/views/daybook/daybook.html create mode 100644 Apollo/assets/views/daybook/daybookadmin.html create mode 100644 Apollo/assets/views/daybook/daybooksuperadmin.html diff --git a/Apollo/api/application/config/constants.php b/Apollo/api/application/config/constants.php index 557b5b01..158d7fbd 100755 --- a/Apollo/api/application/config/constants.php +++ b/Apollo/api/application/config/constants.php @@ -125,6 +125,8 @@ defined('STUDY_MATERIAL_STATUS') OR define('STUDY_MATERIAL_STATUS','T_StudyMater defined('CERTIFICATION') OR define('CERTIFICATION','T_CertificationMaster'); defined('DEFAULTACTIVITY') OR define('DEFAULTACTIVITY','T_StatusMaster'); defined('CERTIFICATION_MASTER') OR define('CERTIFICATION_MASTER','T_CertificationMaster'); +defined('DAYBOOKMASTER') OR define('DAYBOOKMASTER','T_DayBookMaster'); +defined('INCOMEOUTCOMEMASTER') OR define('INCOMEOUTCOMEMASTER','T_Income_Outcome_Master'); diff --git a/Apollo/api/application/config/routes.php b/Apollo/api/application/config/routes.php index 76f62ad5..960d211b 100755 --- a/Apollo/api/application/config/routes.php +++ b/Apollo/api/application/config/routes.php @@ -172,6 +172,17 @@ $route['getStudentBasicInfo'] = 'StudentView_Controller/getStudentInfo'; $route['getCertificateDetails'] = 'Certificate_Controller/getCertificateDetails'; $route['addCertificateDetails'] = 'Certificate_Controller/addCertificateDetails'; $route['updateCertificateDetails'] = 'Certificate_Controller/updateCertificateDetails'; +/* + * Day Book + * */ +$route['deleteDayBookDetails'] = 'DayBook_Controller/deleteDayBookDetails'; +$route['updateDayBookDetails'] = 'DayBook_Controller/updateDayBookDetails'; +$route['getDayBookDetails'] = 'DayBook_Controller/getDayBookDetails'; +$route['getIncomeExpenseTypeState'] = 'DayBook_Controller/getIncomeExpenseTypeState'; +$route['addDayBook'] = 'DayBook_Controller/adddaybook'; +$route['updateDayBookStatusAdmin'] = 'DayBook_Controller/updateDayBookStatusAdmin'; +$route['getDayBookDetailsSuperAdmin'] = 'DayBook_Controller/getDayBookDetailsSuperAdmin'; + diff --git a/Apollo/api/application/controllers/DayBook_Controller.php b/Apollo/api/application/controllers/DayBook_Controller.php new file mode 100644 index 00000000..99cfbe37 --- /dev/null +++ b/Apollo/api/application/controllers/DayBook_Controller.php @@ -0,0 +1,217 @@ +load->model('DayBook_model', 'daybook_model'); + } + + //get income expese type, name details + public function getIncomeExpenseTypeState_post() { + $reqData = $this->post('data'); + $getIncomeExpenseTypeState = $this->daybook_model->get_Income_Expense_typeState();// Check if the employee exist + if ($getIncomeExpenseTypeState) + { + $getIncomeExpenseTypeState['status'] = REST_Controller::HTTP_OK; + // Set the response and exit + $this->response($getIncomeExpenseTypeState, REST_Controller::HTTP_OK); // OK (200) being the HTTP response code + } + else + { + // Set the response and exit + $this->response([ + 'message' => 'No list were found', + 'status' => REST_Controller::HTTP_NOT_FOUND + ], REST_Controller::HTTP_NOT_FOUND); // NOT_FOUND (404) being the HTTP response code + } + } + + // {"data":{"date":"22-12-2017"},"localReqDetails":{"localUserID":"137","localBranchID":"001","localType":"R002","localOn":"2017-12-22T12:45:19.688Z","status":"active"}} + + // get all daybook details + public function getDayBookDetails_post() { + $reqData = $this->post('data'); + $reqDataBy = $this->post('localReqDetails'); + $getDayBookDetails = $this->daybook_model->get_Daybook_Details_List($reqData, $reqDataBy);// Check if the employee exist + if ($getDayBookDetails) + { + $getDayBookDetails['status'] = REST_Controller::HTTP_OK; + // Set the response and exit + $this->response($getDayBookDetails, REST_Controller::HTTP_OK); // OK (200) being the HTTP response code + } + else + { + // Set the response and exit + $this->response([ + 'message' => 'No list were found', + 'status' => REST_Controller::HTTP_NOT_FOUND + ], REST_Controller::HTTP_NOT_FOUND); // NOT_FOUND (404) being the HTTP response code + } + + } + + public function deleteDayBookDetails_post() { + $reqData = $this->post('data'); + $reqbyData = $this->post('localReqDetails'); + $deletedayBookDetails = $this->daybook_model->delete_dayBookDetails($reqData);// Check if the employee exist + if ($deletedayBookDetails) + { + $deletedayBookDetails['status'] = REST_Controller::HTTP_OK; + // Set the response and exit + $this->response($deletedayBookDetails, REST_Controller::HTTP_OK); // OK (200) being the HTTP response code + } + else + { + // Set the response and exit + $this->response([ + 'message' => 'No list were found', + 'status' => REST_Controller::HTTP_NOT_FOUND + ], REST_Controller::HTTP_NOT_FOUND); // NOT_FOUND (404) being the HTTP response code + } + } + + public function updateDayBookDetails_post() { + $reqData = $this->post('data'); + $reqbyData = $this->post('localReqDetails'); + + $updateFor = $reqData['id']; + $req['Type'] = $reqData['type']; + $req['Amount'] = $reqData['amount']; + $req['Description'] = $reqData['description']; + $req['UpdatedBy'] = $reqbyData['localUserID']; + $date = date('Y-m-d H:i:s'); + $req['UpdatedOn'] = $date; + $updatedayBookDetails = $this->daybook_model->update_dayBookDetails($req , $updateFor);// Check if the employee exist + if ($updatedayBookDetails) + { + $updatedayBookDetails['status'] = REST_Controller::HTTP_OK; + // Set the response and exit + $this->response($updatedayBookDetails, REST_Controller::HTTP_OK); // OK (200) being the HTTP response code + } + else + { + // Set the response and exit + $this->response([ + 'message' => 'No list were found', + 'status' => REST_Controller::HTTP_NOT_FOUND + ], REST_Controller::HTTP_NOT_FOUND); // NOT_FOUND (404) being the HTTP response code + } + } + + // add details daybook + public function adddaybook_post() { + $reqData = $this->post('data'); + $reqbyData = $this->post('localReqDetails'); + + $req['Name'] = $reqData['name']; + $req['Type'] = $reqData['type']; + $req['Amount'] = $reqData['amount']; + $req['Date'] = $reqData['date']; + $req['Status'] = $reqData['status']; + $req['Description'] = $reqData['description']; + $req['BranchCode'] = $reqbyData['localBranchID']; + $req['CreatedBy'] = $reqbyData['localUserID']; + $date = date('Y-m-d H:i:s'); + $req['CreatedOn'] = $date; + $addDayBookDetails = $this->daybook_model->add_dayBook($req);// Check if the employee exist + if ($addDayBookDetails) + { + $addDayBookDetails['status'] = REST_Controller::HTTP_OK; + // Set the response and exit + $this->response($addDayBookDetails, REST_Controller::HTTP_OK); // OK (200) being the HTTP response code + } + else + { + // Set the response and exit + $this->response([ + 'message' => 'No list were found', + 'status' => REST_Controller::HTTP_NOT_FOUND + ], REST_Controller::HTTP_NOT_FOUND); // NOT_FOUND (404) being the HTTP response code + } + } + + public function updateDayBookStatusAdmin_post() { + + $reqData = $this->post('data'); + $reqDetails = $this->post('requestDetails'); + + $time = date('Y-m-d H:i:s'); + $dateTime = $time; + + $count = count($reqData); + + for($i=0; $i < $count; $i++) { + $data[] = array( + 'ID' => $reqData[$i]['dabookListId'], + 'Approval_By' => $reqDetails['localUserID'], + 'Status' => $reqData[$i]['ListCodeStatus'], + 'Approval_Comments' => $reqData[$i]['comments'], + 'UpdatedBy' => $reqDetails['localUserID'], + 'UpdatedOn' => $dateTime, + ); + } + + $updateStatusAdminDetails = $this->daybook_model->update_status_admin($data);// Check if the employee exist + if ($updateStatusAdminDetails) + { + $updateStatusAdminDetails['status'] = REST_Controller::HTTP_OK; + // Set the response and exit + $this->response($updateStatusAdminDetails, REST_Controller::HTTP_OK); // OK (200) being the HTTP response code + } + else + { + // Set the response and exit + $this->response([ + 'message' => 'No list were found', + 'status' => REST_Controller::HTTP_NOT_FOUND + ], REST_Controller::HTTP_NOT_FOUND); // NOT_FOUND (404) being the HTTP response code + } + + } + public function getDayBookDetailsSuperAdmin_post() { + $reqData = $this->post('data'); + $reqDataBy = $this->post('localReqDetails'); + $getDayBookDetails = $this->daybook_model->get_Daybook_Details_List_superAdmin($reqData, $reqDataBy);// Check if the employee exist + if ($getDayBookDetails) + { + $getDayBookDetails['status'] = REST_Controller::HTTP_OK; + // Set the response and exit + $this->response($getDayBookDetails, REST_Controller::HTTP_OK); // OK (200) being the HTTP response code + } + else + { + // Set the response and exit + $this->response([ + 'message' => 'No list 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/DayBook_model.php b/Apollo/api/application/models/DayBook_model.php new file mode 100644 index 00000000..cd363afe --- /dev/null +++ b/Apollo/api/application/models/DayBook_model.php @@ -0,0 +1,145 @@ +db->select('t1.ListCode, t1.ListName'); + $this->db->from(''.PICK_LIST_DETAILS. ' as t1'); + $this->db->where('t1.ListGroup', 10); + // $this->db->join('' . COURSE . ' as t2', 't2.UniversityID = t1.UniversityID', 'LEFT'); + $typeDetails = $this->db->get(); + $typeStateDetails = $typeDetails->result(); + // TypeName details + $this->db->select('t2.TypeName, t2.TypeID, t2.ID'); + $this->db->from(''.INCOMEOUTCOMEMASTER. ' as t2'); + $this->db->where('t2.IsActive', 1); + + $typeNaDetails = $this->db->get(); + $typeNameDetails = $typeNaDetails->result(); + + $results['typeNameStatus'] = true; + $results['typeList'] = $typeStateDetails; + $results['typeNameList'] = $typeNameDetails; + return $results; + } + + public function get_Daybook_Details_List($reqData, $reqDataBy) { + $this->db->select('t1.*, t2.ListName, t3.TypeName'); + $this->db->from(''.DAYBOOKMASTER. ' as t1'); + $this->db->join('' . PICK_LIST_DETAILS . ' as t2', 't2.ListCode = t1.Name', 'LEFT'); + $this->db->join('' . INCOMEOUTCOMEMASTER . ' as t3', 't3.ID = t1.Type', 'LEFT'); + $this->db->where('t1.Date', $reqData['date']); + $this->db->order_by('CreatedOn', 'DESC'); + $this->db->where('t1.BranchCode', $reqDataBy['localBranchID']); + // $this->db->join('' . COURSE . ' as t2', 't2.UniversityID = t1.UniversityID', 'LEFT'); + $dayBookDetails = $this->db->get(); + $dayBookDetailsList = $dayBookDetails->result(); + + $results['dayBookListStatus'] = true; + $results['dayBookListDetails'] = $dayBookDetailsList; + return $results; + + } + + public function delete_dayBookDetails($id) { + + $sql1 = " DELETE FROM ".DAYBOOKMASTER." WHERE ID ='$id'"; + // update branch to staff_branch table + if ($this->db->query($sql1) == '1') { + $result['deletedStatus'] = true; + $result['message'] = "DayBook Details Deleted"; + } else { + $result['deletedStatus'] = false; + $result['message'] = "Something went wrong.please try again"; + } + return $result; + } + + public function update_dayBookDetails($Arr, $upFor) { + $this->db->where('ID', $upFor); + $this->db->update(DAYBOOKMASTER, $Arr); + if ($this->db->affected_rows() == '1') { + $result['updateDetailsStatus'] = true; + $result['message'] = "Successfully details Updated"; + } else { + $result['updateDetailsStatus'] = false; + $result['message'] = "Something went wrong.please try again"; + } + return $result; + } + + // add dayBook + public function add_dayBook($Arr) + { + $this->db->insert(DAYBOOKMASTER, $Arr); + if ($this->db->affected_rows() == '1') { + $result['addDayBookStatus'] = true; + $result['message'] = "Successfully DayBook details added"; + + } else { + $result['addDayBookStatus'] = false; + $result['message'] = "Something went wrong.please try again"; + } + return $result; + } + + public function update_status_admin($arr) { + + $Approval_By = $arr[0]['Approval_By']; + $Approval_Comments = $arr[0]['Approval_Comments']; + $UpdatedBy = $arr[0]['UpdatedBy']; + $UpdatedOn = $arr[0]['UpdatedOn']; + $status = $arr[0]['Status']; + $number = array(); + foreach($arr as $ar){ + array_push($number, $ar['ID']); + } + $updateFor = implode(',', $number); + + $sql = "UPDATE ".DAYBOOKMASTER." + SET Status = '$status', Approval_By = '$Approval_By' , + Approval_Comments = '$Approval_Comments', UpdatedBy = '$UpdatedBy' , UpdatedOn = '$UpdatedOn' + WHERE id IN ($updateFor)"; + $mBranchDetails = $this->db->query($sql); + // echo $mBranchDetails; + // echo $this->db->affected_rows(); exit(); + if ($this->db->affected_rows() >= 1) { + $result['addStatus'] = true; + $result['message'] = "Successfully Study Material Status Updated"; + } else { + $result['addStatus'] = false; + $result['message'] = "Something went wrong.please try again"; + } + return $result; + } + + public function get_Daybook_Details_List_superAdmin($reqData, $reqDataBy){ + $this->db->select('t1.*, t2.ListName, t3.TypeName, t4.BranchName'); + $this->db->from(''.DAYBOOKMASTER. ' as t1'); + $this->db->join('' . PICK_LIST_DETAILS . ' as t2', 't2.ListCode = t1.Name', 'LEFT'); + $this->db->join('' . INCOMEOUTCOMEMASTER . ' as t3', 't3.ID = t1.Type', 'LEFT'); + $this->db->join('' . BRANCH . ' as t4', 't4.BranchCode = t1.BranchCode', 'LEFT'); + $this->db->where('t1.Date', $reqData['date']); + $this->db->order_by('CreatedOn', 'DESC'); + // $this->db->join('' . COURSE . ' as t2', 't2.UniversityID = t1.UniversityID', 'LEFT'); + $dayBookDetails = $this->db->get(); + $dayBookDetailsList = $dayBookDetails->result(); + + $results['dayBookListStatus'] = true; + $results['dayBookListDetails'] = $dayBookDetailsList; + return $results; + } +} \ No newline at end of file diff --git a/Apollo/assets/js/config.constant.js b/Apollo/assets/js/config.constant.js index 9f13773a..305ce1d1 100755 --- a/Apollo/assets/js/config.constant.js +++ b/Apollo/assets/js/config.constant.js @@ -146,7 +146,12 @@ app.constant('JS_REQUIRES', { * Certificate Type * */ 'certificateCtrl': 'assets/js/controllers/certificateCtrl.js', - + /* + * daybook details + * */ + 'daybookCtrl': 'assets/js/controllers/daybookCtrl.js', + 'daybookadminCtrl': 'assets/js/controllers/daybookadminCtrl.js', + 'daybooksuperadminCtrl': 'assets/js/controllers/daybooksuperadminCtrl.js', 'studentStatusUpdateCtrl':'assets/js/controllers/studentStatusUpdateCtrl.js', 'studentViewCtrl':'assets/js/controllers/studentViewCtrl.js', diff --git a/Apollo/assets/js/config.router.js b/Apollo/assets/js/config.router.js index 174b6654..36db4a14 100755 --- a/Apollo/assets/js/config.router.js +++ b/Apollo/assets/js/config.router.js @@ -309,11 +309,28 @@ app.config(['$stateProvider', '$urlRouterProvider', '$controllerProvider', '$com } }).state('app.daybook', { url: '/daybook', - template: '
', + templateUrl: "assets/views/daybook/daybook.html", title: 'daybook', + resolve: loadSequence('spin', 'ladda', 'angular-ladda', 'daybookCtrl','ngTable'), ncyBreadcrumb: { label: 'daybook' } + }).state('app.daybookadmin', { + url: '/daybookadmin', + templateUrl: "assets/views/daybook/daybookadmin.html", + title: 'daybook', + resolve: loadSequence('spin', 'ladda', 'angular-ladda', 'daybookadminCtrl','ngTable'), + ncyBreadcrumb: { + label: 'daybook' + } + }).state('app.daybooksuperadmin', { + url: '/daybooksuperadmin', + templateUrl: "assets/views/daybook/daybooksuperadmin.html", + title: 'daybook', + resolve: loadSequence('spin', 'ladda', 'angular-ladda', 'daybooksuperadminCtrl','ngTable'), + ncyBreadcrumb: { + label: 'daybook' + } }).state('app.daybook.income', { url: '/income', templateUrl: "assets/views/utility_search_result.html", diff --git a/Apollo/assets/js/controllers/daybookCtrl.js b/Apollo/assets/js/controllers/daybookCtrl.js new file mode 100644 index 00000000..338243d3 --- /dev/null +++ b/Apollo/assets/js/controllers/daybookCtrl.js @@ -0,0 +1,272 @@ +'use strict'; +/** + * daybook details capturing + * + */ +app.controller('daybookCtrl', ["$scope", "$rootScope", "toaster", "$filter", "ngTableParams", "API_POINTS", "$localStorage", "$http", "$state", 'ipCookie', function ($scope, $rootScope, toaster, $filter, ngTableParams, apiPoint, $localStorage, $http, $state, ipCookie) { + + // get local client details + var localDetail = JSON.parse(localStorage.getItem('localObj')); + var localDetails = ipCookie('cookiechk'); + + $scope.searchData = { + "date": "" + } + + $scope.init = function () { + $scope.currentDate = new Date(); + var formate = "dd-MM-yyyy"; + $scope.searchData.date = $filter('date')(new Date($scope.currentDate), formate); + $scope.getDayBookList(); + $scope.getIncomeExpenseType_Status(); + } + + $scope.changeDate = function () { + var formate = "dd-MM-yyyy"; + $scope.searchData.date = $filter('date')(new Date($scope.searchData.date), formate); + $scope.getDayBookList(); + } + + $scope.noRecordFound = true; + + $scope.getDayBookList = function () { + + var getDatBookListDetails = { + method: 'POST', + url: apiPoint.url + 'getDayBookDetails/', + headers: { + 'Content-Type': 'application/json' + }, + data: { + data: $scope.searchData, + localReqDetails: localDetails, + } + }; + $http(getDatBookListDetails).then(function (response) { + if (response.data.dayBookListStatus) { + + $scope.data = response.data.dayBookListDetails; + if ($scope.data.length !== 0) { + $scope.noRecordFound = false; + } else { + $scope.noRecordFound = true; + } + // alert(JSON.stringify($scope.data)); + // $scope.incomeExpenseType = response.data.typeNameList; + } else { + + } + }); + } + + $scope.getIncomeExpenseType_Status = function () { + var getIncomeExpenseType = { + method: 'POST', + url: apiPoint.url + 'getIncomeExpenseTypeState/', + headers: { + 'Content-Type': 'application/json' + }, + data: { + localReqDetails: localDetails + } + }; + $http(getIncomeExpenseType).then(function (response) { + if (response.data.typeNameStatus) { + $scope.incomeExpenseName = response.data.typeList; + $scope.incomeExpenseType = response.data.typeNameList; + } else { + } + }); + } + + $scope.getType = function (type) { + $scope.getIncomeTypes = $scope.incomeExpenseType.filter(function (val) { + return val.TypeID === 'I002' ? 1 : 0; + }); + $scope.getExpenseTypes = $scope.incomeExpenseType.filter(function (val) { + return val.TypeID === 'I001' ? 1 : 0; + }); + $scope.myModelAdd.type = ''; + $scope.getTypes = type === 'I002' ? $scope.getIncomeTypes : $scope.getExpenseTypes; + }; + + $scope.editId = -1; + $scope.setEditId = function (P) { + // alert(id); + $scope.editId = P; + } + + $scope.editClose = function () { + $scope.editId = -1; + $scope.myModel = { + "id": "", + "date": "", + "incomeExpense": "", + "type": "", + "amount": "", + "status": "", + "description": "" + } + } + + $scope.myModel = { + "id": "", + "date": "", + "incomeExpense": "", + "type": "", + "amount": "", + "status": "", + "description": "" + } + + $scope.copyModel = function (p) { + console.log(p); + $scope.myModel = { + "id": p.ID, + "date": p.Date, + "incomeExpense": p.Name, + "type": p.Type, + "amount": p.Amount, + "status": p.Status, + "description": p.Description + } + } + + $scope.deleEditEntry = function (id) { + swal({ + title: "Are you sure?", + text: "Your will not be able to recover this record!", + type: "warning", + showCancelButton: true, + confirmButtonClass: "btn-danger", + confirmButtonText: "Yes, delete it!", + closeOnConfirm: false + }, + function () { + $scope.indexDelete2(id); + }); + $scope.indexDelete2 = function (id) { + var deleteDetails = { + method: 'POST', + url: apiPoint.url + 'deleteDayBookDetails/', + headers: { + 'Content-Type': 'application/json' + }, + data: { + data: id, + requestDetails: localDetails + } + }; + $http(deleteDetails).then(function (response) { + if (response.data.deletedStatus) { + swal("Success!", response.data.message, "success"); + $scope.getDayBookList(); + } else { + swal("Failed!", response.data.message, "error"); + } + }); + } + } + + $scope.myModelAdd = { + "id": "", + "date": "", + "name": "", + "type": "", + "amount": "", + "status": "", + "description": "" + } + + $scope.daybookAdd = { + submit: function (form, myModelAdd) { + 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 { + var formate = "dd-MM-yyyy"; + $scope.myModelAdd.date = $filter('date')(new Date($scope.myModelAdd.date), formate); + $scope.myModelAdd.status = 'Pending'; + // $scope.data.push(myModelAdd); + + var addDayBookDetails = { + method: 'POST', + url: apiPoint.url + 'addDayBook/', + headers: { + 'Content-Type': 'application/json' + }, + data: { + data: myModelAdd, + localReqDetails: localDetails + } + }; + $http(addDayBookDetails).then(function (response) { + if (response.data.addDayBookStatus) { + swal("Success!", response.data.message, "success"); + $state.go($state.current, {}, { reload: true }); + } else { + swal("Failed!", response.data.message, "error"); + } + }); + } + } + } + + $scope.daybookeditUpdate = { + submit: function (form, myModel) { + 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 { + var updateDayBookDetails = { + method: 'POST', + url: apiPoint.url + 'updateDayBookDetails/', + headers: { + 'Content-Type': 'application/json' + }, + data: { + data: myModel, + requestDetails: localDetails + } + }; + $http(updateDayBookDetails).then(function (response) { + if (response.data.updateDetailsStatus) { + swal("Success!", response.data.message, "success"); + // for success state + $scope.editId = -1; + $scope.getDayBookList(); + } else { + swal("Failed!", response.data.message, "error"); + } + }); + } + } + } + +}]); + + diff --git a/Apollo/assets/js/controllers/daybookadminCtrl.js b/Apollo/assets/js/controllers/daybookadminCtrl.js new file mode 100644 index 00000000..362b21fe --- /dev/null +++ b/Apollo/assets/js/controllers/daybookadminCtrl.js @@ -0,0 +1,530 @@ +'use strict'; +/** + * daybook details capturing + * + */ +app.controller('daybookadminCtrl', ["$scope", "$rootScope", "toaster", "$filter", "ngTableParams", "API_POINTS", "$localStorage", "$http", "$state", 'ipCookie', function ($scope, $rootScope, toaster, $filter, ngTableParams, apiPoint, $localStorage, $http, $state, ipCookie) { + + // get local client details + var localDetail = JSON.parse(localStorage.getItem('localObj')); + var localDetails = ipCookie('cookiechk'); + $scope.localTypeViewAdmin = false; + $scope.localTypeViewSuperAdmin = false; + + // $scope.init = function () { + // const LOCALTYPE = localDetail.localType; + // if (LOCALTYPE === 'R003') { + // $scope.localTypeViewAdmin = true; + // $scope.getDayBookList(); + // } else { + // $scope.localTypeViewSuperAdmin = true; + // } + // } + + $scope.searchData = { + "date": "" + } + + $scope.init = function () { + + const LOCALTYPE = localDetail.localType; + if (LOCALTYPE === 'R003') { + $scope.showTheRefValue = 'I001'; + $scope.localTypeViewAdmin = true; + $scope.currentDate = new Date(); + var formate = "dd-MM-yyyy"; + $scope.searchData.date = $filter('date')(new Date($scope.currentDate), formate); + $scope.getIncomeExpenseType_Status(); + $scope.getDayBookList(); + } else if(LOCALTYPE === 'R004') { + $scope.localTypeViewSuperAdmin = true; + $scope.showTheRefValue = 'I001'; + $scope.localTypeViewAdmin = true; + $scope.currentDate = new Date(); + var formate = "dd-MM-yyyy"; + $scope.searchData.date = $filter('date')(new Date($scope.currentDate), formate); + $scope.getIncomeExpenseType_Status(); + $scope.getDayBookList(); + } + } + + $scope.changeDate = function () { + var formate = "dd-MM-yyyy"; + $scope.searchData.date = $filter('date')(new Date($scope.searchData.date), formate); + $scope.getDayBookList(); + } + + + $scope.getIncomeExpenseType_Status = function () { + var getIncomeExpenseType = { + method: 'POST', + url: apiPoint.url + 'getIncomeExpenseTypeState/', + headers: { + 'Content-Type': 'application/json' + }, + data: { + localReqDetails: localDetails + } + }; + $http(getIncomeExpenseType).then(function (response) { + if (response.data.typeNameStatus) { + $scope.incomeExpenseName = response.data.typeList; + $scope.incomeExpenseType = response.data.typeNameList; + } else { + } + }); + } + + + + $scope.noRecordFound = true; + + $scope.getDayBookList = function () { + + var getDatBookListDetails = { + method: 'POST', + url: apiPoint.url + 'getDayBookDetails/', + headers: { + 'Content-Type': 'application/json' + }, + data: { + data: $scope.searchData, + localReqDetails: localDetails, + } + }; + $http(getDatBookListDetails).then(function (response) { + if (response.data.dayBookListStatus) { + + // $scope.data = response.data.dayBookListDetails; + let datas = response.data.dayBookListDetails; + let searchResultDetailsBef = datas.filter(val => { + return val.Name == 'I001' ? 1 : 0; + }); + $scope.IncomeData = datas.filter(val => { + return val.Name == 'I002' ? 1 : 0; + }); + const filterAddSelect = searchResultDetailsBef.filter(val => { + val['Selected'] = false; + return val; + }); + $scope.searchResultDetails = filterAddSelect; + // alert(JSON.stringify($scope.searchResultDetails)); + $scope.searchResultLength = Object.keys($scope.searchResultDetails).length; + + // if ($scope.data.length !== 0) { + // $scope.OpenWindowStatus = false; + // $scope.noRecordFound = false; + // } else { + // $scope.OpenWindowStatus = false; + // $scope.noRecordFound = true; + // } + // alert(JSON.stringify($scope.data)); + // $scope.incomeExpenseType = response.data.typeNameList; + } else { + + } + }); + } + + + // $scope.getDayBookList = function() { + // let searchResultDetailsBef = $scope.data; + // const filterAddSelect = searchResultDetailsBef.filter(val => { + // val['Selected'] = false; + // return val; + // }); + // $scope.searchResultDetails = filterAddSelect; + // $scope.searchResultLength = Object.keys($scope.searchResultDetails).length; + // } + + + // select all or individual functionality + + var getAllSelected = function () { + var selectedItems = $scope.searchResultDetails.filter(function (item) { + return item.Selected; + }); + + return selectedItems.length === $scope.searchResultDetails.length; + } + + var setAllSelected = function (value) { + angular.forEach($scope.searchResultDetails, function (item) { + item.Selected = value; + }); + } + + $scope.allSelected = function (value) { + if (value !== undefined) { + return setAllSelected(value); + } else { + return getAllSelected(); + } + } + + $scope.myStatusModel = { + 'staus': '', + 'description': '', + } + + // End: select all or individual functionality + + $scope.OpenWindowStatus = false; + $scope.openUpdateWind = function () { + var ItemsSelected = $scope.searchResultDetails.filter(function (item) { + if (item.Selected === true) { return true; } + }); + // $scope.getStatusList(); + // alert(ItemsSelected.length); + if (ItemsSelected.length) { + $scope.myStatusModel = { + 'staus': '', + 'description': '', + } + $scope.OpenWindowStatus = true; + } else { + $scope.OpenWindowStatus = false; + } + } + + $scope.statusUpdate = { + submit: function (form, myStatusModel) { + 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 { + var selectedItems = []; + var ItemsSelected = $scope.searchResultDetails.filter(function (item) { + if (item.Selected === true) { + let itemGetID = new getUpdateDetails(item.ID); + selectedItems.push(itemGetID); + return true; + } + }); + function getUpdateDetails(id) { + this.dabookListId = id; + this.ListCodeStatus = $scope.myStatusModel.staus; + this.comments = $scope.myStatusModel.description; + } + // alert(JSON.stringify($scope.myStatusModel)); + // alert(JSON.stringify(selectedItems)); + var updateStudyMaterial = { + method: 'POST', + url: apiPoint.url + 'updateDayBookStatusAdmin/', + headers: { + 'Content-Type': 'application/json' + }, + data: { + data: selectedItems, + requestDetails: localDetails + } + }; + $http(updateStudyMaterial).then(function (response) { + if (response.data.addStatus) { + swal("Success!", response.data.message, "success"); + // for success state + $scope.getDayBookList(); + $scope.allSelected('undefined'); + $scope.OpenWindowStatus = false; + } else { + swal("Failed!", response.data.message, "error"); + } + }); + } + }, + reset: function (form) { + form.$setPristine(true); + $scope.myStatusModel = { + 'staus': '', + 'description': '', + } + } + } + + + + $scope.statusList = [{ + "status_id": 'TS001', + "name": "Pending", + }, { + "status_id": 'TS002', + "name": "Approved", + }, { + "status_id": 'TS003', + "name": "Rejected", + }]; + + $scope.data = [{ + "id": 1, + "date": "20-12-2017", + "incomeExpense": "Income", + "type": "typeIncome1", + "amount": "1000", + "status": "Pending", + "description": "income type income type income type" + }, { + "id": 2, + "date": "20-12-2017", + "incomeExpense": "Expense", + "type": "typeIncome2", + "amount": "2000", + "status": "Pending", + "description": "income type income type income type" + }, { + "id": 3, + "date": "20-12-2017", + "incomeExpense": "Expense", + "type": "typeIncome3", + "amount": "3000", + "status": "Pending", + "description": "income type income type income type" + }]; + + + + + $scope.incomeExpenseType = [{ + "type_id": 1, + "type": "Income", + "name": "fees" + }, { + "type_id": 2, + "type": "Expense", + "name": "food" + }, { + "type_id": 3, + "type": "Expense", + "name": "phone" + }, { + "type_id": 4, + "type": "Expense", + "name": "tea-coffee" + }, { + "type_id": 5, + "type": "Expense", + "name": "Paper" + }]; + + $scope.getIncomeExpense = function () { + $scope.incomeExpenseName = [{ + "type_id": 1, + "type": "TYPE001", + "name": "Income" + }, { + "type_id": 2, + "type": "TYPE002", + "name": "Expense" + }]; + + } + + $scope.getIncomeTypes = $scope.incomeExpenseType.filter(function (val) { + return val.type === 'Income' ? 1 : 0; + }); + $scope.getExpenseTypes = $scope.incomeExpenseType.filter(function (val) { + return val.type === 'Expense' ? 1 : 0; + }); + + $scope.getType = function (type) { + // alert(type); + $scope.myModelAdd.type = ''; + $scope.getTypes = type === 'Income' ? $scope.getIncomeTypes : $scope.getExpenseTypes; + }; + + $scope.editId = -1; + $scope.setEditId = function (P) { + // alert(id); + $scope.editId = P; + } + + $scope.editClose = function () { + $scope.editId = -1; + $scope.myModel = { + "id": "", + "date": "", + "incomeExpense": "", + "type": "", + "amount": "", + "status": "", + "description": "" + } + } + + $scope.myModel = { + "id": "", + "date": "", + "incomeExpense": "", + "type": "", + "amount": "", + "status": "", + "description": "" + } + + $scope.copyModel = function (p) { + $scope.myModel = { + "id": p.id, + "date": p.date, + "incomeExpense": p.incomeExpense, + "type": p.type, + "amount": p.amount, + "status": p.status, + "description": p.description + } + } + + $scope.deleEditEntry = function (id) { + swal({ + title: "Are you sure?", + text: "Your will not be able to recover this record!", + type: "warning", + showCancelButton: true, + confirmButtonClass: "btn-danger", + confirmButtonText: "Yes, delete it!", + closeOnConfirm: false + }, + function () { + $scope.indexDelete2(); + // if( $scope.indexDelete2() === true) { + // $scope.data; + // swal("Deleted!", "Your imaginary file has been deleted.", "success"); + // } + }); + $scope.indexDelete2 = function () { + let ans = $scope.data.some(function (val, i) { + if (val.id === id) { + $scope.data.splice(i, 1); + swal("Deleted!", "Your record has been deleted.", "success"); + return true; + } + }); return ans; + } + + } + + $scope.myModelAdd = { + "id": "", + "date": "", + "name": "", + "type": "", + "amount": "", + "status": "", + "description": "" + } + + $scope.daybookAdd = { + submit: function (form, myModelAdd) { + 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 { + var formate = "dd-MM-yyyy"; + $scope.myModelAdd.date = $filter('date')(new Date($scope.myModelAdd.date), formate); + $scope.myModelAdd.status = 'Pending'; + $scope.data.push(myModelAdd); + } + } + } + + + + $scope.daybookeditUpdate = { + submit: function (form, myModel) { + 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 { + // var studentForUpdate = []; + // let formate = "dd-MM-yyyy"; + // $scope.myStatusModel.dateOn = $filter('date')(new Date($scope.myStatusModel.dateOn), formate); + // var ItemsSelected = $scope.searchResultDetails.filter(function (item) { + // if (item.Selected === true) { + // let getStudentID = new getStudentForUpdateDetails(item.StudentID); + // studentForUpdate.push(getStudentID); + // return true; + // } + // }); + // function getStudentForUpdateDetails(id) { + // this.StudentID = id; + // this.CourseID = $scope.myStatusModel.semYear; + // this.BranchCode = localDetails.localBranchID; + // this.ListCode = $scope.myStatusModel.staus; + // this.SDate = $scope.myStatusModel.dateOn; + // this.Coursedetail = id; + // this.Comments = $scope.myStatusModel.comment; + // } + // // alert(JSON.stringify($scope.myStatusModel)); + // // alert(JSON.stringify(studentForUpdate)); + + // var updateStudyMaterial = { + // method: 'POST', + // url: apiPoint.url + 'updateStudentMaterialStatus/', + // headers: { + // 'Content-Type': 'application/json' + // }, + // data: { + // data: studentForUpdate, + // requestDetails : localDetails + // } + // }; + // $http(updateStudyMaterial).then(function (response) { + // if (response.data.addStatus) { + // swal("Success!", response.data.message, "success"); + // // for success state + // $scope.allSelected('undefined'); + // $scope.OpenWindowStatus = false; + // } else { + // swal("Failed!", response.data.message, "error"); + // } + // }); + } + }, + // reset: function (form) { + // form.$setPristine(true); + // $scope.myStatusModel = { + // 'semYear': '', + // 'staus': '', + // 'dateOn': '', + // 'comment': '' + // } + // } + } + +}]); + + diff --git a/Apollo/assets/js/controllers/daybooksuperadminCtrl.js b/Apollo/assets/js/controllers/daybooksuperadminCtrl.js new file mode 100644 index 00000000..5159d5bb --- /dev/null +++ b/Apollo/assets/js/controllers/daybooksuperadminCtrl.js @@ -0,0 +1,524 @@ +'use strict'; +/** + * daybook details capturing + * + */ +app.controller('daybooksuperadminCtrl', ["$scope", "$rootScope", "toaster", "$filter", "ngTableParams", "API_POINTS", "$localStorage", "$http", "$state", 'ipCookie', function ($scope, $rootScope, toaster, $filter, ngTableParams, apiPoint, $localStorage, $http, $state, ipCookie) { + + // get local client details + var localDetail = JSON.parse(localStorage.getItem('localObj')); + var localDetails = ipCookie('cookiechk'); + $scope.localTypeViewAdmin = false; + $scope.localTypeViewSuperAdmin = false; + + // $scope.init = function () { + // const LOCALTYPE = localDetail.localType; + // if (LOCALTYPE === 'R003') { + // $scope.localTypeViewAdmin = true; + // $scope.getDayBookList(); + // } else { + // $scope.localTypeViewSuperAdmin = true; + // } + // } + + $scope.searchData = { + "date": "" + } + + $scope.init = function () { + + const LOCALTYPE = localDetail.localType; + if(LOCALTYPE === 'R004') { + $scope.localTypeViewSuperAdmin = true; + $scope.showTheRefValue = 'I001'; + $scope.localTypeViewAdmin = true; + $scope.currentDate = new Date(); + var formate = "dd-MM-yyyy"; + $scope.searchData.date = $filter('date')(new Date($scope.currentDate), formate); + $scope.getIncomeExpenseType_Status(); + $scope.getDayBookList(); + } else { + + } + } + + $scope.changeDate = function () { + var formate = "dd-MM-yyyy"; + $scope.searchData.date = $filter('date')(new Date($scope.searchData.date), formate); + $scope.getDayBookList(); + } + + + $scope.getIncomeExpenseType_Status = function () { + var getIncomeExpenseType = { + method: 'POST', + url: apiPoint.url + 'getIncomeExpenseTypeState/', + headers: { + 'Content-Type': 'application/json' + }, + data: { + localReqDetails: localDetails + } + }; + $http(getIncomeExpenseType).then(function (response) { + if (response.data.typeNameStatus) { + $scope.incomeExpenseName = response.data.typeList; + $scope.incomeExpenseType = response.data.typeNameList; + } else { + } + }); + } + + + + $scope.noRecordFound = true; + + $scope.getDayBookList = function () { + + var getDatBookListDetails = { + method: 'POST', + url: apiPoint.url + 'getDayBookDetailsSuperAdmin/', + headers: { + 'Content-Type': 'application/json' + }, + data: { + data: $scope.searchData, + localReqDetails: localDetails, + } + }; + $http(getDatBookListDetails).then(function (response) { + if (response.data.dayBookListStatus) { + + // $scope.data = response.data.dayBookListDetails; + let datas = response.data.dayBookListDetails; + let searchResultDetailsBef = datas.filter(val => { + return val.Name == 'I001' ? 1 : 0; + }); + $scope.IncomeData = datas.filter(val => { + return val.Name == 'I002' ? 1 : 0; + }); + const filterAddSelect = searchResultDetailsBef.filter(val => { + val['Selected'] = false; + return val; + }); + $scope.searchResultDetails = filterAddSelect; + // alert(JSON.stringify($scope.searchResultDetails)); + $scope.searchResultLength = Object.keys($scope.searchResultDetails).length; + + // if ($scope.data.length !== 0) { + // $scope.OpenWindowStatus = false; + // $scope.noRecordFound = false; + // } else { + // $scope.OpenWindowStatus = false; + // $scope.noRecordFound = true; + // } + // alert(JSON.stringify($scope.data)); + // $scope.incomeExpenseType = response.data.typeNameList; + } else { + + } + }); + } + + + // $scope.getDayBookList = function() { + // let searchResultDetailsBef = $scope.data; + // const filterAddSelect = searchResultDetailsBef.filter(val => { + // val['Selected'] = false; + // return val; + // }); + // $scope.searchResultDetails = filterAddSelect; + // $scope.searchResultLength = Object.keys($scope.searchResultDetails).length; + // } + + + // select all or individual functionality + + var getAllSelected = function () { + var selectedItems = $scope.searchResultDetails.filter(function (item) { + return item.Selected; + }); + + return selectedItems.length === $scope.searchResultDetails.length; + } + + var setAllSelected = function (value) { + angular.forEach($scope.searchResultDetails, function (item) { + item.Selected = value; + }); + } + + $scope.allSelected = function (value) { + if (value !== undefined) { + return setAllSelected(value); + } else { + return getAllSelected(); + } + } + + $scope.myStatusModel = { + 'staus': '', + 'description': '', + } + + // End: select all or individual functionality + + $scope.OpenWindowStatus = false; + $scope.openUpdateWind = function () { + var ItemsSelected = $scope.searchResultDetails.filter(function (item) { + if (item.Selected === true) { return true; } + }); + // $scope.getStatusList(); + // alert(ItemsSelected.length); + if (ItemsSelected.length) { + $scope.myStatusModel = { + 'staus': '', + 'description': '', + } + $scope.OpenWindowStatus = true; + } else { + $scope.OpenWindowStatus = false; + } + } + + $scope.statusUpdate = { + submit: function (form, myStatusModel) { + 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 { + var selectedItems = []; + var ItemsSelected = $scope.searchResultDetails.filter(function (item) { + if (item.Selected === true) { + let itemGetID = new getUpdateDetails(item.ID); + selectedItems.push(itemGetID); + return true; + } + }); + function getUpdateDetails(id) { + this.dabookListId = id; + this.ListCodeStatus = $scope.myStatusModel.staus; + this.comments = $scope.myStatusModel.description; + } + // alert(JSON.stringify($scope.myStatusModel)); + // alert(JSON.stringify(selectedItems)); + var updateStudyMaterial = { + method: 'POST', + url: apiPoint.url + 'updateDayBookStatusAdmin/', + headers: { + 'Content-Type': 'application/json' + }, + data: { + data: selectedItems, + requestDetails: localDetails + } + }; + $http(updateStudyMaterial).then(function (response) { + if (response.data.addStatus) { + swal("Success!", response.data.message, "success"); + // for success state + $scope.getDayBookList(); + $scope.allSelected('undefined'); + $scope.OpenWindowStatus = false; + } else { + swal("Failed!", response.data.message, "error"); + } + }); + } + }, + reset: function (form) { + form.$setPristine(true); + $scope.myStatusModel = { + 'staus': '', + 'description': '', + } + } + } + + + + $scope.statusList = [{ + "status_id": 'TS001', + "name": "Pending", + }, { + "status_id": 'TS002', + "name": "Approved", + }, { + "status_id": 'TS003', + "name": "Rejected", + }]; + + $scope.data = [{ + "id": 1, + "date": "20-12-2017", + "incomeExpense": "Income", + "type": "typeIncome1", + "amount": "1000", + "status": "Pending", + "description": "income type income type income type" + }, { + "id": 2, + "date": "20-12-2017", + "incomeExpense": "Expense", + "type": "typeIncome2", + "amount": "2000", + "status": "Pending", + "description": "income type income type income type" + }, { + "id": 3, + "date": "20-12-2017", + "incomeExpense": "Expense", + "type": "typeIncome3", + "amount": "3000", + "status": "Pending", + "description": "income type income type income type" + }]; + + + + + $scope.incomeExpenseType = [{ + "type_id": 1, + "type": "Income", + "name": "fees" + }, { + "type_id": 2, + "type": "Expense", + "name": "food" + }, { + "type_id": 3, + "type": "Expense", + "name": "phone" + }, { + "type_id": 4, + "type": "Expense", + "name": "tea-coffee" + }, { + "type_id": 5, + "type": "Expense", + "name": "Paper" + }]; + + $scope.getIncomeExpense = function () { + $scope.incomeExpenseName = [{ + "type_id": 1, + "type": "TYPE001", + "name": "Income" + }, { + "type_id": 2, + "type": "TYPE002", + "name": "Expense" + }]; + + } + + $scope.getIncomeTypes = $scope.incomeExpenseType.filter(function (val) { + return val.type === 'Income' ? 1 : 0; + }); + $scope.getExpenseTypes = $scope.incomeExpenseType.filter(function (val) { + return val.type === 'Expense' ? 1 : 0; + }); + + $scope.getType = function (type) { + // alert(type); + $scope.myModelAdd.type = ''; + $scope.getTypes = type === 'Income' ? $scope.getIncomeTypes : $scope.getExpenseTypes; + }; + + $scope.editId = -1; + $scope.setEditId = function (P) { + // alert(id); + $scope.editId = P; + } + + $scope.editClose = function () { + $scope.editId = -1; + $scope.myModel = { + "id": "", + "date": "", + "incomeExpense": "", + "type": "", + "amount": "", + "status": "", + "description": "" + } + } + + $scope.myModel = { + "id": "", + "date": "", + "incomeExpense": "", + "type": "", + "amount": "", + "status": "", + "description": "" + } + + $scope.copyModel = function (p) { + $scope.myModel = { + "id": p.id, + "date": p.date, + "incomeExpense": p.incomeExpense, + "type": p.type, + "amount": p.amount, + "status": p.status, + "description": p.description + } + } + + $scope.deleEditEntry = function (id) { + swal({ + title: "Are you sure?", + text: "Your will not be able to recover this record!", + type: "warning", + showCancelButton: true, + confirmButtonClass: "btn-danger", + confirmButtonText: "Yes, delete it!", + closeOnConfirm: false + }, + function () { + $scope.indexDelete2(); + // if( $scope.indexDelete2() === true) { + // $scope.data; + // swal("Deleted!", "Your imaginary file has been deleted.", "success"); + // } + }); + $scope.indexDelete2 = function () { + let ans = $scope.data.some(function (val, i) { + if (val.id === id) { + $scope.data.splice(i, 1); + swal("Deleted!", "Your record has been deleted.", "success"); + return true; + } + }); return ans; + } + + } + + $scope.myModelAdd = { + "id": "", + "date": "", + "name": "", + "type": "", + "amount": "", + "status": "", + "description": "" + } + + $scope.daybookAdd = { + submit: function (form, myModelAdd) { + 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 { + var formate = "dd-MM-yyyy"; + $scope.myModelAdd.date = $filter('date')(new Date($scope.myModelAdd.date), formate); + $scope.myModelAdd.status = 'Pending'; + $scope.data.push(myModelAdd); + } + } + } + + + + $scope.daybookeditUpdate = { + submit: function (form, myModel) { + 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 { + // var studentForUpdate = []; + // let formate = "dd-MM-yyyy"; + // $scope.myStatusModel.dateOn = $filter('date')(new Date($scope.myStatusModel.dateOn), formate); + // var ItemsSelected = $scope.searchResultDetails.filter(function (item) { + // if (item.Selected === true) { + // let getStudentID = new getStudentForUpdateDetails(item.StudentID); + // studentForUpdate.push(getStudentID); + // return true; + // } + // }); + // function getStudentForUpdateDetails(id) { + // this.StudentID = id; + // this.CourseID = $scope.myStatusModel.semYear; + // this.BranchCode = localDetails.localBranchID; + // this.ListCode = $scope.myStatusModel.staus; + // this.SDate = $scope.myStatusModel.dateOn; + // this.Coursedetail = id; + // this.Comments = $scope.myStatusModel.comment; + // } + // // alert(JSON.stringify($scope.myStatusModel)); + // // alert(JSON.stringify(studentForUpdate)); + + // var updateStudyMaterial = { + // method: 'POST', + // url: apiPoint.url + 'updateStudentMaterialStatus/', + // headers: { + // 'Content-Type': 'application/json' + // }, + // data: { + // data: studentForUpdate, + // requestDetails : localDetails + // } + // }; + // $http(updateStudyMaterial).then(function (response) { + // if (response.data.addStatus) { + // swal("Success!", response.data.message, "success"); + // // for success state + // $scope.allSelected('undefined'); + // $scope.OpenWindowStatus = false; + // } else { + // swal("Failed!", response.data.message, "error"); + // } + // }); + } + }, + // reset: function (form) { + // form.$setPristine(true); + // $scope.myStatusModel = { + // 'semYear': '', + // 'staus': '', + // 'dateOn': '', + // 'comment': '' + // } + // } + } + +}]); + + diff --git a/Apollo/assets/views/daybook/daybook.html b/Apollo/assets/views/daybook/daybook.html new file mode 100644 index 00000000..ddee6d92 --- /dev/null +++ b/Apollo/assets/views/daybook/daybook.html @@ -0,0 +1,276 @@ + +
+
+
+

{{ mainTitle }}

+
+
+
+
+ + +
+
+ + +
+
+ + +
+
+ +
+ +
+ + + +
+
+
+ +
+ + + + + + + + + + + + + + + + + + + + + + + + + + +
Date + + Income/Expense + + Type + + Amount + + Description + + Status + + Activity +
{{p.Date}}{{p.ListName}}{{p.TypeName}}{{p.Amount}}{{p.Description}}{{p.Status}} + {{p.Status}} + {{p.Status}} + - + + +
+
+
+
+
+ + + + Type is Required + +
+
+ + + Amount is Required + +
+
+ + +