#NEWLINE# @ staticmethod #NEWLINE# def irs_dispatch( r , **attr ) : #NEWLINE# #INDENT# '\n            Send a Dispatch notice from an Incident Report\n            - this will be formatted as an OpenGeoSMS\n        ' #NEWLINE# if ( ( r . representation == 'html' ) and ( r . name == 'ireport' ) and r . id and ( not r . component ) ) : #NEWLINE# #INDENT# T = current . T #NEWLINE# msg = current . msg #NEWLINE# record = r . record #NEWLINE# id = record . id #NEWLINE# contact = '' #NEWLINE# if record . contact : #NEWLINE# #INDENT# contact = '\n%s: %s' ( T ( 'Contact' ) , record . contact ) #NEWLINE# #UNINDENT# message = '' #NEWLINE# if record . message : #NEWLINE# #INDENT# message = ( '\n%s' % record . message ) #NEWLINE# #UNINDENT# text = ( 'SI#%s\n%s%s%s' % ( id , record . name , contact , message ) ) #NEWLINE# text += '\nSend help to see how to respond!' #NEWLINE# message = msg . prepare_opengeosms ( record . location_id , code = 'ST' , map = 'google' , text = text ) #NEWLINE# url = URL ( c = 'irs' , f = 'ireport' , args = r . id ) #NEWLINE# opts = dict ( type = 'SMS' , subject = T ( 'Deployment Request' ) , message = message , url = url ) #NEWLINE# s3db = current . s3db #NEWLINE# if current . deployment_settings . get_irs_vehicle ( ) : #NEWLINE# #INDENT# table = s3db . irs_ireport_vehicle_human_resource #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# table = s3db . irs_ireport_human_resource #NEWLINE# #UNINDENT# htable = s3db . hrm_human_resource #NEWLINE# ptable = s3db . pr_person #NEWLINE# query = ( ( ( ( table . ireport_id == id ) & ( table . deleted == False ) ) & ( table . human_resource_id == htable . id ) ) & ( htable . person_id == ptable . id ) ) #NEWLINE# recipients = current . db ( query ) . select ( table . incident_commander , ptable . pe_id ) #NEWLINE# if ( not recipients ) : #NEWLINE# #INDENT# opts [ 'recipient_type' ] = 'pr_person' #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# if ( len ( recipients ) == 1 ) : #NEWLINE# #INDENT# opts [ 'recipient' ] = recipients . first ( ) [ 'pr_person' ] . pe_id #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# ic = False #NEWLINE# for row in recipients : #NEWLINE# #INDENT# if ( row [ 'irs_ireport_human_resource' ] . incident_commander == True ) : #NEWLINE# #INDENT# opts [ 'recipient' ] = row [ 'pr_person' ] . pe_id #NEWLINE# ic = True #NEWLINE# break #NEWLINE# #UNINDENT# #UNINDENT# if ( not ic ) : #NEWLINE# #INDENT# opts [ 'recipient_type' ] = 'pr_person' #NEWLINE# #UNINDENT# #UNINDENT# #UNINDENT# output = msg . compose ( ** opts ) #NEWLINE# if attr . get ( 'rheader' ) : #NEWLINE# #INDENT# rheader = attr [ 'rheader' ] ( r ) #NEWLINE# if rheader : #NEWLINE# #INDENT# output [ 'rheader' ] = rheader #NEWLINE# #UNINDENT# #UNINDENT# output [ 'title' ] = T ( 'Send Dispatch Update' ) #NEWLINE# current . response . view = 'msg/compose.html' #NEWLINE# return output #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# raise HTTP ( 405 , current . ERROR . BAD_METHOD )