|
@@ -0,0 +1,367 @@
|
|
|
+<?php
|
|
|
+
|
|
|
+Lib::loadClass('RouteBase');
|
|
|
+Lib::loadClass('UI');
|
|
|
+Lib::loadClass('Response');
|
|
|
+
|
|
|
+// index.php?_route=UrlAction_BiAuditRaport - uruchamia defaultAction
|
|
|
+class Route_UrlAction_BiAuditRaport extends RouteBase {
|
|
|
+
|
|
|
+ public function defaultAction() {
|
|
|
+ UI::topSection();
|
|
|
+ UI::startContainer();
|
|
|
+
|
|
|
+ echo '<div class="container-bi_audit_raport"></div>';
|
|
|
+ try {
|
|
|
+
|
|
|
+ $items = ACL::getAclByNamespace('default_db/BI_audit_ENERGA_RUM_KONTRAHENCI_POWIAZANIA/BI_audit_ENERGA_RUM_KONTRAHENCI_POWIAZANIA')->buildQuery([
|
|
|
+ 'cols' => [ // TODO:? propertyName = []
|
|
|
+ 'ID',
|
|
|
+ 'L_APPOITMENT_USER',
|
|
|
+ 'default_db__x3A__BI_audit_ENERGA_PRACOWNICY:BI_audit_ENERGA_PRACOWNICY',
|
|
|
+ 'default_db__x3A__BI_audit_ENERGA_RUM_KONTRAHENCI:BI_audit_ENERGA_RUM_KONTRAHENCI',
|
|
|
+ 'default_db__x3A__BI_audit_ENERGA_RUM_KONTRAHENCI_POWIAZANIA_row:BI_audit_ENERGA_RUM_KONTRAHENCI_POWIAZANIA_row',
|
|
|
+ 'default_db__x3A__BI_audit_KW_requested_person:BI_audit_KW_requested_person',
|
|
|
+ ]
|
|
|
+ ])->getItems([
|
|
|
+ 'limit' => 10
|
|
|
+ ]);
|
|
|
+
|
|
|
+ DBG::nicePrint($items, '$items BiAudit');
|
|
|
+
|
|
|
+ UI::inlineJS(__FILE__ . '.view.js', [
|
|
|
+ 'URL_FETCH_TEST' => $this->getLink('fetchEnergaRumKontrahenciPowiazaniaAjax'),
|
|
|
+ 'URL_FETCH_TEST_KRS' => $this->getLink('fetchTestKrsAjax'),
|
|
|
+ 'URL_FETCH_TEST_CEIDG' => $this->getLink('fetchTestCeidgAjax'),
|
|
|
+ 'URL_FETCH_PRACOWNICY' => $this->getLink('fetchPracownicyAjax'),
|
|
|
+ 'DBG' => V::get('DBG', 0, $_GET),
|
|
|
+ ]);
|
|
|
+
|
|
|
+
|
|
|
+ throw new Exception("TODO...");
|
|
|
+
|
|
|
+ } catch (Exception $e) {
|
|
|
+ DBG::log($e);
|
|
|
+ UI::alert('danger', $e->getMessage());
|
|
|
+ }
|
|
|
+ UI::endContainer();
|
|
|
+ UI::footerSection();
|
|
|
+ }
|
|
|
+
|
|
|
+ public function fetchEnergaRumKontrahenciPowiazaniaAjaxAction() {
|
|
|
+ Response::sendTryCatchJson(array($this, 'fetchEnergaRumKontrahenciPowiazaniaAjax')); // , $args = 'JSON_FROM_REQUEST_BODY');
|
|
|
+ }
|
|
|
+ public function fetchEnergaRumKontrahenciPowiazaniaAjax($args) {
|
|
|
+ $id = V::get('ID', 1, $_REQUEST, 'int');
|
|
|
+ $items = ACL::getAclByNamespace('default_db/BI_audit_ENERGA_RUM_KONTRAHENCI_POWIAZANIA/BI_audit_ENERGA_RUM_KONTRAHENCI_POWIAZANIA')->buildQuery([
|
|
|
+ 'cols' => [ // TODO:? propertyName = []
|
|
|
+ 'ID',
|
|
|
+ 'A_ADM_COMPANY',
|
|
|
+ 'L_APPOITMENT_USER',
|
|
|
+ 'A_CLASSIFIED',
|
|
|
+ 'A_STATUS',
|
|
|
+ 'A_STATUS_INFO',
|
|
|
+ 'BI_analiza_depth',
|
|
|
+ 'BI_analiza_reloadCache',
|
|
|
+ 'FILE_STATUS',
|
|
|
+ 'FILE_STATUS_info',
|
|
|
+ 'L_APPOITMENT_USER',
|
|
|
+ 'default_db__x3A__BI_audit_ENERGA_PRACOWNICY:BI_audit_ENERGA_PRACOWNICY',
|
|
|
+ 'default_db__x3A__BI_audit_ENERGA_RUM_KONTRAHENCI:BI_audit_ENERGA_RUM_KONTRAHENCI',
|
|
|
+ 'default_db__x3A__BI_audit_ENERGA_RUM_KONTRAHENCI_POWIAZANIA_row:BI_audit_ENERGA_RUM_KONTRAHENCI_POWIAZANIA_row',
|
|
|
+ 'default_db__x3A__BI_audit_KW_requested_person:BI_audit_KW_requested_person',
|
|
|
+ ],
|
|
|
+ //'f_ID' => $id,
|
|
|
+ ])->getItems([
|
|
|
+ 'limit' => 10
|
|
|
+ ]);
|
|
|
+
|
|
|
+ // $items = [
|
|
|
+ // [ 'ID' => 1, 'L_APPOITMENT_INFO' => 'x', 'BI_analiza_depth' => 'a', 'FILE_STATUS' => 1, 'FILE_STATUS_info' => 'test1'],
|
|
|
+ // [ 'ID' => 2, 'L_APPOITMENT_INFO' => 'y', 'BI_analiza_depth' => 'b', 'FILE_STATUS' => 0, 'FILE_STATUS_info' => 'test2'],
|
|
|
+ // [ 'ID' => 3, 'L_APPOITMENT_INFO' => 'z', 'BI_analiza_depth' => 'c', 'FILE_STATUS' => 1, 'FILE_STATUS_info' => 'test3'],
|
|
|
+ // ];
|
|
|
+
|
|
|
+ return [
|
|
|
+ 'type' => 'success',
|
|
|
+ 'msg' => 'OK',
|
|
|
+ '__req_args' => $_REQUEST,
|
|
|
+ '__args' => $args,
|
|
|
+ 'body' => [
|
|
|
+ 'items' => $items,
|
|
|
+ 'view' => $this->showPowiazaniaEnergaRumKontrahenciPowiazania($items),
|
|
|
+ ]
|
|
|
+ ];
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+public function showPowiazaniaEnergaRumKontrahenciPowiazania($items) {
|
|
|
+
|
|
|
+ $view = '<form class="form-horizontal" method="post">
|
|
|
+ <table class="table table-bordered table-hover table-striped" height=5>
|
|
|
+ <thead>
|
|
|
+ <tr style="text-align:center; background-color:lightgray">
|
|
|
+ <td width=1><input type="checkbox" name="checkAll" id="checkAll" /></td>
|
|
|
+ <td width=1>ID</td>
|
|
|
+ <td>Adnotacje</td>
|
|
|
+ <td>Głębokość analizy</td>
|
|
|
+ <td>Status raportu</td>
|
|
|
+ <td>Status raportu - informacje</td>
|
|
|
+ </tr>
|
|
|
+ </thead>
|
|
|
+ <tbody>
|
|
|
+ ';
|
|
|
+
|
|
|
+ foreach ($items as $key => $row) {
|
|
|
+ $view .= '<tr>
|
|
|
+ <td><input type="checkbox" name="prID[]" value="'.$row['ID'].'" onClick="checkAll()"/></td>
|
|
|
+ <td align="right">'.$row["ID"].'</td>
|
|
|
+ <td align="right">'.$row["L_APPOITMENT_INFO"].'</td>
|
|
|
+ <td align="right">'.$row["BI_analiza_depth"].'</td>
|
|
|
+ <td align="right">'.$row["FILE_STATUS"].'</td>
|
|
|
+ <td align="right">'.$row["FILE_STATUS_info"].'</td>';
|
|
|
+ }
|
|
|
+ $view .= '</tbody></table></form>';
|
|
|
+
|
|
|
+
|
|
|
+ return $view;
|
|
|
+}
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+ public function fetchTestKrsAjaxAction() {
|
|
|
+ Response::sendTryCatchJson(array($this, 'fetchTestKrsAjax')); // , $args = 'JSON_FROM_REQUEST_BODY');
|
|
|
+ }
|
|
|
+ public function fetchTestKrsAjax($args) {
|
|
|
+ $id = V::get('ID', 1, $_REQUEST, 'int');
|
|
|
+ $items = ACL::getAclByNamespace('default_db/BI_audit_KRS/BI_audit_KRS')->buildQuery([
|
|
|
+ 'cols' => [ // TODO:? propertyName = []
|
|
|
+ 'A_kod',
|
|
|
+ 'A_kraj',
|
|
|
+ 'A_miejscowosc',
|
|
|
+ 'A_nrDomu',
|
|
|
+ 'A_nrLokalu',
|
|
|
+ 'A_poczta',
|
|
|
+ 'A_ulica',
|
|
|
+ 'ID',
|
|
|
+ 'S_gmina',
|
|
|
+ 'S_kraj',
|
|
|
+ 'S_miejscowosc',
|
|
|
+ 'S_powiat',
|
|
|
+ 'S_wojewodztwo',
|
|
|
+ 'dataDokumentu',
|
|
|
+ 'default_db__x3A__BI_audit_KRS_company:BI_audit_KRS_company/ID',
|
|
|
+ 'default_db__x3A__BI_audit_KRS_company:BI_audit_KRS_company/krs',
|
|
|
+ 'default_db__x3A__BI_audit_KRS_company:BI_audit_KRS_company/nazwa',
|
|
|
+ 'default_db__x3A__BI_audit_KRS_company:BI_audit_KRS_company/regon',
|
|
|
+ 'default_db__x3A__BI_audit_KRS_person:BI_audit_KRS_person/ID',
|
|
|
+ 'default_db__x3A__BI_audit_KRS_person:BI_audit_KRS_person/imiona',
|
|
|
+ 'default_db__x3A__BI_audit_KRS_person:BI_audit_KRS_person/nazwisko',
|
|
|
+ 'default_db__x3A__BI_audit_KRS_person:BI_audit_KRS_person/pesel',
|
|
|
+ 'krs',
|
|
|
+ 'nazwa',
|
|
|
+ 'nip',
|
|
|
+ 'regon',
|
|
|
+ ],
|
|
|
+ 'f_ID' => "{$id}",
|
|
|
+ ])->getItems([
|
|
|
+ 'limit' => 10
|
|
|
+ ]);
|
|
|
+
|
|
|
+ return [
|
|
|
+ 'type' => 'success',
|
|
|
+ 'msg' => 'KRS',
|
|
|
+ '__req_args' => $_REQUEST,
|
|
|
+ '__args' => $args,
|
|
|
+ 'body' => [
|
|
|
+ 'items' => $items,
|
|
|
+ ]
|
|
|
+ ];
|
|
|
+ }
|
|
|
+
|
|
|
+ public function fetchTestCeidgAjaxAction() {
|
|
|
+ Response::sendTryCatchJson(array($this, 'fetchTestCeidgAjax')); // , $args = 'JSON_FROM_REQUEST_BODY');
|
|
|
+ }
|
|
|
+ public function fetchTestCeidgAjax($args) {
|
|
|
+ $id = V::get('ID', 0, $_REQUEST, 'int');
|
|
|
+ $items = ACL::getAclByNamespace('default_db/BI_audit_CEIDG/BI_audit_CEIDG')->buildQuery([
|
|
|
+ 'cols' => [ // TODO:? propertyName = []
|
|
|
+ 'ID',
|
|
|
+ 'budynek',
|
|
|
+ 'firma',
|
|
|
+ 'gmina',
|
|
|
+ 'identyfikatorWpisu',
|
|
|
+ 'imie',
|
|
|
+ 'kodPocztowy',
|
|
|
+ 'kraj',
|
|
|
+ 'lokal',
|
|
|
+ 'miejscowosc',
|
|
|
+ 'nazwisko',
|
|
|
+ 'nip',
|
|
|
+ 'poczta',
|
|
|
+ 'powiat',
|
|
|
+ 'regon',
|
|
|
+ 'ulica',
|
|
|
+ 'default_db__x3A__BI_audit_CEIDG_pelnomocnicy:BI_audit_CEIDG_pelnomocnicy/ID',
|
|
|
+ 'default_db__x3A__BI_audit_CEIDG_pelnomocnicy:BI_audit_CEIDG_pelnomocnicy/budynek',
|
|
|
+ 'default_db__x3A__BI_audit_CEIDG_pelnomocnicy:BI_audit_CEIDG_pelnomocnicy/gmina',
|
|
|
+ 'default_db__x3A__BI_audit_CEIDG_pelnomocnicy:BI_audit_CEIDG_pelnomocnicy/kodPocztowy',
|
|
|
+ 'default_db__x3A__BI_audit_CEIDG_pelnomocnicy:BI_audit_CEIDG_pelnomocnicy/lokal',
|
|
|
+ 'default_db__x3A__BI_audit_CEIDG_pelnomocnicy:BI_audit_CEIDG_pelnomocnicy/miejscowosc',
|
|
|
+ 'default_db__x3A__BI_audit_CEIDG_pelnomocnicy:BI_audit_CEIDG_pelnomocnicy/nazwa',
|
|
|
+ 'default_db__x3A__BI_audit_CEIDG_pelnomocnicy:BI_audit_CEIDG_pelnomocnicy/nip',
|
|
|
+ 'default_db__x3A__BI_audit_CEIDG_pelnomocnicy:BI_audit_CEIDG_pelnomocnicy/poczta',
|
|
|
+ 'default_db__x3A__BI_audit_CEIDG_pelnomocnicy:BI_audit_CEIDG_pelnomocnicy/powiat',
|
|
|
+ 'default_db__x3A__BI_audit_CEIDG_pelnomocnicy:BI_audit_CEIDG_pelnomocnicy/ulica',
|
|
|
+ 'default_db__x3A__BI_audit_CEIDG_pelnomocnicy:BI_audit_CEIDG_pelnomocnicy/wojewodztwo',
|
|
|
+ 'default_db__x3A__BI_audit_CEIDG_powiazania:BI_audit_CEIDG_powiazania/ID',
|
|
|
+ 'default_db__x3A__BI_audit_CEIDG_powiazania:BI_audit_CEIDG_powiazania/nip',
|
|
|
+ 'default_db__x3A__BI_audit_CEIDG_powiazania:BI_audit_CEIDG_powiazania/regon',
|
|
|
+ ],
|
|
|
+ // 'f_ID' => $id,
|
|
|
+ ])->getItems([
|
|
|
+ 'limit' => 10
|
|
|
+ ]);
|
|
|
+
|
|
|
+ return [
|
|
|
+ 'type' => 'success',
|
|
|
+ 'msg' => 'CEIDG',
|
|
|
+ '__req_args' => $_REQUEST,
|
|
|
+ '__args' => $args,
|
|
|
+ 'body' => [
|
|
|
+ 'items' => $items,
|
|
|
+ ]
|
|
|
+ ];
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+ public function fetchPracownicyAjaxAction() {
|
|
|
+ Response::sendTryCatchJson(array($this, 'fetchPracownicyAjax'));
|
|
|
+ }
|
|
|
+
|
|
|
+ public function fetchPracownicyAjax($args) {
|
|
|
+ $id = V::get('ID', 1, $_REQUEST, 'int');
|
|
|
+ $items = ACL::getAclByNamespace('default_db/BI_audit_ENERGA_PRACOWNICY/BI_audit_ENERGA_PRACOWNICY')->buildQuery([
|
|
|
+ 'cols' => [ // TODO:? propertyName = []
|
|
|
+ 'ID',
|
|
|
+ 'imiona',
|
|
|
+ 'nazwisko',
|
|
|
+ 'nip',
|
|
|
+ 'pesel',
|
|
|
+ 'regon',
|
|
|
+ 'A_ADM_COMPANY',
|
|
|
+ 'A_STATUS',
|
|
|
+ 'default_db__x3A__BI_audit_ENERGA_PRACOWNICY_adresy:BI_audit_ENERGA_PRACOWNICY_adresy/*'
|
|
|
+ ],
|
|
|
+ //'f_ID' => $id,
|
|
|
+ ])->getItems([
|
|
|
+ 'limit' => 10
|
|
|
+ ]);
|
|
|
+
|
|
|
+ return [
|
|
|
+ 'type' => 'success',
|
|
|
+ 'msg' => 'showPracownicy',
|
|
|
+ '__req_args' => $_REQUEST,
|
|
|
+ '__args' => $args,
|
|
|
+ 'body' => [
|
|
|
+ 'items' => $items,
|
|
|
+ 'view' => $this->showPracownicy($items),
|
|
|
+ ]
|
|
|
+ ];
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ public function showPracownicy($items) {
|
|
|
+ $view = '<form class="form-horizontal" method="post">
|
|
|
+ <table class="table table-bordered table-hover table-striped" height=5>
|
|
|
+ <thead>
|
|
|
+ <tr style="text-align:center; background-color:lightgray">
|
|
|
+ <td width=1><input type="checkbox" name="checkAll" id="checkAll" /></td>
|
|
|
+ <td width=1>ID</td>
|
|
|
+ <td>Imię/Imiona</td>
|
|
|
+ <td>Nazwisko</td>
|
|
|
+ <td>NIP</td>
|
|
|
+ <td>Pesel</td>
|
|
|
+ <td>Regon</td>
|
|
|
+ <td>A_ADM_COMPANY</td>
|
|
|
+ <td>A_STATUS</td>
|
|
|
+ <td>Adresy</td>
|
|
|
+ </tr>
|
|
|
+ </thead>
|
|
|
+ <tbody>
|
|
|
+ ';
|
|
|
+
|
|
|
+ foreach ($items as $key => $row) {
|
|
|
+ $view .= '<tr>
|
|
|
+ <td><input type="checkbox" name="prID[]" value="'.$row['ID'].'" /></td>
|
|
|
+ <td align="right">'.$row["ID"].'</td>
|
|
|
+ <td align="right">'.$row["imiona"].'</td>
|
|
|
+ <td align="right">'.$row["nazwisko"].'</td>
|
|
|
+ <td align="right">'.$row["nip"].'</td>
|
|
|
+ <td align="right">'.$row["pesel"].'</td>
|
|
|
+ <td align="right">'.$row["regon"].'</td>
|
|
|
+ <td align="right">'.$row["A_ADM_COMPANY"].'</td>
|
|
|
+ <td align="right">'.$row["A_STATUS"].'</td>
|
|
|
+ <td align="right">'.$row["default_db__x3A__BI_audit_ENERGA_PRACOWNICY_adresy:BI_audit_ENERGA_PRACOWNICY_adresy"].'</td>
|
|
|
+
|
|
|
+ ';
|
|
|
+ }
|
|
|
+ $view .= '</tbody></table></form>';
|
|
|
+
|
|
|
+ return $view;
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ // link do ackji w php: $saveFormUrl = $this->getLink('saveRaportAjax');
|
|
|
+ // przekazać link do JavaScript i tam:
|
|
|
+ // window.fetch('{$saveFormUrl}', { ... }).then(...) - dokumentacja: https://github.com/github/fetch
|
|
|
+ public function saveRaportAjaxAction() {
|
|
|
+ // 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
|
|
|
+ Response::sendTryCatchJson(array($this, 'saveRaportAjax'));
|
|
|
+ }
|
|
|
+ public function saveRaportAjax($args) {
|
|
|
+ // TODO: przejrzeć $args (jeśli JSON) lub $_POST
|
|
|
+ // Tworzenie rekrodu w bazie - Raport -
|
|
|
+ $idRaport = DB::getDB()->insert('BI_audit_ENERGA_RUM_KONTRAHENCI_POWIAZANIA', [
|
|
|
+ 'A_RECORD_CREATE_AUTHOR' => User::getLogin(),
|
|
|
+ 'A_RECORD_CREATE_DATE' => 'NOW()',
|
|
|
+ // 'A_STATUS' => 'WAITING', // jeśli trzeba to ustawić
|
|
|
+
|
|
|
+ ]);
|
|
|
+
|
|
|
+ // TODO: validate args ...
|
|
|
+ // throw new Exception("Wrong field..."); // lub inny komunikat błędu - spowoduje wysłanie json-a { 'msg' => 'Wrong field...', 'type' => 'error' }
|
|
|
+
|
|
|
+
|
|
|
+ // Tworzenie relacji Raport do Pracownicy
|
|
|
+ $pracownicyIds = []; // TODO: array z nr ID na podstawie wysłanego formularza
|
|
|
+ $refPowiazaniaToPracownicy = ACL::getRefTable('default_db/BI_audit_ENERGA_RUM_KONTRAHENCI_POWIAZANIA/BI_audit_ENERGA_RUM_KONTRAHENCI_POWIAZANIA',
|
|
|
+ 'default_db__x3A__BI_audit_ENERGA_PRACOWNICY:BI_audit_ENERGA_PRACOWNICY');
|
|
|
+ foreach ($pracownicyIds as $idPracownik) {
|
|
|
+ DB::getPDO()->insert($refPowiazaniaToPracownicy, ['PRIMARY_KEY' => $idRaport, 'REMOTE_PRIMARY_KEY' => $idPracownik]);
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ // Tworzenie relacji Raport do Kontrahenci - analogicznie jak wyżej
|
|
|
+ $kontrahenciIds = []; // TODO: array z nr ID na podstawie wysłanego formularza
|
|
|
+ $refPowiazaniaToKontrahenci = ACL::getRefTable('default_db/BI_audit_ENERGA_RUM_KONTRAHENCI_POWIAZANIA/BI_audit_ENERGA_RUM_KONTRAHENCI_POWIAZANIA',
|
|
|
+ 'default_db__x3A__BI_audit_ENERGA_RUM_KONTRAHENCI:BI_audit_ENERGA_RUM_KONTRAHENCI');
|
|
|
+ foreach ($kontrahenciIds as $idKontrahent) {
|
|
|
+ DB::getPDO()->insert($refPowiazaniaToKontrahenci, ['PRIMARY_KEY' => $idRaport, 'REMOTE_PRIMARY_KEY' => $idKontrahent]);
|
|
|
+ }
|
|
|
+
|
|
|
+ // ...
|
|
|
+
|
|
|
+ return [
|
|
|
+ 'msg' => "Utworzono raport",
|
|
|
+ 'type' => "success",
|
|
|
+ 'body' => [
|
|
|
+ 'id' => $idRaport,
|
|
|
+ ]
|
|
|
+ ];
|
|
|
+ }
|
|
|
+
|
|
|
+}
|