|
@@ -56,11 +56,12 @@ public function formDataCsvFileAjax() {
|
|
|
|
|
|
if (!file_exists($_FILES['file']['tmp_name'])) throw new Exception("Wybierz plik do przesłania.");
|
|
|
|
|
|
- $file = file($_FILES['file']['tmp_name']);
|
|
|
+ $file = file($_FILES['file']['tmp_name']);
|
|
|
+ $showCheckbox = V::get('showCheckbox', '', $args);
|
|
|
|
|
|
- // parsujemy csv to tablicy
|
|
|
- $arrayDataCsv = $this->csvToArray($file, ';', '"', '\n\r');
|
|
|
|
|
|
+ // parsujemy csv to tablicy
|
|
|
+ $arrayDataCsv = $this->csvToArray($file, ';', '"', '\n\r');
|
|
|
|
|
|
|
|
|
$i = 0;
|
|
@@ -71,20 +72,25 @@ public function formDataCsvFileAjax() {
|
|
|
$viewFormCol .= '<tr>';
|
|
|
foreach ( $line as $keyData => $rowData ) {
|
|
|
// utworzenie nagłówków tabeli
|
|
|
- if( $i == 0) { $header .= '<td>' . $keyData . '</td>'; }
|
|
|
+ if( $i == 0) { $header .= '<td style="min-width:160px">' . $keyData . '</td>'; }
|
|
|
// utworzenie inputa do edycji
|
|
|
- $viewFormCol .= '<td><input type="text" name="item['.$i.']['.$keyData.']" value="'.$rowData .'" class="form-control input-lg" /></td>';
|
|
|
+ $viewFormCol .= '<td style="min-width:160px"><input type="text" name="item['.$i.']['.$keyData.']" value="'.$rowData .'" class="form-control input-lg" /></td>';
|
|
|
|
|
|
}
|
|
|
$viewFormCol .= '</tr>';
|
|
|
|
|
|
- // $viewFormCol .= '</div><div style="margin: 20px 0;"></div>';
|
|
|
$i++;
|
|
|
|
|
|
}
|
|
|
|
|
|
- $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;"><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>';
|
|
|
+ // 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 [
|
|
@@ -105,7 +111,7 @@ public function formDataCsvFileAjax() {
|
|
|
*/
|
|
|
public function saveFormCsvFileAjaxAction() {
|
|
|
Response::sendTryCatchJson(array($this, 'saveFormCsvFileAjax'), $args = 'JSON_FROM_REQUEST_BODY');
|
|
|
- Response::sendTryCatchJson(array($this, 'saveFormCsvFileAjax'));
|
|
|
+ //Response::sendTryCatchJson(array($this, 'saveFormCsvFileAjax'));
|
|
|
}
|
|
|
|
|
|
|
|
@@ -228,8 +234,8 @@ public function formDataCsvFileAjax() {
|
|
|
$response['insert'] = 1;
|
|
|
|
|
|
} catch (Exception $e) {
|
|
|
- DBG::log($e);
|
|
|
- $response['error'] = 1;
|
|
|
+ DBG::log($e);
|
|
|
+ $response['error'] = 1;
|
|
|
}
|
|
|
|
|
|
return $response;
|
|
@@ -1070,7 +1076,7 @@ public function showPowiazaniaEnergaRumKontrahenciPowiazania($items) {
|
|
|
</div>';
|
|
|
|
|
|
$formAddNewData ='
|
|
|
- <li><a title="IMPORT KONTRAHENCI" onClick="showViewUploadFile(event, \'Import kontrahentów\', \'kontrahenci\' )" class="btn btn-info">IMPORT KONTRAHENCI</a></li>
|
|
|
+ <li><a title="IMPORT KONTRAHENCI" onClick="showViewUploadFile(event, \'Import kontrahentów\', \'kontrahenci\', \'/projects/bocian/theme/assets/file_example/kontrahenci_example.csv\' )" 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
|
|
|
|
|
|
$showButtonNextStep = '<button type="button" class="btn btn-primary" onClick="generateBiAuditRaport(event)" id="button-generate-reaport">SZUKAJ POWIĄZAŃ</button>';
|
|
@@ -1092,7 +1098,7 @@ public function showPowiazaniaEnergaRumKontrahenciPowiazania($items) {
|
|
|
</div>';
|
|
|
|
|
|
$formAddNewData ='
|
|
|
- <li><a title="IMPORT PRACOWNIKÓW" onClick="showViewUploadFile(event, \'Import pracowników\', \'pracownicy\' )" class="btn btn-info">IMPORT PRACOWNIKÓW</a></li>
|
|
|
+ <li><a title="IMPORT PRACOWNIKÓW" onClick="showViewUploadFile(event, \'Import pracowników\', \'pracownicy\', \'/projects/bocian/theme/assets/file_example/pracownicy_example.csv\' )" 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
|
|
|
|
|
|
$showButtonNextStep = '<a href="index.php?_route=UrlAction_Bocian#KONTRAHENCI" title="DODAJ DO ANALIZY" class="btn btn-primary">DODAJ DO ANALIZY</a>';
|