cobuild-angular-stack
Version:
Base stack angular sass jade gulp
71 lines (59 loc) • 1.91 kB
JavaScript
(function (module) {
module.controller('AdminDiscountReportsController', AdminDiscountReportsController);
AdminDiscountReportsController.$inject = ['$scope', '$state', '$stateParams','$translate', 'toastr', '$uibModalInstance', 'DiscountCode'];
function AdminDiscountReportsController($scope, $state, $stateParams, $translate, toastr, $uibModalInstance, DiscountCode) {
$scope.date = {
startDate: null,
endDate: null
};
$scope.type = "sales";
$scope.applyCalendar = function() {
var optionsDaterangepicker = {
format : "DD-MM-YYYY",
applyClass: 'btn-green',
applyLabel: "Aceptar",
cancelLabel: 'Cancelar',
daysOfWeek: ["Do", "Lu", "Ma", "Mi", "Ju", "Vi", "Sa"],
monthNames: ["Enero", "Febrero", "Marzo", "Abril", "Mayo", "Junio", "Julio", "Agosto", "Septiembre", "Octubre", "Noviembre", "Diciembre"],
}
$scope.optionsDate = {
applyClass: 'btn-inverse',
locale: optionsDaterangepicker,
eventHandlers: {
'cancel.daterangepicker': function (ev, picker) {
$scope.date = {
startDate: null,
endDate: null
}
}
}
};
}
$scope.download = function() {
var name = "Codigos_de_utilidad_de_venta_anticipada";
switch($scope.type) {
case 'codes':
name = "General_codigos";
break;
case 'sales':
name = 'Codigos_Vta_anticipada'
break;
}
localStorage.fileName = name;
DiscountCode.reports({
type: $scope.type,
startDate: $scope.date.startDate.format("DD/MM/YYYY"),
endDate: $scope.date.endDate.format("DD/MM/YYYY")
}).$promise.then(function(data) {
}, function(err) {
console.log(err);
}).catch(function(err) {
console.log(err);
});
};
$scope.close = function() {
$uibModalInstance.dismiss('cancel');
}
$scope.applyCalendar();
}
})(angular.module('uniko.admin.discount'));