| 1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859 |
- var app = angular.module('app', ['ngRoute', 'ui.bootstrap', 'cgNotify']);
- app.config(['$routeProvider', '$locationProvider', function ($routeProvider, $locationProvider) {
- $locationProvider.html5Mode(true);
- $routeProvider
- .when('/', {
- templateUrl: 'views/error.html',
- controller: 'errorCtrl'
- })
- .when('/:hash', {
- templateUrl: 'views/main.html',
- controller: 'facturaCtrl'
- })
- .when('/create/:hash', {
- templateUrl: 'views/createOrEditPedido.html',
- controller: 'editPedidoCtrl',
- resolve: {
- editing: function() { return false },
- }
- })
- .when('/edit/:hash/:id', {
- templateUrl: 'views/createOrEditPedido.html',
- controller: 'editPedidoCtrl',
- resolve: {
- editing: function() { return true },
- }
- })
- .otherwise({
- redirectTo: '/'
- });
- }]);
- app.factory('pedidosService', function(notify) {
- return {
- pedidoValido: function(filtrados) {
- if (filtrados.length==0){
- notify({message:"No hay productos",classes:"alert alert-danger"});
- return false;
- }
- /*
- for(var f in $scope.listaproductos){
- var prod = $scope.listaproductos[f];
- if(isNaN(prod.cantidad)){
- notify({message:prod.nombre+" tiene cantidad incorrecta",classes:"alert alert-danger"});
- return false;
- } else if (prod.cantidad > prod.stock && prod.cantidad > 0) {
- notify({message:"La cantidad pedida de " + prod.nombre+" es mayor al stock actual (" + prod.stock + ")",classes:"alert alert-danger"});
- return false;
- }
- }
- */
- return true;
- },
- };
- });
|