diff --git a/Apollo/api/application/config/routes.php b/Apollo/api/application/config/routes.php index 64a3e216..fdcfb814 100755 --- a/Apollo/api/application/config/routes.php +++ b/Apollo/api/application/config/routes.php @@ -195,6 +195,8 @@ $route['getIncomeExpenseTypeState'] = 'DayBook_Controller/getIncomeExpenseTypeSt $route['addDayBook'] = 'DayBook_Controller/adddaybook'; $route['updateDayBookStatusAdmin'] = 'DayBook_Controller/updateDayBookStatusAdmin'; $route['getDayBookDetailsSuperAdmin'] = 'DayBook_Controller/getDayBookDetailsSuperAdmin'; +$route['empDayBookModuleAccessChk'] = 'DayBook_Controller/empDayBookModuleAccessChk'; + /* * day book master * */ $route['getDayBookMasterDetails'] = 'DayBookMaster_Controller/getDayBookMasterDetails'; $route['addDaybookMasterDetails'] = 'DayBookMaster_Controller/addDaybookMasterDetails'; diff --git a/Apollo/api/application/controllers/DayBook_Controller.php b/Apollo/api/application/controllers/DayBook_Controller.php index 189a7eff..7bc10d3c 100755 --- a/Apollo/api/application/controllers/DayBook_Controller.php +++ b/Apollo/api/application/controllers/DayBook_Controller.php @@ -52,6 +52,28 @@ class DayBook_Controller extends REST_Controller { } } + + public function empDayBookModuleAccessChk_post() { + $reqDataBy = $this->post('localReqDetails'); + // print_r($reqDataBy);exit(); + $empDayBkAccessChk = $this->daybook_model->emp_day_book_AccessChk($reqDataBy);// Check if the employee exist + if ($empDayBkAccessChk) + { + $empDayBkAccessChk['status'] = REST_Controller::HTTP_OK; + // Set the response and exit + $this->response($empDayBkAccessChk, 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 diff --git a/Apollo/api/application/controllers/Employee_Controller.php b/Apollo/api/application/controllers/Employee_Controller.php index adc7fc3d..cc59b078 100755 --- a/Apollo/api/application/controllers/Employee_Controller.php +++ b/Apollo/api/application/controllers/Employee_Controller.php @@ -200,6 +200,9 @@ class Employee_Controller extends REST_Controller { $req['Qualification'] = $data['qualificaion']; $req['BranchCode'] = $data['homeBranch']; $req['IsActive'] = $data['switchsetting']; + + $req['FinanceModuleAccess'] = $data['finaceModuleAccess']; + $req['DOJ'] = $data['dateofjoining']; $req['JobResponsibility'] = $data['jobResponsibility']; // $req['DOJ'] = $data['dateofjoining']; @@ -436,16 +439,17 @@ class Employee_Controller extends REST_Controller { // update employee branch public function updateEmpBranchDetail_post() { - + // exit(); $empFor = $this->post('empFor'); $reqBanch['BranchCode'] = $this->post('updateBranch'); $req['ListCode'] = $this->post('updateRole'); $reqJOBRES['JobResponsibility'] = $this->post('JobResponsibility'); + $FinanceModuleAccess = $this->post('FinanceModuleAccess') == 1 ? 1 : 0; $req['UpdatedBy'] = $this->post('updateBy'); $date = date('Y-m-d H:i:s'); $req['UpdatedOn'] = $date; - $updateBranch = $this->employee_model->upate_employee_branch( $empFor, $reqBanch, $req, $req['UpdatedBy'], $req['UpdatedOn'], $reqJOBRES );// Check if the employee exist + $updateBranch = $this->employee_model->upate_employee_branch( $empFor, $reqBanch, $req, $req['UpdatedBy'], $req['UpdatedOn'], $reqJOBRES, $FinanceModuleAccess);// Check if the employee exist if ($updateBranch) { $updateBranch['status'] = REST_Controller::HTTP_OK; diff --git a/Apollo/api/application/models/DayBook_model.php b/Apollo/api/application/models/DayBook_model.php index 2960efa0..6c58ec93 100755 --- a/Apollo/api/application/models/DayBook_model.php +++ b/Apollo/api/application/models/DayBook_model.php @@ -36,6 +36,18 @@ class DayBook_model extends CI_Model return $results; } + public function emp_day_book_AccessChk($arr) { + $id = $arr['localUserID']; + $sql1 = "SELECT t1.FinanceModuleAccess FROM ".STAFF." as t1 LEFT JOIN ".LOGIN." as t2 ON t2.StaffID = t1.StaffID WHERE t2.id = $id"; + // update branch to staff_branch table + $dayBookAccDetails = $this->db->query($sql1); + $dayBkAcesDetail = $dayBookAccDetails->result(); + $result['dayBkAccessChkStatus'] = true; + $result['dayBkAccessChk_Value'] = $dayBkAcesDetail[0]->FinanceModuleAccess; + // echo $result['dayBkAccessChk_Value'];exit(); + return $result; + } + public function get_Daybook_Details_List($reqData, $reqDataBy) { if($reqData['date'] != '' && $reqData['dateTo'] != '') { @@ -50,7 +62,8 @@ class DayBook_model extends CI_Model $toDate = $dTo->format('Y-m-d'); $reqpayType = $reqDataBy['localBranchID']; - $querys = "SELECT t1.*, t2.ListName, t3.TypeName FROM ".DAYBOOKMASTER." as t1 LEFT JOIN ".PICK_LIST_DETAILS." as t2 ON t2.ListCode = t1.Name LEFT JOIN ".INCOMEOUTCOMEMASTER." as t3 ON t3.ID = t1.Type + $querys = "SELECT t1.*, t2.ListName, t3.TypeName , t5.Firstname as Approved_by_name FROM ".DAYBOOKMASTER." as t1 LEFT JOIN ".PICK_LIST_DETAILS." as t2 ON t2.ListCode = t1.Name LEFT JOIN ".INCOMEOUTCOMEMASTER." as t3 ON t3.ID = t1.Type + LEFT JOIN ".LOGIN." as t4 ON t4.ID = t1.Approval_By LEFT JOIN ".STAFF." as t5 ON t5.StaffID = t4.StaffID WHERE STR_TO_DATE(t1.Date, '%d-%m-%Y') BETWEEN '$fromDate' AND '$toDate' AND t1.BranchCode = '$reqpayType' ORDER BY CreatedOn DESC"; @@ -69,7 +82,8 @@ class DayBook_model extends CI_Model // $this->db->order_by('CreatedOn', 'DESC'); // $this->db->where('t1.BranchCode', $reqDataBy['localBranchID']); $reqpayType = $reqDataBy['localBranchID']; - $querys = "SELECT t1.*, t2.ListName, t3.TypeName FROM ".DAYBOOKMASTER." as t1 LEFT JOIN ".PICK_LIST_DETAILS." as t2 ON t2.ListCode = t1.Name LEFT JOIN ".INCOMEOUTCOMEMASTER." as t3 ON t3.ID = t1.Type + $querys = "SELECT t1.*, t2.ListName, t3.TypeName, t5.Firstname as Approved_by_name FROM ".DAYBOOKMASTER." as t1 LEFT JOIN ".PICK_LIST_DETAILS." as t2 ON t2.ListCode = t1.Name LEFT JOIN ".INCOMEOUTCOMEMASTER." as t3 ON t3.ID = t1.Type + LEFT JOIN ".LOGIN." as t4 ON t4.ID = t1.Approval_By LEFT JOIN ".STAFF." as t5 ON t5.StaffID = t4.StaffID WHERE t1.BranchCode = '$reqpayType' ORDER BY CreatedOn DESC"; } @@ -156,11 +170,13 @@ class DayBook_model extends CI_Model public function get_Daybook_Details_List_superAdmin($reqData, $reqDataBy){ if($reqData['date'] != '' && $reqData['dateTo'] != '') { - $this->db->select('t1.*, t2.ListName, t3.TypeName, t4.BranchName'); + $this->db->select('t1.*, t2.ListName, t3.TypeName, t4.BranchName, t6.Firstname as Approved_by_name '); $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->join('' . LOGIN . ' as t5', 't5.ID = t1.Approval_By', 'LEFT'); + $this->db->join('' . STAFF . ' as t6', 't6.StaffID = t5.StaffID', 'LEFT'); $this->db->where('t1.Date >=', $reqData['date']); $this->db->where('t1.Date <=', $reqData['dateTo']); $this->db->order_by('CreatedOn', 'DESC'); @@ -168,11 +184,13 @@ class DayBook_model extends CI_Model $dayBookDetails = $this->db->get(); $dayBookDetailsList = $dayBookDetails->result(); } else { - $this->db->select('t1.*, t2.ListName, t3.TypeName, t4.BranchName'); + $this->db->select('t1.*, t2.ListName, t3.TypeName, t4.BranchName, t6.Firstname as Approved_by_name '); $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->join('' . LOGIN . ' as t5', 't5.ID = t1.Approval_By', 'LEFT'); + $this->db->join('' . STAFF . ' as t6', 't6.StaffID = t5.StaffID', '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'); diff --git a/Apollo/api/application/models/Employee_model.php b/Apollo/api/application/models/Employee_model.php index c68b1bbd..e11eb719 100755 --- a/Apollo/api/application/models/Employee_model.php +++ b/Apollo/api/application/models/Employee_model.php @@ -514,7 +514,7 @@ class Employee_model extends CI_Model // get employee branch details public function get_employee_branch($staffId) { - $this->db->select('t3.ListCode, t3.ListName, t4.JobResponsibility'); + $this->db->select('t3.ListCode, t3.ListName, t4.JobResponsibility, t4.FinanceModuleAccess'); $this->db->from('' . PICK_LIST_DETAILS . ' as t3'); $this->db->join('' . STAFF . ' as t4', 't4.ListCode = t3.ListCode', 'LEFT'); $this->db->where('t4.StaffID', $staffId); @@ -553,7 +553,7 @@ class Employee_model extends CI_Model } // update employee branch details - public function upate_employee_branch($empFor, $reqBanch, $req, $createby, $createon, $reqJOBRES) + public function upate_employee_branch($empFor, $reqBanch, $req, $createby, $createon, $reqJOBRES, $FinanceModuleAccess) { // print_r( count($reqBanch['BranchCode']));exit(); if( count($reqBanch['BranchCode']) > 1) { @@ -569,7 +569,7 @@ class Employee_model extends CI_Model // $branchCode = $this->get_branch_code($reqBanch['BranchCode'][0]); $branchCode = $reqBanch['BranchCode'][0]; $roleResponsibility = $reqJOBRES['JobResponsibility']; - $sql = "UPDATE ".STAFF." SET BranchCode='$branchCode', JobResponsibility='$roleResponsibility' WHERE StaffID='$empFor'"; + $sql = "UPDATE ".STAFF." SET BranchCode='$branchCode', JobResponsibility='$roleResponsibility', FinanceModuleAccess=$FinanceModuleAccess WHERE StaffID='$empFor'"; // update branch to staff table if ($this->db->query($sql) == '1') { $this->db->where('StaffID', $empFor); @@ -615,7 +615,7 @@ class Employee_model extends CI_Model // $branchCode = $this->get_branch_code($reqBanch['BranchCode'][0]); $branchCode = $reqBanch['BranchCode'][0]; $roleResponsibility = $reqJOBRES['JobResponsibility']; - $sql = "UPDATE ".STAFF." SET BranchCode='$branchCode', JobResponsibility='$roleResponsibility' WHERE StaffID='$empFor'"; + $sql = "UPDATE ".STAFF." SET BranchCode='$branchCode', JobResponsibility='$roleResponsibility', FinanceModuleAccess=$FinanceModuleAccess WHERE StaffID='$empFor'"; // update branch to staff table if ($this->db->query($sql) == '1') { $this->db->where('StaffID', $empFor); diff --git a/Apollo/api/application/models/Login_model.php b/Apollo/api/application/models/Login_model.php index ad28884b..115e189c 100755 --- a/Apollo/api/application/models/Login_model.php +++ b/Apollo/api/application/models/Login_model.php @@ -35,7 +35,7 @@ class Login_model extends CI_Model if ($password == $loginDetails->Password) { if($loginDetails->ListCode !=STUDENT){ //print_r($loginDetails);exit(); - $this->db->select('t1.MobileNumber, t1.ListCode, t1.ID, t2.BranchCode'); + $this->db->select('t1.MobileNumber, t1.ListCode, t1.ID, t2.BranchCode, t2.FinanceModuleAccess'); $this->db->from('' . LOGIN . ' as t1'); $this->db->join('' . STAFF . ' as t2', 't1.StaffID = t2.StaffID', 'LEFT'); $this->db->where('t1.MobileNumber', $mobile); diff --git a/Apollo/assets/i18n/en.json b/Apollo/assets/i18n/en.json index 0292f8ad..94c6334e 100755 --- a/Apollo/assets/i18n/en.json +++ b/Apollo/assets/i18n/en.json @@ -112,7 +112,8 @@ "MAIN": "DAY BOOK", "INCOMELISTING": "INCOME LISTING", "EXPENSELISTING": "EXPENSE LISTING", - "DAYBOOK": "DAY BOOK " + "DAYBOOK": "DAY BOOK ", + "APPROVAL": "DAY BOOK APPROVAL" }, "mydetails": { "MAIN": "MY DETAILS" diff --git a/Apollo/assets/js/config.constant.js b/Apollo/assets/js/config.constant.js index 420a7c1f..0c199858 100755 --- a/Apollo/assets/js/config.constant.js +++ b/Apollo/assets/js/config.constant.js @@ -152,6 +152,7 @@ app.constant('JS_REQUIRES', { 'daybookCtrl': 'assets/js/controllers/daybookCtrl.js', 'daybookadminCtrl': 'assets/js/controllers/daybookadminCtrl.js', 'daybooksuperadminCtrl': 'assets/js/controllers/daybooksuperadminCtrl.js', + 'daybookapprovalCtrl': 'assets/js/controllers/daybookapprovalCtrl.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 465a0910..a36d78c3 100755 --- a/Apollo/assets/js/config.router.js +++ b/Apollo/assets/js/config.router.js @@ -362,12 +362,27 @@ app.config(['$stateProvider', '$urlRouterProvider', '$controllerProvider', '$com } }).state('app.daybook', { url: '/daybook', - templateUrl: "assets/views/daybook/daybook.html", + template: '
STUDENT STATUS UPDATE
', title: 'daybook', - resolve: loadSequence('spin', 'ladda', 'angular-ladda', 'daybookCtrl','ngTable'), ncyBreadcrumb: { label: 'daybook' } + }).state('app.daybook.details', { + url: '/daybookdetails', + templateUrl: "assets/views/daybook/daybook.html", + title: 'daybookdetails', + resolve: loadSequence('spin', 'ladda', 'angular-ladda', 'daybookCtrl','ngTable'), + ncyBreadcrumb: { + label: 'daybookdetails' + } + }).state('app.daybook.approval', { + url: '/daybookApproval', + templateUrl: "assets/views/daybook/dayBookApproval.html", + title: 'Day Book Approval', + resolve: loadSequence('spin', 'ladda', 'angular-ladda', 'daybookapprovalCtrl','ngTable'), + ncyBreadcrumb: { + label: 'daybookApproval' + } }).state('app.daybookadmin', { url: '/daybookadmin', templateUrl: "assets/views/daybook/daybookadmin.html", diff --git a/Apollo/assets/js/controllers/daybookCtrl.js b/Apollo/assets/js/controllers/daybookCtrl.js index 95bc80a6..06cf009e 100755 --- a/Apollo/assets/js/controllers/daybookCtrl.js +++ b/Apollo/assets/js/controllers/daybookCtrl.js @@ -18,14 +18,15 @@ app.controller('daybookCtrl', ["$scope", "$rootScope", "toaster", "$filter", "ng $scope.init = function () { const LOCALTYPE = localDetail.localType; if(LOCALTYPE === 'R002') { - $scope.currentDate = new Date(); - var formate = "dd-MM-yyyy"; - $scope.searchData.date = $filter('date')(new Date($scope.currentDate), formate); - $scope.searchData.dateTo = $filter('date')(new Date($scope.currentDate), formate); - $scope.getDayBookList(); - $scope.getIncomeExpenseType_Status(); + $scope.currentDate = new Date(); + var formate = "dd-MM-yyyy"; + $scope.searchData.date = $filter('date')(new Date($scope.currentDate), formate); + $scope.searchData.dateTo = $filter('date')(new Date($scope.currentDate), formate); + $scope.getDayBookList(); + $scope.getIncomeExpenseType_Status(); + }else { - ipCookie.remove('cookiechk'); + ipCookie.remove('cookiechk'); $window.localStorage.clear(); $state.go('login.signin'); } @@ -33,6 +34,40 @@ app.controller('daybookCtrl', ["$scope", "$rootScope", "toaster", "$filter", "ng } +$scope.dayBookApprovalAccess = ''; + // Finance module access control + function getFinanceModuleAccess() { + var getFinacnceModuleAcccessCtrl = { + method: 'POST', + url: apiPoint.url + 'empDayBookModuleAccessChk/', + headers: { + 'Content-Type': 'application/json' + }, + data: { + localReqDetails: localDetails + } + }; + $http(getFinacnceModuleAcccessCtrl).then(function (response) { + if (response.data.dayBkAccessChkStatus) { + $scope.dayBookApprovalAccess = response.data.dayBkAccessChk_Value; + $scope.currentDate = new Date(); + var formate = "dd-MM-yyyy"; + $scope.searchData.date = $filter('date')(new Date($scope.currentDate), formate); + $scope.searchData.dateTo = $filter('date')(new Date($scope.currentDate), formate); + $scope.getDayBookList(); + $scope.getIncomeExpenseType_Status(); + return true; + } else { + return true; + } + }); + + } + + // $scope.getApproveLoad = function() { + // alert(); + // } + // change from date, update and call search functionality $scope.changeDate = function () { if($scope.searchData.date !== undefined) { diff --git a/Apollo/assets/js/controllers/daybookadminCtrl.js b/Apollo/assets/js/controllers/daybookadminCtrl.js index 92a7c034..5724d992 100755 --- a/Apollo/assets/js/controllers/daybookadminCtrl.js +++ b/Apollo/assets/js/controllers/daybookadminCtrl.js @@ -20,30 +20,69 @@ app.controller('daybookadminCtrl', ["$scope", "$rootScope", "toaster", "$filter" $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.searchData.dateTo = $filter('date')(new Date($scope.currentDate), formate); - $scope.getIncomeExpenseType_Status(); - $scope.getDayBookList(); - } else { - ipCookie.remove('cookiechk'); - $window.localStorage.clear(); - $state.go('login.signin'); - // $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.searchData.dateTo = $filter('date')(new Date($scope.currentDate), formate); - // $scope.getIncomeExpenseType_Status(); - // $scope.getDayBookList(); + // getFinanceModuleAccess(); + // if(getFinanceModuleAccess()){ + $scope.dayBookApprovalAccess = localDetail.is_DayBookApproval_Access; + $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.searchData.dateTo = $filter('date')(new Date($scope.currentDate), formate); + $scope.getIncomeExpenseType_Status(); + $scope.getDayBookList(); + // } + } else { + ipCookie.remove('cookiechk'); + $window.localStorage.clear(); + $state.go('login.signin'); + // $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.searchData.dateTo = $filter('date')(new Date($scope.currentDate), formate); + // $scope.getIncomeExpenseType_Status(); + // $scope.getDayBookList(); } } + $scope.dayBookApprovalAccess = ''; + + // Finance module access control + function getFinanceModuleAccess() { + var getFinacnceModuleAcccessCtrl = { + method: 'POST', + url: apiPoint.url + 'empDayBookModuleAccessChk/', + headers: { + 'Content-Type': 'application/json' + }, + data: { + localReqDetails: localDetails + } + }; + $http(getFinacnceModuleAcccessCtrl).then(function (response) { + if (response.data.dayBkAccessChkStatus) { + $scope.dayBookApprovalAccess = response.data.dayBkAccessChk_Value; + $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.searchData.dateTo = $filter('date')(new Date($scope.currentDate), formate); + $scope.getIncomeExpenseType_Status(); + $scope.getDayBookList(); + return true; + } else { + return true; + } + }); + + } + + + // change from date, update and call search functionality $scope.changeDate = function () { if($scope.searchData.date !== undefined) { @@ -226,7 +265,7 @@ app.controller('daybookadminCtrl', ["$scope", "$rootScope", "toaster", "$filter" } else { var selectedItems = []; var ItemsSelected = $scope.searchResultDetails.filter(function (item) { - if (item.Selected === true) { + if (item.Selected === true && item.Status === 'Pending') { let itemGetID = new getUpdateDetails(item.ID); selectedItems.push(itemGetID); return true; @@ -237,6 +276,7 @@ app.controller('daybookadminCtrl', ["$scope", "$rootScope", "toaster", "$filter" this.ListCodeStatus = $scope.myStatusModel.staus; this.comments = $scope.myStatusModel.description; } + if(selectedItems.length > 0) { var updateStudyMaterial = { method: 'POST', url: apiPoint.url + 'updateDayBookStatusAdmin/', @@ -259,6 +299,9 @@ app.controller('daybookadminCtrl', ["$scope", "$rootScope", "toaster", "$filter" swal("Failed!", response.data.message, "error"); } }); + } else { + swal("Warning!", "Item not Selected", "warning"); + } } }, reset: function (form) { diff --git a/Apollo/assets/js/controllers/daybookapprovalCtrl.js b/Apollo/assets/js/controllers/daybookapprovalCtrl.js new file mode 100644 index 00000000..74e2168a --- /dev/null +++ b/Apollo/assets/js/controllers/daybookapprovalCtrl.js @@ -0,0 +1,589 @@ +'use strict'; +/** + * daybook details capturing + * + */ +app.controller('daybookapprovalCtrl', ["$scope", "$rootScope", "toaster", "$filter", "ngTableParams", "API_POINTS", "$localStorage", "$http", "$state", 'ipCookie', '$window', function ($scope, $rootScope, toaster, $filter, ngTableParams, apiPoint, $localStorage, $http, $state, ipCookie, $window) { + + // get local client details + var localDetail = JSON.parse(localStorage.getItem('localObj')); + var localDetails = ipCookie('cookiechk'); + $scope.localTypeViewAdmin = false; + $scope.localTypeViewSuperAdmin = false; + + $scope.searchData = { + "date": "", + "dateTo": "" + } + + // load functionality when page get loaded + $scope.init = function () { + const LOCALTYPE = localDetail.localType; + if (LOCALTYPE === 'R002') { + // getFinanceModuleAccess(); + // // if(getFinanceModuleAccess()){ + $scope.dayBookApprovalAccess = localDetail.is_DayBookApproval_Access; + $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.searchData.dateTo = $filter('date')(new Date($scope.currentDate), formate); + $scope.getIncomeExpenseType_Status(); + $scope.getDayBookList(); + // } + } else { + ipCookie.remove('cookiechk'); + $window.localStorage.clear(); + $state.go('login.signin'); + // $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.searchData.dateTo = $filter('date')(new Date($scope.currentDate), formate); + // $scope.getIncomeExpenseType_Status(); + // $scope.getDayBookList(); + } + } + + $scope.dayBookApprovalAccess = ''; + + // Finance module access control + function getFinanceModuleAccess() { + var getFinacnceModuleAcccessCtrl = { + method: 'POST', + url: apiPoint.url + 'empDayBookModuleAccessChk/', + headers: { + 'Content-Type': 'application/json' + }, + data: { + localReqDetails: localDetails + } + }; + $http(getFinacnceModuleAcccessCtrl).then(function (response) { + if (response.data.dayBkAccessChkStatus) { + $scope.dayBookApprovalAccess = response.data.dayBkAccessChk_Value; + $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.searchData.dateTo = $filter('date')(new Date($scope.currentDate), formate); + $scope.getIncomeExpenseType_Status(); + $scope.getDayBookList(); + return true; + } else { + return true; + } + }); + + } + + + + // change from date, update and call search functionality + $scope.changeDate = function () { + if($scope.searchData.date !== undefined) { + var formate = "dd-MM-yyyy"; + $scope.searchData.date = $filter('date')(new Date($scope.searchData.date), formate); + $scope.getDayBookList(); + } else { + $scope.searchData.date = ''; + $scope.getDayBookList(); + } + } + + // change to date, update and call search functionality + $scope.changeToDate = function () { + if($scope.searchData.dateTo !== undefined) { + var formate = "dd-MM-yyyy"; + $scope.searchData.dateTo = $filter('date')(new Date($scope.searchData.dateTo), formate); + $scope.getDayBookList(); + } else { + $scope.searchData.dateTo = ''; + $scope.getDayBookList(); + } + } + + // sorting function for table params + $scope.sort = function (keyname) { + // alert(); + $scope.sortKey = keyname; //set the sortKey to the param passed + $scope.reverse = !$scope.reverse; //if true make it false and vice versa + } + + // income expense type status list + $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.loadingsearch = false; + $scope.noRecordFound = true; + $scope.noRecordFoundSearch = false; + $scope.dataLengthIncome = 0; + $scope.dataLengthExpense = 0; + // day book entry list + $scope.getDayBookList = function () { + $scope.loadingsearch = true; + $scope.noRecordFoundSearch = false; + 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.loadingsearch = false; + // $scope.data = response.data.dayBookListDetails; + let datas = response.data.dayBookListDetails; + if (datas.length <= 0) { + $scope.noRecordFoundSearch = true; + } else { + $scope.noRecordFoundSearch = false; + } + let searchResultDetailsBef = datas.filter(val => { + return val.Name == 'I001' ? 1 : 0; + }); + $scope.IncomeData = datas.filter(val => { + return val.Name == 'I002' ? 1 : 0; + }); + $scope.dataLengthIncome = $scope.IncomeData.length; + const filterAddSelect = searchResultDetailsBef.filter(val => { + val['Selected'] = false; + return val; + }); + $scope.searchResultDetails = filterAddSelect; + $scope.dataLengthExpense = $scope.searchResultDetails.length; + // 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.loadingsearch = false; + } + }); + } + + // 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; + // open popup window when checkbox get selected / close popup window uncheck the selected items + $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; + } + } + + // update the status details + $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 && item.Status === 'Pending' ) { + 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; + } + if(selectedItems.length > 0) { + 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"); + } + }); + } else { + swal("Warning!", "Item not Selected", "warning"); + } + + } + }, + 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 + } + } + + // delete the entry row from the daybook list + $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": "" + } + + // add a new entry to the day book list + $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); + } + } + } + + // update daybook entry data from the list + $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/employeeCtrl.js b/Apollo/assets/js/controllers/employeeCtrl.js index 0da07f2d..a4c85042 100755 --- a/Apollo/assets/js/controllers/employeeCtrl.js +++ b/Apollo/assets/js/controllers/employeeCtrl.js @@ -45,6 +45,7 @@ app.controller('staffCtrl', ["$scope", "toaster", "$filter", "ngTableParams", "$ 'role': '', 'jobResponsibility': '', 'switchsetting': true, + 'finaceModuleAccess': false }; var data = ''; $scope.roleDetails = ''; @@ -199,6 +200,7 @@ app.controller('staffCtrl', ["$scope", "toaster", "$filter", "ngTableParams", "$ $scope.empBranchDetails = { arr: $scope.branchArr, } + response.data.role_details[0].FinanceModuleAccess = response.data.role_details[0].FinanceModuleAccess == 1 ? true : false; $scope.empRoleDetail = response.data.role_details[0]; } else { } @@ -395,6 +397,8 @@ app.controller('staffCtrl', ["$scope", "toaster", "$filter", "ngTableParams", "$ $scope.myModel.dateofjoining = $filter('date')(new Date($scope.myModel.dateofjoining), formate); // alert($scope.myModel.dateofbirth) +// alert(JSON.stringify($scope.myModel)); + var idProof = $scope.files[0]; if (idProof !== undefined) { var formData = new FormData(); @@ -468,6 +472,7 @@ app.controller('staffCtrl', ["$scope", "toaster", "$filter", "ngTableParams", "$ 'role': '', 'jobResponsibility': '', 'switchsetting': true, + 'finaceModuleAccess': false }; } } @@ -600,6 +605,7 @@ app.controller('staffCtrl', ["$scope", "toaster", "$filter", "ngTableParams", "$ $scope.updateEmpBranchDetails = function (form, empRole, empBranchs, p) { // alert(empBranchs.arr.length); + // alert(JSON.stringify(empRole)); if (empBranchs.arr.length >= 1) { var firstError = null; if (form.$invalid) { @@ -632,7 +638,8 @@ app.controller('staffCtrl', ["$scope", "toaster", "$filter", "ngTableParams", "$ 'updateRole': empRole.ListCode, 'JobResponsibility': empRole.JobResponsibility, 'updateBranch': $scope.arr1, - 'updateBy': localDetails.localUserID + 'updateBy': localDetails.localUserID, + 'FinanceModuleAccess': empRole.FinanceModuleAccess } // p.IsActive = p.IsActive === true ? 1 : 0; var req = { diff --git a/Apollo/assets/js/controllers/loginCtrl.js b/Apollo/assets/js/controllers/loginCtrl.js index d3b94c3c..cdb0641b 100755 --- a/Apollo/assets/js/controllers/loginCtrl.js +++ b/Apollo/assets/js/controllers/loginCtrl.js @@ -59,6 +59,7 @@ app.controller('loginCtrl', ["$scope", "$http", "API_POINTS", "$state", '$rootSc "localUserID": $scope.responseData.ID, "localBranchID": $scope.responseData.BranchCode, 'localType': $scope.responseData.ListCode, + 'is_DayBookApproval_Access': $scope.responseData.FinanceModuleAccess, 'localOn': localDateTime, 'status': 'active' } diff --git a/Apollo/assets/js/controllers/sessionCtrl.js b/Apollo/assets/js/controllers/sessionCtrl.js index 31b4c4ef..647e48aa 100755 --- a/Apollo/assets/js/controllers/sessionCtrl.js +++ b/Apollo/assets/js/controllers/sessionCtrl.js @@ -21,6 +21,7 @@ app.controller('sessionCtrl', ["$scope", "$localStorage", "$state", 'ipCookie', $scope.getLoginDash = 'Admin'; } else if (localDetail.localType == 'R002') { $scope.getLoginDash = 'staff'; + $scope.is_active_DayBookAprlAccess = localDetail.is_DayBookApproval_Access; } else if (localDetail.localType == 'R001') { $scope.getLoginDash = 'student'; diff --git a/Apollo/assets/views/daybook/dayBookApproval.html b/Apollo/assets/views/daybook/dayBookApproval.html new file mode 100644 index 00000000..efc69a7d --- /dev/null +++ b/Apollo/assets/views/daybook/dayBookApproval.html @@ -0,0 +1,403 @@ + +
+
+
+

{{ mainTitle }}

+
+
+
+
+ + +
+
+
+ +
+ + +
+
+
+
+ + +
+ +
+ + + +
+
+
+ +
+ + + +
+
+
+ + + + Type is Required + +
+
+ +
+
+ Loading... +
+
+
+

No + records found...

+
+
+ + +
+
+
+
+ Total Count: + {{ dataLengthIncome }} +
+
+
+
+
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Date + + Income/Expense + + Voucher Number + + Paid To / Received From + + Description + + Type + + Amount + + Comments + +
{{p.Date}}{{p.ListName}}{{p.VoucherNumber}}{{p.PaidTo}} +
+
+ {{p.PaidDescription}} +
+
+
{{p.TypeName}}{{p.Amount}} +
+
+ {{p.Description}} +
+
+
+ + +
+
+
+ + +
+
+
+
+ Total Count: + {{ dataLengthExpense }} +
+
+
+
+
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+ + Date + + Income/Expense + + Voucher Number + + Paid To / Received From + + Description + + Type + + Amount + + Comments + + Status + +
+ + {{p.Date}}{{p.ListName}}{{p.VoucherNumber}}{{p.PaidTo}} +
+
+ {{p.PaidDescription}} +
+
+
{{p.TypeName}}{{p.Amount}} +
+
+ {{p.Description}} +
+
+
{{p.Status}} + {{p.Status}} + {{p.Status}} +
+ + +
+
+ +
+
+
+
+
+
+
+
+
+ +
+
+ + Update Status + +
+
+
+
+ + + + Status is Required + +
+ +
+
+
+
+ + +