Subversion Repositories SmartDukaan

Rev

Rev 15399 | Rev 15407 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 15399 Rev 15402
Line 34... Line 34...
34
 
34
 
35
con = None
35
con = None
36
 
36
 
37
SENDER = "cnc.center@shop2020.in"
37
SENDER = "cnc.center@shop2020.in"
38
PASSWORD = "5h0p2o2o"
38
PASSWORD = "5h0p2o2o"
39
SUBJECT = "CRM Outbound Report for" + date.today().isoformat()
39
SUBJECT = "CRM Outbound Report for " + str(date.today() - timedelta(days=3))
40
SMTP_SERVER = "smtp.gmail.com"
40
SMTP_SERVER = "smtp.gmail.com"
41
SMTP_PORT = 587    
41
SMTP_PORT = 587    
42
 
42
 
43
date_format = xlwt.XFStyle()
43
date_format = xlwt.XFStyle()
44
date_format.num_format_str = 'yyyy/mm/dd'
44
date_format.num_format_str = 'yyyy/mm/dd'
Line 46... Line 46...
46
datetime_format = xlwt.XFStyle()
46
datetime_format = xlwt.XFStyle()
47
datetime_format.num_format_str = 'yyyy/mm/dd HH:MM AM/PM'
47
datetime_format.num_format_str = 'yyyy/mm/dd HH:MM AM/PM'
48
 
48
 
49
default_format = xlwt.XFStyle()
49
default_format = xlwt.XFStyle()
50
freshList=['1','2','3','4','5','6','7','8','9','10','11','12','13']
50
freshList=['1','2','3','4','5','6','7','8','9','10','11','12','13']
51
followUpList=['1','2','3','4','5','6','7']
51
followUpList=['1','2','3','4','5','6']
52
onBoardingList=['1','2','3','4','5'] 
52
onBoardingList=['1','2','3','4','5'] 
53
dispositionMap = {  'call_later':0,
53
dispositionMap = {  'call_later':0,
54
                    'ringing_no_answer':1,
54
                    'ringing_no_answer':1,
55
                    'not_reachable':2,
55
                    'not_reachable':2,
56
                    'switch_off':3,
56
                    'switch_off':3,
Line 71... Line 71...
71
                    'not_reachable':2,
71
                    'not_reachable':2,
72
                    'switch_off':3,
72
                    'switch_off':3,
73
                    'retailer_not_interested':4,
73
                    'retailer_not_interested':4,
74
                    'alreadyuser':5,
74
                    'alreadyuser':5,
75
                    'verified_link_sent':6,
75
                    'verified_link_sent':6,
76
                    'not_retailer':7,
-
 
77
                }
76
                }
78
onBoardingDispositionMap = {  'call_later':0,
77
onBoardingDispositionMap = {  'call_later':0,
79
                    'ringing_no_answer':1,
78
                    'ringing_no_answer':1,
80
                    'not_reachable':2,
79
                    'not_reachable':2,
81
                    'switch_off':3,
80
                    'switch_off':3,
82
                    'onboarded':4,
81
                    'onboarded':4,
83
                }
82
                }
84
 
83
 
-
 
84
# FRESH_QUERY="""
-
 
85
# select call_disposition,count(1) from 
-
 
86
# (select * from (select * from callhistory where date(created)=date(now()) 
-
 
87
# and call_type ='fresh' order by created desc) 
-
 
88
# as a group by retailer_id) 
-
 
89
# a1 group by date(created), call_disposition;
-
 
90
# """
85
FRESH_QUERY="""
91
FRESH_QUERY="""
86
select call_disposition,count(1) from 
92
select call_disposition,count(1) from 
87
(select * from (select * from callhistory where date(created)=date(now()) 
93
(select * from (select * from callhistory where date(created)=date(now() - INTERVAL 3 DAY) 
88
and call_type ='fresh' order by created desc) 
94
and call_type ='fresh' order by created desc) 
89
as a group by retailer_id) 
95
as a group by retailer_id) 
90
a1 group by date(created), call_disposition;
96
a1 group by date(created), call_disposition;
91
"""
97
"""
92
AGENT_FRESH_QUERY="""
98
AGENT_FRESH_QUERY="""
93
select call_disposition,count(1) from 
99
select call_disposition,count(1) from 
94
(select * from (select * from callhistory where date(created)=date(now()) 
100
(select * from (select * from callhistory where date(created)=date(now() - INTERVAL 3 DAY) 
95
and call_type ='fresh' and agent_id=%s order by created desc) 
101
and call_type ='fresh' and agent_id=%s order by created desc) 
96
as a group by retailer_id) 
102
as a group by retailer_id) 
97
a1 group by date(created), call_disposition,agent_id;
103
a1 group by date(created), call_disposition,agent_id;
98
"""
104
"""
99
AGENT_NAME_QUERY="""
105
AGENT_NAME_QUERY="""
100
select name from agents where id=%s
106
select name from agents where id=%s
101
"""
107
"""
102
FRESH_QUERY_LOGIN_TIME="""
108
FRESH_QUERY_LOGIN_TIME="""
103
select agent_id,TIMEDIFF(logoutTime,loginTime) from agentlogintimings where role='fresh' and date(created)=date(now());
109
select agent_id,TIMEDIFF(logoutTime,loginTime) from agentlogintimings where role='fresh' and date(created)=date(now() - INTERVAL 3 DAY);
104
"""
110
"""
105
FRESH_QUERY_DURATION="""
111
FRESH_QUERY_DURATION="""
106
select sum(duration_sec) from callhistory where call_type ='fresh' and date(created)=date(now());
112
select sum(duration_sec) from callhistory where call_type ='fresh' and date(created)=date(now() - INTERVAL 3 DAY);
107
"""
113
"""
-
 
114
FRESH_QUERY_AHT="""
-
 
115
select timestampdiff(second, callhistory.last_fetch_time, created) from callhistory where last_fetch_time is not null and call_type='fresh' and date(created)=date(now() - INTERVAL 3 DAY );
-
 
116
"""
-
 
117
FRESH_QUERY_AIT="""
-
 
118
select timestampdiff(second, last_action_time, created) from fetchdatahistory where call_type='fresh' and date(created)=date(now() - INTERVAL 3 DAY);
-
 
119
"""
-
 
120
FRESH_QUERY_LINKS_CONVERTED="""
-
 
121
select count(*) from retailerlinks where date(activated) = date(created) and date(created)=date(now() - interval 3 day);
-
 
122
"""
-
 
123
FRESH_QUERY_LINKS_NOT_CONVERTED="""
-
 
124
select count(*) from retailerlinks where date(activated) is null and date(created)=date(now() - interval 3 day);
-
 
125
"""
-
 
126
 
-
 
127
 
108
AGENT_FRESH_QUERY_LOGIN_TIME="""
128
AGENT_FRESH_QUERY_LOGIN_TIME="""
109
select TIMEDIFF(logoutTime,loginTime) from agentlogintimings where role='fresh' and date(created)=date(now()) and agent_id=%s;
129
select TIMEDIFF(logoutTime,loginTime) from agentlogintimings where role='fresh' and date(created)=date(now() - INTERVAL 3 DAY) and agent_id=%s;
110
"""
130
"""
111
AGENT_FRESH_QUERY_DURATION="""
131
AGENT_FRESH_QUERY_DURATION="""
112
select sum(duration_sec) from callhistory where call_type ='fresh' and date(created)=date(now()) and agent_id=%s;
132
select sum(duration_sec) from callhistory where call_type ='fresh' and date(created)=date(now() - INTERVAL 3 DAY) and agent_id=%s;
-
 
133
"""
-
 
134
AGENT_FRESH_QUERY_AHT="""
-
 
135
select timestampdiff(second, callhistory.last_fetch_time, created) from callhistory where last_fetch_time is not null and call_type='fresh' and date(created)=date(now() - INTERVAL 3 DAY) and agent_id=%s;
113
"""
136
"""
-
 
137
AGENT_FRESH_QUERY_AIT="""
-
 
138
select timestampdiff(second, last_action_time, created) from fetchdatahistory where call_type='fresh' and date(created)=date(now() - INTERVAL 3 DAY) and agent_id=%s;
-
 
139
"""
-
 
140
AGENT_FRESH_QUERY_LINKS_CONVERTED="""
-
 
141
select count(*) from retailerlinks where date(activated) = date(created) and date(created)=date(now() - interval 3 day) and agent_id=%s;
-
 
142
"""
-
 
143
AGENT_FRESH_QUERY_LINKS_NOT_CONVERTED="""
-
 
144
select count(*) from retailerlinks where date(activated) is null and date(created)=date(now() - interval 3 day) and agent_id=%s;
-
 
145
"""
-
 
146
 
114
 
147
 
115
FOLLOW_UP_QUERY="""
148
FOLLOW_UP_QUERY="""
116
select call_disposition,count(1) from 
149
select call_disposition,count(1) from 
117
(select * from (select * from callhistory where date(created)=date(now()) 
150
(select * from (select * from callhistory where date(created)=date(now() - INTERVAL 3 DAY) 
118
and call_type ='followup' order by created desc) 
151
and call_type ='followup' order by created desc) 
119
as a group by retailer_id) 
152
as a group by retailer_id) 
120
a1 group by date(created), call_disposition;
153
a1 group by date(created), call_disposition;
121
"""
154
"""
122
AGENT_FOLLOW_UP_QUERY="""
155
AGENT_FOLLOW_UP_QUERY="""
123
select call_disposition,count(1) from 
156
select call_disposition,count(1) from 
124
(select * from (select * from callhistory where date(created)=date(now()) 
157
(select * from (select * from callhistory where date(created)=date(now() - INTERVAL 3 DAY)
125
and call_type ='followup' and agent_id=%s order by created desc) 
158
and call_type ='followup' and agent_id=%s order by created desc) 
126
as a group by retailer_id) 
159
as a group by retailer_id) 
127
a1 group by date(created), call_disposition,agent_id;
160
a1 group by date(created), call_disposition,agent_id;
128
"""
161
"""
129
FOLLOW_UP_QUERY_LOGIN_TIME="""
162
FOLLOW_UP_QUERY_LOGIN_TIME="""
130
select agent_id,TIMEDIFF(logoutTime,loginTime) from agentlogintimings where role='followup' and date(created)=date(now());
163
select agent_id,TIMEDIFF(logoutTime,loginTime) from agentlogintimings where role='followup' and date(created)=date(now() - INTERVAL 3 DAY);
131
"""
164
"""
132
FOLLOW_UP_QUERY_DURATION="""
165
FOLLOW_UP_QUERY_DURATION="""
133
select sum(duration_sec) from callhistory where call_type ='followup' and date(created)=date(now());
166
select sum(duration_sec) from callhistory where call_type ='followup' and date(created)=date(now() - INTERVAL 3 DAY);
-
 
167
"""
-
 
168
FOLLOW_UP_QUERY_AHT="""
-
 
169
select timestampdiff(second, callhistory.last_fetch_time, created) from callhistory where last_fetch_time is not null and call_type='followup' and date(created)=date(now() - INTERVAL 3 DAY );
-
 
170
"""
-
 
171
FOLLOW_UP_QUERY_AIT="""
-
 
172
select timestampdiff(second, last_action_time, created) from fetchdatahistory where call_type='followup' and date(created)=date(now() - INTERVAL 3 DAY);
134
"""
173
"""
135
AGENT_FOLLOW_UP_QUERY_LOGIN_TIME="""
174
AGENT_FOLLOW_UP_QUERY_LOGIN_TIME="""
136
select TIMEDIFF(logoutTime,loginTime) from agentlogintimings where role='followup' and date(created)=date(now()) and agent_id=%s;
175
select TIMEDIFF(logoutTime,loginTime) from agentlogintimings where role='followup' and date(created)=date(now() - INTERVAL 3 DAY) and agent_id=%s;
137
"""
176
"""
138
AGENT_FOLLOW_UP_QUERY_DURATION="""
177
AGENT_FOLLOW_UP_QUERY_DURATION="""
139
select sum(duration_sec) from callhistory where call_type ='followup' and date(created)=date(now()) and agent_id=%s;
178
select sum(duration_sec) from callhistory where call_type ='followup' and date(created)=date(now() - INTERVAL 3 DAY) and agent_id=%s;
-
 
179
"""
-
 
180
AGENT_FOLLOW_UP_QUERY_AHT="""
-
 
181
select timestampdiff(second, callhistory.last_fetch_time, created) from callhistory where last_fetch_time is not null and call_type='followup' and date(created)=date(now() - INTERVAL 3 DAY) and agent_id=%s;
140
"""
182
"""
-
 
183
AGENT_FOLLOW_UP_QUERY_AIT="""
-
 
184
select timestampdiff(second, last_action_time, created) from fetchdatahistory where call_type='followup' and date(created)=date(now() - INTERVAL 3 DAY)  and agent_id=%s;
-
 
185
"""
-
 
186
 
141
 
187
 
142
ONBOARDING_QUERY="""
188
ONBOARDING_QUERY="""
143
select call_disposition,count(1) from 
189
select call_disposition,count(1) from 
144
(select * from (select * from callhistory where date(created)=date(now()) 
190
(select * from (select * from callhistory where date(created)=date(now() - INTERVAL 3 DAY) 
145
and call_type ='onboarding' order by created desc) 
191
and call_type ='onboarding' order by created desc) 
146
as a group by retailer_id) 
192
as a group by retailer_id) 
147
a1 group by date(created), call_disposition;
193
a1 group by date(created), call_disposition;
148
"""
194
"""
-
 
195
ONBOARDING_QUERY_LOGIN_TIME="""
-
 
196
select agent_id,TIMEDIFF(logoutTime,loginTime) from agentlogintimings where role='onboarding' and date(created)=date(now() - INTERVAL 3 DAY);
-
 
197
"""
-
 
198
ONBOARDING_QUERY_DURATION="""
-
 
199
select sum(duration_sec) from callhistory where call_type ='onboarding' and date(created)=date(now() - INTERVAL 3 DAY);
-
 
200
"""
-
 
201
ONBOARDING_QUERY_AHT="""
-
 
202
select timestampdiff(second, callhistory.last_fetch_time, created) from callhistory where last_fetch_time is not null and call_type='onboarding' and date(created)=date(now() - INTERVAL 3 DAY );
-
 
203
"""
-
 
204
ONBOARDING_QUERY_AIT="""
-
 
205
select timestampdiff(second, last_action_time, created) from fetchdatahistory where call_type='onboarding' and date(created)=date(now() - INTERVAL 3 DAY);
-
 
206
"""
-
 
207
 
149
AGENT_ONBOARDING_QUERY="""
208
AGENT_ONBOARDING_QUERY="""
150
select call_disposition,count(1) from 
209
select call_disposition,count(1) from 
151
(select * from (select * from callhistory where date(created)=date(now()) 
210
(select * from (select * from callhistory where date(created)=date(now() - INTERVAL 3 DAY)
152
and call_type ='onboarding' and agent_id=%s order by created desc) 
211
and call_type ='onboarding' and agent_id=%s order by created desc) 
153
as a group by retailer_id) 
212
as a group by retailer_id) 
154
a1 group by date(created), call_disposition,agent_id;
213
a1 group by date(created), call_disposition,agent_id;
155
"""
214
"""
156
ONBOARDING_QUERY_LOGIN_TIME="""
-
 
157
select agent_id,TIMEDIFF(logoutTime,loginTime) from agentlogintimings where role='onboarding' and date(created)=date(now());
-
 
158
"""
-
 
159
ONBOARDING_QUERY_DURATION="""
-
 
160
select sum(duration_sec) from callhistory where call_type ='onboarding' and date(created)=date(now());
-
 
161
"""
-
 
162
AGENT_ONBOARDING_QUERY_LOGIN_TIME="""
215
AGENT_ONBOARDING_QUERY_LOGIN_TIME="""
163
select TIMEDIFF(logoutTime,loginTime) from agentlogintimings where role='onboarding' and date(created)=date(now()) and agent_id=%s;
216
select TIMEDIFF(logoutTime,loginTime) from agentlogintimings where role='onboarding' and date(created)=date(now() - INTERVAL 3 DAY) and agent_id=%s;
164
"""
217
"""
165
AGENT_ONBOARDING_QUERY_DURATION="""
218
AGENT_ONBOARDING_QUERY_DURATION="""
166
select sum(duration_sec) from callhistory where call_type ='onboarding' and date(created)=date(now()) and agent_id=%s;
219
select sum(duration_sec) from callhistory where call_type ='onboarding' and date(created)=date(now() - INTERVAL 3 DAY) and agent_id=%s;
-
 
220
"""
-
 
221
AGENT_ONBOARDING_QUERY_AHT="""
-
 
222
select timestampdiff(second, callhistory.last_fetch_time, created) from callhistory where last_fetch_time is not null and call_type='onboarding' and date(created)=date(now() - INTERVAL 3 DAY ) and agent_id=%s;
-
 
223
"""
-
 
224
AGENT_ONBOARDING_QUERY_AIT="""
-
 
225
select timestampdiff(second, last_action_time, created) from fetchdatahistory where call_type='onboarding' and date(created)=date(now() - INTERVAL 3 DAY)  and agent_id=%s;
-
 
226
"""
-
 
227
AGENT_ONBOARDING_QUERY_AIT="""
-
 
228
select timestampdiff(second, last_action_time, created) from fetchdatahistory where call_type='onboarding' and date(created)=date(now() - INTERVAL 3 DAY) and agent_id=%s;
167
"""
229
"""
168
 
230
 
-
 
231
center_alignment=xlwt.easyxf("align: horiz center")
-
 
232
 
169
 
233
 
170
 
234
 
171
def getDbConnection():
235
def getDbConnection():
172
    return MySQLdb.connect(DB_HOST, DB_USER, DB_PASSWORD, DB_NAME)
236
    return MySQLdb.connect(DB_HOST, DB_USER, DB_PASSWORD, DB_NAME)
173
 
237
 
Line 212... Line 276...
212
    worksheet.write(10,column, 'Verified Link Sent', boldStyle)
276
    worksheet.write(10,column, 'Verified Link Sent', boldStyle)
213
    worksheet.write(11,column, 'Accessory Retailer', newStyle)
277
    worksheet.write(11,column, 'Accessory Retailer', newStyle)
214
    worksheet.write(12,column, 'Service Center Retailer', newStyle)
278
    worksheet.write(12,column, 'Service Center Retailer', newStyle)
215
    worksheet.write(13,column, 'Not a Retailer', newStyle)
279
    worksheet.write(13,column, 'Not a Retailer', newStyle)
216
    worksheet.write(14,column, 'Recharge Retailer', newStyle)
280
    worksheet.write(14,column, 'Recharge Retailer', newStyle)
217
    worksheet.write(15,column, 'Contactable Data', newStyle)
281
    worksheet.write(15,column, 'Contactable Data (%)', newStyle)
218
    worksheet.write(16,column, 'Non Contactable Data', newStyle)
282
    worksheet.write(16,column, 'Non Contactable Data (%)', newStyle)
219
    worksheet.write(17,column, 'Agents Logged In', style)
283
    worksheet.write(17,column, 'Agents Logged In', style)
220
    worksheet.write(18,column, 'Average Login Time (In Hrs)', style)
284
    worksheet.write(18,column, 'Average Login Time (In Hrs)', style)
221
    worksheet.write(19,column, 'Total Dialed Out', style)
285
    worksheet.write(19,column, 'Total Dialed Out', style)
222
    worksheet.write(20,column, 'Average Dialed Out per agent', style)
286
    worksheet.write(20,column, 'Average Dialed Out per agent', style)
223
    worksheet.write(21,column, 'Average Call Duration (In Hrs)', style)
287
    worksheet.write(21,column, 'Average Call Duration (In Hrs)', style)
-
 
288
    worksheet.write(22,column, 'Average Handling Time (In Hrs)', style)
-
 
289
    worksheet.write(23,column, 'Average Idle Time (In Hrs)', style)
-
 
290
    worksheet.write(24,column, 'Links Converted', style)
-
 
291
    worksheet.write(25,column, 'Link sent yet to be converted', style)
224
    contactableData=0
292
    contactableData=0
225
    nonContactableData=0
293
    nonContactableData=0
226
    
294
    
227
    for r in result:
295
    for r in result:
228
        row = dispositionMap.get(r[0])+1
296
        row = dispositionMap.get(r[0])+1
Line 230... Line 298...
230
            nonContactableData+=int(r[1])
298
            nonContactableData+=int(r[1])
231
        else:
299
        else:
232
            contactableData+=r[1] 
300
            contactableData+=r[1] 
233
        currentList.append(str(row))
301
        currentList.append(str(row))
234
        column = 1
302
        column = 1
235
        worksheet.write(row, column, r[1])
303
        worksheet.write(row, column, r[1],center_alignment)
236
        
304
        
237
    remainingList = list(set(freshList) - set(currentList))
305
    remainingList = list(set(freshList) - set(currentList))
238
    for i,val in enumerate(remainingList):
306
    for i,val in enumerate(remainingList):
239
        row = int(val)
307
        row = int(val)
240
        column = 1
308
        column = 1
241
        worksheet.write(row, column, 0)
309
        worksheet.write(row, column, 0,center_alignment)
242
    totalDispositions=contactableData+nonContactableData
310
    totalDispositions=contactableData+nonContactableData
-
 
311
    
243
    worksheet.write(15,1,(contactableData/float(totalDispositions))*100)
312
    worksheet.write(15,1,round((contactableData/float(totalDispositions))*100,2),center_alignment)
244
    worksheet.write(16,1,(nonContactableData/float(totalDispositions))*100)
313
    worksheet.write(16,1,round((nonContactableData/float(totalDispositions))*100,2),center_alignment)
245
    
314
    
246
    
315
    
247
    conn.close()
316
    conn.close()
248
    datesql=FRESH_QUERY_LOGIN_TIME 
317
    datesql=FRESH_QUERY_LOGIN_TIME 
249
    conn = getDbConnection()
318
    conn = getDbConnection()
Line 257... Line 326...
257
        loginTime+=r[1].seconds
326
        loginTime+=r[1].seconds
258
        agentLoginList.append(str(r[0]))
327
        agentLoginList.append(str(r[0]))
259
    averageLoginTime=loginTime/len(list(set(agentLoginList)))
328
    averageLoginTime=loginTime/len(list(set(agentLoginList)))
260
    hours=averageLoginTime/3600
329
    hours=averageLoginTime/3600
261
    minutesLeft=(averageLoginTime%3600)/60
330
    minutesLeft=(averageLoginTime%3600)/60
262
    worksheet.write(17,1,len(list(set(agentLoginList))))
331
    worksheet.write(17,1,len(list(set(agentLoginList))),center_alignment)
263
    worksheet.write(18,1,str(hours) + ':'+ str(minutesLeft))   
332
    worksheet.write(18,1,str(hours) + ':'+ str(minutesLeft),center_alignment)   
264
    worksheet.write(19,1,totalDispositions)
333
    worksheet.write(19,1,totalDispositions,center_alignment)
265
    print 'list' + str(agentLoginList)
-
 
266
    print 'Avg' + str(totalDispositions/float(len(list(set(agentLoginList)))))
-
 
267
    print 'list' + str(list(set(agentLoginList)))
-
 
268
    worksheet.write(20,1,totalDispositions/float(len(list(set(agentLoginList)))))
334
    worksheet.write(20,1,totalDispositions/float(len(list(set(agentLoginList)))),center_alignment)
269
    conn.close()
335
    conn.close()
270
    datesql=FRESH_QUERY_DURATION
336
    datesql=FRESH_QUERY_DURATION
271
    conn = getDbConnection()
337
    conn = getDbConnection()
272
    
338
    
273
    cursor = conn.cursor()
339
    cursor = conn.cursor()
Line 276... Line 342...
276
    for r in result:
342
    for r in result:
277
        totalCallDuration= r[0]
343
        totalCallDuration= r[0]
278
    averageCallDuration=totalCallDuration/len(list(set(agentLoginList)))    
344
    averageCallDuration=totalCallDuration/len(list(set(agentLoginList)))    
279
    hours=averageCallDuration/3600
345
    hours=averageCallDuration/3600
280
    minutesLeft=(averageCallDuration%3600)/60    
346
    minutesLeft=(averageCallDuration%3600)/60    
281
    worksheet.write(21,1,str(int(hours))+':'+str(int(minutesLeft)))
347
    worksheet.write(21,1,str(int(hours))+':'+str(int(minutesLeft)),center_alignment)
-
 
348
    
-
 
349
    conn.close()
-
 
350
    datesql=FRESH_QUERY_AHT
-
 
351
    conn = getDbConnection()
-
 
352
    
-
 
353
    cursor = conn.cursor()
-
 
354
    cursor.execute(datesql)
-
 
355
    result = cursor.fetchall()
-
 
356
    loginTime=0
-
 
357
    for r in result:
-
 
358
        loginTime+=r[0]
-
 
359
    averageLoginTime=loginTime/len(list(set(agentLoginList)))
-
 
360
    hours=averageLoginTime/3600
-
 
361
    minutesLeft=(averageLoginTime%3600)/60
-
 
362
    worksheet.write(22,1,len(list(set(agentLoginList))),center_alignment)
-
 
363
    
-
 
364
    conn.close()
-
 
365
    datesql=FRESH_QUERY_AIT
-
 
366
    conn = getDbConnection()
-
 
367
    
-
 
368
    cursor = conn.cursor()
-
 
369
    cursor.execute(datesql)
-
 
370
    result = cursor.fetchall()
-
 
371
    loginTime=0
-
 
372
    for r in result:
-
 
373
        loginTime+=r[0]
-
 
374
    averageLoginTime=loginTime/len(list(set(agentLoginList)))
-
 
375
    hours=averageLoginTime/3600
-
 
376
    minutesLeft=(averageLoginTime%3600)/60
-
 
377
    worksheet.write(23,1,len(list(set(agentLoginList))),center_alignment)
-
 
378
    
-
 
379
    conn.close()
-
 
380
    datesql=FRESH_QUERY_LINKS_CONVERTED
-
 
381
    conn = getDbConnection()
-
 
382
    
-
 
383
    cursor = conn.cursor()
-
 
384
    cursor.execute(datesql)
-
 
385
    result = cursor.fetchall()
-
 
386
    loginTime=0
-
 
387
    for r in result:
-
 
388
        worksheet.write(24,1,r[0],center_alignment)
-
 
389
    
-
 
390
    conn.close()
-
 
391
    datesql=FRESH_QUERY_LINKS_NOT_CONVERTED
-
 
392
    conn = getDbConnection()
-
 
393
    
-
 
394
    cursor = conn.cursor()
-
 
395
    cursor.execute(datesql)
-
 
396
    result = cursor.fetchall()
-
 
397
    loginTime=0
-
 
398
    for r in result:
-
 
399
        worksheet.write(25,1,r[0],center_alignment)
282
    
400
    
283
    workbook.save(TMP_FILE)
401
    workbook.save(TMP_FILE)
284
    #sendmail(["manas.kapoor@shop2020.in"], "", TMP_FILE, SUBJECT)        
402
    #sendmail(["manas.kapoor@shop2020.in"], "", TMP_FILE, SUBJECT)        
285
 
403
 
286
 
404
 
287
def generateAgentWiseFreshCallingReport():
405
def generateAgentWiseFreshCallingReport():
288
    
406
    
289
    agentId=3
407
    agentId=3
290
    #global workbook
-
 
291
    rb = open_workbook(TMP_FILE,formatting_info=True)
408
    rb = open_workbook(TMP_FILE,formatting_info=True)
292
    workbook = copy(rb)
409
    workbook = copy(rb)
293
    numberOfSheets=rb.nsheets
410
    numberOfSheets=rb.nsheets
294
    print 'Number of sheets ' + str(numberOfSheets)
-
 
295
    sheet=rb.sheet_by_index(numberOfSheets-1)
411
    sheet=rb.sheet_by_index(numberOfSheets-1)
296
    worksheet = workbook.get_sheet(numberOfSheets-1)
412
    worksheet = workbook.get_sheet(numberOfSheets-1)
297
    
413
    
298
    boldStyle = xlwt.XFStyle()
414
    boldStyle = xlwt.XFStyle()
299
    newStyle= xlwt.XFStyle()
415
    newStyle= xlwt.XFStyle()
Line 321... Line 437...
321
    worksheet.write(row+10,column-1, 'Verified Link Sent', boldStyle)
437
    worksheet.write(row+10,column-1, 'Verified Link Sent', boldStyle)
322
    worksheet.write(row+11,column-1, 'Accessory Retailer', newStyle)
438
    worksheet.write(row+11,column-1, 'Accessory Retailer', newStyle)
323
    worksheet.write(row+12,column-1, 'Service Center Retailer', newStyle)
439
    worksheet.write(row+12,column-1, 'Service Center Retailer', newStyle)
324
    worksheet.write(row+13,column-1, 'Not a Retailer', newStyle)
440
    worksheet.write(row+13,column-1, 'Not a Retailer', newStyle)
325
    worksheet.write(row+14,column-1, 'Recharge Retailer', newStyle)
441
    worksheet.write(row+14,column-1, 'Recharge Retailer', newStyle)
326
    worksheet.write(row+15,column-1, 'Contactable Data', newStyle)
442
    worksheet.write(row+15,column-1, 'Contactable Data (%)', newStyle)
327
    worksheet.write(row+16,column-1, 'Non Contactable Data', newStyle)
443
    worksheet.write(row+16,column-1, 'Non Contactable Data (%)', newStyle)
328
    worksheet.write(row+17,column-1, 'Total Dialed Out', style)
444
    worksheet.write(row+17,column-1, 'Total Dialed Out', style)
329
    worksheet.write(row+18,column-1, 'Login Time (In Hrs)', style)
445
    worksheet.write(row+18,column-1, 'Login Time (In Hrs)', style)
330
    worksheet.write(row+19,column-1, 'Call Duration (In Hrs)', style)
446
    worksheet.write(row+19,column-1, 'Call Duration (In Hrs)', style)
331
    
-
 
-
 
447
    worksheet.write(row+20,column-1, 'Handling Time (In Hrs)', style)
-
 
448
    worksheet.write(row+21,column-1, 'Idle Time (In Hrs)', style)
-
 
449
    worksheet.write(row+22,column-1, 'Links Converted', style)
-
 
450
    worksheet.write(row+23,column-1, 'Link sent yet to be converted', style)        
332
    columnId=agentId
451
    columnId=agentId
333
    while True:
452
    while True:
334
            if agentId >5 :
453
            if agentId >5 :
335
                break
454
                break
336
            else: 
455
            else: 
Line 357... Line 476...
357
                            contactableData+=r[1] 
476
                            contactableData+=r[1] 
358
                        currentList.append(str(dispositionMap.get(r[0])))
477
                        currentList.append(str(dispositionMap.get(r[0])))
359
                        column = agentId
478
                        column = agentId
360
                        remainingList = list(set(freshList) - set(currentList))
479
                        remainingList = list(set(freshList) - set(currentList))
361
                        
480
                        
362
                        worksheet.write(row, columnId, r[1])
481
                        worksheet.write(row, columnId, r[1],center_alignment)
363
                        for i,val in enumerate(remainingList):
482
                        for i,val in enumerate(remainingList):
364
                            row = int(val)+26
483
                            row = int(val)+26
365
                            column = agentId
484
                            column = agentId
366
                            worksheet.write(row, columnId, 0)
485
                            worksheet.write(row, columnId, 0,center_alignment)
367
                    totalDialedOut = contactableData+nonContactableData
486
                    totalDialedOut = contactableData+nonContactableData
368
                    worksheet.write(25+15,columnId,(contactableData/float(totalDialedOut))*100)
487
                    worksheet.write(25+15,columnId,round((contactableData/float(totalDialedOut))*100,2),center_alignment)
369
                    worksheet.write(25+16,columnId,(nonContactableData/float(totalDialedOut))*100)
488
                    worksheet.write(25+16,columnId,round((nonContactableData/float(totalDialedOut))*100,2),center_alignment)
370
                    worksheet.write(25+17,columnId,totalDialedOut)
489
                    worksheet.write(25+17,columnId,totalDialedOut,center_alignment)
371
                    conn.close()
490
                    conn.close()
372
                
491
                
373
                    name_query=AGENT_NAME_QUERY %(agentId)
492
                    name_query=AGENT_NAME_QUERY %(agentId)
374
                    conn = getDbConnection()
493
                    conn = getDbConnection()
375
                    column=agentId
494
                    column=agentId
Line 392... Line 511...
392
                    for r in result:
511
                    for r in result:
393
                        loginTime+=r[0].seconds
512
                        loginTime+=r[0].seconds
394
                        
513
                        
395
                    hours=loginTime/3600
514
                    hours=loginTime/3600
396
                    minutesLeft=(loginTime%3600)/60
515
                    minutesLeft=(loginTime%3600)/60
397
                    worksheet.write(25+18,columnId,str(hours)+':'+str(minutesLeft))    
516
                    worksheet.write(25+18,columnId,str(hours)+':'+str(minutesLeft),center_alignment)    
398
                    conn.close()
517
                    conn.close()
399
                    
518
                    
400
                    name_query=AGENT_FRESH_QUERY_DURATION %(agentId)
519
                    name_query=AGENT_FRESH_QUERY_DURATION %(agentId)
401
                    conn = getDbConnection()
520
                    conn = getDbConnection()
402
                    column=agentId
521
                    column=agentId
Line 406... Line 525...
406
                    loginTime=0
525
                    loginTime=0
407
                    for r in result:
526
                    for r in result:
408
                        loginTime+=r[0]
527
                        loginTime+=r[0]
409
                    hours=loginTime/3600
528
                    hours=loginTime/3600
410
                    minutesLeft=(loginTime%3600)/60
529
                    minutesLeft=(loginTime%3600)/60
411
                    worksheet.write(25+19,columnId,str(int(hours))+':'+str(int(minutesLeft)))    
530
                    worksheet.write(25+19,columnId,str(int(hours))+':'+str(int(minutesLeft)),center_alignment)    
-
 
531
                    conn.close()
-
 
532
                    
-
 
533
                    name_query=AGENT_FRESH_QUERY_AHT %(agentId)
-
 
534
                    conn = getDbConnection()
-
 
535
                    column=agentId
-
 
536
                    cursor = conn.cursor()
-
 
537
                    cursor.execute(name_query)
-
 
538
                    result = cursor.fetchall()
-
 
539
                    loginTime=0
-
 
540
                    for r in result:
-
 
541
                        loginTime+=r[0]
-
 
542
                    hours=loginTime/3600
-
 
543
                    minutesLeft=(loginTime%3600)/60
-
 
544
                    worksheet.write(25+20,columnId,str(int(hours))+':'+str(int(minutesLeft)),center_alignment)    
-
 
545
                    conn.close()
-
 
546
                    
-
 
547
                    name_query=AGENT_FRESH_QUERY_AIT %(agentId)
-
 
548
                    conn = getDbConnection()
-
 
549
                    column=agentId
-
 
550
                    cursor = conn.cursor()
-
 
551
                    cursor.execute(name_query)
-
 
552
                    result = cursor.fetchall()
-
 
553
                    loginTime=0
-
 
554
                    for r in result:
-
 
555
                        loginTime+=r[0]
-
 
556
                    hours=loginTime/3600
-
 
557
                    minutesLeft=(loginTime%3600)/60
-
 
558
                    worksheet.write(25+21,columnId,str(int(hours))+':'+str(int(minutesLeft)),center_alignment)    
-
 
559
                    conn.close()
-
 
560
 
-
 
561
                    datesql=AGENT_FRESH_QUERY_LINKS_CONVERTED%(agentId)
-
 
562
                    conn = getDbConnection()
-
 
563
                    
-
 
564
                    cursor = conn.cursor()
-
 
565
                    cursor.execute(datesql)
-
 
566
                    result = cursor.fetchall()
-
 
567
                    loginTime=0
-
 
568
                    for r in result:
-
 
569
                        worksheet.write(25+22,columnId,r[0],center_alignment)
-
 
570
                    
412
                    conn.close()
571
                    conn.close()
-
 
572
                    datesql=AGENT_FRESH_QUERY_LINKS_NOT_CONVERTED%(agentId)
-
 
573
                    conn = getDbConnection()
-
 
574
                    
-
 
575
                    cursor = conn.cursor()
-
 
576
                    cursor.execute(datesql)
-
 
577
                    result = cursor.fetchall()
-
 
578
                    loginTime=0
-
 
579
                    for r in result:
-
 
580
                        worksheet.write(25+23,columnId,r[0],center_alignment)    
413
                    
581
                    
414
                agentId+=1
582
                agentId+=1
415
                columnId+=1
583
                columnId+=1
416
    workbook.save(TMP_FILE)    
584
    workbook.save(TMP_FILE)    
417
    #sendmail(["manas.kapoor@shop2020.in"], "", TMP_FILE, SUBJECT)        
585
    #sendmail(["manas.kapoor@shop2020.in"], "", TMP_FILE, SUBJECT)        
Line 450... Line 618...
450
    worksheet.write(3,column, 'Not Reachable', newStyle)
618
    worksheet.write(3,column, 'Not Reachable', newStyle)
451
    worksheet.write(4,column, 'Switched Off', newStyle)
619
    worksheet.write(4,column, 'Switched Off', newStyle)
452
    worksheet.write(5,column, 'Retailer Not Interested', newStyle)
620
    worksheet.write(5,column, 'Retailer Not Interested', newStyle)
453
    worksheet.write(6,column, 'Already Profitmandi user', boldStyle)   
621
    worksheet.write(6,column, 'Already Profitmandi user', boldStyle)   
454
    worksheet.write(7,column, 'Verified Link Sent', boldStyle)
622
    worksheet.write(7,column, 'Verified Link Sent', boldStyle)
455
    worksheet.write(8,column, 'Not a retailer', boldStyle)
-
 
456
    worksheet.write(9,column, 'Contactable Data', newStyle)
623
    worksheet.write(8,column, 'Contactable Data (%)', newStyle)
457
    worksheet.write(10,column, 'Non Contactable Data', newStyle)
624
    worksheet.write(9,column, 'Non Contactable Data (%)', newStyle)
458
    worksheet.write(11,column, 'Agents Logged In', style)
625
    worksheet.write(10,column, 'Agents Logged In', style)
459
    worksheet.write(12,column, 'Average Login Time (In Hrs)', style)
626
    worksheet.write(11,column, 'Average Login Time (In Hrs)', style)
460
    worksheet.write(13,column, 'Total Dialed Out', style)
627
    worksheet.write(12,column, 'Total Dialed Out', style)
461
    worksheet.write(14,column, 'Average Dialed Out per agent', style)
628
    worksheet.write(13,column, 'Average Dialed Out per agent', style)
462
    worksheet.write(15,column, 'Average Call Duration (In Hrs)', style)
629
    worksheet.write(14,column, 'Average Call Duration (In Hrs)', style)
-
 
630
    worksheet.write(15,column, 'Average Handling Time (In Hrs)', style)
-
 
631
    worksheet.write(16,column, 'Average Idle Time (In Hrs)', style)
463
    
632
    
464
    contactableData=0
633
    contactableData=0
465
    nonContactableData=0
634
    nonContactableData=0
466
    totalDispositions=0
635
    totalDispositions=0
467
    print result
636
    
468
    for r in result:
637
    for r in result:
469
        row = followUpDispositionMap.get(r[0])+1
638
        row = followUpDispositionMap.get(r[0])+1
470
        if followUpDispositionMap.get(r[0]) == 1 or followUpDispositionMap.get(r[0]) == 2 or followUpDispositionMap.get(r[0]) == 3:
639
        if followUpDispositionMap.get(r[0]) == 1 or followUpDispositionMap.get(r[0]) == 2 or followUpDispositionMap.get(r[0]) == 3:
471
            nonContactableData+=int(r[1])
640
            nonContactableData+=int(r[1])
472
        else:
641
        else:
473
            contactableData+=r[1] 
642
            contactableData+=r[1] 
474
        currentList.append(str(row))
643
        currentList.append(str(row))
475
        column = 1
644
        column = 1
476
        worksheet.write(row, column, r[1])
645
        worksheet.write(row, column, r[1],center_alignment)
477
    
646
    
478
    remainingList = list(set(followUpList) - set(currentList))
647
    remainingList = list(set(followUpList) - set(currentList))
479
    print remainingList
648
    
480
    for i,val in enumerate(remainingList):
649
    for i,val in enumerate(remainingList):
481
        row = int(val)
650
        row = int(val)
482
        print row
651
        
483
        column = 1
652
        column = 1
484
        worksheet.write(row, column, 0)
653
        worksheet.write(row, column, 0,center_alignment)
485
    totalDispositions=contactableData+nonContactableData
654
    totalDispositions=contactableData+nonContactableData
486
    worksheet.write(9,1,(contactableData/float(totalDispositions))*100)
655
    worksheet.write(8,1,round((contactableData/float(totalDispositions))*100,2),center_alignment)
487
    worksheet.write(10,1,(nonContactableData/float(totalDispositions))*100)
656
    worksheet.write(9,1,round((nonContactableData/float(totalDispositions))*100,2),center_alignment)
488
    
657
    
489
    
658
    
490
    conn.close()
659
    conn.close()
491
    datesql=FOLLOW_UP_QUERY_LOGIN_TIME 
660
    datesql=FOLLOW_UP_QUERY_LOGIN_TIME 
492
    conn = getDbConnection()
661
    conn = getDbConnection()
Line 501... Line 670...
501
        loginTime+=r[1].seconds
670
        loginTime+=r[1].seconds
502
        agentLoginList.append(str(r[0]))
671
        agentLoginList.append(str(r[0]))
503
    averageLoginTime=loginTime/len(list(set(agentLoginList)))
672
    averageLoginTime=loginTime/len(list(set(agentLoginList)))
504
    hours=averageLoginTime/3600
673
    hours=averageLoginTime/3600
505
    minutesLeft=(averageLoginTime%3600)/60
674
    minutesLeft=(averageLoginTime%3600)/60
506
    worksheet.write(11,1,len(list(set(agentLoginList))))
675
    worksheet.write(10,1,len(list(set(agentLoginList))),center_alignment)
507
    worksheet.write(12,1,str(hours) + ':'+ str(minutesLeft))   
676
    worksheet.write(11,1,str(hours) + ':'+ str(minutesLeft),center_alignment)   
508
    worksheet.write(13,1,totalDispositions)
677
    worksheet.write(12,1,totalDispositions,center_alignment)
509
    worksheet.write(14,1,(contactableData+nonContactableData)/len(list(set(agentLoginList))))
678
    worksheet.write(13,1,(contactableData+nonContactableData)/len(list(set(agentLoginList))),center_alignment)
510
    conn.close()
679
    conn.close()
511
    datesql=FOLLOW_UP_QUERY_DURATION
680
    datesql=FOLLOW_UP_QUERY_DURATION
512
    conn = getDbConnection()
681
    conn = getDbConnection()
513
    
682
    
514
    cursor = conn.cursor()
683
    cursor = conn.cursor()
Line 517... Line 686...
517
    for r in result:
686
    for r in result:
518
        totalCallDuration= r[0]
687
        totalCallDuration= r[0]
519
    averageCallDuration=totalCallDuration/len(list(set(agentLoginList)))    
688
    averageCallDuration=totalCallDuration/len(list(set(agentLoginList)))    
520
    hours=averageCallDuration/3600
689
    hours=averageCallDuration/3600
521
    minutesLeft=(averageCallDuration%3600)/60    
690
    minutesLeft=(averageCallDuration%3600)/60    
522
    worksheet.write(15,1,str(int(hours))+':'+str(int(minutesLeft)))
691
    worksheet.write(14,1,str(int(hours))+':'+str(int(minutesLeft)),center_alignment)
-
 
692
    conn.close()
-
 
693
    
-
 
694
    datesql=FOLLOW_UP_QUERY_AHT
-
 
695
    conn = getDbConnection()
-
 
696
    cursor = conn.cursor()
523
    workbook.save(TMP_FILE)
697
    cursor.execute(datesql)
-
 
698
    result = cursor.fetchall()
-
 
699
    loginTime=0
-
 
700
    for r in result:
-
 
701
        loginTime+=r[0]
-
 
702
    averageLoginTime=loginTime/len(list(set(agentLoginList)))
-
 
703
    hours=averageLoginTime/3600
-
 
704
    minutesLeft=(averageLoginTime%3600)/60
524
    #sendmail(["manas.kapoor@shop2020.in"], "", TMP_FILE, SUBJECT)        
705
    worksheet.write(15,1,len(list(set(agentLoginList))),center_alignment)
-
 
706
    conn.close()
525
 
707
    
-
 
708
    datesql=FOLLOW_UP_QUERY_AIT
-
 
709
    conn = getDbConnection()
-
 
710
    cursor = conn.cursor()
-
 
711
    cursor.execute(datesql)
-
 
712
    result = cursor.fetchall()
-
 
713
    loginTime=0
-
 
714
    for r in result:
-
 
715
        loginTime+=r[0]
-
 
716
    averageLoginTime=loginTime/len(list(set(agentLoginList)))
-
 
717
    hours=averageLoginTime/3600
-
 
718
    minutesLeft=(averageLoginTime%3600)/60
-
 
719
    worksheet.write(16,1,len(list(set(agentLoginList))),center_alignment)
-
 
720
    workbook.save(TMP_FILE)  
526
 
721
 
527
def generateAgentWiseFollowupCallingReport():
722
def generateAgentWiseFollowupCallingReport():
528
    
723
    
529
    agentId=3
724
    agentId=3
530
    rb = open_workbook(TMP_FILE,formatting_info=True)
725
    rb = open_workbook(TMP_FILE,formatting_info=True)
531
    workbook = copy(rb)
726
    workbook = copy(rb)
532
    numberOfSheets=rb.nsheets
727
    numberOfSheets=rb.nsheets
533
    print 'Number of sheets ' + str(numberOfSheets)
-
 
534
    sheet=rb.sheet_by_index(numberOfSheets-1)
728
    sheet=rb.sheet_by_index(numberOfSheets-1)
535
    worksheet = workbook.get_sheet(numberOfSheets-1)
729
    worksheet = workbook.get_sheet(numberOfSheets-1)
536
    boldStyle = xlwt.XFStyle()
730
    boldStyle = xlwt.XFStyle()
537
    newStyle= xlwt.XFStyle()
731
    newStyle= xlwt.XFStyle()
538
    style = xlwt.XFStyle()
732
    style = xlwt.XFStyle()
Line 552... Line 746...
552
    worksheet.write(row+3,column-1, 'Not Reachable', newStyle)
746
    worksheet.write(row+3,column-1, 'Not Reachable', newStyle)
553
    worksheet.write(row+4,column-1, 'Switched Off', newStyle)
747
    worksheet.write(row+4,column-1, 'Switched Off', newStyle)
554
    worksheet.write(row+5,column-1, 'Retailer Not Interested', newStyle)
748
    worksheet.write(row+5,column-1, 'Retailer Not Interested', newStyle)
555
    worksheet.write(row+6,column-1, 'Already Profitmandi user', boldStyle)   
749
    worksheet.write(row+6,column-1, 'Already Profitmandi user', boldStyle)   
556
    worksheet.write(row+7,column-1, 'Verified Link Sent', boldStyle)
750
    worksheet.write(row+7,column-1, 'Verified Link Sent', boldStyle)
557
    worksheet.write(row+8,column-1, 'Not a Retailer', newStyle)
751
    worksheet.write(row+8,column-1, 'Contactable Data (%)', newStyle)
558
    worksheet.write(row+9,column-1, 'Contactable Data', newStyle)
752
    worksheet.write(row+9,column-1, 'Non Contactable Data (%)', newStyle)
559
    worksheet.write(row+10,column-1, 'Non Contactable Data', newStyle)
753
    worksheet.write(row+10,column-1, 'Total Dialed Out', style)
560
    worksheet.write(row+11,column-1, 'Total Dialed Out', style)
754
    worksheet.write(row+11,column-1, 'Login Time (In Hrs)', style)
-
 
755
    worksheet.write(row+12,column-1, 'Call Duration (In Hrs)', style)
561
    worksheet.write(row+12,column-1, 'Login Time (In Hrs)', style)
756
    worksheet.write(row+13,column-1, 'Handling Time (In Hrs)', style)
562
    worksheet.write(row+13,column-1, 'Call Duration (In Hrs)', style)
757
    worksheet.write(row+14,column-1, 'Idle Time (In Hrs)', style)
563
    
-
 
564
    columnId=agentId
758
    columnId=agentId
565
    while True:
759
    while True:
566
            if agentId >5 :
760
            if agentId >5 :
567
                break
761
                break
568
            else: 
762
            else: 
Line 578... Line 772...
578
                nonContactableData=0
772
                nonContactableData=0
579
                if cursor.rowcount ==0:
773
                if cursor.rowcount ==0:
580
                    agentId+=1
774
                    agentId+=1
581
                    continue    
775
                    continue    
582
                else:
776
                else:
583
                    print result
777
                    
584
                    for r in result:
778
                    for r in result:
585
                        row = followUpDispositionMap.get(r[0])+26
779
                        row = followUpDispositionMap.get(r[0])+26
586
                        if followUpDispositionMap.get(r[0]) == 1 or followUpDispositionMap.get(r[0]) == 2 or followUpDispositionMap.get(r[0]) == 3 or followUpDispositionMap.get(r[0]) == 4:
780
                        if followUpDispositionMap.get(r[0]) == 1 or followUpDispositionMap.get(r[0]) == 2 or followUpDispositionMap.get(r[0]) == 3 :
587
                            nonContactableData+=int(r[1])
781
                            nonContactableData+=int(r[1])
588
                        else:
782
                        else:
589
                            contactableData+=r[1] 
783
                            contactableData+=r[1] 
590
                        currentList.append(str(followUpDispositionMap.get(r[0])+1))
784
                        currentList.append(str(followUpDispositionMap.get(r[0])+1))
591
                        column = agentId
785
                        column = agentId
592
                        worksheet.write(row, columnId, r[1])
786
                        worksheet.write(row, columnId, r[1],center_alignment)
593
                    remainingList = list(set(followUpList) - set(currentList))
787
                    remainingList = list(set(followUpList) - set(currentList))
594
                    
788
                    
595
                    for i,val in enumerate(remainingList):
789
                    for i,val in enumerate(remainingList):
596
                        row = int(val)+25
790
                        row = int(val)+25
597
                        column = agentId
791
                        column = agentId
598
                        worksheet.write(row, columnId, 0)
792
                        worksheet.write(row, columnId, 0,center_alignment)
599
                    totalDialedOut = contactableData+nonContactableData
793
                    totalDialedOut = contactableData+nonContactableData
600
                    worksheet.write(25+9,columnId,(contactableData/float(totalDialedOut))*100)
794
                    worksheet.write(25+8,columnId,round((contactableData/float(totalDialedOut))*100,2),center_alignment)
601
                    worksheet.write(25+10,columnId,(nonContactableData/float(totalDialedOut))*100)
795
                    worksheet.write(25+9,columnId,round((nonContactableData/float(totalDialedOut))*100,2),center_alignment)
602
                    worksheet.write(25+11,columnId,totalDialedOut)
796
                    worksheet.write(25+10,columnId,totalDialedOut,center_alignment)
603
                    conn.close()
797
                    conn.close()
604
                
798
                
605
                    name_query=AGENT_NAME_QUERY %(agentId)
799
                    name_query=AGENT_NAME_QUERY %(agentId)
606
                    conn = getDbConnection()
800
                    conn = getDbConnection()
607
                    column=agentId
801
                    column=agentId
Line 624... Line 818...
624
                    for r in result:
818
                    for r in result:
625
                        loginTime+=r[0].seconds
819
                        loginTime+=r[0].seconds
626
                        
820
                        
627
                    hours=loginTime/3600
821
                    hours=loginTime/3600
628
                    minutesLeft=(loginTime%3600)/60
822
                    minutesLeft=(loginTime%3600)/60
629
                    worksheet.write(25+12,columnId,str(hours)+':'+str(minutesLeft))    
823
                    worksheet.write(25+11,columnId,str(hours)+':'+str(minutesLeft),center_alignment)    
630
                    conn.close()
824
                    conn.close()
631
                    
825
                    
632
                    name_query=AGENT_FOLLOW_UP_QUERY_DURATION %(agentId)
826
                    name_query=AGENT_FOLLOW_UP_QUERY_DURATION %(agentId)
633
                    conn = getDbConnection()
827
                    conn = getDbConnection()
634
                    column=agentId
828
                    column=agentId
Line 638... Line 832...
638
                    loginTime=0
832
                    loginTime=0
639
                    for r in result:
833
                    for r in result:
640
                        loginTime+=r[0]
834
                        loginTime+=r[0]
641
                    hours=loginTime/3600
835
                    hours=loginTime/3600
642
                    minutesLeft=(loginTime%3600)/60
836
                    minutesLeft=(loginTime%3600)/60
-
 
837
                    worksheet.write(25+12,columnId,str(int(hours))+':'+str(int(minutesLeft)),center_alignment)    
-
 
838
                    conn.close()
-
 
839
                    
-
 
840
                    name_query=AGENT_FOLLOW_UP_QUERY_AHT %(agentId)
-
 
841
                    conn = getDbConnection()
-
 
842
                    column=agentId
-
 
843
                    cursor = conn.cursor()
-
 
844
                    cursor.execute(name_query)
-
 
845
                    result = cursor.fetchall()
-
 
846
                    loginTime=0
-
 
847
                    for r in result:
-
 
848
                        loginTime+=r[0]
-
 
849
                    hours=loginTime/3600
-
 
850
                    minutesLeft=(loginTime%3600)/60
643
                    worksheet.write(25+13,columnId,str(int(hours))+':'+str(int(minutesLeft)))    
851
                    worksheet.write(25+13,columnId,str(int(hours))+':'+str(int(minutesLeft)),center_alignment)    
-
 
852
                    conn.close()
-
 
853
                    
-
 
854
                    name_query=AGENT_FOLLOW_UP_QUERY_AIT %(agentId)
-
 
855
                    conn = getDbConnection()
-
 
856
                    column=agentId
-
 
857
                    cursor = conn.cursor()
-
 
858
                    cursor.execute(name_query)
-
 
859
                    result = cursor.fetchall()
-
 
860
                    loginTime=0
-
 
861
                    for r in result:
-
 
862
                        loginTime+=r[0]
-
 
863
                    hours=loginTime/3600
-
 
864
                    minutesLeft=(loginTime%3600)/60
-
 
865
                    worksheet.write(25+14,columnId,str(int(hours))+':'+str(int(minutesLeft)),center_alignment)    
644
                    conn.close()
866
                    conn.close()
645
                    
867
                    
646
                agentId+=1
868
                agentId+=1
647
                columnId+=1
869
                columnId+=1
648
    workbook.save(TMP_FILE)    
870
    workbook.save(TMP_FILE)    
649
    #sendmail(["manas.kapoor@shop2020.in"], "", TMP_FILE, SUBJECT)
-
 
650
    
871
    
651
def generateOnBoardingCallingReport():
872
def generateOnBoardingCallingReport():
652
    datesql=ONBOARDING_QUERY 
873
    datesql=ONBOARDING_QUERY 
653
    conn = getDbConnection()
874
    conn = getDbConnection()
654
    
875
    
Line 686... Line 907...
686
    worksheet.write(8,column, 'Agents Logged In', style)
907
    worksheet.write(8,column, 'Agents Logged In', style)
687
    worksheet.write(9,column, 'Average Login Time (In Hrs)', style)
908
    worksheet.write(9,column, 'Average Login Time (In Hrs)', style)
688
    worksheet.write(10,column, 'Total Dialed Out', style)
909
    worksheet.write(10,column, 'Total Dialed Out', style)
689
    worksheet.write(11,column, 'Average Dialed Out per agent', style)
910
    worksheet.write(11,column, 'Average Dialed Out per agent', style)
690
    worksheet.write(12,column, 'Average Call Duration (In Hrs)', style)
911
    worksheet.write(12,column, 'Average Call Duration (In Hrs)', style)
-
 
912
    worksheet.write(13,column, 'Average Handling Time (In Hrs)', style)
-
 
913
    worksheet.write(14,column, 'Average Idle Time (In Hrs)', style)
691
    
914
    
692
    contactableData=0
915
    contactableData=0
693
    nonContactableData=0
916
    nonContactableData=0
694
    totalDispositions=0
917
    totalDispositions=0
695
    print result
-
 
696
    for r in result:
918
    for r in result:
697
        row = onBoardingDispositionMap.get(r[0])+1
919
        row = onBoardingDispositionMap.get(r[0])+1
698
        if onBoardingDispositionMap.get(r[0]) == 1 or onBoardingDispositionMap.get(r[0]) == 2 or onBoardingDispositionMap.get(r[0]) == 3:
920
        if onBoardingDispositionMap.get(r[0]) == 1 or onBoardingDispositionMap.get(r[0]) == 2 or onBoardingDispositionMap.get(r[0]) == 3:
699
            nonContactableData+=int(r[1])
921
            nonContactableData+=int(r[1])
700
        else:
922
        else:
701
            contactableData+=r[1] 
923
            contactableData+=r[1] 
702
        currentList.append(str(row))
924
        currentList.append(str(row))
703
        column = 1
925
        column = 1
704
        worksheet.write(row, column, r[1])
926
        worksheet.write(row, column, r[1],center_alignment)
705
    
927
    
706
    remainingList = list(set(onBoardingList) - set(currentList))
928
    remainingList = list(set(onBoardingList) - set(currentList))
707
    print remainingList
929
    
708
    for i,val in enumerate(remainingList):
930
    for i,val in enumerate(remainingList):
709
        row = int(val)
931
        row = int(val)
710
        print row
-
 
711
        column = 1
932
        column = 1
712
        worksheet.write(row, column, 0)
933
        worksheet.write(row, column, 0,center_alignment)
713
    totalDispositions=contactableData+nonContactableData
934
    totalDispositions=contactableData+nonContactableData
714
    worksheet.write(6,1,(contactableData/float(totalDispositions))*100)
935
    worksheet.write(6,1,round((contactableData/float(totalDispositions))*100,2),center_alignment)
715
    worksheet.write(7,1,(nonContactableData/float(totalDispositions))*100)
936
    worksheet.write(7,1,round((nonContactableData/float(totalDispositions))*100,2),center_alignment)
716
    
937
    
717
    
938
    
718
    conn.close()
939
    conn.close()
719
    datesql=ONBOARDING_QUERY_LOGIN_TIME 
940
    datesql=ONBOARDING_QUERY_LOGIN_TIME 
720
    conn = getDbConnection()
941
    conn = getDbConnection()
Line 729... Line 950...
729
        loginTime+=r[1].seconds
950
        loginTime+=r[1].seconds
730
        agentLoginList.append(str(r[0]))
951
        agentLoginList.append(str(r[0]))
731
    averageLoginTime=loginTime/len(list(set(agentLoginList)))
952
    averageLoginTime=loginTime/len(list(set(agentLoginList)))
732
    hours=averageLoginTime/3600
953
    hours=averageLoginTime/3600
733
    minutesLeft=(averageLoginTime%3600)/60
954
    minutesLeft=(averageLoginTime%3600)/60
734
    worksheet.write(8,1,len(list(set(agentLoginList))))
955
    worksheet.write(8,1,len(list(set(agentLoginList))),center_alignment)
735
    worksheet.write(9,1,str(hours) + ':'+ str(minutesLeft))   
956
    worksheet.write(9,1,str(hours) + ':'+ str(minutesLeft),center_alignment)   
736
    worksheet.write(10,1,totalDispositions)
957
    worksheet.write(10,1,totalDispositions,center_alignment)
737
    worksheet.write(11,1,(contactableData+nonContactableData)/len(list(set(agentLoginList))))
958
    worksheet.write(11,1,(contactableData+nonContactableData)/len(list(set(agentLoginList))),center_alignment)
738
    conn.close()
959
    conn.close()
739
    datesql=ONBOARDING_QUERY_DURATION
960
    datesql=ONBOARDING_QUERY_DURATION
740
    conn = getDbConnection()
961
    conn = getDbConnection()
741
    
962
    
742
    cursor = conn.cursor()
963
    cursor = conn.cursor()
Line 745... Line 966...
745
    for r in result:
966
    for r in result:
746
        totalCallDuration= r[0]
967
        totalCallDuration= r[0]
747
    averageCallDuration=totalCallDuration/len(list(set(agentLoginList)))    
968
    averageCallDuration=totalCallDuration/len(list(set(agentLoginList)))    
748
    hours=averageCallDuration/3600
969
    hours=averageCallDuration/3600
749
    minutesLeft=(averageCallDuration%3600)/60    
970
    minutesLeft=(averageCallDuration%3600)/60    
750
    worksheet.write(12,1,str(int(hours))+':'+str(int(minutesLeft)))
971
    worksheet.write(12,1,str(int(hours))+':'+str(int(minutesLeft)),center_alignment)
-
 
972
    
-
 
973
    conn.close()
-
 
974
    datesql=ONBOARDING_QUERY_AHT
-
 
975
    conn = getDbConnection()
-
 
976
    
-
 
977
    cursor = conn.cursor()
-
 
978
    cursor.execute(datesql)
-
 
979
    result = cursor.fetchall()
-
 
980
    for r in result:
-
 
981
        totalCallDuration= r[0]
-
 
982
    averageCallDuration=totalCallDuration/len(list(set(agentLoginList)))    
-
 
983
    hours=averageCallDuration/3600
-
 
984
    minutesLeft=(averageCallDuration%3600)/60    
-
 
985
    worksheet.write(13,1,str(int(hours))+':'+str(int(minutesLeft)),center_alignment)
-
 
986
    conn.close()
-
 
987
    datesql=ONBOARDING_QUERY_AIT
-
 
988
    conn = getDbConnection()
-
 
989
    
-
 
990
    cursor = conn.cursor()
-
 
991
    cursor.execute(datesql)
-
 
992
    result = cursor.fetchall()
-
 
993
    for r in result:
-
 
994
        totalCallDuration= r[0]
-
 
995
    averageCallDuration=totalCallDuration/len(list(set(agentLoginList)))
-
 
996
    hours=averageCallDuration/3600
-
 
997
    minutesLeft=(averageCallDuration%3600)/60    
-
 
998
    worksheet.write(14,1,str(int(hours))+':'+str(int(minutesLeft)),center_alignment)
751
    workbook.save(TMP_FILE)
999
    workbook.save(TMP_FILE)
-
 
1000
    
752
    #sendmail(["manas.kapoor@shop2020.in"], "", TMP_FILE, SUBJECT)        
1001
    #sendmail(["manas.kapoor@shop2020.in"], "", TMP_FILE, SUBJECT)        
753
 
1002
 
754
 
1003
 
755
def generateAgentWiseOnboardingCallingReport():
1004
def generateAgentWiseOnboardingCallingReport():
756
    
1005
    
757
    agentId=3
1006
    agentId=3
758
    rb = open_workbook(TMP_FILE,formatting_info=True)
1007
    rb = open_workbook(TMP_FILE,formatting_info=True)
759
    workbook = copy(rb)
1008
    workbook = copy(rb)
760
    numberOfSheets=rb.nsheets
1009
    numberOfSheets=rb.nsheets
761
    print 'Number of sheets ' + str(numberOfSheets)
1010
    
762
    sheet=rb.sheet_by_index(numberOfSheets-1)
1011
    sheet=rb.sheet_by_index(numberOfSheets-1)
763
    worksheet = workbook.get_sheet(numberOfSheets-1)
1012
    worksheet = workbook.get_sheet(numberOfSheets-1)
764
    boldStyle = xlwt.XFStyle()
1013
    boldStyle = xlwt.XFStyle()
765
    newStyle= xlwt.XFStyle()
1014
    newStyle= xlwt.XFStyle()
766
    style = xlwt.XFStyle()
1015
    style = xlwt.XFStyle()
Line 784... Line 1033...
784
    worksheet.write(row+6,column-1, 'Contactable Data', newStyle)
1033
    worksheet.write(row+6,column-1, 'Contactable Data', newStyle)
785
    worksheet.write(row+7,column-1, 'Non Contactable Data', newStyle)
1034
    worksheet.write(row+7,column-1, 'Non Contactable Data', newStyle)
786
    worksheet.write(row+8,column-1, 'Total Dialed Out', style)
1035
    worksheet.write(row+8,column-1, 'Total Dialed Out', style)
787
    worksheet.write(row+9,column-1, 'Login Time (In Hrs)', style)
1036
    worksheet.write(row+9,column-1, 'Login Time (In Hrs)', style)
788
    worksheet.write(row+10,column-1, 'Call Duration (In Hrs)', style)
1037
    worksheet.write(row+10,column-1, 'Call Duration (In Hrs)', style)
789
    
-
 
-
 
1038
    worksheet.write(row+11,column-1, 'Handling Time (In Hrs)', style)
-
 
1039
    worksheet.write(row+12,column-1, 'Idle Time (In Hrs)', style)
790
    columnId=agentId
1040
    columnId=agentId
791
    while True:
1041
    while True:
792
            if agentId >5 :
1042
            if agentId >6 :
793
                break
1043
                break
794
            else: 
1044
            else: 
795
                datesql=AGENT_ONBOARDING_QUERY %(agentId)
1045
                datesql=AGENT_ONBOARDING_QUERY %(agentId)
796
                conn = getDbConnection()
1046
                conn = getDbConnection()
797
                
1047
                
Line 804... Line 1054...
804
                nonContactableData=0
1054
                nonContactableData=0
805
                if cursor.rowcount ==0:
1055
                if cursor.rowcount ==0:
806
                    agentId+=1
1056
                    agentId+=1
807
                    continue    
1057
                    continue    
808
                else:
1058
                else:
809
                    print result
1059
                    
810
                    for r in result:
1060
                    for r in result:
811
                        row = onBoardingDispositionMap.get(r[0])+26
1061
                        row = onBoardingDispositionMap.get(r[0])+26
812
                        if onBoardingDispositionMap.get(r[0]) == 1 or onBoardingDispositionMap.get(r[0]) == 2 or onBoardingDispositionMap.get(r[0]) == 3 or followUpDispositionMap.get(r[0]) == 4:
1062
                        if onBoardingDispositionMap.get(r[0]) == 1 or onBoardingDispositionMap.get(r[0]) == 2 or onBoardingDispositionMap.get(r[0]) == 3 or followUpDispositionMap.get(r[0]) == 4:
813
                            nonContactableData+=int(r[1])
1063
                            nonContactableData+=int(r[1])
814
                        else:
1064
                        else:
815
                            contactableData+=r[1] 
1065
                            contactableData+=r[1] 
816
                        currentList.append(str(onBoardingDispositionMap.get(r[0])+1))
1066
                        currentList.append(str(onBoardingDispositionMap.get(r[0])+1))
817
                        column = agentId
1067
                        column = agentId
818
                        worksheet.write(row, columnId, r[1])
1068
                        worksheet.write(row, columnId, r[1],center_alignment)
819
                    remainingList = list(set(onBoardingList) - set(currentList))
1069
                    remainingList = list(set(onBoardingList) - set(currentList))
820
                    
1070
                    
821
                    for i,val in enumerate(remainingList):
1071
                    for i,val in enumerate(remainingList):
822
                        row = int(val)+25
1072
                        row = int(val)+25
823
                        column = agentId
1073
                        column = agentId
824
                        worksheet.write(row, columnId, 0)
1074
                        worksheet.write(row, columnId, 0,center_alignment)
825
                    totalDialedOut = contactableData+nonContactableData
1075
                    totalDialedOut = contactableData+nonContactableData
826
                    worksheet.write(25+6,columnId,(contactableData/float(totalDialedOut))*100)
1076
                    worksheet.write(25+6,columnId,round((contactableData/float(totalDialedOut))*100,2),center_alignment)
827
                    worksheet.write(25+7,columnId,(nonContactableData/float(totalDialedOut))*100)
1077
                    worksheet.write(25+7,columnId,round((nonContactableData/float(totalDialedOut))*100,2),center_alignment)
828
                    worksheet.write(25+8,columnId,totalDialedOut)
1078
                    worksheet.write(25+8,columnId,totalDialedOut,center_alignment)
829
                    conn.close()
1079
                    conn.close()
830
                
1080
                
831
                    name_query=AGENT_NAME_QUERY %(agentId)
1081
                    name_query=AGENT_NAME_QUERY %(agentId)
832
                    conn = getDbConnection()
1082
                    conn = getDbConnection()
833
                    column=agentId
1083
                    column=agentId
834
                    cursor = conn.cursor()
1084
                    cursor = conn.cursor()
835
                    cursor.execute(name_query)
1085
                    cursor.execute(name_query)
836
                    result = cursor.fetchall()
1086
                    result = cursor.fetchall()
837
                    for r in result:
1087
                    for r in result:
838
                        worksheet.write(25,columnId,r,style)
1088
                        worksheet.write(25,columnId,r,style)
839
                    
-
 
840
                    conn.close()
1089
                    conn.close()
841
                
1090
                
842
                
1091
                
843
                    name_query=ONBOARDING_QUERY_LOGIN_TIME %(agentId)
1092
                    name_query=AGENT_ONBOARDING_QUERY_LOGIN_TIME %(agentId)
844
                    conn = getDbConnection()
1093
                    conn = getDbConnection()
845
                    column=agentId
1094
                    column=agentId
846
                    cursor = conn.cursor()
1095
                    cursor = conn.cursor()
847
                    cursor.execute(name_query)
1096
                    cursor.execute(name_query)
848
                    result = cursor.fetchall()
1097
                    result = cursor.fetchall()
Line 850... Line 1099...
850
                    for r in result:
1099
                    for r in result:
851
                        loginTime+=r[0].seconds
1100
                        loginTime+=r[0].seconds
852
                        
1101
                        
853
                    hours=loginTime/3600
1102
                    hours=loginTime/3600
854
                    minutesLeft=(loginTime%3600)/60
1103
                    minutesLeft=(loginTime%3600)/60
855
                    worksheet.write(25+9,columnId,str(hours)+':'+str(minutesLeft))    
1104
                    worksheet.write(25+9,columnId,str(hours)+':'+str(minutesLeft),center_alignment)    
-
 
1105
                    conn.close()
-
 
1106
                    
-
 
1107
                    name_query=AGENT_ONBOARDING_QUERY_DURATION %(agentId)
-
 
1108
                    conn = getDbConnection()
-
 
1109
                    column=agentId
-
 
1110
                    cursor = conn.cursor()
-
 
1111
                    cursor.execute(name_query)
-
 
1112
                    result = cursor.fetchall()
-
 
1113
                    loginTime=0
-
 
1114
                    for r in result:
-
 
1115
                        loginTime+=r[0]
-
 
1116
                    hours=loginTime/3600
-
 
1117
                    minutesLeft=(loginTime%3600)/60
-
 
1118
                    worksheet.write(25+10,columnId,str(int(hours))+':'+str(int(minutesLeft)),center_alignment)    
856
                    conn.close()
1119
                    conn.close()
857
                    
1120
                    
858
                    name_query=ONBOARDING_QUERY_DURATION %(agentId)
1121
                    name_query=AGENT_ONBOARDING_QUERY_AHT %(agentId)
859
                    conn = getDbConnection()
1122
                    conn = getDbConnection()
860
                    column=agentId
1123
                    column=agentId
861
                    cursor = conn.cursor()
1124
                    cursor = conn.cursor()
862
                    cursor.execute(name_query)
1125
                    cursor.execute(name_query)
863
                    result = cursor.fetchall()
1126
                    result = cursor.fetchall()
864
                    loginTime=0
1127
                    loginTime=0
865
                    for r in result:
1128
                    for r in result:
866
                        loginTime+=r[0]
1129
                        loginTime+=r[0]
867
                    hours=loginTime/3600
1130
                    hours=loginTime/3600
868
                    minutesLeft=(loginTime%3600)/60
1131
                    minutesLeft=(loginTime%3600)/60
869
                    worksheet.write(25+10,columnId,str(int(hours))+':'+str(int(minutesLeft)))    
1132
                    worksheet.write(25+11,columnId,str(int(hours))+':'+str(int(minutesLeft)),center_alignment)    
-
 
1133
                    conn.close()
-
 
1134
                    
-
 
1135
                    name_query=AGENT_ONBOARDING_QUERY_AIT %(agentId)
-
 
1136
                    conn = getDbConnection()
-
 
1137
                    column=agentId
-
 
1138
                    cursor = conn.cursor()
-
 
1139
                    cursor.execute(name_query)
-
 
1140
                    result = cursor.fetchall()
-
 
1141
                    loginTime=0
-
 
1142
                    for r in result:
-
 
1143
                        loginTime+=r[0]
-
 
1144
                    hours=loginTime/3600
-
 
1145
                    minutesLeft=(loginTime%3600)/60
-
 
1146
                    worksheet.write(25+12,columnId,str(int(hours))+':'+str(int(minutesLeft)),center_alignment)    
870
                    conn.close()
1147
                    conn.close()
871
                    
1148
                    
872
                agentId+=1
1149
                agentId+=1
873
                columnId+=1
1150
                columnId+=1
874
    workbook.save(TMP_FILE)          
1151
    workbook.save(TMP_FILE)          
Line 880... Line 1157...
880
    generateAgentWiseFreshCallingReport()
1157
    generateAgentWiseFreshCallingReport()
881
    generateFollowUpCallingReport()
1158
    generateFollowUpCallingReport()
882
    generateAgentWiseFollowupCallingReport()
1159
    generateAgentWiseFollowupCallingReport()
883
    generateOnBoardingCallingReport()
1160
    generateOnBoardingCallingReport()
884
    generateAgentWiseOnboardingCallingReport()
1161
    generateAgentWiseOnboardingCallingReport()
-
 
1162
    sendmail(["manas.kapoor@shop2020.in,amit.sirohi@shop2020.in"], "", TMP_FILE, SUBJECT)
885
 
1163
         
886
def sendmail(email, message, fileName, title):
1164
def sendmail(email, message, fileName, title):
887
    if email == "":
1165
    if email == "":
888
        return
1166
        return
889
    mailServer = smtplib.SMTP(SMTP_SERVER, SMTP_PORT)
1167
    mailServer = smtplib.SMTP(SMTP_SERVER, SMTP_PORT)
890
    mailServer.ehlo()
1168
    mailServer.ehlo()
Line 901... Line 1179...
901
    fileMsg = MIMEBase('application', 'vnd.ms-excel')
1179
    fileMsg = MIMEBase('application', 'vnd.ms-excel')
902
    fileMsg.set_payload(file(TMP_FILE).read())
1180
    fileMsg.set_payload(file(TMP_FILE).read())
903
    encoders.encode_base64(fileMsg)
1181
    encoders.encode_base64(fileMsg)
904
    fileMsg.add_header('Content-Disposition', 'attachment;filename=' + fileName)
1182
    fileMsg.add_header('Content-Disposition', 'attachment;filename=' + fileName)
905
    msg.attach(fileMsg)
1183
    msg.attach(fileMsg)
906
    print 'Sending report'
1184
    
907
    #MAILTO = ['manas.kapoor@saholic.com','rajneesh.arora@saholic.com']
1185
    MAILTO = ['manas.kapoor@saholic.com','amit.sirohi@shop2020.in']
908
    MAILTO = ['manas.kapoor@saholic.com']
1186
    #MAILTO = ['manas.kapoor@saholic.com']
909
    mailServer.login(SENDER, PASSWORD)
1187
    mailServer.login(SENDER, PASSWORD)
910
    mailServer.sendmail(PASSWORD, MAILTO, msg.as_string())
1188
    mailServer.sendmail(PASSWORD, MAILTO, msg.as_string())
911
 
1189
 
912
if __name__ == '__main__':
1190
if __name__ == '__main__':
913
    main()
1191
    main()