Bocian.php 57 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455
  1. <?php
  2. Lib::loadClass('RouteToolBase');
  3. Lib::loadClass('UI');
  4. Lib::loadClass('Response');
  5. Lib::loadClass('Request');
  6. // index.php?_route=UrlAction_BiAuditRaport - uruchamia defaultAction
  7. class RouteTool_Bocian extends RouteToolBase {
  8. public function defaultAction() {
  9. UI::gora();
  10. echo UI::h('script', ['src'=>"static/sweetalert2.min.js"]);
  11. echo UI::h('link', ['rel'=>"stylesheet", 'type'=>"text/css", 'href'=>"static/sweetalert2.min.css"]);
  12. Theme::top();
  13. //echo '<div id="smad-wrapper">'; // todo: sprawdzi czy można usunać
  14. echo '<div class="container-bi_audit_form_pracownicy_raport" style="display: none;"></div>';
  15. echo '<div class="container-bi_audit_form_kontrahenci_raport" style="display: none;"></div>';
  16. // echo '<div class="container-bi_audit_form_raport_data" style="display: none;"></div>';
  17. UI::inlineJS(__FILE__ . '.view.js', [
  18. 'BASE_URLS' => Request::getPathUri(),
  19. 'URL_FETCH_KONTRAHENCI_POWIAZANIA' => $this->getLink('fetchEnergaRumKontrahenciPowiazaniaAjax'),
  20. 'URL_FETCH_TEST_KRS' => $this->getLink('fetchTestKrsAjax'),
  21. 'URL_FETCH_TEST_CEIDG' => $this->getLink('fetchTestCeidgAjax'),
  22. 'URL_FETCH_PRACOWNICY' => $this->getLink('fetchPracownicyAjax'),
  23. 'URL_FETCH_PRACOWNICY_IDS_AJAX' => $this->getLink('fetchPracownicyIdsAjax'),
  24. 'URL_FETCH_KONTRAHENCI' => $this->getLink('fetchKontrahenciAjax'),
  25. 'URL_FETCH_KONTRAHENCI_IDS_AJAX' => $this->getLink('fetchKontrahenciIdsAjax'),
  26. 'URL_CREATE_PRACOWNICY_GROUP' => $this->getLink('createPracownicyGroupAjax'),
  27. 'URL_CREATE_KONTRAHENCIS_GROUP' => $this->getLink('createKontrahenciGroupAjax'),
  28. 'URL_ADD_PRACOWNICY_TO_GROUP' => $this->getLink('addPracownicyToGroupAjax'),
  29. 'URL_ADD_KONTRAHENCI_TO_GROUP' => $this->getLink('addKontrahenciToGroupAjax'),
  30. 'URL_FETCH_GROUP_PRACOWNICY' => $this->getLink('fetchGroupPracownicyAjax'),
  31. 'URL_FETCH_GROUP_KONTRAHENCI' => $this->getLink('fetchGroupKontrahenciAjax'),
  32. 'URL_GENERATE_BI_AUDIT_RAPORT_AJAX' => $this->getLink('generateBiAuditRaportAjax'),
  33. 'DBG' => V::get('DBG', 0, $_GET),
  34. 'VIEW_KONTRAHENCI' => $this->defaultViewFormBiAudit([], 'KONTRAHENCI'),
  35. 'VIEW_PRACOWNICY' => $this->defaultViewFormBiAudit([], 'PRACOWNICY'),
  36. 'URL_FORM_DATA_CSV_FILE_AJAX' => $this->getLink('formDataCsvFileAjax'),
  37. 'URL_SAVE_FORM_CSV_FILE_AJAX' => $this->getLink('saveFormCsvFileAjax'),
  38. 'URL_TABLE_POWIAZANIA' => Router::getRoute('ViewTableAjax', [ 'namespace' => "default_db/BI_audit_ENERGA_RUM_KONTRAHENCI_POWIAZANIA/BI_audit_ENERGA_RUM_KONTRAHENCI_POWIAZANIA" ]),
  39. ]);
  40. echo '</div>'; // #smad-wrapper
  41. UI::dol();
  42. }
  43. /**
  44. * Funkcja ajax do odebrania danych z przesłanego pliku CSV do parsowania
  45. */
  46. public function formDataCsvFileAjaxAction() {
  47. Response::sendTryCatchJson(array($this, 'formDataCsvFileAjax'));
  48. }
  49. /**
  50. * Funkcja parsuje dane wgrywanego plku csv i zwraca dane w inputach
  51. */
  52. public function formDataCsvFileAjax() {
  53. if (!file_exists($_FILES['file']['tmp_name'])) throw new Exception("Wybierz plik do przesłania.");
  54. $file = file($_FILES['file']['tmp_name']);
  55. //$showCheckbox = V::get('showCheckbox', '', $args);
  56. $showCheckbox = V::get('showCheckbox', 0, $_REQUEST, 'string');
  57. // parsujemy csv to tablicy
  58. $arrayDataCsv = $this->csvToArray($file, ';', '"', '\n\r');
  59. $i = 0;
  60. // tworzymy rekordy
  61. foreach ( $arrayDataCsv as $line ) {
  62. $viewFormCol .= '<tr>';
  63. foreach ( $line as $keyData => $rowData ) {
  64. // utworzenie nagłówków tabeli
  65. if( $i == 0) { $header .= '<td style="min-width:160px">' . $keyData . '</td>'; }
  66. // utworzenie inputa do edycji
  67. $viewFormCol .= '<td style="min-width:160px"><input type="text" name="item['.$i.']['.$keyData.']" value="'.$rowData .'" class="form-control input-lg" /></td>';
  68. }
  69. $viewFormCol .= '</tr>';
  70. $i++;
  71. }
  72. // pokaz checkbox jeśli ma status showCheckbox
  73. if ( $showCheckbox == 'yes' ) {
  74. $viewFormCol .= '<div style="margin: 10px 0"><input type="checkbox" name="override" value="1" /> Nadpisz wszystkie rekordy w bazie danych</div';
  75. }
  76. $viewFormHtml = '<div id="smad-window-modal" style="overflow-x: scroll;">
  77. <div class="table-responsive padding-0" >
  78. <form method="POST" id="formDataFromCsv" class="form-horizontal"><table class="table table-bordered table-hover table-striped" height="5"><thead><tr>'. $header .'</tr></thead><tbody id="smad-csv-data">'. $viewFormCol .'</tbody></table></form></div>
  79. </div>';
  80. //return $viewFormHtml;
  81. return [
  82. 'type' => 'success',
  83. 'msg' => 'OK',
  84. '__req_args' => $_REQUEST,
  85. '__args' => $args,
  86. 'body' => [
  87. 'view' => $viewFormHtml,
  88. ]
  89. ];
  90. }
  91. /**
  92. * Funkcja ajax do odebrania danych z przesłanego formularza z parsowanego CSV
  93. */
  94. public function saveFormCsvFileAjaxAction() {
  95. Response::sendTryCatchJson(array($this, 'saveFormCsvFileAjax'), $args = 'JSON_FROM_REQUEST_BODY');
  96. //Response::sendTryCatchJson(array($this, 'saveFormCsvFileAjax'));
  97. }
  98. /**
  99. * Funkcja ajax do zapisania danych z przesłanego formularza z parsowanego CSV
  100. */
  101. public function saveFormCsvFileAjax($args) {
  102. //dane z formularza
  103. $formData = V::get('formData', '', $args);
  104. $enumType = V::get('enumType', '', $args);
  105. $override = false; // false - nie nadpisujemy danych
  106. $arrayInfo = array();
  107. $arrayInfo['insert'] = 0;
  108. $arrayInfo['update'] = 0;
  109. $arrayInfo['error'] = 0;
  110. // pobranie nazwy tabeli z db
  111. $table = $this->getNameTableByEnum( strtoupper($enumType) );
  112. if ( $table == null ) throw new Exception('Błąd zapisu. Tabela w db nie istnieje');
  113. // unserialize data from serialize in javascript
  114. parse_str($formData, $resultArrayFormdata);
  115. if ( count($resultArrayFormdata['item']) == 0) {
  116. throw new Exception("Wystapił problem podczas przesyłania danych - brak przesłanych danych.");
  117. }
  118. // ustawienie true jeśli wyrabno nadpisanie danych
  119. if ( isset($resultArrayFormdata['override']) ) { $override = true; } // aktualizuj rekordy/nadpisz istniejace
  120. // dodanie/aktualizacjia wpisu
  121. foreach ( $resultArrayFormdata['item'] as $line ) {
  122. $response = $this->saveDataToDb($table, $line, $override);
  123. // tworzymy listę informacji o liczbie nowych/zaktualizowanych/z błedami rekordów
  124. $arrayInfo = $this->responseCountListInfoAboutSaveData($response, $arrayInfo);
  125. }
  126. // utworzenie komunikatów
  127. if ( isset($arrayInfo['insert']) ) { $textInsert = "Liczba nowych rekordów: (" . $arrayInfo['insert'] . ");"; }
  128. if ( isset($arrayInfo['error']) ) { $textError = "Liczba nie zapisanych rekordów (" . $arrayInfo['insert'] . ");"; }
  129. return [
  130. 'msg' => "Zapisano dane. " . $textInsert . " " . $textError ,
  131. 'type' => "success",
  132. ];
  133. }
  134. /**
  135. * Count list
  136. */
  137. public function responseCountListInfoAboutSaveData($response, $arrayInfo) {
  138. if (!is_array($response)) throw new Exception('Wystapił bład podczas zapisu danych');
  139. $countData = array();
  140. switch(key($response)) {
  141. case 'insert':
  142. $countData['insert'] = $arrayInfo['insert'] + 1;
  143. break;
  144. case 'error':
  145. $countData['error'] = $arrayInfo['insert'] + 1;
  146. break;
  147. }
  148. return $countData;
  149. }
  150. /**
  151. * Function parse csv to array
  152. * @param $filename - file data from FILE
  153. * @param $delimiter - delimiter
  154. * @param $enclosure -
  155. * @param $escape -
  156. */
  157. function csvToArray($filedata , $delimiter=';', $enclosure='"', $escape = '\\') {
  158. if(!$filedata || empty($filedata)) return false;
  159. $header = null;
  160. $data = array();
  161. foreach( $filedata as $line) {
  162. $values = str_getcsv( $line, $delimiter, $enclosure, $escape );
  163. if(!$header) $header = $values;
  164. else $data[] = array_combine( $header, $values );
  165. }
  166. return $data;
  167. }
  168. /**
  169. * Save data in database
  170. */
  171. public function saveDataToDb( $table, $arrayData, $override = false ) {
  172. $response = array();
  173. try {
  174. if ($override) {
  175. DB::getPDO()->insertOrUpdate($table, array_merge($arrayData, [
  176. '@insert' => [
  177. 'A_RECORD_CREATE_DATE' => 'NOW()',
  178. 'A_RECORD_CREATE_AUTHOR' => User::getLogin(),
  179. ],
  180. '@update' => array_merge($arrayData, [
  181. 'A_RECORD_UPDATE_DATE' => 'NOW()',
  182. 'A_RECORD_UPDATE_AUTHOR' => User::getLogin(),
  183. ]),
  184. ]));
  185. } else {
  186. $responseInsert = DB::getPDO()->insert($table, array_merge($arrayData, [
  187. 'A_RECORD_CREATE_AUTHOR' => User::getLogin(),
  188. 'A_RECORD_CREATE_DATE' => 'NOW()',
  189. ]));
  190. }
  191. $response['insert'] = 1;
  192. } catch (Exception $e) {
  193. DBG::log($e);
  194. $response['error'] = 1;
  195. }
  196. return $response;
  197. }
  198. /**
  199. * Get name table by enum
  200. */
  201. public function getNameTableByEnum($type) {
  202. $nameTable = null;
  203. switch ($type) {
  204. case 'KONTRAHENCI':
  205. $nameTable = 'BI_audit_ENERGA_RUM_KONTRAHENCI';
  206. break;
  207. case 'PRACOWNICY':
  208. $nameTable = 'BI_audit_ENERGA_PRACOWNICY';
  209. break;
  210. }
  211. return $nameTable;
  212. }
  213. public function fetchEnergaRumKontrahenciPowiazaniaAjaxAction() {
  214. Response::sendTryCatchJson(array($this, 'fetchEnergaRumKontrahenciPowiazaniaAjax')); // , $args = 'JSON_FROM_REQUEST_BODY');
  215. }
  216. public function fetchEnergaRumKontrahenciPowiazaniaAjax($args) {
  217. $id = V::get('ID', 26, $_REQUEST, 'int');
  218. $items = ACL::getAclByNamespace('default_db/BI_audit_ENERGA_RUM_KONTRAHENCI_POWIAZANIA/BI_audit_ENERGA_RUM_KONTRAHENCI_POWIAZANIA')->buildQuery([
  219. 'cols' => [ // TODO:? propertyName = []
  220. 'ID',
  221. 'A_ADM_COMPANY',
  222. 'L_APPOITMENT_USER',
  223. 'A_CLASSIFIED',
  224. 'A_STATUS',
  225. 'A_STATUS_INFO',
  226. 'BI_analiza_maxDepth',
  227. 'BI_analiza_minDepth',
  228. 'BI_analiza_onlyTargets',
  229. 'BI_analiza_reloadCache',
  230. 'FILE_STATUS',
  231. 'FILE_STATUS_info',
  232. 'L_APPOITMENT_USER',
  233. 'default_db__x3A__BI_audit_ENERGA_PRACOWNICY:BI_audit_ENERGA_PRACOWNICY',
  234. 'default_db__x3A__BI_audit_ENERGA_RUM_KONTRAHENCI:BI_audit_ENERGA_RUM_KONTRAHENCI',
  235. 'default_db__x3A__BI_audit_ENERGA_RUM_KONTRAHENCI_POWIAZANIA_row:BI_audit_ENERGA_RUM_KONTRAHENCI_POWIAZANIA_row',
  236. 'default_db__x3A__BI_audit_KW_requested_person:BI_audit_KW_requested_person',
  237. ],
  238. 'f_ID' => "{$id}",
  239. ])->getItems([
  240. 'limit' => 10
  241. ]);
  242. // $items = [
  243. // [ 'ID' => 1, 'L_APPOITMENT_INFO' => 'x', 'BI_analiza_depth' => 'a', 'FILE_STATUS' => 1, 'FILE_STATUS_info' => 'test1'],
  244. // [ 'ID' => 2, 'L_APPOITMENT_INFO' => 'y', 'BI_analiza_depth' => 'b', 'FILE_STATUS' => 0, 'FILE_STATUS_info' => 'test2'],
  245. // [ 'ID' => 3, 'L_APPOITMENT_INFO' => 'z', 'BI_analiza_depth' => 'c', 'FILE_STATUS' => 1, 'FILE_STATUS_info' => 'test3'],
  246. // ];
  247. return [
  248. 'type' => 'success',
  249. 'msg' => 'OK',
  250. '__req_args' => $_REQUEST,
  251. '__args' => $args,
  252. 'body' => [
  253. 'items' => $items,
  254. 'view' => $this->showPowiazaniaEnergaRumKontrahenciPowiazania($items),
  255. ]
  256. ];
  257. }
  258. public function showPowiazaniaEnergaRumKontrahenciPowiazania($items) {
  259. $view = '<form class="form-horizontal" method="post">
  260. <table class="table table-bordered table-hover table-striped" height=5>
  261. <thead>
  262. <tr style="">
  263. <td width=1><input type="checkbox" name="checkAll" id="checkAll" /></td>
  264. <td width=1>ID</td>
  265. <td>Adnotacje</td>
  266. <td>Głębokość analizy</td>
  267. <td>Status raportu</td>
  268. <td>Status raportu - informacje</td>
  269. </tr>
  270. </thead>
  271. <tbody>
  272. ';
  273. foreach ($items as $key => $row) {
  274. $view .= '<tr>
  275. <td><input type="checkbox" name="prID[]" value="'.$row['ID'].'" onClick="checkAll()"/></td>
  276. <td align="right">'.$row["ID"].'</td>
  277. <td align="right">'.$row["L_APPOITMENT_INFO"].'</td>
  278. <td align="right">'.$row["BI_analiza_depth"].'</td>
  279. <td align="right">'.$row["FILE_STATUS"].'</td>
  280. <td align="right">'.$row["FILE_STATUS_info"].'</td>';
  281. }
  282. $view .= '</tbody></table></form>';
  283. return $view;
  284. }
  285. public function fetchTestKrsAjaxAction() {
  286. Response::sendTryCatchJson(array($this, 'fetchTestKrsAjax')); // , $args = 'JSON_FROM_REQUEST_BODY');
  287. }
  288. public function fetchTestKrsAjax($args) {
  289. $id = V::get('ID', 1, $_REQUEST, 'int');
  290. $items = ACL::getAclByNamespace('default_db/BI_audit_KRS/BI_audit_KRS')->buildQuery([
  291. 'cols' => [ // TODO:? propertyName = []
  292. 'A_kod',
  293. 'A_kraj',
  294. 'A_miejscowosc',
  295. 'A_nrDomu',
  296. 'A_nrLokalu',
  297. 'A_poczta',
  298. 'A_ulica',
  299. 'ID',
  300. 'S_gmina',
  301. 'S_kraj',
  302. 'S_miejscowosc',
  303. 'S_powiat',
  304. 'S_wojewodztwo',
  305. 'dataDokumentu',
  306. 'default_db__x3A__BI_audit_KRS_company:BI_audit_KRS_company/ID',
  307. 'default_db__x3A__BI_audit_KRS_company:BI_audit_KRS_company/krs',
  308. 'default_db__x3A__BI_audit_KRS_company:BI_audit_KRS_company/nazwa',
  309. 'default_db__x3A__BI_audit_KRS_company:BI_audit_KRS_company/regon',
  310. 'default_db__x3A__BI_audit_KRS_person:BI_audit_KRS_person/ID',
  311. 'default_db__x3A__BI_audit_KRS_person:BI_audit_KRS_person/imiona',
  312. 'default_db__x3A__BI_audit_KRS_person:BI_audit_KRS_person/nazwisko',
  313. 'default_db__x3A__BI_audit_KRS_person:BI_audit_KRS_person/pesel',
  314. 'krs',
  315. 'nazwa',
  316. 'nip',
  317. 'regon',
  318. ],
  319. 'f_ID' => "{$id}",
  320. ])->getItems([
  321. 'limit' => 10
  322. ]);
  323. return [
  324. 'type' => 'success',
  325. 'msg' => 'KRS',
  326. '__req_args' => $_REQUEST,
  327. '__args' => $args,
  328. 'body' => [
  329. 'items' => $items,
  330. ]
  331. ];
  332. }
  333. public function fetchTestCeidgAjaxAction() {
  334. Response::sendTryCatchJson(array($this, 'fetchTestCeidgAjax')); // , $args = 'JSON_FROM_REQUEST_BODY');
  335. }
  336. public function fetchTestCeidgAjax($args) {
  337. $id = V::get('ID', 0, $_REQUEST, 'int');
  338. $items = ACL::getAclByNamespace('default_db/BI_audit_CEIDG/BI_audit_CEIDG')->buildQuery([
  339. 'cols' => [ // TODO:? propertyName = []
  340. 'ID',
  341. 'budynek',
  342. 'firma',
  343. 'gmina',
  344. 'identyfikatorWpisu',
  345. 'imie',
  346. 'kodPocztowy',
  347. 'kraj',
  348. 'lokal',
  349. 'miejscowosc',
  350. 'nazwisko',
  351. 'nip',
  352. 'poczta',
  353. 'powiat',
  354. 'regon',
  355. 'ulica',
  356. 'default_db__x3A__BI_audit_CEIDG_pelnomocnicy:BI_audit_CEIDG_pelnomocnicy/ID',
  357. 'default_db__x3A__BI_audit_CEIDG_pelnomocnicy:BI_audit_CEIDG_pelnomocnicy/budynek',
  358. 'default_db__x3A__BI_audit_CEIDG_pelnomocnicy:BI_audit_CEIDG_pelnomocnicy/gmina',
  359. 'default_db__x3A__BI_audit_CEIDG_pelnomocnicy:BI_audit_CEIDG_pelnomocnicy/kodPocztowy',
  360. 'default_db__x3A__BI_audit_CEIDG_pelnomocnicy:BI_audit_CEIDG_pelnomocnicy/lokal',
  361. 'default_db__x3A__BI_audit_CEIDG_pelnomocnicy:BI_audit_CEIDG_pelnomocnicy/miejscowosc',
  362. 'default_db__x3A__BI_audit_CEIDG_pelnomocnicy:BI_audit_CEIDG_pelnomocnicy/nazwa',
  363. 'default_db__x3A__BI_audit_CEIDG_pelnomocnicy:BI_audit_CEIDG_pelnomocnicy/nip',
  364. 'default_db__x3A__BI_audit_CEIDG_pelnomocnicy:BI_audit_CEIDG_pelnomocnicy/poczta',
  365. 'default_db__x3A__BI_audit_CEIDG_pelnomocnicy:BI_audit_CEIDG_pelnomocnicy/powiat',
  366. 'default_db__x3A__BI_audit_CEIDG_pelnomocnicy:BI_audit_CEIDG_pelnomocnicy/ulica',
  367. 'default_db__x3A__BI_audit_CEIDG_pelnomocnicy:BI_audit_CEIDG_pelnomocnicy/wojewodztwo',
  368. 'default_db__x3A__BI_audit_CEIDG_powiazania:BI_audit_CEIDG_powiazania/ID',
  369. 'default_db__x3A__BI_audit_CEIDG_powiazania:BI_audit_CEIDG_powiazania/nip',
  370. 'default_db__x3A__BI_audit_CEIDG_powiazania:BI_audit_CEIDG_powiazania/regon',
  371. ],
  372. // 'f_ID' => $id,
  373. ])->getItems([
  374. 'limit' => 10
  375. ]);
  376. return [
  377. 'type' => 'success',
  378. 'msg' => 'CEIDG',
  379. '__req_args' => $_REQUEST,
  380. '__args' => $args,
  381. 'body' => [
  382. 'items' => $items,
  383. ]
  384. ];
  385. }
  386. public function fetchKontrahenciIdsAjaxAction() {
  387. Response::sendTryCatchJson(array($this, 'fetchKontrahenciIdsAjax'), $args = 'JSON_FROM_REQUEST_BODY');
  388. }
  389. public function fetchKontrahenciIdsAjax($args) {
  390. $idGroup = V::get('filter_idGroup', 0, $args, 'int');
  391. if ($idGroup < 0) $idGroup = 0;
  392. $backRefFilter = [];
  393. if ($idGroup > 0) {
  394. $backRefFilter['__backRef'] = [
  395. 'namespace' => 'default_db/BI_audit_ENERGA_KONTRAHENCI_group/BI_audit_ENERGA_KONTRAHENCI_group',
  396. 'primaryKey' => $idGroup,
  397. 'fieldName' => 'default_db__x3A__BI_audit_ENERGA_RUM_KONTRAHENCI:BI_audit_ENERGA_RUM_KONTRAHENCI',
  398. ];
  399. }
  400. $searchParams = []; // TODO: ???
  401. $filtersParams = [];
  402. $fieldFilterKeys = array_filter(array_keys($args), function ($key) {
  403. return ('f_' === substr($key, 0, 2));
  404. });
  405. foreach ($fieldFilterKeys as $key) {
  406. $filtersParams[ $key ] = '%' . $args[ $key ] . '%';
  407. }
  408. $acl = ACL::getAclByNamespace('default_db/BI_audit_ENERGA_RUM_KONTRAHENCI/BI_audit_ENERGA_RUM_KONTRAHENCI');
  409. $query = $acl->buildQuery(array_merge([
  410. 'cols' => [
  411. 'ID',
  412. ],
  413. //'f_ID' => $id,
  414. 'limit' => 0,
  415. // 'limitstart' => $limitstart, // offset
  416. // 'order_by' => 'ID', // sortowanie po kolumnie
  417. // 'order_dir' => 'DESC', // kierunek sortowania
  418. // 'f_nip' = "=12345", // szukamy dokładnie tej wartości - mysql: where nip = "12345"
  419. // 'f_nip' = "12345", // szukamy dokładnie tej wartości - mysql: where nip like "%12345%"
  420. // 'f_nip' = "12345%", // szukamy dokładnie tej wartości - mysql: where nip like "12345%"
  421. // 'f_ID' = "=12345", // szukamy dokładnie tej wartości - mysql: where ID = "12345"
  422. ], $searchParams, $filtersParams, $backRefFilter));
  423. // $total = $query->getTotal();
  424. $items = $query->getItems();
  425. return [
  426. 'type' => 'success',
  427. 'msg' => 'kontrahenci ids',
  428. 'body' => [
  429. 'ids' => array_map( V::makePick('ID'), $items ),
  430. ],
  431. '__DBG_args' => $args,
  432. '__DBG_$idGroup' => $idGroup,
  433. '__DBG_$filtersParams' => $filtersParams,
  434. '__DBG_$backRefFilter' => $backRefFilter,
  435. ];
  436. }
  437. /**
  438. * KONTRAHENCI
  439. */
  440. public function fetchKontrahenciAjaxAction() {
  441. Response::sendTryCatchJson(array($this, 'fetchKontrahenciAjax'), $args = $_REQUEST);
  442. }
  443. public function fetchKontrahenciAjax($args) {
  444. $idGroup = V::get('filterIdGroup', 0, $args, 'int'); // TODO: dla filtrów "Wysokiego ryzyka" - przekazywany ID rekodu
  445. if ($idGroup < 0) $idGroup = 0;
  446. $limit = 20;
  447. $limitstart = V::get('limitstart', 0, $args, 'int');
  448. if ($limitstart < 0) $limitstart = 0;
  449. $page = V::get('page', 0, $args, 'int');
  450. $limitstart = ($page - 1) * $limit;
  451. $search = V::get('search', '', $args);
  452. $searchParams = [];
  453. if (!empty($search)) {
  454. $ogcSearch = "*{$search}*"; // wildCard="*" -> mysql '%'
  455. $searchParams['ogc:Filter'] = '
  456. <ogc:Filter>
  457. <ogc:Or>
  458. <ogc:PropertyIsLike wildCard="" singleChar="%23" escapeChar="!">
  459. <ogc:PropertyName>NIP</ogc:PropertyName>
  460. <ogc:Literal>' . $ogcSearch . '</ogc:Literal>
  461. </ogc:PropertyIsLike>
  462. <ogc:PropertyIsLike wildCard="*" singleChar="%23" escapeChar="!">
  463. <ogc:PropertyName>Nazwa_grupy_kapitalowej</ogc:PropertyName>
  464. <ogc:Literal>' . $ogcSearch . '</ogc:Literal>
  465. </ogc:PropertyIsLike>
  466. <ogc:PropertyIsLike wildCard="*" singleChar="%23" escapeChar="!">
  467. <ogc:PropertyName>Pelna_nazwa_kontrahenta</ogc:PropertyName>
  468. <ogc:Literal>' . $ogcSearch . '</ogc:Literal>
  469. </ogc:PropertyIsLike>
  470. </ogc:Or>
  471. </ogc:Filter>
  472. ';
  473. }
  474. $backRefFilter = [];
  475. if ($idGroup > 0) {
  476. $backRefFilter['__backRef'] = [
  477. 'namespace' => 'default_db/BI_audit_ENERGA_KONTRAHENCI_group/BI_audit_ENERGA_KONTRAHENCI_group',
  478. 'primaryKey' => $idGroup,
  479. 'fieldName' => 'default_db__x3A__BI_audit_ENERGA_RUM_KONTRAHENCI:BI_audit_ENERGA_RUM_KONTRAHENCI',
  480. ];
  481. // - ID
  482. // - ID_USER - id usera który stworzył grupę (tylko dla niego będzie widoczna)
  483. // - NAZWA - nazwa grupy
  484. // - 'default_db/BI_audit_ENERGA_RUM_KONTRAHENCI/BI_audit_ENERGA_KONTRAHENCI' minOccurs="0" maxOccurs="unbounded"
  485. }
  486. $filtersParams = [];
  487. $fieldFilterKeys = array_filter(array_keys($args), function ($key) {
  488. return ('f_' === substr($key, 0, 2));
  489. });
  490. foreach ($fieldFilterKeys as $key) {
  491. $filtersParams[ $key ] = '%' . $args[ $key ] . '%';
  492. }
  493. DBG::log($filtersParams, 'Kontrahenci $filtersParams');
  494. $acl = ACL::getAclByNamespace('default_db/BI_audit_ENERGA_RUM_KONTRAHENCI/BI_audit_ENERGA_RUM_KONTRAHENCI');
  495. $query = $acl->buildQuery(array_merge([
  496. 'cols' => [ // TODO:? propertyName = []
  497. 'ID',
  498. 'Nazwa_grupy_kapitalowej',
  499. 'Pelna_nazwa_kontrahenta',
  500. 'Numer_kontrahenta',
  501. 'Skrocona_Nazwa_Kontrahenta',
  502. 'Typ_kontrahenta',
  503. 'NIP',
  504. 'KRS',
  505. 'REGON',
  506. 'PESEL',
  507. 'Forma_prawna_dzialalnosci',
  508. 'Ulica',
  509. 'Numer_budynku',
  510. 'Numer_mieszkania_lokalu',
  511. 'Miejscowosc',
  512. 'Kod_pocztowy',
  513. 'Kraj',
  514. 'Telefon',
  515. 'Fax',
  516. 'Mail',
  517. 'A_ADM_COMPANY',
  518. 'A_CLASSIFIED',
  519. 'Dodano',
  520. 'Podmiot_dominujacy',
  521. 'Tytul_dokumentu',
  522. 'ownCompany',
  523. 'uwagi',
  524. ],
  525. //'f_ID' => $id,
  526. 'limit' => $limit,
  527. 'limitstart' => $limitstart, // offset
  528. ], $searchParams, $filtersParams, $backRefFilter));
  529. $total = $query->getTotal();
  530. $items = $query->getItems();
  531. $pagination = array();
  532. $pagination['total_items'] = $total;
  533. $pagination['size'] = ceil($total/$limit); // pages size
  534. $pagination['current'] = $page;
  535. $pagination['limit'] = $limit;
  536. if ($idGroup > 0) $pagination['filter_idGroup'] = $idGroup;
  537. return [
  538. 'type' => 'success',
  539. 'msg' => 'showKontrajenci',
  540. 'body' => [
  541. 'items' => $items,
  542. //'view' => $this->htmlViewFormBiAudit($items, 'KONTRAHENCI'),
  543. 'pagination' => $pagination
  544. ],
  545. '__DBG_args' => $args,
  546. '__DBG_$idGroup' => $idGroup,
  547. '__DBG_$filtersParams' => $filtersParams,
  548. '__DBG_$backRefFilter' => $backRefFilter,
  549. ];
  550. }
  551. public function showTableKontrahenci($items) {
  552. $view = '<form class="form-horizontal" method="post">
  553. <table class="table table-bordered table-hover table-striped" height=5>
  554. <thead>
  555. <tr>
  556. <td width=1><input type="checkbox" name="checkAll" id="checkAll-KONTRAHENCI" /></td>
  557. <td width=1>ID</td>
  558. <td>Nazwa grupy kapitalowej</td>
  559. <td>Pelna nazwa kontrahenta</td>
  560. <td>Numer kontrahenta</td>
  561. <td>Skrócona nazwa kontrahenta</td>
  562. <td>Typ_kontrahenta</td>
  563. <td>NIP</td>
  564. <td>KRS</td>
  565. <td>Regon</td>
  566. <td>PESEL</td>
  567. <td>Forma prawna działalności</td>
  568. <td>Ulica</td>
  569. <td>Numer budynku</td>
  570. <td>Numer mieszkania lokalu</td>
  571. <td>Miejscowosc</td>
  572. <td>Kod pocztowy</td>
  573. <td>Kraj</td>
  574. <td>Telefon</td>
  575. <td>Fax</td>
  576. <td>Mail</td>
  577. <td>A_ADM_COMPANY</td>
  578. <td>A_CLASSIFIED</td>
  579. <td>Dodano</td>
  580. <td>Podmiot dominujacy</td>
  581. <td>Tytul dokumentu</td>
  582. <td>ownCompany</td>
  583. <td>uwagi</td>
  584. </tr>
  585. <tr>
  586. <td style="padding:0" width=1><button style="padding:5px" id="filtersFieldRemoveBtn-KONTRAHENCI" onClick="return removeFiltersKontrahenci(event, this)" title="Kasuj filtry" class="btn btn-xs btn-link glyphicon glyphicon-remove"></button></td>
  587. <td style="padding:0"><input style="padding:2px 8px; width:80px" onChange="return onChangeFiltersKontrahenci(this)" type="text" name="f_ID" value="" placeholder="%"></td>
  588. <td style="padding:0"><input style="padding:2px 8px; width:100%" onChange="return onChangeFiltersKontrahenci(this)" type="text" name="f_Nazwa_grupy_kapitalowej" value="" placeholder="%"></td>
  589. <td style="padding:0"><input style="padding:2px 8px; width:100%" onChange="return onChangeFiltersKontrahenci(this)" type="text" name="f_Pelna_nazwa_kontrahenta" value="" placeholder="%"></td>
  590. <td style="padding:0"><input style="padding:2px 8px; width:100%" onChange="return onChangeFiltersKontrahenci(this)" type="text" name="f_Numer_kontrahenta" value="" placeholder="%"></td>
  591. <td style="padding:0"><input style="padding:2px 8px; width:100%" onChange="return onChangeFiltersKontrahenci(this)" type="text" name="f_Skrocona_Nazwa_Kontrahenta" value="" placeholder="%"></td>
  592. <td style="padding:0"><input style="padding:2px 8px; width:100%" onChange="return onChangeFiltersKontrahenci(this)" type="text" name="f_Typ_kontrahenta" value="" placeholder="%"></td>
  593. <td style="padding:0"><input style="padding:2px 8px; width:100%" onChange="return onChangeFiltersKontrahenci(this)" type="text" name="f_NIP" value="" placeholder="%"></td>
  594. <td style="padding:0"><input style="padding:2px 8px; width:100%" onChange="return onChangeFiltersKontrahenci(this)" type="text" name="f_KRS" value="" placeholder="%"></td>
  595. <td style="padding:0"><input style="padding:2px 8px; width:100%" onChange="return onChangeFiltersKontrahenci(this)" type="text" name="f_REGON" value="" placeholder="%"></td>
  596. <td style="padding:0"><input style="padding:2px 8px; width:100%" onChange="return onChangeFiltersKontrahenci(this)" type="text" name="f_PESEL" value="" placeholder="%"></td>
  597. <td style="padding:0"><input style="padding:2px 8px; width:100%" onChange="return onChangeFiltersKontrahenci(this)" type="text" name="f_Forma_prawna_dzialalnosci" value="" placeholder="%"></td>
  598. <td style="padding:0"><input style="padding:2px 8px; width:100%" onChange="return onChangeFiltersKontrahenci(this)" type="text" name="f_Ulica" value="" placeholder="%"></td>
  599. <td style="padding:0"><input style="padding:2px 8px; width:100%" onChange="return onChangeFiltersKontrahenci(this)" type="text" name="f_Numer_budynku" value="" placeholder="%"></td>
  600. <td style="padding:0"><input style="padding:2px 8px; width:100%" onChange="return onChangeFiltersKontrahenci(this)" type="text" name="f_Numer_mieszkania_lokalu" value="" placeholder="%"></td>
  601. <td style="padding:0"><input style="padding:2px 8px; width:100%" onChange="return onChangeFiltersKontrahenci(this)" type="text" name="f_Miejscowosc" value="" placeholder="%"></td>
  602. <td style="padding:0"><input style="padding:2px 8px; width:100%" onChange="return onChangeFiltersKontrahenci(this)" type="text" name="f_Kod_pocztowy" value="" placeholder="%"></td>
  603. <td style="padding:0"><input style="padding:2px 8px; width:100%" onChange="return onChangeFiltersKontrahenci(this)" type="text" name="f_Kraj" value="" placeholder="%"></td>
  604. <td style="padding:0"><input style="padding:2px 8px; width:100%" onChange="return onChangeFiltersKontrahenci(this)" type="text" name="f_Telefon" value="" placeholder="%"></td>
  605. <td style="padding:0"><input style="padding:2px 8px; width:100%" onChange="return onChangeFiltersKontrahenci(this)" type="text" name="f_Fax" value="" placeholder="%"></td>
  606. <td style="padding:0"><input style="padding:2px 8px; width:100%" onChange="return onChangeFiltersKontrahenci(this)" type="text" name="f_Mail" value="" placeholder="%"></td>
  607. <td style="padding:0"><input style="padding:2px 8px; width:100%" onChange="return onChangeFiltersKontrahenci(this)" type="text" name="f_A_ADM_COMPANY" value="" placeholder="%"></td>
  608. <td style="padding:0"><input style="padding:2px 8px; width:100%" onChange="return onChangeFiltersKontrahenci(this)" type="text" name="f_A_CLASSIFIED" value="" placeholder="%"></td>
  609. <td style="padding:0"><input style="padding:2px 8px; width:100%" onChange="return onChangeFiltersKontrahenci(this)" type="text" name="f_Dodano" value="" placeholder="%"></td>
  610. <td style="padding:0"><input style="padding:2px 8px; width:100%" onChange="return onChangeFiltersKontrahenci(this)" type="text" name="f_Podmiot_dominujacy" value="" placeholder="%"></td>
  611. <td style="padding:0"><input style="padding:2px 8px; width:100%" onChange="return onChangeFiltersKontrahenci(this)" type="text" name="f_Tytul_dokumentu" value="" placeholder="%"></td>
  612. <td style="padding:0"><input style="padding:2px 8px; width:100%" onChange="return onChangeFiltersKontrahenci(this)" type="text" name="f_ownCompany" value="" placeholder="%"></td>
  613. <td style="padding:0"><input style="padding:2px 8px; width:100%" onChange="return onChangeFiltersKontrahenci(this)" type="text" name="f_uwagi" value="" placeholder="%"></td>
  614. </tr>
  615. </thead>
  616. <tbody id="body-kontrahenci">
  617. </tbody></table>
  618. </form>
  619. ';
  620. return $view;
  621. }
  622. // tworzenie grupy kontrahentów
  623. public function createKontrahenciGroupAjaxAction() {
  624. 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
  625. }
  626. public function createKontrahenciGroupAjax($args) {
  627. $nazwa = V::get('NAZWA', '', $args);
  628. // TODO: vlaidacja nazwy - sprawdzenie czy już nie występuje
  629. $idGroup = DB::getPDO()->insert('BI_audit_ENERGA_KONTRAHENCI_group', [
  630. 'A_RECORD_CREATE_AUTHOR' => User::getLogin(),
  631. 'A_RECORD_CREATE_DATE' => 'NOW()',
  632. 'NAZWA' => $nazwa,
  633. 'ID_USER' => User::getID()
  634. ]);
  635. return [
  636. 'msg' => "Utworzona grupę {$idGroup}",
  637. 'type' => "success",
  638. 'body' => [
  639. 'id' => $idGroup,
  640. 'nazwa' => $nazwa
  641. ]
  642. ];
  643. }
  644. // Dodanie do grupy filtra kontrahentów
  645. public function addKontrahenciToGroupAjaxAction() {
  646. 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
  647. }
  648. public function addKontrahenciToGroupAjax($args) {
  649. $idGroup = V::get('idGroup', '', $args);
  650. $kontrahenciIds = V::get('kontrahenciIds', '', $args);
  651. // validate
  652. if (!$idGroup) throw new Exception("Nie wybrano grupa");
  653. if (!$kontrahenciIds || count($kontrahenciIds) == 0 ) throw new Exception("Proszę wybrać kontrahentów");
  654. $group = ACL::getAclByNamespace('default_db/BI_audit_ENERGA_KONTRAHENCI_group/BI_audit_ENERGA_KONTRAHENCI_group')->buildQuery([
  655. 'cols' => [ // TODO:? propertyName = []
  656. 'ID',
  657. 'ID_USER',
  658. 'NAZWA',
  659. ],
  660. // 'f_ID_USER' => User::getID()
  661. ])->getItem($idGroup);
  662. if (!$group) throw new Exception("Grupa nie istnieje");
  663. if (User::getID() != $group['ID_USER']) throw new Exception("Brak uprawnień do grupy");
  664. // $refGrupyToPracownicy = ACL::getRefTable('obiekt główny', 'nazwa pola - powiązane rekordy');
  665. $refGrupyToKontrahenci = ACL::getRefTable('default_db/BI_audit_ENERGA_KONTRAHENCI_group/BI_audit_ENERGA_KONTRAHENCI_group',
  666. 'default_db__x3A__BI_audit_ENERGA_RUM_KONTRAHENCI:BI_audit_ENERGA_RUM_KONTRAHENCI');
  667. foreach ($kontrahenciIds as $kontrahentIds) {
  668. DB::getPDO()->insert($refGrupyToKontrahenci, ['PRIMARY_KEY' => $idGroup, 'REMOTE_PRIMARY_KEY' => $kontrahentIds]);
  669. }
  670. return [
  671. 'msg' => "Powiązano kontrahentów z grupą {$idGroup}",
  672. 'type' => "success",
  673. ];
  674. }
  675. public function fetchGroupKontrahenciAjaxAction() {
  676. Response::sendTryCatchJson(array($this, 'fetchGroupKontrahenciAjax'));
  677. }
  678. public function fetchGroupKontrahenciAjax() {
  679. $query = ACL::getAclByNamespace('default_db/BI_audit_ENERGA_KONTRAHENCI_group/BI_audit_ENERGA_KONTRAHENCI_group')->buildQuery([
  680. 'cols' => [ // TODO:? propertyName = []
  681. 'ID',
  682. 'ID_USER',
  683. 'NAZWA',
  684. ],
  685. 'f_ID_USER' => "=" . User::getID(),
  686. 'f_A_STATUS' => "!DELETED",
  687. ]);
  688. $itemsKontrahenci = $query->getItems();
  689. if (empty($itemsKontrahenci)) throw new AlertWarningException("Grupy nie istnieją");
  690. $arrayGroupKontrahenci = array();
  691. foreach ($itemsKontrahenci as $item) {
  692. // if (User::getID() != $item['ID_USER']) throw new Exception("Brak uprawnień do grupy");
  693. $arrayGroupKontrahenci[] = [
  694. 'NAZWA' => $item['NAZWA'],
  695. 'ID' => $item['ID'],
  696. ];
  697. }
  698. return [
  699. 'type' => 'success',
  700. 'msg' => 'fetchGroupKontrahenciAjax',
  701. '__req_args' => $_REQUEST,
  702. '__args' => $args,
  703. 'body' => [
  704. 'itemsGroupKontrahenci' => $arrayGroupKontrahenci
  705. ]
  706. ];
  707. }
  708. public function fetchPracownicyIdsAjaxAction() {
  709. Response::sendTryCatchJson(array($this, 'fetchPracownicyIdsAjax'), $args = 'JSON_FROM_REQUEST_BODY');
  710. }
  711. public function fetchPracownicyIdsAjax($args) {
  712. $idGroup = V::get('filter_idGroup', 0, $args, 'int');
  713. if ($idGroup < 0) $idGroup = 0;
  714. $backRefFilter = [];
  715. if ($idGroup > 0) {
  716. $backRefFilter['__backRef'] = [
  717. 'namespace' => 'default_db/BI_audit_ENERGA_PRACOWNICY_group/BI_audit_ENERGA_PRACOWNICY_group',
  718. 'primaryKey' => $idGroup,
  719. 'fieldName' => 'default_db__x3A__BI_audit_ENERGA_PRACOWNICY:BI_audit_ENERGA_PRACOWNICY',
  720. ];
  721. }
  722. $searchParams = []; // TODO: ???
  723. $filtersParams = [];
  724. $fieldFilterKeys = array_filter(array_keys($args), function ($key) {
  725. return ('f_' === substr($key, 0, 2));
  726. });
  727. foreach ($fieldFilterKeys as $key) {
  728. $filtersParams[ $key ] = '%' . $args[ $key ] . '%';
  729. }
  730. $acl = ACL::getAclByNamespace('default_db/BI_audit_ENERGA_PRACOWNICY/BI_audit_ENERGA_PRACOWNICY');
  731. $query = $acl->buildQuery(array_merge([
  732. 'cols' => [
  733. 'ID',
  734. ],
  735. //'f_ID' => $id,
  736. 'limit' => 0,
  737. // 'limitstart' => $limitstart, // offset
  738. // 'order_by' => 'ID', // sortowanie po kolumnie
  739. // 'order_dir' => 'DESC', // kierunek sortowania
  740. // 'f_nip' = "=12345", // szukamy dokładnie tej wartości - mysql: where nip = "12345"
  741. // 'f_nip' = "12345", // szukamy dokładnie tej wartości - mysql: where nip like "%12345%"
  742. // 'f_nip' = "12345%", // szukamy dokładnie tej wartości - mysql: where nip like "12345%"
  743. // 'f_ID' = "=12345", // szukamy dokładnie tej wartości - mysql: where ID = "12345"
  744. ], $searchParams, $filtersParams, $backRefFilter));
  745. // $total = $query->getTotal();
  746. $items = $query->getItems();
  747. return [
  748. 'type' => 'success',
  749. 'msg' => 'pracownicy ids',
  750. 'body' => [
  751. 'ids' => array_map( V::makePick('ID'), $items ),
  752. ],
  753. '__args' => $args,
  754. '__DBG_$idGroup' => $idGroup,
  755. '__DBG_$filtersParams' => $filtersParams,
  756. '__DBG_$backRefFilter' => $backRefFilter,
  757. ];
  758. }
  759. /*
  760. * PRACOWNICY
  761. */
  762. public function fetchPracownicyAjaxAction() {
  763. Response::sendTryCatchJson(array($this, 'fetchPracownicyAjax'), $args = $_REQUEST);
  764. }
  765. public function fetchPracownicyAjax($args) {
  766. $idGroup = V::get('filterIdGroup', 0, $args, 'int'); // dla filtrów "Wysokiego ryzyka" - przekazywany ID rekodu
  767. if ($idGroup < 0) $idGroup = 0;
  768. $limit = 20;
  769. $limitstart = V::get('limitstart', 0, $args, 'int');
  770. if ($limitstart < 0) $limitstart = 0;
  771. $page = V::get('page', 0, $args, 'int');
  772. $limitstart = ($page - 1) * $limit;
  773. $search = V::get('search', '', $args);
  774. $searchParams = [];
  775. if (!empty($search)) {
  776. $ogcSearch = "*{$search}*"; // wildCard="*" -> mysql '%'
  777. $searchParams['ogc:Filter'] = '
  778. <ogc:Filter>
  779. <ogc:Or>
  780. <ogc:PropertyIsLike wildCard="" singleChar="%23" escapeChar="!">
  781. <ogc:PropertyName>nip</ogc:PropertyName>
  782. <ogc:Literal>' . $ogcSearch . '</ogc:Literal>
  783. </ogc:PropertyIsLike>
  784. <ogc:PropertyIsLike wildCard="*" singleChar="%23" escapeChar="!">
  785. <ogc:PropertyName>nazwisko</ogc:PropertyName>
  786. <ogc:Literal>' . $ogcSearch . '</ogc:Literal>
  787. </ogc:PropertyIsLike>
  788. </ogc:Or>
  789. </ogc:Filter>
  790. ';
  791. }
  792. $backRefFilter = [];
  793. if ($idGroup > 0) {
  794. $backRefFilter['__backRef'] = [
  795. 'namespace' => 'default_db/BI_audit_ENERGA_PRACOWNICY_group/BI_audit_ENERGA_PRACOWNICY_group',
  796. 'primaryKey' => $idGroup,
  797. 'fieldName' => 'default_db__x3A__BI_audit_ENERGA_PRACOWNICY:BI_audit_ENERGA_PRACOWNICY',
  798. ];
  799. }
  800. $filtersParams = [];
  801. $fieldFilterKeys = array_filter(array_keys($args), function ($key) {
  802. return ('f_' === substr($key, 0, 2));
  803. });
  804. foreach ($fieldFilterKeys as $key) {
  805. $filtersParams[ $key ] = '%' . $args[ $key ] . '%';
  806. }
  807. $acl = ACL::getAclByNamespace('default_db/BI_audit_ENERGA_PRACOWNICY/BI_audit_ENERGA_PRACOWNICY');
  808. $query = $acl->buildQuery(array_merge([
  809. 'cols' => [
  810. 'ID',
  811. 'imiona',
  812. 'nazwisko',
  813. 'nip',
  814. 'pesel',
  815. 'regon',
  816. 'source',
  817. 'A_ADM_COMPANY',
  818. 'A_CLASSIFIED',
  819. 'A_STATUS',
  820. 'A_STATUS_INFO',
  821. 'L_APPOITMENT_USER',
  822. 'default_db__x3A__BI_audit_ENERGA_PRACOWNICY_adresy:BI_audit_ENERGA_PRACOWNICY_adresy/*'
  823. ],
  824. //'f_ID' => $id,
  825. 'limit' => $limit,
  826. 'limitstart' => $limitstart, // offset
  827. // 'order_by' => 'ID', // sortowanie po kolumnie
  828. // 'order_dir' => 'DESC', // kierunek sortowania
  829. // 'f_nip' = "=12345", // szukamy dokładnie tej wartości - mysql: where nip = "12345"
  830. // 'f_nip' = "12345", // szukamy dokładnie tej wartości - mysql: where nip like "%12345%"
  831. // 'f_nip' = "12345%", // szukamy dokładnie tej wartości - mysql: where nip like "12345%"
  832. // 'f_ID' = "=12345", // szukamy dokładnie tej wartości - mysql: where ID = "12345"
  833. ], $searchParams, $filtersParams, $backRefFilter));
  834. $total = $query->getTotal();
  835. $items = $query->getItems();
  836. $pagination = array();
  837. $pagination['total_items'] = $total;
  838. $pagination['size'] = ceil($total/$limit); // pages size
  839. $pagination['current'] = $page;
  840. $pagination['limit'] = $limit;
  841. // $idGroup = V::get('filterIdGroup', 0, $_REQUEST, 'int'); // TODO: dla filtrów "Wysokiego ryzyka" - przekazywany ID rekodu
  842. if ($idGroup > 0) $pagination['filter_idGroup'] = $idGroup;
  843. // { // tworzenie własnego zapytanie mysql
  844. // $rootTableName = $acl->getRootTableName();
  845. // DB::getPDO()->fetchAll("
  846. // select t.*
  847. // from {$rootTableName} t
  848. // where t.ID in (
  849. // select x.ID
  850. // from ... x
  851. // where
  852. // )
  853. // ");
  854. // }
  855. return [
  856. 'type' => 'success',
  857. 'msg' => 'showPracownicy',
  858. 'body' => [
  859. 'items' => $items,
  860. //'view' => $this->htmlViewFormBiAudit($items, 'PRACOWNICY'),
  861. 'pagination' => $pagination
  862. ],
  863. '__DBG_$idGroup' => $idGroup,
  864. '__DBG_$filtersParams' => $filtersParams,
  865. '__DBG_$backRefFilter' => $backRefFilter,
  866. ];
  867. }
  868. public function showTablePracownicy() {
  869. $view = '<form class="form-horizontal" method="post">
  870. <table class="table table-responsive table-bordered table-hover table-striped" height=5>
  871. <thead>
  872. <tr>
  873. <td width=1><input type="checkbox" name="checkAll" id="checkAll-PRACOWNICY" /></td>
  874. <td width=1>ID</td>
  875. <td>Imię/Imiona</td>
  876. <td>Nazwisko</td>
  877. <td>NIP</td>
  878. <td>Pesel</td>
  879. <td>Regon</td>
  880. <td>source</td>
  881. <td>A_ADM_COMPANY</td>
  882. <td>A_CLASSIFIED</td>
  883. <td>A_STATUS</td>
  884. <td>A_STATUS_INFO</td>
  885. <td>L_APPOITMENT_USER</td>
  886. <td>Adresy</td>
  887. </tr>
  888. <tr>
  889. <td style="padding:0" width=1><button style="padding:5px" id="filtersFieldRemoveBtn-PRACOWNICY" onClick="return removeFiltersPracownicy(event, this)" title="Kasuj filtry" class="btn btn-xs btn-link glyphicon glyphicon-remove"></button></td>
  890. <td style="padding:0"><input style="padding:2px 8px; width:80px" onChange="return onChangeFiltersPracownicy(this)" type="text" name="f_ID" value="" placeholder="%"></td>
  891. <td style="padding:0"><input style="padding:2px 8px; width:100%" onChange="return onChangeFiltersPracownicy(this)" type="text" name="f_imiona" value="" placeholder="%"></td>
  892. <td style="padding:0"><input style="padding:2px 8px; width:100%" onChange="return onChangeFiltersPracownicy(this)" type="text" name="f_nazwisko" value="" placeholder="%"></td>
  893. <td style="padding:0"><input style="padding:2px 8px; width:100%" onChange="return onChangeFiltersPracownicy(this)" type="text" name="f_nip" value="" placeholder="%"></td>
  894. <td style="padding:0"><input style="padding:2px 8px; width:100%" onChange="return onChangeFiltersPracownicy(this)" type="text" name="f_pesel" value="" placeholder="%"></td>
  895. <td style="padding:0"><input style="padding:2px 8px; width:100%" onChange="return onChangeFiltersPracownicy(this)" type="text" name="f_regon" value="" placeholder="%"></td>
  896. <td style="padding:0"><input style="padding:2px 8px; width:100%" onChange="return onChangeFiltersPracownicy(this)" type="text" name="f_source" value="" placeholder="%"></td>
  897. <td style="padding:0"><input style="padding:2px 8px; width:100%" onChange="return onChangeFiltersPracownicy(this)" type="text" name="f_A_ADM_COMPANY" value="" placeholder="%"></td>
  898. <td style="padding:0"><input style="padding:2px 8px; width:100%" onChange="return onChangeFiltersPracownicy(this)" type="text" name="f_A_CLASSIFIED" value="" placeholder="%"></td>
  899. <td style="padding:0"><input style="padding:2px 8px; width:100%" onChange="return onChangeFiltersPracownicy(this)" type="text" name="f_A_STATUS" value="" placeholder="%"></td>
  900. <td style="padding:0"><input style="padding:2px 8px; width:100%" onChange="return onChangeFiltersPracownicy(this)" type="text" name="f_A_STATUS_INFO" value="" placeholder="%"></td>
  901. <td style="padding:0"><input style="padding:2px 8px; width:100%" onChange="return onChangeFiltersPracownicy(this)" type="text" name="f_L_APPOITMENT_USER" value="" placeholder="%"></td>
  902. <td style="padding:0"><input style="padding:2px 8px; width:100%" onChange="return onChangeFiltersPracownicy(this)" type="text" name="f_Adresy" value="" placeholder="%"></td>
  903. </tr>
  904. </thead>
  905. <tbody id="body-pracownicy">
  906. </tbody></table>
  907. </form>';
  908. return $view;
  909. }
  910. // tworzenie grupy pracowników
  911. public function createPracownicyGroupAjaxAction() {
  912. 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
  913. }
  914. public function createPracownicyGroupAjax($args) {
  915. $nazwa = V::get('NAZWA', '', $args);
  916. // validate
  917. if (!$nazwa) throw new Exception("Nie wybrano grupa");
  918. $idGroup = DB::getPDO()->insert('BI_audit_ENERGA_PRACOWNICY_group', [
  919. 'A_RECORD_CREATE_AUTHOR' => User::getLogin(),
  920. 'A_RECORD_CREATE_DATE' => 'NOW()',
  921. 'NAZWA' => $nazwa,
  922. 'ID_USER' => User::getID()
  923. ]);
  924. return [
  925. 'msg' => "Utworzona grupę {$nazwa}",
  926. 'type' => "success",
  927. 'body' => [
  928. 'id' => $idGroup,
  929. 'nazwa' => $nazwa
  930. ]
  931. ];
  932. }
  933. // Dodanie do grupy filtra pracowników
  934. public function addPracownicyToGroupAjaxAction() {
  935. 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
  936. }
  937. public function addPracownicyToGroupAjax($args) {
  938. $idGroup = V::get('idGroup', '', $args);
  939. $pracownicyIds = V::get('pracownicyIds', '', $args);
  940. // validate
  941. if (!$idGroup) throw new Exception("Nie wybrano grupa");
  942. if (!$pracownicyIds || count($pracownicyIds) == 0 ) throw new Exception("Proszę wybrać pracowników");
  943. // TODO: SPRWADZENIE CZY NIE DODANOU JUZ PRACOWNIKAS
  944. // default_db/BI_audit_ENERGA_PRACOWNICY_group/BI_audit_ENERGA_PRACOWNICY_group
  945. // default_db/BI_audit_ENERGA_PRACOWNICY/BI_audit_ENERGA_PRACOWNICY
  946. $group = ACL::getAclByNamespace('default_db/BI_audit_ENERGA_PRACOWNICY_group/BI_audit_ENERGA_PRACOWNICY_group')->buildQuery([
  947. 'cols' => [ // TODO:? propertyName = []
  948. 'ID',
  949. 'ID_USER',
  950. 'NAZWA',
  951. ],
  952. // 'f_ID_USER' => User::getID()
  953. ])->getItem($idGroup);
  954. if (!$group) throw new Exception("Grupa nie istnieje");
  955. if (User::getID() != $group['ID_USER']) throw new Exception("Brak uprawnień do grupy");
  956. // $refGrupyToPracownicy = ACL::getRefTable('obiekt główny', 'nazwa pola - powiązane rekordy');
  957. $refGrupyToPracownicy = ACL::getRefTable('default_db/BI_audit_ENERGA_PRACOWNICY_group/BI_audit_ENERGA_PRACOWNICY_group',
  958. 'default_db__x3A__BI_audit_ENERGA_PRACOWNICY:BI_audit_ENERGA_PRACOWNICY');
  959. foreach ($pracownicyIds as $idPracownik) {
  960. DB::getPDO()->insert($refGrupyToPracownicy, ['PRIMARY_KEY' => $idGroup, 'REMOTE_PRIMARY_KEY' => $idPracownik]);
  961. }
  962. return [
  963. 'msg' => "Powiązano pracowników z grupą {$idGroup}",
  964. 'type' => "success",
  965. ];
  966. }
  967. public function fetchGroupPracownicyAjaxAction() {
  968. Response::sendTryCatchJson(array($this, 'fetchGroupPracownicyAjax'));
  969. }
  970. public function fetchGroupPracownicyAjax() {
  971. $query = ACL::getAclByNamespace('default_db/BI_audit_ENERGA_PRACOWNICY_group/BI_audit_ENERGA_PRACOWNICY_group')->buildQuery([
  972. 'cols' => [ // TODO:? propertyName = []
  973. 'ID',
  974. 'ID_USER',
  975. 'NAZWA',
  976. ],
  977. 'f_ID_USER' => "=" . User::getID(), // szukamy dokładnie tej wartości - mysql: where ID_USER = "1"
  978. 'f_A_STATUS' => "!DELETED", // `A_STATUS` != 'DELETED'
  979. ]);
  980. $items = $query->getItems();
  981. if (empty($items)) throw new AlertWarningException("Grupy nie istnieją");
  982. $arrayGroupPracownicy = array();
  983. foreach ($items as $item) {
  984. // if (User::getID() != $item['ID_USER']) throw new Exception("Brak uprawnień do grupy"); // or skip - continue;
  985. $arrayGroupPracownicy[] = [
  986. 'ID' => $item['ID'],
  987. 'NAZWA' => $item['NAZWA'],
  988. ];
  989. }
  990. return [
  991. 'type' => 'success',
  992. 'msg' => 'fetchGroupPracownicyAjax',
  993. '__req_args' => $_REQUEST,
  994. '__args' => $args,
  995. 'body' => [
  996. 'itmesGroupPracownicy' => $arrayGroupPracownicy
  997. ]
  998. ];
  999. }
  1000. // link do ackji w php: $saveFormUrl = $this->getLink('saveRaportAjax');
  1001. // przekazać link do JavaScript i tam:
  1002. // window.fetch('{$saveFormUrl}', { ... }).then(...) - dokumentacja: https://github.com/github/fetch
  1003. public function generateBiAuditRaportAjaxAction() {
  1004. //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
  1005. Response::sendTryCatchJson(array($this, 'generateBiAuditRaportAjax'), $args = 'JSON_FROM_REQUEST_BODY');
  1006. //Response::sendTryCatchJson(array($this, 'generateBiAuditRaportAjax'));
  1007. }
  1008. public function generateBiAuditRaportAjax($args) {
  1009. // głebokość powiazan
  1010. $depthValue = V::get('depthValue', '', $args);
  1011. if (!$depthValue) {
  1012. throw new Exception("Nie podano wartości dla głębokości powiązań");
  1013. }
  1014. // Tworzenie relacji Raport do Pracownicy
  1015. $pracownicyIds = []; // array z nr ID na podstawie wysłanego formularza
  1016. $pracownicyIds = V::get('pracownicyIds', '', $args);
  1017. // walidacja id pracowników
  1018. if (!$pracownicyIds) {
  1019. throw new Exception("Nie wybrano pracowników");
  1020. }
  1021. $kontrahenciIds = []; // array z nr ID na podstawie wysłanego formularza
  1022. $kontrahenciIds = V::get('kontrahenciIds', '', $args);
  1023. // walidacja id kontrahetów
  1024. if (!$kontrahenciIds) {
  1025. throw new Exception("Nie wybrano kontrahentów");
  1026. }
  1027. // Tworzenie rekrodu w bazie - Raport -
  1028. $idRaport = DB::getPDO()->insert('BI_audit_ENERGA_RUM_KONTRAHENCI_POWIAZANIA', [
  1029. 'A_RECORD_CREATE_AUTHOR' => User::getLogin(),
  1030. 'A_RECORD_CREATE_DATE' => 'NOW()',
  1031. 'FILE_STATUS' => "TO_GENERATE",
  1032. 'BI_analiza_minDepth' => 1,
  1033. 'BI_analiza_maxDepth' => $depthValue
  1034. ]);
  1035. if ($idRaport > 0) {
  1036. DB::getPDO()->insert('BI_audit_ENERGA_RUM_KONTRAHENCI_POWIAZANIA_HIST', [
  1037. 'ID_USERS2' => $idRaport,
  1038. 'A_RECORD_CREATE_AUTHOR' => User::getLogin(),
  1039. 'A_RECORD_CREATE_DATE' => 'NOW()',
  1040. 'FILE_STATUS' => "TO_GENERATE",
  1041. 'BI_analiza_minDepth' => 1,
  1042. 'BI_analiza_maxDepth' => $depthValue
  1043. ]);
  1044. }
  1045. // Tworzenie relacji Raport do Pracownicy
  1046. $refPowiazaniaToPracownicy = ACL::getRefTable('default_db/BI_audit_ENERGA_RUM_KONTRAHENCI_POWIAZANIA/BI_audit_ENERGA_RUM_KONTRAHENCI_POWIAZANIA',
  1047. 'default_db__x3A__BI_audit_ENERGA_PRACOWNICY:BI_audit_ENERGA_PRACOWNICY');
  1048. foreach ($pracownicyIds as $idPracownik) {
  1049. DB::getPDO()->insert($refPowiazaniaToPracownicy, ['PRIMARY_KEY' => $idRaport, 'REMOTE_PRIMARY_KEY' => $idPracownik]);
  1050. }
  1051. // Tworzenie relacji Raport do Kontrahenci - analogicznie jak wyżej
  1052. $refPowiazaniaToKontrahenci = ACL::getRefTable('default_db/BI_audit_ENERGA_RUM_KONTRAHENCI_POWIAZANIA/BI_audit_ENERGA_RUM_KONTRAHENCI_POWIAZANIA',
  1053. 'default_db__x3A__BI_audit_ENERGA_RUM_KONTRAHENCI:BI_audit_ENERGA_RUM_KONTRAHENCI');
  1054. foreach ($kontrahenciIds as $idKontrahent) {
  1055. DB::getPDO()->insert($refPowiazaniaToKontrahenci, ['PRIMARY_KEY' => $idRaport, 'REMOTE_PRIMARY_KEY' => $idKontrahent ]);
  1056. }
  1057. // ...
  1058. return [
  1059. 'msg' => "Zadanie do wygnerowania raportu zostało zapisane.",
  1060. 'type' => "success",
  1061. 'body' => [
  1062. 'id' => $idRaport,
  1063. ]
  1064. ];
  1065. }
  1066. /**
  1067. * Widok formularza dodawania pracowników i kontrahentów
  1068. */
  1069. public function defaultViewFormBiAudit($items, $type) {
  1070. $activeFormSteps = '';
  1071. switch($type) {
  1072. case 'KONTRAHENCI':
  1073. $activeFormStepsKontrahent = 'complete';
  1074. $titleHeader = 'KONTRAHENCI';
  1075. $groupFilterList = '
  1076. <div class="menu-item">
  1077. <ul class="padding-0">
  1078. <li><a href="#" title="STWÓRZ GRUPĘ" class="btn btn-default" onClick="createGroupKontrahenci(event)" data-color-noactive="">+ STWÓRZ GRUPĘ</a></li>
  1079. </ul>
  1080. </div>
  1081. <div id="group-kontrahenci" class="btn-group">
  1082. <button class="btn btn-default active" title="Wszyscy" data-group-filter="0">Wszyscy</button>
  1083. </div>';
  1084. $formFilterHeadTitle = '<h2 class="title" id="smad-filter-head-title-kontrahenci">Wszyscy</h2>';
  1085. $formFilterHeadDesc = '<p>Liczba pozycji na liście: <span id="smad-filter-desc-kontrahenci">0</span></p>';
  1086. $countSelectedItem = '<div>Wybrano: <span id="count-selected-item-kontrahenci">0</span> <span><a title="wyczyść zapamietanych kontrahentów" class="link-primary" onClick="clearListLocalStorageByType(\'kontrahenci\')"><small>(wyczyść)</small></a></span></div>';
  1087. $csvExampleKontrahenci = Request::getPathUri() . 'projects/bocian/theme/assets/file_example/kontrahenci_example.zip';
  1088. $formAddNewData ='
  1089. <li><a title="IMPORT KONTRAHENCI" onClick="showViewUploadFile(event, \'Import kontrahentów\', \'kontrahenci\', \'no\', \''.$csvExampleKontrahenci.'\' )" class="btn btn-info">IMPORT KONTRAHENCI</a></li>
  1090. <!--<li><a href="#" title="DODAJ KONTRAHENCI" class="btn btn-info">+ DODAJ KONTRAHENCI</a></li>-->'; //todo: dodać obsługe doddawania kontrahentow
  1091. $buttonMoveToGroup = '<a title="PRZENIEŚ DO GRUPY" onClick="addKontrahenciToGroup(event)" class="btn btn-info">PRZENIEŚ DO GRUPY</a>';
  1092. $showButtonNextStep = '<button type="button" class="btn btn-primary" onClick="generateBiAuditRaport(event)" id="button-generate-reaport">SZUKAJ POWIĄZAŃ</button>';
  1093. $pagination_form = '<div id="pagination-kontrahenci"></div>';
  1094. break;
  1095. case 'PRACOWNICY':
  1096. $titleHeader = 'PRACOWNICY';
  1097. $groupFilterList = '
  1098. <div class="menu-item">
  1099. <ul class="padding-0">
  1100. <li><a href="#" title="STWÓRZ GRUPĘ" class="btn btn-default" onClick="createGroupPracownicy(event)" >+ STWÓRZ GRUPĘ</a></li>
  1101. </ul>
  1102. </div>
  1103. <div id="group-pracownicy" class="btn-group">
  1104. <button class="btn btn-default active" title="Wszyscy" data-group-filter="0">Wszyscy</button>
  1105. </div>';
  1106. $formFilterHeadTitle = '<h2 class="title" id="smad-filter-head-title-pracownicy">Wszyscy</h2>';
  1107. $formFilterHeadDesc = '<p>Liczba pozycji na liście: <span id="smad-filter-desc-pracownicy">0</span></p>';
  1108. $countSelectedItem = '<div>Wybrano: <span id="count-selected-item-pracownicy">0</span> <span><a title="wyczyść zapamietanych pracowników" class="link-primary" onClick="clearListLocalStorageByType(\'pracownicy\')"><small>(wyczyść)</small></a></span></div>';
  1109. $csvExamplePracownicy = Request::getPathUri() . 'projects/bocian/theme/assets/file_example/pracownicy_example.zip';
  1110. $formAddNewData ='
  1111. <li><a title="IMPORT PRACOWNIKÓW" onClick="showViewUploadFile(event, \'Import pracowników\', \'pracownicy\', \'yes\', \''.$csvExamplePracownicy.'\' )" class="btn btn-info">IMPORT PRACOWNIKÓW</a></li>
  1112. <!--<li><a href="#" title="DODAJ PRACOWNIKÓW" class="btn btn-info" >+ DODAJ PRACOWNIKÓW</a></li>-->'; //todo: dodać obsługe doddawania pracownikow
  1113. $buttonMoveToGroup = '<a title="PRZENIEŚ DO GRUPY" onClick="addPracownikToGroup(event)" class="btn btn-info">PRZENIEŚ DO GRUPY</a>';
  1114. $showButtonNextStep = '<a href="'.Request::getPathUri().'index.php?_route=UrlAction_Bocian#KONTRAHENCI" title="DODAJ DO ANALIZY" class="btn btn-primary">DODAJ DO ANALIZY</a>';
  1115. $pagination_form = '<div id="pagination-pracownicy"></div>';
  1116. break;
  1117. }
  1118. $view = '
  1119. <!-- start:employees-section-->
  1120. <div id="smad-employees-section" class="smad-form-' . $type . '" >
  1121. <div class="container-fluid">
  1122. <div>
  1123. <div class="padding-lr-0">
  1124. <div id="smad-menu-section">
  1125. <div class="col-sm-12 col-md-6 padding-lr-0">
  1126. <div class="menu-items">
  1127. <div class="smad-heder-title menu-item"><span class="smad-line-red">|</span> ' . $titleHeader . ' </div>
  1128. </div>
  1129. </div>
  1130. <div class="col-sm-12 col-md-6 padding-lr-0">
  1131. <div class="form-steps">
  1132. <!-- start:form steps wizard -->
  1133. <div class="row smad-wizard" style="border-bottom:0;">
  1134. <div class="col-xs-4 col-md-4 smad-wizard-step complete"><!-- complited line -->
  1135. <div class="text-center smad-wizard-stepnum">&nbsp;</div>
  1136. <div class="progress"><div class="progress-bar"></div></div>
  1137. <a href="'.Request::getPathUri().'index.php?_route=UrlAction_Bocian#PRACOWNICY" class="smad-wizard-dot"></a>
  1138. <div class="smad-wizard-info complete text-center">
  1139. <div class="step-item"><a href="'.Request::getPathUri().'index.php?_route=UrlAction_Bocian#PRACOWNICY">Krok 1</a></div>
  1140. <div class="step-title">PRACOWNICY <span class="top--count-selected-item-pracownicy"></span></div>
  1141. </div>
  1142. </div>
  1143. <div class="col-xs-4 col-md-4 smad-wizard-step ' . $activeFormStepsKontrahent . ' ">
  1144. <div class="text-center smad-wizard-stepnum">&nbsp;</div>
  1145. <div class="progress"><div class="progress-bar"></div></div>
  1146. <a href="'.Request::getPathUri().'index.php?_route=UrlAction_Bocian#KONTRAHENCI" class="smad-wizard-dot"></a>
  1147. <div class="smad-wizard-info text-center">
  1148. <div class="step-item"><a href="'.Request::getPathUri().'index.php?_route=UrlAction_Bocian#KONTRAHENCI">Krok 2</a></div>
  1149. <div class="step-title">KONTRAHENCI <span class="top--count-selected-item-kontrahenci"></span></div>
  1150. </div>
  1151. </div>
  1152. <div class="col-xs-4 col-md-4 smad-wizard-step ">
  1153. <div class="text-center smad-wizard-stepnum">&nbsp;</div>
  1154. <div class="progress"><div class="progress-bar"></div></div>
  1155. <a href="#" class="smad-wizard-dot"></a>
  1156. <div class="smad-wizard-info text-center">
  1157. <div class="step-item">Krok 3</div>
  1158. <div class="step-title">SZUKANIE POWIĄZAŃ</div>
  1159. </div>
  1160. </div>
  1161. </div>
  1162. <!-- end:form steps wizard -->
  1163. </div>
  1164. </div>
  1165. </div>
  1166. </div>
  1167. </div>
  1168. </div>
  1169. <div class="container-fluid">
  1170. <div class=" padding-lr-0">
  1171. <div class="smad-divider"></div>
  1172. </div>
  1173. </div>
  1174. <!-- start:filters -->
  1175. <div class="container-fluid">
  1176. <div class="row">
  1177. <div>
  1178. <div class="smad-employees-form-section" class="border-top-grey">
  1179. <div class="col-md-9 smad-border-col">
  1180. <div class="menu-items">
  1181. '.$groupFilterList.'
  1182. </div>
  1183. </div>
  1184. <div class="col-md-3">
  1185. <div class="form-input">
  1186. <div class="form-item col-md-6 smad-heder-title">głębokość powiązań:</div>
  1187. <div class="form-item col-md-6">
  1188. <input type="text" class="form-control smad-depth" placeholder="1-16" value="" />
  1189. </div>
  1190. </div>
  1191. </div>
  1192. </div>
  1193. </div>
  1194. </div>
  1195. </div>
  1196. <!-- end:filters -->
  1197. <!-- start:list employees -->
  1198. <div class="container-fluid">
  1199. <div class="padding-0 smad-employees-list-head">
  1200. <div class="col-md-6">
  1201. <header>
  1202. '.$formFilterHeadTitle.'
  1203. </header>
  1204. <div class="desc">
  1205. '.$formFilterHeadDesc.'
  1206. </div>
  1207. <div class="countSelectedItem">
  1208. '.$countSelectedItem.'
  1209. </div>
  1210. </div>
  1211. <div class="col-md-6">
  1212. <div class="menu-items">
  1213. <div class="menu-item">
  1214. <ul class="padding-0">
  1215. '.$formAddNewData.'
  1216. </ul>
  1217. </div>
  1218. </div>
  1219. </div>
  1220. </div>
  1221. </div>
  1222. <div class="container-fluid">
  1223. <div class="table-responsive padding-0" id="smad-table-' . $type . '">
  1224. ' . $this->showListDataByType($items, $type) . '
  1225. </div>
  1226. </div>
  1227. <!-- end:list employees -->
  1228. <!-- start:list paginations employees -->
  1229. <div class="container-fluid ">
  1230. <div>
  1231. '. $pagination_form .'
  1232. </div>
  1233. </div>
  1234. <!-- end:list paginations employees -->
  1235. <!-- start:bottom buttons -->
  1236. <div class="container-fluid smad-employees-bottom-navigation">
  1237. <div class="padding-0">
  1238. <div class="col-lg-6 ">
  1239. '.$buttonMoveToGroup.'
  1240. </div>
  1241. <div class="col-lg-6 text-right">
  1242. ' . $showButtonNextStep . '
  1243. </div>
  1244. </div>
  1245. </div>
  1246. <!-- end:bottom buttons -->
  1247. </div>
  1248. <!-- start:employees-section -->
  1249. ';
  1250. return $view;
  1251. }
  1252. public function showListDataByType($items, $type='PRACOWNICY') {
  1253. switch ($type) {
  1254. case 'PRACOWNICY':
  1255. return $this->showTablePracownicy();
  1256. break;
  1257. case 'KONTRAHENCI':
  1258. return $this->showTableKontrahenci($items);
  1259. break;
  1260. }
  1261. }
  1262. }