'; /*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::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), ]); //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 = '
'; 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->htmlViewEmployees($items) ] ]; } public function showPracownicy($items) { $view = ''; 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, ] ]; } public function htmlViewEmployees($items) { $viewEployees = '