12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280 |
- <?php
- Lib::loadClass('RouteToolBase');
- Lib::loadClass('UI');
- Lib::loadClass('Response');
- Lib::loadClass('Request');
- // index.php?_route=UrlAction_BiAuditRaport - uruchamia defaultAction
- class Bocian extends RouteToolBase {
- 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 id="smad-wrapper">'; // todo: sprawdzi czy można usunać
- 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>';
- // echo '<div class="container-bi_audit_form_raport_data" 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_KONTRAHENCI' => $this->getLink('fetchKontrahenciAjax'),
- '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'),
- ]);
- echo '</div>'; // #smad-wrapper
- UI::dol();
- }
- /**
- * Funkcja ajax do odebrania danych z przesłanego pliku CSV do parsowania
- */
- public function formDataCsvFileAjaxAction() {
- Response::sendTryCatchJson(array($this, 'formDataCsvFileAjax'));
- }
- /**
- * Funkcja parsuje dane wgrywanego plku csv i zwraca dane w inputach
- */
- 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', '', $args);
- $showCheckbox = V::get('showCheckbox', 0, $_REQUEST, 'string');
- // parsujemy csv to tablicy
- $arrayDataCsv = $this->csvToArray($file, ';', '"', '\n\r');
- $i = 0;
- // tworzymy rekordy
- foreach ( $arrayDataCsv as $line ) {
- //$viewFormCol .= '<div style="margin: 10px 0"><span>'.($i + 1).'. </span>';
- $viewFormCol .= '<tr>';
- foreach ( $line as $keyData => $rowData ) {
- // utworzenie nagłówków tabeli
- if( $i == 0) { $header .= '<td style="min-width:160px">' . $keyData . '</td>'; }
- // utworzenie inputa do edycji
- $viewFormCol .= '<td style="min-width:160px"><input type="text" name="item['.$i.']['.$keyData.']" value="'.$rowData .'" class="form-control input-lg" /></td>';
- }
- $viewFormCol .= '</tr>';
- $i++;
- }
- // pokaz checkbox jeśli ma status showCheckbox
- 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 $viewFormHtml;
- return [
- 'type' => 'success',
- 'msg' => 'OK',
- '__req_args' => $_REQUEST,
- '__args' => $args,
- 'body' => [
- 'view' => $viewFormHtml,
- ]
- ];
- }
- /**
- * Funkcja ajax do odebrania danych z przesłanego formularza z parsowanego CSV
- */
- public function saveFormCsvFileAjaxAction() {
- Response::sendTryCatchJson(array($this, 'saveFormCsvFileAjax'), $args = 'JSON_FROM_REQUEST_BODY');
- //Response::sendTryCatchJson(array($this, 'saveFormCsvFileAjax'));
- }
- /**
- * Funkcja ajax do zapisania danych z przesłanego formularza z parsowanego CSV
- */
- public function saveFormCsvFileAjax($args) {
- //dane z formularza
- $formData = V::get('formData', '', $args);
- $enumType = V::get('enumType', '', $args);
- $override = false; // false - nie nadpisujemy danych
- $arrayInfo = array();
- $arrayInfo['insert'] = 0;
- $arrayInfo['update'] = 0;
- $arrayInfo['error'] = 0;
- // pobranie nazwy tabeli z db
- $table = $this->getNameTableByEnum( strtoupper($enumType) );
- if ( $table == null ) throw new Exception('Błąd zapisu. Tabela w db nie istnieje');
- // unserialize data from serialize in javascript
- parse_str($formData, $resultArrayFormdata);
- if ( count($resultArrayFormdata['item']) == 0) {
- throw new Exception("Wystapił problem podczas przesyłania danych - brak przesłanych danych.");
- }
- // ustawienie true jeśli wyrabno nadpisanie danych
- if ( isset($resultArrayFormdata['override']) ) { $override = true; } // aktualizuj rekordy/nadpisz istniejace
- // dodanie/aktualizacjia wpisu
- foreach ( $resultArrayFormdata['item'] as $line ) {
- $response = $this->saveDataToDb($table, $line, $override);
- // tworzymy listę informacji o liczbie nowych/zaktualizowanych/z błedami rekordów
- $arrayInfo = $this->responseCountListInfoAboutSaveData($response, $arrayInfo);
- }
- // utworzenie komunikatów
- 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",
- ];
- }
- /**
- * Count list
- */
- 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 parse csv to array
- * @param $filename - file data from FILE
- * @param $delimiter - delimiter
- * @param $enclosure -
- * @param $escape -
- */
- 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;
- }
- /**
- * Save data in database
- */
- 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' => "fv-sync-from-graffiti",
- ],
- '@update' => array_merge($arrayData, [
- 'A_RECORD_UPDATE_DATE' => 'NOW()',
- 'A_RECORD_UPDATE_AUTHOR' => "fv-sync-from-graffiti",
- ]),
- ]));
- } 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;
- }
- /**
- * Get name table by enum
- */
- 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')); // , $args = 'JSON_FROM_REQUEST_BODY');
- }
- 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' => [ // TODO:? propertyName = []
- '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
- ]);
- // $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="">
- <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,
- ]
- ];
- }
- /**
- * KONTRAHENCI
- */
- public function fetchKontrahenciAjaxAction() {
- Response::sendTryCatchJson(array($this, 'fetchKontrahenciAjax'));
- }
- public function fetchKontrahenciAjax($args) {
- $idGroup = V::get('filterIdGroup', 0, $_REQUEST, 'int'); // TODO: dla filtrów "Wysokiego ryzyka" - przekazywany ID rekodu
- if ($idGroup < 0) $idGroup = 0;
- $limit = 20;
- $limitstart = V::get('limitstart', 0, $_REQUEST, 'int');
- if ($limitstart < 0) $limitstart = 0;
- $page = V::get('page', 0, $_REQUEST, 'int');
- $limitstart = ($page - 1) * $limit;
- $search = V::get('search', '', $_REQUEST);
- $searchParams = [];
- if (!empty($search)) {
- $ogcSearch = "*{$search}*"; // wildCard="*" -> mysql '%'
- $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',
- ];
- // - ID
- // - ID_USER - id usera który stworzył grupę (tylko dla niego będzie widoczna)
- // - NAZWA - nazwa grupy
- // - 'default_db/BI_audit_ENERGA_RUM_KONTRAHENCI/BI_audit_ENERGA_KONTRAHENCI' minOccurs="0" maxOccurs="unbounded"
- }
- $acl = ACL::getAclByNamespace('default_db/BI_audit_ENERGA_RUM_KONTRAHENCI/BI_audit_ENERGA_RUM_KONTRAHENCI');
- $query = $acl->buildQuery(array_merge([
- 'cols' => [ // TODO:? propertyName = []
- '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',
- 'A_STATUS',
- 'A_STATUS_INFO',
- 'Dodano',
- 'L_APPOITMENT_USER',
- 'Podmiot_dominujacy',
- 'Tytul_dokumentu',
- 'ownCompany',
- 'uwagi',
- ],
- //'f_ID' => $id,
- 'limit' => $limit,
- 'limitstart' => $limitstart, // offset
- ], $searchParams, $backRefFilter));
- $total = $query->getTotal();
- $items = $query->getItems();
- $pagination = array();
- $pagination['total_items'] = $total;
- $pagination['size'] = ceil($total/$limit); // pages size
- $pagination['current'] = $page;
- $pagination['limit'] = $limit;
- return [
- 'type' => 'success',
- 'msg' => 'showKontrajenci',
- '__req_args' => $_REQUEST,
- '__args' => $args,
- 'body' => [
- 'items' => $items,
- //'view' => $this->htmlViewFormBiAudit($items, 'KONTRAHENCI'),
- 'pagination' => $pagination
- ]
- ];
- }
- public function showTableKontrahenci($items) {
- $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>ID</td>
- <td>Nazwa grupy kapitalowej</td>
- <td>Pelna nazwa kontrahenta</td>
- <td>Numer kontrahenta</td>
- <td>Skrócona nazwa kontrahenta</td>
- <td>Typ_kontrahenta</td>
- <td>NIP</td>
- <td>KRS</td>
- <td>Regon</td>
- <td>PESEL</td>
- <td>Forma prawna działalności</td>
- <td>Ulica</td>
- <td>Numer budynku</td>
- <td>Numer mieszkania lokalu</td>
- <td>Miejscowosc</td>
- <td>Kod pocztowy</td>
- <td>Kraj</td>
- <td>Telefon</td>
- <td>Fax</td>
- <td>Mail</td>
- <td>A_ADM_COMPANY</td>
- <td>A_CLASSIFIED</td>
- <td>A_STATUS</td>
- <td>A_STATUS_INFO</td>
- <td>Dodano</td>
- <td>L_APPOITMENT_USER</td>
- <td>Podmiot dominujacy</td>
- <td>Tytul dokumentu</td>
- <td>ownCompany</td>
- <td>uwagi</td>
- </tr>
- </thead>
- <tbody id="body-kontrahenci">
- </tbody></table>
- </form>
- ';
- return $view;
- }
- // tworzenie grupy kontrahentów
- public function createKontrahenciGroupAjaxAction() {
- 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
- }
- public function createKontrahenciGroupAjax($args) {
- $nazwa = V::get('NAZWA', '', $args);
- // TODO: vlaidacja nazwy - sprawdzenie czy już nie występuje
- $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
- ]
- ];
- }
- // Dodanie do grupy filtra kontrahentów
- public function addKontrahenciToGroupAjaxAction() {
- 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
- }
- public function addKontrahenciToGroupAjax($args) {
- $idGroup = V::get('idGroup', '', $args);
- $kontrahenciIds = V::get('kontrahenciIds', '', $args);
- // validate
- if (!$idGroup) throw new Exception("Nie wybrano grupa");
- if (!$kontrahenciIds || count($kontrahenciIds) == 0 ) throw new Exception("Proszę wybrać kontrahentów");
- $group = ACL::getAclByNamespace('default_db/BI_audit_ENERGA_KONTRAHENCI_group/BI_audit_ENERGA_KONTRAHENCI_group')->buildQuery([
- 'cols' => [ // TODO:? propertyName = []
- 'ID',
- 'ID_USER',
- 'NAZWA',
- ],
- // 'f_ID_USER' => User::getID()
- ])->getItem($idGroup);
- if (!$group) throw new Exception("Grupa nie istnieje");
- if (User::getID() != $group['ID_USER']) throw new Exception("Brak uprawnień do grupy");
- // $refGrupyToPracownicy = ACL::getRefTable('obiekt główny', 'nazwa pola - powiązane rekordy');
- $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' => [ // TODO:? propertyName = []
- '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) {
- // if (User::getID() != $item['ID_USER']) throw new Exception("Brak uprawnień do grupy");
- $arrayGroupKontrahenci[] = [
- 'NAZWA' => $item['NAZWA'],
- 'ID' => $item['ID'],
- ];
- }
- return [
- 'type' => 'success',
- 'msg' => 'fetchGroupKontrahenciAjax',
- '__req_args' => $_REQUEST,
- '__args' => $args,
- 'body' => [
- 'itemsGroupKontrahenci' => $arrayGroupKontrahenci
- ]
- ];
- }
- /*
- * PRACOWNICY
- */
- public function fetchPracownicyAjaxAction() {
- Response::sendTryCatchJson(array($this, 'fetchPracownicyAjax'));
- }
- public function fetchPracownicyAjax($args) {
- $idGroup = V::get('filterIdGroup', 0, $_REQUEST, 'int'); // TODO: dla filtrów "Wysokiego ryzyka" - przekazywany ID rekodu
- if ($idGroup < 0) $idGroup = 0;
- $limit = 20;
- $limitstart = V::get('limitstart', 0, $_REQUEST, 'int');
- if ($limitstart < 0) $limitstart = 0;
- $page = V::get('page', 0, $_REQUEST, 'int');
- $limitstart = ($page - 1) * $limit;
- $search = V::get('search', '', $_REQUEST);
- $searchParams = [];
- if (!empty($search)) {
- $ogcSearch = "*{$search}*"; // wildCard="*" -> mysql '%'
- $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', // TODO: nowy rejetr na grupy / filty pracowników
- 'primaryKey' => $idGroup,
- 'fieldName' => 'default_db__x3A__BI_audit_ENERGA_PRACOWNICY:BI_audit_ENERGA_PRACOWNICY',
- ];
- // TODO: Storage dodać obiekt xsd default_db/BI_audit_ENERGA_PRACOWNICY_group/BI_audit_ENERGA_PRACOWNICY_group:
- // - ID
- // - ID_USER - id usera który stworzył grupę (tylko dla niego będzie widoczna)
- // - NAZWA - nazwa grupy
- // - 'default_db/BI_audit_ENERGA_PRACOWNICY/BI_audit_ENERGA_PRACOWNICY' minOccurs="0" maxOccurs="unbounded"
- }
- $acl = ACL::getAclByNamespace('default_db/BI_audit_ENERGA_PRACOWNICY/BI_audit_ENERGA_PRACOWNICY');
- $query = $acl->buildQuery(array_merge([
- 'cols' => [ // TODO:? propertyName = []
- 'ID',
- 'imiona',
- 'nazwisko',
- 'nip',
- 'pesel',
- 'regon',
- 'source',
- 'A_ADM_COMPANY',
- 'A_CLASSIFIED',
- 'A_STATUS',
- 'A_STATUS_INFO',
- 'L_APPOITMENT_USER',
- 'default_db__x3A__BI_audit_ENERGA_PRACOWNICY_adresy:BI_audit_ENERGA_PRACOWNICY_adresy/*'
- ],
- //'f_ID' => $id,
- 'limit' => $limit,
- 'limitstart' => $limitstart, // offset
- // 'order_by' => 'ID', // sortowanie po kolumnie
- // 'order_dir' => 'DESC', // kierunek sortowania
- // 'f_nip' = "=12345", // szukamy dokładnie tej wartości - mysql: where nip = "12345"
- // 'f_nip' = "12345", // szukamy dokładnie tej wartości - mysql: where nip like "%12345%"
- // 'f_nip' = "12345%", // szukamy dokładnie tej wartości - mysql: where nip like "12345%"
- // 'f_ID' = "=12345", // szukamy dokładnie tej wartości - mysql: where ID = "12345"
- ], $searchParams, $backRefFilter));
- $total = $query->getTotal();
- $items = $query->getItems();
- $pagination = array();
- $pagination['total_items'] = $total;
- $pagination['size'] = ceil($total/$limit); // pages size
- $pagination['current'] = $page;
- $pagination['limit'] = $limit;
- // { // tworzenie własnego zapytanie mysql
- // $rootTableName = $acl->getRootTableName();
- // DB::getPDO()->fetchAll("
- // select t.*
- // from {$rootTableName} t
- // where t.ID in (
- // select x.ID
- // from ... x
- // where
- // )
- // ");
- // }
- return [
- 'type' => 'success',
- 'msg' => 'showPracownicy',
- '__req_args' => $_REQUEST,
- '__args' => $args,
- 'body' => [
- 'items' => $items,
- //'view' => $this->htmlViewFormBiAudit($items, 'PRACOWNICY'),
- 'pagination' => $pagination
- ]
- ];
- }
- public function showTablePracownicy() {
- $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>ID</td>
- <td>Imię/Imiona</td>
- <td>Nazwisko</td>
- <td>NIP</td>
- <td>Pesel</td>
- <td>Regon</td>
- <td>source</td>
- <td>A_ADM_COMPANY</td>
- <td>A_CLASSIFIED</td>
- <td>A_STATUS</td>
- <td>A_STATUS_INFO</td>
- <td>L_APPOITMENT_USER</td>
- <td>Adresy</td>
- </tr>
- </thead>
- <tbody id="body-pracownicy">
- </tbody></table>
- </form>';
- return $view;
- }
- // tworzenie grupy pracowników
- public function createPracownicyGroupAjaxAction() {
- 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
- }
- public function createPracownicyGroupAjax($args) {
- $nazwa = V::get('NAZWA', '', $args);
- // TODO: vlaidacja nazwy - sprawdzenie czy już nie występuje
- // validate
- if (!$nazwa) throw new Exception("Nie wybrano grupa");
- //if (!$pracownicyIds || count($pracownicyIds) == 0 ) throw new Exception("Proszę wybrać pracowników");
- $idGroup = DB::getPDO()->insert('BI_audit_ENERGA_PRACOWNICY_group', [
- 'A_RECORD_CREATE_AUTHOR' => User::getLogin(),
- 'A_RECORD_CREATE_DATE' => 'NOW()',
- // 'A_STATUS' => 'WAITING', // jeśli trzeba to ustawić
- 'NAZWA' => $nazwa,
- ]);
- //todo: Piotrku czy hist tabele bedziemy uzupełniac ?
- // DB::getPDO()->insert('BI_audit_ENERGA_PRACOWNICY_group_HIST', [
- // 'A_RECORD_CREATE_AUTHOR' => User::getLogin(),
- // 'A_RECORD_CREATE_DATE' => 'NOW()',
- // 'ID_USERS2' => $idRaport,
- // // 'A_STATUS' => 'WAITING', // jeśli trzeba to ustawić
- // 'NAZWA' => $nazwa,
- // ]);
- return [
- 'msg' => "Utworzona grupę {$idGroup}",
- 'type' => "success",
- 'body' => [
- 'id' => $idGroup,
- ]
- ];
- }
- // Dodanie do grupy filtra pracowników
- public function addPracownicyToGroupAjaxAction() {
- 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
- }
- public function addPracownicyToGroupAjax($args) {
- $idGroup = V::get('idGroup', '', $args);
- $pracownicyIds = V::get('pracownicyIds', '', $args);
- // validate
- if (!$idGroup) throw new Exception("Nie wybrano grupa");
- if (!$pracownicyIds || count($pracownicyIds) == 0 ) throw new Exception("Proszę wybrać pracowników");
- // TODO: SPRWADZENIE CZY NIE DODANOU JUZ PRACOWNIKAS
- // default_db/BI_audit_ENERGA_PRACOWNICY_group/BI_audit_ENERGA_PRACOWNICY_group
- // default_db/BI_audit_ENERGA_PRACOWNICY/BI_audit_ENERGA_PRACOWNICY
- $group = ACL::getAclByNamespace('default_db/BI_audit_ENERGA_PRACOWNICY_group/BI_audit_ENERGA_PRACOWNICY_group')->buildQuery([
- 'cols' => [ // TODO:? propertyName = []
- 'ID',
- 'ID_USER',
- 'NAZWA',
- ],
- // 'f_ID_USER' => User::getID()
- ])->getItem($idGroup);
- if (!$group) throw new Exception("Grupa nie istnieje");
- if (User::getID() != $group['ID_USER']) throw new Exception("Brak uprawnień do grupy");
- // $refGrupyToPracownicy = ACL::getRefTable('obiekt główny', 'nazwa pola - powiązane rekordy');
- $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' => [ // TODO:? propertyName = []
- 'ID',
- 'ID_USER',
- 'NAZWA',
- ],
- 'f_ID_USER' => "=" . User::getID(), // szukamy dokładnie tej wartości - mysql: where ID_USER = "1"
- 'f_A_STATUS' => "!DELETED", // `A_STATUS` != 'DELETED'
- ]);
- $items = $query->getItems();
- if (empty($items)) throw new AlertWarningException("Grupy nie istnieją");
- $arrayGroupPracownicy = array();
- foreach ($items as $item) {
- // if (User::getID() != $item['ID_USER']) throw new Exception("Brak uprawnień do grupy"); // or skip - continue;
- $arrayGroupPracownicy[] = [
- 'ID' => $item['ID'],
- 'NAZWA' => $item['NAZWA'],
- ];
- }
- return [
- 'type' => 'success',
- 'msg' => 'fetchGroupPracownicyAjax',
- '__req_args' => $_REQUEST,
- '__args' => $args,
- 'body' => [
- 'itmesGroupPracownicy' => $arrayGroupPracownicy
- ]
- ];
- }
- // 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 generateBiAuditRaportAjaxAction() {
- //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, 'generateBiAuditRaportAjax'), $args = 'JSON_FROM_REQUEST_BODY');
- //Response::sendTryCatchJson(array($this, 'generateBiAuditRaportAjax'));
- }
- public function generateBiAuditRaportAjax($args) {
- // głebokość powiazan
- $depthValue = V::get('depthValue', '', $args);
- if (!$depthValue) {
- throw new Exception("Nie podano wartości dla głębokości powiązań");
- }
- // Tworzenie relacji Raport do Pracownicy
- $pracownicyIds = []; // array z nr ID na podstawie wysłanego formularza
- $pracownicyIds = V::get('pracownicyIds', '', $args);
- // walidacja id pracowników
- if (!$pracownicyIds) {
- throw new Exception("Nie wybrano pracowników");
- }
- $kontrahenciIds = []; // array z nr ID na podstawie wysłanego formularza
- $kontrahenciIds = V::get('kontrahenciIds', '', $args);
- // walidacja id kontrahetów
- if (!$kontrahenciIds) {
- throw new Exception("Nie wybrano kontrahentów");
- }
- // Tworzenie rekrodu w bazie - Raport -
- $idRaport = DB::getPDO()->insert('BI_audit_ENERGA_RUM_KONTRAHENCI_POWIAZANIA', [
- 'A_RECORD_CREATE_AUTHOR' => User::getLogin(),
- 'A_RECORD_CREATE_DATE' => 'NOW()',
- 'A_STATUS' => 'WAITING', // TODO: czy trzeba to ustawić (pytanie do Mariusza)
- 'FILE_STATUS' => "TO_GENERATE",
- 'BI_analiza_minDepth' => 1,
- 'BI_analiza_maxDepth' => $depthValue
- ]);
- // Tworzenie relacji Raport do Pracownicy
- $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
- $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' => "Zadanie do wygnerowania raportu zostało zapisane.",
- 'type' => "success",
- 'body' => [
- 'id' => $idRaport,
- ]
- ];
- }
- /**
- * Widok formularza dodawania pracowników i kontrahentów
- */
- public function defaultViewFormBiAudit($items, $type) {
- $activeFormSteps = '';
- 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>';
- $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>';
- $formAddNewData ='
- <li><a title="IMPORT KONTRAHENCI" onClick="showViewUploadFile(event, \'Import kontrahentów\', \'kontrahenci\', \'no\', \'/projects/bocian/theme/assets/file_example/kontrahenci_example.zip\' )" class="btn btn-info">IMPORT KONTRAHENCI</a></li>
- <!--<li><a href="#" title="DODAJ KONTRAHENCI" class="btn btn-info">+ DODAJ KONTRAHENCI</a></li>-->'; //todo: dodać obsługe doddawania kontrahentow
- $buttonMoveToGroup = '<a title="PRZENIEŚ DO GRUPY" onClick="addKontrahenciToGroup(event)" class="btn btn-info">PRZENIEŚ DO GRUPY</a>';
- $showButtonNextStep = '<button type="button" class="btn btn-primary" onClick="generateBiAuditRaport(event)" id="button-generate-reaport">SZUKAJ POWIĄZAŃ</button>';
- $pagination_form = '<div id="pagination-kontrahenci"></div>';
- 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>';
- $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>';
- $formAddNewData ='
- <li><a title="IMPORT PRACOWNIKÓW" onClick="showViewUploadFile(event, \'Import pracowników\', \'pracownicy\', \'yes\', \'/projects/bocian/theme/assets/file_example/pracownicy_example.zip\' )" 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>-->'; //todo: dodać obsługe doddawania pracownikow
- $buttonMoveToGroup = '<a title="PRZENIEŚ DO GRUPY" onClick="addPracownikToGroup(event)" class="btn btn-info">PRZENIEŚ 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>';
- 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</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</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-6 smad-heder-title">głębokość powiązań:</div>
- <div class="form-item col-md-6">
- <input type="text" class="form-control smad-depth" placeholder="1-16" value="" />
- </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>
- <div class="col-md-6">
- <div class="menu-items">
- <div class="menu-item">
- <ul class="padding-0">
- '.$formAddNewData.'
- </ul>
- </div>
- </div>
- </div>
- </div>
- </div>
- <div class="container-fluid">
- <div class="table-responsive padding-0" id="smad-table-' . $type . '">
- ' . $this->showListDataByType($items, $type) . '
- </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 -->
- ';
- return $view;
- }
- public function showListDataByType($items, $type='PRACOWNICY') {
- switch ($type) {
- case 'PRACOWNICY':
- return $this->showTablePracownicy();
- break;
- case 'KONTRAHENCI':
- return $this->showTableKontrahenci($items);
- break;
- }
- }
- }
|