(function () { "use strict"; angular .module('codeAPLEBOX.client.user.customer.home.rentpermonth') .controller('rentpermonthController', rentpermonthController) .filter('selectBoxFilter_rentperMonth', selectBoxFilter_rentperMonth); /* @ngInject */ function selectBoxFilter_rentperMonth() { return function(items, keyword){ var res = []; if(items != null){ for(var i=0;i 0){ res.push(items[i]); } }else{ res.push(items[i]); } } } return res; } } /* @ngInject */ function rentpermonthController($state, $cookies, $scope, $rootScope, appConfig, $log, Auth, moment, WEB_API_CUSTOMER) { var vm = this; // ======================================================================= // 초기데이터 // ======================================================================= vm.customerInfo = $cookies.getObject("customerInfo"); iniData(); // ======================================================================= // Angularjs Function // ======================================================================= vm.goBack = function(){ // 다른페이지 $state.go('customer.home'); } vm.goDetailView = function(index, releaseInfoId){ $state.go('customer.detailrentpermonth',{ checkDetailView: index.toString(), checkDetailViewReleaseId: releaseInfoId }) } vm.goRentstatus = function(index){ var tmpDate = $cookies.getObject('rentPerMonthYearMonth'); $cookies.putObject('detailStatusYearMonth', tmpDate); $state.go('customer.rentstatus') } vm.goReturnstatus= function(index){ var tmpDate = $cookies.getObject('rentPerMonthYearMonth'); $cookies.putObject('detailStatusYearMonth', tmpDate); $state.go('customer.returnstatus') } vm.changeDate = function(index){ var selectMonth = moment(vm.yearMonth, 'yyyy년 MM월').format('YYYY-MM-DD HH:mm:ss'); if(index == 0){ vm.yearMonth = moment(selectMonth).add(-1, 'month').format("yyyy년 MM월").toString(); }else{ vm.yearMonth = moment(selectMonth).add(1, 'month').format("yyyy년 MM월").toString(); } var now = new Date(moment(vm.yearMonth, 'yyyy년 MM월').format('YYYY-MM-DD HH:mm:ss')); vm.startDate = moment(new Date(now.getFullYear(), now.getMonth(), 1)).format("YYYY-MM-DD"); vm.endDate = moment(new Date(now.getFullYear(), now.getMonth()+1, 0)).format("YYYY-MM-DD"); var rentPerMonthYearMonth = moment(vm.yearMonth, 'yyyy년 MM월').format("YYYY-MM") $cookies.putObject('rentPerMonthYearMonth', rentPerMonthYearMonth); // $state.go('customer.rentpermonth', {}, {reload: true}) getMonthlySummary(); } // ======================================================================= // Common API // ======================================================================= function iniData(){ var rentPerMonthYearMonth = $cookies.getObject('rentPerMonthYearMonth'); if(rentPerMonthYearMonth == null){ var now = new Date(); vm.yearMonth = moment(now).format("YYYY년 MM월"); vm.startDate = moment(new Date(now.getFullYear(), now.getMonth(), 1)).format("YYYY-MM-DD"); vm.endDate = moment(new Date(now.getFullYear(), now.getMonth()+1, 0)).format("YYYY-MM-DD"); var rentPerMonthYearMonth = moment(vm.yearMonth, 'yyyy년 MM월').format("YYYY-MM").toString() $cookies.putObject('rentPerMonthYearMonth', rentPerMonthYearMonth); }else{ var now = new Date(moment(rentPerMonthYearMonth, 'yyyy-MM').format('YYYY-MM-DD HH:mm:ss')); vm.yearMonth = moment(now).format("YYYY년 MM월"); vm.startDate = moment(new Date(now.getFullYear(), now.getMonth(), 1)).format("YYYY-MM-DD"); vm.endDate = moment(new Date(now.getFullYear(), now.getMonth()+1, 0)).format("YYYY-MM-DD"); rentPerMonthYearMonth = moment(vm.yearMonth, 'yyyy년 MM월').format("YYYY-MM").toString() $cookies.putObject('rentPerMonthYearMonth', rentPerMonthYearMonth); } vm.selectedList = [ { code: "전체", name: 2 }, { code: "정상대여", name: 0 }, { code: "추가사용료 발생", name: 1 } ]; vm.selectedFunc = vm.selectedList[0]; // summary (총 대여수량, 총 반납수량, 총 사용료, 총 추가사용료, 총 환급보증금, 대여내역) getMonthlySummary(); } function getMonthlySummary(){ var currentMonth = $cookies.getObject('rentPerMonthYearMonth'); // var currentMonth = moment(new Date()).format("YYYY-MM"); WEB_API_CUSTOMER.getMonthlySummary({ customerId: vm.customerInfo.id, currentMonth: currentMonth }).then(function (result) { vm.monthlyReleaseInfo = result.data.monthlyReleaseInfo; vm.completedReleaseInfo = result.data.completedReleaseInfo; }).catch(function (err) { $log.error(err); }); } } })();