Browse Source

some methods implemented in order page

robert2206 8 years ago
parent
commit
912feb54e1
2 changed files with 60 additions and 59 deletions
  1. 17 59
      src/pages/order/order.html
  2. 43 0
      src/pages/order/order.ts

+ 17 - 59
src/pages/order/order.html

@@ -20,70 +20,28 @@
             Productos
         </ion-item-divider>
         <ion-list>
-            <ion-item (doubleTap)="openOptions()">
+            <ion-item *ngFor="let item of getCart()" (doubleTap)="openOptions()">
                 <ion-avatar item-left>
                     <img src="./assets/images/product.png" />
 			    </ion-avatar>
-                <h2>Producto 001</h2>
-                <p>Precio: </p>
-                <p>Cantidad:</p>
-                <p>Subtotal:</p>
+                <h2>{{ item.name }}</h2>
+                <p>
+                    <strong>Precio:</strong>
+                    {{ item.price }}
+                </p>
+                <p>
+                    <strong>Cantidad:</strong>
+                    {{ item.qty }}:
+                </p>
+                <p>
+                    <strong>Subtotal:</strong>
+                    {{ item.subtotal }}
+                </p>
                 <div item-right>
-				    <button ion-button icon-only>
+				    <button ion-button icon-only color="light">
 					    <i class="fa fa-plus"></i>
 				    </button>
-				    <button ion-button icon-only>
-					    <i class="fa fa-minus"></i>
-				    </button>
-			    </div>
-            </ion-item>
-            <ion-item>
-                <ion-avatar item-left>
-                    <img src="./assets/images/product.png" />
-			    </ion-avatar>
-                <h2>Producto 002</h2>
-                <p>Precio: </p>
-                <p>Cantidad:</p>
-                <p>Subtotal:</p>
-                <div item-right>
-				    <button ion-button icon-only>
-					    <i class="fa fa-plus"></i>
-				    </button>
-				    <button ion-button icon-only>
-					    <i class="fa fa-minus"></i>
-				    </button>
-			    </div>
-            </ion-item>
-            <ion-item>
-                <ion-avatar item-left>
-                    <img src="./assets/images/product.png" />
-			    </ion-avatar>
-                <h2>Producto 003</h2>
-                <p>Precio: </p>
-                <p>Cantidad:</p>
-                <p>Subtotal:</p>
-                <div item-right>
-				    <button ion-button icon-only>
-					    <i class="fa fa-plus"></i>
-				    </button>
-				    <button ion-button icon-only>
-					    <i class="fa fa-minus"></i>
-				    </button>
-			    </div>
-            </ion-item>
-            <ion-item>
-                <ion-avatar item-left>
-                    <img src="./assets/images/product.png" />
-			    </ion-avatar>
-                <h2>Producto 005</h2>
-                <p>Precio: </p>
-                <p>Cantidad:</p>
-                <p>Subtotal:</p>
-                <div item-right>
-				    <button ion-button icon-only>
-					    <i class="fa fa-plus"></i>
-				    </button>
-				    <button ion-button icon-only>
+				    <button ion-button icon-only color="light">
 					    <i class="fa fa-minus"></i>
 				    </button>
 			    </div>
@@ -93,7 +51,7 @@
             Total
         </ion-item-divider>
         <ion-item>
-            <ion-input type="number" value="0" readonly></ion-input>
+            <ion-input type="number" value="{{ getTotal() }}" readonly></ion-input>
         </ion-item>
     </form>
 

+ 43 - 0
src/pages/order/order.ts

@@ -14,6 +14,33 @@ import { ProductSelectionPage } from "./product-selection/product-selection";
 })
 export class OrderPage extends BaseDetailsView<SaleOrder> {
 
+    cart = [
+        {
+            name: "Producto 001",
+            price: 2000,
+            qty: 1,
+            subtotal: 2000
+        },
+        {
+            name: "Producto 001",
+            price: 2000,
+            qty: 1,
+            subtotal: 2000
+        },
+        {
+            name: "Producto 001",
+            price: 2000,
+            qty: 1,
+            subtotal: 2000
+        },
+        {
+            name: "Producto 001",
+            price: 2000,
+            qty: 1,
+            subtotal: 2000
+        }
+    ];
+
     constructor(
         public navCtrl: NavController,
         public navParams: NavParams
@@ -22,6 +49,8 @@ export class OrderPage extends BaseDetailsView<SaleOrder> {
 
         let titleKind = super.getKind() === "budget" ? "Presupuesto" : "Venta";
         super.setTitle(super.itemExists() ? "Editar " + titleKind : "Crear " + titleKind);
+
+        this.getTotal();
     }
 
     /**
@@ -38,6 +67,20 @@ export class OrderPage extends BaseDetailsView<SaleOrder> {
         this.navCtrl.push(CustomerSelectionPage);
     }
 
+    getCart(): Array<any> {
+        return this.cart;
+    }
+
+    getTotal(): number {
+        let total: number = 0;
+
+        for (let i = 0; i < this.getCart().length; i++) {
+            total = total + this.getCart()[i].subtotal;
+        }
+        
+        return total;
+    }
+    
     /**
      * 
      */