This commit is contained in:
cereci5049 2024-04-16 20:51:57 +05:30
parent 46bbcf0d02
commit 5c8b347cbe
4 changed files with 28 additions and 25 deletions

View File

@ -59,20 +59,22 @@
<div class="col-lg-12 grid-margin stretch-card"> <div class="col-lg-12 grid-margin stretch-card">
<div class="card"> <div class="card">
<div class="card-body"> <div class="card-body">
<h4 class="card-title">Turnover Table</h4> <h4 class="card-title">Orders Table</h4>
</p> </p>
<table class="table table-striped"> <table class="table table-striped">
<thead> <thead>
<tr> <tr>
<th> User </th> <th> Product </th>
<th> Last name </th> <th> Quantity </th>
<th> Email </th> <th> Price </th>
<th> Orders </th> <th> Order Date </th>
<th> Amount </th> <th> Amount </th>
<th> Address </th>
<th> State </th>
</tr> </tr>
</thead> </thead>
<tbody> <tbody>
<tr> {# <tr>
<td class="py-1"> <td class="py-1">
<img src="/a3b/admin/images/faces-clipart/pic-1.png" alt="image" /> <img src="/a3b/admin/images/faces-clipart/pic-1.png" alt="image" />
</td> </td>
@ -84,25 +86,21 @@
</td> </td>
<td> $ 77.99 </td> <td> $ 77.99 </td>
<td> May 15, 2015 </td> <td> May 15, 2015 </td>
</tr> </tr> #}
{# {% for (id, user) in users.pairs() %} {% for (id, order) in orders.pairs() %}
<tr> <tr>
<td class="py-1"> <td> {{order.product.name}} </td>
<img src="/a3b/admin/images/faces-clipart/pic-1.png" alt="image" /> <td> {{order.quantity}} </td>
</td> <td> ₹ {{order.product.price}} </td>
<td> <td> {{order.createdAt}} </td>
<a href="/admin/{{user.id}}/show"> <td> ₹ {{toFloat(order.quantity)*order.product.price}} </td>
{{user.lastName}} <td> {{order.address}} </td>
</a> <td> {{order.state}} </td>
</td>
<td> {{user.email}} </td>
<td> {{user.totalQuantity}} </td>
<td> ₹ {{user.totalPrice}} </td>
</tr> </tr>
{% endfor %} #} {% endfor %}
<tr> {# <tr>
<td class="py-1"> <td class="py-1">
<img src="/a3b/admin/images/faces-clipart/pic-2.png" alt="image" /> <img src="/a3b/admin/images/faces-clipart/pic-2.png" alt="image" />
</td> </td>
@ -179,7 +177,7 @@
</td> </td>
<td> $ 150.00 </td> <td> $ 150.00 </td>
<td> June 16, 2015 </td> <td> June 16, 2015 </td>
</tr> </tr> #}
</tbody> </tbody>
</table> </table>
</div> </div>

View File

@ -2,8 +2,9 @@ import db_connector/db_sqlite
import import
strutils, strutils,
times,
../a3pkg/models, ../a3pkg/models,
./users ./[users, products]
proc close*(db: DbConn) = proc close*(db: DbConn) =
db.close() db.close()
@ -72,6 +73,9 @@ proc getOrders*(db: DbConn, userId: int): seq[Orders]=
order.phoneNumber = row[6] order.phoneNumber = row[6]
order.productId = parseInt(row[7]) order.productId = parseInt(row[7])
order.quantity = parseInt(row[8]) order.quantity = parseInt(row[8])
order.createdAt = row[9]
# order.orderStatus =
order.product = db.getProductById(order.productId)
orders.add(order) orders.add(order)

View File

@ -2,7 +2,7 @@ import
mike, mike,
nimja, nimja,
../a3pkg/mics, ../a3pkg/mics,
../a3c/orders ../a3c/[orders, products]
proc admin*(ctx: Context): string= proc admin*(ctx: Context): string=
var var

View File

@ -47,7 +47,8 @@ type
phoneNumber*: string phoneNumber*: string
productId*: int productId*: int
quantity*: int quantity*: int
createdAt*: DateTime createdAt*: string
updatedAt*: DateTime updatedAt*: DateTime
orderStatus*: string orderStatus*: string
orderDate*: DateTime orderDate*: DateTime
product*: Products