Bocian.php 40 KB

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