Bocian.php 41 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193
  1. <?php
  2. Lib::loadClass('RouteToolBase');
  3. Lib::loadClass('UI');
  4. Lib::loadClass('Response');
  5. // index.php?_route=UrlAction_BiAuditRaport - uruchamia defaultAction
  6. class Bocian extends RouteToolBase {
  7. public function defaultAction() {
  8. UI::gora();
  9. echo UI::h('script', ['src'=>"static/sweetalert2.min.js"]);
  10. echo UI::h('link', ['rel'=>"stylesheet", 'type'=>"text/css", 'href'=>"static/sweetalert2.min.css"]);
  11. Theme::top();
  12. //echo '<div id="smad-wrapper">'; // todo: sprawdzi czy można usunać
  13. echo '<div class="container-bi_audit_form_pracownicy_raport" style="display: none;"></div>';
  14. echo '<div class="container-bi_audit_form_kontrahenci_raport" style="display: none;"></div>';
  15. // echo '<div class="container-bi_audit_form_raport_data" style="display: none;"></div>';
  16. UI::inlineJS(__FILE__ . '.view.js', [
  17. 'URL_FETCH_KONTRAHENCI_POWIAZANIA' => $this->getLink('fetchEnergaRumKontrahenciPowiazaniaAjax'),
  18. 'URL_FETCH_TEST_KRS' => $this->getLink('fetchTestKrsAjax'),
  19. 'URL_FETCH_TEST_CEIDG' => $this->getLink('fetchTestCeidgAjax'),
  20. 'URL_FETCH_PRACOWNICY' => $this->getLink('fetchPracownicyAjax'),
  21. 'URL_FETCH_KONTRAHENCI' => $this->getLink('fetchKontrahenciAjax'),
  22. 'URL_CREATE_PRACOWNICY_GROUP' => $this->getLink('createPracownicyGroupAjax'),
  23. 'URL_CREATE_KONTRAHENCIS_GROUP' => $this->getLink('createKontrahenciGroupAjax'),
  24. 'URL_ADD_PRACOWNICY_TO_GROUP' => $this->getLink('addPracownicyToGroupAjax'),
  25. 'URL_ADD_KONTRAHENCI_TO_GROUP' => $this->getLink('addKontrahenciToGroupAjax'),
  26. 'URL_FETCH_GROUP_PRACOWNICY' => $this->getLink('fetchGroupPracownicyAjax'),
  27. 'URL_FETCH_GROUP_KONTRAHENCI' => $this->getLink('fetchGroupKontrahenciAjax'),
  28. 'URL_GENERATE_BI_AUDIT_RAPORT_AJAX' => $this->getLink('generateBiAuditRaportAjax'),
  29. 'DBG' => V::get('DBG', 0, $_GET),
  30. 'VIEW_KONTRAHENCI' => $this->defaultViewFormBiAudit([], 'KONTRAHENCI'),
  31. 'VIEW_PRACOWNICY' => $this->defaultViewFormBiAudit([], 'PRACOWNICY'),
  32. 'URL_PARSE_CSV_FILE_AJAX' => $this->getLink('parseCsvFileAjax'),
  33. 'URL_SAVE_FORM_CSV_FILE_AJAX' => $this->getLink('saveFormCsvFileAjax'),
  34. ]);
  35. echo '</div>'; // #smad-wrapper
  36. UI::dol();
  37. }
  38. /**
  39. * Funkcja ajax do odebrania danych z przesłanego pliku CSV do parsowania
  40. */
  41. public function parseCsvFileAjaxAction() {
  42. Response::sendTryCatchJson(array($this, 'parseCsvFileAjax')); // , $args = 'JSON_FROM_REQUEST_BODY');
  43. }
  44. /**
  45. * Funkcja parsuje dane wgrywanego plku csv
  46. */
  47. public function parseCsvFileAjax() {
  48. if (!file_exists($_FILES['file']['tmp_name'])) throw new Exception("Wybierz plik do przesłania.");
  49. $file = file($_FILES['file']['tmp_name']);
  50. // nagłowki csv
  51. $headCsv = array();
  52. // wiersze CSV(poza pierwszym)
  53. $arrayRows = array();
  54. $i = 0;
  55. $viewFormHtml = '<div id="smad-window-modal" style="overflow-x: scroll;"><form method="POST" >';
  56. foreach ($file as $line) {
  57. if ( $i == 0 ) {
  58. $headCsv = explode(';', $line);
  59. } else {
  60. $arrayRows = explode(';', $line);
  61. $viewFormHtml .= '<div style="margin: 10px 0"><span>'.$i.'. </span>';
  62. foreach ($arrayRows as $keyData => $rowData) {
  63. // sprawdzenie czy ustawiony naglówek - jeśli nie to wyświetl komunikat
  64. // if ($headCsv[$keyData]) throw new Exception("Brak nagłówka w kolumnie " . ($keyData + 1) . "w pliku CSV.");
  65. $viewFormHtml .= "<input type='text' name='item[$i]['".str_replace('"', '', $headCsv[$keyData])."']' value='".str_replace('"', '', $rowData )."' />";
  66. }
  67. $viewFormHtml .= '</div><div style="margin: 20px 0;"></div>';
  68. }
  69. $i++;
  70. }
  71. $viewFormHtml .= '</form></div>';
  72. //return $viewFormHtml;
  73. return [
  74. 'type' => 'success',
  75. 'msg' => 'OK',
  76. '__req_args' => $_REQUEST,
  77. '__args' => $args,
  78. 'body' => [
  79. 'view' => $viewFormHtml,
  80. ]
  81. ];
  82. // if (!isset($_FILES['fileData'])) throw new Exception("Błąd formularza ");
  83. }
  84. /**
  85. * Funkcja ajax do odebrania danych z przesłanego formularza z parsowanego CSV
  86. */
  87. public function saveFormCsvFileAjaxAction() {
  88. Response::sendTryCatchJson(array($this, 'saveFormCsvFileAjax'));
  89. }
  90. /**
  91. * Funkcja ajax do zapisania danych z przesłanego formularza z parsowanego CSV
  92. */
  93. public function saveFormCsvFileAjax() {
  94. //todo: dane do zapisania z formularza
  95. }
  96. public function fetchEnergaRumKontrahenciPowiazaniaAjaxAction() {
  97. Response::sendTryCatchJson(array($this, 'fetchEnergaRumKontrahenciPowiazaniaAjax')); // , $args = 'JSON_FROM_REQUEST_BODY');
  98. }
  99. public function fetchEnergaRumKontrahenciPowiazaniaAjax($args) {
  100. $id = V::get('ID', 26, $_REQUEST, 'int');
  101. $items = ACL::getAclByNamespace('default_db/BI_audit_ENERGA_RUM_KONTRAHENCI_POWIAZANIA/BI_audit_ENERGA_RUM_KONTRAHENCI_POWIAZANIA')->buildQuery([
  102. 'cols' => [ // TODO:? propertyName = []
  103. 'ID',
  104. 'A_ADM_COMPANY',
  105. 'L_APPOITMENT_USER',
  106. 'A_CLASSIFIED',
  107. 'A_STATUS',
  108. 'A_STATUS_INFO',
  109. 'BI_analiza_maxDepth',
  110. 'BI_analiza_minDepth',
  111. 'BI_analiza_onlyTargets',
  112. 'BI_analiza_reloadCache',
  113. 'FILE_STATUS',
  114. 'FILE_STATUS_info',
  115. 'L_APPOITMENT_USER',
  116. 'default_db__x3A__BI_audit_ENERGA_PRACOWNICY:BI_audit_ENERGA_PRACOWNICY',
  117. 'default_db__x3A__BI_audit_ENERGA_RUM_KONTRAHENCI:BI_audit_ENERGA_RUM_KONTRAHENCI',
  118. 'default_db__x3A__BI_audit_ENERGA_RUM_KONTRAHENCI_POWIAZANIA_row:BI_audit_ENERGA_RUM_KONTRAHENCI_POWIAZANIA_row',
  119. 'default_db__x3A__BI_audit_KW_requested_person:BI_audit_KW_requested_person',
  120. ],
  121. 'f_ID' => "{$id}",
  122. ])->getItems([
  123. 'limit' => 10
  124. ]);
  125. // $items = [
  126. // [ 'ID' => 1, 'L_APPOITMENT_INFO' => 'x', 'BI_analiza_depth' => 'a', 'FILE_STATUS' => 1, 'FILE_STATUS_info' => 'test1'],
  127. // [ 'ID' => 2, 'L_APPOITMENT_INFO' => 'y', 'BI_analiza_depth' => 'b', 'FILE_STATUS' => 0, 'FILE_STATUS_info' => 'test2'],
  128. // [ 'ID' => 3, 'L_APPOITMENT_INFO' => 'z', 'BI_analiza_depth' => 'c', 'FILE_STATUS' => 1, 'FILE_STATUS_info' => 'test3'],
  129. // ];
  130. return [
  131. 'type' => 'success',
  132. 'msg' => 'OK',
  133. '__req_args' => $_REQUEST,
  134. '__args' => $args,
  135. 'body' => [
  136. 'items' => $items,
  137. 'view' => $this->showPowiazaniaEnergaRumKontrahenciPowiazania($items),
  138. ]
  139. ];
  140. }
  141. public function showPowiazaniaEnergaRumKontrahenciPowiazania($items) {
  142. $view = '<form class="form-horizontal" method="post">
  143. <table class="table table-bordered table-hover table-striped" height=5>
  144. <thead>
  145. <tr style="">
  146. <td width=1><input type="checkbox" name="checkAll" id="checkAll" /></td>
  147. <td width=1>ID</td>
  148. <td>Adnotacje</td>
  149. <td>Głębokość analizy</td>
  150. <td>Status raportu</td>
  151. <td>Status raportu - informacje</td>
  152. </tr>
  153. </thead>
  154. <tbody>
  155. ';
  156. foreach ($items as $key => $row) {
  157. $view .= '<tr>
  158. <td><input type="checkbox" name="prID[]" value="'.$row['ID'].'" onClick="checkAll()"/></td>
  159. <td align="right">'.$row["ID"].'</td>
  160. <td align="right">'.$row["L_APPOITMENT_INFO"].'</td>
  161. <td align="right">'.$row["BI_analiza_depth"].'</td>
  162. <td align="right">'.$row["FILE_STATUS"].'</td>
  163. <td align="right">'.$row["FILE_STATUS_info"].'</td>';
  164. }
  165. $view .= '</tbody></table></form>';
  166. return $view;
  167. }
  168. public function fetchTestKrsAjaxAction() {
  169. Response::sendTryCatchJson(array($this, 'fetchTestKrsAjax')); // , $args = 'JSON_FROM_REQUEST_BODY');
  170. }
  171. public function fetchTestKrsAjax($args) {
  172. $id = V::get('ID', 1, $_REQUEST, 'int');
  173. $items = ACL::getAclByNamespace('default_db/BI_audit_KRS/BI_audit_KRS')->buildQuery([
  174. 'cols' => [ // TODO:? propertyName = []
  175. 'A_kod',
  176. 'A_kraj',
  177. 'A_miejscowosc',
  178. 'A_nrDomu',
  179. 'A_nrLokalu',
  180. 'A_poczta',
  181. 'A_ulica',
  182. 'ID',
  183. 'S_gmina',
  184. 'S_kraj',
  185. 'S_miejscowosc',
  186. 'S_powiat',
  187. 'S_wojewodztwo',
  188. 'dataDokumentu',
  189. 'default_db__x3A__BI_audit_KRS_company:BI_audit_KRS_company/ID',
  190. 'default_db__x3A__BI_audit_KRS_company:BI_audit_KRS_company/krs',
  191. 'default_db__x3A__BI_audit_KRS_company:BI_audit_KRS_company/nazwa',
  192. 'default_db__x3A__BI_audit_KRS_company:BI_audit_KRS_company/regon',
  193. 'default_db__x3A__BI_audit_KRS_person:BI_audit_KRS_person/ID',
  194. 'default_db__x3A__BI_audit_KRS_person:BI_audit_KRS_person/imiona',
  195. 'default_db__x3A__BI_audit_KRS_person:BI_audit_KRS_person/nazwisko',
  196. 'default_db__x3A__BI_audit_KRS_person:BI_audit_KRS_person/pesel',
  197. 'krs',
  198. 'nazwa',
  199. 'nip',
  200. 'regon',
  201. ],
  202. 'f_ID' => "{$id}",
  203. ])->getItems([
  204. 'limit' => 10
  205. ]);
  206. return [
  207. 'type' => 'success',
  208. 'msg' => 'KRS',
  209. '__req_args' => $_REQUEST,
  210. '__args' => $args,
  211. 'body' => [
  212. 'items' => $items,
  213. ]
  214. ];
  215. }
  216. public function fetchTestCeidgAjaxAction() {
  217. Response::sendTryCatchJson(array($this, 'fetchTestCeidgAjax')); // , $args = 'JSON_FROM_REQUEST_BODY');
  218. }
  219. public function fetchTestCeidgAjax($args) {
  220. $id = V::get('ID', 0, $_REQUEST, 'int');
  221. $items = ACL::getAclByNamespace('default_db/BI_audit_CEIDG/BI_audit_CEIDG')->buildQuery([
  222. 'cols' => [ // TODO:? propertyName = []
  223. 'ID',
  224. 'budynek',
  225. 'firma',
  226. 'gmina',
  227. 'identyfikatorWpisu',
  228. 'imie',
  229. 'kodPocztowy',
  230. 'kraj',
  231. 'lokal',
  232. 'miejscowosc',
  233. 'nazwisko',
  234. 'nip',
  235. 'poczta',
  236. 'powiat',
  237. 'regon',
  238. 'ulica',
  239. 'default_db__x3A__BI_audit_CEIDG_pelnomocnicy:BI_audit_CEIDG_pelnomocnicy/ID',
  240. 'default_db__x3A__BI_audit_CEIDG_pelnomocnicy:BI_audit_CEIDG_pelnomocnicy/budynek',
  241. 'default_db__x3A__BI_audit_CEIDG_pelnomocnicy:BI_audit_CEIDG_pelnomocnicy/gmina',
  242. 'default_db__x3A__BI_audit_CEIDG_pelnomocnicy:BI_audit_CEIDG_pelnomocnicy/kodPocztowy',
  243. 'default_db__x3A__BI_audit_CEIDG_pelnomocnicy:BI_audit_CEIDG_pelnomocnicy/lokal',
  244. 'default_db__x3A__BI_audit_CEIDG_pelnomocnicy:BI_audit_CEIDG_pelnomocnicy/miejscowosc',
  245. 'default_db__x3A__BI_audit_CEIDG_pelnomocnicy:BI_audit_CEIDG_pelnomocnicy/nazwa',
  246. 'default_db__x3A__BI_audit_CEIDG_pelnomocnicy:BI_audit_CEIDG_pelnomocnicy/nip',
  247. 'default_db__x3A__BI_audit_CEIDG_pelnomocnicy:BI_audit_CEIDG_pelnomocnicy/poczta',
  248. 'default_db__x3A__BI_audit_CEIDG_pelnomocnicy:BI_audit_CEIDG_pelnomocnicy/powiat',
  249. 'default_db__x3A__BI_audit_CEIDG_pelnomocnicy:BI_audit_CEIDG_pelnomocnicy/ulica',
  250. 'default_db__x3A__BI_audit_CEIDG_pelnomocnicy:BI_audit_CEIDG_pelnomocnicy/wojewodztwo',
  251. 'default_db__x3A__BI_audit_CEIDG_powiazania:BI_audit_CEIDG_powiazania/ID',
  252. 'default_db__x3A__BI_audit_CEIDG_powiazania:BI_audit_CEIDG_powiazania/nip',
  253. 'default_db__x3A__BI_audit_CEIDG_powiazania:BI_audit_CEIDG_powiazania/regon',
  254. ],
  255. // 'f_ID' => $id,
  256. ])->getItems([
  257. 'limit' => 10
  258. ]);
  259. return [
  260. 'type' => 'success',
  261. 'msg' => 'CEIDG',
  262. '__req_args' => $_REQUEST,
  263. '__args' => $args,
  264. 'body' => [
  265. 'items' => $items,
  266. ]
  267. ];
  268. }
  269. /**
  270. * KONTRAHENCI
  271. */
  272. public function fetchKontrahenciAjaxAction() {
  273. Response::sendTryCatchJson(array($this, 'fetchKontrahenciAjax'));
  274. }
  275. public function fetchKontrahenciAjax($args) {
  276. $idGroup = V::get('filterIdGroup', 0, $_REQUEST, 'int'); // TODO: dla filtrów "Wysokiego ryzyka" - przekazywany ID rekodu
  277. if ($idGroup < 0) $idGroup = 0;
  278. $limit = 5;
  279. $limitstart = V::get('limitstart', 0, $_REQUEST, 'int');
  280. if ($limitstart < 0) $limitstart = 0;
  281. $page = V::get('page', 0, $_REQUEST, 'int');
  282. $limitstart = ($page - 1) * $limit;
  283. $search = V::get('search', '', $_REQUEST);
  284. $searchParams = [];
  285. if (!empty($search)) {
  286. $ogcSearch = "*{$search}*"; // wildCard="*" -> mysql '%'
  287. $searchParams['ogc:Filter'] = '
  288. <ogc:Filter>
  289. <ogc:Or>
  290. <ogc:PropertyIsLike wildCard="" singleChar="%23" escapeChar="!">
  291. <ogc:PropertyName>NIP</ogc:PropertyName>
  292. <ogc:Literal>' . $ogcSearch . '</ogc:Literal>
  293. </ogc:PropertyIsLike>
  294. <ogc:PropertyIsLike wildCard="*" singleChar="%23" escapeChar="!">
  295. <ogc:PropertyName>Nazwa_grupy_kapitalowej</ogc:PropertyName>
  296. <ogc:Literal>' . $ogcSearch . '</ogc:Literal>
  297. </ogc:PropertyIsLike>
  298. <ogc:PropertyIsLike wildCard="*" singleChar="%23" escapeChar="!">
  299. <ogc:PropertyName>Pelna_nazwa_kontrahenta</ogc:PropertyName>
  300. <ogc:Literal>' . $ogcSearch . '</ogc:Literal>
  301. </ogc:PropertyIsLike>
  302. </ogc:Or>
  303. </ogc:Filter>
  304. ';
  305. }
  306. $backRefFilter = [];
  307. if ($idGroup > 0) {
  308. $backRefFilter['__backRef'] = [
  309. 'namespace' => 'default_db/BI_audit_ENERGA_PRACOWNICY_GRUPY/BI_audit_ENERGA_KONTRAHENCIS_GRUPY', // TODO: nowy rejetr na grupy / filty KONTRAHENCI
  310. 'primaryKey' => $idGroup,
  311. 'fieldName' => 'default_db__x3A__BI_audit_ENERGA_PRACOWNICY:BI_audit_ENERGA_KONTRAHENCIS',
  312. ];
  313. // TODO: Storage dodać obiekt xsd default_db/BI_audit_ENERGA_PRACOWNICY_GRUPY/BI_audit_ENERGA_KONTRAHENCI_GRUPY:
  314. // - ID
  315. // - ID_USER - id usera który stworzył grupę (tylko dla niego będzie widoczna)
  316. // - NAZWA - nazwa grupy
  317. // - 'default_db/BI_audit_ENERGA_PRACOWNICY/BI_audit_ENERGA_KONTRAHENCI' minOccurs="0" maxOccurs="unbounded"
  318. }
  319. $acl = ACL::getAclByNamespace('default_db/BI_audit_ENERGA_RUM_KONTRAHENCI/BI_audit_ENERGA_RUM_KONTRAHENCI');
  320. $query = $acl->buildQuery(array_merge([
  321. 'cols' => [ // TODO:? propertyName = []
  322. 'ID',
  323. 'Nazwa_grupy_kapitalowej',
  324. 'Pelna_nazwa_kontrahenta',
  325. 'Numer_kontrahenta',
  326. 'Skrocona_Nazwa_Kontrahenta',
  327. 'Typ_kontrahenta',
  328. 'NIP',
  329. 'KRS',
  330. 'REGON',
  331. 'PESEL',
  332. 'Forma_prawna_dzialalnosci',
  333. 'Ulica',
  334. 'Numer_budynku',
  335. 'Numer_mieszkania_lokalu',
  336. 'Miejscowosc',
  337. 'Kod_pocztowy',
  338. 'Kraj',
  339. 'Telefon',
  340. 'Fax',
  341. 'Mail',
  342. 'A_ADM_COMPANY',
  343. 'A_CLASSIFIED',
  344. 'A_STATUS',
  345. 'A_STATUS_INFO',
  346. 'Dodano',
  347. 'L_APPOITMENT_USER',
  348. 'Podmiot_dominujacy',
  349. 'Tytul_dokumentu',
  350. 'ownCompany',
  351. 'uwagi',
  352. ],
  353. //'f_ID' => $id,
  354. 'limit' => $limit,
  355. 'limitstart' => $limitstart, // offset
  356. ], $searchParams, $backRefFilter));
  357. $total = $query->getTotal();
  358. $items = $query->getItems();
  359. $pagination = array();
  360. $pagination['total_items'] = $total;
  361. $pagination['size'] = ceil($total/$limit); // pages size
  362. $pagination['current'] = $page;
  363. $pagination['limit'] = $limit;
  364. return [
  365. 'type' => 'success',
  366. 'msg' => 'showKontrajenci',
  367. '__req_args' => $_REQUEST,
  368. '__args' => $args,
  369. 'body' => [
  370. 'items' => $items,
  371. //'view' => $this->htmlViewFormBiAudit($items, 'KONTRAHENCI'),
  372. 'pagination' => $pagination
  373. ]
  374. ];
  375. }
  376. //
  377. // public function fetchKontrahenciAjaxOld($args) {
  378. // //$id = V::get('ID', 1, $_REQUEST, 'int');
  379. // $items = ACL::getAclByNamespace('default_db/BI_audit_ENERGA_RUM_KONTRAHENCI/BI_audit_ENERGA_RUM_KONTRAHENCI')->buildQuery([
  380. // 'cols' => [ // TODO:? propertyName = []
  381. // 'ID',
  382. // 'Nazwa_grupy_kapitalowej',
  383. // 'Pelna_nazwa_kontrahenta',
  384. // 'NIP',
  385. // 'KRS',
  386. // 'REGON',
  387. // 'Miejscowosc',
  388. // 'Kod_pocztowy',
  389. // 'Telefon'
  390. // ],
  391. // //'f_ID' => $id,
  392. // ])->getItems([
  393. // 'limit' => 10
  394. // ]);
  395. //
  396. // return [
  397. // 'type' => 'success',
  398. // 'msg' => 'showKontrahenci',
  399. // '__req_args' => $_REQUEST,
  400. // '__args' => $args,
  401. // 'body' => [
  402. // 'items' => $items,
  403. // 'view' => $this->htmlViewFormBiAudit($items, 'KONTRAHENCI')
  404. // ]
  405. // ];
  406. // }
  407. public function showTableKontrahenci($items) {
  408. $view = '<form class="form-horizontal" method="post">
  409. <table class="table table-bordered table-hover table-striped" height=5>
  410. <thead>
  411. <tr>
  412. <td width=1><input type="checkbox" name="checkAll" id="checkAll-KONTRAHENCI" /></td>
  413. <td width=1>ID</td>
  414. <td>Nazwa grupy kapitalowej</td>
  415. <td>Pelna nazwa kontrahenta</td>
  416. <td>Numer kontrahenta</td>
  417. <td>Skrócona nazwa kontrahenta</td>
  418. <td>Typ_kontrahenta</td>
  419. <td>NIP</td>
  420. <td>KRS</td>
  421. <td>Regon</td>
  422. <td>PESEL</td>
  423. <td>Forma prawna działalności</td>
  424. <td>Ulica</td>
  425. <td>Numer budynku</td>
  426. <td>Numer mieszkania lokalu</td>
  427. <td>Miejscowosc</td>
  428. <td>Kod pocztowy</td>
  429. <td>Kraj</td>
  430. <td>Telefon</td>
  431. <td>Fax</td>
  432. <td>Mail</td>
  433. <td>A_ADM_COMPANY</td>
  434. <td>A_CLASSIFIED</td>
  435. <td>A_STATUS</td>
  436. <td>A_STATUS_INFO</td>
  437. <td>Dodano</td>
  438. <td>L_APPOITMENT_USER</td>
  439. <td>Podmiot dominujacy</td>
  440. <td>Tytul dokumentu</td>
  441. <td>ownCompany</td>
  442. <td>uwagi</td>
  443. </tr>
  444. </thead>
  445. <tbody id="body-kontrahenci">
  446. </tbody></table>
  447. </form>
  448. ';
  449. return $view;
  450. }
  451. // tworzenie grupy kontrahentów
  452. public function createKontrahenciGroupAjaxAction() {
  453. Response::sendTryCatchJson(array($this, 'createKontrahenciGroupAjax'), $args = 'JSON_FROM_REQUEST_BODY'); // użyj tej wersji jeśli chcesz wysyłać z przelgądarki JSON-a post-em
  454. }
  455. public function createKontrahenciGroupAjax($args) {
  456. $nazwa = V::get('NAZWA', '', $args);
  457. // TODO: vlaidacja nazwy - sprawdzenie czy już nie występuje
  458. $idGroup = DB::getPDO()->insert('BI_audit_ENERGA_KONTRAHENCI_GRUPY', [
  459. 'A_RECORD_CREATE_AUTHOR' => User::getLogin(),
  460. 'A_RECORD_CREATE_DATE' => 'NOW()',
  461. 'NAZWA' => $nazwa,
  462. ]);
  463. return [
  464. 'msg' => "Utworzona grupę {$idGroup}",
  465. 'type' => "success",
  466. 'body' => [
  467. 'id' => $idGroup,
  468. ]
  469. ];
  470. }
  471. // Dodanie do grupy filtra kontrahentów
  472. public function addKontrahenciToGroupAjaxAction() {
  473. // Response::sendTryCatchJson(array($this, 'addKontrahenciToGroupAjax'), $args = 'JSON_FROM_REQUEST_BODY'); // użyj tej wersji jeśli chcesz wysyłać z przelgądarki JSON-a post-em
  474. Response::sendTryCatchJson(array($this, 'addKontrahenciToGroupAjax'));
  475. }
  476. public function addKontrahenciToGroupAjax($args) {
  477. $idGroup = V::get('idGroup', 0, $_REQUEST, 'int');
  478. $kontrahenciIds = V::get('kontrahenciIds', [], $_REQUEST, 'array');
  479. // validate
  480. if (!$idGroup) throw new Exception("Nie wybrano grupa");
  481. if (!$kontrahenciIds || count($kontrahenciIds) == 0 ) throw new Exception("Proszę wybrać kontrahentów");
  482. $group = ACL::getAclByNamespace('default_db/BI_audit_ENERGA_KONTRAHENCI_GRUPY/BI_audit_ENERGA_KONTRAHENCI_GRUPY')->buildQuery([
  483. 'cols' => [ // TODO:? propertyName = []
  484. 'ID',
  485. 'ID_USER',
  486. 'NAZWA',
  487. ],
  488. // 'f_ID_USER' => User::getID()
  489. ])->getItem($idGroup);
  490. if (!$group) throw new Exception("Grupa nie istnieje");
  491. if (User::getID() != $group['ID_USER']) throw new Exception("Brak uprawnień do grupy");
  492. // $refGrupyToPracownicy = ACL::getRefTable('obiekt główny', 'nazwa pola - powiązane rekordy');
  493. $refGrupyToKontrahenci = ACL::getRefTable('default_db/BI_audit_ENERGA_KONTRAHENCI_GRUPY/BI_audit_ENERGA_KONTRAHENCI_GRUPY',
  494. 'default_db__x3A__BI_audit_ENERGA_KONTRAHENCI:BI_audit_ENERGA_KONTRAHENCI');
  495. foreach ($kontrahenciIds as $kontrahentIds) {
  496. DB::getPDO()->insert($refGrupyToKontrahenci, ['PRIMARY_KEY' => $idGroup, 'REMOTE_PRIMARY_KEY' => $kontrahentIds]);
  497. }
  498. return [
  499. 'msg' => "Powiązano kontrahentów z grupą {$idGroup}",
  500. 'type' => "success",
  501. ];
  502. }
  503. public function fetchGroupKontrahenciAjaxAction() {
  504. Response::sendTryCatchJson(array($this, 'fetchGroupKontrahenciAjax'));
  505. }
  506. public function fetchGroupKontrahenciAjax() {
  507. // TODO: odkomentować jak zostanie dodana tabela default_db/BI_audit_ENERGA_KONTRAHENCI_GRUPY/BI_audit_ENERGA_KONTRAHENCI_GRUPY
  508. /*$group = ACL::getAclByNamespace('default_db/BI_audit_ENERGA_KONTRAHENCI_GRUPY/BI_audit_ENERGA_KONTRAHENCI_GRUPY')->buildQuery([
  509. 'cols' => [ // TODO:? propertyName = []
  510. 'ID',
  511. 'ID_USER',
  512. 'NAZWA',
  513. ],
  514. 'f_ID_USER' => User::getID()
  515. ])->getItem($idGroup);
  516. if (!$group) throw new Exception("Grupa nie istnieje");
  517. if (User::getID() != $group['ID_USER']) throw new Exception("Brak uprawnień do grupy");
  518. $itemsKontrahenci = $query->getItems();
  519. $arrayGroupKontrahenci = array();
  520. foreach ($itemsKontrahenci as $key => $value) {
  521. $arrayGroupKontrahenci[$value['ID']] = $value['NAZWA'];
  522. }
  523. */
  524. //TODO: USUNAĆ listę grup wpisane na sztywno
  525. $arrayGroupKontrahenci = array();
  526. $arrayGroupKontrahenci[0]["ID"] = 1;
  527. $arrayGroupKontrahenci[0]["NAZWA"] = "Grupa 1";
  528. $arrayGroupKontrahenci[1]["ID"] = 2;
  529. $arrayGroupKontrahenci[1]["NAZWA"] = "Grupa 2";
  530. $arrayGroupKontrahenci[2]["ID"] = 3;
  531. $arrayGroupKontrahenci[2]["NAZWA"] = "Grupa 3";
  532. $arrayGroupKontrahenci[3]["ID"] = 4;
  533. $arrayGroupKontrahenci[3]["NAZWA"] = "Grupa 4";
  534. $arrayGroupKontrahenci[4]["ID"] = 5;
  535. $arrayGroupKontrahenci[4]["NAZWA"] = "Grupa 5";
  536. $arrayGroupKontrahenci[5]["ID"] = 6;
  537. $arrayGroupKontrahenci[5]["NAZWA"] = "Grupa 6";
  538. $arrayGroupKontrahenci[6]["ID"] = 7;
  539. $arrayGroupKontrahenci[6]["NAZWA"] = "Grupa 7";
  540. $arrayGroupKontrahenci[7]["ID"] = 8;
  541. $arrayGroupKontrahenci[7]["NAZWA"] = "Grupa 8";
  542. $arrayGroupKontrahenci[8]["ID"] = 9;
  543. $arrayGroupKontrahenci[8]["NAZWA"] = "Grupa 9";
  544. $arrayGroupKontrahenci[9]["ID"] = 10;
  545. $arrayGroupKontrahenci[9]["NAZWA"] = "Grupa 10";
  546. $arrayGroupKontrahenci[9]["ID"] = 11;
  547. $arrayGroupKontrahenci[9]["NAZWA"] = "Grupa 11";
  548. return [
  549. 'type' => 'success',
  550. 'msg' => 'fetchKontrahenciToGroup',
  551. '__req_args' => $_REQUEST,
  552. '__args' => $args,
  553. 'body' => [
  554. 'itemsGroupKontrahenci' => $arrayGroupKontrahenci
  555. ]
  556. ];
  557. }
  558. /*
  559. * PRACOWNICY
  560. */
  561. public function fetchPracownicyAjaxAction() {
  562. // sleep(2);
  563. Response::sendTryCatchJson(array($this, 'fetchPracownicyAjax'));
  564. }
  565. public function fetchPracownicyAjax($args) {
  566. $idGroup = V::get('filterIdGroup', 0, $_REQUEST, 'int'); // TODO: dla filtrów "Wysokiego ryzyka" - przekazywany ID rekodu
  567. if ($idGroup < 0) $idGroup = 0;
  568. $limit = 2;
  569. $limitstart = V::get('limitstart', 0, $_REQUEST, 'int');
  570. if ($limitstart < 0) $limitstart = 0;
  571. $page = V::get('page', 0, $_REQUEST, 'int');
  572. $limitstart = ($page - 1) * $limit;
  573. $search = V::get('search', '', $_REQUEST);
  574. $searchParams = [];
  575. if (!empty($search)) {
  576. $ogcSearch = "*{$search}*"; // wildCard="*" -> mysql '%'
  577. $searchParams['ogc:Filter'] = '
  578. <ogc:Filter>
  579. <ogc:Or>
  580. <ogc:PropertyIsLike wildCard="" singleChar="%23" escapeChar="!">
  581. <ogc:PropertyName>nip</ogc:PropertyName>
  582. <ogc:Literal>' . $ogcSearch . '</ogc:Literal>
  583. </ogc:PropertyIsLike>
  584. <ogc:PropertyIsLike wildCard="*" singleChar="%23" escapeChar="!">
  585. <ogc:PropertyName>nazwisko</ogc:PropertyName>
  586. <ogc:Literal>' . $ogcSearch . '</ogc:Literal>
  587. </ogc:PropertyIsLike>
  588. </ogc:Or>
  589. </ogc:Filter>
  590. ';
  591. }
  592. $backRefFilter = [];
  593. if ($idGroup > 0) {
  594. $backRefFilter['__backRef'] = [
  595. 'namespace' => 'default_db/BI_audit_ENERGA_PRACOWNICY_GRUPY/BI_audit_ENERGA_PRACOWNICY_GRUPY', // TODO: nowy rejetr na grupy / filty pracowników
  596. 'primaryKey' => $idGroup,
  597. 'fieldName' => 'default_db__x3A__BI_audit_ENERGA_PRACOWNICY:BI_audit_ENERGA_PRACOWNICY',
  598. ];
  599. // TODO: Storage dodać obiekt xsd default_db/BI_audit_ENERGA_PRACOWNICY_GRUPY/BI_audit_ENERGA_PRACOWNICY_GRUPY:
  600. // - ID
  601. // - ID_USER - id usera który stworzył grupę (tylko dla niego będzie widoczna)
  602. // - NAZWA - nazwa grupy
  603. // - 'default_db/BI_audit_ENERGA_PRACOWNICY/BI_audit_ENERGA_PRACOWNICY' minOccurs="0" maxOccurs="unbounded"
  604. }
  605. $acl = ACL::getAclByNamespace('default_db/BI_audit_ENERGA_PRACOWNICY/BI_audit_ENERGA_PRACOWNICY');
  606. $query = $acl->buildQuery(array_merge([
  607. 'cols' => [ // TODO:? propertyName = []
  608. 'ID',
  609. 'imiona',
  610. 'nazwisko',
  611. 'nip',
  612. 'pesel',
  613. 'regon',
  614. 'source',
  615. 'A_ADM_COMPANY',
  616. 'A_CLASSIFIED',
  617. 'A_STATUS',
  618. 'A_STATUS_INFO',
  619. 'L_APPOITMENT_USER',
  620. 'default_db__x3A__BI_audit_ENERGA_PRACOWNICY_adresy:BI_audit_ENERGA_PRACOWNICY_adresy/*'
  621. ],
  622. //'f_ID' => $id,
  623. 'limit' => $limit,
  624. 'limitstart' => $limitstart, // offset
  625. // 'order_by' => 'ID', // sortowanie po kolumnie
  626. // 'order_dir' => 'DESC', // kierunek sortowania
  627. // 'f_nip' = "=12345", // szukamy dokładnie tej wartości - mysql: where nip = "12345"
  628. // 'f_nip' = "12345", // szukamy dokładnie tej wartości - mysql: where nip like "%12345%"
  629. // 'f_nip' = "12345%", // szukamy dokładnie tej wartości - mysql: where nip like "12345%"
  630. // 'f_ID' = "=12345", // szukamy dokładnie tej wartości - mysql: where ID = "12345"
  631. ], $searchParams, $backRefFilter));
  632. $total = $query->getTotal();
  633. $items = $query->getItems();
  634. $pagination = array();
  635. $pagination['total_items'] = $total;
  636. $pagination['size'] = ceil($total/$limit); // pages size
  637. $pagination['current'] = $page;
  638. $pagination['limit'] = $limit;
  639. // { // tworzenie własnego zapytanie mysql
  640. // $rootTableName = $acl->getRootTableName();
  641. // DB::getPDO()->fetchAll("
  642. // select t.*
  643. // from {$rootTableName} t
  644. // where t.ID in (
  645. // select x.ID
  646. // from ... x
  647. // where
  648. // )
  649. // ");
  650. // }
  651. return [
  652. 'type' => 'success',
  653. 'msg' => 'showPracownicy',
  654. '__req_args' => $_REQUEST,
  655. '__args' => $args,
  656. 'body' => [
  657. 'items' => $items,
  658. //'view' => $this->htmlViewFormBiAudit($items, 'PRACOWNICY'),
  659. 'pagination' => $pagination
  660. ]
  661. ];
  662. }
  663. public function showTablePracownicy() {
  664. $view = '<form class="form-horizontal" method="post">
  665. <table class="table table-responsive table-bordered table-hover table-striped" height=5>
  666. <thead>
  667. <tr>
  668. <td width=1><input type="checkbox" name="checkAll" id="checkAll-PRACOWNICY" /></td>
  669. <td width=1>ID</td>
  670. <td>Imię/Imiona</td>
  671. <td>Nazwisko</td>
  672. <td>NIP</td>
  673. <td>Pesel</td>
  674. <td>Regon</td>
  675. <td>source</td>
  676. <td>A_ADM_COMPANY</td>
  677. <td>A_CLASSIFIED</td>
  678. <td>A_STATUS</td>
  679. <td>A_STATUS_INFO</td>
  680. <td>L_APPOITMENT_USER</td>
  681. <td>Adresy</td>
  682. </tr>
  683. </thead>
  684. <tbody id="body-pracownicy">
  685. </tbody></table>
  686. </form>';
  687. return $view;
  688. }
  689. // tworzenie grupy pracowników
  690. public function createPracownicyGroupAjaxAction() {
  691. Response::sendTryCatchJson(array($this, 'createPracownicyGroupAjax'), $args = 'JSON_FROM_REQUEST_BODY'); // użyj tej wersji jeśli chcesz wysyłać z przelgądarki JSON-a post-em
  692. // Response::sendTryCatchJson(array($this, 'createPracownicyGroupAjax'));
  693. }
  694. public function createPracownicyGroupAjax($args) {
  695. $nazwa = V::get('NAZWA', '', $args);
  696. // TODO: vlaidacja nazwy - sprawdzenie czy już nie występuje
  697. // validate
  698. if (!$nazwa) throw new Exception("Nie wybrano grupa");
  699. if (!$kontrahenciIds || count($kontrahenciIds) == 0 ) throw new Exception("Proszę wybrać kontrahentów");
  700. $idGroup = DB::getPDO()->insert('BI_audit_ENERGA_PRACOWNICY_GRUPY', [
  701. 'A_RECORD_CREATE_AUTHOR' => User::getLogin(),
  702. 'A_RECORD_CREATE_DATE' => 'NOW()',
  703. // 'A_STATUS' => 'WAITING', // jeśli trzeba to ustawić
  704. 'NAZWA' => $nazwa,
  705. ]);
  706. // DB::getPDO()->insert('BI_audit_ENERGA_PRACOWNICY_GRUPY_HIST', [
  707. // 'A_RECORD_CREATE_AUTHOR' => User::getLogin(),
  708. // 'A_RECORD_CREATE_DATE' => 'NOW()',
  709. // 'ID_USERS2' => $idRaport,
  710. // // 'A_STATUS' => 'WAITING', // jeśli trzeba to ustawić
  711. // 'NAZWA' => $nazwa,
  712. // ]);
  713. return [
  714. 'msg' => "Utworzona grupę {$idGroup}",
  715. 'type' => "success",
  716. 'body' => [
  717. 'id' => $idGroup,
  718. ]
  719. ];
  720. }
  721. // Dodanie do grupy filtra pracowników
  722. public function addPracownicyToGroupAjaxAction() {
  723. // Response::sendTryCatchJson(array($this, 'addPracownicyToGroupAjax'), $args = 'JSON_FROM_REQUEST_BODY'); // użyj tej wersji jeśli chcesz wysyłać z przelgądarki JSON-a post-em
  724. Response::sendTryCatchJson(array($this, 'addPracownicyToGroupAjax'));
  725. }
  726. public function addPracownicyToGroupAjax($args) {
  727. $idGroup = V::get('idGroup', 0, $_REQUEST, 'int');
  728. $pracownicyIds = V::get('pracownicyIds', [], $_REQUEST, 'array');
  729. // validate
  730. if (!$nazwa) throw new Exception("Nie wybrano grupa");
  731. if (!$pracownicyIds || count($pracownicyIds) == 0 ) throw new Exception("Proszę wybrać pracowników");
  732. // TODO: SPRWADZENIE CZY NIE DODANOU JUZ PRACOWNIKAS
  733. // default_db/BI_audit_ENERGA_PRACOWNICY_GRUPY/BI_audit_ENERGA_PRACOWNICY_GRUPY
  734. // default_db/BI_audit_ENERGA_PRACOWNICY/BI_audit_ENERGA_PRACOWNICY
  735. $group = ACL::getAclByNamespace('default_db/BI_audit_ENERGA_PRACOWNICY_GRUPY/BI_audit_ENERGA_PRACOWNICY_GRUPY')->buildQuery([
  736. 'cols' => [ // TODO:? propertyName = []
  737. 'ID',
  738. 'ID_USER',
  739. 'NAZWA',
  740. ],
  741. // 'f_ID_USER' => User::getID()
  742. ])->getItem($idGroup);
  743. if (!$group) throw new Exception("Grupa nie istnieje");
  744. if (User::getID() != $group['ID_USER']) throw new Exception("Brak uprawnień do grupy");
  745. // $refGrupyToPracownicy = ACL::getRefTable('obiekt główny', 'nazwa pola - powiązane rekordy');
  746. $refGrupyToPracownicy = ACL::getRefTable('default_db/BI_audit_ENERGA_PRACOWNICY_GRUPY/BI_audit_ENERGA_PRACOWNICY_GRUPY',
  747. 'default_db__x3A__BI_audit_ENERGA_PRACOWNICY:BI_audit_ENERGA_PRACOWNICY');
  748. foreach ($pracownicyIds as $idPracownik) {
  749. DB::getPDO()->insert($refGrupyToPracownicy, ['PRIMARY_KEY' => $idGroup, 'REMOTE_PRIMARY_KEY' => $idPracownik]);
  750. }
  751. return [
  752. 'msg' => "Powiązano pracowników z grupą {$idGroup}",
  753. 'type' => "success",
  754. ];
  755. }
  756. public function fetchGroupPracownicyAjaxAction() {
  757. Response::sendTryCatchJson(array($this, 'fetchGroupPracownicyAjax'));
  758. }
  759. public function fetchGroupPracownicyAjax() {
  760. // TODO: odkomentować jak zostanie dodana tabela default_db/BI_audit_ENERGA_PRACOWNICY_GRUPY/BI_audit_ENERGA_PRACOWNICY_GRUPY
  761. /*$group = ACL::getAclByNamespace('default_db/BI_audit_ENERGA_PRACOWNICY_GRUPY/BI_audit_ENERGA_PRACOWNICY_GRUPY')->buildQuery([
  762. 'cols' => [ // TODO:? propertyName = []
  763. 'ID',
  764. 'ID_USER',
  765. 'NAZWA',
  766. ],
  767. 'f_ID_USER' => User::getID()
  768. ])->getItem($idGroup);
  769. if (!$group) throw new Exception("Grupa nie istnieje");
  770. if (User::getID() != $group['ID_USER']) throw new Exception("Brak uprawnień do grupy");
  771. $items = $query->getItems();
  772. $arrayGroupPracownicy = array();
  773. foreach ($items as $key => $value) {
  774. $arrayGroupPracownicy[$value['ID']] = $value['NAZWA'];
  775. }
  776. */
  777. //TODO: USUNAĆ listę grup wpisane na sztywno
  778. $arrayGroupPracownicy = array();
  779. $arrayGroupPracownicy[0]["ID"] = 1;
  780. $arrayGroupPracownicy[0]["NAZWA"] = "Grupa 1";
  781. $arrayGroupPracownicy[1]["ID"] = 2;
  782. $arrayGroupPracownicy[1]["NAZWA"] = "Grupa 2";
  783. $arrayGroupPracownicy[2]["ID"] = 3;
  784. $arrayGroupPracownicy[2]["NAZWA"] = "Grupa 3";
  785. $arrayGroupPracownicy[3]["ID"] = 4;
  786. $arrayGroupPracownicy[3]["NAZWA"] = "Grupa 4";
  787. $arrayGroupPracownicy[4]["ID"] = 5;
  788. $arrayGroupPracownicy[4]["NAZWA"] = "Grupa 5";
  789. return [
  790. 'type' => 'success',
  791. 'msg' => 'fetchGroupPracownicyAjax',
  792. '__req_args' => $_REQUEST,
  793. '__args' => $args,
  794. 'body' => [
  795. 'itmesGroupPracownicy' => $arrayGroupPracownicy
  796. ]
  797. ];
  798. }
  799. // link do ackji w php: $saveFormUrl = $this->getLink('saveRaportAjax');
  800. // przekazać link do JavaScript i tam:
  801. // window.fetch('{$saveFormUrl}', { ... }).then(...) - dokumentacja: https://github.com/github/fetch
  802. public function generateBiAuditRaportAjaxAction() {
  803. //Response::sendTryCatchJson(array($this, 'saveRaportAjax'), $args = 'JSON_FROM_REQUEST_BODY'); // użyj tej wersji jeśli chcesz wysyłać z przelgądarki JSON-a post-em
  804. Response::sendTryCatchJson(array($this, 'generateBiAuditRaportAjax'), $args = 'JSON_FROM_REQUEST_BODY');
  805. //Response::sendTryCatchJson(array($this, 'generateBiAuditRaportAjax'));
  806. }
  807. public function generateBiAuditRaportAjax($args) {
  808. // głebokość powiazan
  809. $depthValue = V::get('depthValue', '', $args);
  810. if (!$depthValue) {
  811. throw new Exception("Nie podano wartości dla głębokości powiązań");
  812. }
  813. // Tworzenie relacji Raport do Pracownicy
  814. $pracownicyIds = []; // array z nr ID na podstawie wysłanego formularza
  815. $pracownicyIds = V::get('pracownicyIds', '', $args);
  816. // walidacja id pracowników
  817. if (!$pracownicyIds) {
  818. throw new Exception("Nie wybrano pracowników");
  819. }
  820. $kontrahenciIds = []; // array z nr ID na podstawie wysłanego formularza
  821. $kontrahenciIds = V::get('kontrahenciIds', '', $args);
  822. // walidacja id kontrahetów
  823. if (!$kontrahenciIds) {
  824. throw new Exception("Nie wybrano kontrahentów");
  825. }
  826. // Tworzenie rekrodu w bazie - Raport -
  827. $idRaport = DB::getPDO()->insert('BI_audit_ENERGA_RUM_KONTRAHENCI_POWIAZANIA', [
  828. 'A_RECORD_CREATE_AUTHOR' => User::getLogin(),
  829. 'A_RECORD_CREATE_DATE' => 'NOW()',
  830. 'A_STATUS' => 'WAITING', // TODO: czy trzeba to ustawić (pytanie do Mariusza)
  831. 'FILE_STATUS' => "TO_GENERATE",
  832. 'BI_analiza_minDepth' => 1,
  833. 'BI_analiza_maxDepth' => $depthValue
  834. ]);
  835. // Tworzenie relacji Raport do Pracownicy
  836. $refPowiazaniaToPracownicy = ACL::getRefTable('default_db/BI_audit_ENERGA_RUM_KONTRAHENCI_POWIAZANIA/BI_audit_ENERGA_RUM_KONTRAHENCI_POWIAZANIA',
  837. 'default_db__x3A__BI_audit_ENERGA_PRACOWNICY:BI_audit_ENERGA_PRACOWNICY');
  838. foreach ($pracownicyIds as $idPracownik) {
  839. DB::getPDO()->insert($refPowiazaniaToPracownicy, ['PRIMARY_KEY' => $idRaport, 'REMOTE_PRIMARY_KEY' => $idPracownik]);
  840. }
  841. // Tworzenie relacji Raport do Kontrahenci - analogicznie jak wyżej
  842. $refPowiazaniaToKontrahenci = ACL::getRefTable('default_db/BI_audit_ENERGA_RUM_KONTRAHENCI_POWIAZANIA/BI_audit_ENERGA_RUM_KONTRAHENCI_POWIAZANIA',
  843. 'default_db__x3A__BI_audit_ENERGA_RUM_KONTRAHENCI:BI_audit_ENERGA_RUM_KONTRAHENCI');
  844. foreach ($kontrahenciIds as $idKontrahent) {
  845. DB::getPDO()->insert($refPowiazaniaToKontrahenci, ['PRIMARY_KEY' => $idRaport, 'REMOTE_PRIMARY_KEY' => $idKontrahent ]);
  846. }
  847. // ...
  848. return [
  849. 'msg' => "Zadanie do wygnerowania raportu zostało zapisane.",
  850. 'type' => "success",
  851. 'body' => [
  852. 'id' => $idRaport,
  853. ]
  854. ];
  855. }
  856. /**
  857. * Widok formularza dodawania pracowników i kontrahentów
  858. */
  859. public function defaultViewFormBiAudit($items, $type) {
  860. $activeFormSteps = '';
  861. switch($type) {
  862. case 'KONTRAHENCI':
  863. $activeFormStepsKontrahent = 'complete';
  864. $titleHeader = 'KONTRAHENCI';
  865. $groupFilterList = '
  866. <div class="menu-item">
  867. <ul class="padding-0">
  868. <li><a href="#" title="STWÓRZ GRUPĘ" class="btn btn-default" onClick="createGroupKontrahenci(event)" data-color-noactive="">+ STWÓRZ GRUPĘ</a></li>
  869. </ul>
  870. </div>
  871. <div id="group-kontrahenci" class="btn-group">
  872. <button class="btn btn-default active" title="Wszyscy" data-group-filter="0">Wszyscy</button>
  873. </div>';
  874. $formAddNewData ='
  875. <li><a title="IMPORT KONTRAHENCI" onClick="showViewUploadFile(event, \'Import kontrahentów\' )" class="btn btn-info">IMPORT KONTRAHENCI</a></li>
  876. <!--<li><a href="#" title="DODAJ KONTRAHENCI" class="btn btn-info">+ DODAJ KONTRAHENCI</a></li>-->'; //todo: dodać obsługe doddawania kontrahentow
  877. $showButtonNextStep = '<button type="button" class="btn btn-primary" onClick="generateBiAuditRaport(event)" id="button-generate-reaport">SZUKAJ POWIĄZAŃ</button>';
  878. $pagination_form = '<div id="pagination-kontrahenci"></div>';
  879. break;
  880. case 'PRACOWNICY':
  881. $titleHeader = 'PRACOWNICY';
  882. $groupFilterList = '
  883. <div class="menu-item">
  884. <ul class="padding-0">
  885. <li><a href="#" title="STWÓRZ GRUPĘ" class="btn btn-default" onClick="createGroupPracownicy(event)" >+ STWÓRZ GRUPĘ</a></li>
  886. </ul>
  887. </div>
  888. <div id="group-pracownicy" class="btn-group">
  889. <button class="btn btn-default active" title="Wszyscy" data-group-filter="0">Wszyscy</button>
  890. </div>';
  891. $formAddNewData ='
  892. <li><a href="#" title="IMPORT PRACOWNIKÓW" class="btn btn-info">IMPORT PRACOWNIKÓW</a></li>
  893. <!--<li><a href="#" title="DODAJ PRACOWNIKÓW" class="btn btn-info" >+ DODAJ PRACOWNIKÓW</a></li>-->'; //todo: dodać obsługe doddawania pracownikow
  894. $showButtonNextStep = '<a href="index.php?_route=UrlAction_Bocian#KONTRAHENCI" title="DODAJ DO ANALIZY" class="btn btn-primary">DODAJ DO ANALIZY</a>';
  895. $pagination_form = '<div id="pagination-pracownicy"></div>';
  896. break;
  897. }
  898. $view = '
  899. <!-- start:employees-section-->
  900. <div id="smad-employees-section" class="smad-form-' . $type . '" >
  901. <div class="container-fluid">
  902. <div>
  903. <div class="padding-lr-0">
  904. <div id="smad-menu-section">
  905. <div class="col-sm-12 col-md-6 padding-lr-0">
  906. <div class="menu-items">
  907. <div class="smad-heder-title menu-item"><span class="smad-line-red">|</span> ' . $titleHeader . ' </div>
  908. </div>
  909. </div>
  910. <div class="col-sm-12 col-md-6 padding-lr-0">
  911. <div class="form-steps">
  912. <!-- start:form steps wizard -->
  913. <div class="row smad-wizard" style="border-bottom:0;">
  914. <div class="col-xs-4 col-md-4 smad-wizard-step complete"><!-- complited line -->
  915. <div class="text-center smad-wizard-stepnum">&nbsp;</div>
  916. <div class="progress"><div class="progress-bar"></div></div>
  917. <a href="index.php?_route=UrlAction_Bocian#PRACOWNICY" class="smad-wizard-dot"></a>
  918. <div class="smad-wizard-info complete text-center">
  919. <div class="step-item">Krok 1</div>
  920. <div class="step-title ">PRACOWNICY</div>
  921. </div>
  922. </div>
  923. <div class="col-xs-4 col-md-4 smad-wizard-step ' . $activeFormStepsKontrahent . ' ">
  924. <div class="text-center smad-wizard-stepnum">&nbsp;</div>
  925. <div class="progress"><div class="progress-bar"></div></div>
  926. <a href="index.php?_route=UrlAction_Bocian#KONTRAHENCI" class="smad-wizard-dot"></a>
  927. <div class="smad-wizard-info text-center">
  928. <div class="step-item">Krok 2</div>
  929. <div class="step-title ">KONTRAHENCI</div>
  930. </div>
  931. </div>
  932. <div class="col-xs-4 col-md-4 smad-wizard-step ">
  933. <div class="text-center smad-wizard-stepnum">&nbsp;</div>
  934. <div class="progress"><div class="progress-bar"></div></div>
  935. <a href="#" class="smad-wizard-dot"></a>
  936. <div class="smad-wizard-info text-center">
  937. <div class="step-item">Krok 3</div>
  938. <div class="step-title ">SZUKANIE POWIĄZAŃ</div>
  939. </div>
  940. </div>
  941. </div>
  942. <!-- end:form steps wizard -->
  943. </div>
  944. </div>
  945. </div>
  946. </div>
  947. </div>
  948. </div>
  949. <div class="container-fluid">
  950. <div class=" padding-lr-0">
  951. <div class="smad-divider"></div>
  952. </div>
  953. </div>
  954. <!-- start:filters -->
  955. <div class="container-fluid">
  956. <div class="row">
  957. <div>
  958. <div class="smad-employees-form-section" class="border-top-grey">
  959. <div class="col-md-9 smad-border-col">
  960. <div class="menu-items">
  961. '.$groupFilterList.'
  962. </div>
  963. </div>
  964. <div class="col-md-3">
  965. <div class="form-input">
  966. <div class="form-item col-md-6 smad-heder-title">głębokość powiązań:</div>
  967. <div class="form-item col-md-6">
  968. <input type="text" class="form-control smad-depth" placeholder="1-16" value="" />
  969. </div>
  970. </div>
  971. </div>
  972. </div>
  973. </div>
  974. </div>
  975. </div>
  976. <!-- end:filters -->
  977. <!-- start:list employees -->
  978. <div class="container-fluid">
  979. <div class="padding-0 smad-employees-list-head">
  980. <div class="col-md-6">
  981. <header>
  982. <h2 class="title">Wszyscy</h2>
  983. </header>
  984. <div class="desc">
  985. Lorem Ipsum jest tekstem stosowanym jako przykładowy wypełniacz w przemyśle poligraficznym.
  986. </div>
  987. </div>
  988. <div class="col-md-6">
  989. <div class="menu-items">
  990. <div class="menu-item">
  991. <ul class="padding-0">
  992. '.$formAddNewData.'
  993. </ul>
  994. </div>
  995. </div>
  996. </div>
  997. </div>
  998. </div>
  999. <div class="container-fluid">
  1000. <div class="table-responsive padding-0" id="smad-table-' . $type . '">
  1001. ' . $this->showListDataByType($items, $type) . '
  1002. </div>
  1003. </div>
  1004. <!-- end:list employees -->
  1005. <!-- start:list paginations employees -->
  1006. <div class="container-fluid ">
  1007. <div>
  1008. '. $pagination_form .'
  1009. </div>
  1010. </div>
  1011. <!-- end:list paginations employees -->
  1012. <!-- start:bottom buttons -->
  1013. <div class="container-fluid smad-employees-bottom-navigation">
  1014. <div class="padding-0">
  1015. <div class="col-lg-6 ">
  1016. <a href="#" title="PRZENIEŚ DO GRUPY" onClick="addPracownikToGroup(event)" class="btn btn-info">PRZENIEŚ DO GRUPY</a>
  1017. </div>
  1018. <div class="col-lg-6 text-right">
  1019. ' . $showButtonNextStep . '
  1020. </div>
  1021. </div>
  1022. </div>
  1023. <!-- end:bottom buttons -->
  1024. </div>
  1025. <!-- start:employees-section -->
  1026. ';
  1027. return $view;
  1028. }
  1029. public function showListDataByType($items, $type='PRACOWNICY') {
  1030. switch ($type) {
  1031. case 'PRACOWNICY':
  1032. return $this->showTablePracownicy();
  1033. break;
  1034. case 'KONTRAHENCI':
  1035. return $this->showTableKontrahenci($items);
  1036. break;
  1037. }
  1038. }
  1039. }