class TripLeg < Sequel::Model(:'trip legs') # NOTE - Count of instances as of 06/01/2009 => 70630 set_primary_key [:'kid - user', :'kid - mult', :'kid - comm', :'kid - date', :'kid - time'] # 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 :leg_rate_aircraft, :class=>:Aircraft, :key=>:'leg rate ac id', :primary_key=>:'aircraft id' many_to_one :authorizer_name, :class=>:Personnel, :key=>:authorization, :primary_key=>:employee_id # Many to one associations with composite primary keys n_to_o :trip, :class=>:Trip, :prefix=>'trips' n_to_o :arrival_airport_fuel, :class => :AirportFuel, :prefix => 'arr fuel' n_to_o :departure_airport_fuel, :class => :AirportFuel, :prefix => 'dep fuel' n_to_o :crew_hotel, :class=>:AirportService, :prefix=>'crewhotel' n_to_o :leg_authorizer, :class=>:Passenger, :prefix=>'author' n_to_o :catering, :class=>:AirportService, :prefix=>'catering' n_to_o :crew_limo, :class=>:AirportService, :prefix=>'crewlimo' n_to_o :arrival_fbo, :class=>:AirportFbo, :prefix=>'fbo' n_to_o :departure_fbo, :class=>:AirportFbo, :prefix=>'fueler' n_to_o :leg_rate, :class=>:AircraftRate, :prefix=>'leg rate' n_to_o :leg_requestor, :class=>:Passenger, :prefix=>'leg req' n_to_o :pax_limo, :class=>:AirportService, :prefix=>'limo' n_to_o :misc_service1, :class=>:AirportService, :prefix=>'misc 1' n_to_o :misc_service2, :class=>:AirportService, :prefix=>'misc 2' n_to_o :misc_service3, :class=>:AirportService, :prefix=>'misc 3' n_to_o :pax_hotel, :class=>:AirportService, :prefix=>'pax hotel' n_to_o :planner, :class=>:Passenger, :prefix=>'planner' n_to_o :trip_requester, :class=>:Passenger, :prefix=>'requester' # Many to one associations with custom treatment many_to_one :arrival_airport, :class=>:Airport, :key=>nil, :dataset=> proc { if !arrival_icao.blank? Airport.filter(:'icao'=> arrival_icao) else Airport.filter(:'airport id prefix'.like("%#{arrival_ap_prefix}"), :'airport id'.like("%#{arrival_airport_id}")) end } many_to_one :departure_airport, :class=>:Airport, :key=>:departure_icao, :primary_key=>:icao #:key=>nil, :dataset=>proc{ ref_method = self[:'depart-icao/iata/id']; case ref_method; when 1 then Airport.filter(:'icao'=>self[:'departure icao']); when 2 then Airport.filter(:'iata'=>self[:'departure iata']); else Airport.filter(:'airport id prefix'.like("%#{self[:'depart a/p prefix']}"), :'airport id'.like("%#{self[:'depart airport id']}")); end } many_to_one :alternate_arrival_airport, :class=>:Airport, :key=>nil, :dataset=>proc{ Airport.filter(:'airport id prefix'.like("%#{self[:'arr alt prefix']}"), :'airport id'.like( "%#{self[:'arr alt id']}"))} many_to_one :alternate_departure_airport, :class=>:Airport, :key=>nil, :dataset=>proc{ Airport.filter(:'airport id prefix'.like("%#{self[:'dep alt prefix']}"), :'airport id'.like( "%#{self[:'dep alt id']}"))} # One to many associations with composite primary keys o_to_n :crew_legs, :class=>:CrewLeg, :prefix=>'trip leg' o_to_n :audit_trails, :class=>:AuditTrail, :prefix=>'owner' o_to_n :flight_log_expenses, :class=>:FlightLogExpense, :prefix=>'trip leg' # Code associations code_association :approval_value, :'approval code', :trip_approval code_association :base, :'base', :location code_association :cancellation_code, :'cancel code', :cancellation_code code_association :company_value, :'company', :company code_association :delay_1_reason_value, :'delay 1 reason', :delay_reason code_association :delay_2_reason_value, :'delay 2 reason', :delay_reason code_association :department_value, :'department', :department code_association :division_value, :'division', :division code_association :regulation_code, :'regulation', :certification code_association :purpose_value, :'leg purpose code', :purpose code_association :leg_rate_value, :'leg rate code', :aircraft_rate code_association :leg_type_value, :'leg type code', :trip_type code_association :trip_type_value, :'leg type code', :trip_type code_association :special_qualification_value, :'specialqualification', :special_qualification #### BEGIN GENERATED SECTION #### column_alias :ac_cost_fixed, :'a/c cost fixed' column_alias :ac_log_ac_hrs, :'a/c log a/c hrs' column_alias :ac_log_acc_cyc_1, :'a/c log acc cyc 1' column_alias :ac_log_acc_cyc_2, :'a/c log acc cyc 2' column_alias :ac_log_acc_hrs_1, :'a/c log acc hrs 1' column_alias :ac_log_acc_hrs_2, :'a/c log acc hrs 2' column_alias :ac_log_eng_acc_cyc1, :'a/c log eng acc cyc1' column_alias :ac_log_eng_acc_cyc2, :'a/c log eng acc cyc2' column_alias :ac_log_eng_acc_cyc3, :'a/c log eng acc cyc3' column_alias :ac_log_eng_acc_cyc4, :'a/c log eng acc cyc4' column_alias :ac_log_eng_acc_hrs1, :'a/c log eng acc hrs1' column_alias :ac_log_eng_acc_hrs2, :'a/c log eng acc hrs2' column_alias :ac_log_eng_acc_hrs3, :'a/c log eng acc hrs3' column_alias :ac_log_eng_acc_hrs4, :'a/c log eng acc hrs4' column_alias :ac_log_eng_cyc_fix1, :'a/c log eng cyc fix1' column_alias :ac_log_eng_cyc_fix2, :'a/c log eng cyc fix2' column_alias :ac_log_eng_cyc_fix3, :'a/c log eng cyc fix3' column_alias :ac_log_eng_cyc_fix4, :'a/c log eng cyc fix4' column_alias :ac_log_eng_cycles_1, :'a/c log eng cycles 1' column_alias :ac_log_eng_cycles_2, :'a/c log eng cycles 2' column_alias :ac_log_eng_cycles_3, :'a/c log eng cycles 3' column_alias :ac_log_eng_cycles_4, :'a/c log eng cycles 4' column_alias :ac_log_eng_hrs_1, :'a/c log eng hrs 1' column_alias :ac_log_eng_hrs_2, :'a/c log eng hrs 2' column_alias :ac_log_eng_hrs_3, :'a/c log eng hrs 3' column_alias :ac_log_eng_hrs_4, :'a/c log eng hrs 4' column_alias :ac_log_eng_hrs_fix1, :'a/c log eng hrs fix1' column_alias :ac_log_eng_hrs_fix2, :'a/c log eng hrs fix2' column_alias :ac_log_eng_hrs_fix3, :'a/c log eng hrs fix3' column_alias :ac_log_eng_hrs_fix4, :'a/c log eng hrs fix4' column_alias :ac_log_eng_oil_1, :'a/c log eng oil 1' column_alias :ac_log_eng_oil_2, :'a/c log eng oil 2' column_alias :ac_log_eng_oil_3, :'a/c log eng oil 3' column_alias :ac_log_eng_oil_4, :'a/c log eng oil 4' column_alias :ac_log_eng_starts_1, :'a/c log eng starts 1' column_alias :ac_log_eng_starts_2, :'a/c log eng starts 2' column_alias :ac_log_eng_starts_3, :'a/c log eng starts 3' column_alias :ac_log_eng_starts_4, :'a/c log eng starts 4' column_alias :ac_log_eng_cp_1, :'a/c log eng cp 1' column_alias :ac_log_eng_cp_2, :'a/c log eng cp 2' column_alias :ac_log_eng_cp_3, :'a/c log eng cp 3' column_alias :ac_log_eng_cp_4, :'a/c log eng cp 4' column_alias :ac_log_eng_gp_1, :'a/c log eng gp 1' column_alias :ac_log_eng_gp_2, :'a/c log eng gp 2' column_alias :ac_log_eng_gp_3, :'a/c log eng gp 3' column_alias :ac_log_eng_gp_4, :'a/c log eng gp 4' column_alias :ac_log_eng_ip_1, :'a/c log eng ip 1' column_alias :ac_log_eng_ip_2, :'a/c log eng ip 2' column_alias :ac_log_eng_ip_3, :'a/c log eng ip 3' column_alias :ac_log_eng_ip_4, :'a/c log eng ip 4' column_alias :ac_log_eng_pt_1, :'a/c log eng pt 1' column_alias :ac_log_eng_pt_2, :'a/c log eng pt 2' column_alias :ac_log_eng_pt_3, :'a/c log eng pt 3' column_alias :ac_log_eng_pt_4, :'a/c log eng pt 4' column_alias :ac_log_leg_number, :'a/c log leg number' column_alias :ac_log_lifts, :'a/c log lifts' column_alias :ac_log_page_number, :'a/c log page number' column_alias :ac_log_rev_deploy, :'a/c log rev deploy' column_alias :ac_log_rev_eng_cyc, :'a/c log rev eng cyc' column_alias :ac_rest_type, :'ac rest type' column_alias :apis_num, :'apis num' column_alias :ac_class_code, :'ac class code' column_alias :actual_nautical_mile, :'actual nautical mile' column_alias :additional_time, :'additional time' column_alias :addl_nm_fixed, :'addl nm fixed' column_alias :addl_nautical_miles, :'addl nautical miles' column_alias :addl_time_fixed, :'addl time fixed' column_alias :addon_cost, :'addon cost' column_alias :air_chef, :'air chef' column_alias :aircraft_cost, :'aircraft cost' column_alias :aircraft_cruise, :'aircraft cruise' column_alias :aircraft_id, :'aircraft id' column_alias :aircraft_type_id, :'aircraft type id' column_alias :airline_cost, :'airline cost' column_alias :airline_cost_fixed, :'airline cost fixed' column_alias :alert_flight, :'alert flight' column_alias :altitude, :'altitude' column_alias :altitude_fixed, :'altitude fixed' column_alias :amend_date, :'amend date' column_alias :amend_time, :'amend time' column_alias :amended_by, :'amended by' column_alias :approach_1_category, :'approach 1 category' column_alias :approach_1_qty, :'approach 1 qty' column_alias :approach_1_type, :'approach 1 type' column_alias :approach_2_category, :'approach 2 category' column_alias :approach_2_qty, :'approach 2 qty' column_alias :approach_2_type, :'approach 2 type' column_alias :approach_3_category, :'approach 3 category' column_alias :approach_3_qty, :'approach 3 qty' column_alias :approach_3_type, :'approach 3 type' column_alias :approval_code, :'approval code' column_alias :arr_alt_id, :'arr alt id' column_alias :arr_alt_prefix, :'arr alt prefix' column_alias :arr_alt_sch, :'arr alt sch' column_alias :arr_ap_chg, :'arr ap chg' column_alias :arr_date_act_gmt, :'arr date act gmt' column_alias :arr_date_act_home, :'arr date act home' column_alias :arr_date_act_local, :'arr date act local' column_alias :arr_fuel_kid_comm, :'arr fuel kid - comm' column_alias :arr_fuel_kid_date, :'arr fuel kid - date' column_alias :arr_fuel_kid_mult, :'arr fuel kid - mult' column_alias :arr_fuel_kid_time, :'arr fuel kid - time' column_alias :arr_fuel_kid_user, :'arr fuel kid - user' column_alias :arr_fuel_vendor, :'arr fuel vendor' column_alias :arr_special_trn, :'arr special trn' column_alias :arriv_tz_gmt_offset, :'arriv tz gmt offset' column_alias :arriv_time_act_gmt, :'arriv time act gmt' column_alias :arriv_time_act_local, :'arriv time act local' column_alias :arrival, :'arrival' column_alias :arrival_ap_prefix, :'arrival a/p prefix' column_alias :arrival_aro, :'arrival aro' column_alias :arrival_airport_id, :'arrival airport id' column_alias :arrival_date_local, :'arrival date - local' column_alias :arrival_date_gmt, :'arrival date gmt' column_alias :arrival_date_home, :'arrival date home' column_alias :arrival_iata, :'arrival iata' column_alias :arrival_icao, :'arrival icao' column_alias :arrival_non_ap_site, :'arrival non-ap site' column_alias :arrival_site_desc, :'arrival site desc' column_alias :arrival_time_act_hom, :'arrival time act hom' column_alias :arrival_time_est, :'arrival time est.' column_alias :arrival_icao_iata_id, :'arrival-icao/iata/id' column_alias :aug_crew_count, :'aug crew count' 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 :authorization, :'authorization' column_alias :auto_validate, :'auto validate' column_alias :base, :'base' column_alias :billable, :'billable' column_alias :billable_expenses, :'billable expenses' column_alias :block_time_actual, :'block time actual' column_alias :breakfast_comment, :'breakfast comment' column_alias :cg, :'cg' column_alias :cg_limit_aft, :'cg limit aft' column_alias :cg_limit_fwd, :'cg limit fwd' column_alias :cancel_code, :'cancel code' column_alias :cancelled, :'cancelled' column_alias :cargo_pounds, :'cargo - pounds' column_alias :cargo_actual, :'cargo actual' column_alias :cargo_off_at_arrival, :'cargo off at arrival' column_alias :cargo_on_at_depart, :'cargo on at depart' column_alias :category_2_appr, :'category 2 appr' column_alias :catering_comment, :'catering comment' column_alias :catering_departure, :'catering departure' column_alias :catering_flags, :'catering flags' column_alias :catering_kid_comm, :'catering kid - comm' column_alias :catering_kid_date, :'catering kid - date' column_alias :catering_kid_mult, :'catering kid - mult' column_alias :catering_kid_time, :'catering kid - time' column_alias :catering_kid_user, :'catering kid - user' column_alias :closed, :'closed' column_alias :company, :'company' column_alias :cost_center, :'cost center' column_alias :crew_brief, :'crew brief' column_alias :crew_change, :'crew change' column_alias :crew_duty, :'crew duty' column_alias :crew_flight, :'crew flight' column_alias :crew_hotel_comment, :'crew hotel comment' column_alias :crew_hotel_departure, :'crew hotel departure' column_alias :crew_hotel_flags, :'crew hotel flags' column_alias :crew_pic_chg, :'crew pic chg' column_alias :crew_rest, :'crew rest' column_alias :crew_training_count, :'crew training count' column_alias :crewhotel_kid_comm, :'crewhotel kid - comm' column_alias :crewhotel_kid_date, :'crewhotel kid - date' column_alias :crewhotel_kid_mult, :'crewhotel kid - mult' column_alias :crewhotel_kid_time, :'crewhotel kid - time' column_alias :crewhotel_kid_user, :'crewhotel kid - user' column_alias :crewlimo_comment, :'crewlimo comment' column_alias :crewlimo_depart, :'crewlimo depart' column_alias :crewlimo_flags, :'crewlimo flags' column_alias :crewlimo_kid_comm, :'crewlimo kid - comm' column_alias :crewlimo_kid_date, :'crewlimo kid - date' column_alias :crewlimo_kid_mult, :'crewlimo kid - mult' column_alias :crewlimo_kid_time, :'crewlimo kid - time' column_alias :crewlimo_kid_user, :'crewlimo kid - user' column_alias :dh_confirmed, :'dh confirmed' column_alias :dh_cost, :'dh cost' column_alias :dh_currency, :'dh currency' column_alias :dh_date_begin, :'dh date begin' column_alias :dh_date_end, :'dh date end' column_alias :dh_flex_begin, :'dh flex begin' column_alias :dh_flex_end, :'dh flex end' column_alias :dh_flex_times, :'dh flex times' column_alias :dh_pax_count, :'dh pax count' column_alias :dh_pax_ent, :'dh pax ent' column_alias :dh_pax_personal, :'dh pax personal' column_alias :day1_reserve_leg, :'day1 reserve leg' column_alias :deadhead, :'deadhead' column_alias :deiced, :'deiced' column_alias :delay_1_reason, :'delay 1 reason' column_alias :delay_1_time, :'delay 1 time' column_alias :delay_2_reason, :'delay 2 reason' column_alias :delay_2_time, :'delay 2 time' column_alias :delay_3_reason, :'delay 3 reason' column_alias :delay_3_time, :'delay 3 time' column_alias :delay_4_reason, :'delay 4 reason' column_alias :delay_4_time, :'delay 4 time' column_alias :delay_comment, :'delay comment' column_alias :delivery_comment, :'delivery comment' column_alias :dep_alt_id, :'dep alt id' column_alias :dep_alt_prefix, :'dep alt prefix' column_alias :dep_alt_sch, :'dep alt sch' column_alias :dep_ap_chg, :'dep ap chg' column_alias :dep_fuel_kid_comm, :'dep fuel kid - comm' column_alias :dep_fuel_kid_date, :'dep fuel kid - date' column_alias :dep_fuel_kid_mult, :'dep fuel kid - mult' column_alias :dep_fuel_kid_time, :'dep fuel kid - time' column_alias :dep_fuel_kid_user, :'dep fuel kid - user' column_alias :dep_fuel_vendor, :'dep fuel vendor' column_alias :dep_special_trn, :'dep special trn' column_alias :depart_ap_prefix, :'depart a/p prefix' column_alias :depart_airport_id, :'depart airport id' column_alias :depart_date_local, :'depart date - local' column_alias :depart_date_key, :'depart date key' column_alias :depart_non_ap_site, :'depart non-ap site' column_alias :depart_site_desc, :'depart site desc' column_alias :depart_tz_gmt_offset, :'depart tz gmt offset' column_alias :depart_time_act_home, :'depart time act home' column_alias :depart_icao_iata_id, :'depart-icao/iata/id' column_alias :department, :'department' column_alias :departure_aro, :'departure aro' column_alias :departure_iata, :'departure iata' column_alias :departure_icao, :'departure icao' column_alias :dept_date_act_gmt, :'dept date act gmt' column_alias :dept_date_act_home, :'dept date act home' column_alias :dept_date_act_local, :'dept date act local' column_alias :dept_date_gmt, :'dept date gmt' column_alias :dept_date_home, :'dept date home' column_alias :dept_time_act_gmt, :'dept time act gmt' column_alias :dept_time_act_local, :'dept time act local' column_alias :dept_time_est, :'dept time est.' column_alias :dinner_comment, :'dinner comment' column_alias :division, :'division' column_alias :duty_act, :'duty act' column_alias :duty_post_flight, :'duty post flight' column_alias :duty_pre_flight, :'duty pre flight' column_alias :eft, :'eft' column_alias :eft_fixed, :'eft fixed' column_alias :egt, :'egt' column_alias :egt_fixed, :'egt fixed' column_alias :eta_gmt, :'eta - gmt' column_alias :eta_home, :'eta - home' column_alias :eta_local, :'eta - local' column_alias :eta_fixed, :'eta fixed' column_alias :eta_night, :'eta night' column_alias :eta_requested, :'eta requested' column_alias :eta_tentative, :'eta tentative' column_alias :etd_gmt, :'etd - gmt' column_alias :etd_home, :'etd - home' column_alias :etd_local, :'etd - local' column_alias :etd_fixed, :'etd fixed' column_alias :etd_key, :'etd key' column_alias :etd_night, :'etd night' column_alias :etd_requested, :'etd requested' column_alias :etd_tentative, :'etd tentative' column_alias :ete, :'ete' column_alias :email, :'email' column_alias :exp_res_leg, :'exp res leg' column_alias :ext_trip_num, :'ext trip num' column_alias :fbo_comment, :'fbo comment' column_alias :fbo_departure, :'fbo departure' column_alias :fbo_flags, :'fbo flags' column_alias :fbo_kid_comm, :'fbo kid - comm' column_alias :fbo_kid_date, :'fbo kid - date' column_alias :fbo_kid_mult, :'fbo kid - mult' column_alias :fbo_kid_time, :'fbo kid - time' column_alias :fbo_kid_user, :'fbo kid - user' 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_attachments, :'fs attachments' column_alias :fs_bill_cc, :'fs bill cc' column_alias :fs_bill_direct, :'fs bill direct' column_alias :fs_catering, :'fs catering' column_alias :fs_cost_est, :'fs cost est' 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_hangar, :'fs hangar' column_alias :fs_hotel, :'fs hotel' column_alias :fs_landing_permit, :'fs landing permit' column_alias :fs_lavatory, :'fs lavatory' column_alias :fs_meet_greet, :'fs meet greet' column_alias :fs_misc, :'fs misc' column_alias :fs_overflight_permit, :'fs overflight permit' column_alias :fs_pax_dep_loc, :'fs pax dep loc' column_alias :fs_prefile, :'fs prefile' column_alias :fs_prelim_flt_plan, :'fs prelim flt plan' column_alias :fs_quick_turn, :'fs quick turn' column_alias :fs_security_guard, :'fs security guard' column_alias :fs_slots, :'fs slots' column_alias :fs_transportation, :'fs transportation' column_alias :fs_update_req, :'fs update req' 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_id, :'flight id' column_alias :flight_number, :'flight number' column_alias :flight_time_actual, :'flight time actual' column_alias :flight_time_inst_act, :'flight time inst act' column_alias :flight_time_inst_sim, :'flight time inst sim' column_alias :flight_time_night, :'flight time night' column_alias :flight_time_training, :'flight time training' column_alias :flog_regulation, :'flog regulation' column_alias :flt_follow, :'flt follow' column_alias :flt_time_tax, :'flt time tax' column_alias :fuel_burn, :'fuel burn' column_alias :fuel_burned, :'fuel burned' column_alias :fuel_code, :'fuel code' column_alias :fuel_cost, :'fuel cost' column_alias :fuel_in, :'fuel in' column_alias :fuel_out, :'fuel out' column_alias :fuel_stop_time, :'fuel stop time' column_alias :fueler_comment, :'fueler comment' column_alias :fueler_depart, :'fueler depart' column_alias :fueler_flags, :'fueler flags' column_alias :fueler_kid_comm, :'fueler kid - comm' column_alias :fueler_kid_date, :'fueler kid - date' column_alias :fueler_kid_mult, :'fueler kid - mult' column_alias :fueler_kid_time, :'fueler kid - time' column_alias :fueler_kid_user, :'fueler kid - user' column_alias :glndw, :'glndw' column_alias :gtow, :'gtow' column_alias :group, :'group' column_alias :heading, :'heading' column_alias :hobbs_begin_time, :'hobbs begin time' column_alias :hobbs_end, :'hobbs end' column_alias :holding, :'holding' column_alias :home_tz_gmt_offset, :'home tz gmt offset' column_alias :inside_eec_percent, :'inside eec percent' column_alias :inst_appr_ap1_id, :'inst appr ap1 id' column_alias :inst_appr_ap1_prefix, :'inst appr ap1 prefix' column_alias :inst_appr_ap2_id, :'inst appr ap2 id' column_alias :inst_appr_ap2_prefix, :'inst appr ap2 prefix' column_alias :inst_appr_ap3_id, :'inst appr ap3 id' column_alias :inst_appr_ap3_prefix, :'inst appr ap3 prefix' column_alias :internal_12, :'internal 12' column_alias :internal_13, :'internal 13' column_alias :internal_calc_error, :'internal calc error' column_alias :internal_trans_crew, :'internal trans crew' column_alias :internal02, :'internal02' column_alias :internal03, :'internal03' column_alias :internal04, :'internal04' column_alias :international_leg, :'international leg' 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 :land_time_act_gmt, :'land time act gmt' column_alias :land_time_act_home, :'land time act home' column_alias :landing_night, :'landing night' column_alias :landing_qty, :'landing qty' column_alias :landing_seo, :'landing seo' column_alias :landing_time_est, :'landing time est.' column_alias :leg_count, :'leg count' column_alias :leg_error, :'leg error' column_alias :leg_language, :'leg language' column_alias :leg_no_tax, :'leg no tax' column_alias :leg_number, :'leg number' column_alias :leg_pairing_end, :'leg pairing end' column_alias :leg_pax_comment, :'leg pax comment' column_alias :leg_purpose_code, :'leg purpose code' column_alias :leg_rate_ac_company, :'leg rate ac company' column_alias :leg_rate_ac_id, :'leg rate ac id' column_alias :leg_rate_code, :'leg rate code' column_alias :leg_rate_date, :'leg rate date' column_alias :leg_rate_kid_comm, :'leg rate kid - comm' column_alias :leg_rate_kid_date, :'leg rate kid - date' column_alias :leg_rate_kid_mult, :'leg rate kid - mult' column_alias :leg_rate_kid_time, :'leg rate kid - time' column_alias :leg_rate_kid_user, :'leg rate kid - user' column_alias :leg_req_kid_comm, :'leg req kid - comm' column_alias :leg_req_kid_date, :'leg req kid - date' column_alias :leg_req_kid_mult, :'leg req kid - mult' column_alias :leg_req_kid_time, :'leg req kid - time' column_alias :leg_req_kid_user, :'leg req kid - user' column_alias :leg_requester, :'leg requester' column_alias :leg_state, :'leg state' column_alias :leg_type_code, :'leg type code' column_alias :legality_violation, :'legality violation' column_alias :limo_comment, :'limo comment' column_alias :limo_departure, :'limo departure' column_alias :limo_flags, :'limo flags' column_alias :limo_kid_comm, :'limo kid - comm' column_alias :limo_kid_date, :'limo kid - date' column_alias :limo_kid_mult, :'limo kid - mult' column_alias :limo_kid_time, :'limo kid - time' column_alias :limo_kid_user, :'limo kid - user' column_alias :locked, :'locked' column_alias :locked_by_user_id, :'locked by - user id' column_alias :lunch_comment, :'lunch comment' column_alias :mtow, :'mtow' column_alias :mics_serv_2_comment, :'mics serv 2 comment' column_alias :misc_1_kid_comm, :'misc 1 kid - comm' column_alias :misc_1_kid_date, :'misc 1 kid - date' column_alias :misc_1_kid_mult, :'misc 1 kid - mult' column_alias :misc_1_kid_time, :'misc 1 kid - time' column_alias :misc_1_kid_user, :'misc 1 kid - user' column_alias :misc_2_kid_comm, :'misc 2 kid - comm' column_alias :misc_2_kid_date, :'misc 2 kid - date' column_alias :misc_2_kid_mult, :'misc 2 kid - mult' column_alias :misc_2_kid_time, :'misc 2 kid - time' column_alias :misc_2_kid_user, :'misc 2 kid - user' column_alias :misc_3_kid_comm, :'misc 3 kid - comm' column_alias :misc_3_kid_date, :'misc 3 kid - date' column_alias :misc_3_kid_mult, :'misc 3 kid - mult' column_alias :misc_3_kid_time, :'misc 3 kid - time' column_alias :misc_3_kid_user, :'misc 3 kid - user' column_alias :misc_serv_1_comment, :'misc serv 1 comment' column_alias :misc_serv_1_depart, :'misc serv 1 depart' column_alias :misc_serv_1_flags, :'misc serv 1 flags' column_alias :misc_serv_2_depart, :'misc serv 2 depart' column_alias :misc_serv_2_flags, :'misc serv 2 flags' column_alias :misc_serv_3_comment, :'misc serv 3 comment' column_alias :misc_serv_3_depart, :'misc serv 3 depart' column_alias :misc_serv_3_flags, :'misc serv 3 flags' column_alias :nautical_miles, :'nautical miles' column_alias :never_scheduled, :'never scheduled' column_alias :night_flight, :'night flight' column_alias :non_fuel_expenses, :'non fuel expenses' column_alias :note, :'note' column_alias :number_of_fuel_stops, :'number of fuel stops' column_alias :open_checklist, :'open checklist' column_alias :overflight, :'overflight' column_alias :pic_rcp, :'pic rcp' column_alias :pager, :'pager' column_alias :pallets, :'pallets' column_alias :pass_actual_fixed, :'pass actual fixed' column_alias :passengers_actual, :'passengers actual' column_alias :pax_boarding, :'pax boarding' column_alias :pax_count, :'pax count' column_alias :pax_deplaning, :'pax deplaning' column_alias :pax_ent, :'pax ent' column_alias :pax_estimated, :'pax estimated' column_alias :pax_hotel_comment, :'pax hotel comment' column_alias :pax_hotel_departure, :'pax hotel departure' column_alias :pax_hotel_flags, :'pax hotel flags' column_alias :pax_hotel_kid_comm, :'pax hotel kid - comm' column_alias :pax_hotel_kid_date, :'pax hotel kid - date' column_alias :pax_hotel_kid_mult, :'pax hotel kid - mult' column_alias :pax_hotel_kid_time, :'pax hotel kid - time' column_alias :pax_hotel_kid_user, :'pax hotel kid - user' column_alias :pax_personal, :'pax personal' column_alias :pax_standby_count, :'pax standby count' column_alias :pax_waitlist, :'pax waitlist' column_alias :pilot_mon_appr, :'pilot mon appr' 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 :quote_rate, :'quote rate' column_alias :ron, :'ron' column_alias :ron_fixed, :'ron fixed' column_alias :radiation, :'radiation' column_alias :regulation, :'regulation' column_alias :release_date, :'release date' column_alias :release_time, :'release time' column_alias :release_user, :'release user' column_alias :released, :'released' column_alias :requester, :'requester' 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_key, :'requester name key' column_alias :requester_purpose, :'requester purpose' column_alias :restricted, :'restricted' column_alias :route_comment, :'route comment' column_alias :ss_start_lat, :'ss start lat' column_alias :ss_start_long, :'ss start long' column_alias :ss_start_time, :'ss start time' column_alias :ss_stop_lat, :'ss stop lat' column_alias :ss_stop_long, :'ss stop long' column_alias :ss_stop_time, :'ss stop time' column_alias :scheduled_quote, :'scheduled quote' column_alias :security_code, :'security code' column_alias :shuttle_flight, :'shuttle flight' column_alias :simulator, :'simulator' column_alias :sortie, :'sortie' column_alias :special_comment, :'special comment' column_alias :specialqualification, :'specialqualification' column_alias :status, :'status' column_alias :statute_miles, :'statute miles' column_alias :sup_res_leg, :'sup res leg' column_alias :t_o_time_act_gmt, :'t/o time act gmt' column_alias :tas, :'tas' column_alias :tas_fixed, :'tas fixed' column_alias :tach_begin_time, :'tach begin time' column_alias :tach_end_time, :'tach end time' column_alias :takeof_time_act_home, :'takeof time act home' column_alias :takeoff_night, :'takeoff night' column_alias :takeoff_qty, :'takeoff qty' column_alias :takeoff_seo, :'takeoff seo' column_alias :taxi_fixed, :'taxi fixed' column_alias :taxi_time, :'taxi time' column_alias :tech_stop, :'tech stop' column_alias :time_zone_change, :'time zone change' column_alias :total_expenses, :'total expenses' column_alias :total_weight, :'total weight' column_alias :touch_go, :'touch go' column_alias :tracking, :'tracking' column_alias :trans_crew_fa, :'trans crew fa' column_alias :trans_crew_fe, :'trans crew fe' column_alias :trans_crew_other, :'trans crew other' column_alias :trans_crew_pic, :'trans crew pic' column_alias :trans_crew_sic, :'trans crew sic' column_alias :trip_number, :'trip number' column_alias :trip_request, :'trip request' column_alias :trips_kid_comm, :'trips kid - comm' column_alias :trips_kid_date, :'trips kid - date' column_alias :trips_kid_mult, :'trips kid - mult' column_alias :trips_kid_time, :'trips kid - time' column_alias :trips_kid_user, :'trips kid - user' column_alias :vor_check, :'vor check' column_alias :valid_rest, :'valid rest' column_alias :verified_by, :'verified by' column_alias :verify_date, :'verify date' column_alias :verify_number, :'verify number' column_alias :verify_time, :'verify time' column_alias :wind, :'wind' column_alias :winds_fixed, :'winds fixed' column_alias :key0, :'key0' column_alias :key1, :'key1' 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' #### END GENERATED SECTION #### # delegators delegate :lead_pax, :to => :trip # Column views column_view :dept_date_act_gmt, :date, :actual_departure_date_gmt column_view :dept_time_act_gmt, :time, :actual_departure_time_gmt column_def_datetime :actual_departure_date_time_gmt, :'dept date act gmt', :'dept time act gmt' def actual_takeoff_date_time_gmt date = actual_departure_date_gmt date += 1.day if t_o_time_act_gmt < dept_time_act_gmt date.to_datetime.advance(:minutes=>t_o_time_act_gmt) end column_view :arrival_date_gmt, :date, :actual_arrival_date_gmt column_view :arriv_time_act_gmt, :time, :actual_arrival_time_gmt column_def_datetime :actual_arrival_date_time_gmt, :'arr date act gmt', :'arriv time act gmt' def actual_land_date_time_gmt date = actual_arrival_date_gmt date -= 1.day if land_time_act_gmt > arriv_time_act_gmt date.to_datetime.advance(:minutes=>land_time_act_gmt) end column_view :dept_date_act_local, :date, :actual_departure_date_local column_view :dept_time_act_local, :time, :actual_departure_time_local column_def_datetime :actual_departure_date_time_local, :'dept date act local', :'dept time act local' column_view :arrival_date_local, :date, :actual_arrival_date_local column_view :arriv_time_act_local, :time, :actual_arrival_time_local column_def_datetime :actual_arrival_date_time_local, :'arr date act local', :'arriv time act local' column_view :dept_date_gmt, :date, :planned_departure_date_gmt column_view :etd_gmt, :time, :planned_departure_time_gmt column_def_datetime :planned_departure_date_time_gmt, :'dept date gmt', :'etd - gmt' column_view :depart_date_local, :date, :planned_departure_date_local column_view :etd_local, :time, :planned_departure_time_local column_def_datetime :planned_departure_date_time_local, :'depart date - local', :'etd - local' column_view :arrival_date_gmt, :date, :planned_arrival_date_gmt column_view :eta_gmt, :time, :planned_arrival_time_gmt column_def_datetime :planned_arrival_date_time_gmt, :'arrival date gmt', :'eta - gmt' column_view :arrival_date_local, :date, :planned_arrival_date_local column_view :eta_local, :time, :planned_arrival_time_local column_def_datetime :planned_arrival_date_time_local, :'arrival date - local', :'eta - local' column_view :dept_date_act_home, :date, :actual_departure_date_base column_view :depart_time_act_home, :time, :actual_departure_time_base column_def_datetime :actual_departure_date_time_base_old, :'dept date act home', :'depart time act home' def actual_departure_date_time_base() actual_departure_date_time_gmt + (home_tz_gmt_offset/10).hours; end column_view :arr_date_act_home, :date, :actual_arrival_date_base column_view :arrival_time_act_hom, :time, :actual_arrival_time_base column_def_datetime :actual_arrival_date_time_base_old, :'arr date act home', :'arrival time act hom' def actual_arrival_date_time_base() actual_arrival_date_time_gmt + (home_tz_gmt_offset/10).hours; end column_view :ete, :time column_view :eft, :time column_view :flight_time_actual, :time, :aft_time column_view :block_time_actual, :time, :abt_time column_view :t_o_time_act_gmt, :time, :actual_takeoff_time_gmt column_view :land_time_act_gmt, :time, :actual_land_time_gmt column_view :delay_1_time, :time, :delay_1_duration column_view :delay_2_time, :time, :delay_2_duration # get pic or sic or purser for this trip leg. type should be :pic or :sic or :pur def pilot_code(type) crew_leg = pilot_crew(type) crew_leg ? crew_leg.crew : '' end def pic; pilot_code(:pic); end def sic; pilot_code(:sic); end def pilot_crew(type) return nil unless type crew_legs.find{|cl| cl.position_code_code == type.to_s.upcase } end def pic_crew; pilot_crew(:pic); end def sic_crew; pilot_crew(:sic); end def ebt_time # subtracting the two datetimes yields a fraction of a day, so multiplying by minutes # in day ( 1440 ) to get total minutes difference. assumes flights not more than 24 hours. minutes_between = (planned_arrival_date_time_gmt - planned_departure_date_time_gmt) * 1440; Time.from_minutes(minutes_between) end def is_deadhead? status==1 and (deadhead==1 or pax_count==0) and [107, 115, 108, 104].include? leg_type_code end # sort on lead_pax value to lead pax = 1 is first and the lead_pax values of 0 are all after def passenger_list return '' if trip__passengers.blank? or is_deadhead? trip__passengers.sort_by{|tp| -tp.lead_pax}.collect do |tp| if (leg_number >= tp.departure_leg_number and leg_number <= tp.arrival_leg_number) tp.name + (tp.lead_pax==1 ? " (lead pax)" : '' ) end end.compact.uniq.join(' : ') end def leg_status return "CANC" if cancel_code > 0 return "VERI" if verify_date > 0 return "FLOG" if status != 1 and flight_time_actual > 0 case status when 0 then "SCHED" when 1 then "VERI" when 10 then "CANC" when 23 then "CANC" when 21 then "MAINT" when 20 then "SCHED" #really is "RESVD" else "[#{status}]"; end end # This method guarantees an icao for a view that needs one. If there is an icao, use it, otherwise make # it from the prefix and airport_id .. which works as an icao, but beware, because these put together # icao's that you make are valid icao codes, but you can't search the airport based it, since these # airport rows don't have an icao code at all, they only have the prefix and airport_id. whacky. def departure_icao_val departure_icao == nil || departure_icao.blank? ? depart_ap_prefix + depart_airport_id : departure_icao end def arrival_icao_val arrival_icao == nil || arrival_icao.blank? ? arrival_ap_prefix + arrival_airport_id : arrival_icao end def departure_icao_expanded "#{departure_icao_val} #{departure_airport__name} #{departure_airport__city} ,#{departure_airport__state_abbreviation}" end def arrival_icao_expanded "#{arrival_icao_val} #{arrival_airport__name} #{arrival_airport__city} ,#{arrival_airport__state_abbreviation}" end def total_trip_statute_miles trip__total_statute_miles.to_f/10.0 end # converts nautical miles to statute miles with fractional bit # silly because its so similar in value to statute_miles def custom_statute_miles return 0 unless nautical_miles ((nautical_miles*1.150777*10).to_i)/10.0 end end