Index: WAeUP_SRP/branches/joachim-event-branch/WAeUPTables.py
===================================================================
--- WAeUP_SRP/branches/joachim-event-branch/WAeUPTables.py	(revision 1672)
+++ WAeUP_SRP/branches/joachim-event-branch/WAeUPTables.py	(revision 1673)
@@ -278,4 +278,16 @@
 ###)
 
+class OnlinePaymentsImport(WAeUPTable): ###(
+
+    meta_type = 'WAeUP Online Payment Transactions'
+    name = "online_payments_import"
+    key = "order_id"
+    def __init__(self):
+        WAeUPTable.__init__(self, self.name)
+
+
+InitializeClass(CoursesCatalog)
+###)
+
 class ReturningImport(WAeUPTable): ###(
 
Index: WAeUP_SRP/branches/joachim-event-branch/WAeUPTool.py
===================================================================
--- WAeUP_SRP/branches/joachim-event-branch/WAeUPTool.py	(revision 1672)
+++ WAeUP_SRP/branches/joachim-event-branch/WAeUPTool.py	(revision 1673)
@@ -532,3 +532,129 @@
     ###)
 
+    security.declareProtected(ModifyPortalContent,"getInvalidCallbackTransactions")###(
+    def getCallbacksFromLog(self,filename):
+        """fix Online Payment Transactions from Z2.log entries"""
+        import transaction
+        import random
+        from cgi import parse_qs
+        from urlparse import urlparse
+        #from pdb import set_trace
+        wftool = self.portal_workflow
+        current = DateTime.DateTime().strftime("%d-%m-%y_%H_%M_%S")
+        students_folder = self.portal_url.getPortalObject().campus.students
+        s = r'(?P<client_ip>\S+) - (?P<member_id>\S+) \['
+        s += r'(?P<date>.*)\] "(?P<get>.*)" (?P<codes>\d+ \d+) "'
+        s += r'(?P<intersw>.*)" "(?P<agent>.*)"'
+        data = re.compile(s)
+        start = True
+        tr_count = 1
+        total = 0
+        #name = 'pume_results'
+        #name = 'epaymentsuccessful_z2log2'
+        name = filename
+        no_import = []
+        imported = []
+        logger = logging.getLogger('WAeUPTool.getFailedTransactions')
+        try:
+            transactions = open("%s/import/%s" % (i_home,name),"rb").readlines()
+        except:
+            logger.error('Error reading %s' % name)
+            return
+        tas = []
+        for line in transactions:
+            dict = {}
+            items = data.search(line)
+            dict['idict'] = idict = items.groupdict()
+            #print idict
+            #from pdb import set_trace;set_trace()
+            urlparsed = urlparse(idict['get'][4:])
+            #print urlparsed
+            path = urlparsed[2].split('/')
+            dict['student_id'] = student_id = path[8]
+            dict['payment_id'] = payment_id = path[10]
+            dict['qs_dict'] = qs_dict = parse_qs(urlparsed[4])
+            tas.append(dict)
+            tr_count += 1
+        return tas
+    ###)
+
+    security.declareProtected(ModifyPortalContent,"importOnlinePaymentTransactions")###(
+    def importOnlinePaymentTransactions(self):
+        """load Online Payment Transactions from CSV values"""
+        import transaction
+        import random
+        #from pdb import set_trace
+        current = DateTime.DateTime().strftime("%d-%m-%y_%H_%M_%S")
+        opt = self.online_payments_import
+        students_folder = self.portal_url.getPortalObject().campus.students
+        start = True
+        tr_count = 1
+        total = 0
+        #name = 'pume_results'
+        name = 'OnlineTransactions'
+        no_import = []
+        imported = []
+        logger = logging.getLogger('WAeUPTool.importOnlinePaymentTransactions')
+        try:
+            transactions = csv.DictReader(open("%s/import/%s.csv" % (i_home,name),"rb"))
+        except:
+            logger.error('Error reading %s.csv' % name)
+            return
+        for pay_transaction in transactions:
+            if start:
+                start = False
+                logger.info('Start loading from %s.csv' % name)
+                s = ','.join(['"%s"' % fn for fn in pay_transaction.keys()])
+                no_import.append('%s,"Error"' % s)
+                format = ','.join(['"%%(%s)s"' % fn for fn in pay_transaction.keys()])
+                format_error = format + ',"%(Error)s"'
+            data = {}
+
+            # format of the first file sent from Tayo
+            #data['datetime'] = date = DateTime.DateTime(pay_transaction['Date'])
+            #data['student_id'] = student_id = pay_transaction['Payer ID']
+            #data['order_id'] = order_id = pay_transaction['Order ID (Tranx Ref)']
+            #data['response_code'] = response_code = pay_transaction['Resp Code']
+            #data['amount'] = amount = pay_transaction['Amount']
+
+            # format of the second file sent from Tayo
+            data['datetime'] = date = 0
+            data['student_id'] = student_id = pay_transaction['Payer ID']
+            data['order_id'] = order_id = pay_transaction['Order ID (Tranx Ref)']
+            data['response_code'] = response_code = '00'
+            data['amount'] = amount = pay_transaction['Amount']
+
+            dup = False
+            if response_code == "12":
+                continue
+            try:
+                opt.addRecord(**data)
+            except ValueError:
+                dup = True
+            #from pdb import set_trace;set_trace()
+            if dup:
+                if response_code == "00":
+                    opt.modifyRecord(**data)
+                else:
+                    pay_transaction['Error'] = "Duplicate order Id"
+                    no_import.append( format_error % pay_transaction)
+                    logger.info("dupplicate order_id %(order_id)s for %(student_id)s %(response_code)s" % data)
+                    continue
+            tr_count += 1
+            if tr_count > 1000:
+                if len(no_import) > 0:
+                    open("%s/import/%s_not_imported%s.csv" % (i_home,name,current),"a").write(
+                             '\n'.join(no_import) + '\n')
+                    no_import = []
+                em = '%d transactions committed\n' % (tr_count)
+                transaction.commit()
+                regs = []
+                logger.info(em)
+                total += tr_count
+                tr_count = 0
+        open("%s/import/%s_not_imported%s.csv" % (i_home,name,current),"a").write(
+                                                '\n'.join(no_import))
+        return self.REQUEST.RESPONSE.redirect("%s" % self.REQUEST.get('URL1'))
+    ###)
+
 InitializeClass(WAeUPTool)
Index: WAeUP_SRP/branches/joachim-event-branch/skins/waeup_student/getNewStudentStatistics.py
===================================================================
--- WAeUP_SRP/branches/joachim-event-branch/skins/waeup_student/getNewStudentStatistics.py	(revision 1672)
+++ WAeUP_SRP/branches/joachim-event-branch/skins/waeup_student/getNewStudentStatistics.py	(revision 1673)
@@ -12,112 +12,114 @@
 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
+    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())
-l = []
 if not context.isStaff():
     return l
-dep = {}
+total_dict = {}
 
-dep['id'] = "All Faculties"
+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))
-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)
+##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',
+                   'clearance_pin_entered',
+                   'clearance_requested',
+                   'cleared_and_validated',
+                   'objection_raised',
+                   )
+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)
+fac_res = {}
+#fac_res['total'] = total_dict
+faculties = context.portal_catalog(portal_type="Faculty")
+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)
+        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)    
 
 return l
Index: WAeUP_SRP/branches/joachim-event-branch/skins/waeup_student/getNewStudentStatistics_old.py
===================================================================
--- WAeUP_SRP/branches/joachim-event-branch/skins/waeup_student/getNewStudentStatistics_old.py	(revision 1673)
+++ WAeUP_SRP/branches/joachim-event-branch/skins/waeup_student/getNewStudentStatistics_old.py	(revision 1673)
@@ -0,0 +1,127 @@
+## 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/branches/joachim-event-branch/skins/waeup_student/list_students.py
===================================================================
--- WAeUP_SRP/branches/joachim-event-branch/skins/waeup_student/list_students.py	(revision 1672)
+++ WAeUP_SRP/branches/joachim-event-branch/skins/waeup_student/list_students.py	(revision 1673)
@@ -12,4 +12,12 @@
 export student_list
 """
+try:
+    from Products.zdb import set_trace
+except:
+    def set_trace():
+        pass
+from Products.AdvancedQuery import Eq, Between, Le,In,MatchRegexp
+aq_portal = context.portal_catalog.evalAdvancedQuery
+aq_students = context.students_catalog.evalAdvancedQuery
 request = context.REQUEST
 setheader = request.RESPONSE.setHeader
@@ -33,6 +41,19 @@
 lines.append(','.join(fields))
 format = '"%(' + ')s","%('.join(fields) + ')s"'
-cleared = context.portal_catalog(review_state = "cleared_and_validated")
+#cleared = context.portal_catalog(review_state = "cleared_and_validated")
+query = In('review_state',('cleared_and_validated',
+                           'school_fee_paid',
+                           'courses_registered',
+                           'courses_validated'))
+cleared = aq_portal(query)
+newquery = Eq('portal_type','StudentApplication') & MatchRegexp('SearchableText',r'^6*')
+#newquery = MatchRegexp('SearchableText','^5*')
+new_students = aq_portal(newquery)
+new_sids = []
+for ns in new_students:
+    new_sids.append(ns.getPath().split('/')[-2])
 for student in cleared:
+    if student.getId not in new_sids:
+        continue
     erg = scat(id=student.getId)
     if not erg:
Index: WAeUP_SRP/branches/joachim-event-branch/skins/waeup_utilities/readOnlinePaymentsFromLog.py
===================================================================
--- WAeUP_SRP/branches/joachim-event-branch/skins/waeup_utilities/readOnlinePaymentsFromLog.py	(revision 1673)
+++ WAeUP_SRP/branches/joachim-event-branch/skins/waeup_utilities/readOnlinePaymentsFromLog.py	(revision 1673)
@@ -0,0 +1,117 @@
+## Script (Python) "search_pins"
+##bind container=container
+##bind context=context
+##bind namespace=
+##bind script=script
+##bind subpath=traverse_subpath
+##parameters=
+##title=
+##
+# $Id$
+"""
+read the successfull epayments from an extract of Z2.log
+this extract must be created with
+
+cat /zope/instances/uniben1/log/Z2.log.1 | grep epayment_cb | grep RespCode=00 
+> /zope/instances/uniben1/import/successfullepaymentsDDMMYY.log
+
+in /zope/instances/uniben1/import/ are already all files from 25.3.07
+
+"""
+import logging
+logger = logging.getLogger('Skins.readOnlinePaymentsFromLog')
+
+request = context.REQUEST
+session = request.SESSION
+response = request.RESPONSE
+setheader = request.RESPONSE.setHeader
+import DateTime
+
+def rwrite(s):
+    response.setHeader('Content-type','text/html; charset=ISO-8859-15')
+    response.write('%s<br>\r\n' % s)
+
+wftool = context.portal_workflow
+mtool = context.portal_membership
+member = mtool.getAuthenticatedMember()
+roles = member.getRolesInContext(context)
+retcat = context.returning_import
+rcat = context.results_import
+scat = context.students_catalog
+from Products.AdvancedQuery import Eq, Between, Le,In
+aq_students = context.students_catalog.evalAdvancedQuery
+students_folder = context.portal_url.getPortalObject().campus.students
+resp_codes = (("x_RespDesc","resp_desc"),
+      ("x_RespPayRef","resp_pay_reference"),
+      ("x_RespCode","resp_code"),
+      ("x_CardNum","resp_card_num"),
+      ("x_ApprAmt","resp_approved_amount"),
+      )
+count = 0
+correct = 0
+approved = 0
+tas = context.waeup_tool.getCallbacksFromLog('successfullepayments260307.log')
+for ta in tas:
+    count += 1
+    student_id = ta['student_id']
+    payment_id = ta['payment_id']
+    qs_dict = ta['qs_dict']
+    if not students_folder.hasObject(student_id):
+        rwrite("no student %s" % student_id)
+        continue
+    student_obj = getattr(students_folder,student_id)
+    if not student_obj.hasObject('payments'):
+        rwrite("no payments for student %s" % student_id)
+        continue
+    payments = getattr(student_obj,'payments')
+    if not payments.hasObject(payment_id):
+        rwrite("no payment %s for student %s" % (payment_id,student_id))
+        continue
+    payment_obj = getattr(payments,payment_id)
+    payment_doc = payment_obj.getContent()
+    pdoc = {}
+    for rc,key in resp_codes:
+        pdoc[key] = getattr(payment_doc,key)
+    readin = {}
+    for rc,pdk in resp_codes:
+        readin[pdk] = qs_dict.get(rc)[0]
+    response_code = readin['resp_code']
+    if payment_doc.resp_code != response_code:
+        rwrite('"%d","%d","%s","%s","%s","%s"' % (
+                                                  count,correct,
+                                                  student_id,
+                                                  payment_id,
+                                                  response_code,
+                                                  payment_doc.resp_code
+                                                  ))
+    elif payment_doc.resp_code == response_code:
+        correct +=1
+        rwrite('"%d","%d","%s","%s","%s","%s"' % (
+                                                  count,correct,
+                                                  student_id,
+                                                  payment_id,
+                                                  response_code,
+                                                  payment_doc.resp_code
+                                                  ))
+    if payment_doc.resp_code == "" and response_code == "00":
+        pd = {}
+        review_state = wftool.getInfoFor(payment_obj,'review_state',None)
+        if review_state != "opened":
+            logger.info('payment object of %s closed' % (student_id))
+            continue
+        review_state = wftool.getInfoFor(student_obj,'review_state',None)
+        if review_state != "cleared_and_validated":
+            logger.info('%s review_state = %s' % (student_id,review_state))
+            continue
+        pd['resp_code'] = 'IP'
+        pd['resp_desc'] = 'Payment approved by import, %s' % (DateTime.DateTime())
+        payment_doc.edit(mapping=pd)
+        if payment_doc.type_description.startswith('School Fee'):
+            wftool.doActionFor(student_obj,'pay_school_fee')
+        logger.info('%s approves epayment for %s by import' % (member,student_id))
+        wftool.doActionFor(payment_obj,'close')
+        approved += 1
+        if approved > 50:
+            context.waeup_tool.doCommit()
+            logger.info('%s transactions commited' % (approved))
+            approved = 0
Index: WAeUP_SRP/branches/joachim-event-branch/skins/waeup_utilities/ti_182_resolve.py
===================================================================
--- WAeUP_SRP/branches/joachim-event-branch/skins/waeup_utilities/ti_182_resolve.py	(revision 1673)
+++ WAeUP_SRP/branches/joachim-event-branch/skins/waeup_utilities/ti_182_resolve.py	(revision 1673)
@@ -0,0 +1,126 @@
+## Script (Python) "getNewStudentStatistics"
+##bind container=container
+##bind context=context
+##bind namespace=
+##bind script=script
+##bind subpath=traverse_subpath
+##parameters=
+##title=
+##
+# $Id$
+"""
+resolve ticket #182
+"""
+try:
+    from Products.zdb import set_trace
+except:
+    def set_trace():
+        pass
+import logging
+#>>>>>>>>>>>>>>>><
+logger = logging.getLogger('Skins.ti_182_resolve')
+#logger.info('already done on 26.3.07 by joachim')
+#return
+#<<<<<<<<<<<<<<<<<
+request = context.REQUEST
+session = request.SESSION
+response = request.RESPONSE
+setheader = request.RESPONSE.setHeader
+students = context.portal_url.getPortalObject().campus.students
+#from string import Template
+def intersect(m,n):
+    return [i for i in m if i in n]
+
+def rwrite(s):
+    response.setHeader('Content-type','text/html; charset=ISO-8859-15')
+    response.write("%s<br>\n\r" % s)
+def getObject(outer,object):
+    if outer.hasObject(object):
+        return getattr(outer,object)
+    return None
+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
+
+
+#freshquery = Eq('level','100') | (Eq('level','200') & Eq('entry_mode','DE'))
+#total_new = aq_students(freshquery)
+##query = In('review_state',('cleared_and_validated',
+##                           'school_fee_paid',
+##                           'courses_registered',
+##                           'courses_validated'))
+##cleared = aq_portal(query)
+##rwrite("Cleared and beyond students: %d" % len(cleared))
+##cleared_ids = [s.getId for s in cleared]
+newquery = Eq('portal_type','StudentApplication') & MatchRegexp('SearchableText',r'^6*')
+new_students = aq_portal(newquery)
+new_ids = [r.getPath().split('/')[-2] for r in new_students]
+rwrite("New students: %d" % len(new_ids))
+#diff_new_cleared = [i for i in new_ids if i not in cleared_ids]  
+#diff_cleared_new = [i for i in cleared_ids if i not in new_ids]  
+##special_states =  ('admitted',
+##                   'clearance_pin_entered',
+##                   'clearance_requested',
+##                   'cleared_and_validated',
+##                   'objection_raised',
+##                   )
+##special_query = In('review_state',special_states)
+##special = aq_portal(special_query)
+##special_ids = [s.getId for s in special]
+##rwrite("New special students: %d" % len(special_ids))
+admitted_query = Eq('review_state','admitted')
+admitted = aq_portal(admitted_query)
+admitted_ids = [s.getId for s in admitted]
+rwrite("Admitted students: %d" % len(admitted_ids))
+##faculties = context.portal_catalog(portal_type="Faculty")
+##fac_ids = [f.getId for f in faculties]
+##fac_query = In('faculty',fac_ids)
+##faculties_students = aq_students(fac_query)
+##faculties_student_ids = [s.id for s in faculties_students]
+##set_trace()
+count = 0
+for sid in admitted_ids:
+    if sid not in new_ids:
+        if not count:
+            rwrite('Students with review_state admitted and jamb_reg_no not beginning with 6') 
+        count += 1
+        erg = context.students_catalog(id=sid)
+        if not erg:
+            set_trace()
+            continue
+        student = erg[0]
+        dict = context.getFormattedStudentEntry(student)
+        dict['count'] = count
+        dict['review_state'] = 'admitted'
+        rwrite('"%(count)d","%(id)s","%(name)s","%(jamb_reg_no)s","%(faculty)s","%(entry_mode)s,"%(review_state)s,"%(level)s",' % dict)
+        
+##retcount = 0
+##count = 0
+##newc = 0
+###set_trace()
+##for student in cleared:
+##    erg = context.students_catalog(id=student.getId)
+##    if not erg:
+##        set_trace()
+##        continue
+##    if not erg[0].jamb_reg_no.startswith('6'):
+##        retcount += 1
+##        continue
+##    newc += 1
+##    if not student.getId in special_ids:
+##        count += 1
+####        dict = context.getFormattedStudentEntry(student)
+####        dict['review_state'] = 'unknown'
+####        dict['count'] = count
+####        res = context.portal_catalog(portal_type='Student',id = student.getId)
+####        if res:
+####            rs = dict['review_state'] = res[0].review_state
+####            rwrite('"%(count)d","%(id)s","%(name)s","%(jamb_reg_no)s","%(matric_no)s","%(entry_mode)s,"%(level)s","%(review_state)s"' % dict)
+##rwrite("Cleared not in special: %d" % count)
+##rwrite("Returning students: %d" % retcount)
+##rwrite("New cleared students: %d" % newc)
+rwrite("Finished")
+
