Index: WAeUP_SRP/trunk/PatchCatalogToolXMLAdapter.py
===================================================================
--- WAeUP_SRP/trunk/PatchCatalogToolXMLAdapter.py	(revision 1619)
+++ WAeUP_SRP/trunk/PatchCatalogToolXMLAdapter.py	(revision 1620)
@@ -26,7 +26,6 @@
     new_indexes = []
     new_columns = []
-    if na[0][1] in ("WAeUP Table"):
-        not_found = False
-    elif na[0][1] == "CMF Catalog":
+    #from pdb import set_trace; set_trace()
+    if na[0][1] == "CMF Catalog":
         #print na[1][1]
         not_found = False
@@ -49,9 +48,9 @@
             not_found = True
     if not_found:
-        self._initProperties(node)
-        self._initObjects(node)
+        #self._initProperties(node)
+        #self._initObjects(node)
         self._initIndexes(node)
         self._initColumns(node)
-        self._refreshCatalog()
+        #self._refreshCatalog()
 
     self._logger.info("Catalog tool imported.")
Index: WAeUP_SRP/trunk/WAeUPTables.py
===================================================================
--- WAeUP_SRP/trunk/WAeUPTables.py	(revision 1619)
+++ WAeUP_SRP/trunk/WAeUPTables.py	(revision 1620)
@@ -22,8 +22,9 @@
 from Globals import InitializeClass
 from Products.ZCatalog.ZCatalog import ZCatalog
+from Products.ZCatalog.ProgressHandler import ZLogHandler
 from AccessControl import ClassSecurityInfo
 from Products.CMFCore.permissions import ModifyPortalContent
 
-import DateTime
+import DateTime,time
 import csv,re
 import logging
@@ -48,4 +49,21 @@
     implements(IWAeUPTable)
     security = ClassSecurityInfo()
+
+    def refreshCatalog(self, clear=0, pghandler=None):
+        """ don't refresh for a normal table """
+
+        if self.REQUEST and self.REQUEST.RESPONSE:
+            self.REQUEST.RESPONSE.redirect(
+              URL1 +
+              '/manage_catalogAdvanced?manage_tabs_message=Catalog%20refresh%20not%20implemented')
+
+    def manage_catalogClear(self, REQUEST=None, RESPONSE=None, URL1=None):
+        """ clears the whole enchilada """
+        #self._catalog.clear()
+
+        if REQUEST and RESPONSE:
+            RESPONSE.redirect(
+              URL1 +
+              '/manage_catalogAdvanced?manage_tabs_message=Catalog%20Clearing%20disabled')
 
     def addRecord(self, **data):
@@ -75,7 +93,4 @@
             raise KeyError("No record for uid %s" % uid)
         record = records[0]
-        record_data = {}
-        for field in self.schema() + self.indexes():
-            record_data[field] = getattr(record, field)
         record_data = {}
         for field in self.schema() + self.indexes():
@@ -210,11 +225,215 @@
 
 class StudentsCatalog(WAeUPTable): ###(
+    security = ClassSecurityInfo()
 
     meta_type = 'WAeUP Students Catalog'
     name = "students_catalog"
     key = "id"
+    interesting_types = ('Student',
+                         'StudentApplication',
+                         'StudentCLearance',
+                         'StudentPersonal',
+                         'StudentStudyCourse',
+                         )
+                         
     def __init__(self):
         WAeUPTable.__init__(self, 'students_catalog')
-
+        return
+    
+    def get_review_state(self,sid,application_doc,clearance_doc,personal_doc,study_course_doc): ###(
+        "return the students review_state from portal_catalog"
+        cat_res = self.portal_catalog(id = sid)
+        if len(cat_res) != 1:
+            return None
+        return cat_res[0].review_state
+
+    def get_course(self,sid,application_doc,clearance_doc,personal_doc,study_course_doc):
+        "return the students study_course"
+        if study_course_doc is None:
+            return None
+        return getattr(study_course_doc,'study_course',None)
+
+    def get_department(self,sid,application_doc,clearance_doc,personal_doc,study_course_doc):
+        "return the students department"
+        if study_course_doc is None:
+            return None
+        certificate_res = self.portal_catalog(id = study_course_doc.study_course)
+        if len(certificate_res) != 1:
+            return None
+        return certificate_res[0].getPath().split('/')[-3]
+
+    def get_email(self,sid,application_doc,clearance_doc,personal_doc,study_course_doc):
+        "return the students email from the personal"
+        if personal_doc is None:
+            return None
+        return getattr(personal_doc,'email',None)
+
+    def get_entry_mode(self,sid,application_doc,clearance_doc,personal_doc,study_course_doc):
+        "return the students entry_mode from the application"
+        if application_doc is None:
+            return None
+        return getattr(application_doc,'entry_mode',None)
+
+    def get_jamb_reg_no(self,sid,application_doc,clearance_doc,personal_doc,study_course_doc):
+        "return the students jamb_reg_no from the application"
+        if application_doc is None:
+            return None
+        return getattr(application_doc,'jamb_reg_no',None)
+    
+    def get_faculty(self,sid,application_doc,clearance_doc,personal_doc,study_course_doc):
+        "return the students faculty"
+        if study_course_doc is None:
+            return None
+        certificate_res = self.portal_catalog(id = study_course_doc.study_course)
+        if len(certificate_res) != 1:
+            return None
+        return certificate_res[0].getPath().split('/')[-4]
+
+    def get_level(self,sid,application_doc,clearance_doc,personal_doc,study_course_doc):
+        "return the students study_course"
+        if study_course_doc is None:
+            return None
+        #from pdb import set_trace;set_trace()
+        return getattr(study_course_doc,'current_level',None)
+
+    def get_matric_no(self,sid,application_doc,clearance_doc,personal_doc,study_course_doc):
+        "return the students matric_no from the clearance "
+        if clearance_doc is None:
+            return None
+        return getattr(clearance_doc,'matric_no',None)
+        
+    def get_name(self,sid,application_doc,clearance_doc,personal_doc,study_course_doc):
+        "return the students name from the personal"
+        if personal_doc is None:
+            return None
+        doc = personal_doc
+        return "%s %s %s" % (doc.firstname,doc.middlename,doc.lastname)
+
+    def get_phone(self,sid,application_doc,clearance_doc,personal_doc,study_course_doc):
+        "return the students phone from the personal"
+        if personal_doc is None:
+            return None
+        return getattr(personal_doc,'phone',None)
+
+    def get_sex(self,sid,application_doc,clearance_doc,personal_doc,study_course_doc):
+        "return the students sex from the personal"
+        if personal_doc is None:
+            return None
+        return getattr(personal_doc,'sex',None)
+
+    def get_verdict(self,sid,application_doc,clearance_doc,personal_doc,study_course_doc):
+        "return the students study_course"
+        if study_course_doc is None:
+            return None
+        return getattr(study_course_doc,'current_verdict',None)
+    ###)
+
+    def refreshCatalog(self, clear=0, pghandler=None): ###(
+        """ re-index everything we can find """
+        students_folder = self.portal_url.getPortalObject().campus.students
+        
+        cat = self._catalog
+        paths = self._catalog.uids.items()
+        if clear:
+            paths = tuple(paths)
+            cat.clear()
+
+        num_objects = len(paths)
+        if pghandler:
+            pghandler.init('Refreshing catalog: %s' % self.absolute_url(1), num_objects)
+        for i in xrange(num_objects):
+            if pghandler: pghandler.report(i)
+            p = paths[i]
+            sid = p[0]
+            pcat_res = self.portal_catalog(id=sid) 
+            if len(pcat_res) != 1:
+                continue
+            student_brain = pcat_res[0]
+            student_obj = student_brain.getObject()
+            if student_obj.hasObject('application'):
+                application_doc = getattr(student_obj,'application').getContent()
+            else:
+                application_doc = None
+            if student_obj.hasObject('clearance'):
+                clearance_doc = getattr(student_obj,'clearance').getContent()
+            else:
+                clearance_doc = None
+            if student_obj.hasObject('personal'):
+                personal_doc = getattr(student_obj,'personal').getContent()
+            else:
+                personal_doc = None
+            if student_obj.hasObject('study_course'):
+                study_course_doc = getattr(student_obj,'study_course').getContent()
+            else:
+                study_course_doc = None
+            data = {}
+            data['id'] = sid
+            for field in self.schema():
+                function = getattr(self,"get_%s" % field, None)
+                if function is None:
+                    continue
+                value = function(sid,application_doc,clearance_doc,personal_doc,study_course_doc)
+                if value is not None:
+                    data[field] = value
+            self.modifyRecord(**data)
+        if pghandler: pghandler.finish()
+    ###)
+
+    def manage_catalogReindex(self, REQUEST, RESPONSE, URL1):
+        """ clear the catalog, then re-index everything """
+
+        elapse = time.time()
+        c_elapse = time.clock()
+
+        pgthreshold = self._getProgressThreshold()
+        handler = (pgthreshold > 0) and ZLogHandler(pgthreshold) or None
+        self.refreshCatalog(clear=0, pghandler=handler)
+
+        elapse = time.time() - elapse
+        c_elapse = time.clock() - c_elapse
+
+        RESPONSE.redirect(
+            URL1 +
+            '/manage_catalogAdvanced?manage_tabs_message=' +
+            urllib.quote('Catalog Updated \n'
+                         'Total time: %s\n'
+                         'Total CPU time: %s' % (`elapse`, `c_elapse`)))
+        
+        
+    security.declarePrivate('notify_event_listener')
+    def notify_event_listener(self,event_type,object,infos):
+        "listen for events"
+        pt = object.portal_type
+        mt = object.meta_type
+        students_catalog = self.students_catalog
+        #if pt not in self.interesting_types:
+        #    return
+        #print "%(pt)s\n %(event_type)s \n %(infos)s\n" % vars()
+        if not infos.has_key('rpath'):
+            return
+        if pt == 'Student' and event_type == "workflow":
+            pass
+        elif mt == 'StudentApplication':
+            if event_type not in ('sys_modify_object'):
+                return
+            print "%(pt)s\n %(event_type)s \n %(infos)s\n" % vars()
+            from pdb import set_trace;set_trace()
+            jamb_reg_no = getattr(object,'jamb_reg_no',None)
+            if jamb_reg_no is None:
+                return
+            student_id = infos['rpath'].split('/')[2]
+            self.fixName(student_id)
+            student_entry = students_catalog(id = student_id)[0]
+            if student_entry.jamb_reg_no == jamb_reg_no:
+                return
+            students_catalog.modifyRecord(id = student_id,
+                                          jamb_reg_no = jamb_reg_no)
+        elif mt == 'StudentPersonal':
+            if event_type not in ('sys_modify_object'):
+                return
+            print "%(pt)s\n %(event_type)s \n %(infos)s\n" % vars()
+            student_id = infos['rpath'].split('/')[2]
+            self.fixName(student_id)
+            
 
 InitializeClass(StudentsCatalog)
@@ -234,4 +453,16 @@
 ###)
 
+class OnlinePaymentTransactions(WAeUPTable): ###(
+
+    meta_type = 'WAeUP Online Payment Transactions'
+    name = "online_payment_transactions"
+    key = "order_id"
+    def __init__(self):
+        WAeUPTable.__init__(self, self.name)
+
+
+InitializeClass(CoursesCatalog)
+###)
+
 class ReturningImport(WAeUPTable): ###(
 
Index: WAeUP_SRP/trunk/WAeUPTool.py
===================================================================
--- WAeUP_SRP/trunk/WAeUPTool.py	(revision 1619)
+++ WAeUP_SRP/trunk/WAeUPTool.py	(revision 1620)
@@ -38,9 +38,8 @@
 p_home = package_home(globals())
 i_home = INSTANCE_HOME
-import logging,os
+import DateTime
+import logging
 import transaction
-
-
-
+import csv,re,os
 
 class WAeUPTool(UniqueObject, SimpleItem, ActionProviderBase):
@@ -532,3 +531,72 @@
     ###)
 
+    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_payment_transactions
+        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 = {}
+            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'] 
+            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 commited total %s\n' % (tr_count,total)
+                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/trunk/exportimport.py
===================================================================
--- WAeUP_SRP/trunk/exportimport.py	(revision 1619)
+++ WAeUP_SRP/trunk/exportimport.py	(revision 1620)
@@ -120,4 +120,5 @@
     importWAeUPTable(site.courses_catalog, '', context,'courses_catalog')
     importWAeUPTable(site.payments_catalog, '', context,'payments_catalog')
+    importWAeUPTable(site.online_payment_transactions, '', context,'online_payment_transactions')
     importWAeUPTable(site.portal_pins, '', context,'pins')
     importWAeUPTable(site.portal_pumeresults, '', context,'pumeresults')
Index: WAeUP_SRP/trunk/profiles/default/online_payment_transactions.xml
===================================================================
--- WAeUP_SRP/trunk/profiles/default/online_payment_transactions.xml	(revision 1620)
+++ WAeUP_SRP/trunk/profiles/default/online_payment_transactions.xml	(revision 1620)
@@ -0,0 +1,18 @@
+<?xml version="1.0"?>
+<?xml-stylesheet type="text/xsl" href="catalog.xsl"?>
+<object name="courses_catalog" meta_type="WAeUP Table">
+ <column value="datetime"/>
+ <column value="student_id"/>
+ <column value="order_id"/>
+ <column value="response_code"/>
+ <column value="amount"/>
+ <index name="student_id" meta_type="FieldIndex">
+  <indexed_attr value="student_id"/>
+ </index>
+ <index name="datetime" meta_type="DateIndex">
+  <indexed_attr value="datetime"/>
+ </index>
+ <index name="order_id" meta_type="FieldIndex">
+  <indexed_attr value="order_id"/>
+ </index>
+</object>
Index: WAeUP_SRP/trunk/profiles/default/toolset.xml
===================================================================
--- WAeUP_SRP/trunk/profiles/default/toolset.xml	(revision 1619)
+++ WAeUP_SRP/trunk/profiles/default/toolset.xml	(revision 1620)
@@ -7,4 +7,6 @@
  <required tool_id="payments_catalog"
            class="Products.WAeUP_SRP.WAeUPTables.PaymentsCatalog"/>
+ <required tool_id="online_payment_transactions"
+           class="Products.WAeUP_SRP.WAeUPTables.OnlinePaymentTransactions"/>
  <required tool_id="portal_pins"
            class="Products.WAeUP_SRP.WAeUPTables.PinTable"/>
Index: WAeUP_SRP/trunk/skins/waeup_epayment/check_online_payments.py
===================================================================
--- WAeUP_SRP/trunk/skins/waeup_epayment/check_online_payments.py	(revision 1620)
+++ WAeUP_SRP/trunk/skins/waeup_epayment/check_online_payments.py	(revision 1620)
@@ -0,0 +1,67 @@
+## Script (Python) "check_online_payments"
+##bind container=container
+##bind context=context
+##bind namespace=
+##bind script=script
+##bind subpath=traverse_subpath
+##parameters=
+##title=
+##
+# $Id$
+"""
+payment callback
+"""
+import logging
+logger = logging.getLogger('Skins.check_online_payments')
+from AccessControl import Unauthorized
+import DateTime
+if context.portal_membership.isAnonymousUser():
+    return None
+
+request = context.REQUEST
+response = request.RESPONSE
+students = context.portal_url.getPortalObject().campus.students
+wftool = context.portal_workflow
+mtool = context.portal_membership
+member = mtool.getAuthenticatedMember()
+member_id = str(member)
+student_id = context.getStudentId()
+online_transactions = context.online_payment_transactions
+try:
+    from Products.zdb import set_trace
+except:
+    def set_trace():
+        pass
+def rwrite(s):
+    response.setHeader('Content-type','text/html; charset=ISO-8859-15')
+    response.write("%s<br>\n" % s)
+try:
+    from Products.AdvancedQuery import Eq, Between, Le,In
+    aq_portal = context.portal_catalog.evalAdvancedQuery
+    aq_students = context.students_catalog.evalAdvancedQuery
+except:
+    aq_portal = None
+
+query1 = Eq('portal_type','Payment')
+query2 = ~ Eq('SearchableText',"SC Payment Successful")
+online_payments = aq_portal(query1 & query2)
+set_trace()
+online_transactions = context.online_payment_transactions
+
+for op_brain in online_payments:
+    student_id = op_brain.getPath().split('/')[-3]
+    payment_doc = op_brain.getObject().getContent()
+    order_id = "%s%s" % (student_id[1:],op_brain.getId[1:])
+    transactions = online_transactions(student_id = student_id)
+    if payment_doc.resp_code == "00" and not transactions:
+        rwrite("%s no transaction for successfull payment %s" % (student_id,payment_id))
+        continue
+    for transaction in transactions:
+        t_order_id = transaction.order_id
+        if t_order_id == order_id:
+            rwrite("%s payment %s found bankresponse: %s resp_code: %s" % (student_id,
+                                                                        payment_id,
+                                                                        transaction.response_code,
+                                                                        payment_doc.resp_code
+                                                                        ))
+            continue
Index: WAeUP_SRP/trunk/skins/waeup_epayment/check_transactions.py
===================================================================
--- WAeUP_SRP/trunk/skins/waeup_epayment/check_transactions.py	(revision 1620)
+++ WAeUP_SRP/trunk/skins/waeup_epayment/check_transactions.py	(revision 1620)
@@ -0,0 +1,68 @@
+## Script (Python) "check_transactions"
+##bind container=container
+##bind context=context
+##bind namespace=
+##bind script=script
+##bind subpath=traverse_subpath
+##parameters=
+##title=
+##
+# $Id$
+"""
+payment callback
+"""
+import logging
+logger = logging.getLogger('Skins.check_transactions')
+from AccessControl import Unauthorized
+import DateTime
+if context.portal_membership.isAnonymousUser():
+    return None
+
+request = context.REQUEST
+response = request.RESPONSE
+students = context.portal_url.getPortalObject().campus.students
+wftool = context.portal_workflow
+mtool = context.portal_membership
+member = mtool.getAuthenticatedMember()
+member_id = str(member)
+student_id = context.getStudentId()
+online_transactions = context.online_payment_transactions
+def rwrite(s):
+    response.setHeader('Content-type','text/html; charset=ISO-8859-15')
+    response.write("%s<br>\n" % s)
+correct = 0
+count = 0
+for ot_brain in online_transactions():
+    student_id = ot_brain.student_id
+    if not students.hasObject(student_id):
+        rwrite("%s not found" % student_id)
+        continue
+    student_obj = getattr(students,student_id)
+    if not student_obj.hasObject('payments'):
+        rwrite("%s payments-folder not found" % student_id)
+        continue
+    payments_folder = getattr(student_obj,'payments')
+    payment_id = "p%s" % ot_brain.order_id[6:]
+    if not payments_folder.hasObject(payment_id):
+        rwrite("%s payment %s not found" % (student_id,payment_id))
+        continue
+    payment_doc = getattr(payments_folder,payment_id).getContent()
+    response_code = ot_brain.response_code
+    count +=1
+    if payment_doc.resp_code != response_code:
+        rwrite("%d:%d %s payment %s found bankresponse: %s != resp_code %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 payment %s found bankresponse: %s matches resp_code %s" % (
+                                                                        count,correct,
+                                                                        student_id,
+                                                                        payment_id,
+                                                                        response_code,
+                                                                        payment_doc.resp_code
+                                                                        ))
Index: WAeUP_SRP/trunk/skins/waeup_epayment/requery_payment.py
===================================================================
--- WAeUP_SRP/trunk/skins/waeup_epayment/requery_payment.py	(revision 1619)
+++ WAeUP_SRP/trunk/skins/waeup_epayment/requery_payment.py	(revision 1620)
@@ -10,9 +10,9 @@
 # $Id$
 """
-pay online
+requery online-payment
 """
 from urllib import urlencode
 import logging
-logger = logging.getLogger('Skins.pay_online')
+logger = logging.getLogger('Skins.requery_payment')
 import DateTime
 
@@ -45,5 +45,4 @@
 
 
-info['callback_url'] = "%s/payments/%s/epayment_requery_cb" % (student.absolute_url(),p_id)
 payment = context
 if payment.portal_type != 'Payment':
@@ -51,8 +50,9 @@
 payment_doc = payment.getContent()
 #from Products.zdb import set_trace;set_trace()
-info['order_id'] = payment_doc.order_id
+info['order_id'] = p_id = payment_doc.order_id
+info['callback_url'] = "%s/payments/%s/epayment_requery_cb" % (student.absolute_url(),p_id)
 info['type_description'] = payment_doc.type_description
-info['pay_bill_to'] = payment_doc.pay_bill_to
 info['amount'] = payment_doc.amount
+info['student_id'] = student_id
 logger.info('%(student_id)s requeried online school fee payment for order_id %(order_id)s' % info)
 payment_fields = (('x_SiteID','site_id'),
Index: WAeUP_SRP/trunk/skins/waeup_epayment/requery_payment_form.pt
===================================================================
--- WAeUP_SRP/trunk/skins/waeup_epayment/requery_payment_form.pt	(revision 1619)
+++ WAeUP_SRP/trunk/skins/waeup_epayment/requery_payment_form.pt	(revision 1620)
@@ -3,5 +3,5 @@
                 tal:define="info options/info">
                 
-        <h3>Authorize Online Payment! </h3>
+        <h3>Requery Online Payment! </h3>
         <br />
                 
@@ -12,5 +12,4 @@
           <input type="hidden" tal:attributes="name python:arg[0];value python:arg[1]" />
       </span>          
-      <div>Requery this payment</div>
         <table>
           <tr>
@@ -18,10 +17,4 @@
             Payment:</td>
             <td tal:content="info/type_description"></td>
-          </tr>
-          <tr>
-            <td>
-            Name:
-            </td>
-            <td tal:content="info/pay_bill_to" />
           </tr>
           <tr>
