Index: WAeUP_SRP/trunk/Students.py
===================================================================
--- WAeUP_SRP/trunk/Students.py	(revision 1318)
+++ WAeUP_SRP/trunk/Students.py	(revision 1319)
@@ -617,5 +617,5 @@
         name = 'Admitted'
         no_import = []
-        s = ','.join(['"(%s)"' % fn for fn in csv_fields])
+        s = ','.join(['"%s"' % fn for fn in csv_fields])
         no_import.append('"Error",%s' % s)
         format = '"%(Error)s",' + ','.join(['"%%(%s)s"' % fn for fn in csv_fields])
@@ -841,9 +841,10 @@
         if len(res) > 0:
             regs = [s.matric_no for s in res]
+        #import pdb;pdb.set_trace()
         for student in returning:
             if start:
                 start = False
                 logger.info('start loading from %s.csv' % name)
-                s = ','.join(['"(%s)"' % fn for fn in student.keys()])
+                s = ','.join(['"%s"' % fn for fn in student.keys()])
                 imported.append(s)
                 no_import.append('%s,"Error"' % s)
@@ -851,6 +852,7 @@
                 format_error = format + ',"%(Error)s"'
                 no_certificate = "no certificate %s" % format
-            matric_no = student.get('matric_no').upper()
-            student['matric_no'] = matric_no
+            student['matric_no'] = matric_no = student.get('matric_no').upper()
+            student['Mode_of_Entry'] = entry_mode = student.get('Mode of Entry').upper()
+            student['Permanent_Address'] = perm_address = student.get('Permanent Address')
             if matric_no == '':
                 student['Error'] = "Empty matric_no"
@@ -869,5 +871,4 @@
                 table.addRecord(**student)
             except ValueError:
-                #import pdb;pdb.set_trace()
                 student['Error'] = "Duplicate"
                 no_import.append( format_error % student)
@@ -897,6 +898,118 @@
     ###)
 
-
-
+    security.declareProtected(ModifyPortalContent,"fixAllEntryModeForReturning")###(
+    def fixAllEntryModeForReturning(self):
+        "read all Returning*.csv"
+        ipath = "%s/import/" % i_home
+        names = os.listdir(ipath)
+        #import pdb;pdb.set_trace()
+        for name in names:
+            head,tail = os.path.splitext(name)
+            if head.startswith('Returning')\
+               and tail == '.csv'\
+               and name.find('imported') < 0:
+                self.fixEntryModeForReturning(csv_file=head)
+
+    security.declareProtected(ModifyPortalContent,"fixEntryModeForReturning")###(
+    def fixEntryModeForReturning(self,csv_file=None):
+        """load Returning Studentdata from CSV values"""
+        import transaction
+        import random
+        wftool = self.portal_workflow
+        current = DateTime.DateTime().strftime("%d-%m-%y_%H_%M_%S")
+        students_folder = self.portal_url.getPortalObject().campus.students
+        tr_count = 1
+        total = 0
+        if csv_file is None:
+            name = 'Returning'
+        else:
+            name = csv_file
+        table = self.returning_import
+        st_cat = self.students_catalog
+        no_import = []
+        logger = logging.getLogger('getEntryMode.%s' % name)
+        try:
+            returning = csv.DictReader(open("%s/import/%s.csv" % (i_home,name),"rb"))
+        except:
+            logger.error('Error reading %s.csv' % name)
+            return
+        start = True
+        for student in returning:
+            if start:
+                start = False
+                logger.info('start loading from %s.csv' % name)
+                s = ','.join(['"(%s)"' % fn for fn in student.keys()])
+                no_import.append('%s,"Error"' % s)
+                format = ','.join(['"%%(%s)s"' % fn for fn in student.keys()])
+                format_error = format + ',"%(Error)s"'
+            matric_no = student.get('matric_no')
+            if not matric_no:
+                continue
+            matric_no = matric_no.upper()
+            student['matric_no'] = matric_no
+            if matric_no == '':
+                continue
+            if not table(matric_no = matric_no):
+                student['Error'] = "Not imported yet"
+                no_import.append( format_error % student)
+                continue
+            student_id = None
+            app = None
+            per = None
+            if st_cat(matric_no = matric_no):
+                student_id = st_cat(matric_no = matric_no)[0].id
+                app = getattr(getattr(students_folder,student_id),'application',None)
+                if app is not None:
+                    app_doc = app.getContent()
+                per = getattr(getattr(students_folder,student_id),'personal',None)
+                if per is not None:
+                    per_doc = per.getContent()
+            student['Mode_of_Entry'] = entry_mode = student.get('Mode of Entry').upper()
+            student['Permanent_Address'] = perm_address = student.get('Permanent Address')
+            entry_mode = student['Mode of Entry']
+            if not entry_mode:
+                student['Error'] = "'Mode of Entry' empty"
+                no_import.append( format_error % student)
+                continue
+            try:
+                table.modifyRecord(matric_no = matric_no,
+                                   Mode_of_Entry = entry_mode,
+                                   Permanent_Address = perm_address)
+            except KeyError:
+                student['Error'] = "Not found in returning_import"
+                no_import.append( format_error % student)
+                continue
+            if student_id is not None:
+                try:
+                    st_cat.modifyRecord(id = student_id,
+                                        entry_mode=entry_mode)
+                except KeyError:
+                    student['Error'] = "Not found in students_catalog"
+                    no_import.append( format_error % student)
+                    continue
+            if app is not None:
+                da = {}
+                da['entry_mode'] = entry_mode
+                app_doc.edit(mapping=da)
+            if per is not None:
+                dp = {}
+                dp['perm_address'] = entry_mode
+                per_doc.edit(mapping=dp)
+            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'))
+    ###)
 
     security.declareProtected(ModifyPortalContent,"updateReturningStudents")###(
@@ -993,7 +1106,4 @@
         return self.REQUEST.RESPONSE.redirect("%s" % self.REQUEST.get('URL1'))
     ###)
-
-
-
 
     security.declareProtected(ModifyPortalContent,"importResults")###(
Index: WAeUP_SRP/trunk/WAeUPTool.py
===================================================================
--- WAeUP_SRP/trunk/WAeUPTool.py	(revision 1318)
+++ WAeUP_SRP/trunk/WAeUPTool.py	(revision 1319)
@@ -182,9 +182,7 @@
             student = res[0]
         logger.info('"%s", "creating Datastructure"' % student_id)
-
         #student should not be allowed to perform this transition
         #wftool = self.portal_workflow
         #wftool.doActionFor(student,'return')
-
         certcode_org = student.Coursemajorcode
         certcode = makeCertificateCode(certcode_org)
Index: WAeUP_SRP/trunk/profiles/default/layouts.xml
===================================================================
--- WAeUP_SRP/trunk/profiles/default/layouts.xml	(revision 1318)
+++ WAeUP_SRP/trunk/profiles/default/layouts.xml	(revision 1319)
@@ -33,4 +33,5 @@
  <object name="student_search" meta_type="CPS Layout"/>
  <object name="student_study_level" meta_type="CPS Layout"/>
+ <object name="student_transfer" meta_type="CPS Layout"/>
  <object name="study_level" meta_type="CPS Layout"/>
  <object name="university" meta_type="CPS Layout"/>
Index: WAeUP_SRP/trunk/profiles/default/layouts/student_transfer.xml
===================================================================
--- WAeUP_SRP/trunk/profiles/default/layouts/student_transfer.xml	(revision 1319)
+++ WAeUP_SRP/trunk/profiles/default/layouts/student_transfer.xml	(revision 1319)
@@ -0,0 +1,42 @@
+<?xml version="1.0"?>
+<object name="student_transfer" meta_type="CPS Layout">
+  <property name="layout_create_method"></property>
+  <property name="layout_edit_method"></property>
+  <property name="layout_view_method"></property>
+  <property name="style_prefix">layout_application_</property>
+  <property name="flexible_widgets"/>
+  <property name="validate_values_expr"></property>
+  <widget name="pin" meta_type="Scratchcard Pin Widget">
+    <property name="title">Schoolfee Scratch Card</property>
+    <property name="fields">
+      <element value="payment_id"/>
+    </property>
+    <property name="label">Access Code</property>
+    <property name="label_edit">Access Code</property>
+    <property name="readonly_layout_modes"/>
+    <property name="hidden_layout_modes"/>
+    <property name="hidden_readonly_layout_modes"/>
+    <property name="prefix">CLR</property>
+  </widget>
+  <widget name="transfer_type" meta_type="Select Widget">
+    <property name="title">Transfer Type</property>
+    <property name="fields">
+      <element value="response_desc"/>
+    </property>
+    <property name="is_required">True</property>
+    <property name="label">Select Type</property>
+    <property name="label_edit">Select Type</property>
+    <property name="readonly_layout_modes"/>
+    <property name="hidden_layout_modes"/>
+    <property name="hidden_readonly_layout_modes"/>
+    <property name="vocabulary">student_transfer_types</property>
+  </widget>
+  <table>
+    <row>
+      <cell name="transfer_type"/>
+    </row>
+    <row>
+      <cell name="pin"/>
+    </row>
+  </table>
+</object>
Index: WAeUP_SRP/trunk/profiles/default/students_catalog.xml
===================================================================
--- WAeUP_SRP/trunk/profiles/default/students_catalog.xml	(revision 1318)
+++ WAeUP_SRP/trunk/profiles/default/students_catalog.xml	(revision 1319)
@@ -25,4 +25,7 @@
   <indexed_attr value="faculty"/>
  </index>
+ <index name="entry_mode" meta_type="KeywordIndex">
+  <indexed_attr value="entry_mode"/>
+ </index>
  <index name="department" meta_type="KeywordIndex">
   <indexed_attr value="department"/>
Index: WAeUP_SRP/trunk/profiles/default/vocabularies.xml
===================================================================
--- WAeUP_SRP/trunk/profiles/default/vocabularies.xml	(revision 1318)
+++ WAeUP_SRP/trunk/profiles/default/vocabularies.xml	(revision 1319)
@@ -21,4 +21,5 @@
  <object name="pin_prefixes" meta_type="CPS Vocabulary"/>
  <object name="student_search_mode" meta_type="CPS Vocabulary"/>
+ <object name="student_transfer_types" meta_type="CPS Vocabulary"/>
  <object name="scratch_card_search_mode" meta_type="CPS Vocabulary"/>
  <object name="student_status_voc" meta_type="CPS Vocabulary"/>
Index: WAeUP_SRP/trunk/profiles/default/vocabularies/student_transfer_types.xml
===================================================================
--- WAeUP_SRP/trunk/profiles/default/vocabularies/student_transfer_types.xml	(revision 1319)
+++ WAeUP_SRP/trunk/profiles/default/vocabularies/student_transfer_types.xml	(revision 1319)
@@ -0,0 +1,9 @@
+<?xml version="1.0"?>
+<object name="transfer_types" meta_type="CPS Vocabulary">
+  <property name="title"></property>
+  <property name="title_msgid"></property>
+  <property name="description"></property>
+  <property name="acl_write_roles">Manager</property>
+  <item key="intra" msgid="">Intra Faculty Transfer</item>
+  <item key="inter" msgid="">Inter Faculty Transfer</item>
+</object>
Index: WAeUP_SRP/trunk/skins/waeup_student/request_transfer.py
===================================================================
--- WAeUP_SRP/trunk/skins/waeup_student/request_transfer.py	(revision 1319)
+++ WAeUP_SRP/trunk/skins/waeup_student/request_transfer.py	(revision 1319)
@@ -0,0 +1,82 @@
+## Script (Python) "pay_by_sc"
+##bind container=container
+##bind context=context
+##bind namespace=
+##bind script=script
+##bind subpath=traverse_subpath
+##parameters=
+##title=
+##
+# $Id$
+"""
+pay online
+"""
+import logging
+from urllib import urlencode
+logger = logging.getLogger('EPayment.')
+import DateTime
+lt = context.portal_layouts
+request = context.REQUEST
+students = context.portal_url.getPortalObject().campus.students
+
+student_id = context.getStudentId()
+if student_id is None:
+    return request.RESPONSE.redirect("%s/srp_anonymous_view" % context.portal_url())
+
+student = getattr(students,student_id)
+sbrain = context.students_catalog(id=student_id)[0]
+
+validate = request.has_key("cpsdocument_create_button")
+res,psm,ds = lt.renderLayout(layout_id= 'student_transfer',
+                      schema_id= 'epayment',
+                      context=context,
+                      mapping=validate and request,
+                      ob={},
+                      layout_mode="create",
+                      formaction = "request_transfer",
+                      button = 'Start'
+                      )
+if psm == 'invalid':
+    psm = 'Please correct your errors!'
+    return context.request_transfer_form(rendered = res,
+                                 psm = psm,
+                                 mode = 'edit',
+                                 ds = ds,
+                                 )
+elif psm == '':
+    return context.request_transfer_form(rendered = res,
+                                 psm = None,
+                                 mode = 'edit',
+                                 ds = ds,
+                                 )
+elif psm == 'valid':
+    pass
+if "payments" not in student.objectIds():
+    student.invokeFactory('PaymentsFolder','payments')
+    payments = getattr(student,'payments')
+    d = {}
+    d['Title'] = 'Payments'
+    payments.getContent().edit(mapping=d)
+    wftool.doActionFor(payments,'open')
+else:
+    payments = getattr(student,'payments')
+#from Products.zdb import set_trace; set_trace()
+info = {}
+order_id = ds.get('pin_n')
+p_id = "p%s" % order_id
+now = DateTime.DateTime()
+info['date'] = now
+info['amount'] = "n/a"
+pin = info['order_id'] = ds.get('pin')
+info['type_code'] = "%s" % pin
+info['type_description'] = 'School Fee SC %s' % pin
+payments.invokeFactory('Payment', p_id)
+payment = getattr(payments,p_id)
+wftool = context.portal_workflow
+wftool.doActionFor(payment,'open')
+payment.getContent().edit(mapping=info)
+wftool.doActionFor(payment,'close')
+wftool.doActionFor(student,'pay_school_fee')
+url = "%s/payments" % (student.absolute_url())
+request.RESPONSE.redirect(url)
+
Index: WAeUP_SRP/trunk/skins/waeup_student/request_transfer_form.pt
===================================================================
--- WAeUP_SRP/trunk/skins/waeup_student/request_transfer_form.pt	(revision 1319)
+++ WAeUP_SRP/trunk/skins/waeup_student/request_transfer_form.pt	(revision 1319)
@@ -0,0 +1,23 @@
+<tal:block define="rendered_main options/rendered;
+           portal_status_message options/psm;
+           data_storage options/ds;
+           edition python:1;"
+           >
+  <metal:block define-macro="edit_form">
+    <metal:block use-macro="here/content_lib_master/macros/master">
+      <metal:block fill-slot="header"
+                   tal:define="creation creation|nothing;
+                   edition edition|nothing;
+                   metadata metadata|nothing"
+                   >
+      </metal:block>
+      <metal:block fill-slot="main">
+        <h3>Request a Transfer!</h3>
+        <br />
+        <div tal:replace="structure rendered_main" />
+      </metal:block>
+      <metal:block fill-slot="sub">
+      </metal:block>
+    </metal:block>
+  </metal:block>
+</tal:block>
