Subversion Repositories SmartDukaan

Rev

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

Rev 15407 Rev 15409
Line 45... Line 45...
45
datetime_format = xlwt.XFStyle()
45
datetime_format = xlwt.XFStyle()
46
datetime_format.num_format_str = 'yyyy/mm/dd HH:MM AM/PM'
46
datetime_format.num_format_str = 'yyyy/mm/dd HH:MM AM/PM'
47
 
47
 
48
default_format = xlwt.XFStyle()
48
default_format = xlwt.XFStyle()
49
freshList=['1','2','3','4','5','6','7','8','9','10','11','12','13']
49
freshList=['1','2','3','4','5','6','7','8','9','10','11','12','13']
50
followUpList=['1','2','3','4','5','6']
50
followUpList=['1','2','3','4','5','6','7','8','9','10']
51
onBoardingList=['1','2','3','4','5'] 
51
onBoardingList=['1','2','3','4','5'] 
52
dispositionMap = {  'call_later':0,
52
dispositionMap = {  'call_later':0,
53
                    'ringing_no_answer':1,
53
                    'ringing_no_answer':1,
54
                    'not_reachable':2,
54
                    'not_reachable':2,
55
                    'switch_off':3,
55
                    'switch_off':3,
Line 70... Line 70...
70
                    'not_reachable':2,
70
                    'not_reachable':2,
71
                    'switch_off':3,
71
                    'switch_off':3,
72
                    'retailer_not_interested':4,
72
                    'retailer_not_interested':4,
73
                    'alreadyuser':5,
73
                    'alreadyuser':5,
74
                    'verified_link_sent':6,
74
                    'verified_link_sent':6,
-
 
75
                    'accessory_retailer':7,
-
 
76
                    'service_center_retailer':8,
-
 
77
                    'not_retailer':9, 
-
 
78
                    'recharge_retailer':10
75
                }
79
                }
76
onBoardingDispositionMap = {  'call_later':0,
80
onBoardingDispositionMap = {  'call_later':0,
77
                    'ringing_no_answer':1,
81
                    'ringing_no_answer':1,
78
                    'not_reachable':2,
82
                    'not_reachable':2,
79
                    'switch_off':3,
83
                    'switch_off':3,
Line 617... Line 621...
617
    worksheet.write(3,column, 'Not Reachable', newStyle)
621
    worksheet.write(3,column, 'Not Reachable', newStyle)
618
    worksheet.write(4,column, 'Switched Off', newStyle)
622
    worksheet.write(4,column, 'Switched Off', newStyle)
619
    worksheet.write(5,column, 'Retailer Not Interested', newStyle)
623
    worksheet.write(5,column, 'Retailer Not Interested', newStyle)
620
    worksheet.write(6,column, 'Already Profitmandi user', boldStyle)   
624
    worksheet.write(6,column, 'Already Profitmandi user', boldStyle)   
621
    worksheet.write(7,column, 'Verified Link Sent', boldStyle)
625
    worksheet.write(7,column, 'Verified Link Sent', boldStyle)
-
 
626
    worksheet.write(8,column, 'Accessory Retailer', newStyle)
-
 
627
    worksheet.write(9,column, 'Service Center Retailer', newStyle)
-
 
628
    worksheet.write(10,column, 'Not Retailer', boldStyle)   
-
 
629
    worksheet.write(11,column, 'Recharge Retailer', boldStyle)
622
    worksheet.write(8,column, 'Contactable Data (%)', newStyle)
630
    worksheet.write(12,column, 'Contactable Data (%)', newStyle)
623
    worksheet.write(9,column, 'Non Contactable Data (%)', newStyle)
631
    worksheet.write(13,column, 'Non Contactable Data (%)', newStyle)
624
    worksheet.write(10,column, 'Agents Logged In', style)
632
    worksheet.write(14,column, 'Agents Logged In', style)
625
    worksheet.write(11,column, 'Average Login Time (In Hrs)', style)
633
    worksheet.write(15,column, 'Average Login Time (In Hrs)', style)
626
    worksheet.write(12,column, 'Total Dialed Out', style)
634
    worksheet.write(16,column, 'Total Dialed Out', style)
627
    worksheet.write(13,column, 'Average Dialed Out per agent', style)
635
    worksheet.write(17,column, 'Average Dialed Out per agent', style)
628
    worksheet.write(14,column, 'Average Call Duration (In Hrs)', style)
636
    worksheet.write(18,column, 'Average Call Duration (In Hrs)', style)
629
    worksheet.write(15,column, 'Average Handling Time (In Hrs)', style)
637
    worksheet.write(19,column, 'Average Handling Time (In Hrs)', style)
630
    worksheet.write(16,column, 'Average Idle Time (In Hrs)', style)
638
    worksheet.write(20,column, 'Average Idle Time (In Hrs)', style)
631
    
639
    
632
    contactableData=0
640
    contactableData=0
633
    nonContactableData=0
641
    nonContactableData=0
634
    totalDispositions=0
642
    totalDispositions=0
635
    
643
    
Line 649... Line 657...
649
        row = int(val)
657
        row = int(val)
650
        
658
        
651
        column = 1
659
        column = 1
652
        worksheet.write(row, column, 0,center_alignment)
660
        worksheet.write(row, column, 0,center_alignment)
653
    totalDispositions=contactableData+nonContactableData
661
    totalDispositions=contactableData+nonContactableData
654
    worksheet.write(8,1,round((contactableData/float(totalDispositions))*100,2),center_alignment)
662
    worksheet.write(12,1,round((contactableData/float(totalDispositions))*100,2),center_alignment)
655
    worksheet.write(9,1,round((nonContactableData/float(totalDispositions))*100,2),center_alignment)
663
    worksheet.write(13,1,round((nonContactableData/float(totalDispositions))*100,2),center_alignment)
656
    
664
    
657
    
665
    
658
    conn.close()
666
    conn.close()
659
    datesql=FOLLOW_UP_QUERY_LOGIN_TIME 
667
    datesql=FOLLOW_UP_QUERY_LOGIN_TIME 
660
    conn = getDbConnection()
668
    conn = getDbConnection()
Line 669... Line 677...
669
        loginTime+=r[1].seconds
677
        loginTime+=r[1].seconds
670
        agentLoginList.append(str(r[0]))
678
        agentLoginList.append(str(r[0]))
671
    averageLoginTime=loginTime/len(list(set(agentLoginList)))
679
    averageLoginTime=loginTime/len(list(set(agentLoginList)))
672
    hours=averageLoginTime/3600
680
    hours=averageLoginTime/3600
673
    minutesLeft=(averageLoginTime%3600)/60
681
    minutesLeft=(averageLoginTime%3600)/60
674
    worksheet.write(10,1,len(list(set(agentLoginList))),center_alignment)
682
    worksheet.write(14,1,len(list(set(agentLoginList))),center_alignment)
675
    worksheet.write(11,1,str(hours) + ':'+ str(minutesLeft),center_alignment)   
683
    worksheet.write(15,1,str(hours) + ':'+ str(minutesLeft),center_alignment)   
676
    worksheet.write(12,1,totalDispositions,center_alignment)
684
    worksheet.write(16,1,totalDispositions,center_alignment)
677
    worksheet.write(13,1,(contactableData+nonContactableData)/len(list(set(agentLoginList))),center_alignment)
685
    worksheet.write(17,1,(contactableData+nonContactableData)/len(list(set(agentLoginList))),center_alignment)
678
    conn.close()
686
    conn.close()
679
    datesql=FOLLOW_UP_QUERY_DURATION
687
    datesql=FOLLOW_UP_QUERY_DURATION
680
    conn = getDbConnection()
688
    conn = getDbConnection()
681
    
689
    
682
    cursor = conn.cursor()
690
    cursor = conn.cursor()
Line 685... Line 693...
685
    for r in result:
693
    for r in result:
686
        totalCallDuration= r[0]
694
        totalCallDuration= r[0]
687
    averageCallDuration=totalCallDuration/len(list(set(agentLoginList)))    
695
    averageCallDuration=totalCallDuration/len(list(set(agentLoginList)))    
688
    hours=averageCallDuration/3600
696
    hours=averageCallDuration/3600
689
    minutesLeft=(averageCallDuration%3600)/60    
697
    minutesLeft=(averageCallDuration%3600)/60    
690
    worksheet.write(14,1,str(int(hours))+':'+str(int(minutesLeft)),center_alignment)
698
    worksheet.write(18,1,str(int(hours))+':'+str(int(minutesLeft)),center_alignment)
691
    conn.close()
699
    conn.close()
692
    
700
    
693
    datesql=FOLLOW_UP_QUERY_AHT
701
    datesql=FOLLOW_UP_QUERY_AHT
694
    conn = getDbConnection()
702
    conn = getDbConnection()
695
    cursor = conn.cursor()
703
    cursor = conn.cursor()
Line 699... Line 707...
699
    for r in result:
707
    for r in result:
700
        loginTime+=r[0]
708
        loginTime+=r[0]
701
    averageLoginTime=loginTime/len(list(set(agentLoginList)))
709
    averageLoginTime=loginTime/len(list(set(agentLoginList)))
702
    hours=averageLoginTime/3600
710
    hours=averageLoginTime/3600
703
    minutesLeft=(averageLoginTime%3600)/60
711
    minutesLeft=(averageLoginTime%3600)/60
704
    worksheet.write(15,1,len(list(set(agentLoginList))),center_alignment)
712
    worksheet.write(19,1,len(list(set(agentLoginList))),center_alignment)
705
    conn.close()
713
    conn.close()
706
    
714
    
707
    datesql=FOLLOW_UP_QUERY_AIT
715
    datesql=FOLLOW_UP_QUERY_AIT
708
    conn = getDbConnection()
716
    conn = getDbConnection()
709
    cursor = conn.cursor()
717
    cursor = conn.cursor()
Line 713... Line 721...
713
    for r in result:
721
    for r in result:
714
        loginTime+=r[0]
722
        loginTime+=r[0]
715
    averageLoginTime=loginTime/len(list(set(agentLoginList)))
723
    averageLoginTime=loginTime/len(list(set(agentLoginList)))
716
    hours=averageLoginTime/3600
724
    hours=averageLoginTime/3600
717
    minutesLeft=(averageLoginTime%3600)/60
725
    minutesLeft=(averageLoginTime%3600)/60
718
    worksheet.write(16,1,len(list(set(agentLoginList))),center_alignment)
726
    worksheet.write(20,1,len(list(set(agentLoginList))),center_alignment)
719
    workbook.save(TMP_FILE)  
727
    workbook.save(TMP_FILE)  
720
 
728
 
721
def generateAgentWiseFollowupCallingReport():
729
def generateAgentWiseFollowupCallingReport():
722
    
730
    
723
    agentId=3
731
    agentId=3
Line 745... Line 753...
745
    worksheet.write(row+3,column-1, 'Not Reachable', newStyle)
753
    worksheet.write(row+3,column-1, 'Not Reachable', newStyle)
746
    worksheet.write(row+4,column-1, 'Switched Off', newStyle)
754
    worksheet.write(row+4,column-1, 'Switched Off', newStyle)
747
    worksheet.write(row+5,column-1, 'Retailer Not Interested', newStyle)
755
    worksheet.write(row+5,column-1, 'Retailer Not Interested', newStyle)
748
    worksheet.write(row+6,column-1, 'Already Profitmandi user', boldStyle)   
756
    worksheet.write(row+6,column-1, 'Already Profitmandi user', boldStyle)   
749
    worksheet.write(row+7,column-1, 'Verified Link Sent', boldStyle)
757
    worksheet.write(row+7,column-1, 'Verified Link Sent', boldStyle)
-
 
758
    worksheet.write(row+8,column-1, 'Accessory Retailer', newStyle)
-
 
759
    worksheet.write(row+9,column-1, 'Service Center Retailer', newStyle)
-
 
760
    worksheet.write(row+10,column-1, 'Not retailer', style)
-
 
761
    worksheet.write(row+11,column-1, 'Recharge Retailer', style)
750
    worksheet.write(row+8,column-1, 'Contactable Data (%)', newStyle)
762
    worksheet.write(row+12,column-1, 'Contactable Data (%)', newStyle)
751
    worksheet.write(row+9,column-1, 'Non Contactable Data (%)', newStyle)
763
    worksheet.write(row+13,column-1, 'Non Contactable Data (%)', newStyle)
752
    worksheet.write(row+10,column-1, 'Total Dialed Out', style)
764
    worksheet.write(row+14,column-1, 'Total Dialed Out', style)
753
    worksheet.write(row+11,column-1, 'Login Time (In Hrs)', style)
765
    worksheet.write(row+15,column-1, 'Login Time (In Hrs)', style)
754
    worksheet.write(row+12,column-1, 'Call Duration (In Hrs)', style)
766
    worksheet.write(row+16,column-1, 'Call Duration (In Hrs)', style)
755
    worksheet.write(row+13,column-1, 'Handling Time (In Hrs)', style)
767
    worksheet.write(row+17,column-1, 'Handling Time (In Hrs)', style)
756
    worksheet.write(row+14,column-1, 'Idle Time (In Hrs)', style)
768
    worksheet.write(row+18,column-1, 'Idle Time (In Hrs)', style)
757
    columnId=agentId
769
    columnId=agentId
758
    while True:
770
    while True:
759
            if agentId >20 :
771
            if agentId >20 :
760
                break
772
                break
761
            else: 
773
            else: 
Line 788... Line 800...
788
                    for i,val in enumerate(remainingList):
800
                    for i,val in enumerate(remainingList):
789
                        row = int(val)+25
801
                        row = int(val)+25
790
                        column = agentId
802
                        column = agentId
791
                        worksheet.write(row, columnId, 0,center_alignment)
803
                        worksheet.write(row, columnId, 0,center_alignment)
792
                    totalDialedOut = contactableData+nonContactableData
804
                    totalDialedOut = contactableData+nonContactableData
793
                    worksheet.write(25+8,columnId,round((contactableData/float(totalDialedOut))*100,2),center_alignment)
805
                    worksheet.write(25+12,columnId,round((contactableData/float(totalDialedOut))*100,2),center_alignment)
794
                    worksheet.write(25+9,columnId,round((nonContactableData/float(totalDialedOut))*100,2),center_alignment)
806
                    worksheet.write(25+13,columnId,round((nonContactableData/float(totalDialedOut))*100,2),center_alignment)
795
                    worksheet.write(25+10,columnId,totalDialedOut,center_alignment)
807
                    worksheet.write(25+14,columnId,totalDialedOut,center_alignment)
796
                    conn.close()
808
                    conn.close()
797
                
809
                
798
                    name_query=AGENT_NAME_QUERY %(agentId)
810
                    name_query=AGENT_NAME_QUERY %(agentId)
799
                    conn = getDbConnection()
811
                    conn = getDbConnection()
800
                    column=agentId
812
                    column=agentId
Line 817... Line 829...
817
                    for r in result:
829
                    for r in result:
818
                        loginTime+=r[0].seconds
830
                        loginTime+=r[0].seconds
819
                        
831
                        
820
                    hours=loginTime/3600
832
                    hours=loginTime/3600
821
                    minutesLeft=(loginTime%3600)/60
833
                    minutesLeft=(loginTime%3600)/60
822
                    worksheet.write(25+11,columnId,str(hours)+':'+str(minutesLeft),center_alignment)    
834
                    worksheet.write(25+15,columnId,str(hours)+':'+str(minutesLeft),center_alignment)    
823
                    conn.close()
835
                    conn.close()
824
                    
836
                    
825
                    name_query=AGENT_FOLLOW_UP_QUERY_DURATION %(agentId)
837
                    name_query=AGENT_FOLLOW_UP_QUERY_DURATION %(agentId)
826
                    conn = getDbConnection()
838
                    conn = getDbConnection()
827
                    column=agentId
839
                    column=agentId
Line 831... Line 843...
831
                    loginTime=0
843
                    loginTime=0
832
                    for r in result:
844
                    for r in result:
833
                        loginTime+=r[0]
845
                        loginTime+=r[0]
834
                    hours=loginTime/3600
846
                    hours=loginTime/3600
835
                    minutesLeft=(loginTime%3600)/60
847
                    minutesLeft=(loginTime%3600)/60
836
                    worksheet.write(25+12,columnId,str(int(hours))+':'+str(int(minutesLeft)),center_alignment)    
848
                    worksheet.write(25+16,columnId,str(int(hours))+':'+str(int(minutesLeft)),center_alignment)    
837
                    conn.close()
849
                    conn.close()
838
                    
850
                    
839
                    name_query=AGENT_FOLLOW_UP_QUERY_AHT %(agentId)
851
                    name_query=AGENT_FOLLOW_UP_QUERY_AHT %(agentId)
840
                    conn = getDbConnection()
852
                    conn = getDbConnection()
841
                    column=agentId
853
                    column=agentId
Line 845... Line 857...
845
                    loginTime=0
857
                    loginTime=0
846
                    for r in result:
858
                    for r in result:
847
                        loginTime+=r[0]
859
                        loginTime+=r[0]
848
                    hours=loginTime/3600
860
                    hours=loginTime/3600
849
                    minutesLeft=(loginTime%3600)/60
861
                    minutesLeft=(loginTime%3600)/60
850
                    worksheet.write(25+13,columnId,str(int(hours))+':'+str(int(minutesLeft)),center_alignment)    
862
                    worksheet.write(25+17,columnId,str(int(hours))+':'+str(int(minutesLeft)),center_alignment)    
851
                    conn.close()
863
                    conn.close()
852
                    
864
                    
853
                    name_query=AGENT_FOLLOW_UP_QUERY_AIT %(agentId)
865
                    name_query=AGENT_FOLLOW_UP_QUERY_AIT %(agentId)
854
                    conn = getDbConnection()
866
                    conn = getDbConnection()
855
                    column=agentId
867
                    column=agentId
Line 859... Line 871...
859
                    loginTime=0
871
                    loginTime=0
860
                    for r in result:
872
                    for r in result:
861
                        loginTime+=r[0]
873
                        loginTime+=r[0]
862
                    hours=loginTime/3600
874
                    hours=loginTime/3600
863
                    minutesLeft=(loginTime%3600)/60
875
                    minutesLeft=(loginTime%3600)/60
864
                    worksheet.write(25+14,columnId,str(int(hours))+':'+str(int(minutesLeft)),center_alignment)    
876
                    worksheet.write(25+18,columnId,str(int(hours))+':'+str(int(minutesLeft)),center_alignment)    
865
                    conn.close()
877
                    conn.close()
866
                    
878
                    
867
                agentId+=1
879
                agentId+=1
868
                columnId+=1
880
                columnId+=1
869
    workbook.save(TMP_FILE)    
881
    workbook.save(TMP_FILE)