| 412 |
ashish |
1 |
'''
|
|
|
2 |
Created on 05-Aug-2010
|
|
|
3 |
|
|
|
4 |
@author: ashish
|
|
|
5 |
'''
|
|
|
6 |
import xlwt
|
|
|
7 |
from shop2020.clients.LogisticsClient import LogisticsClient
|
|
|
8 |
|
| 434 |
ashish |
9 |
def get_html_page():
|
|
|
10 |
a = '''<html>
|
|
|
11 |
<head>
|
|
|
12 |
<meta content="text/html; charset=ISO-8859-1"
|
|
|
13 |
http-equiv="content-type">
|
|
|
14 |
<title>Logistics Dashbaord</title>
|
|
|
15 |
</head>
|
|
|
16 |
<body>
|
|
|
17 |
<h2>Aramex dashboard<br>
|
|
|
18 |
</h2>
|
|
|
19 |
<br>
|
|
|
20 |
<hr style="width: 100%; height: 2px;">
|
|
|
21 |
<h3>Package related links</h3>
|
|
|
22 |
<ol>
|
|
|
23 |
<li><a href="/list">Get today's packages</a></li>
|
|
|
24 |
</ol>
|
|
|
25 |
</body>
|
|
|
26 |
</html>'''
|
|
|
27 |
return a
|
|
|
28 |
|
|
|
29 |
|
|
|
30 |
def get_sample_xml():
|
|
|
31 |
xml = open("/tmp/AWB_Track.xml", 'r').read()
|
|
|
32 |
return xml
|
|
|
33 |
|
| 412 |
ashish |
34 |
def get_xls_for_today(warehouse):
|
|
|
35 |
book = xlwt.Workbook(encoding="utf8")
|
|
|
36 |
sheet = book.add_sheet("Shipment", True);
|
|
|
37 |
sheet.write(0,0, "No shipments")
|
|
|
38 |
|
|
|
39 |
|
|
|
40 |
|
|
|
41 |
logistics_client = LogisticsClient()
|
|
|
42 |
logistics_client.__start__()
|
|
|
43 |
client = logistics_client.get_client()
|
|
|
44 |
|
|
|
45 |
shipments = client.getTodaysShipments(int(warehouse), 1)
|
|
|
46 |
|
|
|
47 |
if shipments:
|
|
|
48 |
#add the headers to the xls file
|
|
|
49 |
sheet.write(0,0, "Shipments for today")
|
|
|
50 |
#headings
|
|
|
51 |
sheet.write(1,0, "AWB")
|
|
|
52 |
sheet.write(1,1, "Origin")
|
|
|
53 |
sheet.write(1,2, "Destination")
|
|
|
54 |
sheet.write(1,3, "Timestamp")
|
|
|
55 |
sheet.write(1,4, "Recepient's Name")
|
|
|
56 |
sheet.write(1,5, "Recepient's Address")
|
|
|
57 |
sheet.write(1,6, "Recepient's Pincode")
|
|
|
58 |
sheet.write(1,7, "Recepient's Phone")
|
|
|
59 |
sheet.write(1,8, "Weight")
|
|
|
60 |
sheet.write(1,9, "Contents")
|
|
|
61 |
sheet.write(1,10, "Warehouse")
|
|
|
62 |
|
|
|
63 |
i=3
|
|
|
64 |
for shipment in shipments:
|
|
|
65 |
sheet.write(i,0, shipment.awb)
|
|
|
66 |
sheet.write(i,1, shipment.origin)
|
|
|
67 |
sheet.write(i,2, shipment.destination)
|
|
|
68 |
sheet.write(i,3, shipment.timestamp)
|
|
|
69 |
sheet.write(i,4, shipment.recepient_name)
|
|
|
70 |
sheet.write(i,5, shipment.recepient_address)
|
|
|
71 |
sheet.write(i,6, shipment.recepient_pincode)
|
|
|
72 |
sheet.write(i,7, shipment.recepient_phone)
|
|
|
73 |
sheet.write(i,8, shipment.shipment_weight)
|
|
|
74 |
sheet.write(i,9, shipment.shipment_contents)
|
|
|
75 |
sheet.write(i,10, shipment.warehouse_name)
|
|
|
76 |
i = i + 1
|
|
|
77 |
|
|
|
78 |
book.save("/tmp/worksheet-statemnet.xls")
|
|
|
79 |
|
|
|
80 |
file = open("/tmp/worksheet-statemnet.xls", 'r').read()
|
|
|
81 |
return file
|
|
|
82 |
|