Index: /WAeUP_SRP/trunk/ScratchCards.py
===================================================================
--- /WAeUP_SRP/trunk/ScratchCards.py	(revision 1011)
+++ /WAeUP_SRP/trunk/ScratchCards.py	(revision 1012)
@@ -147,4 +147,18 @@
         return unused
 
+    security.declareProtected(View,"getNumberOfUsedPins")
+    def getNumberOfUsedPins(self):
+        """return the number of used Pins"""
+        #import pdb;pdb.set_trace()
+        pins_cat = self.portal_pins
+        doc = self.getContent()
+        used = [{'pin': p.pin,
+              'serial': p.serial,
+              'student': p.student,
+              } for p in pins_cat.searchResults(prefix_batch = "%s%d"
+                                               % (doc.prefix,doc.batch_no),
+                                               ) if p.student]
+        return len(used)
+
 InitializeClass(ScratchCardBatch)
 
Index: /WAeUP_SRP/trunk/skins/waeup_pins/batch_view.pt
===================================================================
--- /WAeUP_SRP/trunk/skins/waeup_pins/batch_view.pt	(revision 1011)
+++ /WAeUP_SRP/trunk/skins/waeup_pins/batch_view.pt	(revision 1012)
@@ -27,4 +27,8 @@
         
         
+
+        <h3><span tal:replace="info/nr_used" /> Pins used out of 
+        <span tal:replace="info/batch_doc/no_of_pins" /></h3>
+      
         <span tal:replace="structure rendered" />
 
Index: /WAeUP_SRP/trunk/skins/waeup_pins/search_pins.py
===================================================================
--- /WAeUP_SRP/trunk/skins/waeup_pins/search_pins.py	(revision 1011)
+++ /WAeUP_SRP/trunk/skins/waeup_pins/search_pins.py	(revision 1012)
@@ -22,9 +22,10 @@
 lt = context.portal_layouts
 validate = request.has_key("cpsdocument_edit_button")
+default = {'search_mode': 'student',}
 rend,psm,ds = lt.renderLayout(layout_id= 'scratch_card_search',
                       schema_id= 'student_search',
                       context=context,
                       mapping=validate and request,
-                      ob={},
+                      ob=default,
                       layout_mode='edit',
                       formaction="search_pins",
@@ -35,4 +36,5 @@
 info['unused'] = info['batch_doc'].getUnusedPins()
 info['used'] = []
+info['nr_used'] = info['batch_doc'].getNumberOfUsedPins()
 
 if psm == '':
@@ -46,43 +48,44 @@
 what = ds.get('search_mode')
 term = ds.get('search_string')
+if term != "":
+    if what == 'student' :
+        items_1 = context.portal_pins(student = term.upper())
+        items_2 = context.portal_pins(student = term.lower())
+        items = items_1 + items_2
+    elif what == 'pin':
+        items = context.portal_pins(pin = term.upper())
+    else:
+        items = []
+    l = []
+    students_url = "%s/%s" % (context.portal_url(),'students')
+    pins = []
+    for i in items:
+        item = {}
+        sno = i['student']
+        item['student'] = sno
+        item['serial'] = i.serial
+        item['pin'] = i.pin
+        if i.pin in pins:
+            continue
+        pins.append(i.pins)
+        if len(sno)==10:
+            #res = context.portal_catalog(SearchableText=sno,portal_type='StudentApplication')
+            res = context.students_catalog(jamb_reg_no=sno.upper())
+            if len(res) > 0:
+                item['student_url'] = "%s/campus/students/%s" % (context.portal_url(),res[0].id)
+                item['student_id'] = res[0].id
+            else:
+                item['student_url'] = None
+                item['student_id'] = ''
+        elif sno:
+            item['student_url'] = '%s/campus/students/%s' % (students_url,item['student'])
+            item['student_id'] = student
+        else:
+            item['student_url'] = ''
+            item['student_id'] = "not used"
+        l.append(item)
+        
+    info['used'] = l
 
-if what == 'student':
-    items_1 = context.portal_pins(student = term.upper())
-    items_2 = context.portal_pins(student = term.lower())
-    items = items_1 + items_2
-elif what == 'pin':
-    items = context.portal_pins(pin = term.upper())
-else:
-    items = []
-l = []
-students_url = "%s/%s" % (context.portal_url(),'students')
-pins = []
-for i in items:
-    item = {}
-    sno = i['student']
-    item['student'] = sno
-    item['serial'] = i.serial
-    item['pin'] = i.pin
-    if i.pin in pins:
-        continue
-    pins.append(i.pins)
-    if len(sno)==10:
-        #res = context.portal_catalog(SearchableText=sno,portal_type='StudentApplication')
-        res = context.students_catalog(jamb_reg_no=sno.upper())
-        if len(res) > 0:
-            item['student_url'] = "%s/campus/students/%s" % (context.portal_url(),res[0].id)
-            item['student_id'] = res[0].id
-        else:
-            item['student_url'] = None
-            item['student_id'] = ''
-    elif sno:
-        item['student_url'] = '%s/campus/students/%s' % (students_url,item['student'])
-        item['student_id'] = student
-    else:
-        item['student_url'] = ''
-        item['student_id'] = "not used"
-    l.append(item)
-    
-info['used'] = l
 return context.batch_view(rendered = rend,
                              psm = psm,
Index: /WAeUP_SRP/trunk/skins/waeup_student/clearance_edit_form.pt
===================================================================
--- /WAeUP_SRP/trunk/skins/waeup_student/clearance_edit_form.pt	(revision 1011)
+++ /WAeUP_SRP/trunk/skins/waeup_student/clearance_edit_form.pt	(revision 1012)
@@ -10,8 +10,9 @@
            editable python: (is_student and clear_review_state == 'opened' or is_so) and not is_co;
            mode python: test(editable,'edit','view');
+           layout_id python: test(is_co,'student_clearance','student_clearance_fe');
            rendered_main python:info['clear_doc'].render(request=request,
                                                layout_mode = mode,
                                                schema_id='student_clearance',
-                                               layout_id='student_clearance',
+                                               layout_id=layout_id,
                                                use_session=True);
            form_action string:clearance_edit;
