Index: /WAeUP_SRP/trunk/skins/waeup_student/getNewStudentStatistics.py
===================================================================
--- /WAeUP_SRP/trunk/skins/waeup_student/getNewStudentStatistics.py	(revision 1760)
+++ /WAeUP_SRP/trunk/skins/waeup_student/getNewStudentStatistics.py	(revision 1761)
@@ -12,115 +12,65 @@
 return Student Statistics
 """
-try:
-    from Products.zdb import set_trace
-except:
-    def set_trace():
-        pass
+
 import logging
 logger = logging.getLogger('Skins.getNewStudentStatistics')
 
-try:
-    from Products.AdvancedQuery import Eq, Between, Le,In, Ge,MatchRegexp
-    aq_portal = context.portal_catalog.evalAdvancedQuery
-    aq_students = context.students_catalog.evalAdvancedQuery
-except:
-    evalAdvancedQuery = None
-
-def intersect(m,n):
-    return [i for i in m if i in n]
-    
 logger.info('%s invoked statistics' % context.portal_membership.getAuthenticatedMember())
 if not context.isStaff():
-    return l
-total_dict = {}
+    return 'Not allowed'
 
-total_dict['id'] = "All Faculties"
 
-##freshquery = Eq('level','100') | (Eq('level','200') & Eq('entry_mode','DE'))
-##total_new = aq_students(freshquery)
-##total_new = float(len(total_new))
-newquery = Eq('portal_type','StudentApplication') & MatchRegexp('SearchableText',r'^6*')
-total_res = aq_portal(newquery)
-new_ids = [r.getPath().split('/')[-2] for r in total_res]
-total_new = float(len(total_res))
-total_dict['new'] = "%.0f" % total_new
-special_states =  ('admitted',
+total_new = context.students_catalog(session = '06')
+
+new_states =      ('admitted',
                    'clearance_pin_entered',
+                   'objection_raised',
                    'clearance_requested',
                    'cleared_and_validated',
-                   'objection_raised',
+                   'school_fee_paid',
+                   'courses_registered',
+                   'courses_validated',
                    )
-state_count = 0 
-state_ids = {}
-for state in special_states:
-    res = context.portal_catalog(review_state = state)
-    ids = [r.getId for r in res]
-    state_ids[state] = ids 
-    count = len(res)
-    state_count += count
-    total_dict[state] = count
-    total_dict['%s_percent' % state] =  "%.0f" % round(count*100/total_new)
-total_dict['rest'] = "%.0f" % (total_new - state_count)
-total_dict['rest_percent'] = "%.0f" % round((total_new - state_count)*100/total_new)
+faculties = context.portal_catalog(portal_type="Faculty")
+
+l = []
+
+
 fac_res = {}
-#fac_res['total'] = total_dict
-faculties = context.portal_catalog(portal_type="Faculty")
+
+dict = {}
+dict['id'] = 'All Faculties'
+dict['title'] = 'All Faculties'
+res = context.students_catalog(entry_session = '06')
+dict['total'] = len(res)
+for state in new_states:
+    res = context.students_catalog(entry_session = '06', review_state = state)
+    dict[state] = len(res)
+    statepercent = state+'_percent'    
+    if dict['total'] > 0:
+        dict[statepercent] = "%.0f" % round(dict[state]*100.0/dict['total'])
+    else:
+        dict[statepercent] = 0   
+#fac_res['all'] = dict
+l.append(dict)
+
 for f in faculties:
     dict = {}
     dict['id'] = f.getId
     dict['title'] = f.Title
-    sid_in_faculty = [s.id for s in context.students_catalog(faculty=f.getId)]
-    new_in_faculty = intersect(new_ids,sid_in_faculty)
-    dict['new'] = rest = len(new_in_faculty)
-    for state in special_states:
-        state_count = len(intersect(state_ids[state], new_in_faculty))
-        rest -= state_count
-        dict[state] = state_count
-    dict['rest'] = rest
-    fac_res[f.getId] = dict
-#set_trace()    
-##for sid,review_state in new_ids:
-##    scat_res = context.students_catalog(id = sid)
-##    if not scat_res:
-##        continue
-##    student = scat_res[0]
-##    faculty = student.faculty
-##    if not fac_res.has_key(faculty):
-##        continue
-##    if review_state in special_states:
-##        fac_res[faculty][review_state] = fac_res[faculty][review_state] + 1
-##    else:
-##        fac_res[faculty]['rest'] = fac_res[faculty]['rest'] + 1
-l = []
-l.append(total_dict)
-fac_ids = [f.getId for f in faculties]
-fac_ids.sort()
-check_dict = {}
-check_dict['id'] = 'Check'
-check_dict['new'] = 0
-check_dict['new_percent'] = 0
-check_dict['rest'] = 0
-check_dict['rest_percent'] = 0
-for state in special_states:
-    check_dict[state] = 0
-    check_dict["%s_percent" % state] = 0
-    
-for f in fac_ids:
-    total_fac = fac_res[f]['new']
-    check_dict['new'] = check_dict['new'] + total_fac
-    check_dict['rest'] = check_dict['rest'] + fac_res[f]['rest']
-    for state in special_states:
-        check_dict[state] = check_dict[state] + fac_res[f][state]
-        if total_fac != 0:
-            fac_res[f]['%s_percent' % state] = "%.0f" % round(fac_res[f][state]*100/total_fac)
+    res = context.students_catalog(entry_session = '06', faculty = f.getId)
+    dict['total'] = len(res)
+    for state in new_states:
+        res = context.students_catalog(entry_session = '06', faculty = f.getId, review_state = state)
+        dict[state] = len(res)
+        statepercent = state+'_percent'
+        if dict['total'] > 0:
+            dict[statepercent] = "%.0f" % round(dict[state]*100.0/dict['total'])
         else:
-            fac_res[f]['%s_percent' % state] = "%.0f" % 0.0
-    if total_fac != 0:
-        fac_res[f]['rest_percent'] = "%.0f" % round(fac_res[f]['rest']*100/total_fac)
-    else:
-        fac_res[f]['rest_percent'] = "%.0f" % 0.0
-    l.append(fac_res[f])
-l.append(check_dict)    
+            dict[statepercent] = 0    
+    #fac_res[f.getId] = dict
+    l.append(dict)
 
 return l
 
+
Index: eUP_SRP/trunk/skins/waeup_student/getNewStudentStatistics_old.py
===================================================================
--- /WAeUP_SRP/trunk/skins/waeup_student/getNewStudentStatistics_old.py	(revision 1760)
+++ 	(revision )
@@ -1,127 +1,0 @@
-## Script (Python) "getNewStudentStatistics"
-##bind container=container
-##bind context=context
-##bind namespace=
-##bind script=script
-##bind subpath=traverse_subpath
-##parameters=
-##title=
-##
-# $Id$
-"""
-return Student Statistics
-"""
-import logging
-logger = logging.getLogger('Skins.getNewStudentStatistics')
-
-try:
-    from Products.AdvancedQuery import Eq, Between, Le,In, Ge,MatchRegexp
-    aq_portal = context.portal_catalog.evalAdvancedQuery
-    aq_students = context.students_catalog.evalAdvancedQuery
-except:
-    evalAdvancedQuery = None
-logger.info('%s invoked statistics' % context.portal_membership.getAuthenticatedMember())
-l = []
-if not context.isStaff():
-    return l
-dep = {}
-
-dep['id'] = "All Faculties"
-
-freshquery = Eq('level','100') | (Eq('level','200') & Eq('entry_mode','DE'))
-total_new = aq_students(freshquery)
-total_new = float(len(total_new))
-##newquery = Eq('portal_type','StudentApplication') & MatchRegexp('SearchableText',r'^6*')
-##total_new = aq_portal(newquery)
-##total_new = float(len(total_new))
-dep['new'] = "%.0f" % total_new
-
-
-#from Products.zdb import set_trace;set_trace()
-
-adm_res = context.portal_catalog(review_state ='admitted')
-adm_ids = [r.getId for r in adm_res]
-adm = len(adm_res)
-dep['admitted'] = adm
-dep['admitted_percent'] =  "%.0f" % round(adm*100/total_new)
-
-cpe_res = context.portal_catalog(review_state ='clearance_pin_entered')
-cpe_ids = [r.getId for r in cpe_res]
-cpe = len(cpe_res)
-dep['clearance_pin_entered'] = cpe
-dep['clearance_pin_entered_percent'] = "%.0f" % round(cpe*100/total_new)
-
-cr_res = context.portal_catalog(review_state='clearance_requested')
-cr_ids = [r.getId for r in cr_res]
-cr = len(cr_res)
-dep['clearance_requested'] = cr
-dep['clearance_requested_percent'] = "%.0f" % round(cr*100/total_new)
-
-cav_res = context.portal_catalog(review_state ='cleared_and_validated')
-cav_ids = [r.getId for r in cav_res]
-cav = len(cav_res)
-dep['cleared_and_validated'] = cav
-dep['cleared_and_validated_percent'] = "%.0f" % round(cav*100/total_new)
-
-or_res = context.portal_catalog(review_state='objection_raised')
-or_ids = [r.getId for r in or_res]
-ora = len(or_res)
-dep['objection_raised'] = ora
-dep['objection_raised_percent'] = "%.0f" % round(ora*100/total_new)
-
-total_sfp = total_new - (cav + cr + cpe + adm + ora)
-dep['rest'] = int(total_sfp)
-dep['rest_percent'] = "%.0f" % round(total_sfp*100/total_new)
-
-
-l.append(dep)
-fs = context.portal_catalog(portal_type="Faculty")
-for fid in [f.getId for f in fs]:
-    dep = {}
-    dep['id'] = fid
-    fquery = Eq('faculty',fid)
-    fac_res = aq_students(fquery & freshquery)
-    fac_ids = [r.id for r in fac_res]
-    total = float(len(fac_res))
-
-    if total == 0:
-        continue
-
-    dep['new'] = "%.0f" % total
-
-    adm = len([s for s in fac_ids if s in adm_ids])
-    dep['admitted'] = adm
-    dep['admitted_percent'] = 0
-    if total:
-        dep['admitted_percent'] = "%.0f" % round(adm*100/total)
-
-    cpe = len([s for s in fac_ids if s in cpe_ids])
-    dep['clearance_pin_entered'] = cpe
-    dep['clearance_pin_entered_percent'] = 0
-    if total:
-        dep['clearance_pin_entered_percent'] = "%.0f" % round(cpe*100/total)
-    cr = len([s for s in fac_ids if s in cr_ids])
-    dep['clearance_requested'] = cr
-    dep['clearance_requested_percent'] = 0
-    if total:
-        dep['clearance_requested_percent'] = "%.0f" % round(cr*100/total)
-    cav = len([s for s in fac_ids if s in cav_ids])
-    dep['cleared_and_validated'] = cav
-    dep['cleared_and_validated_percent'] = 0
-    if total:
-        dep['cleared_and_validated_percent'] = "%.0f" % round(cav*100/total)
-
-    ora = len([s for s in fac_ids if s in or_ids])
-    dep['objection_raised'] = ora
-    dep['objection_raised_percent'] = 0
-    if total:
-        dep['objection_raised_percent'] = "%.0f" % round(ora*100/total)
-
-    rest = int(total - (cav + cr + cpe + adm + ora))
-    dep['rest'] = rest
-    dep['rest_percent'] = "%.0f" % round(rest*100/total)
-
-    l.append(dep)
-
-return l
-
Index: /WAeUP_SRP/trunk/skins/waeup_student/statistics_new_view.pt
===================================================================
--- /WAeUP_SRP/trunk/skins/waeup_student/statistics_new_view.pt	(revision 1760)
+++ /WAeUP_SRP/trunk/skins/waeup_student/statistics_new_view.pt	(revision 1761)
@@ -1,12 +1,12 @@
 <metal:body use-macro="here/main_template/macros/master">
   <metal:main fill-slot="main">
-  <metal:block tal:define="departments context/getNewStudentStatistics;
+  <metal:block tal:define="faculties context/getNewStudentStatistics;
                         mtool here/portal_membership;
                         member mtool/getAuthenticatedMember;">       
 
-      <span tal:condition="not: departments">
+      <span tal:condition="not: faculties">
         <span tal:content="here/illegal_view" />
       </span>
-      <span tal:condition="departments">
+      <span tal:condition="faculties">
   
       <strong>
@@ -33,11 +33,14 @@
             <th align="right">CR</th>
             <th align="right">VC</th>
-            <th align="right">SFP+</th>
+            <th align="right">SFP</th>
+            <th align="right">CR</th>
+            <th align="right">CV</th>
+
           </tr>
-          <tr tal:repeat="d departments"
+          <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="80px" align="right">
-                <span tal:content="d/new" />
+                <span tal:content="d/total" />
               </td>
               <td width="80px" align="right"> 
@@ -62,7 +65,16 @@
               </td>
               <td width="80px" align="right"> 
-                <span tal:content="d/rest" />
-                (<span tal:content="d/rest_percent" />%)
-              </td>     
+                <span tal:content="d/school_fee_paid" />
+                (<span tal:content="d/school_fee_paid_percent" />%)
+              </td>
+              <td width="80px" align="right"> 
+                <span tal:content="d/courses_registered" />
+                (<span tal:content="d/courses_registered_percent" />%)
+              </td>
+              <td width="80px" align="right"> 
+                <span tal:content="d/courses_validated" />
+                (<span tal:content="d/courses_validated_percent" />%)
+              </td>                                          
+
           </tr>
         </table>
@@ -74,5 +86,7 @@
         <tr><td>CR: </td> <td>Clearance requested</td></tr>
         <tr><td>VC: </td> <td>Validated and cleared</td></tr>
-        <tr><td>SFP+: </td> <td>School fee paid and further</td></tr>
+        <tr><td>SFP: </td> <td>School fee paid</td></tr>
+        <tr><td>CR: </td> <td>Course list registered</td></tr>
+        <tr><td>CV: </td> <td>Course list validated</td></tr>                
         </table>
       </span>
