| 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 |
|
|
|
9 |
def get_xls_for_today(warehouse):
|
|
|
10 |
book = xlwt.Workbook(encoding="utf8")
|
|
|
11 |
sheet = book.add_sheet("Shipment", True);
|
|
|
12 |
sheet.write(0,0, "No shipments")
|
|
|
13 |
|
|
|
14 |
|
|
|
15 |
|
|
|
16 |
logistics_client = LogisticsClient()
|
|
|
17 |
logistics_client.__start__()
|
|
|
18 |
client = logistics_client.get_client()
|
|
|
19 |
|
|
|
20 |
shipments = client.getTodaysShipments(int(warehouse), 1)
|
|
|
21 |
|
|
|
22 |
if shipments:
|
|
|
23 |
#add the headers to the xls file
|
|
|
24 |
sheet.write(0,0, "Shipments for today")
|
|
|
25 |
#headings
|
|
|
26 |
sheet.write(1,0, "AWB")
|
|
|
27 |
sheet.write(1,1, "Origin")
|
|
|
28 |
sheet.write(1,2, "Destination")
|
|
|
29 |
sheet.write(1,3, "Timestamp")
|
|
|
30 |
sheet.write(1,4, "Recepient's Name")
|
|
|
31 |
sheet.write(1,5, "Recepient's Address")
|
|
|
32 |
sheet.write(1,6, "Recepient's Pincode")
|
|
|
33 |
sheet.write(1,7, "Recepient's Phone")
|
|
|
34 |
sheet.write(1,8, "Weight")
|
|
|
35 |
sheet.write(1,9, "Contents")
|
|
|
36 |
sheet.write(1,10, "Warehouse")
|
|
|
37 |
|
|
|
38 |
i=3
|
|
|
39 |
for shipment in shipments:
|
|
|
40 |
sheet.write(i,0, shipment.awb)
|
|
|
41 |
sheet.write(i,1, shipment.origin)
|
|
|
42 |
sheet.write(i,2, shipment.destination)
|
|
|
43 |
sheet.write(i,3, shipment.timestamp)
|
|
|
44 |
sheet.write(i,4, shipment.recepient_name)
|
|
|
45 |
sheet.write(i,5, shipment.recepient_address)
|
|
|
46 |
sheet.write(i,6, shipment.recepient_pincode)
|
|
|
47 |
sheet.write(i,7, shipment.recepient_phone)
|
|
|
48 |
sheet.write(i,8, shipment.shipment_weight)
|
|
|
49 |
sheet.write(i,9, shipment.shipment_contents)
|
|
|
50 |
sheet.write(i,10, shipment.warehouse_name)
|
|
|
51 |
i = i + 1
|
|
|
52 |
|
|
|
53 |
book.save("/tmp/worksheet-statemnet.xls")
|
|
|
54 |
|
|
|
55 |
file = open("/tmp/worksheet-statemnet.xls", 'r').read()
|
|
|
56 |
return file
|
|
|
57 |
|