app.js 1.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859
  1. var app = angular.module('app', ['ngRoute', 'ui.bootstrap', 'cgNotify']);
  2. app.config(['$routeProvider', '$locationProvider', function ($routeProvider, $locationProvider) {
  3. $locationProvider.html5Mode(true);
  4. $routeProvider
  5. .when('/', {
  6. templateUrl: 'views/error.html',
  7. controller: 'errorCtrl'
  8. })
  9. .when('/:hash', {
  10. templateUrl: 'views/main.html',
  11. controller: 'facturaCtrl'
  12. })
  13. .when('/create/:hash', {
  14. templateUrl: 'views/createOrEditPedido.html',
  15. controller: 'editPedidoCtrl',
  16. resolve: {
  17. editing: function() { return false },
  18. }
  19. })
  20. .when('/edit/:hash/:id', {
  21. templateUrl: 'views/createOrEditPedido.html',
  22. controller: 'editPedidoCtrl',
  23. resolve: {
  24. editing: function() { return true },
  25. }
  26. })
  27. .otherwise({
  28. redirectTo: '/'
  29. });
  30. }]);
  31. app.factory('pedidosService', function(notify) {
  32. return {
  33. pedidoValido: function(filtrados) {
  34. if (filtrados.length==0){
  35. notify({message:"No hay productos",classes:"alert alert-danger"});
  36. return false;
  37. }
  38. /*
  39. for(var f in $scope.listaproductos){
  40. var prod = $scope.listaproductos[f];
  41. if(isNaN(prod.cantidad)){
  42. notify({message:prod.nombre+" tiene cantidad incorrecta",classes:"alert alert-danger"});
  43. return false;
  44. } else if (prod.cantidad > prod.stock && prod.cantidad > 0) {
  45. notify({message:"La cantidad pedida de " + prod.nombre+" es mayor al stock actual (" + prod.stock + ")",classes:"alert alert-danger"});
  46. return false;
  47. }
  48. }
  49. */
  50. return true;
  51. },
  52. };
  53. });