Index: WAeUP_SRP/trunk/skins/waeup_fceokene/getPaymentStatistics.py
===================================================================
--- WAeUP_SRP/trunk/skins/waeup_fceokene/getPaymentStatistics.py	(revision 5560)
+++ WAeUP_SRP/trunk/skins/waeup_fceokene/getPaymentStatistics.py	(revision 5560)
@@ -0,0 +1,128 @@
+## 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
+
+ARTS = ('CRS','ISS','HIS','MUS','ECO','GEO','POL','SOS','CCA','ECU','THA','GED','GSE','PES','SPC','ENG ','FRE','ARB','HAU','IGB','YOR')
+
+#SCS = ('BIO','CHE','HED','MAT','PED','PHY ','CSC','ISC','PHE','AGE','BED','HEC','TED','FAA')
+
+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')
+
+d = {}
+
+query = Eq('session',session_id) & In('review_state',catA) & Eq('mode','pd_ft')
+d['pd_ft'] = len(context.students_catalog.evalAdvancedQuery(query))
+
+query = Eq('session',session_id) & In('review_state',catA) & Eq('mode','prence') & In('department',ARTS)
+d['prence_arts'] = len(context.students_catalog.evalAdvancedQuery(query))
+
+query = Eq('session',session_id) & In('review_state',catA) & Eq('mode','prence') & ~In('department',ARTS)
+d['prence_sci'] = len(context.students_catalog.evalAdvancedQuery(query))
+
+# regular students
+
+query = Eq('session',session_id) & In('review_state',catA) & Eq('mode','ug_ft') & In('department',ARTS) & In('level',L1)
+d['ug_ft_arts_100'] = len(context.students_catalog.evalAdvancedQuery(query))
+
+query = Eq('session',session_id) & In('review_state',catA) & Eq('mode','ug_ft') & ~In('department',ARTS) & In('level',L1)
+d['ug_ft_sci_100'] = len(context.students_catalog.evalAdvancedQuery(query))
+
+query = Eq('session',session_id) & In('review_state',catA) & Eq('mode','ug_ft') & In('department',ARTS) & In('level',L2)
+d['ug_ft_arts_200'] = len(context.students_catalog.evalAdvancedQuery(query))
+
+query = Eq('session',session_id) & In('review_state',catA) & Eq('mode','ug_ft') & ~In('department',ARTS) & In('level',L2)
+d['ug_ft_sci_200'] = len(context.students_catalog.evalAdvancedQuery(query))
+
+query = Eq('session',session_id) & In('review_state',catA) & Eq('mode','ug_ft') & In('department',ARTS) & In('level',L3)
+d['ug_ft_arts_300'] = len(context.students_catalog.evalAdvancedQuery(query))
+
+query = Eq('session',session_id) & In('review_state',catA) & Eq('mode','ug_ft') & ~In('department',ARTS) & In('level',L3)
+d['ug_ft_sci_300'] = len(context.students_catalog.evalAdvancedQuery(query))
+
+query = Eq('session',session_id) & In('review_state',catA) & Eq('mode','ug_ft') & In('department',ARTS) & In('level',L4)
+d['ug_ft_arts_rep'] = len(context.students_catalog.evalAdvancedQuery(query))
+
+query = Eq('session',session_id) & In('review_state',catA) & Eq('mode','ug_ft') & ~In('department',ARTS) & In('level',L4)
+d['ug_ft_sci_rep'] = len(context.students_catalog.evalAdvancedQuery(query))
+
+# sandwich
+
+query = Eq('session',session_id) & In('review_state',catA) & Eq('mode','ug_sw') & In('department',ARTS) & In('level',L1)
+d['ug_sw_arts_100'] = len(context.students_catalog.evalAdvancedQuery(query))
+
+query = Eq('session',session_id) & In('review_state',catA) & Eq('mode','ug_sw') & ~In('department',ARTS) & In('level',L1)
+d['ug_sw_sci_100'] = len(context.students_catalog.evalAdvancedQuery(query))
+
+query = Eq('session',session_id) & In('review_state',catA) & Eq('mode','ug_sw') & In('department',ARTS) & In('level',L2)
+d['ug_sw_arts_200'] = len(context.students_catalog.evalAdvancedQuery(query))
+
+query = Eq('session',session_id) & In('review_state',catA) & Eq('mode','ug_sw') & ~In('department',ARTS) & In('level',L2)
+d['ug_sw_sci_200'] = len(context.students_catalog.evalAdvancedQuery(query))
+
+query = Eq('session',session_id) & In('review_state',catA) & Eq('mode','ug_sw') & In('department',ARTS) & In('level',L3)
+d['ug_sw_arts_300'] = len(context.students_catalog.evalAdvancedQuery(query))
+
+query = Eq('session',session_id) & In('review_state',catA) & Eq('mode','ug_sw') & ~In('department',ARTS) & In('level',L3)
+d['ug_sw_sci_300'] = len(context.students_catalog.evalAdvancedQuery(query))
+
+query = Eq('session',session_id) & In('review_state',catA) & Eq('mode','ug_sw') & In('department',ARTS) & In('level',L4)
+d['ug_sw_arts_400'] = len(context.students_catalog.evalAdvancedQuery(query))
+
+query = Eq('session',session_id) & In('review_state',catA) & Eq('mode','ug_sw') & ~In('department',ARTS) & In('level',L4)
+d['ug_sw_sci_400'] = len(context.students_catalog.evalAdvancedQuery(query))
+
+query = Eq('session',session_id) & In('review_state',catA) & Eq('mode','ug_sw') & In('department',ARTS) & In('level',L5)
+d['ug_sw_arts_500'] = len(context.students_catalog.evalAdvancedQuery(query))
+
+query = Eq('session',session_id) & In('review_state',catA) & Eq('mode','ug_sw') & ~In('department',ARTS) & In('level',L5)
+d['ug_sw_sci_500'] = len(context.students_catalog.evalAdvancedQuery(query))
+
+query = Eq('session',session_id) & In('review_state',catA) & Eq('mode','ug_sw') & In('department',ARTS) & In('level',L6)
+d['ug_sw_arts_rep'] = len(context.students_catalog.evalAdvancedQuery(query))
+
+query = Eq('session',session_id) & In('review_state',catA) & Eq('mode','ug_sw') & ~In('department',ARTS) & In('level',L6)
+d['ug_sw_sci_rep'] = 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
Index: WAeUP_SRP/trunk/skins/waeup_fceokene/statistics_payment_view.pt
===================================================================
--- WAeUP_SRP/trunk/skins/waeup_fceokene/statistics_payment_view.pt	(revision 5560)
+++ WAeUP_SRP/trunk/skins/waeup_fceokene/statistics_payment_view.pt	(revision 5560)
@@ -0,0 +1,135 @@
+<metal:body use-macro="here/main_template/macros/master">
+  <metal:main fill-slot="main">
+  <metal:block tal:define="faculties context/getSimpleStudentStatistics;
+                        mtool here/portal_membership;
+                        member mtool/getAuthenticatedMember;
+                        session_str python:context.getSessionId()[1]">       
+
+      <span tal:condition="not: faculties">
+        <span tal:content="here/illegal_view" />
+      </span>
+      <span tal:condition="faculties">
+  
+      <strong>
+      <nobr><a href="search_students">Search Students</a>
+      &nbsp;&nbsp;&nbsp;&nbsp;</nobr>        
+   
+      </strong>     
+
+      <h3>Basic Student Statistics <span tal:content="session_str" /></h3>
+      <br />      
+      <span tal:condition="not:isAnon">
+      Student records imported: <span tal:content="python: faculties[0]['total_in_catalog']" />
+      <br />  <br />  
+        <table >  
+
+          <tr>
+            <th>&nbsp;</th>
+            
+            <th style="border-style:solid; border-width:1px; border-color:black; text-align:center" colspan="3">Total</th>
+            
+            <th style="border-style:solid; border-width:1px; border-color:black; text-align:center" colspan="3">Category A</th>
+
+            <th style="border-style:solid; border-width:1px; border-color:black; text-align:center" colspan="3">Category B</th>
+
+            <th style="border-style:solid; border-width:1px; border-color:black; text-align:center" colspan="3">Category C</th>
+
+
+          </tr>
+
+          <tr class="odd ajaxtd">
+            <th >School</th>
+            <th style='text-align:right'>Returning</th>
+            <th style='text-align:right'>New</th>
+            <th style='text-align:right'>Pre-NCE</th>
+            <th style='text-align:right'>Returning</th>
+            <th style='text-align:right'>New</th>
+            <th style='text-align:right'>Pre-NCE</th>
+            <th style='text-align:right'>Returning</th>
+            <th style='text-align:right'>New</th>
+            <th style='text-align:right'>Pre-NCE</th>
+            <th style='text-align:right'>Returning</th>
+            <th style='text-align:right'>New</th>
+            <th style='text-align:right'>Pre-NCE</th>
+
+          </tr>
+          <tr tal:repeat="d faculties"
+              tal:attributes="class python:test(repeat['d'].even(), 'even ajaxtd', 'odd ajaxtd')">
+              <td width="80px"> <span tal:content="d/id" /> </td>
+
+              <td width="60px" style='text-align:right'> 
+                <span tal:content="d/total_ft" />
+              </td>              
+
+              <td width="60px" style='text-align:right'> 
+                <span tal:content="d/total_pt" />
+              </td>              
+
+              <td width="60px" style='text-align:right'> 
+                <span tal:content="d/total_dp" />
+              </td>                 
+              
+              <td width="60px" style='text-align:right'> 
+                <span tal:content="d/total_Aft" />
+              </td>              
+
+              <td width="60px" style='text-align:right'> 
+                <span tal:content="d/total_Apt" />
+              </td>              
+
+              <td width="60px" style='text-align:right'> 
+                <span tal:content="d/total_Adp" />
+              </td>              
+
+              <td width="60px" style='text-align:right'> 
+                <span tal:content="d/total_Bft" />
+              </td>              
+
+              <td width="60px" style='text-align:right'> 
+                <span tal:content="d/total_Bpt" />
+              </td>              
+              
+              <td width="60px" style='text-align:right'> 
+                <span tal:content="d/total_Bdp" />
+              </td>      
+              
+              <td width="60px" style='text-align:right'> 
+                <span tal:content="d/total_Cft" />
+              </td>      
+              
+              <td width="60px" style='text-align:right'> 
+                <span tal:content="d/total_Cpt" />
+              </td>      
+              
+              <td width="60px" style='text-align:right'> 
+                <span tal:content="d/total_Cdp" />
+              </td>                                                
+
+                                       
+
+          </tr>
+        </table>
+
+        <br />
+        <table   border=0>
+
+        <tr><td>Category A: </td> <td>students who paid their school fee in <span tal:content="session_str" /></td></tr>
+        <tr><td>Category B: </td> <td>students who registered their courses online (A contains B) in <span tal:content="session_str" /></td></tr>
+        <tr><td>Category C: </td> <td>students who 'arrived' in <span tal:content="session_str" /> but have not yet paid their school fee</td></tr>
+        <tr><td>Returning: </td> <td>students in NCE-II or NCE-III</td></tr>
+        <tr><td>New: </td> <td>students in NCE-I</td></tr>
+        <tr><td>&nbsp;</td><td>&nbsp;</td></tr>
+        <tr><td colspan="2"><strong>Remark:</strong> <span tal:content="python: faculties[0]['not_categorized']" /> returning students are not categorized.
+             </td>
+        </tr>
+          
+        </table>
+        
+        
+        
+      </span>
+      </span>
+  </metal:block>      
+  </metal:main>
+</metal:body>
+      
