Advertisement
psi_mmobile

Untitled

Mar 30th, 2023
172
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 9.14 KB | None | 0 0
  1. --function getLastSecurityBriefingDate(p_person in number) return date;
  2. function getLastSecurityBriefingDate(p_person in number) return date is
  3. v_wbs_person_presence_id number(10);
  4. v_last_briefing_date date;
  5. begin
  6. select max(wpr.wbs_person_presence_id)
  7. into v_wbs_person_presence_id
  8. from wbs_person_presence wpr
  9. where wpr.person_id = p_person_id;
  10. exception when no_data_found then
  11. return null;
  12. end;
  13. begin
  14. select wpr.presence_date
  15. into v_last_briefing_date
  16. from wbs w, wbs_person_presence wpr
  17. where wpr.wbs_person_presence_id = v_wbs_person_presence_id
  18. and w.wbs_id = wpr.wbs_id;
  19. exception when no_data_found then
  20. return null;
  21. end;
  22. return v_last_briefing_date;
  23. end;
  24.  
  25. --function getLastSecurityBriefingWBSStr (p_person in number) return varcha2;
  26. function getLastSecurityBriefingWBSStr (p_person in number) return varchar2 is
  27. v_wbs_person_presence_id number(10);
  28. v_last_briefing_wbs varchar2(200);
  29. begin
  30. select max(wpr.wbs_person_presence_id)
  31. into v_wbs_person_presence_id
  32. from wbs_person_presence wpr
  33. where wpr.person_id = p_person_id;
  34. exception when no_data_found then
  35. return null;
  36. end;
  37. begin
  38. select wbs.name || ' ' || wbs.ref_number
  39. into v_last_briefing_wbs
  40. from wbs w, wbs_person_presence wpr
  41. where wpr.wbs_person_presence_id = v_wbs_person_presence_id
  42. and w.wbs_id = wpr.wbs_id;
  43. exception when no_data_found then
  44. return null;
  45. end;
  46. return v_wbs_last_briefing_wbs;
  47. end;
  48. /
  49.  
  50.  
  51. -- CREATE OR REPLACE FORCE EDITIONABLE VIEW "OF_OWNER"."V_ORDS_GET_PERSON_LIST" ("PERSON_ID", "VEHICLE_OWNER_ID", "VO_PERSON_CATEGORY_ID", "FIRST_NAME", "LAST_NAME", "AGE", "BIRTH_DATE", "GENDER", "LANGUAGE", "COMPANY_NR", "PHONE", "MSISDN", "LIMOSA", "NISS", "EMAIL", "HOME_POI_ID", "STREET", "STREET_NR", "LOCATION", "POST_CODE", "COUNTRY", "ADDITIONAL_ADRESS_INFO", "WORKING_SCHEDULE_ID", "JOB_TITLE", "OC_CALENDAR_ID", "PERSON_STATUS_ID", "START_WORK_DATE", "END_WORK_DATE", "LAST_ATTACH_DOC_ADMIN_SHARING_DATE", "LAST_ATTACH_DOC_ADMIN_SHARING_MC_ID", "LAST_SO_TRANSACTION_ID", "HIRING_AUTHORIZATION_DATE", "HIRING_AUTHORIZATION_REQUEST_DATE", "FIRING_AUTHORIZATION_DATE", "FIRING_AUTHORIZATION_REQUEST_DATE", "VO_DIVISION_ID", "REAL_EMPLOYER_NAME", "REAL_EMPLOYER_TIN", "REAL_EMPLOYER_ADMIN_REGION_ID", "RANK1_SC_NAME", "RANK1_SC_TIN", "RANK1_SC_ADMIN_REGION_ID", "PERSON_ADMIN_REGION_ID", "ADMIN_STATUS_CATEGORY_ID", "IS_ADMIN_STATUS_OK", "IS_BLACKLISTED", "NATIONALITY_CODE_ID", "EMPLOYEE_CONTRACT_TYPE_ID", "VO_EMPLOYEE_CONTRACT_TYPE_ID", "LM_NAME", "LM_DATE", "LM_COMMENT", "IS_CROSS_BORDER_WORKER", "COMPANY_NAME", "COMPANY_TIN", "ALL_ADMIN_ATTACH_DOC_VALIDATED", "ADMIN_PROFILE_ID", "LAST_CAW_POI_NAME", "LAST_CAW_POI_TIN", "LAST_CAW_REF_NUMBER", "LAST_CAW_CREATION_DATE", "LAST_CAW_WORK_DATE", "LAST_CAW_STATUS", "SO_TRANSACTION_STATUS_ID", "LAST_CAW_LM_DATE", "LAST_CAW_COMMENT", "SOT_REMARK_EXIST", "ADMIN_PROOF_DOC", "ADMIN_PROOF_CATEGORY_VALIDITIES", "RE_VALIDATION_STATUS", "SC_VALIDATION_STATUS","MANAGER1_FIRST_NAME","MANAGER1_LAST_NAME","MANAGER1_COMPANY_NR","MANAGER2_FIRST_NAME","MANAGER2_LAST_NAME","MANAGER2_COMPANY_NR","PERSON_LAST_MED_VISIT_DATE","LAST_MED_VISIT_STATUS_ID","PERSON_LAST_MED_VISIT_STATUS","LAST_SECURITY_BRIEFING_DATE","LAST_SECURITY_BRIEFING_WBS") AS
  52. select
  53. p.person_id,
  54. p.vehicle_owner_id,
  55. vpc.vo_person_category_id,
  56. p.first_name,
  57. p.last_name,
  58. p.age,
  59. p.birth_date,
  60. p.gender,
  61. p.language,
  62. p.company_nr,
  63. p.phone,
  64. p.msisdn,
  65. p.limosa,
  66. p.niss,
  67. p.email,
  68. p.home_poi_id,
  69. home.street,
  70. home.street_nr,
  71. home.location,
  72. home.post_code,
  73. home.country,
  74. home.additional_adress_info,
  75. p.working_schedule_id,
  76. p.job_title,
  77. p.oc_calendar_id,
  78. p.person_status_id,
  79. p.start_work_date,
  80. p.end_work_date,
  81. p.last_attach_doc_admin_sharing_date,
  82. p.last_attach_doc_admin_sharing_mc_id,
  83. p.last_so_transaction_id,
  84. p.hiring_authorization_date,
  85. p.hiring_authorization_request_date,
  86. p.firing_authorization_date,
  87. p.firing_authorization_request_date,
  88. p.vo_division_id,
  89.  
  90. decode(p.real_employer_tin, 'Double entry', 'Double entry', 'Unknown', 'Unknown', 'UNKNOWN', 'Unknown', 'unknown', 'Unknown', re_vt.real_employer_name) real_employer_name,
  91. decode(p.real_employer_tin, 'Double entry', 'Double entry', nvl(re_vt.tin, p.real_employer_tin)) real_employer_tin,
  92. cast(decode(p.real_employer_tin, 'Double entry', null, 'Unknown', null, 'UNKNOWN', null, 'unknown', null, re_vt.admin_region_id) as number(10)) real_employer_admin_region_id,
  93.  
  94. decode(p.rank1_sc_tin, 'Double entry', 'Double entry', 'Unknown', 'Unknown', 'UNKNOWN', 'Unknown', 'unknown', 'Unknown', sc_vt.real_employer_name) rank1_sc_name,
  95. decode(p.rank1_sc_tin, 'Double entry', 'Double entry', nvl(sc_vt.tin, p.rank1_sc_tin)) rank1_sc_tin,
  96. cast(decode(p.rank1_sc_tin, 'Double entry', null, 'Unknown', null, 'UNKNOWN', null, 'unknown', null, sc_vt.admin_region_id) as number(10)) rank1_sc_admin_region_id,
  97.  
  98. p.person_admin_region_id,
  99. p.admin_status_category_id,
  100. p.is_admin_status_ok,
  101. p.is_blacklisted,
  102. p.nationality_code_id,
  103. p.employee_contract_type_id,
  104. p.vo_employee_contract_type_id,
  105. p.lm_name,
  106. p.lm_date,
  107. p.lm_comment,
  108. p.is_cross_border_worker,
  109. vo.company_name,
  110. vo.company_tin,
  111. p.all_admin_attach_doc_validated,
  112. ap.admin_profile_category_id admin_profile_id,
  113. ocp.name last_caw_poi_name,
  114. wbs.poi_tin last_caw_poi_tin,
  115. wbs.ref_number last_caw_ref_number,
  116. sot.creation_date last_caw_creation_date,
  117. sot.work_date last_caw_work_date,
  118. sots.name last_caw_status,
  119. sots.so_transaction_status_id,
  120. sot.lm_date last_caw_lm_date,
  121. sot.so_comment last_caw_comment,
  122. sot.sot_remark_exist,
  123. (select json_arrayagg(json_object(vapd.admin_profile_category_id,
  124. vapd.admin_proof_category_id,
  125. vapd.admin_proof_category_name,
  126. vapd.admin_proof_short_name,
  127. vapd.admin_proof_id,
  128. vapd.document_type_name,
  129. vapd.document_type_id,
  130. vapd.is_admin_proof_doc_valid) returning clob)
  131. from v_admin_proof_doc vapd
  132. where vapd.person_id = p.person_id) admin_proof_doc,
  133. json_array(json_object('admin_proof_category_id' value 1,
  134. 'valid' value p_person.isAdminProofCatValid(1, p.person_id, trunc(sysdate))),
  135. json_object('admin_proof_category_id' value 2,
  136. 'valid' value p_person.isAdminProofCatValid(2, p.person_id, trunc(sysdate))),
  137. json_object('admin_proof_category_id' value 3,
  138. 'valid' value p_person.isAdminProofCatValid(3, p.person_id, trunc(sysdate))),
  139. json_object('admin_proof_category_id' value 4,
  140. 'valid' value p_person.isAdminProofCatValid(4, p.person_id, trunc(sysdate)))
  141. ) admin_proof_category_validities,
  142. re_vnv.vat_validation_status re_validation_status,
  143. sc_vnv.vat_validation_status sc_validation_status,
  144. manager1.first_name manager1_first_name,
  145. manager1.last_name manager1_last_name,
  146. manager1.company_nr manager1_company_nr,
  147. manager2.first_name manager2_first_name,
  148. manager2.last_name manager2_last_name,
  149. manager2.company_nr manager2_company_nr,
  150. p.last_med_visit_date person_last_med_visit_date,
  151. p.last_med_visit_status_id,
  152. last_medical_visit_status.name person_last_med_visit_status,
  153. p_person.getLastSecurityBriefingDate(p.person_id) last_security_briefing_date,
  154. p_person.getLastSecurityBriefingWBSStr(p.person_id) last_security_briefing_wbs
  155. from vo_person_category vpc,
  156. oc_poi home,
  157. vehicle_owner vo,
  158. person p,
  159. social_office_transaction sot,
  160. wbs,
  161. oc_poi ocp,
  162. so_transaction_status sots,
  163. vo_tin re_vt,
  164. vo_tin sc_vt,
  165. vat_number_validation re_vnv,
  166. vat_number_validation sc_vnv,
  167. admin_profile ap,
  168. person manager1,
  169. person manager2,
  170. medical_visit_status last_medical_visit_status
  171. where vpc.vo_person_category_id = p.vo_person_category_id
  172. and home.poi_id = p.home_poi_id
  173. and vo.vehicle_owner_id = vpc.vehicle_owner_id
  174. and sot.social_office_transaction_id (+) = p.last_so_transaction_id
  175. and wbs.wbs_id (+) = sot.wbs_id
  176. and ocp.poi_id (+) = wbs.poi_id
  177. and sots.so_transaction_status_id (+) = sot.so_transaction_status_id
  178. and re_vt.tin (+) = p.real_employer_tin
  179. and re_vt.vehicle_owner_id (+) = vo.vehicle_owner_id
  180. and p.admin_profile_id = ap.admin_profile_id (+)
  181. --and nvl(p.person_status_id,0) <> 2
  182.  
  183. and decode(SUBSTR(re_vnv.vat_number (+), 1,3), 'BE0', SUBSTR(re_vnv.vat_number (+), 4), re_vnv.vat_number (+)) = p.real_employer_tin
  184. and decode(SUBSTR(sc_vnv.vat_number (+), 1,3), 'BE0', SUBSTR(sc_vnv.vat_number (+), 4), sc_vnv.vat_number (+)) = p.rank1_sc_tin
  185.  
  186. and sc_vt.tin (+) = p.rank1_sc_tin
  187. and sc_vt.vehicle_owner_id (+) = vo.vehicle_owner_id
  188. and p.manager_person_id = manager1.person_id(+)
  189. and p.manager2_person_id = manager2.person_id(+)
  190. and p.last_med_visit_status_id = last_medical_visit_status.medical_visit_status_id(+);
  191.  
  192.  
  193. -- GRANT SELECT ON "OF_OWNER"."V_ORDS_GET_PERSON_LIST" TO "OF_PBI";
  194.  
  195.  
  196.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement