| Line 337... |
Line 337... |
| 337 |
worksheet.write(17,column, 'Total Dialed Out', style)
|
337 |
worksheet.write(17,column, 'Total Dialed Out', style)
|
| 338 |
worksheet.write(18,column, 'Average Dialed Out per agent', style)
|
338 |
worksheet.write(18,column, 'Average Dialed Out per agent', style)
|
| 339 |
|
339 |
|
| 340 |
contactableData=0
|
340 |
contactableData=0
|
| 341 |
nonContactableData=0
|
341 |
nonContactableData=0
|
| 342 |
|
342 |
global ACCS_CART_WILL_PLACE_ORDER
|
| 343 |
for r in result:
|
343 |
for r in result:
|
| 344 |
row = accsDispositionMap.get(r[0])
|
344 |
row = accsDispositionMap.get(r[0])
|
| 345 |
if accsDispositionMap.get(r[0]) == 2 or accsDispositionMap.get(r[0]) == 3 or accsDispositionMap.get(r[0]) == 4:
|
345 |
if accsDispositionMap.get(r[0]) == 2 or accsDispositionMap.get(r[0]) == 3 or accsDispositionMap.get(r[0]) == 4:
|
| 346 |
nonContactableData+=int(r[1])
|
346 |
nonContactableData+=int(r[1])
|
| 347 |
else:
|
347 |
else:
|
| - |
|
348 |
if accsDispositionMap.get(r[0])==12:
|
| - |
|
349 |
ACCS_CART_WILL_PLACE_ORDER = r[1]
|
| 348 |
contactableData+=r[1]
|
350 |
contactableData+=r[1]
|
| 349 |
currentList.append(str(row))
|
351 |
currentList.append(str(row))
|
| 350 |
column = 1
|
352 |
column = 1
|
| 351 |
worksheet.write(row, column, r[1],center_alignment)
|
353 |
worksheet.write(row, column, r[1],center_alignment)
|
| 352 |
|
354 |
|
| Line 354... |
Line 356... |
| 354 |
for i,val in enumerate(remainingList):
|
356 |
for i,val in enumerate(remainingList):
|
| 355 |
row = int(val)
|
357 |
row = int(val)
|
| 356 |
column = 1
|
358 |
column = 1
|
| 357 |
worksheet.write(row, column, 0,center_alignment)
|
359 |
worksheet.write(row, column, 0,center_alignment)
|
| 358 |
totalDispositions=contactableData+nonContactableData
|
360 |
totalDispositions=contactableData+nonContactableData
|
| 359 |
|
361 |
global ACCS_CART_TOTAL
|
| - |
|
362 |
global ACCS_CART_SUCCESSFUL
|
| - |
|
363 |
ACCS_CART_TOTAL = totalDispositions
|
| - |
|
364 |
ACCS_CART_SUCCESSFUL=contactableData
|
| 360 |
if totalDispositions > 0:
|
365 |
if totalDispositions > 0:
|
| 361 |
worksheet.write(13,1,round((contactableData/float(totalDispositions))*100,2),center_alignment)
|
366 |
worksheet.write(13,1,round((contactableData/float(totalDispositions))*100,2),center_alignment)
|
| 362 |
worksheet.write(14,1,round((nonContactableData/float(totalDispositions))*100,2),center_alignment)
|
367 |
worksheet.write(14,1,round((nonContactableData/float(totalDispositions))*100,2),center_alignment)
|
| 363 |
|
368 |
|
| 364 |
conn.close()
|
369 |
conn.close()
|
| Line 370... |
Line 375... |
| 370 |
result = cursor.fetchall()
|
375 |
result = cursor.fetchall()
|
| 371 |
agentLoginList=[]
|
376 |
agentLoginList=[]
|
| 372 |
for r in result:
|
377 |
for r in result:
|
| 373 |
agentLoginList.append(str(r[0]))
|
378 |
agentLoginList.append(str(r[0]))
|
| 374 |
conn.close()
|
379 |
conn.close()
|
| 375 |
|
- |
|
| - |
|
380 |
global ACCS_CART_LOGIN
|
| - |
|
381 |
ACCS_CART_LOGIN = len(list(set(agentLoginList)))
|
| 376 |
if len(list(set(agentLoginList))) > 0:
|
382 |
if len(list(set(agentLoginList))) > 0:
|
| 377 |
datesql=ACCS_CART_QUERY_LOGIN_TIME
|
383 |
datesql=ACCS_CART_QUERY_LOGIN_TIME
|
| 378 |
conn = getDbConnection()
|
384 |
conn = getDbConnection()
|
| 379 |
cursor = conn.cursor()
|
385 |
cursor = conn.cursor()
|
| 380 |
cursor.execute(datesql)
|
386 |
cursor.execute(datesql)
|
| Line 1450... |
Line 1456... |
| 1450 |
m.addRecipient(receipient)
|
1456 |
m.addRecipient(receipient)
|
| 1451 |
m.setSubject(title)
|
1457 |
m.setSubject(title)
|
| 1452 |
m.setHtmlBody(message+"<br>"+message1+"<br>"+message2)
|
1458 |
m.setHtmlBody(message+"<br>"+message1+"<br>"+message2)
|
| 1453 |
m.send()
|
1459 |
m.send()
|
| 1454 |
|
1460 |
|
| - |
|
1461 |
def getAccsCartHtml():
|
| - |
|
1462 |
heading = "Accessories Cart Users(Project 1)"
|
| - |
|
1463 |
message="No. of Agents " + str(ACCS_CART_LOGIN)
|
| - |
|
1464 |
message1="Total Calls attempted " + str(ACCS_CART_TOTAL)
|
| - |
|
1465 |
message2="Total Successful calls " + str(ACCS_CART_SUCCESSFUL)
|
| - |
|
1466 |
message3="Will Order "+ str(ACCS_CART_WILL_PLACE_ORDER)
|
| - |
|
1467 |
message4="Will Order % " +str(round((ACCS_CART_WILL_PLACE_ORDER/float(ACCS_CART_TOTAL))*100,2))
|
| - |
|
1468 |
return "<u>" + heading + "</u><br>" +message+"<br>"+message1+"<br>"+message2+"<br>"+message3+"<br>"+message4+"<br>"
|
| - |
|
1469 |
|
| - |
|
1470 |
def getAccsCartOrders():
|
| - |
|
1471 |
datesql = "select count(distinct order_id),sum(quantity),sum(amount_paid) from allorder where category='Accs' and date(created_on)>=date(now() - interval 7 day) and user_id in (select user_id from usercrmcallingdata where project_id=1);"
|
| - |
|
1472 |
conn = getDbConnection()
|
| - |
|
1473 |
cursor = conn.cursor()
|
| - |
|
1474 |
cursor.execute(datesql)
|
| - |
|
1475 |
result = cursor.fetchall()
|
| - |
|
1476 |
inputs = "No of users who placed orders within 7 days of successful calling<br>" + "Total Orders " + str(result[0][0]) + "<br>Total Quantity " + str(result[0][1]) + "<br>Total Value " + str(result[0][2]) + "<br>"
|
| - |
|
1477 |
conn.close()
|
| - |
|
1478 |
return inputs
|
| 1455 |
|
1479 |
|
| - |
|
1480 |
def getAccsCartProductPricingInput():
|
| - |
|
1481 |
datesql = "select product_input,pricing_input from productpricinginputs where date(created)=date(now()) and project_id=1 and product_input not like '';"
|
| - |
|
1482 |
conn = getDbConnection()
|
| - |
|
1483 |
cursor = conn.cursor()
|
| - |
|
1484 |
cursor.execute(datesql)
|
| - |
|
1485 |
result = cursor.fetchall()
|
| - |
|
1486 |
inputs="Product Pricing Inputs"
|
| - |
|
1487 |
for r in result:
|
| - |
|
1488 |
inputs = inputs + "<br>" + r[0] + "-----" + str(r[1])
|
| - |
|
1489 |
conn.close()
|
| - |
|
1490 |
return inputs
|
| - |
|
1491 |
|
| 1456 |
def sendmailretention(email, message, fileName, title):
|
1492 |
def sendmailretention(email, message, fileName, title):
|
| 1457 |
if email == "":
|
1493 |
if email == "":
|
| 1458 |
return
|
1494 |
return
|
| 1459 |
mailServer = smtplib.SMTP(SMTP_SERVER, SMTP_PORT)
|
1495 |
mailServer = smtplib.SMTP(SMTP_SERVER, SMTP_PORT)
|
| 1460 |
mailServer.ehlo()
|
1496 |
mailServer.ehlo()
|
| Line 1464... |
Line 1500... |
| 1464 |
# Create the container (outer) email message.
|
1500 |
# Create the container (outer) email message.
|
| 1465 |
msg = MIMEMultipart()
|
1501 |
msg = MIMEMultipart()
|
| 1466 |
msg['Subject'] = title
|
1502 |
msg['Subject'] = title
|
| 1467 |
msg.preamble = title
|
1503 |
msg.preamble = title
|
| 1468 |
|
1504 |
|
| - |
|
1505 |
msg.attach(MIMEText(getAccsCartHtml(), 'html'))
|
| - |
|
1506 |
msg.attach(MIMEText(getAccsCartOrders(),'html'))
|
| - |
|
1507 |
msg.attach(MIMEText(getAccsCartProductPricingInput(),'html'))
|
| - |
|
1508 |
|
| 1469 |
fileMsg = MIMEBase('application', 'vnd.ms-excel')
|
1509 |
fileMsg = MIMEBase('application', 'vnd.ms-excel')
|
| 1470 |
fileMsg.set_payload(file(RET_FILE).read())
|
1510 |
fileMsg.set_payload(file(RET_FILE).read())
|
| 1471 |
encoders.encode_base64(fileMsg)
|
1511 |
encoders.encode_base64(fileMsg)
|
| 1472 |
fileMsg.add_header('Content-Disposition', 'attachment;filename=' + fileName)
|
1512 |
fileMsg.add_header('Content-Disposition', 'attachment;filename=' + fileName)
|
| 1473 |
msg.attach(fileMsg)
|
1513 |
msg.attach(fileMsg)
|