Bocian.php 40 KB

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