def document_tabs(r):
 tab_opts = [{'tablename': 'assess_rat', 'resource': 'rat', 'one_title': '1 Assessment', 'num_title': ' Assessments'}, {'tablename': 'irs_ireport', 'resource': 'ireport', 'one_title': '1 Incident Report', 'num_title': ' Incident Reports'}, {'tablename': 'cr_shelter', 'resource': 'shelter', 'one_title': '1 Shelter', 'num_title': ' Shelters'}, {'tablename': 'req_req', 'resource': 'req', 'one_title': '1 Request', 'num_title': ' Requests'}]
 tabs = [(T('Details'), None)]
 crud_string = s3base.S3CRUD.crud_string
 for tab_opt in tab_opts:
  tablename = tab_opt['tablename']
  if ((tablename in db) and (document_id in db[tablename])):
   table = db[tablename]
   query = ((table.deleted == False) & (table.document_id == r.id))
   tab_count = db(query).count()
   if (tab_count == 0):
    label = crud_string(tablename, 'label_create')
   elif (tab_count == 1):
    label = tab_opt['one_title']
   else:
    label = T((str(tab_count) + tab_opt['num_title']))
   tabs.append((label, tab_opt['resource']))
 return tabs

def document_tabs ( r ) : tab_opts = [ { 'tablename' : 'assess_rat' , 'resource' : 'rat' , 'one_title' : '1 Assessment' , 'num_title' : ' Assessments' } , { 'tablename' : 'irs_ireport' , 'resource' : 'ireport' , 'one_title' : '1 Incident Report' , 'num_title' : ' Incident Reports' } , { 'tablename' : 'cr_shelter' , 'resource' : 'shelter' , 'one_title' : '1 Shelter' , 'num_title' : ' Shelters' } , { 'tablename' : 'req_req' , 'resource' : 'req' , 'one_title' : '1 Request' , 'num_title' : ' Requests' } ] tabs = [ ( T ( 'Details' ) , None ) ] crud_string = s3base . S3CRUD . crud_string for tab_opt in tab_opts : tablename = tab_opt [ 'tablename' ] if ( ( tablename in db ) and ( document_id in db [ tablename ] ) ) : table = db [ tablename ] query = ( ( table . deleted == False ) & ( table . document_id == r . id ) ) tab_count = db ( query ) . count ( ) if ( tab_count == 0 ) : label = crud_string ( tablename , 'label_create' ) elif ( tab_count == 1 ) : label = tab_opt [ 'one_title' ] else : label = T ( ( str ( tab_count ) + tab_opt [ 'num_title' ] ) ) tabs . append ( ( label , tab_opt [ 'resource' ] ) ) return tabs
display the number of components in the tabs - currently unused as we dont have these tabs off documents .