12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814 |
- <?php
- Lib::loadClass('RouteToolBase');
- Lib::loadClass('UI');
- Lib::loadClass('Response');
- Lib::loadClass('Request');
- class RouteTool_Bocian extends RouteToolBase {
- public static $helpEmailTo = 'biuro@bialnet.com.pl';
- public static $FIELD_LIST_PRACOWNICY = [
- 'ID',
- 'imiona',
- 'nazwisko',
- 'nip',
- 'pesel',
- 'regon',
- 'source',
- 'jednostka_organizacyjna',
- 'A_STATUS',
- 'A_STATUS_INFO',
- 'L_APPOITMENT_USER',
-
- ];
- public static $FIELD_LIST_KONTRAHENCI = [
- 'ID',
- 'Nazwa_grupy_kapitalowej',
- 'Pelna_nazwa_kontrahenta',
- 'Numer_kontrahenta',
- 'Skrocona_Nazwa_Kontrahenta',
- 'Typ_kontrahenta',
- 'NIP',
- 'KRS',
- 'REGON',
- 'PESEL',
- 'Forma_prawna_dzialalnosci',
- 'Ulica',
- 'Numer_budynku',
- 'Numer_mieszkania_lokalu',
- 'Miejscowosc',
- 'Kod_pocztowy',
- 'Kraj',
- 'Telefon',
- 'Fax',
- 'Mail',
- 'A_ADM_COMPANY',
- 'A_CLASSIFIED',
- 'Dodano',
- 'Podmiot_dominujacy',
- 'Tytul_dokumentu',
- 'ownCompany',
- 'uwagi',
- ];
- public function aboutAction() {
- UI::gora();
- echo UI::h('script', ['src'=>"static/sweetalert2.min.js"]);
- echo UI::h('link', ['rel'=>"stylesheet", 'type'=>"text/css", 'href'=>"static/sweetalert2.min.css"]);
- Theme::top();
- include('page-about.view.php');
- UI::dol();
- }
-
- public function trainingAction() {
- UI::gora();
- echo UI::h('script', ['src'=>"static/sweetalert2.min.js"]);
- echo UI::h('link', ['rel'=>"stylesheet", 'type'=>"text/css", 'href'=>"static/sweetalert2.min.css"]);
- Theme::top();
- include('page-training.view.php');
- UI::dol();
- }
-
- public function helpFormAction() {
- UI::gora();
- echo UI::h('script', ['src'=>"static/sweetalert2.min.js"]);
- echo UI::h('link', ['rel'=>"stylesheet", 'type'=>"text/css", 'href'=>"static/sweetalert2.min.css"]);
- Theme::top();
- $messageValidate = array();
- if( V::get('button_send', 0, $_POST) == 1 ){
-
- $helpName = htmlentities(V::get('help_name', 0, $_POST));
- $helpEmail = htmlentities(V::get('help_email', 0, $_POST));
- $helpDescription = htmlentities(V::get('help_description', 0, $_POST));
- if ( empty($helpDescription) && !filter_var($helpEmail, FILTER_VALIDATE_EMAIL)) {
- $messageValidate['error'] = 1;
- }
- $noticeRequest = 'Email: ' . $helpEmail . "; Treść zgłoszenia: " . $helpDescription;
-
- $idQualityNotice = DB::getPDO()->insert('QUALITY_NOTICES', [
- 'NOTICE_INITIAL_TYPE' => 'BAD_PROCESS',
- 'ID_PROCES' => '1',
- 'NOTICE_REQUEST' => $noticeRequest,
- 'NOTICE_REPLY' => '',
- 'NOTICE_REPLY_TYPE' => 'BAD_PROCESS',
- 'L_APPOITMENT_DATE' => 'NOW()',
- 'L_APPOITMENT_USER' => User::getLogin(),
- 'ADM_ACCOUNT' => User::getLogin(),
- 'THIS_SINGLE_WASTE_COST' => '',
- 'WASTE_COST_COMMENT' => '',
- 'THIS_SINGLE_FIX_COST' => '',
- 'YEAR_COST_FOREACST_OF_SUCH_PROBLEM_WITH_FIXING' => '',
- 'FIX_COST_COMMENT' => '',
- 'A_RECORD_CREATE_AUTHOR' => User::getLogin(),
- 'A_RECORD_CREATE_DATE' => 'NOW()'
- ]);
- if( $idQualityNotice > 0 ) {
- $messageValidate['success'] = 'send';
- } else {
- $messageValidate['error'] = 2;
- }
- }
- include('page-help.view.php');
- UI::dol();
- }
- public function defaultAction() {
- UI::gora();
- echo UI::h('script', ['src'=>"static/sweetalert2.min.js"]);
- echo UI::h('link', ['rel'=>"stylesheet", 'type'=>"text/css", 'href'=>"static/sweetalert2.min.css"]);
- Theme::top();
-
- echo '<div class="container-bi_audit_form_pracownicy_raport" style="display: none;"></div>';
- echo '<div class="container-bi_audit_form_kontrahenci_raport" style="display: none;"></div>';
-
- UI::inlineJS(__FILE__ . '.view.js', [
- 'BASE_URLS' => Request::getPathUri(),
- 'URL_FETCH_KONTRAHENCI_POWIAZANIA' => $this->getLink('fetchEnergaRumKontrahenciPowiazaniaAjax'),
- 'URL_FETCH_TEST_KRS' => $this->getLink('fetchTestKrsAjax'),
- 'URL_FETCH_TEST_CEIDG' => $this->getLink('fetchTestCeidgAjax'),
- 'URL_FETCH_PRACOWNICY' => $this->getLink('fetchPracownicyAjax'),
- 'URL_FETCH_PRACOWNICY_IDS_AJAX' => $this->getLink('fetchPracownicyIdsAjax'),
- 'URL_FETCH_KONTRAHENCI' => $this->getLink('fetchKontrahenciAjax'),
- 'URL_FETCH_KONTRAHENCI_IDS_AJAX' => $this->getLink('fetchKontrahenciIdsAjax'),
- 'URL_CREATE_PRACOWNICY_GROUP' => $this->getLink('createPracownicyGroupAjax'),
- 'URL_CREATE_KONTRAHENCIS_GROUP' => $this->getLink('createKontrahenciGroupAjax'),
- 'URL_ADD_PRACOWNICY_TO_GROUP' => $this->getLink('addPracownicyToGroupAjax'),
- 'URL_ADD_KONTRAHENCI_TO_GROUP' => $this->getLink('addKontrahenciToGroupAjax'),
- 'URL_FETCH_GROUP_PRACOWNICY' => $this->getLink('fetchGroupPracownicyAjax'),
- 'URL_FETCH_GROUP_KONTRAHENCI' => $this->getLink('fetchGroupKontrahenciAjax'),
- 'URL_GENERATE_BI_AUDIT_RAPORT_AJAX' => $this->getLink('generateBiAuditRaportAjax'),
- 'DBG' => V::get('DBG', 0, $_GET),
- 'VIEW_KONTRAHENCI' => $this->defaultViewFormBiAudit([], 'KONTRAHENCI'),
- 'VIEW_PRACOWNICY' => $this->defaultViewFormBiAudit([], 'PRACOWNICY'),
- 'URL_FORM_DATA_CSV_FILE_AJAX' => $this->getLink('formDataCsvFileAjax'),
- 'URL_SAVE_FORM_CSV_FILE_AJAX' => $this->getLink('saveFormCsvFileAjax'),
- 'URL_TABLE_POWIAZANIA' => Router::getRoute('ViewTableAjax', [ 'namespace' => "default_db/BI_audit_ENERGA_RUM_KONTRAHENCI_POWIAZANIA/BI_audit_ENERGA_RUM_KONTRAHENCI_POWIAZANIA" ]),
- 'FIELD_LIST_PRACOWNICY' => array_merge(
- array_map(function ($fieldName) {
- return "f_{$fieldName}";
- }, self::$FIELD_LIST_PRACOWNICY),
- [
- 'f_Adresy',
- ]
- ),
- 'FIELD_LIST_KONTRAHENCI' => array_map(function ($fieldName) {
- return "f_{$fieldName}";
- }, self::$FIELD_LIST_KONTRAHENCI),
- ]);
- echo '</div>';
- UI::dol();
- }
- public function formDataCsvFileAjaxAction() {
- Response::sendTryCatchJson(array($this, 'formDataCsvFileAjax'));
- }
- public function formDataCsvFileAjax() {
- if (!file_exists($_FILES['file']['tmp_name'])) throw new Exception("Wybierz plik do przesłania.");
- $file = file($_FILES['file']['tmp_name']);
-
- $showCheckbox = V::get('showCheckbox', 0, $_REQUEST, 'string');
-
- $arrayDataCsv = $this->csvToArray($file, ';', '"', '\n\r');
- $i = 0;
-
- foreach ( $arrayDataCsv as $line ) {
- $viewFormCol .= '<tr>';
- foreach ( $line as $keyData => $rowData ) {
-
- if( $i == 0) { $header .= '<td style="min-width:160px">' . $keyData . '</td>'; }
-
- $viewFormCol .= '<td style="min-width:160px"><input type="text" name="item['.$i.']['.$keyData.']" value="'.$rowData .'" class="form-control input-lg" /></td>';
- }
- $viewFormCol .= '</tr>';
- $i++;
- }
-
- if ( $showCheckbox == 'yes' ) {
- $viewFormCol .= '<div style="margin: 10px 0"><input type="checkbox" name="override" value="1" /> Nadpisz wszystkie rekordy w bazie danych</div';
- }
- $viewFormHtml = '<div id="smad-window-modal" style="overflow-x: scroll;">
- <div class="table-responsive padding-0" >
- <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>
- </div>';
-
- return [
- 'type' => 'success',
- 'msg' => 'OK',
- '__req_args' => $_REQUEST,
- '__args' => $args,
- 'body' => [
- 'view' => $viewFormHtml,
- ]
- ];
- }
-
- public function saveFormCsvFileAjaxAction() {
- Response::sendTryCatchJson(array($this, 'saveFormCsvFileAjax'), $args = 'JSON_FROM_REQUEST_BODY');
-
- }
- public function saveFormCsvFileAjax($args) {
-
- $formData = V::get('formData', '', $args);
- $enumType = V::get('enumType', '', $args);
- $override = false;
- $arrayInfo = array();
- $arrayInfo['insert'] = 0;
- $arrayInfo['update'] = 0;
- $arrayInfo['error'] = 0;
-
- $table = $this->getNameTableByEnum( strtoupper($enumType) );
- if ( $table == null ) throw new Exception('Błąd zapisu. Tabela w db nie istnieje');
-
- parse_str($formData, $resultArrayFormdata);
- if ( count($resultArrayFormdata['item']) == 0) {
- throw new Exception("Wystapił problem podczas przesyłania danych - brak przesłanych danych.");
- }
-
- if ( isset($resultArrayFormdata['override']) ) { $override = true; }
-
- foreach ( $resultArrayFormdata['item'] as $line ) {
- $response = $this->saveDataToDb($table, $line, $override);
-
- $arrayInfo = $this->responseCountListInfoAboutSaveData($response, $arrayInfo);
- }
-
- if ( isset($arrayInfo['insert']) ) { $textInsert = "Liczba nowych rekordów: (" . $arrayInfo['insert'] . ");"; }
- if ( isset($arrayInfo['error']) ) { $textError = "Liczba nie zapisanych rekordów (" . $arrayInfo['insert'] . ");"; }
- return [
- 'msg' => "Zapisano dane. " . $textInsert . " " . $textError ,
- 'type' => "success",
- ];
- }
-
- public function responseCountListInfoAboutSaveData($response, $arrayInfo) {
- if (!is_array($response)) throw new Exception('Wystapił bład podczas zapisu danych');
- $countData = array();
- switch(key($response)) {
- case 'insert':
- $countData['insert'] = $arrayInfo['insert'] + 1;
- break;
- case 'error':
- $countData['error'] = $arrayInfo['insert'] + 1;
- break;
- }
- return $countData;
- }
-
- function csvToArray($filedata , $delimiter=';', $enclosure='"', $escape = '\\') {
- if(!$filedata || empty($filedata)) return false;
- $header = null;
- $data = array();
- foreach( $filedata as $line) {
- $values = str_getcsv( $line, $delimiter, $enclosure, $escape );
- if(!$header) $header = $values;
- else $data[] = array_combine( $header, $values );
- }
- return $data;
- }
-
- public function saveDataToDb( $table, $arrayData, $override = false ) {
- $response = array();
- try {
- if ($override) {
- DB::getPDO()->insertOrUpdate($table, array_merge($arrayData, [
- '@insert' => [
- 'A_RECORD_CREATE_DATE' => 'NOW()',
- 'A_RECORD_CREATE_AUTHOR' => User::getLogin(),
- ],
- '@update' => array_merge($arrayData, [
- 'A_RECORD_UPDATE_DATE' => 'NOW()',
- 'A_RECORD_UPDATE_AUTHOR' => User::getLogin(),
- ]),
- ]));
- } else {
- $responseInsert = DB::getPDO()->insert($table, array_merge($arrayData, [
- 'A_RECORD_CREATE_AUTHOR' => User::getLogin(),
- 'A_RECORD_CREATE_DATE' => 'NOW()',
- ]));
- }
- $response['insert'] = 1;
- } catch (Exception $e) {
- DBG::log($e);
- $response['error'] = 1;
- }
- return $response;
- }
-
- public function getNameTableByEnum($type) {
- $nameTable = null;
- switch ($type) {
- case 'KONTRAHENCI':
- $nameTable = 'BI_audit_ENERGA_RUM_KONTRAHENCI';
- break;
- case 'PRACOWNICY':
- $nameTable = 'BI_audit_ENERGA_PRACOWNICY';
- break;
- }
- return $nameTable;
- }
- public function fetchEnergaRumKontrahenciPowiazaniaAjaxAction() {
- Response::sendTryCatchJson(array($this, 'fetchEnergaRumKontrahenciPowiazaniaAjax'));
- }
- public function fetchEnergaRumKontrahenciPowiazaniaAjax($args) {
- $id = V::get('ID', 26, $_REQUEST, 'int');
- $items = ACL::getAclByNamespace('default_db/BI_audit_ENERGA_RUM_KONTRAHENCI_POWIAZANIA/BI_audit_ENERGA_RUM_KONTRAHENCI_POWIAZANIA')->buildQuery([
- 'cols' => [
- 'ID',
- 'A_ADM_COMPANY',
- 'L_APPOITMENT_USER',
- 'A_CLASSIFIED',
- 'A_STATUS',
- 'A_STATUS_INFO',
- 'BI_analiza_maxDepth',
- 'BI_analiza_minDepth',
- 'BI_analiza_onlyTargets',
- '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
- ]);
-
-
-
-
-
- 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="">
- <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'));
- }
- public function fetchTestKrsAjax($args) {
- $id = V::get('ID', 1, $_REQUEST, 'int');
- $items = ACL::getAclByNamespace('default_db/BI_audit_KRS/BI_audit_KRS')->buildQuery([
- 'cols' => [
- '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'));
- }
- public function fetchTestCeidgAjax($args) {
- $id = V::get('ID', 0, $_REQUEST, 'int');
- $items = ACL::getAclByNamespace('default_db/BI_audit_CEIDG/BI_audit_CEIDG')->buildQuery([
- 'cols' => [
- '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',
- ],
-
- ])->getItems([
- 'limit' => 10
- ]);
- return [
- 'type' => 'success',
- 'msg' => 'CEIDG',
- '__req_args' => $_REQUEST,
- '__args' => $args,
- 'body' => [
- 'items' => $items,
- ]
- ];
- }
- public function fetchKontrahenciIdsAjaxAction() {
- Response::sendTryCatchJson(array($this, 'fetchKontrahenciIdsAjax'), $args = 'JSON_FROM_REQUEST_BODY');
- }
- public function fetchKontrahenciIdsAjax($args) {
- $idGroup = V::get('filter_idGroup', 0, $args, 'int');
- if ($idGroup < 0) $idGroup = 0;
- $backRefFilter = [];
- if ($idGroup > 0) {
- $backRefFilter['__backRef'] = [
- 'namespace' => 'default_db/BI_audit_ENERGA_KONTRAHENCI_group/BI_audit_ENERGA_KONTRAHENCI_group',
- 'primaryKey' => $idGroup,
- 'fieldName' => 'default_db__x3A__BI_audit_ENERGA_RUM_KONTRAHENCI:BI_audit_ENERGA_RUM_KONTRAHENCI',
- ];
- }
- $searchParams = [];
- $filtersParams = [];
- $fieldFilterKeys = array_filter(array_keys($args), function ($key) {
- return ('f_' === substr($key, 0, 2));
- });
- foreach ($fieldFilterKeys as $key) {
- $filtersParams[ $key ] = '%' . $args[ $key ] . '%';
- }
- $acl = ACL::getAclByNamespace('default_db/BI_audit_ENERGA_RUM_KONTRAHENCI/BI_audit_ENERGA_RUM_KONTRAHENCI');
- $query = $acl->buildQuery(array_merge([
- 'cols' => [
- 'ID',
- ],
-
- 'limit' => 0,
-
-
-
-
-
-
-
- ], $searchParams, $filtersParams, $backRefFilter));
-
- $items = $query->getItems();
- return [
- 'type' => 'success',
- 'msg' => 'kontrahenci ids',
- 'body' => [
- 'ids' => array_map( V::makePick('ID'), $items ),
- ],
- '__DBG_args' => $args,
- '__DBG_$idGroup' => $idGroup,
- '__DBG_$filtersParams' => $filtersParams,
- '__DBG_$backRefFilter' => $backRefFilter,
- ];
- }
-
- public function fetchKontrahenciAjaxAction() {
- Response::sendTryCatchJson(array($this, 'fetchKontrahenciAjax'), $args = $_REQUEST);
- }
- public function fetchKontrahenciAjax($args) {
- $idGroup = V::get('filterIdGroup', 0, $args, 'int');
- if ($idGroup < 0) $idGroup = 0;
- $limit = 20;
- $limitstart = V::get('limitstart', 0, $args, 'int');
- if ($limitstart < 0) $limitstart = 0;
- $page = V::get('page', 0, $args, 'int');
- $limitstart = ($page - 1) * $limit;
- $search = V::get('search', '', $args);
- $searchParams = [];
- if (!empty($search)) {
- $ogcSearch = "*{$search}*";
- $searchParams['ogc:Filter'] = '
- <ogc:Filter>
- <ogc:Or>
- <ogc:PropertyIsLike wildCard="" singleChar="%23" escapeChar="!">
- <ogc:PropertyName>NIP</ogc:PropertyName>
- <ogc:Literal>' . $ogcSearch . '</ogc:Literal>
- </ogc:PropertyIsLike>
- <ogc:PropertyIsLike wildCard="*" singleChar="%23" escapeChar="!">
- <ogc:PropertyName>Nazwa_grupy_kapitalowej</ogc:PropertyName>
- <ogc:Literal>' . $ogcSearch . '</ogc:Literal>
- </ogc:PropertyIsLike>
- <ogc:PropertyIsLike wildCard="*" singleChar="%23" escapeChar="!">
- <ogc:PropertyName>Pelna_nazwa_kontrahenta</ogc:PropertyName>
- <ogc:Literal>' . $ogcSearch . '</ogc:Literal>
- </ogc:PropertyIsLike>
- </ogc:Or>
- </ogc:Filter>
- ';
- }
- $backRefFilter = [];
- if ($idGroup > 0) {
- $backRefFilter['__backRef'] = [
- 'namespace' => 'default_db/BI_audit_ENERGA_KONTRAHENCI_group/BI_audit_ENERGA_KONTRAHENCI_group',
- 'primaryKey' => $idGroup,
- 'fieldName' => 'default_db__x3A__BI_audit_ENERGA_RUM_KONTRAHENCI:BI_audit_ENERGA_RUM_KONTRAHENCI',
- ];
-
-
-
-
- }
- $filtersParams = [];
- $fieldFilterKeys = array_filter(array_keys($args), function ($key) {
- return ('f_' === substr($key, 0, 2));
- });
- foreach ($fieldFilterKeys as $key) {
- $filtersParams[ $key ] = '%' . $args[ $key ] . '%';
- }
- DBG::log($filtersParams, 'Kontrahenci $filtersParams');
- $acl = ACL::getAclByNamespace('default_db/BI_audit_ENERGA_RUM_KONTRAHENCI/BI_audit_ENERGA_RUM_KONTRAHENCI');
- $query = $acl->buildQuery(array_merge([
- 'cols' => [
- 'ID',
- 'Nazwa_grupy_kapitalowej',
- 'Pelna_nazwa_kontrahenta',
- 'Numer_kontrahenta',
- 'Skrocona_Nazwa_Kontrahenta',
- 'Typ_kontrahenta',
- 'NIP',
- 'KRS',
- 'REGON',
- 'PESEL',
- 'Forma_prawna_dzialalnosci',
- 'Ulica',
- 'Numer_budynku',
- 'Numer_mieszkania_lokalu',
- 'Miejscowosc',
- 'Kod_pocztowy',
- 'Kraj',
- 'Telefon',
- 'Fax',
- 'Mail',
- 'A_ADM_COMPANY',
- 'A_CLASSIFIED',
- 'Dodano',
- 'Podmiot_dominujacy',
- 'Tytul_dokumentu',
- 'ownCompany',
- 'uwagi',
- ],
-
- 'limit' => $limit,
- 'limitstart' => $limitstart,
- ], $searchParams, $filtersParams, $backRefFilter));
- $total = $query->getTotal();
- $items = $query->getItems();
- $pagination = array();
- $pagination['total_items'] = $total;
- $pagination['size'] = ceil($total/$limit);
- $pagination['current'] = $page;
- $pagination['limit'] = $limit;
- if ($idGroup > 0) $pagination['filter_idGroup'] = $idGroup;
- return [
- 'type' => 'success',
- 'msg' => 'showKontrajenci',
- 'body' => [
- 'items' => $items,
-
- 'pagination' => $pagination
- ],
- '__DBG_args' => $args,
- '__DBG_$idGroup' => $idGroup,
- '__DBG_$filtersParams' => $filtersParams,
- '__DBG_$backRefFilter' => $backRefFilter,
- ];
- }
- public function showTableKontrahenci($labels = []) {
-
- $view = '<form class="form-horizontal" method="post">
- <table class="table table-bordered table-hover table-striped" height=5>
- <thead>
- <tr>
- <td width=1><input type="checkbox" name="checkAll" id="checkAll-KONTRAHENCI" /></td>
- <td width=1>' . V::get('ID', 'ID', $labels) . '</td>
- <td>' . V::get('Nazwa_grupy_kapitalowej', 'Nazwa grupy kapitalowej', $labels) . '</td>
- <td>' . V::get('Pelna_nazwa_kontrahenta', 'Pelna nazwa kontrahenta', $labels) . '</td>
- <td>' . V::get('Numer_kontrahenta', 'Numer kontrahenta', $labels) . '</td>
- <td>' . V::get('Skrocona_Nazwa_Kontrahenta', 'Skrócona nazwa kontrahenta', $labels) . '</td>
- <td>' . V::get('Typ_kontrahenta', 'Typ_kontrahenta', $labels) . '</td>
- <td>' . V::get('NIP', 'NIP', $labels) . '</td>
- <td>' . V::get('KRS', 'KRS', $labels) . '</td>
- <td>' . V::get('REGON', 'Regon', $labels) . '</td>
- <td>' . V::get('PESEL', 'PESEL', $labels) . '</td>
- <td>' . V::get('Forma_prawna_dzialalnosci', 'Forma prawna działalności', $labels) . '</td>
- <td>' . V::get('Ulica', 'Ulica', $labels) . '</td>
- <td>' . V::get('Numer_budynku', 'Numer budynku', $labels) . '</td>
- <td>' . V::get('Numer_mieszkania_lokalu', 'Numer mieszkania lokalu', $labels) . '</td>
- <td>' . V::get('Miejscowosc', 'Miejscowosc', $labels) . '</td>
- <td>' . V::get('Kod_pocztowy', 'Kod pocztowy', $labels) . '</td>
- <td>' . V::get('Kraj', 'Kraj', $labels) . '</td>
- <td>' . V::get('Telefon', 'Telefon', $labels) . '</td>
- <td>' . V::get('Fax', 'Fax', $labels) . '</td>
- <td>' . V::get('Mail', 'Mail', $labels) . '</td>
- <td>' . V::get('A_ADM_COMPANY', 'A_ADM_COMPANY', $labels) . '</td>
- <td>' . V::get('A_CLASSIFIED', 'A_CLASSIFIED', $labels) . '</td>
- <td>' . V::get('Dodano', 'Dodano', $labels) . '</td>
- <td>' . V::get('Podmiot_dominujacy', 'Podmiot dominujacy', $labels) . '</td>
- <td>' . V::get('Tytul_dokumentu', 'Tytul dokumentu', $labels) . '</td>
- <td>' . V::get('ownCompany', 'ownCompany', $labels) . '</td>
- <td>' . V::get('uwagi', 'uwagi', $labels) . '</td>
- </tr>
- <tr>
- <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>
- <td style="padding:0"><input style="padding:2px 8px; width:80px" onChange="return onChangeFiltersKontrahenci(event, this)" onKeypress="return onKeypressFiltersKontrahenci(event, this)" type="text" name="f_ID" value="" placeholder="%"></td>
- <td style="padding:0"><input style="padding:2px 8px; width:100%" onChange="return onChangeFiltersKontrahenci(event, this)" onKeypress="return onKeypressFiltersKontrahenci(event, this)" type="text" name="f_Nazwa_grupy_kapitalowej" value="" placeholder="%"></td>
- <td style="padding:0"><input style="padding:2px 8px; width:100%" onChange="return onChangeFiltersKontrahenci(event, this)" onKeypress="return onKeypressFiltersKontrahenci(event, this)" type="text" name="f_Pelna_nazwa_kontrahenta" value="" placeholder="%"></td>
- <td style="padding:0"><input style="padding:2px 8px; width:100%" onChange="return onChangeFiltersKontrahenci(event, this)" onKeypress="return onKeypressFiltersKontrahenci(event, this)" type="text" name="f_Numer_kontrahenta" value="" placeholder="%"></td>
- <td style="padding:0"><input style="padding:2px 8px; width:100%" onChange="return onChangeFiltersKontrahenci(event, this)" onKeypress="return onKeypressFiltersKontrahenci(event, this)" type="text" name="f_Skrocona_Nazwa_Kontrahenta" value="" placeholder="%"></td>
- <td style="padding:0"><input style="padding:2px 8px; width:100%" onChange="return onChangeFiltersKontrahenci(event, this)" onKeypress="return onKeypressFiltersKontrahenci(event, this)" type="text" name="f_Typ_kontrahenta" value="" placeholder="%"></td>
- <td style="padding:0"><input style="padding:2px 8px; width:100%" onChange="return onChangeFiltersKontrahenci(event, this)" onKeypress="return onKeypressFiltersKontrahenci(event, this)" type="text" name="f_NIP" value="" placeholder="%"></td>
- <td style="padding:0"><input style="padding:2px 8px; width:100%" onChange="return onChangeFiltersKontrahenci(event, this)" onKeypress="return onKeypressFiltersKontrahenci(event, this)" type="text" name="f_KRS" value="" placeholder="%"></td>
- <td style="padding:0"><input style="padding:2px 8px; width:100%" onChange="return onChangeFiltersKontrahenci(event, this)" onKeypress="return onKeypressFiltersKontrahenci(event, this)" type="text" name="f_REGON" value="" placeholder="%"></td>
- <td style="padding:0"><input style="padding:2px 8px; width:100%" onChange="return onChangeFiltersKontrahenci(event, this)" onKeypress="return onKeypressFiltersKontrahenci(event, this)" type="text" name="f_PESEL" value="" placeholder="%"></td>
- <td style="padding:0"><input style="padding:2px 8px; width:100%" onChange="return onChangeFiltersKontrahenci(event, this)" onKeypress="return onKeypressFiltersKontrahenci(event, this)" type="text" name="f_Forma_prawna_dzialalnosci" value="" placeholder="%"></td>
- <td style="padding:0"><input style="padding:2px 8px; width:100%" onChange="return onChangeFiltersKontrahenci(event, this)" onKeypress="return onKeypressFiltersKontrahenci(event, this)" type="text" name="f_Ulica" value="" placeholder="%"></td>
- <td style="padding:0"><input style="padding:2px 8px; width:100%" onChange="return onChangeFiltersKontrahenci(event, this)" onKeypress="return onKeypressFiltersKontrahenci(event, this)" type="text" name="f_Numer_budynku" value="" placeholder="%"></td>
- <td style="padding:0"><input style="padding:2px 8px; width:100%" onChange="return onChangeFiltersKontrahenci(event, this)" onKeypress="return onKeypressFiltersKontrahenci(event, this)" type="text" name="f_Numer_mieszkania_lokalu" value="" placeholder="%"></td>
- <td style="padding:0"><input style="padding:2px 8px; width:100%" onChange="return onChangeFiltersKontrahenci(event, this)" onKeypress="return onKeypressFiltersKontrahenci(event, this)" type="text" name="f_Miejscowosc" value="" placeholder="%"></td>
- <td style="padding:0"><input style="padding:2px 8px; width:100%" onChange="return onChangeFiltersKontrahenci(event, this)" onKeypress="return onKeypressFiltersKontrahenci(event, this)" type="text" name="f_Kod_pocztowy" value="" placeholder="%"></td>
- <td style="padding:0"><input style="padding:2px 8px; width:100%" onChange="return onChangeFiltersKontrahenci(event, this)" onKeypress="return onKeypressFiltersKontrahenci(event, this)" type="text" name="f_Kraj" value="" placeholder="%"></td>
- <td style="padding:0"><input style="padding:2px 8px; width:100%" onChange="return onChangeFiltersKontrahenci(event, this)" onKeypress="return onKeypressFiltersKontrahenci(event, this)" type="text" name="f_Telefon" value="" placeholder="%"></td>
- <td style="padding:0"><input style="padding:2px 8px; width:100%" onChange="return onChangeFiltersKontrahenci(event, this)" onKeypress="return onKeypressFiltersKontrahenci(event, this)" type="text" name="f_Fax" value="" placeholder="%"></td>
- <td style="padding:0"><input style="padding:2px 8px; width:100%" onChange="return onChangeFiltersKontrahenci(event, this)" onKeypress="return onKeypressFiltersKontrahenci(event, this)" type="text" name="f_Mail" value="" placeholder="%"></td>
- <td style="padding:0"><input style="padding:2px 8px; width:100%" onChange="return onChangeFiltersKontrahenci(event, this)" onKeypress="return onKeypressFiltersKontrahenci(event, this)" type="text" name="f_A_ADM_COMPANY" value="" placeholder="%"></td>
- <td style="padding:0"><input style="padding:2px 8px; width:100%" onChange="return onChangeFiltersKontrahenci(event, this)" onKeypress="return onKeypressFiltersKontrahenci(event, this)" type="text" name="f_A_CLASSIFIED" value="" placeholder="%"></td>
- <td style="padding:0"><input style="padding:2px 8px; width:100%" onChange="return onChangeFiltersKontrahenci(event, this)" onKeypress="return onKeypressFiltersKontrahenci(event, this)" type="text" name="f_Dodano" value="" placeholder="%"></td>
- <td style="padding:0"><input style="padding:2px 8px; width:100%" onChange="return onChangeFiltersKontrahenci(event, this)" onKeypress="return onKeypressFiltersKontrahenci(event, this)" type="text" name="f_Podmiot_dominujacy" value="" placeholder="%"></td>
- <td style="padding:0"><input style="padding:2px 8px; width:100%" onChange="return onChangeFiltersKontrahenci(event, this)" onKeypress="return onKeypressFiltersKontrahenci(event, this)" type="text" name="f_Tytul_dokumentu" value="" placeholder="%"></td>
- <td style="padding:0"><input style="padding:2px 8px; width:100%" onChange="return onChangeFiltersKontrahenci(event, this)" onKeypress="return onKeypressFiltersKontrahenci(event, this)" type="text" name="f_ownCompany" value="" placeholder="%"></td>
- <td style="padding:0"><input style="padding:2px 8px; width:100%" onChange="return onChangeFiltersKontrahenci(event, this)" onKeypress="return onKeypressFiltersKontrahenci(event, this)" type="text" name="f_uwagi" value="" placeholder="%"></td>
- </tr>
- </thead>
- <tbody id="body-kontrahenci">
- </tbody></table>
- </form>
- ';
- return $view;
- }
-
- public function createKontrahenciGroupAjaxAction() {
- Response::sendTryCatchJson(array($this, 'createKontrahenciGroupAjax'), $args = 'JSON_FROM_REQUEST_BODY');
- }
- public function createKontrahenciGroupAjax($args) {
- $nazwa = V::get('NAZWA', '', $args);
-
- $idGroup = DB::getPDO()->insert('BI_audit_ENERGA_KONTRAHENCI_group', [
- 'A_RECORD_CREATE_AUTHOR' => User::getLogin(),
- 'A_RECORD_CREATE_DATE' => 'NOW()',
- 'NAZWA' => $nazwa,
- 'ID_USER' => User::getID()
- ]);
- return [
- 'msg' => "Utworzona grupę {$idGroup}",
- 'type' => "success",
- 'body' => [
- 'id' => $idGroup,
- 'nazwa' => $nazwa
- ]
- ];
- }
-
- public function addKontrahenciToGroupAjaxAction() {
- Response::sendTryCatchJson(array($this, 'addKontrahenciToGroupAjax'), $args = 'JSON_FROM_REQUEST_BODY');
- }
- public function addKontrahenciToGroupAjax($args) {
- $idGroup = V::get('idGroup', '', $args);
- $type = V::get('type', 'ids', $args);
- $kontrahenciIds = V::get('kontrahenciIds', '', $args);
- $filter = V::get('filter', '', $args);
-
- if (!$idGroup) throw new Exception("Nie wybrano grupa");
- switch ($type) {
- case 'ids': {
- if (!$kontrahenciIds || count($kontrahenciIds) == 0) throw new Exception("Proszę wybrać kontrahentów");
- } break;
- case 'filter': {
- if (!isset($args['filter'])) throw new Exception("Proszę wybrać kontrahentów");
- } break;
- default: throw new Exception("Missing type");
- }
- $group = ACL::getAclByNamespace('default_db/BI_audit_ENERGA_KONTRAHENCI_group/BI_audit_ENERGA_KONTRAHENCI_group')->buildQuery([
- 'cols' => [
- 'ID',
- 'ID_USER',
- 'NAZWA',
- ],
-
- ])->getItem($idGroup);
- if (!$group) throw new Exception("Grupa nie istnieje");
- if (User::getID() != $group['ID_USER']) throw new Exception("Brak uprawnień do grupy");
- if ('filter' === $type) {
- $args__idGroup = V::get('filterIdGroup', 0, $args['filter'], 'int');
- if ($args__idGroup < 0) $args__idGroup = 0;
- $search = V::get('search', '', $args['filter']);
- $searchParams = [];
- if (!empty($search)) {
- $ogcSearch = "*{$search}*";
- $searchParams['ogc:Filter'] = '
- <ogc:Filter>
- <ogc:Or>
- <ogc:PropertyIsLike wildCard="" singleChar="%23" escapeChar="!">
- <ogc:PropertyName>NIP</ogc:PropertyName>
- <ogc:Literal>' . $ogcSearch . '</ogc:Literal>
- </ogc:PropertyIsLike>
- <ogc:PropertyIsLike wildCard="*" singleChar="%23" escapeChar="!">
- <ogc:PropertyName>Nazwa_grupy_kapitalowej</ogc:PropertyName>
- <ogc:Literal>' . $ogcSearch . '</ogc:Literal>
- </ogc:PropertyIsLike>
- <ogc:PropertyIsLike wildCard="*" singleChar="%23" escapeChar="!">
- <ogc:PropertyName>Pelna_nazwa_kontrahenta</ogc:PropertyName>
- <ogc:Literal>' . $ogcSearch . '</ogc:Literal>
- </ogc:PropertyIsLike>
- </ogc:Or>
- </ogc:Filter>
- ';
- }
- $backRefFilter = [];
- if ($args__idGroup > 0) {
- $backRefFilter['__backRef'] = [
- 'namespace' => 'default_db/BI_audit_ENERGA_KONTRAHENCI_group/BI_audit_ENERGA_KONTRAHENCI_group',
- 'primaryKey' => $args__idGroup,
- 'fieldName' => 'default_db__x3A__BI_audit_ENERGA_RUM_KONTRAHENCI:BI_audit_ENERGA_RUM_KONTRAHENCI',
- ];
- }
- $filtersParams = [];
- $fieldFilterKeys = array_filter(array_keys($args['filter']), function ($key) {
- return ('f_' === substr($key, 0, 2));
- });
- foreach ($fieldFilterKeys as $key) {
- $filtersParams[ $key ] = '%' . $args['filter'][ $key ] . '%';
- }
- $acl = ACL::getAclByNamespace('default_db/BI_audit_ENERGA_RUM_KONTRAHENCI/BI_audit_ENERGA_RUM_KONTRAHENCI');
- $query = $acl->buildQuery(array_merge([
- 'cols' => ['ID'],
- ], $searchParams, $filtersParams, $backRefFilter, [
- 'limit' => 0
- ]));
- $items = $query->getItems();
- $kontrahenciIds = array_map(function ($row) {
- return $row['ID'];
- }, $items);
- }
-
- $refGrupyToKontrahenci = ACL::getRefTable('default_db/BI_audit_ENERGA_KONTRAHENCI_group/BI_audit_ENERGA_KONTRAHENCI_group',
- 'default_db__x3A__BI_audit_ENERGA_RUM_KONTRAHENCI:BI_audit_ENERGA_RUM_KONTRAHENCI');
- foreach ($kontrahenciIds as $kontrahentIds) {
- DB::getPDO()->insert($refGrupyToKontrahenci, ['PRIMARY_KEY' => $idGroup, 'REMOTE_PRIMARY_KEY' => $kontrahentIds]);
- }
- return [
- 'msg' => "Powiązano kontrahentów z grupą {$idGroup}",
- 'type' => "success",
- ];
- }
- public function fetchGroupKontrahenciAjaxAction() {
- Response::sendTryCatchJson(array($this, 'fetchGroupKontrahenciAjax'));
- }
- public function fetchGroupKontrahenciAjax() {
- $query = ACL::getAclByNamespace('default_db/BI_audit_ENERGA_KONTRAHENCI_group/BI_audit_ENERGA_KONTRAHENCI_group')->buildQuery([
- 'cols' => [
- 'ID',
- 'ID_USER',
- 'NAZWA',
- ],
- 'f_ID_USER' => "=" . User::getID(),
- 'f_A_STATUS' => "!DELETED",
- ]);
- $itemsKontrahenci = $query->getItems();
- if (empty($itemsKontrahenci)) throw new AlertWarningException("Grupy nie istnieją");
- $arrayGroupKontrahenci = array();
- foreach ($itemsKontrahenci as $item) {
-
- $arrayGroupKontrahenci[] = [
- 'NAZWA' => $item['NAZWA'],
- 'ID' => $item['ID'],
- ];
- }
- return [
- 'type' => 'success',
- 'msg' => 'fetchGroupKontrahenciAjax',
- '__req_args' => $_REQUEST,
- '__args' => $args,
- 'body' => [
- 'itemsGroupKontrahenci' => $arrayGroupKontrahenci
- ]
- ];
- }
- public function fetchPracownicyIdsAjaxAction() {
- Response::sendTryCatchJson(array($this, 'fetchPracownicyIdsAjax'), $args = 'JSON_FROM_REQUEST_BODY');
- }
- public function fetchPracownicyIdsAjax($args) {
- $idGroup = V::get('filter_idGroup', 0, $args, 'int');
- if ($idGroup < 0) $idGroup = 0;
- $backRefFilter = [];
- if ($idGroup > 0) {
- $backRefFilter['__backRef'] = [
- 'namespace' => 'default_db/BI_audit_ENERGA_PRACOWNICY_group/BI_audit_ENERGA_PRACOWNICY_group',
- 'primaryKey' => $idGroup,
- 'fieldName' => 'default_db__x3A__BI_audit_ENERGA_PRACOWNICY:BI_audit_ENERGA_PRACOWNICY',
- ];
- }
- $searchParams = [];
- $filtersParams = [];
- $fieldFilterKeys = array_filter(array_keys($args), function ($key) {
- return ('f_' === substr($key, 0, 2));
- });
- foreach ($fieldFilterKeys as $key) {
- $filtersParams[ $key ] = '%' . $args[ $key ] . '%';
- }
- $acl = ACL::getAclByNamespace('default_db/BI_audit_ENERGA_PRACOWNICY/BI_audit_ENERGA_PRACOWNICY');
- $query = $acl->buildQuery(array_merge([
- 'cols' => [
- 'ID',
- ],
-
- 'limit' => 0,
-
-
-
-
-
-
-
- ], $searchParams, $filtersParams, $backRefFilter));
-
- $items = $query->getItems();
- return [
- 'type' => 'success',
- 'msg' => 'pracownicy ids',
- 'body' => [
- 'ids' => array_map( V::makePick('ID'), $items ),
- ],
- '__args' => $args,
- '__DBG_$idGroup' => $idGroup,
- '__DBG_$filtersParams' => $filtersParams,
- '__DBG_$backRefFilter' => $backRefFilter,
- ];
- }
-
- public function fetchPracownicyAjaxAction() {
- Response::sendTryCatchJson(array($this, 'fetchPracownicyAjax'), $args = $_REQUEST);
- }
- public function fetchPracownicyAjax($args) {
- $idGroup = V::get('filterIdGroup', 0, $args, 'int');
- if ($idGroup < 0) $idGroup = 0;
- $limit = 20;
- $page = V::get('page', 0, $args, 'int');
- $limitstart = ($page - 1) * $limit;
- $search = V::get('search', '', $args);
- $searchParams = [];
- if (!empty($search)) {
- $ogcSearch = "*{$search}*";
- $searchParams['ogc:Filter'] = '
- <ogc:Filter>
- <ogc:Or>
- <ogc:PropertyIsLike wildCard="" singleChar="%23" escapeChar="!">
- <ogc:PropertyName>nip</ogc:PropertyName>
- <ogc:Literal>' . $ogcSearch . '</ogc:Literal>
- </ogc:PropertyIsLike>
- <ogc:PropertyIsLike wildCard="*" singleChar="%23" escapeChar="!">
- <ogc:PropertyName>nazwisko</ogc:PropertyName>
- <ogc:Literal>' . $ogcSearch . '</ogc:Literal>
- </ogc:PropertyIsLike>
- </ogc:Or>
- </ogc:Filter>
- ';
- }
- $backRefFilter = [];
- if ($idGroup > 0) {
- $backRefFilter['__backRef'] = [
- 'namespace' => 'default_db/BI_audit_ENERGA_PRACOWNICY_group/BI_audit_ENERGA_PRACOWNICY_group',
- 'primaryKey' => $idGroup,
- 'fieldName' => 'default_db__x3A__BI_audit_ENERGA_PRACOWNICY:BI_audit_ENERGA_PRACOWNICY',
- ];
- }
- $filtersParams = [];
- $fieldFilterKeys = array_filter(array_keys($args), function ($key) {
- return ('f_' === substr($key, 0, 2));
- });
- foreach ($fieldFilterKeys as $key) {
- $filtersParams[ $key ] = '%' . $args[ $key ] . '%';
- }
- $acl = ACL::getAclByNamespace('default_db/BI_audit_ENERGA_PRACOWNICY/BI_audit_ENERGA_PRACOWNICY');
- $query = $acl->buildQuery(array_merge([
- 'cols' => array_merge(self::$FIELD_LIST_PRACOWNICY, [
- 'default_db__x3A__BI_audit_ENERGA_PRACOWNICY_adresy:BI_audit_ENERGA_PRACOWNICY_adresy/*'
- ]),
-
- 'limit' => $limit,
- 'limitstart' => $limitstart,
-
-
-
-
-
-
- ], $searchParams, $filtersParams, $backRefFilter));
- $total = $query->getTotal();
- $items = $query->getItems();
- $pagination = array();
- $pagination['total_items'] = $total;
- $pagination['size'] = ceil($total/$limit);
- $pagination['current'] = $page;
- $pagination['limit'] = $limit;
-
- if ($idGroup > 0) $pagination['filter_idGroup'] = $idGroup;
-
-
-
-
-
-
-
-
-
-
-
-
- return [
- 'type' => 'success',
- 'msg' => 'showPracownicy',
- 'body' => [
- 'items' => $items,
-
- 'pagination' => $pagination
- ],
- '__DBG_$idGroup' => $idGroup,
- '__DBG_$filtersParams' => $filtersParams,
- '__DBG_$backRefFilter' => $backRefFilter,
- ];
- }
- public function showTablePracownicy($labels = []) {
-
- $view = '<form class="form-horizontal" method="post">
- <table class="table table-responsive table-bordered table-hover table-striped" height=5>
- <thead>
- <tr>
- <td width=1><input type="checkbox" name="checkAll" id="checkAll-PRACOWNICY" /></td>
- <td width=1>' . V::get('ID', 'ID', $labels) . '</td>
- <td>' . V::get('imiona', 'Imię/Imiona', $labels) . '</td>
- <td>' . V::get('nazwisko', 'Nazwisko', $labels) . '</td>
- <td>' . V::get('nip', 'NIP', $labels) . '</td>
- <td>' . V::get('pesel', 'Pesel', $labels) . '</td>
- <td>' . V::get('regon', 'Regon', $labels) . '</td>
- <td>' . V::get('source', 'source', $labels) . '</td>
- <td>' . V::get('jednostka_organizacyjna', 'jednostka_organizacyjna', $labels) . '</td>
- <td>' . V::get('A_STATUS', 'A_STATUS', $labels) . '</td>
- <td>' . V::get('A_STATUS_INFO', 'A_STATUS_INFO', $labels) . '</td>
- <td>' . V::get('L_APPOITMENT_USER', 'L_APPOITMENT_USER', $labels) . '</td>
- <td>' . V::get('Adresy', 'Adresy', $labels) . '</td>
- </tr>
- <tr>
- <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>
- <td style="padding:0"><input style="padding:2px 8px; width:80px" onChange="return onChangeFiltersPracownicy(event, this)" onKeypress="return onKeypressFiltersPracownicy(event, this)" type="text" name="f_ID" value="" placeholder="%"></td>
- <td style="padding:0"><input style="padding:2px 8px; width:100%" onChange="return onChangeFiltersPracownicy(event, this)" onKeypress="return onKeypressFiltersPracownicy(event, this)" type="text" name="f_imiona" value="" placeholder="%"></td>
- <td style="padding:0"><input style="padding:2px 8px; width:100%" onChange="return onChangeFiltersPracownicy(event, this)" onKeypress="return onKeypressFiltersPracownicy(event, this)" type="text" name="f_nazwisko" value="" placeholder="%"></td>
- <td style="padding:0"><input style="padding:2px 8px; width:100%" onChange="return onChangeFiltersPracownicy(event, this)" onKeypress="return onKeypressFiltersPracownicy(event, this)" type="text" name="f_nip" value="" placeholder="%"></td>
- <td style="padding:0"><input style="padding:2px 8px; width:100%" onChange="return onChangeFiltersPracownicy(event, this)" onKeypress="return onKeypressFiltersPracownicy(event, this)" type="text" name="f_pesel" value="" placeholder="%"></td>
- <td style="padding:0"><input style="padding:2px 8px; width:100%" onChange="return onChangeFiltersPracownicy(event, this)" onKeypress="return onKeypressFiltersPracownicy(event, this)" type="text" name="f_regon" value="" placeholder="%"></td>
- <td style="padding:0"><input style="padding:2px 8px; width:100%" onChange="return onChangeFiltersPracownicy(event, this)" onKeypress="return onKeypressFiltersPracownicy(event, this)" type="text" name="f_source" value="" placeholder="%"></td>
- <td style="padding:0"><input style="padding:2px 8px; width:100%" onChange="return onChangeFiltersPracownicy(event, this)" onKeypress="return onKeypressFiltersPracownicy(event, this)" type="text" name="f_jednostka_organizacyjna" value="" placeholder="%"></td>
- <td style="padding:0"><input style="padding:2px 8px; width:100%" onChange="return onChangeFiltersPracownicy(event, this)" onKeypress="return onKeypressFiltersPracownicy(event, this)" type="text" name="f_A_STATUS" value="" placeholder="%"></td>
- <td style="padding:0"><input style="padding:2px 8px; width:100%" onChange="return onChangeFiltersPracownicy(event, this)" onKeypress="return onKeypressFiltersPracownicy(event, this)" type="text" name="f_A_STATUS_INFO" value="" placeholder="%"></td>
- <td style="padding:0"><input style="padding:2px 8px; width:100%" onChange="return onChangeFiltersPracownicy(event, this)" onKeypress="return onKeypressFiltersPracownicy(event, this)" type="text" name="f_L_APPOITMENT_USER" value="" placeholder="%"></td>
- <td style="padding:0"><input style="padding:2px 8px; width:100%" onChange="return onChangeFiltersPracownicy(event, this)" onKeypress="return onKeypressFiltersPracownicy(event, this)" type="text" name="f_Adresy" value="" placeholder="%"></td>
- </tr>
- </thead>
- <tbody id="body-pracownicy">
- </tbody></table>
- </form>';
- return $view;
- }
-
- public function createPracownicyGroupAjaxAction() {
- Response::sendTryCatchJson(array($this, 'createPracownicyGroupAjax'), $args = 'JSON_FROM_REQUEST_BODY');
- }
- public function createPracownicyGroupAjax($args) {
- $nazwa = V::get('NAZWA', '', $args);
-
- if (!$nazwa) throw new Exception("Nie wybrano grupa");
- $idGroup = DB::getPDO()->insert('BI_audit_ENERGA_PRACOWNICY_group', [
- 'A_RECORD_CREATE_AUTHOR' => User::getLogin(),
- 'A_RECORD_CREATE_DATE' => 'NOW()',
- 'NAZWA' => $nazwa,
- 'ID_USER' => User::getID()
- ]);
- return [
- 'msg' => "Utworzona grupę {$nazwa}",
- 'type' => "success",
- 'body' => [
- 'id' => $idGroup,
- 'nazwa' => $nazwa
- ]
- ];
- }
-
- public function addPracownicyToGroupAjaxAction() {
- Response::sendTryCatchJson(array($this, 'addPracownicyToGroupAjax'), $args = 'JSON_FROM_REQUEST_BODY');
- }
- public function addPracownicyToGroupAjax($args) {
- $idGroup = V::get('idGroup', '', $args);
- $type = V::get('type', 'ids', $args);
- $pracownicyIds = V::get('pracownicyIds', '', $args);
- $filter = V::get('filter', '', $args);
-
- if (!$idGroup) throw new Exception("Nie wybrano grupa");
- switch ($type) {
- case 'ids': {
- if (!$pracownicyIds || count($pracownicyIds) == 0) throw new Exception("Proszę wybrać pracowników");
- } break;
- case 'filter': {
- if (!isset($args['filter'])) throw new Exception("Proszę wybrać pracowników");
- } break;
- default: throw new Exception("Missing type");
- }
-
-
-
- $group = ACL::getAclByNamespace('default_db/BI_audit_ENERGA_PRACOWNICY_group/BI_audit_ENERGA_PRACOWNICY_group')->buildQuery([
- 'cols' => [
- 'ID',
- 'ID_USER',
- 'NAZWA',
- ],
-
- ])->getItem($idGroup);
- if (!$group) throw new Exception("Grupa nie istnieje");
- if (User::getID() != $group['ID_USER']) throw new Exception("Brak uprawnień do grupy");
- if ('filter' === $type) {
- $args__idGroup = V::get('filterIdGroup', 0, $args['filter'], 'int');
- if ($args__idGroup < 0) $args__idGroup = 0;
- $search = V::get('search', '', $args['filter']);
- $searchParams = [];
- if (!empty($search)) {
- $ogcSearch = "*{$search}*";
- $searchParams['ogc:Filter'] = '
- <ogc:Filter>
- <ogc:Or>
- <ogc:PropertyIsLike wildCard="" singleChar="%23" escapeChar="!">
- <ogc:PropertyName>nip</ogc:PropertyName>
- <ogc:Literal>' . $ogcSearch . '</ogc:Literal>
- </ogc:PropertyIsLike>
- <ogc:PropertyIsLike wildCard="*" singleChar="%23" escapeChar="!">
- <ogc:PropertyName>nazwisko</ogc:PropertyName>
- <ogc:Literal>' . $ogcSearch . '</ogc:Literal>
- </ogc:PropertyIsLike>
- </ogc:Or>
- </ogc:Filter>
- ';
- }
- $backRefFilter = [];
- if ($args__idGroup > 0) {
- $backRefFilter['__backRef'] = [
- 'namespace' => 'default_db/BI_audit_ENERGA_PRACOWNICY_group/BI_audit_ENERGA_PRACOWNICY_group',
- 'primaryKey' => $args__idGroup,
- 'fieldName' => 'default_db__x3A__BI_audit_ENERGA_PRACOWNICY:BI_audit_ENERGA_PRACOWNICY',
- ];
- }
- $filtersParams = [];
- $fieldFilterKeys = array_filter(array_keys($args['filter']), function ($key) {
- return ('f_' === substr($key, 0, 2));
- });
- foreach ($fieldFilterKeys as $key) {
- $filtersParams[ $key ] = '%' . $args['filter'][ $key ] . '%';
- }
- $acl = ACL::getAclByNamespace('default_db/BI_audit_ENERGA_PRACOWNICY/BI_audit_ENERGA_PRACOWNICY');
- $query = $acl->buildQuery(array_merge([
- 'cols' => ['ID'],
- ], $searchParams, $filtersParams, $backRefFilter, [
- 'limit' => 0
- ]));
- $items = $query->getItems();
- $pracownicyIds = array_map(function ($row) {
- return $row['ID'];
- }, $items);
- }
-
- $refGrupyToPracownicy = ACL::getRefTable('default_db/BI_audit_ENERGA_PRACOWNICY_group/BI_audit_ENERGA_PRACOWNICY_group',
- 'default_db__x3A__BI_audit_ENERGA_PRACOWNICY:BI_audit_ENERGA_PRACOWNICY');
- foreach ($pracownicyIds as $idPracownik) {
- DB::getPDO()->insert($refGrupyToPracownicy, ['PRIMARY_KEY' => $idGroup, 'REMOTE_PRIMARY_KEY' => $idPracownik]);
- }
- return [
- 'msg' => "Powiązano pracowników z grupą {$idGroup}",
- 'type' => "success",
- ];
- }
- public function fetchGroupPracownicyAjaxAction() {
- Response::sendTryCatchJson(array($this, 'fetchGroupPracownicyAjax'));
- }
- public function fetchGroupPracownicyAjax() {
- $query = ACL::getAclByNamespace('default_db/BI_audit_ENERGA_PRACOWNICY_group/BI_audit_ENERGA_PRACOWNICY_group')->buildQuery([
- 'cols' => [
- 'ID',
- 'ID_USER',
- 'NAZWA',
- ],
- 'f_ID_USER' => "=" . User::getID(),
- 'f_A_STATUS' => "!DELETED",
- ]);
- $items = $query->getItems();
- if (empty($items)) throw new AlertWarningException("Grupy nie istnieją");
- $arrayGroupPracownicy = array();
- foreach ($items as $item) {
-
- $arrayGroupPracownicy[] = [
- 'ID' => $item['ID'],
- 'NAZWA' => $item['NAZWA'],
- ];
- }
- return [
- 'type' => 'success',
- 'msg' => 'fetchGroupPracownicyAjax',
- '__req_args' => $_REQUEST,
- '__args' => $args,
- 'body' => [
- 'itmesGroupPracownicy' => $arrayGroupPracownicy
- ]
- ];
- }
-
-
-
- public function generateBiAuditRaportAjaxAction() {
-
- Response::sendTryCatchJson(array($this, 'generateBiAuditRaportAjax'), $args = 'JSON_FROM_REQUEST_BODY');
-
- }
- public function generateBiAuditRaportAjax($args) {
-
- $depthValue = V::get('depthValue', '', $args);
- if (!$depthValue) {
- throw new Exception("Nie podano wartości dla głębokości powiązań");
- }
-
- $analizaOnlyTargets = V::get('analizaOnlyTargets', '', $args);
- if (!$analizaOnlyTargets) {
- throw new Exception("Nie podano wartości czy zwracać wyniki tylko z obiektami docelowymi");
- }
-
- $pracownicyIds = [];
- $pracownicyIds = V::get('pracownicyIds', '', $args);
- $kontrahenciIds = [];
- $kontrahenciIds = V::get('kontrahenciIds', '', $args);
-
- if ( !$kontrahenciIds && !$pracownicyIds ) {
- throw new Exception("Nie wybrano pozycji do analizy. Wybierz pracowników/kontrahentów.");
- }
-
- $idRaport = DB::getPDO()->insert('BI_audit_ENERGA_RUM_KONTRAHENCI_POWIAZANIA', [
- 'A_RECORD_CREATE_AUTHOR' => User::getLogin(),
- 'A_RECORD_CREATE_DATE' => 'NOW()',
- 'FILE_STATUS' => "TO_GENERATE",
- 'BI_analiza_minDepth' => 1,
- 'BI_analiza_maxDepth' => $depthValue,
- 'BI_analiza_onlyTargets' => analizaOnlyTargets
- ]);
- if ($idRaport > 0) {
- DB::getPDO()->insert('BI_audit_ENERGA_RUM_KONTRAHENCI_POWIAZANIA_HIST', [
- 'ID_USERS2' => $idRaport,
- 'A_RECORD_CREATE_AUTHOR' => User::getLogin(),
- 'A_RECORD_CREATE_DATE' => 'NOW()',
- 'FILE_STATUS' => "TO_GENERATE",
- 'BI_analiza_minDepth' => 1,
- 'BI_analiza_maxDepth' => $depthValue,
- 'BI_analiza_onlyTargets' => analizaOnlyTargets
- ]);
- }
-
- $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');
-
- $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');
-
- if ( !$pracownicyIds ) {
-
- DB::getPDO()->execSql("insert into `{$refPowiazaniaToPracownicy}` (`PRIMARY_KEY`,`REMOTE_PRIMARY_KEY`)
- select '{$idRaport}' as PRIMARY_KEY
- , ID as REMOTE_PRIMARY_KEY
- from `BI_audit_ENERGA_PRACOWNICY`
- ");
- } else {
- foreach ($pracownicyIds as $idPracownik) {
- DB::getPDO()->insert($refPowiazaniaToPracownicy, ['PRIMARY_KEY' => $idRaport, 'REMOTE_PRIMARY_KEY' => $idPracownik]);
- }
- }
-
- if ( !$kontrahenciIds ) {
-
- DB::getPDO()->execSql("insert into `{$refPowiazaniaToKontrahenci}` (`PRIMARY_KEY`,`REMOTE_PRIMARY_KEY`)
- select '{$idRaport}' as PRIMARY_KEY
- , ID as REMOTE_PRIMARY_KEY
- from `BI_audit_ENERGA_RUM_KONTRAHENCI`
- ");
- } else {
- foreach ($kontrahenciIds as $idKontrahent) {
- DB::getPDO()->insert($refPowiazaniaToKontrahenci, ['PRIMARY_KEY' => $idRaport, 'REMOTE_PRIMARY_KEY' => $idKontrahent ]);
- }
- }
- return [
- 'msg' => "Zadanie do wygnerowania raportu zostało zapisane.",
- 'type' => "success",
- 'body' => [
- 'id' => $idRaport,
- ]
- ];
- }
-
- public function defaultViewFormBiAudit($items, $type) {
- $activeFormSteps = '';
- $fieldLabels = [];
- switch($type) {
- case 'KONTRAHENCI':
- $activeFormStepsKontrahent = 'complete';
- $titleHeader = 'KONTRAHENCI';
- $groupFilterList = '
- <div class="menu-item">
- <ul class="padding-0">
- <li><a href="#" title="STWÓRZ GRUPĘ" class="btn btn-default" onClick="createGroupKontrahenci(event)" data-color-noactive="">+ STWÓRZ GRUPĘ</a></li>
- </ul>
- </div>
- <div id="group-kontrahenci" class="btn-group">
- <button class="btn btn-default active" title="Wszyscy" data-group-filter="0">Wszyscy</button>
- </div>';
- $formSmadDepth = '<input type="text" class="form-control smad-depth-kontrahenci" placeholder="1-16" value="" />';
- $formSmadSelectTarget = '<select class="form-control" id="smad-select-target-kontrahenci"><option value="y">tak</option><option value="n">nie</option></select>';
- $formFilterHeadTitle = '<h2 class="title" id="smad-filter-head-title-kontrahenci">Wszyscy</h2>';
- $formFilterHeadDesc = '<p>Liczba pozycji na liście: <span id="smad-filter-desc-kontrahenci">0</span></p>';
- $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>';
- $graphView = '<div class="smad-kontrahenci-graph-view" style="display: none;"></div>';
- $csvExampleKontrahenci = Request::getPathUri() . 'projects/bocian/theme/assets/file_example/kontrahenci_example.zip';
- $formAddNewData ='
- <li><a title="IMPORT KONTRAHENCI" onClick="showViewUploadFile(event, \'Import kontrahentów\', \'kontrahenci\', \'no\', \''.$csvExampleKontrahenci.'\' )" class="btn btn-info">IMPORT KONTRAHENCI</a></li>
- <!--<li><a href="#" title="DODAJ KONTRAHENCI" class="btn btn-info">+ DODAJ KONTRAHENCI</a></li>-->';
- $buttonMoveToGroup = '<a title="DODAJ WYBRANE DO GRUPY" onClick="addKontrahenciToGroup(event)" class="btn btn-info">DODAJ WYBRANE DO GRUPY</a>';
- $buttonMoveToGroup .= '<a title="DODAJ WSZYSTKIE DO GRUPY" onClick="addKontrahenciAllToGroup(event)" class="btn btn-info" style="margin-left:12px">DODAJ WSZYSTKIE DO GRUPY</a>';
- $showButtonNextStep = '';
- $pagination_form = '<div id="pagination-kontrahenci"></div>';
- $acl = ACL::getAclByNamespace("default_db/BI_audit_ENERGA_RUM_KONTRAHENCI/BI_audit_ENERGA_RUM_KONTRAHENCI");
- $fieldList = $acl->getRealFieldList();
- $fieldLabels = array_combine(
- $fieldList,
- array_map(function ($fieldName) use ($acl) {
- return $acl->getFieldLabel($fieldName);
- }, $fieldList)
- );
- DBG::log($fieldLabels, 'array', "fieldLabels (KONTRAHENCI)");
- break;
- case 'PRACOWNICY':
- $titleHeader = 'PRACOWNICY';
- $groupFilterList = '
- <div class="menu-item">
- <ul class="padding-0">
- <li><a href="#" title="STWÓRZ GRUPĘ" class="btn btn-default" onClick="createGroupPracownicy(event)" >+ STWÓRZ GRUPĘ</a></li>
- </ul>
- </div>
- <div id="group-pracownicy" class="btn-group">
- <button class="btn btn-default active" title="Wszyscy" data-group-filter="0">Wszyscy</button>
- </div>';
- $formSmadDepth = '<input type="text" class="form-control smad-depth" placeholder="1-16" value="" />';
- $formSmadSelectTarget = '<select class="form-control" id="smad-select-target"><option value="y">tak</option><option value="n">nie</option></select>';
- $formFilterHeadTitle = '<h2 class="title" id="smad-filter-head-title-pracownicy">Wszyscy</h2>';
- $formFilterHeadDesc = '<p>Liczba pozycji na liście: <span id="smad-filter-desc-pracownicy">0</span></p>';
- $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>';
- $graphView = '<div class="smad-pracownicy-graph-view" style="display: none;"> test sss </div>';
- $csvExamplePracownicy = Request::getPathUri() . 'projects/bocian/theme/assets/file_example/pracownicy_example.zip';
- $formAddNewData ='
- <li><a title="IMPORT PRACOWNIKÓW" onClick="showViewUploadFile(event, \'Import pracowników\', \'pracownicy\', \'yes\', \''.$csvExamplePracownicy.'\' )" class="btn btn-info">IMPORT PRACOWNIKÓW</a></li>
- <!--<li><a href="#" title="DODAJ PRACOWNIKÓW" class="btn btn-info" >+ DODAJ PRACOWNIKÓW</a></li>-->';
- $buttonMoveToGroup = '<a title="DODAJ WYBRANE DO GRUPY" onClick="addPracownikToGroup(event)" class="btn btn-info">DODAJ WYBRANE DO GRUPY</a>';
- $buttonMoveToGroup .= '<a title="DODAJ WSZYSTKIE DO GRUPY" onClick="addPracownikAllToGroup(event)" class="btn btn-info" style="margin-left:12px">DODAJ WSZYSTKIE DO GRUPY</a>';
- $showButtonNextStep = '<a href="'.Request::getPathUri().'index.php?_route=UrlAction_Bocian#KONTRAHENCI" title="DODAJ DO ANALIZY" class="btn btn-primary">DODAJ DO ANALIZY</a>';
- $pagination_form = '<div id="pagination-pracownicy"></div>';
- $acl = ACL::getAclByNamespace("default_db/BI_audit_ENERGA_PRACOWNICY/BI_audit_ENERGA_PRACOWNICY");
- $fieldList = $acl->getRealFieldList();
- $fieldLabels = array_combine(
- $fieldList,
- array_map(function ($fieldName) use ($acl) {
- return $acl->getFieldLabel($fieldName);
- }, $fieldList)
- );
- DBG::log($fieldLabels, 'array', "fieldLabels (PRACOWNICY)");
- break;
- }
- $view = '
- <!-- start:employees-section-->
- <div id="smad-employees-section" class="smad-form-' . $type . '" >
- <div class="container-fluid">
- <div>
- <div class="padding-lr-0">
- <div id="smad-menu-section">
- <div class="col-sm-12 col-md-6 padding-lr-0">
- <div class="menu-items">
- <div class="smad-heder-title menu-item"><span class="smad-line-red">|</span> ' . $titleHeader . ' </div>
- </div>
- </div>
- <div class="col-sm-12 col-md-6 padding-lr-0">
- <div class="form-steps">
- <!-- start:form steps wizard -->
- <div class="row smad-wizard" style="border-bottom:0;">
- <div class="col-xs-4 col-md-4 smad-wizard-step complete"><!-- complited line -->
- <div class="text-center smad-wizard-stepnum"> </div>
- <div class="progress"><div class="progress-bar"></div></div>
- <a href="'.Request::getPathUri().'index.php?_route=UrlAction_Bocian#PRACOWNICY" class="smad-wizard-dot"></a>
- <div class="smad-wizard-info complete text-center">
- <div class="step-item"><a href="'.Request::getPathUri().'index.php?_route=UrlAction_Bocian#PRACOWNICY">Krok 1</a></div>
- <div class="step-title">PRACOWNICY <span class="top--count-selected-item-pracownicy"></span></div>
- </div>
- </div>
- <div class="col-xs-4 col-md-4 smad-wizard-step ' . $activeFormStepsKontrahent . ' ">
- <div class="text-center smad-wizard-stepnum"> </div>
- <div class="progress"><div class="progress-bar"></div></div>
- <a href="'.Request::getPathUri().'index.php?_route=UrlAction_Bocian#KONTRAHENCI" class="smad-wizard-dot"></a>
- <div class="smad-wizard-info text-center">
- <div class="step-item"><a href="'.Request::getPathUri().'index.php?_route=UrlAction_Bocian#KONTRAHENCI">Krok 2</a></div>
- <div class="step-title">KONTRAHENCI <span class="top--count-selected-item-kontrahenci"></span></div>
- </div>
- </div>
- <div class="col-xs-4 col-md-4 smad-wizard-step ">
- <div class="text-center smad-wizard-stepnum"> </div>
- <div class="progress"><div class="progress-bar"></div></div>
- <a href="#" class="smad-wizard-dot"></a>
- <div class="smad-wizard-info text-center">
- <div class="step-item">Krok 3</div>
- <div class="step-title">SZUKANIE POWIĄZAŃ</div>
- </div>
- </div>
- </div>
- <!-- end:form steps wizard -->
- </div>
- </div>
- </div>
- </div>
- </div>
- </div>
- <div class="container-fluid">
- <div class=" padding-lr-0">
- <div class="smad-divider"></div>
- </div>
- </div>
- <!-- start:filters -->
- <div class="container-fluid">
- <div class="row">
- <div>
- <div class="smad-employees-form-section" class="border-top-grey">
- <div class="col-md-9 smad-border-col">
- <div class="menu-items">
- '.$groupFilterList.'
- </div>
- </div>
- <div class="col-md-3">
- <div class="form-input">
- <div class="form-item col-md-7 col-lg-9 smad-heder-title">głębokość powiązań:</div>
- <div class="form-item col-md-5 col-lg-3">
- '.$formSmadDepth.'
- </div>
- </div>
- <div class="form-input">
- <div class="form-item col-md-7 col-lg-9 smad-heder-title">Czy zwracać wyniki tylko ze znalezionymi obiektami docelowymi(z tabeli kontrahentów)?</div>
- <div class="form-item col-md-5 col-lg-3">
- '.$formSmadSelectTarget.'
- </div>
- </div>
- </div>
- </div>
- </div>
- </div>
- </div>
- <!-- end:filters -->
- <!-- start:list employees -->
- <div class="container-fluid">
- <div class="padding-0 smad-employees-list-head">
- <div class="col-md-6">
- <header>
- '.$formFilterHeadTitle.'
- </header>
- <div class="desc">
- '.$formFilterHeadDesc.'
- </div>
- <div class="countSelectedItem">
- '.$countSelectedItem.'
- </div>
- </div>
- <div class="col-md-6">
- <div class="menu-items">
- <div class="menu-item">
- <ul class="padding-0">
- '.$formAddNewData.'
- </ul>
- </div>
- </div>
- </div>
- </div>
- </div>
- <!-- Start: graph-view -->
- <div class="smad-graph-section">
- <div class="container-fluid">
- '.$graphView.'
- </div>
- </div>
- <!-- End: graph-view -->
- <div class="container-fluid">
- <div class="table-responsive padding-0" id="smad-table-' . $type . '">
- ' . $this->showListDataByType($items, $type, $fieldLabels) . '
- </div>
- </div>
- <!-- end:list employees -->
- <!-- start:list paginations employees -->
- <div class="container-fluid ">
- <div>
- '. $pagination_form .'
- </div>
- </div>
- <!-- end:list paginations employees -->
- <!-- start:bottom buttons -->
- <div class="container-fluid smad-employees-bottom-navigation">
- <div class="padding-0">
- <div class="col-lg-6 ">
- '.$buttonMoveToGroup.'
- </div>
- <div class="col-lg-6 text-right">
- ' . $showButtonNextStep . '
- </div>
- </div>
- </div>
- <!-- end:bottom buttons -->
- </div>
- <!-- start:employees-section -->
- <!-- START:bottom generate reaport-->
- <div class="container-fluid smad-generate-reaport">
- <div class="row">
- <div class="container text-center">
- <button type="button" class="btn btn-default smad-generate-reaport-button" onclick="generateBiAuditRaport(event)" id="button-generate-reaport" >GENERUJ RAPORT POWIĄZAŃ</button>
- </div>
- <div class="container smad-generate-reaport-info text-center">
- <div class="step-title"><span class="bottom--count-selected-item-kontrahenci"></span></div>
- <div class="step-title"><span class="bottom--count-selected-item-pracownicy"></span></div>
- <div><strong><span class="bottom--message-warning-critical-search"></span></strong></div>
- </div>
- </div>
- </div>
- <!-- end:bottom generate reaport -->
- ';
- return $view;
- }
- public function showListDataByType($items, $type='PRACOWNICY', $labels) {
- switch ($type) {
- case 'PRACOWNICY':
- return $this->showTablePracownicy($labels);
- break;
- case 'KONTRAHENCI':
- return $this->showTableKontrahenci($labels);
- break;
- }
- }
- }
|