| Line 52... |
Line 52... |
| 52 |
default_format = xlwt.XFStyle()
|
52 |
default_format = xlwt.XFStyle()
|
| 53 |
freshList=['1','2','3','4','5','6','7','8','9','10','11','12','13']
|
53 |
freshList=['1','2','3','4','5','6','7','8','9','10','11','12','13']
|
| 54 |
followUpList=['1','2','3','4','5','6','7','8','9','10']
|
54 |
followUpList=['1','2','3','4','5','6','7','8','9','10']
|
| 55 |
onBoardingList=['1','2','3','4','5']
|
55 |
onBoardingList=['1','2','3','4','5']
|
| 56 |
accsList=['1','2','3','4','5','6','7','8','9','10','11','12']
|
56 |
accsList=['1','2','3','4','5','6','7','8','9','10','11','12']
|
| - |
|
57 |
accsOrdersList=['1','2','3','4','5','6','7','8','9','10','11','12','13','14']
|
| 57 |
dispositionMap = { 'call_later':0,
|
58 |
dispositionMap = { 'call_later':0,
|
| 58 |
'ringing_no_answer':1,
|
59 |
'ringing_no_answer':1,
|
| 59 |
'not_reachable':2,
|
60 |
'not_reachable':2,
|
| 60 |
'switch_off':3,
|
61 |
'switch_off':3,
|
| 61 |
'invalid_no':4,
|
62 |
'invalid_no':4,
|
| Line 100... |
Line 101... |
| 100 |
'checking_price':9,
|
101 |
'checking_price':9,
|
| 101 |
'order_process':10,
|
102 |
'order_process':10,
|
| 102 |
'placed_order':11,
|
103 |
'placed_order':11,
|
| 103 |
'place_order':12
|
104 |
'place_order':12
|
| 104 |
}
|
105 |
}
|
| - |
|
106 |
|
| - |
|
107 |
accsDispositionOrdersMap = { 'call_later':1,
|
| - |
|
108 |
'ringing_no_answer':2,
|
| - |
|
109 |
'not_reachable':3,
|
| - |
|
110 |
'switch_off':4,
|
| - |
|
111 |
'technical_issue':5,
|
| - |
|
112 |
'pricing_issue':6,
|
| - |
|
113 |
'shipping_issue':7,
|
| - |
|
114 |
'already_purchased':8,
|
| - |
|
115 |
'product_availability':9,
|
| - |
|
116 |
'return_replacement':10,
|
| - |
|
117 |
'product_quality_issue':11,
|
| - |
|
118 |
'delayed_delivery':12,
|
| - |
|
119 |
'other_complaint':13,
|
| - |
|
120 |
'not_dealing_accessories':14
|
| - |
|
121 |
}
|
| 105 |
# FRESH_QUERY="""
|
122 |
# FRESH_QUERY="""
|
| 106 |
# select call_disposition,count(1) from
|
123 |
# select call_disposition,count(1) from
|
| 107 |
# (select * from (select * from callhistory where date(created)=date(now())
|
124 |
# (select * from (select * from callhistory where date(created)=date(now())
|
| 108 |
# and call_type ='fresh' order by created desc)
|
125 |
# and call_type ='fresh' order by created desc)
|
| 109 |
# as a group by retailer_id)
|
126 |
# as a group by retailer_id)
|
| Line 312... |
Line 329... |
| 312 |
ACCS_TAB_PRODUCT_PRICING="""
|
329 |
ACCS_TAB_PRODUCT_PRICING="""
|
| 313 |
select user_id,call_disposition,product_input,pricing_input from productpricinginputs where
|
330 |
select user_id,call_disposition,product_input,pricing_input from productpricinginputs where
|
| 314 |
date(created)=date(now() - interval 1 day) and product_input not like '' and project_id=2;
|
331 |
date(created)=date(now() - interval 1 day) and product_input not like '' and project_id=2;
|
| 315 |
"""
|
332 |
"""
|
| 316 |
|
333 |
|
| - |
|
334 |
ACCS_ORDER_QUERY="""
|
| - |
|
335 |
select call_disposition,count(1) from
|
| - |
|
336 |
(select * from (select * from callhistorycrm where date(created)=date(now()- interval 1 day)
|
| - |
|
337 |
and project_id=3 order by created desc)
|
| - |
|
338 |
as a group by user_id)
|
| - |
|
339 |
a1 group by date(created), call_disposition;
|
| - |
|
340 |
"""
|
| - |
|
341 |
|
| - |
|
342 |
ACCS_ORDER_AGENTS_CALLED_COUNT="""
|
| - |
|
343 |
select distinct(agent_id) from callhistorycrm where project_id=3 and date(created) = date(now() - interval 1 day)
|
| - |
|
344 |
"""
|
| - |
|
345 |
|
| - |
|
346 |
ACCS_ORDER_QUERY_LOGIN_TIME="""
|
| - |
|
347 |
select agent_id,TIMEDIFF(logoutTime,loginTime) from agentlogintimings where role='accs_order' and date(created)=date(now() - interval 1 day);
|
| - |
|
348 |
"""
|
| - |
|
349 |
|
| - |
|
350 |
ACCS_ORDER_DISPOSITION_DESCRIPTION="""
|
| - |
|
351 |
select user_id,call_disposition,disposition_description,disposition_comments
|
| - |
|
352 |
from callhistorycrm where call_disposition not in ('ringing_no_answer','not_reachable','switch_off','call_later')
|
| - |
|
353 |
and date(created)=date(now() - interval 1 day) and project_id=3"""
|
| - |
|
354 |
|
| - |
|
355 |
ACCS_ORDER_PRODUCT_PRICING="""
|
| - |
|
356 |
select user_id,call_disposition,product_input,pricing_input from productpricinginputs where
|
| - |
|
357 |
date(created)=date(now() - interval 1 day) and product_input not like '' and project_id=3;
|
| - |
|
358 |
"""
|
| - |
|
359 |
|
| 317 |
def getDbConnection():
|
360 |
def getDbConnection():
|
| 318 |
return MySQLdb.connect(DB_HOST, DB_USER, DB_PASSWORD, DB_NAME)
|
361 |
return MySQLdb.connect(DB_HOST, DB_USER, DB_PASSWORD, DB_NAME)
|
| 319 |
|
362 |
|
| 320 |
def generateAccessoriesCartReport():
|
363 |
def generateAccessoriesCartReport():
|
| 321 |
datesql=ACCS_CART_QUERY
|
364 |
datesql=ACCS_CART_QUERY
|
| Line 605... |
Line 648... |
| 605 |
for data in r:
|
648 |
for data in r:
|
| 606 |
worksheet.write(row,column,data)
|
649 |
worksheet.write(row,column,data)
|
| 607 |
column+=1
|
650 |
column+=1
|
| 608 |
|
651 |
|
| 609 |
newWorkbook.save(RET_FILE)
|
652 |
newWorkbook.save(RET_FILE)
|
| - |
|
653 |
|
| - |
|
654 |
def generateAccessoriesOrderReport():
|
| - |
|
655 |
datesql=ACCS_ORDER_QUERY
|
| - |
|
656 |
conn = getDbConnection()
|
| - |
|
657 |
|
| - |
|
658 |
cursor = conn.cursor()
|
| - |
|
659 |
cursor.execute(datesql)
|
| - |
|
660 |
result = cursor.fetchall()
|
| - |
|
661 |
rb = open_workbook(RET_FILE,formatting_info=True)
|
| - |
|
662 |
newWorkbook = copy(rb)
|
| 610 |
|
663 |
|
| - |
|
664 |
worksheet = newWorkbook.add_sheet("Accessories Order")
|
| - |
|
665 |
boldStyle = xlwt.XFStyle()
|
| - |
|
666 |
newStyle= xlwt.XFStyle()
|
| - |
|
667 |
style = xlwt.XFStyle()
|
| - |
|
668 |
pattern = xlwt.Pattern()
|
| - |
|
669 |
pattern.pattern = xlwt.Pattern.SOLID_PATTERN
|
| - |
|
670 |
pattern.pattern_fore_colour = xlwt.Style.colour_map['yellow']
|
| - |
|
671 |
style.pattern = pattern
|
| - |
|
672 |
f = xlwt.Font()
|
| - |
|
673 |
f.bold = True
|
| - |
|
674 |
boldStyle.font = f
|
| - |
|
675 |
|
| - |
|
676 |
column = 0
|
| - |
|
677 |
row = 0
|
| - |
|
678 |
currentList=[]
|
| - |
|
679 |
|
| - |
|
680 |
worksheet.write(0,0,'Call Disposition Type',style)
|
| - |
|
681 |
worksheet.write(0,1,'Count',style)
|
| - |
|
682 |
worksheet.write(1, column, 'Call Later', newStyle)
|
| - |
|
683 |
worksheet.write(2,column, 'Ringing No Answer', newStyle)
|
| - |
|
684 |
worksheet.write(3,column, 'Not Reachable', newStyle)
|
| - |
|
685 |
worksheet.write(4,column, 'Switched Off', newStyle)
|
| - |
|
686 |
worksheet.write(5,column, 'Technical Issue', newStyle)
|
| - |
|
687 |
worksheet.write(6,column, 'Pricing Issue', newStyle)
|
| - |
|
688 |
worksheet.write(7,column, 'Shipping Issue', newStyle)
|
| - |
|
689 |
worksheet.write(8,column, 'Already purchased required stock', newStyle)
|
| - |
|
690 |
worksheet.write(9,column, 'Product Not available', newStyle)
|
| - |
|
691 |
worksheet.write(10,column, 'Return or replacement pending', newStyle)
|
| - |
|
692 |
worksheet.write(11,column, 'Product Quality issue', newStyle)
|
| - |
|
693 |
worksheet.write(12,column, 'Delayed delivery', newStyle)
|
| - |
|
694 |
worksheet.write(13,column, 'Other complaint with Profitmandi', newStyle)
|
| - |
|
695 |
worksheet.write(14,column, 'Not Dealing in Accessories/Not Interested', newStyle)
|
| - |
|
696 |
worksheet.write(15,column, 'Contactable Data (%)', newStyle)
|
| - |
|
697 |
worksheet.write(16,column, 'Non Contactable Data (%)', newStyle)
|
| - |
|
698 |
worksheet.write(17,column, 'Agents Logged In', style)
|
| - |
|
699 |
worksheet.write(18,column, 'Average Login Time (In Hrs)', style)
|
| - |
|
700 |
worksheet.write(19,column, 'Total Dialed Out', style)
|
| - |
|
701 |
worksheet.write(20,column, 'Average Dialed Out per agent', style)
|
| - |
|
702 |
|
| - |
|
703 |
contactableData=0
|
| - |
|
704 |
nonContactableData=0
|
| - |
|
705 |
for r in result:
|
| - |
|
706 |
row = accsDispositionOrdersMap.get(r[0])
|
| - |
|
707 |
if accsDispositionOrdersMap.get(r[0]) == 2 or accsDispositionOrdersMap.get(r[0]) == 3 or accsDispositionOrdersMap.get(r[0]) == 4:
|
| - |
|
708 |
nonContactableData+=int(r[1])
|
| - |
|
709 |
else:
|
| - |
|
710 |
contactableData+=r[1]
|
| - |
|
711 |
currentList.append(str(row))
|
| - |
|
712 |
column = 1
|
| - |
|
713 |
worksheet.write(row, column, r[1],center_alignment)
|
| - |
|
714 |
|
| - |
|
715 |
remainingList = list(set(accsOrdersList) - set(currentList))
|
| - |
|
716 |
for i,val in enumerate(remainingList):
|
| - |
|
717 |
row = int(val)
|
| - |
|
718 |
column = 1
|
| - |
|
719 |
worksheet.write(row, column, 0,center_alignment)
|
| - |
|
720 |
totalDispositions=contactableData+nonContactableData
|
| - |
|
721 |
global ACCS_ORDER_TOTAL
|
| - |
|
722 |
global ACCS_ORDER_SUCCESSFUL
|
| - |
|
723 |
ACCS_ORDER_TOTAL = totalDispositions
|
| - |
|
724 |
ACCS_ORDER_SUCCESSFUL=contactableData
|
| - |
|
725 |
if totalDispositions > 0:
|
| - |
|
726 |
worksheet.write(15,1,round((contactableData/float(totalDispositions))*100,2),center_alignment)
|
| - |
|
727 |
worksheet.write(16,1,round((nonContactableData/float(totalDispositions))*100,2),center_alignment)
|
| - |
|
728 |
|
| - |
|
729 |
conn.close()
|
| - |
|
730 |
|
| - |
|
731 |
datesql=ACCS_ORDER_AGENTS_CALLED_COUNT
|
| - |
|
732 |
conn = getDbConnection()
|
| - |
|
733 |
cursor = conn.cursor()
|
| - |
|
734 |
cursor.execute(datesql)
|
| - |
|
735 |
result = cursor.fetchall()
|
| - |
|
736 |
agentLoginList=[]
|
| - |
|
737 |
for r in result:
|
| - |
|
738 |
agentLoginList.append(str(r[0]))
|
| - |
|
739 |
conn.close()
|
| - |
|
740 |
global ACCS_ORDER_LOGIN
|
| - |
|
741 |
ACCS_ORDER_LOGIN = len(list(set(agentLoginList)))
|
| - |
|
742 |
if len(list(set(agentLoginList))) > 0:
|
| - |
|
743 |
datesql=ACCS_ORDER_QUERY_LOGIN_TIME
|
| - |
|
744 |
conn = getDbConnection()
|
| - |
|
745 |
cursor = conn.cursor()
|
| - |
|
746 |
cursor.execute(datesql)
|
| - |
|
747 |
result = cursor.fetchall()
|
| - |
|
748 |
loginTime=0
|
| - |
|
749 |
for r in result:
|
| - |
|
750 |
loginTime+=r[1].seconds
|
| - |
|
751 |
averageLoginTime=loginTime/len(list(set(agentLoginList)))
|
| - |
|
752 |
hours=averageLoginTime/3600
|
| - |
|
753 |
minutesLeft=(averageLoginTime%3600)/60
|
| - |
|
754 |
worksheet.write(17,1,len(list(set(agentLoginList))),center_alignment)
|
| - |
|
755 |
worksheet.write(18,1,str(hours) + ':'+ str(minutesLeft),center_alignment)
|
| - |
|
756 |
worksheet.write(19,1,totalDispositions,center_alignment)
|
| - |
|
757 |
worksheet.write(20,1,totalDispositions/float(len(list(set(agentLoginList)))),center_alignment)
|
| - |
|
758 |
conn.close()
|
| - |
|
759 |
|
| - |
|
760 |
|
| - |
|
761 |
worksheet.write(0,5, 'User Id', style)
|
| - |
|
762 |
worksheet.write(0,6, 'Call Disposition', style)
|
| - |
|
763 |
worksheet.write(0,7, 'Disposition Description', style)
|
| - |
|
764 |
worksheet.write(0,8, 'Disposition Comments', style)
|
| - |
|
765 |
datesql = ACCS_ORDER_DISPOSITION_DESCRIPTION
|
| - |
|
766 |
conn = getDbConnection()
|
| - |
|
767 |
cursor = conn.cursor()
|
| - |
|
768 |
cursor.execute(datesql)
|
| - |
|
769 |
result = cursor.fetchall()
|
| - |
|
770 |
row=0
|
| - |
|
771 |
for r in result:
|
| - |
|
772 |
row=row+1
|
| - |
|
773 |
column =5
|
| - |
|
774 |
for data in r:
|
| - |
|
775 |
worksheet.write(row,column,data)
|
| - |
|
776 |
column+=1
|
| - |
|
777 |
conn.close()
|
| - |
|
778 |
|
| - |
|
779 |
worksheet.write(22,0, 'User Id', style)
|
| - |
|
780 |
worksheet.write(22,1, 'Call Disposition', style)
|
| - |
|
781 |
worksheet.write(22,2, 'Product Inputs', style)
|
| - |
|
782 |
worksheet.write(22,3, 'Pricing Inputs', style)
|
| - |
|
783 |
datesql = ACCS_ORDER_PRODUCT_PRICING
|
| - |
|
784 |
conn = getDbConnection()
|
| - |
|
785 |
cursor = conn.cursor()
|
| - |
|
786 |
cursor.execute(datesql)
|
| - |
|
787 |
result = cursor.fetchall()
|
| - |
|
788 |
row=20
|
| - |
|
789 |
for r in result:
|
| - |
|
790 |
row=row+1
|
| - |
|
791 |
column =0
|
| - |
|
792 |
for data in r:
|
| - |
|
793 |
worksheet.write(row,column,data)
|
| - |
|
794 |
column+=1
|
| - |
|
795 |
conn.close()
|
| - |
|
796 |
newWorkbook.save(RET_FILE)
|
| - |
|
797 |
|
| 611 |
def generateFreshCallingReport():
|
798 |
def generateFreshCallingReport():
|
| 612 |
datesql=FRESH_QUERY
|
799 |
datesql=FRESH_QUERY
|
| 613 |
conn = getDbConnection()
|
800 |
conn = getDbConnection()
|
| 614 |
|
801 |
|
| 615 |
cursor = conn.cursor()
|
802 |
cursor = conn.cursor()
|
| Line 1588... |
Line 1775... |
| 1588 |
#sendmail(["manas.kapoor@shop2020.in"], "", TMP_FILE, SUBJECT)
|
1775 |
#sendmail(["manas.kapoor@shop2020.in"], "", TMP_FILE, SUBJECT)
|
| 1589 |
sendmail(["amit.sirohi@shop2020.in","rajneesh.arora@saholic.com","ritesh.chauhan@shop2020.in", "shailesh.kumar@shop2020.in","utkarsh@coreoutsourcingservices.com","gupta.varun@coreoutsourcingservices.com","manas.kapoor@shop2020.in"], "", TMP_FILE, SUBJECT)
|
1776 |
sendmail(["amit.sirohi@shop2020.in","rajneesh.arora@saholic.com","ritesh.chauhan@shop2020.in", "shailesh.kumar@shop2020.in","utkarsh@coreoutsourcingservices.com","gupta.varun@coreoutsourcingservices.com","manas.kapoor@shop2020.in"], "", TMP_FILE, SUBJECT)
|
| 1590 |
if options.reporttype == 'retention':
|
1777 |
if options.reporttype == 'retention':
|
| 1591 |
generateAccessoriesCartReport()
|
1778 |
generateAccessoriesCartReport()
|
| 1592 |
generateAccessoriesTabsReport()
|
1779 |
generateAccessoriesTabsReport()
|
| - |
|
1780 |
generateAccessoriesOrderReport()
|
| 1593 |
#sendmailretention(["manas.kapoor@shop2020.in"], "", RET_FILE, RET_SUBJECT)
|
1781 |
#sendmailretention(["manas.kapoor@shop2020.in"], "", RET_FILE, RET_SUBJECT)
|
| 1594 |
sendmailretention(["amit.sirohi@shop2020.in","rajneesh.arora@saholic.com", "shailesh.kumar@shop2020.in","chaitnaya.vats@shop2020.in","manas.kapoor@shop2020.in"], "", RET_FILE, RET_SUBJECT)
|
1782 |
sendmailretention(["amit.sirohi@shop2020.in","rajneesh.arora@saholic.com", "shailesh.kumar@shop2020.in","chaitnaya.vats@shop2020.in","manas.kapoor@shop2020.in"], "", RET_FILE, RET_SUBJECT)
|
| 1595 |
|
1783 |
|
| 1596 |
def sendmail(email, message, fileName, title):
|
1784 |
def sendmail(email, message, fileName, title):
|
| 1597 |
if email == "":
|
1785 |
if email == "":
|
| Line 1698... |
Line 1886... |
| 1698 |
for r in result:
|
1886 |
for r in result:
|
| 1699 |
inputs = inputs + "<br>" + r[0] + "-----" + str(r[1])
|
1887 |
inputs = inputs + "<br>" + r[0] + "-----" + str(r[1])
|
| 1700 |
conn.close()
|
1888 |
conn.close()
|
| 1701 |
return inputs
|
1889 |
return inputs
|
| 1702 |
|
1890 |
|
| - |
|
1891 |
def getAccsOrdersHtml():
|
| - |
|
1892 |
heading = "Accessories Orders(Project 3)"
|
| - |
|
1893 |
message="No. of Agents " + str(ACCS_ORDER_LOGIN)
|
| - |
|
1894 |
message1="Total Calls attempted " + str(ACCS_ORDER_TOTAL)
|
| - |
|
1895 |
message2="Total Successful calls " + str(ACCS_ORDER_SUCCESSFUL)
|
| - |
|
1896 |
return "<br><br><u>" + heading + "</u><br>" +message+"<br>"+message1+"<br>"+message2+"<br>"
|
| - |
|
1897 |
|
| - |
|
1898 |
def getAccsOrdersProject():
|
| - |
|
1899 |
datesql = "select date(now() - interval 1 day), count(distinct user_id),count(distinct order_id), sum(quantity),sum(amount_paid) from allorder where store_id='spice' and category='Accs' and date(created_on)=date(now() - interval 1 day) and user_id in (select user_id from usercrmcallingdata where project_id=3 and date(created)>=date(now()- interval 7 day));"
|
| - |
|
1900 |
conn = getDbConnection()
|
| - |
|
1901 |
cursor = conn.cursor()
|
| - |
|
1902 |
cursor.execute(datesql)
|
| - |
|
1903 |
result = cursor.fetchall()
|
| - |
|
1904 |
inputs = "No of users who placed orders on Date " + str(result[0][0]) + "<br> Number of Users " + str(result[0][1])+ " <br> Total Orders " + str(result[0][2]) + "<br>Total Quantity " + str(result[0][3]) + "<br>Total Value " + str(result[0][4]) + "<br>"
|
| - |
|
1905 |
conn.close()
|
| - |
|
1906 |
return inputs
|
| - |
|
1907 |
|
| - |
|
1908 |
def getAccsOrdersProductPricingInput():
|
| - |
|
1909 |
datesql = "select product_input,pricing_input from productpricinginputs where date(created)=date(now() - interval 1 day) and project_id=3 and product_input not like '';"
|
| - |
|
1910 |
conn = getDbConnection()
|
| - |
|
1911 |
cursor = conn.cursor()
|
| - |
|
1912 |
cursor.execute(datesql)
|
| - |
|
1913 |
result = cursor.fetchall()
|
| - |
|
1914 |
inputs="Product Pricing Inputs"
|
| - |
|
1915 |
for r in result:
|
| - |
|
1916 |
inputs = inputs + "<br>" + r[0] + "-----" + str(r[1])
|
| - |
|
1917 |
conn.close()
|
| - |
|
1918 |
return inputs
|
| 1703 |
|
1919 |
|
| 1704 |
def sendmailretention(email, message, fileName, title):
|
1920 |
def sendmailretention(email, message, fileName, title):
|
| 1705 |
if email == "":
|
1921 |
if email == "":
|
| 1706 |
return
|
1922 |
return
|
| 1707 |
mailServer = smtplib.SMTP(SMTP_SERVER, SMTP_PORT)
|
1923 |
mailServer = smtplib.SMTP(SMTP_SERVER, SMTP_PORT)
|
| Line 1720... |
Line 1936... |
| 1720 |
|
1936 |
|
| 1721 |
msg.attach(MIMEText(getAccsTabHtml(), 'html'))
|
1937 |
msg.attach(MIMEText(getAccsTabHtml(), 'html'))
|
| 1722 |
msg.attach(MIMEText(getAccsTabOrders(),'html'))
|
1938 |
msg.attach(MIMEText(getAccsTabOrders(),'html'))
|
| 1723 |
msg.attach(MIMEText(getAccsTabProductPricingInput(),'html'))
|
1939 |
msg.attach(MIMEText(getAccsTabProductPricingInput(),'html'))
|
| 1724 |
|
1940 |
|
| - |
|
1941 |
msg.attach(MIMEText(getAccsOrdersHtml(), 'html'))
|
| - |
|
1942 |
msg.attach(MIMEText(getAccsOrdersProject(),'html'))
|
| - |
|
1943 |
msg.attach(MIMEText(getAccsOrdersProductPricingInput(),'html'))
|
| 1725 |
|
1944 |
|
| 1726 |
fileMsg = MIMEBase('application', 'vnd.ms-excel')
|
1945 |
fileMsg = MIMEBase('application', 'vnd.ms-excel')
|
| 1727 |
fileMsg.set_payload(file(RET_FILE).read())
|
1946 |
fileMsg.set_payload(file(RET_FILE).read())
|
| 1728 |
encoders.encode_base64(fileMsg)
|
1947 |
encoders.encode_base64(fileMsg)
|
| 1729 |
fileMsg.add_header('Content-Disposition', 'attachment;filename=' + fileName)
|
1948 |
fileMsg.add_header('Content-Disposition', 'attachment;filename=' + fileName)
|