Index: WAeUP_SRP/trunk/skins/waeup_accommodation/accommodation_record_slip.pt
===================================================================
--- WAeUP_SRP/trunk/skins/waeup_accommodation/accommodation_record_slip.pt	(revision 5616)
+++ WAeUP_SRP/trunk/skins/waeup_accommodation/accommodation_record_slip.pt	(revision 5616)
@@ -0,0 +1,114 @@
+<metal:body use-macro="here/slip_template/macros/master">
+    <metal:main fill-slot="main"
+                tal:define="
+                            info_acco options/info|nothing;
+                            info_app context/getApplicationInfo;
+                            ">
+      <span tal:condition="python: not info_acco">
+            <span tal:content="here/illegal_view" />
+      </span>   
+      <span tal:condition="python: info_acco">                   
+          <h3>Hostel Allocation Slip (including Maintenance Receipt)</h3>
+
+          <br />
+           
+        <span tal:omit-tag=""
+              tal:content="structure python: info_app['app_doc'].render(proxy=info_app['app_doc'],
+              layout_mode='view_info', 
+              layout_id='student_application')" 
+              />     
+          
+       <table width="" cellpadding="2" cellspacing="0" summary="Form layout">
+
+         <tr>
+             <td width="180px" valign="top">
+              <span class="dlabel">Booking Session</span>:
+             </td>
+             <td> 
+                <span tal:content="python:context.portal_vocabularies.sessions.get(info_acco['Booking Session'])"></span>
+             </td>
+         </tr>
+         <tr>
+             <td width="180px" valign="top">
+              <span class="dlabel">Bed</span>:
+             </td>
+             <td> 
+                <span tal:content="python:context.getFormattedBed(info_acco['Bed'])"></span>
+             </td>
+         </tr>
+         <tr>
+             <td width="180px" valign="top">
+              <span class="dlabel">Bed Type</span>:
+             </td>
+             <td> 
+                <span tal:content="python:info_acco['Bed Type']"></span>
+             </td>
+         </tr>                  
+         <tr>
+             <td width="180px" valign="top">
+              <span class="dlabel">Hostel Application Date</span>:
+             </td>
+             <td> 
+                <span tal:content="python:context.getDateStr(fmt='%d/%m/%Y', dt=info_acco['Hostel Application Date'])"></span>
+             </td>
+         </tr>    
+         <tr>
+             <td width="180px" valign="top">
+              <span class="dlabel">Hostel Application PIN</span>:
+             </td>
+             <td> 
+                <span tal:content="python:info_acco['Hostel Application PIN']"></span>
+             </td>
+         </tr>   
+         <tr>
+             <td width="180px" valign="top">
+              <span class="dlabel">Maintenance Payment Code</span>:
+             </td>
+             <td> 
+                <span tal:content="python:info_acco['Maintenance Payment Code']"></span>
+             </td>
+         </tr> 
+         <tr>
+             <td width="180px" valign="top">
+              <span class="dlabel">Maintenance Fee</span>:
+             </td>
+             <td> 
+                <span tal:content="python:info_acco['Maintenance Fee']"></span>
+             </td>
+         </tr>                     
+         <tr>
+             <td width="180px" valign="top">
+              <span class="dlabel">Hostel Maintenance PIN</span>:
+             </td>
+             <td> 
+                <span tal:content="python:info_acco['Hostel Maintenance PIN']"></span>
+             </td>
+         </tr>            
+         <tr>
+             <td width="180px" valign="top">
+              <span class="dlabel">Online Payment Id</span>:
+             </td>
+             <td> 
+                <span tal:content="python:info_acco['Online Payment Id']"></span>
+             </td>
+         </tr>            
+         <tr>
+             <td width="180px" valign="top">
+              <span class="dlabel">Maintenance Payment Date</span>:
+             </td>
+             <td> 
+                <span tal:content="python:context.getDateStr(fmt='%d/%m/%Y', dt=info_acco['Maintenance Payment Date'])"></span>
+             </td>
+         </tr>                                              
+         <tr>
+             <td width="180px" valign="top">
+              <span class="dlabel">Booking Status</span>:
+             </td>
+             <td> 
+                <span tal:content="python:info_acco['Booking Status']"></span>
+             </td>
+         </tr>
+       </table>
+      </span>      
+    </metal:main>
+</metal:body>
Index: WAeUP_SRP/trunk/skins/waeup_accommodation/accommodations.pt
===================================================================
--- WAeUP_SRP/trunk/skins/waeup_accommodation/accommodations.pt	(revision 5616)
+++ WAeUP_SRP/trunk/skins/waeup_accommodation/accommodations.pt	(revision 5616)
@@ -0,0 +1,79 @@
+<metal:body use-macro="here/main_template/macros/master">
+  <metal:main fill-slot="main"
+              tal:define="info context/getAccommodationRecords;">
+    <span tal:condition="not: info">
+      <span tal:content="here/illegal_view" />
+    </span>
+    <span tal:condition="info" tal:omit-tag="">
+      <span tal:define= " rows info/accommodations;
+      is_student info/is_student;
+      s_name info/student_name;"
+      >
+        <a href=""
+           tal:attributes="href string:${context/absolute_url}">
+          <img tal:attributes="src string:${here/portal_url}/arrow_up.gif"/>
+          Up one level
+        </a>
+        <h3> 
+          <span tal:condition="not:is_student" tal:omit-tag="">
+            <span tal:content="s_name" />:</span>
+          <span tal:condition="is_student" tal:omit-tag="">My</span> Accommodation Bookings
+        </h3>
+        <br />
+        
+        <table class="registration" width="100%">
+          <tr>
+            <th>Session</th>
+            <th>Bed</th>
+
+            <th>&nbsp;</th>
+          </tr>                    
+          <tr tal:repeat="row rows"
+              tal:attributes="class python:test(repeat['row'].even(), 'even ajaxtd', 'odd ajaxtd')">
+            <td tal:attributes="class python:test(row['paid'], 'active')" 
+                tal:content="python:context.portal_vocabularies.sessions.get(row['session'])" />
+            <td tal:attributes="class python:test(row['paid'], 'active')" 
+                tal:content="python:context.getFormattedBed(row['bed'])" />
+
+            <td tal:condition="not:row/paid">
+              <a 
+                 tal:attributes="href string:${row/url}/pay_accommodation?session=${row/session}">
+                 [pay maintenance fee]
+              </a> 
+            </td>
+
+            <td>
+              <a target="slip" href="" 
+                 tal:attributes="href string:${row/url}/viewAccommodationRecord?session=${row/session}"
+                 onclick="javascript:window.open('','slip','width=600, height=700, directories=no, toolbar=no, location=no, menubar=yes, scrollbars=yes, status=no, resizable=no, dependent=no')">
+                 [view slip]
+              </a> 
+            </td>
+            <td tal:condition="row/cancellation_allowed">
+              <a href=""
+                 tal:attributes="href string:${row/url}/cancel_allocation?session=${row/session}">
+                 [cancel booking]
+              </a> 
+            </td>            
+            <td tal:condition="row/relocation_allowed">
+              <a href="" 
+                 tal:attributes="href string:${row/url}/relocate?session=${row/session}">
+                 [relocate]
+              </a> 
+            </td>             
+          </tr>
+        </table>
+        <br /><br />
+        <form action="" method="post" class="group"
+              tal:condition="python: info['booking_allowed'] and not info['booking_disabled']"
+              tal:attributes="action string:${context/absolute_url}/book_accommodation">
+          <input type="submit" class="context" value="Proceed to Accommodation Booking" />
+          <input type="hidden" name="xxx"
+                 tal:attributes="value string:xxx"
+                 /> &nbsp; <br /><br />
+        </form>      
+        
+      </span>
+    </span>
+  </metal:main>
+</metal:body>
Index: WAeUP_SRP/trunk/skins/waeup_accommodation/book_accommodation.py
===================================================================
--- WAeUP_SRP/trunk/skins/waeup_accommodation/book_accommodation.py	(revision 5616)
+++ WAeUP_SRP/trunk/skins/waeup_accommodation/book_accommodation.py	(revision 5616)
@@ -0,0 +1,112 @@
+## Script (Python) "book_accommodation.py"
+##bind container=container
+##bind context=context
+##bind namespace=
+##bind script=script
+##bind subpath=traverse_subpath
+##parameters=REQUEST
+# $Id$
+"""
+process the the accommodation reservation
+"""
+try:
+    from Products.zdb import set_trace
+except:
+    def set_trace():
+        pass
+import DateTime
+current = DateTime.DateTime()
+pr = context.portal_registration
+wftool = context.portal_workflow
+lt = context.portal_layouts
+info = context.getAccommodationStatus()
+
+import logging
+logger = logging.getLogger('Skins.book_accommodation')
+
+if info is None:
+    member_id = str(context.portal_membership.getAuthenticatedMember())
+    logger.info('%s tried to reserve accommodation' % (member_id))
+    return context.REQUEST.RESPONSE.redirect("%s/srp_invalid_access" % context.portal_url())
+
+if info['booking_disabled']:
+    return context.REQUEST.RESPONSE.redirect("%s/booking_disabled" % info['student'].absolute_url())
+if not info['booking_allowed']:
+    return context.REQUEST.RESPONSE.redirect("%s/no_booking_allowed" % info['student'].absolute_url())
+student = info['student']
+student_id = info['student_id']
+acco_id = info['acco_id']
+session = info['session'][0]
+mode = 'create'
+validate = REQUEST.has_key("cpsdocument_create_button")
+button = 'Book'
+
+res,psm,ds = lt.renderLayout(layout_id= 'student_accommodation_fe',
+                      schema_id= 'student_accommodation',
+                      context=context,
+                      mapping=validate and REQUEST,
+                      ob=info,
+                      layout_mode=mode,
+                      formaction = "book_accommodation",
+                      button = button)
+
+
+
+if psm == 'invalid':
+    member_id = str(context.portal_membership.getAuthenticatedMember())
+    #logger.info('%s, %s' % (member_id,info['error'] ))
+    logger.info('%s entered invalid data' % (member_id))
+    psm = "Please correct your input."
+    return context.book_accommodation_form(rendered = res,
+                                 psm = psm,
+                                 mode = mode,
+                                 ds = ds,
+                                 )
+elif psm == '':
+    return context.book_accommodation_form(rendered = res,
+                                 psm = None,
+                                 mode = mode,
+                                 ds = ds,
+                                 )
+elif psm == 'valid':
+    pin = str(ds.get('acco_res_sc_pin'))
+    code,bed = context.portal_accommodation.searchAndReserveBed(student_id,
+                                                                "%s" % (info['student_status']),
+                                                                random_order=False)
+    while True:
+        if code == 1:
+            break
+        if code == -1:
+            break
+        elif code == -2:
+            return context.book_accommodation_form(rendered = res,
+                                    psm = "No bed available. Your category is already fully booked.",
+                                    mode = mode,
+                                    ds = ds,
+                                    )
+        else: # unknown error
+            return context.book_accommodation_form(rendered = res,
+                                    psm = "Unexpected Error!",
+                                    mode = mode,
+                                    ds = ds,
+                                    )
+
+
+hall_info = context.waeup_tool.getHallInfo(bed)
+data={}
+data['acco_res_sc_pin'] = ds['acco_res_sc_pin']
+data['acco_maint_code'] = hall_info.get('maintenance_code')
+data['acco_maint_fee'] = hall_info.get('maintenance_fee')
+data['acco_res_date'] = current
+data['bed'] = bed
+data['session'] = session
+data['student_status'] = info['student_status']
+data['catkey'] =student_id + '|' + session
+data['student_id'] = student_id
+data['reservation_status'] = 'bed_reserved'
+
+#set_trace()
+context.accommodation_catalog.addRecord(**data)
+
+return context.REQUEST.RESPONSE.redirect("%s/accommodations" % student.absolute_url())
+
Index: WAeUP_SRP/trunk/skins/waeup_accommodation/book_accommodation_form.pt
===================================================================
--- WAeUP_SRP/trunk/skins/waeup_accommodation/book_accommodation_form.pt	(revision 5616)
+++ WAeUP_SRP/trunk/skins/waeup_accommodation/book_accommodation_form.pt	(revision 5616)
@@ -0,0 +1,37 @@
+<tal:block define="
+                   rendered_main options/rendered;
+                   portal_status_message options/psm;
+                   data_storage options/ds|nothing;
+                   mode options/mode;
+                   info python: context.getAccommodationStatus();
+                   ">
+<metal:block define-macro="edit_form">
+  <metal:block use-macro="here/main_template/macros/master">
+  <metal:block fill-slot="header">
+    </metal:block>
+      <metal:block fill-slot="main">
+      
+  
+      
+        <h3>Book Your Accommodation! </h3>
+        <br />
+
+
+
+        <div tal:replace="structure rendered_main" />
+
+        
+        <p>Instructions :</p>
+        
+        <ul>
+            <li>Buy a Hostel Application Scratch Card.</li> 
+            <li>Enter the PIN above and press 'Book'.</li>
+            <li>Print your Hostel Allocation Slip.</li>
+        </ul>
+
+      </metal:block>
+      <metal:block fill-slot="sub">
+      </metal:block>
+    </metal:block>
+  </metal:block>
+</tal:block>
Index: WAeUP_SRP/trunk/skins/waeup_accommodation/cancel_allocation.py
===================================================================
--- WAeUP_SRP/trunk/skins/waeup_accommodation/cancel_allocation.py	(revision 5616)
+++ WAeUP_SRP/trunk/skins/waeup_accommodation/cancel_allocation.py	(revision 5616)
@@ -0,0 +1,51 @@
+## Script (Python) "cancel_allocation"
+##bind container=container
+##bind context=context
+##bind namespace=
+##bind script=script
+##bind subpath=traverse_subpath
+##parameters=session=None
+##title=
+##
+# $Id$
+"""
+cancel bed allocation (former release_bed)
+"""
+import logging
+logger = logging.getLogger('Skins.cancel_allocation')
+
+import DateTime
+current = DateTime.DateTime()
+request = context.REQUEST
+redirect = request.RESPONSE.redirect
+mtool = context.portal_membership
+wf = context.portal_workflow
+member = mtool.getAuthenticatedMember()
+member_id = str(member)
+path_info = request.get('PATH_INFO').split('/')
+students = context.portal_url.getPortalObject().campus.students
+student_id = context.getStudentId()
+
+if not context.isSectionOfficer():
+    logger.info('%s tried to access %s' % (member_id,student_id))
+    return None
+
+if student_id is not None:
+    logger.info('%s requests bed_release for %s' % (member_id,student_id))
+    res = context.portal_accommodation(student=student_id)
+    if len(res) == 0:
+        logger.info('no bed of %s found' % (student_id))
+        return redirect("%s/%s/accommodations" % (students.absolute_url(),student_id))
+    allocated_bed = res[0]
+    context.portal_accommodation.modifyRecord(bed=allocated_bed.bed,student=context.portal_accommodation.not_occupied)
+    data = {}
+    data['catkey'] = student_id + '|' + session
+    data['bed'] = "-- cancelled on %s by section officer --" % context.getDateStr(fmt='%d/%m/%Y', dt=current)
+    data['acco_maint_fee'] = ""
+    #set_trace()
+    context.accommodation_catalog.modifyRecord(**data)
+    logger.info('%s released bed of %s' % (member_id,student_id))
+    return redirect("%s/%s/accommodations" % (students.absolute_url(),student_id))
+
+return None
+
Index: WAeUP_SRP/trunk/skins/waeup_accommodation/getAccommodationRecords.py
===================================================================
--- WAeUP_SRP/trunk/skins/waeup_accommodation/getAccommodationRecords.py	(revision 5616)
+++ WAeUP_SRP/trunk/skins/waeup_accommodation/getAccommodationRecords.py	(revision 5616)
@@ -0,0 +1,71 @@
+## Script (Python) "getAccommodationRecords"
+##bind container=container
+##bind context=context
+##bind namespace=
+##bind script=script
+##bind subpath=traverse_subpath
+##parameters=student_id=None
+##title=
+##
+# $Id$
+"""
+"""
+import logging
+logger = logging.getLogger('Skins.getAccommodationRecords')
+import DateTime
+
+pprops = context.portal_properties
+booking_disabled = not pprops.enable_acco_booking
+
+request = context.REQUEST
+mtool = context.portal_membership
+wf = context.portal_workflow
+member = mtool.getAuthenticatedMember()
+member_id = str(member)
+path_info = request.get('PATH_INFO').split('/')
+portal_session = context.getSessionId()[0]
+
+if mtool.isAnonymousUser():
+    return None
+info = {}
+if student_id is None:
+    requested_id = context.getStudentId()
+    if requested_id and not context.isStaff() and member_id != requested_id:
+        logger.info('%s tried to access %s' % (member_id,requested_id))
+        return None
+    elif context.isStaff():
+        student_id = requested_id
+    else:
+        student_id = member_id
+student_record = context.students_catalog.getRecordByKey(student_id)
+if student_record is None:
+    logger.info('%s not found in students_catalog' % student_id)
+    return None
+
+info['is_so'] = context.isSectionOfficer()
+info['is_student'] = context.isStudent()
+info['student_name'] = student_record.name    
+student_path = "%s/campus/students/%s" % (context.portal_url(),student_id)
+accommodation_records = context.accommodation_catalog(student_id = student_id)
+accommodations = []
+for ar in accommodation_records:
+    row = {}
+    row['session'] = ar.session
+    row['bed'] = ar.bed
+    row['reservation_status'] = ar.reservation_status
+    row['paid'] = ar.reservation_status == 'maintenance_fee_paid'
+    row['url'] = student_path
+    row['cancellation_allowed'] = info['is_so'] and ar.session == portal_session
+    row['relocation_allowed'] = info['is_so'] and ar.session == portal_session
+    accommodations.append(row)
+
+info['accommodations'] = accommodations
+
+as = context.getAccommodationStatus()
+info['booking_allowed'] = as['booking_allowed']
+info['booking_disabled'] = as['booking_disabled']
+
+return info
+                 
+    
+    
Index: WAeUP_SRP/trunk/skins/waeup_accommodation/getAccommodationStatus.py
===================================================================
--- WAeUP_SRP/trunk/skins/waeup_accommodation/getAccommodationStatus.py	(revision 5616)
+++ WAeUP_SRP/trunk/skins/waeup_accommodation/getAccommodationStatus.py	(revision 5616)
@@ -0,0 +1,179 @@
+## Script (Python) "getAccommodationStatus"
+##bind container=container
+##bind context=context
+##bind namespace=
+##bind script=script
+##bind subpath=traverse_subpath
+##parameters=student_id=None
+##title=
+##
+# $Id$
+"""
+return Info about the current Student
+"""
+try:
+    from Products.zdb import set_trace
+except:
+    def set_trace():
+        pass
+
+import logging
+logger = logging.getLogger('Skins.getAccommodationStatus')
+import DateTime
+
+pprops = context.portal_properties
+booking_disabled = not pprops.enable_acco_booking
+
+request = context.REQUEST
+mtool = context.portal_membership
+wf = context.portal_workflow
+member = mtool.getAuthenticatedMember()
+member_id = str(member)
+path_info = request.get('PATH_INFO').split('/')
+
+if mtool.isAnonymousUser():
+    return None
+info = {}
+if student_id is None:
+    requested_id = context.getStudentId()
+    if requested_id and not context.isStaff() and member_id != requested_id:
+        logger.info('%s tried to access %s' % (member_id,requested_id))
+        return None
+    elif context.isStaff():
+        student_id = requested_id
+    else:
+        student_id = member_id
+student_record = context.students_catalog.getRecordByKey(student_id)
+if student_record is None:
+    logger.info('%s not found in students_catalog' % student_id)
+    return None
+
+info['error'] = None
+info['matric_no']=student_record.matric_no
+info['jamb_reg_no']=student_record.jamb_reg_no
+info['name']=student_record.name
+info['email']=student_record.email
+info['level']=student_record.level
+info['verdict']=getattr(student_record,'verdict','')
+review_state = info['review_state'] = student_record.review_state
+info['session'] = session = context.getSessionId()
+students_object = context.portal_url.getPortalObject().campus.students
+student = getattr(students_object, student_id)
+info['student_id'] = student_id
+info['student'] = student
+
+# do not change these settings!
+
+booking_allowed = False
+info['booking_disabled'] = False
+
+# customize from here
+
+ekehuan_certificates = ('BARTAPG',
+                        'BARTAPM',
+                        'BARTCER',
+                        'BARTFAA',
+                        'BARTFAP',
+                        'BARTSCP',
+                        'BARTTXT',
+                        'BARTMAS',
+                        'BARTTHR',
+                        )
+
+new_states = ('cleared_and_validated',
+              'school_fee_paid',
+              'courses_registered',
+              'courses_validated',
+              )
+new = None
+arrived = None
+
+try:
+    new = int(student_record.entry_session) == int(session[0])
+except:    
+    logger.info('%s has invalid entry_session %s' % (student_id,student_record.entry_session))
+try:
+    arrived = int(student_record.session) == int(session[0])
+except:    
+    logger.info('%s has invalid session %s' % (student_id,student_record.session))    
+    
+level = None
+end_level = None
+previous = None
+
+try:
+    level = int(student_record.level)
+except:
+    logger.info('%s has invalid level %s' % (student_id,student_record.level))
+try:
+    end_level = int(student_record.end_level)
+except:
+    logger.info('%s has invalid end_level %s' % (student_id,student_record.end_level))
+try:
+    previous = int(student_record.session) == int(session[0]) - 1
+except:
+    logger.info('%s has invalid session %s' % (student_id,student_record.session))
+
+if level is None or end_level is None or student_record.review_state in ('deactivated','graduated'):
+    pass
+elif arrived:
+    if new:
+        booking_allowed = student_record.review_state in new_states
+    else:
+        booking_allowed = not (level % 100) 
+elif previous:
+    booking_allowed = student_record.verdict in ('A','B',)
+
+info['booking_allowed'] = booking_allowed
+if not booking_allowed:
+    info['student_status'] = ''
+    #info['new'] = new
+    logger.info('%s: not eligible' % (student_id))     
+    return info
+
+d = {}
+delta = 0
+if previous:
+    delta = 100
+if new:
+    bt = 'fr'
+elif level + delta < end_level:
+    bt = 're'
+else:
+    bt = 'fi'
+d['sex'] = 'male'
+if student_record.sex:
+    d['sex'] = 'female'
+if student_record.faculty in ('MED','DEN') and level > 400:
+    bt += "_med"
+elif student_record.course in ekehuan_certificates:
+    bt += "_ekenhuan"
+#elif student_record.course in pti_certificates:
+#    bt += "_pti"
+info['sex']=d['sex']
+d['bt'] = bt
+student_status = "%(sex)s_%(bt)s" % d
+info['student_status'] = student_status
+
+# customize end
+
+acco_id = student_id + '|' + session[0]
+info['acco_id'] = acco_id
+
+if booking_disabled:
+  info['booking_disabled'] = True
+  #logger.info('%s: %s eligible but booking disabled' % (student_id,student_status))  
+
+accommodation_record = context.accommodation_catalog.getRecordByKey(acco_id)
+if accommodation_record is None:
+    return info
+  
+info['booking_allowed'] = False
+info['acco_res_date'] = accommodation_record.acco_res_date
+info['acco_res_sc_pin'] = accommodation_record.acco_res_sc_pin
+info['acco_maint_fee'] = accommodation_record.acco_maint_fee
+info['student_status'] = accommodation_record.student_status
+info['bed'] = accommodation_record.bed
+info['session'] = accommodation_record.session
+
+return info
Index: WAeUP_SRP/trunk/skins/waeup_accommodation/pay_accommodation.py
===================================================================
--- WAeUP_SRP/trunk/skins/waeup_accommodation/pay_accommodation.py	(revision 5616)
+++ WAeUP_SRP/trunk/skins/waeup_accommodation/pay_accommodation.py	(revision 5616)
@@ -0,0 +1,83 @@
+## Script (Python) "pay_accommodation.py"
+##bind container=container
+##bind context=context
+##bind namespace=
+##bind script=script
+##bind subpath=traverse_subpath
+##parameters=REQUEST
+# $Id$
+"""
+process the the accommodation fee payment
+"""
+try:
+    from Products.zdb import set_trace
+except:
+    def set_trace():
+        pass
+import DateTime
+current = DateTime.DateTime()
+pr = context.portal_registration
+wftool = context.portal_workflow
+lt = context.portal_layouts
+info = context.getAccommodationStatus()
+
+import logging
+logger = logging.getLogger('Skins.pay_accommodation')
+
+if info is None:
+    member_id = str(context.portal_membership.getAuthenticatedMember())
+    logger.info('%s tried to pay accommodation' % (member_id))
+    return context.REQUEST.RESPONSE.redirect("%s/srp_invalid_access" % context.portal_url())
+
+#if info['booking_disabled']:
+#    return context.REQUEST.RESPONSE.redirect("%s/booking_disabled" % info['student'].absolute_url())
+#if not info['booking_allowed']:
+#    return context.REQUEST.RESPONSE.redirect("%s/no_booking_allowed" % info['student'].absolute_url())
+student = info['student']
+student_id = info['student_id']
+acco_id = info['acco_id']
+session = info['session']
+mode = 'edit'
+validate = REQUEST.has_key("cpsdocument_edit_button")
+button = 'Submit'
+
+
+res,psm,ds = lt.renderLayout(layout_id= 'student_accommodation_fe',
+                      schema_id= 'student_accommodation',
+                      context=context,
+                      mapping=validate and REQUEST,
+                      ob=info,
+                      layout_mode=mode,
+                      formaction = "pay_accommodation",
+                      button = button)
+
+if psm == 'invalid':
+    member_id = str(context.portal_membership.getAuthenticatedMember())
+    #logger.info('%s, %s' % (member_id,info['error'] ))
+    logger.info('%s entered invalid data' % (member_id))
+    psm = "Please correct your input."
+    return context.pay_accommodation_form(rendered = res,
+                                 psm = psm,
+                                 mode = mode,
+                                 ds = ds,
+                                 )
+elif psm == '':
+    return context.pay_accommodation_form(rendered = res,
+                                 psm = None,
+                                 mode = mode,
+                                 ds = ds,
+                                 )
+elif psm == 'valid':
+    pass
+
+data={}
+data['acco_maint_sc_pin'] = ds['acco_maint_sc_pin']
+data['acco_maint_date'] = current
+data['catkey'] =student_id + '|' + session
+data['reservation_status'] = 'maintenance_fee_paid'
+
+#set_trace()
+context.accommodation_catalog.modifyRecord(**data)
+
+return context.REQUEST.RESPONSE.redirect("%s/accommodations" % student.absolute_url())
+
Index: WAeUP_SRP/trunk/skins/waeup_accommodation/pay_accommodation_form.pt
===================================================================
--- WAeUP_SRP/trunk/skins/waeup_accommodation/pay_accommodation_form.pt	(revision 5616)
+++ WAeUP_SRP/trunk/skins/waeup_accommodation/pay_accommodation_form.pt	(revision 5616)
@@ -0,0 +1,57 @@
+<tal:block define="
+                   rendered_main options/rendered;
+                   portal_status_message options/psm;
+                   data_storage options/ds|nothing;
+                   mode options/mode;
+                   info python: context.getAccommodationStatus();
+                   maintenance_online info/online_payment|nothing;                  
+                   ">
+<metal:block define-macro="edit_form">
+  <metal:block use-macro="here/main_template/macros/master">
+  <metal:block fill-slot="header">
+    </metal:block>
+      <metal:block fill-slot="main">
+      
+        <h3>Pay Your Accommodation Maintenance Fee! </h3>
+        <br />
+
+        <div tal:replace="structure rendered_main" />
+        
+        <p>Instructions :</p>
+        
+        <ul tal:condition="not: maintenance_online">
+             <li>Buy a Hostel Maintenance Scratch Card 
+               (Code: <span tal:replace="python: 'acco_maint_code'" />) for 
+               <span tal:replace="python: 'acco_maint_fee'" /> Nairas</li> 
+             <li>Enter the PIN above and press 'Submit'.</li>
+             <li>Print your Hostel Maintenance Receipt.</li>
+        </ul>
+        
+        <tal:block condition="maintenance_online">
+            <table tal:condition="not: info/maintenance_paid">
+              <tr >
+                <form action="pay_interswitch_acco" method="post" 
+                      enctype="multipart/form-data" class="workflow"
+                      >
+                  <input type="hidden" 
+                         name="paytype"
+                         value="HOM"
+                         />
+                  <td colspan="2">  
+                    <input type="submit" 
+                           class="standalone" 
+                           name="cpsdocument_create_button"
+                           value="Pay Maintenance Fee Online"
+                           />
+                  </td>
+                </form>
+              </tr>
+            </table>
+        </tal:block>
+
+      </metal:block>
+      <metal:block fill-slot="sub">
+      </metal:block>
+    </metal:block>
+  </metal:block>
+</tal:block>
Index: WAeUP_SRP/trunk/skins/waeup_accommodation/relocate.py
===================================================================
--- WAeUP_SRP/trunk/skins/waeup_accommodation/relocate.py	(revision 5616)
+++ WAeUP_SRP/trunk/skins/waeup_accommodation/relocate.py	(revision 5616)
@@ -0,0 +1,86 @@
+## Script (Python) "relocate"
+##bind container=container
+##bind context=context
+##bind namespace=
+##bind script=script
+##bind subpath=traverse_subpath
+##parameters=session=None
+##title=
+##
+# $Id$
+"""
+relocate to a new bed if allocated bed is wrong (former change_bed)
+"""
+import logging
+from Products.AdvancedQuery import Eq, Between, Le,In
+
+logger = logging.getLogger('Skins.relocate')
+request = context.REQUEST
+redirect = request.RESPONSE.redirect
+mtool = context.portal_membership
+wf = context.portal_workflow
+member = mtool.getAuthenticatedMember()
+member_id = str(member)
+path_info = request.get('PATH_INFO').split('/')
+students = context.portal_url.getPortalObject().campus.students
+portal_acco_cat = context.portal_accommodation
+studs = context.students_catalog
+student_id = context.getStudentId()
+
+if not context.isSectionOfficer():
+    logger.info('%s tried to access %s' % (member_id,student_id))
+    return None
+
+if student_id is not None:
+    logger.info('%s requests bed change for %s' % (member_id,student_id))
+    info = context.getAccommodationStatus(student_id)
+    res = portal_acco_cat(student=student_id)
+    status = info['student_status']
+    while True:
+        if len(res) == 0:
+            psm = 'No bed allocated for %s' % (student_id)
+            logger.info(psm)
+            pass
+            #break
+        elif res[0].bed_type.endswith("reserved"):
+             logger.info("found reserved bed %s which won't be released" % res[0].bed)
+             pass
+        else:
+            allocated_bed = res[0]
+            #if allocated_bed.bed_type == status:
+            #    logger.info('Status %s of %s has not changed.' % (status,student_id))
+            #    psm='Student status has not changed!'
+            #    break
+            logger.info('Bed status %s of %s has changed to %s.' % (allocated_bed.bed_type,student_id,status))
+            query = Eq('bed_type',status) & Eq('student',context.portal_accommodation.not_occupied)
+            records = context.portal_accommodation.evalAdvancedQuery(query)
+            if len(records) < 1:
+                psm='Bed change for %s failed, no free bed in category %s.' % (student_id,status)
+                logger.info(psm)
+                break
+            portal_acco_cat.modifyRecord(bed=allocated_bed.bed,student=portal_acco_cat.not_occupied)
+            logger.info('Bed %s released' % (allocated_bed.bed))
+        code,bed = portal_acco_cat.searchAndReserveBed(student_id,status,random_order=True)
+        if code > -2:
+            acco_info = context.waeup_tool.getHallInfo(bed)
+            d = {}
+            d['bed'] = bed
+            d['student_status'] = status
+            d['catkey'] = student_id + '|' + session
+            d['acco_maint_code'] = acco_info.get('maintenance_code')
+            d['acco_maint_fee'] = acco_info.get('maintenance_fee')
+            context.accommodation_catalog.modifyRecord(**d)
+        if code > 0:
+            psm = 'Bed changed!'
+            logger.info('Bed %s allocated to %s' % (bed,student_id))
+        elif code == -1:
+            psm = 'A reserved bed has been allocated.'
+        elif code == -2:
+            psm = 'No bed %s for %s available!' % (status,student_id)
+        else:
+            psm = 'Bed change failed!'
+        break
+
+return redirect("%s/%s/accommodations" % (students.absolute_url(),student_id))
+
+
Index: WAeUP_SRP/trunk/skins/waeup_accommodation/viewAccommodationRecord.py
===================================================================
--- WAeUP_SRP/trunk/skins/waeup_accommodation/viewAccommodationRecord.py	(revision 5616)
+++ WAeUP_SRP/trunk/skins/waeup_accommodation/viewAccommodationRecord.py	(revision 5616)
@@ -0,0 +1,73 @@
+## Script (Python) "viewAccommodationRecord"
+##bind container=container
+##bind context=context
+##bind namespace=
+##bind script=script
+##bind subpath=traverse_subpath
+##parameters=student_id=None,session=None
+##title=
+##
+# $Id$
+"""
+"""
+import logging
+logger = logging.getLogger('Skins.getAccommodationRecords')
+import DateTime
+
+pprops = context.portal_properties
+booking_disabled = not pprops.enable_acco_booking
+
+request = context.REQUEST
+mtool = context.portal_membership
+wf = context.portal_workflow
+member = mtool.getAuthenticatedMember()
+member_id = str(member)
+path_info = request.get('PATH_INFO').split('/')
+
+if mtool.isAnonymousUser():
+    return None
+info = {}
+if student_id is None:
+    requested_id = context.getStudentId()
+    if requested_id and not context.isStaff() and member_id != requested_id:
+        logger.info('%s tried to access %s' % (member_id,requested_id))
+        return None
+    elif context.isStaff():
+        student_id = requested_id
+    else:
+        student_id = member_id
+student_record = context.students_catalog.getRecordByKey(student_id)
+if student_record is None:
+    logger.info('%s not found in students_catalog' % student_id)
+    return None
+
+student_path = "%s/campus/students/%s" % (context.portal_url(),student_id)
+
+if session:
+    accommodation_records = context.accommodation_catalog(student_id = student_id, session = session)
+    accommodation = []
+    ar = accommodation_records[0]
+    info = {}
+    fields = {
+              'Hostel Application Date':'acco_res_date',
+              'Hostel Application PIN':'acco_res_sc_pin',
+              'Bed':'bed',
+              'Booking Session':'session',
+              'Bed Type':'student_status',
+              'Maintenance Payment Date':'acco_maint_date',
+              'Maintenance Payment Code':'acco_maint_code',
+              'Hostel Maintenance PIN':'acco_maint_sc_pin',
+              'Online Payment Id':'acco_maint_pay_id',
+              'Maintenance Fee':'acco_maint_fee',              
+              'Booking Status':'reservation_status'
+              }    
+    #info['url'] = student_path 
+    for field in fields:
+        info[field] = getattr(ar,fields[field],None)
+
+return context.accommodation_record_slip(
+                                info = info,
+                               )
+                 
+    
+    
