David před 10 roky
rodič
revize
a1e718ef86
2 změnil soubory, kde provedl 53 přidání a 44 odebrání
  1. 7 1
      controllers/facturaCtrl.js
  2. 46 43
      views/main.html

+ 7 - 1
controllers/facturaCtrl.js

@@ -1,4 +1,5 @@
 app.controller('facturaCtrl', function ($scope, $http, $window, notify,$location) {
+	$scope.error=false;
 	$scope.cero=true;
 	$scope.total=0;
 	var user = $location.search().user;
@@ -7,9 +8,14 @@ app.controller('facturaCtrl', function ($scope, $http, $window, notify,$location
 	$scope.update = function() {
 		$http.get('back/cliente/' + user).success(function(data) {
 	   		$scope.userdata = data; 
+		}).error(function(data) {
+			$scope.error=true;
 		});
+
 		$http.get('back/productos/' + user).success(function(data) {
 	   		$scope.listaproductos = data; 
+		}).error(function(data) {
+			$scope.error=true;
 		});
 	};
 
@@ -53,7 +59,7 @@ app.controller('facturaCtrl', function ($scope, $http, $window, notify,$location
 
 		$http.post('back/pedido', { pedido: pedido } )
 	        .success(function(data, status, headers, config) {
-				notify("Guardada correctamente");
+				notify("Enviado correctamente. En unos minutos recibiras un e-mail de confirmacion");
 	        })
 	        .error(function(data, status, headers, config) {
 				notify({classes:"alert alert-danger", message:"Error: "+ data.err});

+ 46 - 43
views/main.html

@@ -1,55 +1,58 @@
-<div class="row">
-	<div class="col-md-12">
-		<label>
-			<h3>Pedido {{userdata.nombre}} {{userdata.apellido}}</h3>
-		</label>
-	</div>
-</div>
-<div class="row">
-	<div class="col-md-6">
-		<label class="col-md-12">
-			Filtro:
-			<input type="text" class="form-control form-control-small" ng-model="filtro" style="display:block">
-		</label>
-	</div>
+<div ng-if="error">
+	<h1 style="text-align:center">Link inv&aacute;lido</h1>
 </div>
 
-<div class="col-md-6 col-sm-12 col-xs-12">
-	<table class="table table-striped">
-		<tr>
-			<th>Cantidad</th>
-			<th>ID</th>
-			<th>Nombre</th>
-			<th>Precio</th>
-			<th>Total</th>
-		</tr>
-		<tr ng-repeat="p in listaproductos | filter: filtro | filter:filterCero(criteria) track by p.id">
-			<td><input ng-change="updateTotal()" type=number class="form-control" ng-model="p.cantidad" value="0" min="0" max="100" style='width:70px;text-align:center;'></td>
-			<td>{{p.id}}</td>
-			<td>{{p.nombre}}</td>
-			<td>${{p.precio}}</td>
-			<td>${{p.cantidad*p.precio}}</td>
-		</tr>
-	</table>
-</div>
-<div class="col-md-6 col-sm-12 col-xs-12">
+<div ng-if="!error">
 	<div class="row">
 		<div class="col-md-12">
-		<label>
-			<input type="checkbox" ng-model="cero">
-			Ver productos en 0
-		</label>
+			<label>
+				<h3>Pedido {{userdata.nombre}} {{userdata.apellido}}</h3>
+			</label>
 		</div>
 	</div>
 	<div class="row">
-		<div class="col-md-12">
-			<b>Total:</b>
-			${{total}}
+		<div class="col-md-6">
+			<label class="col-md-12">
+				Filtro:
+				<input type="text" class="form-control form-control-small" ng-model="filtro" style="display:block">
+			</label>
 		</div>
 	</div>
-	<div class="row">
-		<div class="col-md-12">
-			<button class="css-button" ng-click="ok()">Enviar</button>
+	
+	<div class="col-md-6 col-sm-12 col-xs-12">
+		<table class="table table-striped">
+			<tr>
+				<th>Cantidad</th>
+				<th>ID</th>
+				<th>Nombre</th>
+				<th>Precio</th>
+				<th>Total</th>
+			</tr>
+			<tr ng-repeat="p in listaproductos | filter: filtro | filter:filterCero(criteria) track by p.id">
+				<td><input ng-change="updateTotal()" type=number class="form-control" ng-model="p.cantidad" value="0" min="0" max="100" style='width:70px;text-align:center;'></td>
+				<td>{{p.id}}</td>
+				<td>{{p.nombre}}</td>
+				<td>${{p.precio}}</td>
+				<td>${{p.cantidad*p.precio}}</td>
+			</tr>
+		</table>
+	</div>
+	<div class="col-md-6 col-sm-12 col-xs-12">
+		<div class="row">
+			<div class="col-md-12">
+				<b>Total sin descuento:</b>
+				${{total}}
+			</div>
+		</div>
+		<div class="row">
+			<div class="col-md-12">
+				<button ng-show="cero==1" class="css-button" ng-click="cero=0">Confirmar</button>
+				<button ng-show="cero==0" class="css-button" ng-click="cero=1">Modificar</button>
+				<!--
+				<button class="css-button" ng-click="">Ver pedido</button>
+				-->
+				<button ng-show="cero==0" class="css-button" ng-click="ok()">Enviar Pedido</button>
+			</div>
 		</div>
 	</div>
 </div>