Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- --Person activity control
- SELECT VFmxPdDay.VO_PERSON_CATEGORY_ID,
- VFmxPdDay.PERSON_ID,
- VFmxPdDay.WORK_CODE_ID,
- VFmxPdDay.DATE_DAY,
- VFmxPdDay.WORK_DURATION,
- VFmxPdDay.PLANNED_WORK_DURATION,
- VFmxPdDay.HP_DESTINATION_POI_ID,
- VFmxPdDay.HP_DRIVER_ALONE_KM,
- VFmxPdDay.HP_DRIVER_WITH_P_KM,
- VFmxPdDay.HP_PASSENGER_KM,
- VFmxPdDay.HP_PRIVATE_KM,
- VFmxPdDay.PH_ORIGIN_POI_ID,
- VFmxPdDay.PH_DRIVER_ALONE_KM,
- VFmxPdDay.PH_DRIVER_WITH_P_KM,
- VFmxPdDay.PH_PASSENGER_KM,
- VFmxPdDay.PH_PRIVATE_KM,
- VFmxPdDay.TOT_PASSENGER_KM,
- VFmxPdDay.TOT_DRIVER_WITH_P_KM,
- VFmxPdDay.AGGREG_COMMENT,
- VFmxPdDay.LM_COMMENT,
- VFmxPdDay.LM_DATE,
- VFmxPdDay.IS_MODIFIED_BY_USER,
- VFmxPdDay.OC_AGGREG_ADMIN_STATUS_ID,
- VFmxPdDay.TOT_HP_CALCULATED,
- VFmxPdDay.TOT_PH_CALCULATED,
- VFmxPdDay.TOT_HP,
- VFmxPdDay.TOT_PH,
- VFmxPdDay.REPORTED_WORK_DURATION,
- VFmxPdDay.REPORTED_PASSENGER_KM,
- VFmxPdDay.REPORTED_DRIVER_KM,
- VFmxPdDay.IS_LOCKED,
- VFmxPdDay.TOT_DRIVER_WITH_P_KM_PRICE,
- VFmxPdDay.TOT_PASSENGER_PRICE,
- VFmxPdDay.IS_MODIFIED_BY_LOAD_REP,
- VFmxPdDay.STATUS_NAME,
- VFmxPdDay.FLAG_COLOUR,
- VFmxPdDay.PH_ORIGIN_POI_NAME,
- VFmxPdDay.HP_DESTINATION_POI_NAME,
- VFmxPdDay.PERSON_NAME,
- VFmxPdDay.DAY_STR,
- VFmxPdDay.DAY_NR,
- VFmxPdDay.WORK_CODE_NAME,
- VFmxPdDay.PERSON_COMPANY_NR,
- VFmxPdDay.POI_SHORT_NAME,
- VFmxPdDay.PERSON_LAST_NAME,
- VFmxPdDay.PERSON_FIRST_NAME,
- VFmxPdDay.CAN_DRIVE_WITH_PASSENGERS,
- VFmxPdDay.ASSOCIATED_POI_SHORT_NAME,
- VFmxPdDay.WBS_NAME,
- VFmxPdDay.WBS_ID,
- VFmxPdDay.PD_DAY_ID,
- UPPER(VFmxPdDay.STATUS_NAME||' '||VFmxPdDay.WBS_NAME||' '||VFmxPdDay.DATE_DAY||' '||VFmxPdDay.PERSON_NAME) AS IDSTRING,
- VFmxPdDay.TOT_PRIVATE_KM,
- VFmxPdDay.TOT_PRIVATE_PRICE,
- VFmxPdDay.IS_WORKING_DAY,
- Person.HOME_POI_ID,
- Person.PERSON_ID AS PERSON_ID1,
- OperationCenter.OPERATION_CENTER_ID,
- VFmxPdDay.WORK_CODE_STD_ID,
- VFmxPdDay.IS_HR_EDITABLE,
- VFmxPdDay.IS_HRMGT_PROFILE,
- DECODE(OperationMode.short_name,'NW','#223c4a','CO','#f75414','') AS OM_COLOR,
- OperationMode.NAME AS OM_NAME,
- OperationMode.SHORT_NAME AS OM_SHORT_NAME,
- OperationMode.OPERATION_MODE_ID,
- VFmxPdDay.ACTIVITY_CHART,
- VFmxPdDay.ACTIVITY_CHART_CLOB,
- VFmxPdDay.TRF_DHR,
- VFmxPdDay.SUMMARY_KM_FORMULA,
- (OcPoi.NAME) AS VIEW_ATTR,
- (VFmxPdDay.WBS_NAME) AS VIEW_ATTR,
- (VFmxPdDay.STATUS_NAME) AS VIEW_ATTR,
- (VFmxPdDay.work_code_name) AS VIEW_ATTR,
- VFmxPdDay.TOT_PUBLIC_TRANSPORT_PRICE,
- VFmxPdDay.WORKER_REPORT_COMMENT
- FROM V_FMX_PD_DAY VFmxPdDay, PERSON Person, OC_POI OcPoi, OPERATION_CENTER OperationCenter, OPERATION_MODE OperationMode, GU_PERSON GuPerson
- WHERE VFmxPdDay.PERSON_ID = Person.PERSON_ID
- AND Person.HOME_POI_ID = OcPoi.POI_ID(+)
- AND (Person.PERSON_ID = ? OR ? = 0) -- i na 2te mesta 0
- AND Person.VO_PERSON_CATEGORY_ID = ? --100752
- AND date_day BETWEEN ? AND ? --vkarvash dati tuka
- AND ((NVL(tot_passenger_km,0)+NVL(tot_driver_with_p_km,0)
- +NVL(reported_passenger_km,0)+NVL(reported_driver_km,0)+NVL(tot_private_km,0)+NVL(work_duration,0)>0)
- OR ?='true') -- 'true'
- AND (?='true' OR (TO_CHAR(date_day,'d')IN(TO_CHAR(TO_DATE('05/01/09','DD/MM/YY'),'D'), --'true'
- TO_CHAR(TO_DATE('06/01/09','DD/MM/YY'),'D'),
- TO_CHAR(TO_DATE('07/01/09','DD/MM/YY'),'D'),
- TO_CHAR(TO_DATE('08/01/09','DD/MM/YY'),'D'),
- TO_CHAR(TO_DATE('09/01/09','DD/MM/YY'),'D'))) OR NVL(tot_hp,0)+NVL(tot_ph,0)>0)
- AND (? = 'false' OR status_name != 'Normal')
- AND (? = 'false' OR NVL(tot_driver_with_p_km,0)>0) --'true'
- AND ((? = 'false') OR (NVL(is_locked,'N')='N'))
- AND ((? = 'false') OR (OperationMode.OPERATION_MODE_ID=2))
- AND OperationCenter.OPERATION_CENTER_ID = ? --operation center na user-a AB
- AND VFmxPdDay.OPERATION_MODE_ID = OperationMode.OPERATION_MODE_ID(+)
- AND Person.PERSON_ID = GuPerson.Person_id
- AND GuPerson.gui_user_id = ? --101943 USER:AB
- AND NVL (GuPerson.caw_limited, 'N') <> 'Y'
- ORDER BY person_company_nr, person_last_name, person_first_name, date_day;
- --Payroll lines
- SELECT PdTrfDay.DATE_DAY,
- PdTrfDay.PD_TRF_DAY_ID,
- PdTrfDay.DESTINATION_POI_ID,
- PdTrfDay.IS_LOCKED,
- PdTrfDay.IS_MODIFIED_BY_USER,
- PdTrfDay.OC_AGGREG_ADMIN_STATUS_ID,
- PdTrfDay.OC_DAY_AGGREG_ID,
- PdTrfDay.OPERATION_MODE_ID,
- PdTrfDay.PD_TRF_TYPE_ID,
- PdTrfDay.PD_TRF_USER_COMMENT,
- PdTrfDay.PERSON_ID,
- PdTrfDay.REF_NUMBER,
- CAST(PdTrfDay.START_TIME AS TIMESTAMP) AS STARTTIME,
- CAST(PdTrfDay.STOP_TIME AS TIMESTAMP) AS STOPTIME,
- PdTrfDay.TRF_DHR,
- PdTrfDay.TRF_PHR,
- PdTrfDay.WBS_ID,
- PdTrfDay.WORK_CODE_ID,
- PdTrfDay.VEHICLE_ID,
- WorkCode.WORK_CODE_ID AS WORK_CODE_ID1,
- GuPerson.GUI_USER_ID,
- GuPerson.PERSON_ID AS PERSON_ID1,
- OperationMode.NAME,
- OperationMode.OPERATION_MODE_ID AS OPERATION_MODE_ID1,
- OperationMode.SHORT_NAME,
- OcAggregAdminStatus.OC_AGGREG_ADMIN_STATUS_ID AS OC_AGGREG_ADMIN_STATUS_ID1,
- OcDayAggreg.OC_DAY_AGGREG_ID AS OC_DAY_AGGREG_ID1,
- OcPoi.POI_ID,
- VoPersonCategory.VO_PERSON_CATEGORY_ID,
- Person.PERSON_ID AS PERSON_ID2,
- (Person.Last_name || ' ' || Person.First_Name) AS VIEW_ATTR,
- TO_CHAR(PdTrfDay.date_day, 'Dy', 'nls_date_language=' || (SELECT CASE WHEN language = 'DU' THEN 'Dutch' WHEN language = 'FR' THEN 'French' ELSE 'English' END FROM gui_users gu WHERE gu.gui_user_id = GuPerson.gui_user_id)) AS VIEW_ATTR,
- TO_CHAR( PdTrfDay.date_day,'dd') AS VIEW_ATTR,
- TO_CHAR ( PdTrfDay.DATE_DAY , 'dd/MM/yyyy' ) AS VIEW_ATTR,
- DECODE(PdTrfDay.start_poi_id,NULL,PdTrfDay.start_location_name, DECODE(OcPoi.oc_poi_status_id,4, '[' || OcPoi.short_name || '].'|| p_vd_poi.getVehicleDataAddress(PdTrfDay.start_vehicle_data_id), p_wbs.getWbsName(PdTrfDay.wbs_Id, PdTrfDay.start_poi_id))) AS VIEW_ATTR,
- MOD(DENSE_RANK () OVER (ORDER BY Person.company_nr, person.last_name, person.person_id, PdTrfDay.date_day), 2) AS VIEW_ATTR,
- PdTrfDay.START_POI_ID,
- PdTrfDay.TOT_PRIVATE_KM,
- PdTrfDay.TOT_DRIVER_WITH_P_KM,
- PdTrfDay.TOT_PASSENGER_KM,
- OcAggregAdminStatus.FLAG_COLOUR,
- VoPersonCategory.VEHICLE_OWNER_ID,
- DECODE(OperationMode.short_name,'NW','#223c4a','CO','#f75414','') AS VIEW_ATTR,
- PdTrfDay.USER_COMMENT,
- UPPER (PdTrfDay.PD_TRF_USER_COMMENT || ' ' || UPPER(NVL(PdTrfDay.EXPORT_FILE_NAME,'')) || ' ' || PdTrfDay.ref_number || ' ' || OcPoi.name || ' ' || USER_COMMENT || ' ' || OperationMode.SHORT_NAME || ' ' || OcAggregAdminStatus.NAME || ' ' || Person.Last_name || ' ' || Person.First_Name || ' ' || DECODE(PdTrfDay.start_poi_id,NULL,PdTrfDay.start_location_name, DECODE(OcPoi.oc_poi_status_id,4, '[' || OcPoi.short_name || '].' || p_vd_poi.getVehicleDataAddress(PdTrfDay.start_vehicle_data_id), p_wbs.getWbsName(NULL, OcPoi.poi_id))) || ' ' || Person.COMPANY_NR || ' ' || WorkCode.SHORT_CODE || ' ' || ACTIVITY.ACTIVITY_CODE || ' ' || ACTIVITY.ACTIVITY_NAME || ' ' || VEHICLE.COMPANY_NR || ' ' || VEHICLE.NUMBERPLATE || ' ' || P_WBS.getWBSPathWithNames(PdTrfDay.wbs_Id) || ' ' || P_WBS.getWBSPathWithREF_number(PdTrfDay.WBS_ID) || ' ' || P_WBS.getWBSPathWithShortName(PdTrfDay.WBS_ID)) AS VIEW_ATTR,
- (SELECT work_code_id FROM work_code WHERE vehicle_owner_id = VoPersonCategory.vehicle_owner_id AND work_code_std_id=110 AND order_num = ( SELECT MIN(order_num) FROM work_code WHERE vehicle_owner_id = VoPersonCategory.vehicle_owner_id AND work_code_std_id=110)) AS VIEW_ATTR,
- (VoPersonCategory.VEHICLE_OWNER_ID) AS VIEW_ATTR,
- (Person.Company_nr) AS VIEW_ATTR,
- (VoPersonCategory.Name) AS VIEW_ATTR,
- (VehicleOwner.Company_name) AS VIEW_ATTR,
- PdTrfDay.ACTIVITY_ID,
- PdDay.PD_DAY_ID,
- (PdDay.TRF_DHR_SUPP_TO_STORE) AS VIEW_ATTR,
- ROW_NUMBER () over (PARTITION BY pdday.pd_day_id ORDER BY PdTrfDay.order_num, PdTrfDay.START_TIME) AS ROW_NUM,
- (PdDay.TRF_DHR_SUPP_TO_PAY) AS VIEW_ATTR,
- (PdDay.MOBILITY_ZONE_ID) AS VIEW_ATTR,
- (Pdday.MOBILITY_COMPENSATION) AS VIEW_ATTR,
- (PdDay.MEAL_ALLOWANCE) AS VIEW_ATTR,
- (Vehicle.COMPANY_NR || ' ' || Vehicle.NUMBERPLATE) AS VIEW_ATTR,
- PdTrfDay.START_LOCATION_ADDRESS,
- (Vehicle.NUMBERPLATE) AS VIEW_ATTR,
- (Vehicle.COMPANY_NR) AS VIEW_ATTR,
- PdTrfDay.TRF_IHR,
- (PDDAY.Declared_Vehicle_Km) AS VIEW_ATTR,
- (PDDAY.Declared_Vehicle_Ref) AS VIEW_ATTR,
- (PDDAY.pause) AS VIEW_ATTR,
- (PDDAY.Declared_Private_Km) AS VIEW_ATTR,
- PdTrfDay.START_LOCATION_NAME,
- PdTrfDay.ERP_SIGN_ATTACHED_DOC_ID,
- PdTrfDay.VALIDATED_BY_EMAIL,
- PdTrfDay.VALIDATED_BY_NAME,
- PdTrfDay.VALIDATION_COMMENT,
- (PDDAY.Declared_On_Foot_Km) AS VIEW_ATTR,
- (PDDAY.Declared_Bicycle_Km) AS VIEW_ATTR,
- (PDDAY.public_transport) AS VIEW_ATTR,
- (Private_Vehicle) AS VIEW_ATTR,
- (PDDAY.Company_Vehicle) AS VIEW_ATTR,
- (PDDAY.long_distance) AS VIEW_ATTR,
- (PDDAY.TRAJECT) AS VIEW_ATTR,
- (PDDAY.Transport) AS VIEW_ATTR,
- (PDDAY.DECLARED_JOURNEY_TYPE_ID) AS VIEW_ATTR,
- (PDDAY.WORK_LOCATION_CATEGORY) AS VIEW_ATTR,
- (PDDAY.WORK_LOCATION_POST_CODE) AS VIEW_ATTR,
- (PDDAY.MEETING_POINT_POST_CODE) AS VIEW_ATTR,
- SUM( CASE WHEN WorkCode.work_code_std_type_id = 1 THEN PdTrfDay.TRF_DHR ELSE 0 END) OVER (PARTITION BY PdTrfDay.date_day,PdTrfDay.person_id) AS VIEW_ATTR,
- GraphicalSymbol.GRAPHICAL_SYMBOL_ID,
- (GraphicalSymbol.NAME) AS VIEW_ATTR,
- P_WBS.getWBSPathWithNames(PdTrfDay.wbs_Id) AS VIEW_ATTR,
- P_WBS.getWBSPathWithREF_number(PdTrfDay.WBS_ID) AS VIEW_ATTR,
- P_WBS.getWBSPathWithShortName(PdTrfDay.WBS_ID) AS VIEW_ATTR,
- (PDDAY.WORK_LOCATION_CITY) AS VIEW_ATTR,
- (PDDAY.MEETING_POINT_CITY) AS VIEW_ATTR,
- (PDDAY.PLANNED_WORK_DURATION) AS VIEW_ATTR,
- WorkCode.WORK_CODE_STD_TYPE_ID,
- PdTrfDay.HEAVY_WORK,
- NVL(PdTrfDay.is_exported, 'N') AS Is_Exported,
- P_WBS.getlvl0WbsRefNumber(PdTrfDay.WBS_ID) AS VIEW_ATTR,
- P_WBS.getlvl1WbsRefNumber(PdTrfDay.WBS_ID) AS VIEW_ATTR,
- P_WBS.getlvl2WbsRefNumber(PdTrfDay.WBS_ID) AS VIEW_ATTR,
- (OcAggregAdminStatus.NAME) AS VIEW_ATTR,
- (WorkCode.short_code) AS VIEW_ATTR,
- PdTrfDay.REF_NUMBER_TASK_CODE,
- (Vehicle1.COMPANY_NR || ' ' || Vehicle1.NUMBERPLATE) AS VIEW_ATTR,
- (PdTrfDay.Person_id) AS VIEW_ATTR,
- PdTrfDay.ORDER_NUM,
- PdTrfDay.EXPORT_FILE_NAME,
- PdTrfDay.TRF_PRICE,
- (WorkCode.WORK_CODE_NAME) AS VIEW_ATTR,
- PdTrfDay.TRF_KM_ROUTE,
- PdTrfDay.TRF_KM_ESTIMATED,
- DECODE (IVehicle.vehicle_id, NULL, DECODE (PdTrfVehicle.vehicle_id, NULL, NULL, TRIM(DECODE(PdTrfVehicle.company_nr, NULL, '', PdTrfVehicle.company_nr || ' - ') || PdTrfVehicle.numberplate)), TRIM(DECODE(IVehicle.company_nr, NULL, '', IVehicle.company_nr || ' - ') || IVehicle.numberplate)) AS VIEW_ATTR,
- (PDDAY.MAINTENANCE) AS VIEW_ATTR,
- (PDDAY.LAUNDRY) AS VIEW_ATTR,
- (PDDAY.DAY_JOURNEY_ROLE) AS VIEW_ATTR,
- (OcPoi.name) AS POI_NAME,
- PdTrfDay.SUBMITTED_BY_PERSON_ID,
- PdTrfDay.SUBMITTED_BY_DATE_DAY,
- PdTrfDay.VALIDATION_STATUS_ID,
- (OperationMode.SHORT_NAME) AS VIEW_ATTR,
- (OperationMode.NAME) AS VIEW_ATTR,
- (PDDAY.WORK_DURATION) AS VIEW_ATTR
- FROM PD_TRF_DAY PdTrfDay, PERSON Person, VO_PERSON_CATEGORY VoPersonCategory, OC_POI OcPoi, OC_DAY_AGGREG OcDayAggreg, OC_AGGREG_ADMIN_STATUS OcAggregAdminStatus, OPERATION_MODE OperationMode, GU_PERSON GuPerson, WORK_CODE WorkCode, VEHICLE_OWNER VehicleOwner, PD_DAY PdDay, VEHICLE Vehicle, OF_OWNER.ACTIVITY Activity, OF_OWNER.GRAPHICAL_SYMBOL GraphicalSymbol, VEHICLE Vehicle1, VEHICLE IVehicle, VEHICLE PdTrfVehicle
- WHERE PdTrfDay.start_poi_id = OcPoi.poi_id (+)
- AND PdTrfDay.oc_day_aggreg_id = OcDayAggreg.oc_day_aggreg_id (+)
- AND PdTrfDay.OC_AGGREG_ADMIN_STATUS_ID = OcAggregAdminStatus.OC_AGGREG_ADMIN_STATUS_ID (+)
- AND PdTrfDay.Operation_mode_id = OperationMode.Operation_mode_id (+)
- AND PdTrfDay.work_code_id = WorkCode.work_code_id (+)
- AND WorkCode.GRAPHICAL_SYMBOL_ID = GraphicalSymbol.GRAPHICAL_SYMBOL_ID (+)
- AND PdTrfDay.person_id = Person.person_id
- AND Person.Vo_Person_Category_id = VoPersonCategory.Vo_Person_Category_id
- AND VoPersonCategory.Vehicle_owner_id = VehicleOwner.vehicle_owner_id
- AND Person.PERSON_ID = GuPerson.PERSON_ID
- AND PdTrfDay.date_day = PdDay.date_day
- AND PdTrfDay.person_id = PdDay.person_id
- AND PdTrfDay.activity_id = activity.activity_id(+)
- AND pdday.vehicle_id = vehicle.vehicle_id (+)
- AND pdday.vehicle2_id = vehicle1.vehicle_id (+)
- AND PdTrfDay.TRF_I_VEHICLE_ID = IVehicle.vehicle_id (+)
- AND PdTrfDay.VEHICLE_ID = PdTrfVehicle.VEHICLE_ID (+)
- AND NVL (GuPerson.caw_limited, 'N') <> 'Y'
- AND GuPerson.gui_user_id = ? --101943 USER:AB
- AND (Person.vo_person_category_id = ? OR ? = -1) --100752
- AND PdTrfDay.date_day >= ? AND PdTrfDay.date_day <= ? --kakvito dati iskash
- AND (Person.PERSON_ID = ? OR ? = 0) -- i na 2te 0
- AND ((NVL (PdTrfDay.TRF_DHR, 0) + NVL (PdTrfDay.TRF_PHR, 0)) > 0 OR ? = 'true') --'true'
- AND (?='true' OR TO_CHAR (PdTrfDay.date_day, 'DY', 'NLS_DATE_LANGUAGE=ENGLISH') NOT IN ('SAT', 'SUN')
- OR (NVL (PdTrfDay.TRF_DHR, 0) + NVL (PdTrfDay.TRF_PHR, 0)) > 0) --'true'
- AND (? = 'false' OR OcAggregAdminStatus.name != 'Normal') --'false'
- AND ((? = 'false') OR (NVL(PdTrfDay.is_locked,'N')='N')) --'false'
- AND ((? = 'false') OR (OperationMode.OPERATION_MODE_ID=2)) --'false'
- AND (? = '-1' OR Person.Person_ID IN (SELECT person_id FROM vo_group_person WHERE vo_group_id IN ( SELECT regexp_substr( ? ,'[^,]+', 1, LEVEL) FROM dual
- CONNECT BY regexp_substr( ?, '[^,]+', 1, LEVEL) IS NOT NULL ))) --'-1'
- AND (? = '-1' OR P_WBS.getlvl0WbsRefNumber(PdTrfDay.WBS_ID) = ? ) --'-1'
- AND Person.Vo_Person_category_id IN (
- SELECT VFmxPc.VO_PERSON_CATEGORY_ID FROM V_FMX_PC VFmxPc
- WHERE VFmxPc.OPERATION_CENTER_ID IN
- (
- SELECT OPERATION_CENTER_ID FROM GUI_USERS WHERE GUI_USER_ID = ? --101943 USER:AB
- )
- AND VFmxPc.VO_PERSON_CATEGORY_ID IN (SELECT DISTINCT VO_PERSON_CATEGORY_ID FROM GU_PERSON gu, PERSON p WHERE gu.PERSON_ID = p.PERSON_ID AND gu.GUI_USER_ID = ?)) --101943 USER:AB
- AND INSTR(?,TO_CHAR(WorkCode.WORK_CODE_STD_TYPE_ID)) > 0 -- vmesto da ima '1'
- AND INSTR(?,TO_CHAR(WorkCode.WORK_CODE_STD_CATEGORY_ID)) > 0 --vmesto ? da ima '1,2,3'
- AND ((? = 'false') OR (NVL(PdTrfDay.is_exported,'N')='N'))--false
- AND (? = 'false' OR NVL(VoPersonCategory.IS_EXPORTED_TO_PAYROLL,'Y')='Y') --'true'
- ORDER BY Person.COMPANY_NR, Person.Last_name, PdTrfDay.date_day, PdTrfDay.START_TIME, row_num;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement