097
This commit is contained in:
		
							parent
							
								
									73e690655d
								
							
						
					
					
						commit
						30fef95b94
					
				| @ -57,3 +57,27 @@ proc getUser*(db: DbConn, email, password: string): User = | |||||||
|   user.accessLevel = parseInt(row[7]) |   user.accessLevel = parseInt(row[7]) | ||||||
| 
 | 
 | ||||||
|   return user |   return user | ||||||
|  | 
 | ||||||
|  | proc getUserOrdersAmount*(db: DbConn, userId: int): (int, int)= | ||||||
|  |   var | ||||||
|  |     row = db.getAllRows(sql"SELECT * FROM orders WHERE user_id=?", userId) | ||||||
|  |     totalQuantity = 0 | ||||||
|  |     totalPrice = 0 | ||||||
|  |   for b, c in row: | ||||||
|  |     var | ||||||
|  |       quantity = c[8] | ||||||
|  |       row1 = db.getValue(sql"SELECT price FROM products WHERE id=?", c[7]) | ||||||
|  |    | ||||||
|  |     totalQuantity = parseInt(quantity) | ||||||
|  |     totalPrice = parseInt(row1) | ||||||
|  |   return (totalQuantity, totalPrice) | ||||||
|  | 
 | ||||||
|  | proc getUserCartTable*(db: DbConn)= | ||||||
|  |   var | ||||||
|  |     row = db.getAllRows(sql"SELECT * FROM users;") | ||||||
|  | 
 | ||||||
|  |   for a, b in row: | ||||||
|  |     var | ||||||
|  |       c = db.getValue(sql"SELECT COUNT(id) FROM orders WHERE user_id=?", b[0]) | ||||||
|  |       # d = db.getUserOrdersAmount(parseInt(b[0])) | ||||||
|  |       # d = db.getValue(sql"SELECT SUM()") | ||||||
|  | |||||||
| @ -1,7 +1,10 @@ | |||||||
| import | import | ||||||
|   mike, |   mike, | ||||||
|   nimja |   nimja, | ||||||
|  |   ./a3pkg/mics | ||||||
| 
 | 
 | ||||||
| proc admin*(ctx: Context): string= | proc admin*(ctx: Context): string= | ||||||
|  |   var | ||||||
|  |     db = newDatabase() | ||||||
| 
 | 
 | ||||||
|   compileTemplateFile(getScriptDir() / "a3a" / "admin" / "index.html") |   compileTemplateFile(getScriptDir() / "a3a" / "admin" / "index.html") | ||||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user