class Trip < Sequel::Model(:'trips') # NOTE - Count of instances as of 06/01/2009 => 32927 # Many to one associations with atomic primary keys many_to_one :aircraft, :class=>:Aircraft, :key=>:'aircraft id', :primary_key=>:'aircraft id' many_to_one :aircraft_type, :class=>:AircraftType, :key=>:'aircraft type id', :primary_key=>:'aircraft type id' many_to_one :locked_by, :class=>:User, :key=>:'locked by - user id', :primary_key=>:'users initials' # Many to one associations with custom treatment many_to_one :popup_comment, :class=>:Comment, :key=>nil, :dataset=>proc{Comment.filter( :kid_date=>kid_date, :kid_time=>kid_time, :kid_user=>kid_user, :kid_mult=>kid_mult, :kid_comm=>((kid_comm*10)+4) )} many_to_one :lead_pax, :class=>:TripPassenger, :key=>nil, :graph_only_conditions => { :"trip kid - date" => :'kid - date', :"trip kid - time" => :'kid - time', :"trip kid - user" => :'kid - user', :"trip kid - mult" => :'kid - mult', :"trip kid - comm" => :'kid - comm', :'lead pax' => 1 }, :dataset => lambda{ TripPassenger.filter( :"trip kid - date"=>self[:'kid - date'], :"trip kid - time"=>self[:'kid - time'], :"trip kid - user"=>self[:'kid - user'], :"trip kid - mult"=>self[:'kid - mult'], :"trip kid - comm"=>self[:'kid - comm'], :'lead pax' => 1) } # Many to one associations with composite primary keys n_to_o :quote, :class=>:Quote, :prefix=>'quote' n_to_o :trip_authorizer, :class=>:Passenger, :prefix=>'author' n_to_o :trip_planner, :class=>:Passenger, :prefix=>'planner' n_to_o :trip_requester, :class=>:Passenger, :prefix=>'requester' # One to many associations with composite primary keys o_to_n :crew_trips, :class=>:CrewTrip, :prefix=>'trip' o_to_n :trip_legs, :class=>:TripLeg, :prefix=>'trips' o_to_n :audit_trails, :class=>:AuditTrail, :prefix=>'owner' o_to_n :passengers, :class => :TripPassenger, :prefix => 'trip' o_to_n :attachments, :class => :VendorDocument, :prefix => 'vendor' o_to_n :comments, :class=>:Comment, :prefix=>'owner' def _add_attachment(attachment) attachment.vendor_kid_date = self.kid_date attachment.vendor_kid_time = self.kid_time attachment.vendor_kid_user = self.kid_user attachment.vendor_kid_comm = self.kid_comm attachment.vendor_kid_mult = self.kid_mult attachment.save end # One to many associations with composite primary key (reverse lookup) one_to_many :trip_passengers, :class=>:TripPassenger, :key=>nil, :dataset=>proc{TripPassenger.filter( :trip_kid_date=>self.kid_date, :trip_kid_time=>self.kid_time,:trip_kid_user=>self.kid_user,:trip_kid_comm=>self.kid_comm,:trip_kid_mult=>self.kid_mult)} one_to_many :all_comments, :class=>:Comment, :dataset=>proc{Comment.filter( :kid_date=>kid_date, :kid_time=>kid_time, :kid_user=>kid_user, :kid_mult=>kid_mult, :kid_comm=>(kid_comm*10)..(kid_comm*10+9))} # Code associations code_association :department_value, :'department code', :department code_association :company_value, :'company code', :company code_association :division_value, :'division code', :division code_association :purpose_value, :'purpose code', :purpose code_association :trip_type_value, :'trip type code', :trip_type code_association :rate_type_value, :'rate type code', :aircraft_rate code_association :base_value, :'base code', :location code_association :cancellation_code, :'cancel code', :cancellation_code code_association :passenger_rate, :'pax rate', :passenger_rate code_association :approval_value, :'approval_code', :trip_approval code_association :special_qualification, :'specialqualification', :special_qualification #Column Views column_view :kid_date, :date, :scheduled_date #### BEGIN GENERATED SECTION #### set_primary_key [:'kid - user', :'kid - mult', :'kid - comm', :'kid - date', :'kid - time'] column_alias :ac_owner_code, :'ac owner code' column_alias :ac_rest_type, :'ac rest type' column_alias :ac_tail_number, :'ac tail number' column_alias :aircraft_id, :'aircraft id' column_alias :aircraft_type_id, :'aircraft type id' column_alias :airfare, :'airfare' column_alias :airfare_fixed, :'airfare fixed' column_alias :approval_code, :'approval code' column_alias :arrival_date_gmt, :'arrival date - gmt' column_alias :arrival_date_home, :'arrival date - home' column_alias :arrival_date_local, :'arrival date - local' column_alias :author_kid_comm, :'author kid - comm' column_alias :author_kid_date, :'author kid - date' column_alias :author_kid_mult, :'author kid - mult' column_alias :author_kid_time, :'author kid - time' column_alias :author_kid_user, :'author kid - user' column_alias :authorizer, :'authorizer' column_alias :base_code, :'base code' column_alias :billable, :'billable' column_alias :billable_cost, :'billable cost' column_alias :billable_cost_fixed, :'billable cost fixed' column_alias :billable_expenses, :'billable expenses' column_alias :business_reason, :'business reason' column_alias :cancel_code, :'cancel code' column_alias :company_code, :'company code' column_alias :contract_number, :'contract number' column_alias :cost, :'cost' column_alias :cost_center, :'cost center' column_alias :cost_fixed, :'cost fixed' column_alias :cost_percent, :'cost percent' column_alias :crew_brief, :'crew brief' column_alias :d_h_cost, :'d/h cost' column_alias :date_to_gmt_offset, :'date to gmt offset' column_alias :depart_date_home, :'depart date - home' column_alias :depart_date_local, :'depart date - local' column_alias :department_code, :'department code' column_alias :departure_date_gmt, :'departure date - gmt' column_alias :dept_date_gmt_offset, :'dept date gmt offset' column_alias :division_code, :'division code' column_alias :email, :'email' column_alias :eta_gmt, :'eta - gmt' column_alias :eta_home, :'eta - home' column_alias :eta_local, :'eta - local' column_alias :etd_gmt, :'etd - gmt' column_alias :etd_home, :'etd - home' column_alias :etd_local, :'etd - local' column_alias :ext_trip_id, :'ext trip id' column_alias :ext_trip_num, :'ext trip num' column_alias :fs_apis, :'fs apis' column_alias :fs_aro_dom_slot, :'fs aro dom slot' column_alias :fs_ac_parking, :'fs ac parking' column_alias :fs_ac_security, :'fs ac security' column_alias :fs_aircraft_charter, :'fs aircraft charter' column_alias :fs_catering, :'fs catering' column_alias :fs_crew_hotel, :'fs crew hotel' column_alias :fs_crew_limo, :'fs crew limo' column_alias :fs_crew_visa, :'fs crew visa' column_alias :fs_customs, :'fs customs' column_alias :fs_flight_following, :'fs flight following' column_alias :fs_flight_plan_cond, :'fs flight plan cond' column_alias :fs_flight_planning, :'fs flight planning' column_alias :fs_flt_plan_wind, :'fs flt plan wind' column_alias :fs_fueler, :'fs fueler' column_alias :fs_gnd_handling, :'fs gnd handling' column_alias :fs_hotel, :'fs hotel' column_alias :fs_landing_permit, :'fs landing permit' column_alias :fs_misc, :'fs misc' column_alias :fs_overflight_permit, :'fs overflight permit' column_alias :fs_prefile, :'fs prefile' column_alias :fs_prelim_flt_plan, :'fs prelim flt plan' column_alias :fs_security_guard, :'fs security guard' column_alias :fs_slots, :'fs slots' column_alias :fs_transportation, :'fs transportation' column_alias :fs_uplink_afis, :'fs uplink afis' column_alias :fs_uplink_uvdata, :'fs uplink uvdata' column_alias :fs_visa, :'fs visa' column_alias :fs_weather_brief, :'fs weather brief' column_alias :fs_weather_outlook, :'fs weather outlook' column_alias :fs_weather_update, :'fs weather update' column_alias :fs_wx_brief_intl, :'fs wx brief intl' column_alias :fs2, :'fs2' column_alias :flight_plan_code, :'flight plan code' column_alias :flt_following, :'flt following' column_alias :group, :'group' column_alias :history, :'history' column_alias :internal_10, :'internal 10' column_alias :internal_11, :'internal 11' column_alias :internal_6, :'internal 6' column_alias :internal01, :'internal01' column_alias :internal02, :'internal02' column_alias :internal03, :'internal03' column_alias :internal04, :'internal04' column_alias :intl_leg_count, :'intl leg count' column_alias :kid_comm, :'kid - comm' column_alias :kid_date, :'kid - date' column_alias :kid_mult, :'kid - mult' column_alias :kid_time, :'kid - time' column_alias :kid_user, :'kid - user' column_alias :language, :'language' column_alias :last_update_date, :'last update date' column_alias :last_update_time, :'last update time' column_alias :last_updated, :'last updated' column_alias :leg_billable, :'leg billable' column_alias :leg_count, :'leg count' column_alias :leg_flight_number, :'leg flight number' column_alias :lock_date, :'lock date' column_alias :lock_time, :'lock time' column_alias :lock_user, :'lock user' column_alias :locked, :'locked' column_alias :locked_by_user_id, :'locked by - user id' column_alias :min_average_ac_1, :'min average ac 1' column_alias :min_average_ac_2, :'min average ac 2' column_alias :min_average_ac_3, :'min average ac 3' column_alias :min_average_ac_4, :'min average ac 4' column_alias :min_average_legs_1, :'min average legs 1' column_alias :min_average_legs_2, :'min average legs 2' column_alias :min_average_legs_3, :'min average legs 3' column_alias :min_average_legs_4, :'min average legs 4' column_alias :min_average_pax_1, :'min average pax 1' column_alias :min_average_pax_2, :'min average pax 2' column_alias :min_average_pax_3, :'min average pax 3' column_alias :min_average_pax_4, :'min average pax 4' column_alias :no_fly_date, :'no fly date' column_alias :no_fly_number, :'no fly number' column_alias :no_fly_number_str, :'no fly number str' column_alias :no_fly_user, :'no fly user' column_alias :note, :'note' column_alias :open_checklist, :'open checklist' column_alias :pager, :'pager' column_alias :pax_billable, :'pax billable' column_alias :pax_rate, :'pax rate' column_alias :planner, :'planner' column_alias :planner_fax, :'planner fax' column_alias :planner_kid_comm, :'planner kid - comm' column_alias :planner_kid_date, :'planner kid - date' column_alias :planner_kid_mult, :'planner kid - mult' column_alias :planner_kid_time, :'planner kid - time' column_alias :planner_kid_user, :'planner kid - user' column_alias :planner_phone, :'planner phone' column_alias :priority, :'priority' column_alias :privilege, :'privilege' column_alias :problem_set, :'problem set' column_alias :purpose_code, :'purpose code' column_alias :quote_kid_comm, :'quote kid - comm' column_alias :quote_kid_date, :'quote kid - date' column_alias :quote_kid_mult, :'quote kid - mult' column_alias :quote_kid_time, :'quote kid - time' column_alias :quote_kid_user, :'quote kid - user' column_alias :quoted_ac_cost, :'quoted a/c cost' column_alias :quoted_addl_cost, :'quoted addl cost' column_alias :quoted_fuel_cost, :'quoted fuel cost' column_alias :quotes_ac_rate, :'quotes ac rate' column_alias :rate_type_code, :'rate type code' column_alias :regulation, :'regulation' column_alias :release_date, :'release date' column_alias :release_time, :'release time' column_alias :release_user, :'release user' column_alias :request_date, :'request date' column_alias :request_number, :'request number' column_alias :requester_kid_comm, :'requester kid - comm' column_alias :requester_kid_date, :'requester kid - date' column_alias :requester_kid_mult, :'requester kid - mult' column_alias :requester_kid_time, :'requester kid - time' column_alias :requester_kid_user, :'requester kid - user' column_alias :requester_name, :'requester name' column_alias :requester_name_key, :'requester name key' column_alias :requester_purpose, :'requester purpose' column_alias :restricted, :'restricted' column_alias :route_comment, :'route comment' column_alias :shuttle_flight, :'shuttle flight' column_alias :sortie, :'sortie' column_alias :special_handling, :'special handling' column_alias :specialqualification, :'specialqualification' column_alias :status, :'status' column_alias :status_closed, :'status closed' column_alias :tax, :'tax' column_alias :total_block_time, :'total block time' column_alias :total_expenses, :'total expenses' column_alias :total_flight_time, :'total flight time' column_alias :total_hobbs, :'total hobbs' column_alias :total_nautical_miles, :'total nautical miles' column_alias :total_pax_cost, :'total pax cost' column_alias :total_pax_count, :'total pax count' column_alias :total_statute_miles, :'total statute miles' column_alias :trip_number, :'trip number' column_alias :trip_pax_comment, :'trip pax comment' column_alias :trip_request, :'trip request' column_alias :trip_type_code, :'trip type code' column_alias :vendor_id, :'vendor id' column_alias :winter, :'winter' column_alias :internal_cost_3, :'internal cost 3' column_alias :internal_cost_4, :'internal cost 4' column_alias :internal_cost_5, :'internal cost 5' column_alias :key0, :'key0' column_alias :key1, :'key1' column_alias :key10, :'key10' column_alias :key11, :'key11' column_alias :key12, :'key12' column_alias :key13, :'key13' column_alias :key14, :'key14' column_alias :key2, :'key2' column_alias :key3, :'key3' column_alias :key4, :'key4' column_alias :key5, :'key5' column_alias :key6, :'key6' column_alias :key7, :'key7' column_alias :key8, :'key8' column_alias :key9, :'key9' column_alias :reserved_2, :'reserved 2' column_alias :reserved_3, :'reserved 3' #### END GENERATED SECTION #### end