diff --git a/Apollo/api/application/models/DayBook_model.php b/Apollo/api/application/models/DayBook_model.php index e692c2df..de502f1a 100755 --- a/Apollo/api/application/models/DayBook_model.php +++ b/Apollo/api/application/models/DayBook_model.php @@ -64,11 +64,11 @@ class DayBook_model extends CI_Model $toDate = $dTo->format('Y-m-d'); $reqpayType = $reqDataBy['localBranchID']; - $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 + $querys = "SELECT t1.ID as ORDER_ID, 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 ID DESC"; - + AND '$toDate' AND t1.BranchCode = '$reqpayType' ORDER BY ORDER_ID DESC"; +// echo $querys;exit(); // $this->db->where(' STR_TO_DATE(t1.Date, %d-%m-%Y) >=', $fromDate); // $this->db->where(' STR_TO_DATE(t1.Date, %d-%m-%Y) >=', $toDate); // $this->db->where('t1.Date', $reqData['date']); @@ -84,9 +84,10 @@ 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, 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 + $querys = "SELECT t1.ID as ORDER_ID, 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 ID DESC"; + WHERE t1.BranchCode = '$reqpayType' ORDER BY ORDER_ID DESC"; + } // $this->db->join('' . COURSE . ' as t2', 't2.UniversityID = t1.UniversityID', 'LEFT'); @@ -126,10 +127,10 @@ class DayBook_model extends CI_Model $latestUpdateDetails2 = $latestUpdate2->result(); foreach( $latestUpdateDetails2 as $clip){ - if($clip->Name == 'I002') { + if($clip->Name == 'I002' && ($clip->Status == "Pending" || $clip->Status == "Approved" || $clip->Status == "approved" || $clip->Status == "pending")) { //Income $currBalance = $currBalance + $clip->Amount; - }else if ($clip->Name == 'I001') { + }else if ($clip->Name == 'I001' && ($clip->Status == "Pending" || $clip->Status == "Approved" || $clip->Status == "approved" || $clip->Status == "pending")) { //Expense $currBalance = $currBalance - $clip->Amount; } else { @@ -152,52 +153,56 @@ class DayBook_model extends CI_Model // delete the daybook fees entry details public function delete_dayBookFeePayableDetails($id) { -// echo $id;exit(); - $this->db->select('FeesPaymentID'); + $this->db->select('FeesPaymentID, BranchCode'); $this->db->from(DAYBOOKMASTER); $this->db->where('ID', $id); $typeDetails = $this->db->get(); $typeStateDetails = $typeDetails->result(); - // print_r($typeStateDetails);exit(); $getID = $typeStateDetails[0]->FeesPaymentID; - // if($getID != '' || $getID != null ) { - // $sql1 = " DELETE FROM T_Students_Fees_PaidDetails WHERE ID ='$getID'"; - // // update branch to staff_branch table - // if ($this->db->query($sql1) == '1') { - // $sql2 = " DELETE FROM ".DAYBOOKMASTER." WHERE ID ='$id'"; - // if ($this->db->query($sql2) == '1') { - // $result['deletedStatus'] = true; - // $result['message'] = "Entry is Deleted"; - // }else{ - // $result['deletedStatus'] = false; - // $result['message'] = "Something went wrong.please try again"; - // } - // } else { - // $result['deletedStatus'] = false; - // $result['message'] = "Something went wrong.please try again"; - // } - // return $result; - // } else { - // $sql1 = " DELETE FROM ".DAYBOOKMASTER." WHERE ID ='$id'"; - // // update branch to staff_branch table - // if ($this->db->query($sql1) == '1') { - // $result['deletedStatus'] = true; - // $result['message'] = "Entry is Deleted"; - // } else { - // $result['deletedStatus'] = false; - // $result['message'] = "Something went wrong.please try again"; - // } - // return $result; - // } + $branch = $typeStateDetails[0]->BranchCode; + // echo $id;exit(); try { $sql1 = " DELETE FROM ".STUDENTS_FEES_PAID." WHERE ID ='$getID'"; $this->db->query($sql1); } catch(Exception $e) { echo 'error'; } finally { - $sql1 = " DELETE FROM ".DAYBOOKMASTER." WHERE ID ='$id'"; + $sql = "SELECT * FROM ".DAYBOOKMASTER." WHERE (BranchCode = '$branch' AND ID < '$id') + ORDER BY ID DESC + LIMIT 1 "; + + $currBalance = 0; + $currID = $id; + $latestUpdate = $this->db->query($sql); + $latestUpdateDetails = $latestUpdate->result(); + If(is_array($latestUpdateDetails) && count($latestUpdateDetails)>0) + { + $currBalance = $latestUpdateDetails[0]->Balance; + $currID = $latestUpdateDetails[0]->ID; + }else{ + } + $sql1 = " DELETE FROM ".DAYBOOKMASTER." WHERE FeesPaymentID ='$getID'"; // update branch to staff_branch table - if ($this->db->query($sql1) == '1') { + if ($this->db->query($sql1) == '1') { + + $sql2 = "SELECT * FROM ".DAYBOOKMASTER." WHERE (BranchCode = '$branch' AND ID > '$currID') + ORDER BY ID ASC"; + $latestUpdate2 = $this->db->query($sql2); + $latestUpdateDetails2 = $latestUpdate2->result(); + + foreach( $latestUpdateDetails2 as $clip){ + if($clip->Name == 'I002' && ($clip->Status == "Pending" || $clip->Status == "Approved" || $clip->Status == "approved" || $clip->Status == "pending")) { + //Income + $currBalance = $currBalance + $clip->Amount; + }else if ($clip->Name == 'I001' && ($clip->Status == "Pending" || $clip->Status == "Approved" || $clip->Status == "approved" || $clip->Status == "pending")) { + //Expense + $currBalance = $currBalance - $clip->Amount; + } else { + } + $updateSql = "UPDATE ".DAYBOOKMASTER." SET Balance ='$currBalance' WHERE ID = '$clip->ID'"; + $this->db->query($updateSql); + } + $result['deletedStatus'] = true; $result['message'] = "Entry is Deleted"; } else { @@ -215,9 +220,14 @@ class DayBook_model extends CI_Model $sql = "SELECT * FROM ".DAYBOOKMASTER." WHERE (BranchCode = '$branch' AND ID < '$upFor') ORDER BY ID DESC LIMIT 1 "; + $prevBalance = 0; $latestUpdate = $this->db->query($sql); $latestUpdateDetails = $latestUpdate->result(); + If(is_array($latestUpdateDetails) && count($latestUpdateDetails)>0) + { $prevBalance = $latestUpdateDetails[0]->Balance; + }else{ + } if($Arr['Name'] == 'I002') { //Income @@ -245,10 +255,10 @@ class DayBook_model extends CI_Model $latestUpdateDetails2 = $latestUpdate2->result(); foreach( $latestUpdateDetails2 as $clip){ - if($clip->Name == 'I002') { + if($clip->Name == 'I002' && ($clip->Status == "Pending" || $clip->Status == "Approved" || $clip->Status == "approved" || $clip->Status == "pending")) { //Income $currBalance = $currBalance + $clip->Amount; - }else if ($clip->Name == 'I001') { + }else if ($clip->Name == 'I001' && ($clip->Status == "Pending" || $clip->Status == "Approved" || $clip->Status == "approved" || $clip->Status == "pending")) { //Expense $currBalance = $currBalance - $clip->Amount; } else { @@ -272,9 +282,16 @@ class DayBook_model extends CI_Model $sql = "SELECT * FROM ".DAYBOOKMASTER." WHERE BranchCode = '$branch' ORDER BY CreatedOn DESC LIMIT 1"; + $prevBalance = 0; $latestUpdate = $this->db->query($sql); $latestUpdateDetails = $latestUpdate->result(); + + If(is_array($latestUpdateDetails) && count($latestUpdateDetails)>0) + { $prevBalance = $latestUpdateDetails[0]->Balance; + }else{ + } + if($Arr['Name'] == 'I002') { //Income $Arr['Balance'] = $prevBalance + $Arr['Amount']; @@ -326,7 +343,7 @@ class DayBook_model extends CI_Model $currBalance = 0; $latestUpdate = $this->db->query($sql); $latestUpdateDetails = $latestUpdate->result(); - if($updateDataDetails[0]->Name == 'I002') { + if($updateDataDetails[0]->Name == 'I002' ) { //Income $currBalance = $latestUpdateDetails[0]->Balance + $Amount; }else if ($updateDataDetails[0]->Name == 'I001') { @@ -349,10 +366,10 @@ class DayBook_model extends CI_Model $latestUpdate2 = $this->db->query($sql2); $latestUpdateDetails2 = $latestUpdate2->result(); foreach( $latestUpdateDetails2 as $clip){ - if($clip->Name == 'I002') { + if($clip->Name == 'I002' && ($clip->Status == "Pending" || $clip->Status == "Approved" || $clip->Status == "approved" || $clip->Status == "pending")) { //Income $currBalance = $currBalance + $clip->Amount; - }else if ($clip->Name == 'I001') { + }else if ($clip->Name == 'I001' && ($clip->Status == "Pending" || $clip->Status == "Approved" || $clip->Status == "approved" || $clip->Status == "pending")) { //Expense $currBalance = $currBalance - $clip->Amount; } else { @@ -366,57 +383,108 @@ class DayBook_model extends CI_Model $result['addStatus'] = false; $result['message'] = "Something went wrong.please try again"; } - } else if( $status == "Rejected" || $status == "rejected" ) { - - + } else if( $status == "Rejected" || $status == "rejected" ) { $mysql = "SELECT * FROM ".DAYBOOKMASTER." WHERE ID = '$updateFor'"; $updateDetails = $this->db->query($mysql); $updateDataDetails = $updateDetails->result(); $branch = $updateDataDetails[0]->BranchCode; $Amount = 0; $Amount = $updateDataDetails[0]->Amount; + if($updateDataDetails[0]->PaymentStatus === '1' ){ - $sql = "SELECT * FROM ".DAYBOOKMASTER." WHERE (BranchCode = '$branch' AND ID < '$updateFor') - ORDER BY ID DESC - LIMIT 1 "; + + $sql = "SELECT * FROM ".DAYBOOKMASTER." WHERE (BranchCode = '$branch' AND ID < '$updateFor') + ORDER BY ID DESC + LIMIT 1 "; - $currBalance = 0; - $latestUpdate = $this->db->query($sql); - $latestUpdateDetails = $latestUpdate->result(); - $currBalance = $latestUpdateDetails[0]->Balance; + $currBalance = 0; + $latestUpdate = $this->db->query($sql); + $latestUpdateDetails = $latestUpdate->result(); + $currBalance = $latestUpdateDetails[0]->Balance; - $sql = "UPDATE ".DAYBOOKMASTER." - SET Status = '$status', Approval_By = '$Approval_By' , - Approval_Comments = '$Approval_Comments', UpdatedBy = '$UpdatedBy' , UpdatedOn = '$UpdatedOn' , Balance = '$currBalance' - WHERE id = '$updateFor' "; - $mBranchDetails = $this->db->query($sql); - // echo $mBranchDetails; - // echo $this->db->affected_rows(); exit(); - if ($this->db->affected_rows() >= 1) { - $sql2 = "SELECT * FROM ".DAYBOOKMASTER." WHERE (BranchCode = '$branch' AND ID > '$updateFor') - ORDER BY ID ASC"; - $latestUpdate2 = $this->db->query($sql2); - $latestUpdateDetails2 = $latestUpdate2->result(); - foreach( $latestUpdateDetails2 as $clip){ - if($clip->Name == 'I002') { - //Income - $currBalance = $currBalance + $clip->Amount; - }else if ($clip->Name == 'I001') { - //Expense - $currBalance = $currBalance - $clip->Amount; - } else { + $sql = "UPDATE ".DAYBOOKMASTER." + SET Status = '$status', Approval_By = '$Approval_By' , + Approval_Comments = '$Approval_Comments', UpdatedBy = '$UpdatedBy' , UpdatedOn = '$UpdatedOn' , Balance = '$currBalance' + WHERE id = '$updateFor' "; + $mBranchDetails = $this->db->query($sql); + // echo $mBranchDetails; + // echo $this->db->affected_rows(); exit(); + if ($this->db->affected_rows() >= 1) { + $sql2 = "SELECT * FROM ".DAYBOOKMASTER." WHERE (BranchCode = '$branch' AND ID > '$updateFor') + ORDER BY ID ASC"; + $latestUpdate2 = $this->db->query($sql2); + $latestUpdateDetails2 = $latestUpdate2->result(); + foreach( $latestUpdateDetails2 as $clip){ + if($clip->Name == 'I002' && ($clip->Status == "Pending" || $clip->Status == "Approved" || $clip->Status == "approved" || $clip->Status == "pending")) { + //Income + $currBalance = $currBalance + $clip->Amount; + }else if ($clip->Name == 'I001' && ($clip->Status == "Pending" || $clip->Status == "Approved" || $clip->Status == "approved" || $clip->Status == "pending")) { + //Expense + $currBalance = $currBalance - $clip->Amount; + } else { + } + $updateSql = "UPDATE ".DAYBOOKMASTER." SET Balance ='$currBalance' WHERE ID = '$clip->ID'"; + $this->db->query($updateSql); } - $updateSql = "UPDATE ".DAYBOOKMASTER." SET Balance ='$currBalance' WHERE ID = '$clip->ID'"; - $this->db->query($updateSql); + $result['addStatus'] = true; + $result['message'] = "Successfully Details Updated"; + } else { + $result['addStatus'] = false; + $result['message'] = "Something went wrong.please try again"; + } + } else if($updateDataDetails[0]->PaymentStatus === '0') { + $currentVoucheNumber = $updateDataDetails[0]->VoucherNumber; + $mySql = "SELECT * FROM ".DAYBOOKMASTER." WHERE (BranchCode = '$branch' AND VoucherNumber = '$currentVoucheNumber') + ORDER BY ID ASC + LIMIT 1 "; + $mySqlUpdate = $this->db->query($mySql); + $mySqlUpdateDetails = $mySqlUpdate->result(); + $mySqlUpdateDetailsID = $mySqlUpdateDetails[0]->ID; + + $sql = "SELECT * FROM ".DAYBOOKMASTER." WHERE (BranchCode = '$branch' AND ID < '$mySqlUpdateDetailsID') + ORDER BY ID DESC + LIMIT 1 "; + $currBalance = 0; + $latestUpdate = $this->db->query($sql); + $latestUpdateDetails = $latestUpdate->result(); + If(is_array($latestUpdateDetails) && count($latestUpdateDetails)>0) + { + $currBalance = $latestUpdateDetails[0]->Balance; + }else{ } - $result['addStatus'] = true; - $result['message'] = "Successfully Details Updated"; - } else { - $result['addStatus'] = false; - $result['message'] = "Something went wrong.please try again"; + $sql = "UPDATE ".DAYBOOKMASTER." + SET Status = '$status', Approval_By = '$Approval_By' , + Approval_Comments = '$Approval_Comments', UpdatedBy = '$UpdatedBy' , UpdatedOn = '$UpdatedOn' , Balance = '$currBalance' + WHERE VoucherNumber = '$currentVoucheNumber' "; + $mBranchDetails = $this->db->query($sql); + // echo $mBranchDetails; + // echo $this->db->affected_rows(); exit(); + if ($this->db->affected_rows() >= 1) { + $sql2 = "SELECT * FROM ".DAYBOOKMASTER." WHERE (BranchCode = '$branch' AND ID > '$updateFor') + ORDER BY ID ASC"; + $latestUpdate2 = $this->db->query($sql2); + $latestUpdateDetails2 = $latestUpdate2->result(); + foreach( $latestUpdateDetails2 as $clip){ + if($clip->Name == 'I002' && ($clip->Status == "Pending" || $clip->Status == "Approved" || $clip->Status == "approved" || $clip->Status == "pending")) { + //Income + $currBalance = $currBalance + $clip->Amount; + }else if ($clip->Name == 'I001' && ($clip->Status == "Pending" || $clip->Status == "Approved" || $clip->Status == "approved" || $clip->Status == "pending")) { + //Expense + $currBalance = $currBalance - $clip->Amount; + } else { + } + $updateSql = "UPDATE ".DAYBOOKMASTER." SET Balance ='$currBalance' WHERE ID = '$clip->ID'"; + $this->db->query($updateSql); + } + $result['addStatus'] = true; + $result['message'] = "Successfully Details Updated"; + } else { + $result['addStatus'] = false; + $result['message'] = "Something went wrong.please try again"; + } + + } } - - } return $result; } diff --git a/Apollo/assets/js/config.constant.js b/Apollo/assets/js/config.constant.js index 5885861b..903156a0 100755 --- a/Apollo/assets/js/config.constant.js +++ b/Apollo/assets/js/config.constant.js @@ -153,6 +153,7 @@ app.constant('JS_REQUIRES', { 'daybookadminCtrl': 'assets/js/controllers/daybookadminCtrl.js', 'daybooksuperadminCtrl': 'assets/js/controllers/daybooksuperadminCtrl.js', 'daybookapprovalCtrl': 'assets/js/controllers/daybookapprovalCtrl.js', + 'daybookadminapprovalCtrl': 'assets/js/controllers/daybookadminapprovalCtrl.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 5f7b8494..f20f78cb 100755 --- a/Apollo/assets/js/config.router.js +++ b/Apollo/assets/js/config.router.js @@ -416,13 +416,30 @@ app.config(['$stateProvider', '$urlRouterProvider', '$controllerProvider', '$com } }).state('app.daybookadmin', { url: '/daybookadmin', - templateUrl: "assets/views/daybook/daybookadmin.html", + template: '
STUDENT STATUS UPDATE
', title: 'Income/Expense', - resolve: loadSequence('spin', 'ladda', 'angular-ladda', 'daybookadminCtrl','ngTable'), ncyBreadcrumb: { label: 'Income/Expense' + } + }).state('app.daybookadmin.details', { + url: '/daybookadmindetails', + templateUrl: "assets/views/daybook/daybookadmin.html", + title: 'Income/Expense', + resolve: loadSequence('spin', 'ladda', 'angular-ladda', 'daybookadminCtrl','ngTable'), + ncyBreadcrumb: { + label: 'Income/Expense' + } + }) + .state('app.daybookadmin.approval', { + url: '/daybookadminApproval', + templateUrl: "assets/views/daybook/dayBookadminApproval.html", + title: 'Approve expense', + resolve: loadSequence('spin', 'ladda', 'angular-ladda', 'daybookadminapprovalCtrl','ngTable'), + ncyBreadcrumb: { + label: 'Approve expense' } - }).state('app.daybooksuperadmin', { + }) + .state('app.daybooksuperadmin', { url: '/daybooksuperadmin', templateUrl: "assets/views/daybook/daybooksuperadmin.html", title: 'Income/Expense', diff --git a/Apollo/assets/js/controllers/daybookadminCtrl.js b/Apollo/assets/js/controllers/daybookadminCtrl.js index 4ae71ffa..b0efb100 100755 --- a/Apollo/assets/js/controllers/daybookadminCtrl.js +++ b/Apollo/assets/js/controllers/daybookadminCtrl.js @@ -3,54 +3,40 @@ * daybook details capturing * */ -app.controller('daybookadminCtrl', ["$scope", "$rootScope", "toaster", "$filter", "ngTableParams", "API_POINTS", "$localStorage", "$http", "$state", 'ipCookie', '$window', function ($scope, $rootScope, toaster, $filter, ngTableParams, apiPoint, $localStorage, $http, $state, ipCookie, $window) { +app.controller('daybookadminCtrl', ["$scope", "$rootScope", "toaster", "$filter", "ngTableParams", "API_POINTS", "$localStorage", "$http", "$state", 'ipCookie', '$window','SweetAlert', function ($scope, $rootScope, toaster, $filter, ngTableParams, apiPoint, $localStorage, $http, $state, ipCookie, $window, SweetAlert) { // 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 + // get the data while page loading functions goes here $scope.init = function () { - const LOCALTYPE = localDetail.localType; - if (LOCALTYPE === 'R003') { - // getFinanceModuleAccess(); - // if(getFinanceModuleAccess()){ - $scope.dayBookApprovalAccess = localDetail.is_DayBookApproval_Access; - $scope.showTheRefValue = 'I001'; - $scope.localTypeViewAdmin = true; + const LOCALTYPE = localDetail.localType; + if(LOCALTYPE === 'R003') { $scope.currentDate = new Date(); + var d = new Date(); + $scope.oneMonthBefore = d.setMonth(d.getMonth()-1); + // alert($scope.oneMonthBefore); var formate = "dd-MM-yyyy"; - $scope.searchData.date = $filter('date')(new Date($scope.currentDate), formate); + $scope.searchData.date = $filter('date')(new Date($scope.oneMonthBefore), 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.getIncomeExpenseType_Status(); + + }else {alert(); + ipCookie.remove('cookiechk'); + $window.localStorage.clear(); + $state.go('login.signin'); } } - $scope.dayBookApprovalAccess = ''; - - // Finance module access control +$scope.dayBookApprovalAccess = ''; + // Finance module access control function getFinanceModuleAccess() { var getFinacnceModuleAcccessCtrl = { method: 'POST', @@ -65,14 +51,12 @@ app.controller('daybookadminCtrl', ["$scope", "$rootScope", "toaster", "$filter" $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(); + $scope.getIncomeExpenseType_Status(); return true; } else { return true; @@ -80,8 +64,10 @@ app.controller('daybookadminCtrl', ["$scope", "$rootScope", "toaster", "$filter" }); } - + // $scope.getApproveLoad = function() { + // alert(); + // } // change from date, update and call search functionality $scope.changeDate = function () { @@ -107,14 +93,46 @@ app.controller('daybookadminCtrl', ["$scope", "$rootScope", "toaster", "$filter" } } - // sorting function for table params + // 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.noRecordFound = true; + $scope.dataLength = 0; + // get day book type name list + $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; + $scope.dataLength = $scope.data.length; + if ($scope.data.length !== 0) { + $scope.noRecordFound = false; + } else { + $scope.noRecordFound = true; + } + // alert(JSON.stringify($scope.data)); + // $scope.incomeExpenseType = response.data.typeNameList; + } else { + + } + }); + } + + // income expense type status list $scope.getIncomeExpenseType_Status = function () { var getIncomeExpenseType = { method: 'POST', @@ -135,269 +153,16 @@ app.controller('daybookadminCtrl', ["$scope", "$rootScope", "toaster", "$filter" }); } - $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(" ", "Updated successfully.", "success"); - // for success state - $scope.getDayBookList(); - $scope.allSelected('undefined'); - $scope.OpenWindowStatus = false; - } else { - swal(" ", response.data.message, "error"); - } - }); - } else { - swal(" ", "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; - }); - + // parse the income and expense type from the list $scope.getType = function (type) { - // alert(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 === 'Income' ? $scope.getIncomeTypes : $scope.getExpenseTypes; + $scope.getTypes = type === 'I002' ? $scope.getIncomeTypes : $scope.getExpenseTypes; }; $scope.editId = -1; @@ -415,7 +180,12 @@ app.controller('daybookadminCtrl', ["$scope", "$rootScope", "toaster", "$filter" "type": "", "amount": "", "status": "", - "description": "" + "description": "", + "paidTo": "", + "description_paid": "", + "voucherNumber": "", + "branch":"", + "name":"" } } @@ -426,22 +196,73 @@ app.controller('daybookadminCtrl', ["$scope", "$rootScope", "toaster", "$filter" "type": "", "amount": "", "status": "", - "description": "" + "description": "", + "paidTo": "", + "description_paid": "", + "voucherNumber": "", + "branch": "", + "name":"" } $scope.copyModel = function (p) { + console.log(p); $scope.myModel = { - "id": p.id, - "date": p.date, - "incomeExpense": p.incomeExpense, - "type": p.type, - "amount": p.amount, - "status": p.status, - "description": p.description + "id": p.ID, + "date": p.Date, + "incomeExpense": p.Name, + "type": p.Type, + "amount": p.Amount, + "status": p.Status, + "description": p.Description, + "paidTo": p.PaidTo, + "description_paid": p.PaidDescription, + "voucherNumber": p.VoucherNumber, + "branch":p.BranchCode, + "name": p.Name } + // alert(JSON.stringify($scope.myModel)); } - // delete the entry row from the daybook list + + //delete the income entry From the fees payable + $scope.deleteFeePayableEntry = function (id) { + // alert(id); + SweetAlert.swal({ + title: "Warning!", + text: "Do you want to Delete this Entry ?", + type: "warning", + showCancelButton: true, + confirmButtonColor: "#007aff", + confirmButtonText: "Yes!" + }, function (res) { + if (res === true) { + // alert(id); + // alert(stuId); + var deleteFeePayableDetails = { + method: 'POST', + url: apiPoint.url + 'deleteDayBookFeePayableDetails/', + headers: { + 'Content-Type': 'application/json' + }, + data: { + data: id, + requestDetails: localDetails + } + }; + $http(deleteFeePayableDetails).then(function (response) { + if (response.data.deletedStatus) { + swal(" ", "Deleted Successfully.", "success"); + $scope.getDayBookList(); + } else { + swal(" ", response.data.message, "error"); + } + }); + } + }); + } + + + // delete the income/expense list row $scope.deleEditEntry = function (id) { swal({ title: "Are you sure?", @@ -453,22 +274,29 @@ app.controller('daybookadminCtrl', ["$scope", "$rootScope", "toaster", "$filter" closeOnConfirm: false }, function () { - $scope.indexDelete2(); - // if( $scope.indexDelete2() === true) { - // $scope.data; - // swal("Deleted!", "Your imaginary file has been deleted.", "success"); - // } + $scope.indexDelete2(id); }); - $scope.indexDelete2 = function () { - let ans = $scope.data.some(function (val, i) { - if (val.id === id) { - $scope.data.splice(i, 1); - swal(" ", "Your record has been deleted.", "success"); - return true; + $scope.indexDelete2 = function (id) { + var deleteDetails = { + method: 'POST', + url: apiPoint.url + 'deleteDayBookDetails/', + headers: { + 'Content-Type': 'application/json' + }, + data: { + data: id, + requestDetails: localDetails } - }); return ans; + }; + $http(deleteDetails).then(function (response) { + if (response.data.deletedStatus) { + swal(" ", "Deleted Successfully.", "success"); + $scope.getDayBookList(); + } else { + swal(" ", response.data.message, "error"); + } + }); } - } $scope.myModelAdd = { @@ -478,10 +306,13 @@ app.controller('daybookadminCtrl', ["$scope", "$rootScope", "toaster", "$filter" "type": "", "amount": "", "status": "", - "description": "" + "description": "", + "paidTo": "", + "description_paid": "", + "voucherNumber": "" } - // add a new entry to the day book list + // add a new daybook entry $scope.daybookAdd = { submit: function (form, myModelAdd) { var firstError = null; @@ -500,15 +331,51 @@ app.controller('daybookadminCtrl', ["$scope", "$rootScope", "toaster", "$filter" 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.myModelAdd.status = $scope.myModelAdd.name == 'I001' ? 'Pending' : 'Approved'; + // $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(" ", "Income/Expense added successfully.", "success"); + $state.go($state.current, {}, { reload: true }); + } else { + swal(" ", response.data.message, "error"); + } + }); } + }, + reset: function (form) { + form.$setPristine(true); + $scope.myModelAdd = { + "id": "", + "date": "", + "name": "", + "type": "", + "amount": "", + "status": "", + "description": "", + "paidTo": "", + "description_paid": "", + "voucherNumber": "" + } } } - // update daybook entry data from the list + // update a daybook entry details $scope.daybookeditUpdate = { submit: function (form, myModel) { var firstError = null; @@ -527,60 +394,30 @@ app.controller('daybookadminCtrl', ["$scope", "$rootScope", "toaster", "$filter" 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"); - // } - // }); + // alert(JSON.stringify($scope.myModel));exit(); + var updateDayBookDetails = { + method: 'POST', + url: apiPoint.url + 'updateDayBookDetails/', + headers: { + 'Content-Type': 'application/json' + }, + data: { + data: $scope.myModel, + requestDetails: localDetails + } + }; + $http(updateDayBookDetails).then(function (response) { + if (response.data.updateDetailsStatus) { + swal(" ","Updated successfully.", "success"); + // for success state + $scope.editId = -1; + $scope.getDayBookList(); + } else { + swal(" ", response.data.message, "error"); + } + }); } - }, - // reset: function (form) { - // form.$setPristine(true); - // $scope.myStatusModel = { - // 'semYear': '', - // 'staus': '', - // 'dateOn': '', - // 'comment': '' - // } - // } + } } }]); diff --git a/Apollo/assets/js/controllers/daybookadminapprovalCtrl.js b/Apollo/assets/js/controllers/daybookadminapprovalCtrl.js new file mode 100644 index 00000000..5ef2149d --- /dev/null +++ b/Apollo/assets/js/controllers/daybookadminapprovalCtrl.js @@ -0,0 +1,311 @@ +'use strict'; +/** + * daybook details capturing + * + */ +app.controller('daybookadminapprovalCtrl', ["$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 === 'R003') { + // getFinanceModuleAccess(); + // // if(getFinanceModuleAccess()){ + $scope.dayBookApprovalAccess = localDetail.is_DayBookApproval_Access; + $scope.showTheRefValue = undefined; + $scope.localTypeViewAdmin = true; + $scope.currentDate = new Date(); + var d = new Date(); + $scope.oneMonthBefore = d.setMonth(d.getMonth()-1); + var formate = "dd-MM-yyyy"; + $scope.searchData.date = $filter('date')(new Date($scope.oneMonthBefore), 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.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 = undefined; + $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; + $scope.datas = response.data.dayBookListDetails; + + const filterAddSelect = $scope.datas.filter(val => { + val['Selected'] = false; + return val; + }); + $scope.searchResultDetails = filterAddSelect; + $scope.searchResultDetailsCopy = filterAddSelect; + } else { + $scope.loadingsearch = false; + } + }); + } + + // Select one row in a table once + $scope.setOneSelect = function (value) { + angular.forEach($scope.searchResultDetails, function (item) { + item.Selected = false; + }); + value.Selected = true; + $scope.OpenWindowStatus = true; + $scope.openUpdateWind(); + } + + $scope.unSelect = function () { + // alert(value.Selected); + angular.forEach($scope.searchResultDetails, function (item) { + item.Selected = false; + }); + $scope.openUpdateWind(); + } + + $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; } + }); + 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(); + } 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(" ", "Updated successfully,", "success"); + // for success state + $scope.getDayBookList(); + $scope.unSelect(); + $scope.myStatusModel = { + 'staus': '', + 'description': '', + } + $scope.allSelected('undefined'); + $scope.OpenWindowStatus = false; + } else { + swal(" ", response.data.message, "error"); + } + }); + } else { + swal(" ", "Item not Selected", "warning"); + } + + } + }, + reset: function (form) { + form.$setPristine(true); + $scope.myStatusModel = { + 'staus': '', + 'description': '', + } + } + } + + $scope.showTheResType = function (type) { + // alert(type); + if (type == undefined) { + $scope.searchResultDetails = $scope.searchResultDetailsCopy; + } else { + $scope.searchResultDetails = $scope.searchResultDetailsCopy.filter(val => { + return val.Name == type ? 1 : 0; + }) + } + + // const filterAddSelect = $scope.searchResultDetails.filter(val => { + + // }); + } + + $scope.statusList = [{ + "status_id": 'TS001', + "name": "Pending", + }, { + "status_id": 'TS002', + "name": "Approved", + }, { + "status_id": 'TS003', + "name": "Rejected", + }]; + +}]); + + diff --git a/Apollo/assets/js/controllers/daybookapprovalCtrl.js b/Apollo/assets/js/controllers/daybookapprovalCtrl.js index 32398f92..55276d5f 100644 --- a/Apollo/assets/js/controllers/daybookapprovalCtrl.js +++ b/Apollo/assets/js/controllers/daybookapprovalCtrl.js @@ -23,11 +23,13 @@ app.controller('daybookapprovalCtrl', ["$scope", "$rootScope", "toaster", "$filt // getFinanceModuleAccess(); // // if(getFinanceModuleAccess()){ $scope.dayBookApprovalAccess = localDetail.is_DayBookApproval_Access; - $scope.showTheRefValue = 'I001'; + $scope.showTheRefValue = undefined; $scope.localTypeViewAdmin = true; $scope.currentDate = new Date(); + var d = new Date(); + $scope.oneMonthBefore = d.setMonth(d.getMonth()-1); var formate = "dd-MM-yyyy"; - $scope.searchData.date = $filter('date')(new Date($scope.currentDate), formate); + $scope.searchData.date = $filter('date')(new Date($scope.oneMonthBefore), formate); $scope.searchData.dateTo = $filter('date')(new Date($scope.currentDate), formate); $scope.getIncomeExpenseType_Status(); $scope.getDayBookList(); @@ -35,16 +37,7 @@ app.controller('daybookapprovalCtrl', ["$scope", "$rootScope", "toaster", "$filt } 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(); + $state.go('login.signin'); } } @@ -65,7 +58,7 @@ app.controller('daybookapprovalCtrl', ["$scope", "$rootScope", "toaster", "$filt $http(getFinacnceModuleAcccessCtrl).then(function (response) { if (response.data.dayBkAccessChkStatus) { $scope.dayBookApprovalAccess = response.data.dayBkAccessChk_Value; - $scope.showTheRefValue = 'I001'; + $scope.showTheRefValue = undefined; $scope.localTypeViewAdmin = true; $scope.currentDate = new Date(); var formate = "dd-MM-yyyy"; @@ -81,8 +74,6 @@ app.controller('daybookapprovalCtrl', ["$scope", "$rootScope", "toaster", "$filt } - - // change from date, update and call search functionality $scope.changeDate = function () { if($scope.searchData.date !== undefined) { @@ -107,14 +98,14 @@ app.controller('daybookapprovalCtrl', ["$scope", "$rootScope", "toaster", "$filt } } - // sorting function for table params + // 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 + // income expense type status list $scope.getIncomeExpenseType_Status = function () { var getIncomeExpenseType = { method: 'POST', @@ -135,12 +126,12 @@ app.controller('daybookapprovalCtrl', ["$scope", "$rootScope", "toaster", "$filt }); } - $scope.loadingsearch = false; + $scope.loadingsearch = false; $scope.noRecordFound = true; $scope.noRecordFoundSearch = false; - $scope.dataLengthIncome = 0; - $scope.dataLengthExpense = 0; - // day book entry list + $scope.dataLengthIncome = 0; + $scope.dataLengthExpense = 0; + // day book entry list $scope.getDayBookList = function () { $scope.loadingsearch = true; $scope.noRecordFoundSearch = false; @@ -157,66 +148,39 @@ app.controller('daybookapprovalCtrl', ["$scope", "$rootScope", "toaster", "$filt }; $http(getDatBookListDetails).then(function (response) { if (response.data.dayBookListStatus) { - $scope.loadingsearch = false; + $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 => { + $scope.datas = response.data.dayBookListDetails; + + const filterAddSelect = $scope.datas.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; + $scope.searchResultDetailsCopy = filterAddSelect; } else { - $scope.loadingsearch = false; + $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) { + // Select one row in a table once + $scope.setOneSelect = function (value) { angular.forEach($scope.searchResultDetails, function (item) { - item.Selected = value; + item.Selected = false; }); + value.Selected = true; + $scope.OpenWindowStatus = true; + $scope.openUpdateWind(); } - $scope.allSelected = function (value) { - if (value !== undefined) { - return setAllSelected(value); - } else { - return getAllSelected(); + $scope.unSelect = function () { + // alert(value.Selected); + angular.forEach($scope.searchResultDetails, function (item) { + item.Selected = false; + }); + $scope.openUpdateWind(); } - } $scope.myStatusModel = { 'staus': '', @@ -231,9 +195,7 @@ app.controller('daybookapprovalCtrl', ["$scope", "$rootScope", "toaster", "$filt var ItemsSelected = $scope.searchResultDetails.filter(function (item) { if (item.Selected === true) { return true; } }); - // $scope.getStatusList(); - // alert(ItemsSelected.length); - if (ItemsSelected.length) { + if (ItemsSelected.length) { $scope.myStatusModel = { 'staus': '', 'description': '', @@ -261,8 +223,7 @@ app.controller('daybookapprovalCtrl', ["$scope", "$rootScope", "toaster", "$filt } } 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 { + } else { var selectedItems = []; var ItemsSelected = $scope.searchResultDetails.filter(function (item) { if (item.Selected === true && item.Status === 'Pending' ) { @@ -293,6 +254,11 @@ app.controller('daybookapprovalCtrl', ["$scope", "$rootScope", "toaster", "$filt swal(" ", "Updated successfully,", "success"); // for success state $scope.getDayBookList(); + $scope.unSelect(); + $scope.myStatusModel = { + 'staus': '', + 'description': '', + } $scope.allSelected('undefined'); $scope.OpenWindowStatus = false; } else { @@ -314,7 +280,20 @@ app.controller('daybookapprovalCtrl', ["$scope", "$rootScope", "toaster", "$filt } } - + $scope.showTheResType = function (type) { + // alert(type); + if (type == undefined) { + $scope.searchResultDetails = $scope.searchResultDetailsCopy; + } else { + $scope.searchResultDetails = $scope.searchResultDetailsCopy.filter(val => { + return val.Name == type ? 1 : 0; + }) + } + + // const filterAddSelect = $scope.searchResultDetails.filter(val => { + + // }); + } $scope.statusList = [{ "status_id": 'TS001', @@ -327,263 +306,6 @@ app.controller('daybookapprovalCtrl', ["$scope", "$rootScope", "toaster", "$filt "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/sessionCtrl.js b/Apollo/assets/js/controllers/sessionCtrl.js index ab345fe6..e32c475f 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 = 'superAdmin'; } else if (localDetail.localType == 'R003') { $scope.getLoginDash = 'Admin'; + $scope.is_active_DayBookAprlAccess = localDetail.is_DayBookApproval_Access; } else if (localDetail.localType == 'R002') { $scope.getLoginDash = 'staff'; $scope.is_active_DayBookAprlAccess = localDetail.is_DayBookApproval_Access; diff --git a/Apollo/assets/views/daybook/dayBookApproval.html b/Apollo/assets/views/daybook/dayBookApproval.html index cebc9993..9d20930f 100644 --- a/Apollo/assets/views/daybook/dayBookApproval.html +++ b/Apollo/assets/views/daybook/dayBookApproval.html @@ -44,18 +44,9 @@
- - +
- -
+
@@ -67,8 +58,7 @@
- -
+
@@ -83,30 +73,15 @@ - - Type is Required
-

No records found...

-
+ - + Paid To / Received From Description/Comments - - + Type Amount - - @@ -192,25 +160,14 @@ {{p.TypeName}} {{p.Amount}} - -
-
-
+
--> +
+
+ + +
+
+
+
+ +
+
+ + + +
+
+
+
+ + + +
+
+
+ + + Type is Required + +
+
+
+
+ Loading... +
+
+
+

No + records found...

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