index.php 29 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486
  1. <?php
  2. if (cfr('EXTCONTRAS')) {
  3. if ($ubillingConfig->getAlterParam('EXTCONTRAS_FINANCE_ON')) {
  4. $ExtContras = new ExtContras();
  5. show_window(__('External counterparties: finances'), $ExtContras->renderMainControls());
  6. if (ubRouting::checkPost($ExtContras::ROUTE_FORCECACHE_UPD)) {
  7. $ExtContras->refreshCacheForced();
  8. die($ExtContras->renderWebMsg(__('Info'), __('Cache data updated succesfuly'), 'info'));
  9. }
  10. if (ubRouting::checkGet($ExtContras::ROUTE_CONTRAS_JSON)){
  11. $whereRaw = '';
  12. /* if (ubRouting::checkPost($ExtContras::MISC_WEBFILTER_DATE_START)) {
  13. $whereRaw.= "`" . $ExtContras::TABLE_ECCONTRACTS . '`.`' . $ExtContras::DBFLD_CTRCT_DTSTART . "` >= '" . ubRouting::post($ExtContras::MISC_WEBFILTER_DATE_START) . "'";
  14. }
  15. if (ubRouting::checkPost($ExtContras::MISC_WEBFILTER_DATE_END)) {
  16. $whereRaw.= (empty($whereRaw) ? '' : ' AND ');
  17. $whereRaw.= "`" . $ExtContras::TABLE_ECCONTRACTS . '`.`' . $ExtContras::DBFLD_CTRCT_DTSTART . "` <= '" . ubRouting::post($ExtContras::MISC_WEBFILTER_DATE_END) . "' + INTERVAL 1 DAY";
  18. }
  19. if (ubRouting::checkPost($ExtContras::MISC_WEBFILTER_PAYDAY)) {
  20. $whereRaw.= (empty($whereRaw) ? '' : ' AND ');
  21. $whereRaw.= "`" . $ExtContras::TABLE_EXTCONTRAS . '`.`' . $ExtContras::DBFLD_EXTCONTRAS_PAYDAY . "` = " . ubRouting::post($ExtContras::MISC_WEBFILTER_PAYDAY);
  22. }*/
  23. $ExtContras->extcontrasRenderListJSON($whereRaw);
  24. }
  25. if (ubRouting::checkGet($ExtContras::ROUTE_PROFILE_JSON)){
  26. $ExtContras->profileRenderListJSON();
  27. }
  28. if (ubRouting::checkGet($ExtContras::ROUTE_CONTRACT_JSON)) {
  29. $ExtContras->contractRenderListJSON();
  30. }
  31. if (ubRouting::checkGet($ExtContras::ROUTE_ADDRESS_JSON)) {
  32. $ExtContras->addressRenderListJSON();
  33. }
  34. if (ubRouting::checkGet($ExtContras::ROUTE_PERIOD_JSON)){
  35. $ExtContras->periodRenderListJSON();
  36. }
  37. if (ubRouting::checkGet($ExtContras::ROUTE_INVOICES_JSON)){
  38. $whereRaw = '';
  39. if (ubRouting::checkPost($ExtContras::MISC_WEBFILTER_DATE_START)) {
  40. $whereRaw.= "`" . $ExtContras::DBFLD_INVOICES_DATE . "` >= '" . ubRouting::post($ExtContras::MISC_WEBFILTER_DATE_START) . "'";
  41. }
  42. if (ubRouting::checkPost($ExtContras::MISC_WEBFILTER_DATE_END)) {
  43. $whereRaw.= (empty($whereRaw) ? '' : ' AND ');
  44. $whereRaw.= "`" . $ExtContras::DBFLD_INVOICES_DATE . "` <= '" . ubRouting::post($ExtContras::MISC_WEBFILTER_DATE_END) . "' + INTERVAL 1 DAY";
  45. }
  46. $ExtContras->invoiceRenderListJSON($whereRaw);
  47. }
  48. if (ubRouting::checkGet($ExtContras::ROUTE_MISSPAYMS_JSON)){
  49. $whereRaw = '';
  50. if (ubRouting::checkPost($ExtContras::MISC_WEBFILTER_MISSPAYMS)) {
  51. $whereRaw.= ubRouting::post($ExtContras::MISC_WEBFILTER_MISSPAYMS);
  52. } else {
  53. $whereRaw.= ' ISNULL(`' . $ExtContras::DBFLD_MISSPAYMS_DATE_PAYED . '`)';
  54. }
  55. $ExtContras->missedPaymsRenderListJSON($whereRaw);
  56. }
  57. if (ubRouting::checkGet($ExtContras::ROUTE_2LVL_CNTRCTS_DETAIL)) {
  58. if (ubRouting::checkPost($ExtContras::DBFLD_EXTCONTRAS_PROFILE_ID)) {
  59. $detailsFilter = '&' . $ExtContras::DBFLD_EXTCONTRAS_PROFILE_ID . '=' . ubRouting::post($ExtContras::DBFLD_EXTCONTRAS_PROFILE_ID);
  60. $ajaxURL = '' . $ExtContras::URL_ME . '&' . $ExtContras::ROUTE_2LVL_CNTRCTS_JSON . '=true' . $detailsFilter;
  61. $jqdtID = 'jqdt_' . md5($ajaxURL);
  62. die(wf_Plate(wf_tag('h3', false, 'glamour', 'style="margin-top: 10px; width: 95%;"') . __('Contracts')
  63. . wf_nbsp(4) . wf_JQDTRefreshButton($jqdtID, '', '', 'style="display: contents;"') . wf_delimiter(0)
  64. . $ExtContras->extcontrasFilterWebFormInline($ajaxURL, $jqdtID) . wf_tag('h3', true)
  65. . $ExtContras->ecRender2ndLvlContractsJQDT('', ubRouting::get($ExtContras::MISC_MARKROW_URL), $detailsFilter, false))
  66. . wf_CleanDiv() . wf_delimiter(0));
  67. }
  68. }
  69. if (ubRouting::checkGet($ExtContras::ROUTE_2LVL_CNTRCTS_JSON)) {
  70. $whereRaw = '';
  71. if (ubRouting::checkGet($ExtContras::DBFLD_EXTCONTRAS_PROFILE_ID)) {
  72. $whereRaw.= "`" . $ExtContras::TABLE_EXTCONTRAS . "`.`" . $ExtContras::DBFLD_EXTCONTRAS_PROFILE_ID . "` = " . ubRouting::get($ExtContras::DBFLD_EXTCONTRAS_PROFILE_ID);
  73. }
  74. if (ubRouting::checkPost($ExtContras::MISC_WEBFILTER_DATE_START)) {
  75. $whereRaw.= (empty($whereRaw) ? '' : ' AND ');
  76. $whereRaw.= "`" . $ExtContras::TABLE_ECCONTRACTS . '`.`' . $ExtContras::DBFLD_CTRCT_DTSTART . "` >= '" . ubRouting::post($ExtContras::MISC_WEBFILTER_DATE_START) . "'";
  77. }
  78. if (ubRouting::checkPost($ExtContras::MISC_WEBFILTER_DATE_END)) {
  79. $whereRaw.= (empty($whereRaw) ? '' : ' AND ');
  80. $whereRaw.= "`" . $ExtContras::TABLE_ECCONTRACTS . '`.`' . $ExtContras::DBFLD_CTRCT_DTSTART . "` <= '" . ubRouting::post($ExtContras::MISC_WEBFILTER_DATE_END) . "' + INTERVAL 1 DAY";
  81. }
  82. if (ubRouting::checkPost($ExtContras::MISC_WEBFILTER_PAYDAY)) {
  83. $whereRaw.= (empty($whereRaw) ? '' : ' AND ');
  84. $whereRaw.= "`" . $ExtContras::TABLE_EXTCONTRAS . '`.`' . $ExtContras::DBFLD_EXTCONTRAS_PAYDAY . "` = " . ubRouting::post($ExtContras::MISC_WEBFILTER_PAYDAY);
  85. }
  86. $ExtContras->ecRender2ndLvlContractsListJSON($whereRaw);
  87. }
  88. if (ubRouting::checkGet($ExtContras::ROUTE_FINOPS_DETAILS_CNTRCTS)) {
  89. if (ubRouting::checkPost($ExtContras::DBFLD_COMMON_ID)) {
  90. $detailsFilterFinops = '&' . $ExtContras::DBFLD_COMMON_ID . '=' . ubRouting::post($ExtContras::DBFLD_COMMON_ID)
  91. . '&' . $ExtContras::DBFLD_EXTCONTRAS_CONTRACT_ID . '=' . ubRouting::post($ExtContras::DBFLD_EXTCONTRAS_CONTRACT_ID);
  92. $ajaxURLFinops = '' . $ExtContras::URL_ME . '&' . $ExtContras::ROUTE_FINOPS_JSON . '=true' . $detailsFilterFinops;
  93. $jqdtIDFinops = 'jqdt_' . md5($ajaxURLFinops);
  94. $detailsFilterAddr = $detailsFilterFinops . '&' . $ExtContras::DBFLD_EXTCONTRAS_ADDRESS_ID . '=' . ubRouting::post($ExtContras::DBFLD_EXTCONTRAS_ADDRESS_ID);
  95. $ajaxURLAddr = '' . $ExtContras::URL_ME . '&' . $ExtContras::ROUTE_3LVL_ADDR_JSON . '=true' . $detailsFilterAddr;
  96. $jqdtIDAddr = 'jqdt_' . md5($ajaxURLAddr);
  97. die(wf_Plate(wf_tag('h3', false, 'glamour', 'style="margin-top: 10px; width: 95%;"') . __('Addresses')
  98. . wf_nbsp(4) . wf_JQDTRefreshButton($jqdtIDAddr, '', '', 'style="display: contents;"') . wf_delimiter(0)
  99. . $ExtContras->extcontrasFilterWebFormInline($ajaxURLAddr, $jqdtIDAddr) . wf_tag('h3', true)
  100. . $ExtContras->ecRender2ndLvlAddressJQDT('', ubRouting::get($ExtContras::MISC_MARKROW_URL), $detailsFilterAddr, false))
  101. . wf_Plate(wf_tag('h3', false, 'glamour', 'style="margin-top: 25px; width: 95%;"') . __('Financial operations')
  102. . wf_nbsp(4) . wf_JQDTRefreshButton($jqdtIDFinops, '', '', 'style="display: contents;"') . wf_delimiter(0)
  103. . $ExtContras->extcontrasFilterWebFormInline($ajaxURLFinops, $jqdtIDFinops, false) . wf_tag('h3', true)
  104. . $ExtContras->finopsRenderJQDT('', ubRouting::get($ExtContras::MISC_MARKROW_URL), $detailsFilterFinops, false))
  105. . wf_CleanDiv() . wf_delimiter(0));
  106. }
  107. }
  108. if (ubRouting::checkGet($ExtContras::ROUTE_3LVL_ADDR_JSON)) {
  109. $whereRaw = '';
  110. if (ubRouting::checkGet($ExtContras::DBFLD_COMMON_ID)) {
  111. $whereRaw.= "`" . $ExtContras::TABLE_EXTCONTRAS . "`.`" . $ExtContras::DBFLD_EXTCONTRAS_PROFILE_ID . "` = " . ubRouting::get($ExtContras::DBFLD_COMMON_ID)
  112. . " AND `" . $ExtContras::TABLE_EXTCONTRAS . "`.`" . $ExtContras::DBFLD_EXTCONTRAS_CONTRACT_ID . "` = " . ubRouting::get($ExtContras::DBFLD_EXTCONTRAS_CONTRACT_ID);
  113. //. " AND `" . $ExtContras::TABLE_EXTCONTRAS . "`.`" . $ExtContras::DBFLD_EXTCONTRAS_ADDRESS_ID . "` = " . ubRouting::get($ExtContras::DBFLD_EXTCONTRAS_ADDRESS_ID);
  114. }
  115. if (ubRouting::checkPost($ExtContras::MISC_WEBFILTER_DATE_START)) {
  116. $whereRaw.= (empty($whereRaw) ? '' : ' AND ');
  117. $whereRaw.= "`" . $ExtContras::TABLE_ECCONTRACTS . '`.`' . $ExtContras::DBFLD_CTRCT_DTSTART . "` >= '" . ubRouting::post($ExtContras::MISC_WEBFILTER_DATE_START) . "'";
  118. }
  119. if (ubRouting::checkPost($ExtContras::MISC_WEBFILTER_DATE_END)) {
  120. $whereRaw.= (empty($whereRaw) ? '' : ' AND ');
  121. $whereRaw.= "`" . $ExtContras::TABLE_ECCONTRACTS . '`.`' . $ExtContras::DBFLD_CTRCT_DTSTART . "` <= '" . ubRouting::post($ExtContras::MISC_WEBFILTER_DATE_END) . "' + INTERVAL 1 DAY";
  122. }
  123. if (ubRouting::checkPost($ExtContras::MISC_WEBFILTER_PAYDAY)) {
  124. $whereRaw.= (empty($whereRaw) ? '' : ' AND ');
  125. $whereRaw.= "`" . $ExtContras::TABLE_EXTCONTRAS . '`.`' . $ExtContras::DBFLD_EXTCONTRAS_PAYDAY . "` = " . ubRouting::post($ExtContras::MISC_WEBFILTER_PAYDAY);
  126. }
  127. $ExtContras->ecRender2ndLvlAddressListJSON($whereRaw);
  128. }
  129. if (ubRouting::checkGet($ExtContras::ROUTE_FINOPS_DETAILS_ADDRESS)) {
  130. if (ubRouting::checkPost($ExtContras::DBFLD_COMMON_ID)) {
  131. $detailsFilterFinops = '&' . $ExtContras::DBFLD_COMMON_ID . '=' . ubRouting::post($ExtContras::DBFLD_COMMON_ID)
  132. . '&' . $ExtContras::DBFLD_EXTCONTRAS_CONTRACT_ID . '=' . ubRouting::post($ExtContras::DBFLD_EXTCONTRAS_CONTRACT_ID)
  133. . '&' . $ExtContras::DBFLD_EXTCONTRAS_ADDRESS_ID . '=' . ubRouting::post($ExtContras::DBFLD_EXTCONTRAS_ADDRESS_ID);
  134. $ajaxURL = '' . $ExtContras::URL_ME . '&' . $ExtContras::ROUTE_FINOPS_JSON . '=true' . $detailsFilterFinops;
  135. $jqdtIDFinops = 'jqdt_' . md5($ajaxURL);
  136. die(wf_Plate(wf_tag('h3', false, 'glamour', 'style="margin-top: 25px; width: 95%;"') . __('Financial operations')
  137. . wf_nbsp(4) . wf_JQDTRefreshButton($jqdtIDFinops, '', '', 'style="display: contents;"') . wf_delimiter(0)
  138. . $ExtContras->extcontrasFilterWebFormInline($ajaxURL, $jqdtIDFinops, false) . wf_tag('h3', true)
  139. . $ExtContras->finopsRenderJQDT('', ubRouting::get($ExtContras::MISC_MARKROW_URL), $detailsFilterFinops, false))
  140. . wf_CleanDiv() . wf_delimiter(0));
  141. }
  142. }
  143. if (ubRouting::checkGet($ExtContras::ROUTE_FINOPS_JSON)) {
  144. $whereRaw = '';
  145. if (ubRouting::checkGet($ExtContras::DBFLD_COMMON_ID)) {
  146. if (ubRouting::checkGet($ExtContras::DBFLD_EXTCONTRAS_CONTRACT_ID)
  147. and ! ubRouting::checkGet($ExtContras::DBFLD_EXTCONTRAS_ADDRESS_ID)) {
  148. $whereRaw .= "`" . $ExtContras::TABLE_ECMONEY . "`.`"
  149. . $ExtContras::DBFLD_MONEY_PROFILEID . "` = " . ubRouting::get($ExtContras::DBFLD_COMMON_ID)
  150. . " AND `" . $ExtContras::TABLE_ECMONEY . "`.`"
  151. . $ExtContras::DBFLD_EXTCONTRAS_CONTRACT_ID . "` = " . ubRouting::get($ExtContras::DBFLD_EXTCONTRAS_CONTRACT_ID);
  152. } elseif (ubRouting::checkGet($ExtContras::DBFLD_EXTCONTRAS_CONTRACT_ID)
  153. and ubRouting::checkGet($ExtContras::DBFLD_EXTCONTRAS_ADDRESS_ID)) {
  154. $whereRaw .= "`" . $ExtContras::TABLE_ECMONEY . "`.`"
  155. . $ExtContras::DBFLD_MONEY_PROFILEID . "` = " . ubRouting::get($ExtContras::DBFLD_COMMON_ID)
  156. . " AND `" . $ExtContras::TABLE_ECMONEY . "`.`"
  157. . $ExtContras::DBFLD_EXTCONTRAS_CONTRACT_ID . "` = " . ubRouting::get($ExtContras::DBFLD_EXTCONTRAS_CONTRACT_ID)
  158. . " AND `" . $ExtContras::TABLE_ECMONEY . "`.`"
  159. . $ExtContras::DBFLD_EXTCONTRAS_ADDRESS_ID . "` = " . ubRouting::get($ExtContras::DBFLD_EXTCONTRAS_ADDRESS_ID);
  160. }
  161. if (ubRouting::checkPost($ExtContras::MISC_WEBFILTER_DATE_START)) {
  162. $whereRaw.= (empty($whereRaw) ? '' : ' AND ');
  163. $whereRaw.= "`" . $ExtContras::DBFLD_MONEY_DATE . "` >= '" . ubRouting::post($ExtContras::MISC_WEBFILTER_DATE_START) . "'";
  164. }
  165. if (ubRouting::checkPost($ExtContras::MISC_WEBFILTER_DATE_END)) {
  166. $whereRaw.= (empty($whereRaw) ? '' : ' AND ');
  167. $whereRaw.= "`" . $ExtContras::DBFLD_MONEY_DATE . "` <= '" . ubRouting::post($ExtContras::MISC_WEBFILTER_DATE_END) . "' + INTERVAL 1 DAY";
  168. }
  169. } else {
  170. if (ubRouting::checkPost($ExtContras::MISC_WEBFILTER_DATE_START)) {
  171. $whereRaw.= "`" . $ExtContras::DBFLD_MONEY_DATE . "` >= '" . ubRouting::post($ExtContras::MISC_WEBFILTER_DATE_START) . "'";
  172. }
  173. if (ubRouting::checkPost($ExtContras::MISC_WEBFILTER_DATE_END)) {
  174. $whereRaw.= (empty($whereRaw) ? '' : ' AND ');
  175. $whereRaw.= "`" . $ExtContras::DBFLD_MONEY_DATE . "` <= '" . ubRouting::post($ExtContras::MISC_WEBFILTER_DATE_END) . "' + INTERVAL 1 DAY";
  176. }
  177. }
  178. $ExtContras->finopsRenderListJSON($whereRaw);
  179. }
  180. if (ubRouting::checkPost($ExtContras::URL_EXTCONTRAS_COLORS)) {
  181. $ExtContras->setTableGridColorOpts();
  182. }
  183. if (ubRouting::checkGet($ExtContras::URL_EXTCONTRAS_COLORS)) {
  184. show_window(__('Counterparties table coloring settings'), $ExtContras->extcontrasColorSettings());
  185. }
  186. if (ubRouting::checkGet($ExtContras::URL_EXTCONTRAS)) {
  187. show_window(__('Counterparties list') . wf_nbsp(4)
  188. . wf_Link($ExtContras::URL_ME . '&' . $ExtContras::URL_EXTCONTRAS_COLORS . '=true',
  189. wf_img_sized('skins/color-picker.png', __('Coloring settings config'),
  190. '22', '22', 'vertical-align: middle;'),
  191. false, 'ubButton', 'target="_blank" style="display: inline; padding: 3px 7px; vertical-align: middle;"'),
  192. wf_Plate($ExtContras->extcontrasWebForm(false), '', '', '', 'margin-right: 30px;')
  193. . $ExtContras->extcontrasRenderMainJQDT()
  194. );
  195. // . $ExtContras->extcontrasFilterWebForm() . wf_CleanDiv() . wf_delimiter(0)
  196. }
  197. if (ubRouting::checkGet($ExtContras::URL_DICTPROFILES)) {
  198. show_window(__('Counterparties profiles dictionary'),
  199. $ExtContras->profileWebForm(false)
  200. . wf_delimiter() . $ExtContras->profileRenderJQDT('', ubRouting::get($ExtContras::MISC_MARKROW_URL))
  201. );
  202. }
  203. if (ubRouting::checkGet($ExtContras::URL_DICTCONTRACTS)) {
  204. show_window(__('Counterparties contracts dictionary'),
  205. $ExtContras->contractWebForm(false)
  206. . wf_delimiter() . $ExtContras->contractRenderJQDT('', ubRouting::get($ExtContras::MISC_MARKROW_URL))
  207. );
  208. }
  209. if (ubRouting::checkGet($ExtContras::URL_DICTADDRESS)) {
  210. show_window(__('Contracts addresses dictionary'),
  211. $ExtContras->addressWebForm(false)
  212. . wf_delimiter() . $ExtContras->addressRenderJQDT('', ubRouting::get($ExtContras::MISC_MARKROW_URL))
  213. );
  214. }
  215. if (ubRouting::checkGet($ExtContras::URL_DICTPERIODS)) {
  216. show_window(__('Periods dictionary'),
  217. $ExtContras->periodWebForm(false)
  218. . wf_delimiter() . $ExtContras->periodRenderJQDT('', ubRouting::get($ExtContras::MISC_MARKROW_URL))
  219. );
  220. }
  221. if (ubRouting::checkGet($ExtContras::URL_INVOICES)) {
  222. show_window(__('Invoices'),
  223. wf_Plate($ExtContras->invoiceWebForm(false), '', '', '', 'margin-right: 30px;')
  224. . $ExtContras->invoiceFilterWebForm() . wf_CleanDiv() . wf_delimiter(0)
  225. . $ExtContras->invoiceRenderJQDT('', ubRouting::get($ExtContras::MISC_MARKROW_URL))
  226. );
  227. }
  228. if (ubRouting::checkGet($ExtContras::URL_FINOPERATIONS)) {
  229. show_window(__('Financial operations'),
  230. wf_Plate($ExtContras->finopsWebForm(false), '', '', '', 'margin-right: 30px;')
  231. . $ExtContras->finopsFilterWebForm() . wf_CleanDiv() . wf_delimiter(0)
  232. . $ExtContras->finopsRenderJQDT('', ubRouting::get($ExtContras::MISC_MARKROW_URL))
  233. );
  234. }
  235. if (ubRouting::checkGet($ExtContras::URL_MISSEDPAYMENTS)) {
  236. show_window(__('Missed payments with expired pay date'),
  237. $ExtContras->missedPaymsFilterWebForm() . wf_delimiter() .
  238. $ExtContras->missedPaymsRenderJQDT('', ubRouting::get($ExtContras::MISC_MARKROW_URL))
  239. );
  240. }
  241. if (ubRouting::checkPost($ExtContras::ROUTE_PROFILE_ACTS)) {
  242. $dataArray = array($ExtContras::DBFLD_PROFILE_NAME => ubRouting::post($ExtContras::CTRL_PROFILE_NAME),
  243. $ExtContras::DBFLD_PROFILE_CONTACT => ubRouting::post($ExtContras::CTRL_PROFILE_CONTACT),
  244. $ExtContras::DBFLD_PROFILE_EDRPO => ubRouting::post($ExtContras::CTRL_PROFILE_EDRPO),
  245. $ExtContras::DBFLD_PROFILE_MAIL => ubRouting::post($ExtContras::CTRL_PROFILE_MAIL)
  246. );
  247. $chkUniqArray = $ExtContras->createCheckUniquenessArray($ExtContras::DBFLD_PROFILE_NAME, '=',
  248. ubRouting::post($ExtContras::CTRL_PROFILE_NAME));
  249. $showResult = $ExtContras->processCRUDs($dataArray, $ExtContras::TABLE_ECPROFILES, $ExtContras::CTRL_PROFILE_NAME,
  250. 'profileWebForm',true, $chkUniqArray,
  251. 'Profile');
  252. die($showResult);
  253. }
  254. if (ubRouting::checkPost($ExtContras::ROUTE_CONTRACT_ACTS)) {
  255. $autoprlngChk = ubRouting::post($ExtContras::CTRL_CTRCT_AUTOPRLNG, 'fi', FILTER_VALIDATE_BOOLEAN);
  256. $autoprlngChk = (empty($autoprlngChk) ? 0 : 1);
  257. $dataArray = array($ExtContras::DBFLD_CTRCT_CONTRACT => ubRouting::post($ExtContras::CTRL_CTRCT_CONTRACT),
  258. $ExtContras::DBFLD_CTRCT_DTSTART => ubRouting::post($ExtContras::CTRL_CTRCT_DTSTART),
  259. $ExtContras::DBFLD_CTRCT_DTEND => ubRouting::post($ExtContras::CTRL_CTRCT_DTEND),
  260. $ExtContras::DBFLD_CTRCT_SUBJECT => ubRouting::post($ExtContras::CTRL_CTRCT_SUBJECT),
  261. $ExtContras::DBFLD_CTRCT_FULLSUM => ubRouting::post($ExtContras::CTRL_CTRCT_FULLSUM),
  262. $ExtContras::DBFLD_CTRCT_NOTES => ubRouting::post($ExtContras::CTRL_CTRCT_NOTES),
  263. $ExtContras::DBFLD_CTRCT_AUTOPRLNG => $autoprlngChk
  264. );
  265. $chkUniqArray = $ExtContras->createCheckUniquenessArray($ExtContras::DBFLD_CTRCT_CONTRACT, '=',
  266. ubRouting::post($ExtContras::CTRL_CTRCT_CONTRACT));
  267. $showResult = $ExtContras->processCRUDs($dataArray, $ExtContras::TABLE_ECCONTRACTS, $ExtContras::CTRL_CTRCT_CONTRACT,
  268. 'contractWebForm',true, $chkUniqArray,
  269. 'Contract');
  270. die($showResult);
  271. }
  272. if (ubRouting::checkPost($ExtContras::ROUTE_ADDRESS_ACTS)) {
  273. $dataArray = array($ExtContras::DBFLD_ADDRESS_ADDR => ubRouting::post($ExtContras::CTRL_ADDRESS_ADDR),
  274. $ExtContras::DBFLD_ADDRESS_SUM => ubRouting::post($ExtContras::CTRL_ADDRESS_SUM),
  275. $ExtContras::DBFLD_ADDRESS_CTNOTES => ubRouting::post($ExtContras::CTRL_ADDRESS_CTNOTES),
  276. $ExtContras::DBFLD_ADDRESS_NOTES => ubRouting::post($ExtContras::CTRL_ADDRESS_NOTES)
  277. );
  278. $chkUniqArray = $ExtContras->createCheckUniquenessArray($ExtContras::DBFLD_ADDRESS_ADDR, '=',
  279. ubRouting::post($ExtContras::CTRL_ADDRESS_ADDR));
  280. $showResult = $ExtContras->processCRUDs($dataArray, $ExtContras::TABLE_ECADDRESS, $ExtContras::CTRL_ADDRESS_ADDR,
  281. 'addressWebForm', true, $chkUniqArray,
  282. 'Address');
  283. die($showResult);
  284. }
  285. if (ubRouting::checkPost($ExtContras::ROUTE_PERIOD_ACTS)) {
  286. $dataArray = array($ExtContras::DBFLD_PERIOD_NAME => ubRouting::post($ExtContras::CTRL_PERIOD_NAME));
  287. $chkUniqArray = $ExtContras->createCheckUniquenessArray($ExtContras::DBFLD_PERIOD_NAME, '=',
  288. ubRouting::post($ExtContras::CTRL_PERIOD_NAME));
  289. $showResult = $ExtContras->processCRUDs($dataArray, $ExtContras::TABLE_ECPERIODS, $ExtContras::CTRL_PERIOD_NAME,
  290. 'periodWebForm', true, $chkUniqArray,
  291. 'Period');
  292. die($showResult);
  293. }
  294. if (ubRouting::checkPost($ExtContras::ROUTE_INVOICES_ACTS)) {
  295. $invoIncoming = (ubRouting::post($ExtContras::CTRL_INVOICES_IN_OUT) == 'incoming') ? 1 : 0;
  296. $invoOutgoing = (ubRouting::post($ExtContras::CTRL_INVOICES_IN_OUT) == 'outgoing') ? 1 : 0;
  297. $dataArray = array($ExtContras::DBFLD_INVOICES_CONTRASID => ubRouting::post($ExtContras::CTRL_INVOICES_CONTRASID),
  298. $ExtContras::DBFLD_INVOICES_INTERNAL_NUM => ubRouting::post($ExtContras::CTRL_INVOICES_INTERNAL_NUM),
  299. $ExtContras::DBFLD_INVOICES_INVOICE_NUM => ubRouting::post($ExtContras::CTRL_INVOICES_INVOICE_NUM),
  300. $ExtContras::DBFLD_INVOICES_DATE => ubRouting::post($ExtContras::CTRL_INVOICES_DATE),
  301. $ExtContras::DBFLD_INVOICES_SUM => ubRouting::post($ExtContras::CTRL_INVOICES_SUM),
  302. $ExtContras::DBFLD_INVOICES_SUM_VAT => ubRouting::post($ExtContras::CTRL_INVOICES_SUM_VAT),
  303. $ExtContras::DBFLD_INVOICES_NOTES => ubRouting::post($ExtContras::CTRL_INVOICES_NOTES),
  304. $ExtContras::DBFLD_INVOICES_INCOMING => $invoIncoming,
  305. $ExtContras::DBFLD_INVOICES_OUTGOING => $invoOutgoing
  306. );
  307. $chkUniqArray = $ExtContras->createCheckUniquenessArray($ExtContras::DBFLD_INVOICES_INVOICE_NUM, '=',
  308. ubRouting::post($ExtContras::CTRL_INVOICES_INVOICE_NUM));
  309. $showResult = $ExtContras->processCRUDs($dataArray, $ExtContras::TABLE_ECINVOICES, $ExtContras::CTRL_INVOICES_INVOICE_NUM,
  310. 'invoiceWebForm', true, $chkUniqArray,
  311. 'Invoice');
  312. die($showResult);
  313. }
  314. if (ubRouting::checkPost($ExtContras::ROUTE_CONTRAS_ACTS)) {
  315. $dataArray = array($ExtContras::DBFLD_EXTCONTRAS_PROFILE_ID => ubRouting::post($ExtContras::CTRL_EXTCONTRAS_PROFILE_ID),
  316. $ExtContras::DBFLD_EXTCONTRAS_CONTRACT_ID => ubRouting::post($ExtContras::CTRL_EXTCONTRAS_CONTRACT_ID),
  317. $ExtContras::DBFLD_EXTCONTRAS_ADDRESS_ID => ubRouting::post($ExtContras::CTRL_EXTCONTRAS_ADDRESS_ID),
  318. $ExtContras::DBFLD_EXTCONTRAS_PERIOD_ID => ubRouting::post($ExtContras::CTRL_EXTCONTRAS_PERIOD_ID),
  319. $ExtContras::DBFLD_EXTCONTRAS_PAYDAY => ubRouting::post($ExtContras::CTRL_EXTCONTRAS_PAYDAY),
  320. $ExtContras::DBFLD_EXTCONTRAS_DATECREATE => curdatetime()
  321. );
  322. //$chkUniqArray = $ExtContras->createCheckUniquenessArray($ExtContras::DBFLD_INVOICES_INVOICE_NUM, '=',
  323. // ubRouting::post($ExtContras::CTRL_INVOICES_INVOICE_NUM));
  324. $showResult = $ExtContras->processCRUDs($dataArray, $ExtContras::TABLE_EXTCONTRAS, $ExtContras::CTRL_EXTCONTRAS_PAYDAY,
  325. 'extcontrasWebForm', false, array(),
  326. 'External counterparty');
  327. die($showResult);
  328. }
  329. if (ubRouting::checkPost($ExtContras::ROUTE_FINOPS_ACTS)) {
  330. $moneyDateValue = curdatetime();
  331. $profileID = ubRouting::post($ExtContras::CTRL_MONEY_PROFILEID);
  332. $contractID = ubRouting::post($ExtContras::CTRL_MONEY_CNTRCTID);
  333. $addressID = ubRouting::post($ExtContras::CTRL_MONEY_ADDRESSID);
  334. if (ubRouting::checkPost($ExtContras::ROUTE_ACTION_CREATE)) {
  335. // $payDay = $ExtContras->getContraPayday($profileID, $contractID, $addressID);
  336. // $paymentDueDate = date('Y-m-') . $payDay;
  337. $moneyDateField = $ExtContras::DBFLD_MONEY_DATE;
  338. } else {
  339. $moneyDateField = $ExtContras::DBFLD_MONEY_DATE_EDIT;
  340. }
  341. if (ubRouting::checkPost($ExtContras::ROUTE_ACTION_PREFILL)) {
  342. $prefillData = ubRouting::post($ExtContras::MISC_PREFILL_DATA);
  343. $createModality = true;
  344. } else {
  345. $prefillData = array();
  346. $createModality = false;
  347. }
  348. $finopIncoming = (ubRouting::post($ExtContras::CTRL_MONEY_INOUT) == 'incoming') ? 1 : 0;
  349. $finopOutgoing = (ubRouting::post($ExtContras::CTRL_MONEY_INOUT) == 'outgoing') ? 1 : 0;
  350. $dataArray = array($ExtContras::DBFLD_MONEY_PROFILEID => $profileID,
  351. $ExtContras::DBFLD_MONEY_CNTRCTID => $contractID,
  352. $ExtContras::DBFLD_MONEY_ADDRESSID => $addressID,
  353. $ExtContras::DBFLD_MONEY_INVOICEID => ubRouting::post($ExtContras::CTRL_MONEY_INVOICEID),
  354. $ExtContras::DBFLD_MONEY_ACCRUALID => ubRouting::post($ExtContras::CTRL_MONEY_ACCRUALID),
  355. $ExtContras::DBFLD_MONEY_PURPOSE => ubRouting::post($ExtContras::CTRL_MONEY_PURPOSE),
  356. $ExtContras::DBFLD_MONEY_SMACCRUAL => ubRouting::post($ExtContras::CTRL_MONEY_SUMACCRUAL),
  357. $ExtContras::DBFLD_MONEY_SMPAYMENT => ubRouting::post($ExtContras::CTRL_MONEY_SUMPAYMENT),
  358. $ExtContras::DBFLD_MONEY_PAYNOTES => ubRouting::post($ExtContras::CTRL_MONEY_PAYNOTES),
  359. $ExtContras::DBFLD_MONEY_INCOMING => $finopIncoming,
  360. $ExtContras::DBFLD_MONEY_OUTGOING => $finopOutgoing,
  361. $moneyDateField => $moneyDateValue
  362. );
  363. /*if (ubRouting::checkPost($ExtContras::ROUTE_ACTION_CREATE)) {
  364. $dataArray[$ExtContras::DBFLD_MONEY_DATE_PAYMENT] = $paymentDueDate;
  365. }*/
  366. // comes here from a hidden input of finops webform
  367. if (ubRouting::checkPost($ExtContras::MISC_MISSED_PAYMENT_PROCESSING)) {
  368. $missedPyamID = ubRouting::post($ExtContras::MISC_MISSED_PAYMENT_ID);
  369. if (!empty($missedPyamID)) {
  370. $ExtContras->updateMissedPaymentPayedDate($missedPyamID);
  371. $paymentDueDate = $ExtContras->getMissedPaymentPayDay($missedPyamID);
  372. $dataArray[$ExtContras::DBFLD_MONEY_DATE_PAYMENT] = $paymentDueDate;
  373. }
  374. }
  375. $showResult = $ExtContras->processCRUDs($dataArray, $ExtContras::TABLE_ECMONEY, $ExtContras::CTRL_MONEY_PURPOSE,
  376. 'finopsWebForm', false, array(),
  377. 'Financial operation', $prefillData, $createModality);
  378. die($showResult);
  379. }
  380. if (ubRouting::checkPost($ExtContras::ROUTE_MISSPAYMS_ACTS)) {
  381. $showResult = $ExtContras->processCRUDs(array(), $ExtContras::TABLE_ECMISSPAYMENTS);
  382. die($showResult);
  383. }
  384. } else {
  385. show_warning(__('This module is disabled'));
  386. }
  387. } else {
  388. show_error(__('Access denied'));
  389. }
  390. ?>