def staff():
 s3.filter = (FS('type') == 1)
 def prep(r):
  table = r.table
  tablename = r.tablename
  get_vars = r.get_vars
  crud_strings = s3.crud_strings
  crud_strings[tablename] = crud_strings['hrm_staff']
  resource = r.resource
  if ('expiring' in get_vars):
   query = (FS('end_date') < (request.utcnow + datetime.timedelta(weeks=4)))
   resource.add_filter(query)
   crud_strings[tablename].title_list = T('Staff with Contracts Expiring in the next Month')
   resource.configure(sortby=table.end_date, insertable=False)
   list_fields = [(T('Contract End Date'), 'end_date'), 'person_id', 'job_title_id', 'organisation_id', 'site_id']
   if settings.get_hrm_staff_departments():
    list_fields.insert(4, 'department_id')
   resource.configure(list_fields=list_fields)
  elif (r.representation == 'xls'):
   s3db.hrm_xls_list_fields(r, vol=False)
  else:
   list_fields = ['person_id', 'job_title_id', 'organisation_id', 'site_id', (T('Email'), 'email.value'), (settings.get_ui_label_mobile_phone(), 'phone.value')]
   if settings.get_hrm_staff_departments():
    list_fields.insert(3, 'department_id')
   if settings.get_hrm_use_trainings():
    list_fields.append('person_id$training.course_id')
   if settings.get_hrm_use_certificates():
    list_fields.append('person_id$certification.certificate_id')
   list_fields.append((T('Contract End Date'), 'end_date'))
   list_fields.append('status')
   resource.configure(list_fields=list_fields)
  if r.interactive:
   if r.id:
    if (r.method not in ('profile', 'delete')):
     vars = {'human_resource.id': r.id, 'group': 'staff'}
     args = []
     if (r.representation == 'iframe'):
      vars['format'] = 'iframe'
      args = [r.method]
     redirect(URL(f='person', vars=vars, args=args))
   elif (r.method == 'import'):
    redirect(URL(f='person', args='import', vars={'group': 'staff'}))
   elif ((not r.component) and (r.method != 'delete')):
    field = table.site_id
    site_id = get_vars.get('site_id', None)
    if site_id:
     field.default = site_id
     field.writable = False
    field.comment = DIV(DIV(_class='tooltip', _title=('%s|%s' % (settings.get_org_site_label(), T('The facility where this position is based.')))))
    table.status.writable = table.status.readable = False
    dob = s3db.pr_person.date_of_birth
    dob.widget = S3CalendarWidget(past_months=972, future_months=(-192))
  return True
 s3.prep = prep
 def postp(r, output):
  if r.interactive:
   if (not r.component):
    s3_action_buttons(r, deletable=settings.get_hrm_deletable())
    if (('msg' in settings.modules) and settings.get_hrm_compose_button() and auth.permission.has_permission('update', c='hrm', f='compose')):
     s3.actions.append({'url': URL(f='compose', vars={'human_resource.id': '[id]'}), '_class': 'action-btn send', 'label': str(T('Send Message'))})
  elif (r.representation == 'plain'):
   output = s3db.hrm_map_popup(r)
  return output
 s3.postp = postp
 return s3_rest_controller('hrm', 'human_resource')

def staff ( ) : s3 . filter = ( FS ( 'type' ) == 1 ) def prep ( r ) : table = r . table tablename = r . tablename get_vars = r . get_vars crud_strings = s3 . crud_strings crud_strings [ tablename ] = crud_strings [ 'hrm_staff' ] resource = r . resource if ( 'expiring' in get_vars ) : query = ( FS ( 'end_date' ) < ( request . utcnow + datetime . timedelta ( weeks = 4 ) ) ) resource . add_filter ( query ) crud_strings [ tablename ] . title_list = T ( 'Staff with Contracts Expiring in the next Month' ) resource . configure ( sortby = table . end_date , insertable = False ) list_fields = [ ( T ( 'Contract End Date' ) , 'end_date' ) , 'person_id' , 'job_title_id' , 'organisation_id' , 'site_id' ] if settings . get_hrm_staff_departments ( ) : list_fields . insert ( 4 , 'department_id' ) resource . configure ( list_fields = list_fields ) elif ( r . representation == 'xls' ) : s3db . hrm_xls_list_fields ( r , vol = False ) else : list_fields = [ 'person_id' , 'job_title_id' , 'organisation_id' , 'site_id' , ( T ( 'Email' ) , 'email.value' ) , ( settings . get_ui_label_mobile_phone ( ) , 'phone.value' ) ] if settings . get_hrm_staff_departments ( ) : list_fields . insert ( 3 , 'department_id' ) if settings . get_hrm_use_trainings ( ) : list_fields . append ( 'person_id$training.course_id' ) if settings . get_hrm_use_certificates ( ) : list_fields . append ( 'person_id$certification.certificate_id' ) list_fields . append ( ( T ( 'Contract End Date' ) , 'end_date' ) ) list_fields . append ( 'status' ) resource . configure ( list_fields = list_fields ) if r . interactive : if r . id : if ( r . method not in ( 'profile' , 'delete' ) ) : vars = { 'human_resource.id' : r . id , 'group' : 'staff' } args = [ ] if ( r . representation == 'iframe' ) : vars [ 'format' ] = 'iframe' args = [ r . method ] redirect ( URL ( f = 'person' , vars = vars , args = args ) ) elif ( r . method == 'import' ) : redirect ( URL ( f = 'person' , args = 'import' , vars = { 'group' : 'staff' } ) ) elif ( ( not r . component ) and ( r . method != 'delete' ) ) : field = table . site_id site_id = get_vars . get ( 'site_id' , None ) if site_id : field . default = site_id field . writable = False field . comment = DIV ( DIV ( _class = 'tooltip' , _title = ( '%s|%s' % ( settings . get_org_site_label ( ) , T ( 'The facility where this position is based.' ) ) ) ) ) table . status . writable = table . status . readable = False dob = s3db . pr_person . date_of_birth dob . widget = S3CalendarWidget ( past_months = 972 , future_months = ( - 192 ) ) return True s3 . prep = prep def postp ( r , output ) : if r . interactive : if ( not r . component ) : s3_action_buttons ( r , deletable = settings . get_hrm_deletable ( ) ) if ( ( 'msg' in settings . modules ) and settings . get_hrm_compose_button ( ) and auth . permission . has_permission ( 'update' , c = 'hrm' , f = 'compose' ) ) : s3 . actions . append ( { 'url' : URL ( f = 'compose' , vars = { 'human_resource.id' : '[id]' } ) , '_class' : 'action-btn send' , 'label' : str ( T ( 'Send Message' ) ) } ) elif ( r . representation == 'plain' ) : output = s3db . hrm_map_popup ( r ) return output s3 . postp = postp return s3_rest_controller ( 'hrm' , 'human_resource' )
rest controller for budget_staff .