-
Notifications
You must be signed in to change notification settings - Fork 11
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
16 changed files
with
172 additions
and
193 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -11,7 +11,7 @@ | |
'app.pouch', | ||
'app.model', | ||
'app.settings', | ||
'app.sales' | ||
// 'app.report' | ||
'app.sales', | ||
'app.report' | ||
]); | ||
})(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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; | ||
})); | ||
} | ||
} | ||
})(); |
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
File renamed without changes.
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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.
File renamed without changes.
Oops, something went wrong.