Index: /WAeUP_SRP/trunk/skins/waeup_aaua/getPaymentStatistics.py
===================================================================
--- /WAeUP_SRP/trunk/skins/waeup_aaua/getPaymentStatistics.py	(revision 5579)
+++ /WAeUP_SRP/trunk/skins/waeup_aaua/getPaymentStatistics.py	(revision 5579)
@@ -0,0 +1,126 @@
+## Script (Python) "getRetStudentStatistics"
+##bind container=container
+##bind context=context
+##bind namespace=
+##bind script=script
+##bind subpath=traverse_subpath
+##parameters=session_id=None
+##title=
+##
+# $Id$
+"""
+return Payment Statistics
+"""
+
+from Products.AdvancedQuery import Eq, Between, Le,In
+
+import logging
+logger = logging.getLogger('Skins.getPaymentStatistics')
+
+import DateTime,csv
+
+member = context.portal_membership.getAuthenticatedMember()
+logger.info('%s invoked statistics' % member)
+if not context.isStaff():
+    return
+
+IPTP = ('ACC','BFN','BUS','HIS','ECO','PAD','PGD','SOC')
+
+#INE = ('ATE','CEM','EDU','GST','SSE','STE ')
+
+catA =      (      'school_fee_paid',
+                   'courses_registered',
+                   'courses_validated',
+                   )
+                   
+if not session_id:
+    session_id  = context.getSessionId()[0]
+
+L1 = ('100','110','120')
+L2 = ('200','210','220')
+L3 = ('300','310','320')
+L4 = ('400','410','420')
+L5 = ('500','510','520')
+L6 = ('600','610','620')
+L7 = ('700','710','720')
+L8 = ('800','810','820')
+d = {}
+
+# Diploma and Direct entry students
+
+query = Eq('session',session_id) & In('review_state',catA) & Eq('mode','dp_pt')
+d['dp_pt'] = len(context.students_catalog.evalAdvancedQuery(query))
+
+query = Eq('session',session_id) & In('review_state',catA) & Eq('mode','de_pt')
+d['de_pt'] = len(context.students_catalog.evalAdvancedQuery(query))
+
+query = Eq('session',session_id) & In('review_state',catA) & Eq('mode','de_sw')
+d['de_sw'] = len(context.students_catalog.evalAdvancedQuery(query))
+
+# IPTP students
+
+query = Eq('session',session_id) & In('review_state',catA) & Eq('mode','ug_pt') & In('department',IPTP) & In('level',L1)
+d['ug_pt_iptp_100'] = len(context.students_catalog.evalAdvancedQuery(query))
+
+
+query = Eq('session',session_id) & In('review_state',catA) & Eq('mode','ug_pt') & In('department',IPTP) & In('level',L2)
+d['ug_pt_iptp_200'] = len(context.students_catalog.evalAdvancedQuery(query))
+
+
+query = Eq('session',session_id) & In('review_state',catA) & Eq('mode','ug_pt') & In('department',IPTP) & In('level',L3)
+d['ug_pt_iptp_300'] = len(context.students_catalog.evalAdvancedQuery(query))
+
+query = Eq('session',session_id) & In('review_state',catA) & Eq('mode','ug_pt') & In('department',IPTP) & In('level',L4)
+d['ug_pt_iptp_400'] = len(context.students_catalog.evalAdvancedQuery(query))
+
+query = Eq('session',session_id) & In('review_state',catA) & Eq('mode','ug_pt') & In('department',IPTP) & In('level',L5)
+d['ug_pt_iptp_500'] = len(context.students_catalog.evalAdvancedQuery(query))
+
+query = Eq('session',session_id) & In('review_state',catA) & Eq('mode','pg_pt') & In('department',IPTP) & In('level',L6)
+d['pg_pt_iptp_600'] = len(context.students_catalog.evalAdvancedQuery(query))
+
+query = Eq('session',session_id) & In('review_state',catA) & Eq('mode','pg_pt') & In('department',IPTP) & In('level',L7)
+d['pg_pt_iptp_700'] = len(context.students_catalog.evalAdvancedQuery(query))
+
+query = Eq('session',session_id) & In('review_state',catA) & Eq('mode','pg_pt') & In('department',IPTP) & In('level',L8)
+d['pg_pt_iptp_800'] = len(context.students_catalog.evalAdvancedQuery(query))
+
+#INE  sandwich
+
+
+query = Eq('session',session_id) & In('review_state',catA) & Eq('mode','ug_sw') & ~In('department',IPTP) & In('level',L1)
+d['ug_sw_ine_100'] = len(context.students_catalog.evalAdvancedQuery(query))
+
+
+query = Eq('session',session_id) & In('review_state',catA) & Eq('mode','ug_sw') & ~In('department',IPTP) & In('level',L2)
+d['ug_sw_ine_200'] = len(context.students_catalog.evalAdvancedQuery(query))
+
+
+query = Eq('session',session_id) & In('review_state',catA) & Eq('mode','ug_sw') & ~In('department',IPTP) & In('level',L3)
+d['ug_sw_ine_300'] = len(context.students_catalog.evalAdvancedQuery(query))
+
+
+query = Eq('session',session_id) & In('review_state',catA) & Eq('mode','ug_sw') & ~In('department',IPTP) & In('level',L4)
+d['ug_sw_ine_400'] = len(context.students_catalog.evalAdvancedQuery(query))
+
+
+query = Eq('session',session_id) & In('review_state',catA) & Eq('mode','ug_sw') & ~In('department',IPTP) & In('level',L5)
+d['ug_sw_ine_500'] = len(context.students_catalog.evalAdvancedQuery(query))
+
+
+query = Eq('session',session_id) & In('review_state',catA) & Eq('mode','pg_sw') & ~In('department',IPTP) & In('level',L6)
+d['pg_sw_ine_600'] = len(context.students_catalog.evalAdvancedQuery(query))
+
+query = Eq('session',session_id) & In('review_state',catA) & Eq('mode','pg_sw') & ~In('department',IPTP) & In('level',L7)
+d['pg_sw_ine_700'] = len(context.students_catalog.evalAdvancedQuery(query))
+
+query = Eq('session',session_id) & In('review_state',catA) & Eq('mode','pg_sw') & ~In('department',IPTP) & In('level',L8)
+d['pg_sw_ine_800'] = len(context.students_catalog.evalAdvancedQuery(query))
+
+l = []
+l += d,
+
+csv_name = context.waeup_tool.dumpListToCSV(l,'payments_statistics')
+logger.info('%s dumped payments statistics to %s' % (member,csv_name))
+
+return d
