0
I made a page to query records and I have two fields search by name and search by start month and end month.
Example: I would like to select the months and a div
display the total value of that month’s Service Order (as an example image)...if anyone can give help with an example.
// Funcao que esta exibindo o valor Total de Ordem de servicos na div
$scope.GetTotal = function() {
var total = 0;
for (var i = 0; i < $scope.ordens.length; i++) {
var relatorio = $scope.ordens[i];
total += parseFloat(relatorio.ordemValor);
}
return total;
};
/* Consulta OS por data - filtros */
angular.module("App").filter("betweenDate", function($filter) {
return function(collection, column, startDate, endDate) {
var new_collection = [];
moment(startDate)
.startOf("month")
.format("YYYY-MM");
moment(endDate)
.startOf("month")
.format("YYYY-MM");
if (angular.isDefined(startDate) && angular.isDefined(endDate)) {
if (startDate != "" && endDate != "") {
if (angular.isDefined(startDate)) {
startDate = $filter("date")(startDate, "yyyy-MM");
//Date.parse($filter('date')(startDate, 'yyyy-MM'));
}
if (angular.isDefined(endDate)) {
endDate = $filter("date")(endDate, "yyyy-MM");
//Date.parse($filter('date')(endDate, 'yyyy-MM'));
}
angular.forEach(collection, function(value, index) {
var obj = value[column];
var currentDate = $filter("date")(obj, "yyyy-MM");
//Date.parse($filter('date')(obj, 'yyyy-MM'));
if (currentDate >= startDate && endDate >= currentDate) {
new_collection.push(value);
}
});
} else {
new_collection = collection;
}
collection = new_collection;
}
return collection;
};
});
<tr ng-repeat="ordem in ordens | filter: criterioDeBusca | orderBy:'-ordemData' | betweenDate:'ordemData':startDate:endDate | dateRange:'ordemData':startDate:endDate" ng-if="ordem.ordemStatus == 'ABERTO'"></tr>
I recommend using ng-table (http://ng-table.com/#/). You will be able to do everything you want ;)
– Leo Brescia
@Leobrescia already managed to solve the problem! thanks
– Ricardo Chomicz
Put the solution here. It may help others :)
– Leo Brescia