Skip to content

Commit

Permalink
sales report
Browse files Browse the repository at this point in the history
  • Loading branch information
dvbondoy committed Feb 15, 2017
1 parent f2e4ed1 commit 189cded
Show file tree
Hide file tree
Showing 16 changed files with 172 additions and 193 deletions.
4 changes: 2 additions & 2 deletions www/app.module.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
'app.pouch',
'app.model',
'app.settings',
'app.sales'
// 'app.report'
'app.sales',
'app.report'
]);
})();
5 changes: 5 additions & 0 deletions www/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@
<script src="model/model.sales.js"></script>
<script src="model/model.local.js"></script>
<script src="model/model.uom.js"></script>
<script src="model/model.reports.js"></script>

<script src="settings/settings.module.js"></script>
<script src="settings/settings.route.js"></script>
Expand All @@ -62,6 +63,10 @@
<script src="sales/sales.route.js"></script>
<script src="sales/sales.services.js"></script>
<script src="sales/sales.controller.js"></script>

<script src="reports/report.module.js"></script>
<script src="reports/report.route.js"></script>
<script src="reports/report.controller.js"></script>

</head>
<body ng-app="app">
Expand Down
53 changes: 53 additions & 0 deletions www/model/model.reports.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
(function() {
'use strict';

angular
.module('app.model')
.factory('Report', Report);

Report.$inject = ['$q'];
function Report($q) {
return {
salesToday:salesToday,
salesYesterday:salesYesterday,
dateRange:dateRange
};

function salesToday(){
var now = moment().format('YYYY-MM-DD');

return $q.when(_db.allDocs({include_docs:true,startkey:'sale/'+now,endkey:'sale/'+now+'\uffff'})
.then(function(docs){
return docs.rows.map(function(row){
return row.doc;
});
}).catch(function(error){
return error;
}));
}

function salesYesterday() {
var yesterdate = moment().subtract(1, 'days').format('YYYY-MMM-DD');

return $q.when(_db.allDocs({include_docs:true,startkey:'sale/'+yesterdate,endkey:'sale/'+yesterdate+'uffff'})
.then(function(docs){
return docs.rows.map(function(row){
return row.doc;
});
}).catch(function(error){
return error;
}));
}

function dateRange(from_date, to_date) {
return $q.when(_db.allDocs({include_docs:true,startkey:moment(from_date).format('YYYY-MM-DD'),endkey:moment(to_date).format('YYYY-MM-DD')+'\uffff'})
.then(function(docs){
return docs.rows.map(function(row){
return row.doc;
});
}).catch(function(error){
return error;
}));
}
}
})();
148 changes: 0 additions & 148 deletions www/report/report.controller.js

This file was deleted.

32 changes: 0 additions & 32 deletions www/report/templates/report.html

This file was deleted.

70 changes: 70 additions & 0 deletions www/reports/report.controller.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
(function() {
'use strict';

angular
.module('app.report')
.controller('ReportController', ReportController);

ReportController.$inject = ['$scope','Report','$ionicActionSheet'];
function ReportController($scope,Report,$ionicActionSheet) {
var vm = this;

// Report.salesToday().then(function(result){
// console.log(result);
// });

$scope.Sales = {
list:[],
setDate:function(){
var sales = this;

var menu = [
{text:'Today'},{text:'Yesteday'},{text:'Date Range'}
];

var hideSheet = $ionicActionSheet.show({
buttons:menu,
cancelText:'Cancel',
cancel:function(){
return 0;
},
buttonClicked:function(index){
switch(index){
case 0:
break;
case 1:
break;
case 2:
}
}
});
},
today:function(){
var sales = this;

Report.salesToday().then(function(result){
console.log('report.controller:46');
console.log(result);
sales.list = result;
});
},
yesteday:function(){
var sales = this;

Report.salesYesterday().then(function(result){
sales.list = result;
});
},
range:function(from, to){
var sales = this;

Report.dateRange(from, to).then(function(result){
sales.list = result;
});
}
};

$scope.Sales.today();

}
})();
File renamed without changes.
9 changes: 1 addition & 8 deletions www/report/report.route.js → www/reports/report.route.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,14 +14,7 @@
state: 'app.report',
config: {
url: '/report',
templateUrl: 'report/templates/report.html'
}
},
{
state: 'app.sales_report',
config: {
url: '/sales_report',
templateUrl: 'report/templates/sales_report.html'
templateUrl: 'reports/templates/report.html'
}
}
];
Expand Down
File renamed without changes.
File renamed without changes.
33 changes: 33 additions & 0 deletions www/reports/templates/report.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
<ion-view view-title="Sales Reports" ng-controller="ReportController as vm">
<ion-nav-bar class="bar-stable bar-no-border" align-title="center">
<!-- Back button -->
<ion-nav-back-button>
Back
</ion-nav-back-button>

<!-- Burger button -->
<ion-nav-buttons side="left">
<button class="button button-icon button-clear ion-navicon" menu-toggle="left">
</button>
</ion-nav-buttons>

<!-- View order button-->
<ion-nav-buttons side="right">
<button class="button button-icon ion-calendar"></button>
</ion-nav-buttons>
</ion-nav-bar>

<ion-content>
<div class="padding">
<h2>Sales</h2>
<ion-list>
<ion-item ng-repeat="sale in Sales.list">
<span class="gray">Trans ID: {{sale._id}}</span>
<p>Time: {{sale.time}}</p>
<p>Charge: {{sale.charge | currency:"Php "}}</p>
<p>Items: {{sale.items.length}}</p>
</ion-item>
</ion-list>
</div>
</ion-content>
</ion-view>
File renamed without changes.
Loading

0 comments on commit 189cded

Please sign in to comment.