099
This commit is contained in:
parent
e8760ab1a7
commit
53dfa0f257
BIN
db5.sqlite3
BIN
db5.sqlite3
Binary file not shown.
@ -533,6 +533,19 @@
|
|||||||
<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() %}
|
||||||
|
<tr>
|
||||||
|
<td class="py-1">
|
||||||
|
<img src="/a3b/admin/images/faces-clipart/pic-1.png" alt="image" />
|
||||||
|
</td>
|
||||||
|
<td> {{user.lastName}} </td>
|
||||||
|
<td> {{user.email}} </td>
|
||||||
|
<td> {{user.totalQuantity}} </td>
|
||||||
|
<td> {{user.totalPrice}} </td>
|
||||||
|
</tr>
|
||||||
|
{% 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" />
|
||||||
|
@ -330,6 +330,7 @@
|
|||||||
<tbody>
|
<tbody>
|
||||||
{% var total: float = 0.0 %}
|
{% var total: float = 0.0 %}
|
||||||
{% for (id, product) in products.pairs() %}
|
{% for (id, product) in products.pairs() %}
|
||||||
|
<div><input type="hidden" name="product" value="{{product.id}}"></div>
|
||||||
<tr>
|
<tr>
|
||||||
<td>{{product.name}} <strong class="mx-2">x</strong> {{toFloat(cart[id].quantity)}}</td>
|
<td>{{product.name}} <strong class="mx-2">x</strong> {{toFloat(cart[id].quantity)}}</td>
|
||||||
<td>₹{{toFloat(cart[id].quantity)*product.price}}</td>
|
<td>₹{{toFloat(cart[id].quantity)*product.price}}</td>
|
||||||
|
@ -88,3 +88,6 @@ proc getPriceByProductName*(db: DbConn, name: string): float =
|
|||||||
## getPriceByProductName returns the price of a product by its name
|
## getPriceByProductName returns the price of a product by its name
|
||||||
var row = db.getRow(sql"SELECT price FROM products WHERE name = ?", name)
|
var row = db.getRow(sql"SELECT price FROM products WHERE name = ?", name)
|
||||||
return parseFloat(row[0])
|
return parseFloat(row[0])
|
||||||
|
|
||||||
|
proc getProductIdByProductName*(db: DbConn, name: string): int=
|
||||||
|
result = parseInt(db.getValue(sql"SELECT id FROM products WHERE name=?", name))
|
||||||
|
@ -59,10 +59,12 @@ proc getUser*(db: DbConn, email, password: string): User =
|
|||||||
return user
|
return user
|
||||||
|
|
||||||
proc getUserOrdersAmount*(db: DbConn, userId: int): (int, int)=
|
proc getUserOrdersAmount*(db: DbConn, userId: int): (int, int)=
|
||||||
|
echo userId
|
||||||
var
|
var
|
||||||
row = db.getAllRows(sql"SELECT product_id, quantity FROM orders WHERE user_id=?", userId)
|
row = db.getAllRows(sql"SELECT (product_id, quantity) FROM orders WHERE user_id=?", userId)
|
||||||
totalQuantity = 0
|
totalQuantity = 0
|
||||||
totalPrice = 0
|
totalPrice = 0
|
||||||
|
echo row
|
||||||
for b, c in row:
|
for b, c in row:
|
||||||
var
|
var
|
||||||
quantity = c[1]
|
quantity = c[1]
|
||||||
|
@ -1,10 +1,14 @@
|
|||||||
import
|
import
|
||||||
mike,
|
mike,
|
||||||
nimja,
|
nimja,
|
||||||
./a3pkg/mics
|
./a3pkg/mics,
|
||||||
|
./a3c/users
|
||||||
|
|
||||||
proc admin*(ctx: Context): string=
|
proc admin*(ctx: Context): string=
|
||||||
var
|
var
|
||||||
db = newDatabase()
|
db = newDatabase()
|
||||||
|
users = db.getUserCartTable()
|
||||||
|
|
||||||
|
echo users
|
||||||
|
|
||||||
compileTemplateFile(getScriptDir() / "a3a" / "admin" / "index.html")
|
compileTemplateFile(getScriptDir() / "a3a" / "admin" / "index.html")
|
||||||
|
@ -23,6 +23,8 @@ proc checkOut*(ctx: Context): string=
|
|||||||
productName = qParams.getOrDefault("prod", "")
|
productName = qParams.getOrDefault("prod", "")
|
||||||
quantity = parseInt(qParams.getOrDefault("quantity", "0"))
|
quantity = parseInt(qParams.getOrDefault("quantity", "0"))
|
||||||
|
|
||||||
|
# p = seq[int]
|
||||||
|
|
||||||
if email != "":
|
if email != "":
|
||||||
productCount = micsCartProductCount(email, password)
|
productCount = micsCartProductCount(email, password)
|
||||||
|
|
||||||
@ -34,8 +36,9 @@ proc checkOut*(ctx: Context): string=
|
|||||||
product: Products
|
product: Products
|
||||||
ca: Cart
|
ca: Cart
|
||||||
|
|
||||||
product.id = 1
|
product.id = db.getProductIdByProductName(productName)
|
||||||
product.name = productName
|
product.name = productName
|
||||||
|
# p1 = db.getProductIdByProductName(productName)
|
||||||
product.price = db.getPriceByProductName(productName)
|
product.price = db.getPriceByProductName(productName)
|
||||||
ca.quantity = quantity
|
ca.quantity = quantity
|
||||||
products.add(product)
|
products.add(product)
|
||||||
|
@ -44,12 +44,13 @@ proc validationCheckOut*(ctx: Context) =
|
|||||||
order: Orders
|
order: Orders
|
||||||
user: User
|
user: User
|
||||||
|
|
||||||
order.userId = userId
|
# order.userId = userId
|
||||||
order.country = country
|
# order.country = country
|
||||||
order.address = address
|
# order.address = address
|
||||||
order.state = state
|
# order.state = state
|
||||||
order.postalCode = zip
|
# order.postalCode = zip
|
||||||
order.phoneNumber = phone
|
# order.phoneNumber = phone
|
||||||
|
# order.productId = 0
|
||||||
|
|
||||||
user.firstName = firstName
|
user.firstName = firstName
|
||||||
user.lastName = lastName
|
user.lastName = lastName
|
||||||
@ -61,10 +62,22 @@ proc validationCheckOut*(ctx: Context) =
|
|||||||
db.createPost(user)
|
db.createPost(user)
|
||||||
db.clearCart(userId)
|
db.clearCart(userId)
|
||||||
|
|
||||||
var _ = db.createOrder(order)
|
# var _ = db.createOrder(order)
|
||||||
|
|
||||||
for c, d in cart:
|
for c, d in cart:
|
||||||
var product = db.getProductById(d.productId)
|
var product = db.getProductById(d.productId)
|
||||||
|
|
||||||
|
order.userId = userId
|
||||||
|
order.country = country
|
||||||
|
order.address = address
|
||||||
|
order.state = state
|
||||||
|
order.postalCode = zip
|
||||||
|
order.phoneNumber = phone
|
||||||
|
order.productId = d.productId
|
||||||
|
order.quantity = d.quantity
|
||||||
|
|
||||||
|
var _ = db.createOrder(order)
|
||||||
|
|
||||||
products.add(product)
|
products.add(product)
|
||||||
|
|
||||||
ctx.send(sendThankYou())
|
ctx.send(sendThankYou())
|
||||||
|
Loading…
Reference in New Issue
Block a user