Advertisement
ILyaCyclone

CabinetContracts - ContractStageView

May 17th, 2021
277
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 4.57 KB | None | 0 0
  1. /* CabinetContracts - ContractStageView */
  2.  
  3. Select st.id_stage
  4. ,st.id_contract
  5. ,st.identifier -- Номер этапа
  6. ,st.stage -- Этап (наименование)
  7. ,st.d_start -- Начало этапа
  8. ,st.d_end -- Конец этапа
  9. ,nvl((Select Sum(sa.money)
  10. From accounts_contract_ ac
  11. ,paragraphs_ p
  12. ,salary_account_ sa
  13. Where ac.id_stage = st.id_stage
  14. And ac.id_paragraph = p.id_paragraph
  15. And p.idk_order In (436, 444)
  16. And ac.id_basis_sal = sa.id_basis_sal_charge)
  17. ,st.money) money -- Стоимость этапа
  18. ,st.inst -- Институт
  19. ,nvl((Select Sum(ac.money)
  20. From accounts_contract_ ac
  21. ,paragraphs_ p
  22. ,dependences_lists_ dl
  23. ,accounts_contract_ ac2
  24. ,paragraphs_ p2
  25. Where ac.id_stage = st.id_stage
  26. And ac.id_paragraph = p.id_paragraph
  27. And p.id_order = dl.id_o_main
  28. And dl.id_o_dependent = p2.id_order
  29. And p2.id_paragraph = ac2.id_paragraph
  30. And ac2.id_stage = ac.id_stage
  31. And ac2.d_start = ac.d_start)
  32. ,0) pay -- Оплачено
  33. /*
  34. ,Case
  35. When (Select Count(Distinct ac.id_paragraph || ac2.id_stage)
  36. From accounts_contract_ ac
  37. ,paragraphs_ p
  38. ,accounts_contract_ ac2
  39. Where ac.id_stage = st.id_stage
  40. And ac.id_paragraph = p.id_paragraph
  41. And p.idk_order In (62, 431)
  42. And ac.money > 0
  43. And st.Status_order = 1
  44. And ac2.id_paragraph = p.id_paragraph) = 1 Then
  45. 'http://miit.ru/rs/Квитанция на оплату договора ' || st.Status_Text
  46. || '.pdf?cd=1&id_list=' ||
  47. (Select Distinct p.id_order
  48. From accounts_contract_ ac
  49. ,paragraphs_ p
  50. ,accounts_contract_ ac2
  51. Where ac.id_stage = st.id_stage
  52. And ac.id_paragraph = p.id_paragraph
  53. And p.idk_order In (62, 431)
  54. And ac.money > 0
  55. And ac2.id_paragraph = p.id_paragraph)
  56. Else
  57. Null
  58. End id_par -- Ссылка на печать документа
  59. */
  60. From (Select ps.Status_Text
  61. ,ps.Status_order
  62. ,nvl(st.subject, 'stage № ' || nvl(st.identifier, 1)) ||
  63. Decode(sn.id_stages_names
  64. ,''
  65. ,''
  66. ,42478
  67. ,''
  68. ,42477
  69. ,' (разница в планах)'
  70. ,' (' || sn.Name || ')') stage
  71. ,c.d_start d_start_dog
  72. ,c.d_end d_end_dog
  73. ,c.id_contract
  74. ,st.d_start
  75. ,st.d_end
  76. ,st.identifier
  77. ,st.id_stage
  78. ,nvl((Select Sum(sa.money)
  79. From accounts_contract_ ac
  80. ,salary_account_ sa
  81. ,paragraphs_ p
  82. Where ac.id_stage = st.id_stage
  83. And ac.id_basis_sal = sa.id_salary_account
  84. And ac.id_paragraph = p.id_paragraph
  85. And p.idk_order In (444, 436))
  86. ,st.money) money
  87. ,ts_.Get_DivisionName(sd.id_d_institute
  88. ,st.d_start
  89. ,1
  90. ,1
  91. ,2
  92. ,2) inst
  93.  
  94. From contracts_ c
  95. ,employees_ e
  96. ,paragraphs_status_ ps
  97. ,stages_ st
  98. ,stages_names_ sn
  99. ,web_user_wp w
  100. ,specialities_contract_ sc
  101. ,specialities_division_ sd
  102.  
  103. Where c.id_with_whom = e.id_contractor
  104. And w.id_web_user = :Bind_IdWebUser
  105. And e.id_e = w.id_e_kis
  106. And c.id_contract = st.id_contract
  107. And c.id_paragraph = ps.id_paragraph
  108. And c.id_contract = sc.id_contract(+)
  109. And sc.id_d_specialitie = sd.id_d_specialitie(+)
  110. And st.id_stages_names = sn.id_stages_names(+)) st
  111.  
  112. Order by st.d_start, st.identifier, st.stage
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement