| Line 25... |
Line 25... |
| 25 |
def getDbConnection():
|
25 |
def getDbConnection():
|
| 26 |
return MySQLdb.connect(DB_HOST, DB_USER, DB_PASSWORD, DB_NAME)
|
26 |
return MySQLdb.connect(DB_HOST, DB_USER, DB_PASSWORD, DB_NAME)
|
| 27 |
|
27 |
|
| 28 |
|
28 |
|
| 29 |
ORDERS_QUERY='''
|
29 |
ORDERS_QUERY='''
|
| 30 |
select * from order_view order by id desc limit %s offset %s
|
30 |
select o.*, u.username from order_view o join users u on u.id=o.user_id order by id desc limit %s offset %s
|
| 31 |
'''
|
31 |
'''
|
| 32 |
ORDERS_DATE_QUERY = '''
|
32 |
ORDERS_DATE_QUERY = '''
|
| 33 |
select * from order_view where created > %s and store_id = %s
|
33 |
select o.*, u.username from order_view o join users u on u.id=o.user_id order by id desc where created > %s and store_id = %s
|
| 34 |
'''
|
34 |
'''
|
| 35 |
ORDERS_DATE_QUERY1 = '''
|
35 |
ORDERS_DATE_QUERY1 = '''
|
| 36 |
select * from orders where created > %s and store_id = %s
|
36 |
select * from orders where created > %s and store_id = %s
|
| 37 |
'''
|
37 |
'''
|
| 38 |
|
38 |
|
| Line 65... |
Line 65... |
| 65 |
query = ORDERS_QUERY%(window,skip)
|
65 |
query = ORDERS_QUERY%(window,skip)
|
| 66 |
cursor.execute(query)
|
66 |
cursor.execute(query)
|
| 67 |
result = cursor.fetchall()
|
67 |
result = cursor.fetchall()
|
| 68 |
template = "<html><head><style>td,th{border:1px solid;padding:2px}</style></head><div>Total Orders: %s</div><br/><body><table style='font-size:12px;border:1px solid grey;border-spacing:0;cell-spacing:0;border-bottom:1px solid grey;border-bottom:1px solid transparent'>%s</table></body></html>"
|
68 |
template = "<html><head><style>td,th{border:1px solid;padding:2px}</style></head><div>Total Orders: %s</div><br/><body><table style='font-size:12px;border:1px solid grey;border-spacing:0;cell-spacing:0;border-bottom:1px solid grey;border-bottom:1px solid transparent'>%s</table></body></html>"
|
| 69 |
tbodyarr = []
|
69 |
tbodyarr = []
|
| 70 |
colhead="<tr><th>Id</th><th>User Id</th><th>Store Id</th><th>Order Url</th><th>Subtag</th><th>Statu</th><th>Created on</th></tr>"
|
70 |
colhead="<tr><th>Id</th><th>User Id</th><th>Username</th><th>Store Id</th><th>Order Url</th><th>Subtag</th><th>Statu</th><th>Created on</th></tr>"
|
| 71 |
tbodyarr.append(colhead)
|
71 |
tbodyarr.append(colhead)
|
| 72 |
for row in result:
|
72 |
for row in result:
|
| 73 |
tbodyarr.append("<tr><td>" + xstr(row[0]) + "</td><td>" + xstr(row[1]) +"</td><td>" + xstr(row[2]) +"</td><td><a target='_blank' href='/rawhtml/" + xstr(row[0]) + "'>" + xstr(row[3])[:130] +"</a></td><td>" + xstr(row[4]) + "</td><td>" + row[5]+ "</td><td>" + row[6].strftime("%Y-%m-%d %H:%M:%S") + "</td></tr>")
|
73 |
tbodyarr.append("<tr><td>" + xstr(row[0]) + "</td><td>" + xstr(row[1]) +"</td><td>" + xstr(row[-1]) + "</td><td>" + xstr(row[2]) +"</td><td><a target='_blank' href='/rawhtml/" + xstr(row[0]) + "'>" + xstr(row[3])[:130] +"</a></td><td>" + xstr(row[4]) + "</td><td>" + row[5]+ "</td><td>" + row[6].strftime("%Y-%m-%d %H:%M:%S") + "</td></tr>")
|
| 74 |
|
74 |
|
| 75 |
return template%(total_count, "".join(tbodyarr))
|
75 |
return template%(total_count, "".join(tbodyarr))
|
| 76 |
except:
|
76 |
except:
|
| 77 |
traceback.print_exc()
|
77 |
traceback.print_exc()
|
| 78 |
finally:
|
78 |
finally:
|