|
@@ -61,24 +61,20 @@ public function formDataCsvFileAjax() {
|
|
|
|
|
|
$arrayDataCsv = $this->csvToArray($file, ';', '"', '\n\r');
|
|
|
|
|
|
+
|
|
|
+
|
|
|
$i = 0;
|
|
|
|
|
|
foreach ( $arrayDataCsv as $line ) {
|
|
|
|
|
|
|
|
|
- $lenArrayLine = count($line);
|
|
|
$viewFormCol .= '<tr>';
|
|
|
- $j = 0;
|
|
|
foreach ( $line as $keyData => $rowData ) {
|
|
|
|
|
|
if( $i == 0) { $header .= '<td>' . $keyData . '</td>'; }
|
|
|
|
|
|
$viewFormCol .= '<td><input type="text" name="item['.$i.']['.$keyData.']" value="'.$rowData .'" class="form-control input-lg" /></td>';
|
|
|
|
|
|
- if ($j == $lenArrayLine - 1) {
|
|
|
- $viewFormCol .= '<td><input type="checkbox" name="item['.$i.'][update]" value="1" /></td>';
|
|
|
- }
|
|
|
- $j++;
|
|
|
}
|
|
|
$viewFormCol .= '</tr>';
|
|
|
|
|
@@ -87,7 +83,8 @@ public function formDataCsvFileAjax() {
|
|
|
|
|
|
}
|
|
|
|
|
|
- $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 .'<td>Zaktualizuj</td></tr></thead><tbody id="smad-csv-data">'. $viewFormCol .'</tbody></table></form></div>';
|
|
|
+ $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>';
|
|
|
|
|
|
|
|
|
return [
|
|
@@ -120,6 +117,7 @@ public function formDataCsvFileAjax() {
|
|
|
$formData = V::get('formData', '', $args);
|
|
|
$enumType = V::get('enumType', '', $args);
|
|
|
|
|
|
+ $override = false;
|
|
|
$arrayInfo = array();
|
|
|
$arrayInfo['insert'] = 0;
|
|
|
$arrayInfo['update'] = 0;
|
|
@@ -136,20 +134,25 @@ public function formDataCsvFileAjax() {
|
|
|
throw new Exception("Wystapił problem podczas przesyłania danych - brak przesłanych danych.");
|
|
|
}
|
|
|
|
|
|
+
|
|
|
+ if ( isset($resultArrayFormdata['override']) ) { $override = true; }
|
|
|
+
|
|
|
+
|
|
|
|
|
|
foreach ( $resultArrayFormdata['item'] as $line ) {
|
|
|
-
|
|
|
- if ( array_key_exists('update', $line) ) {
|
|
|
- $response = $this->updateDataToDb($table, $line);
|
|
|
- } else {
|
|
|
- $response = $this->saveDataToDb($table, $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. Liczba nowych rekordów: (" . $arrayInfo['insert'] . "); Liczba zaktualizowanych rekordów: (" . $arrayInfo['update'] . ")'; Liczba rekordów nie zapisanych: (" . $arrayInfo['error'] . ")" ,
|
|
|
+ 'msg' => "Zapisano dane. " . $textInsert . " " . $textError ,
|
|
|
'type' => "success",
|
|
|
];
|
|
|
|
|
@@ -161,17 +164,14 @@ public function formDataCsvFileAjax() {
|
|
|
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':
|
|
|
- $arrayInfo['insert'] = $arrayInfo['insert'] + 1;
|
|
|
- break;
|
|
|
- case 'update':
|
|
|
- $arrayInfo['update'] = $arrayInfo['insert'] + 1;
|
|
|
+ $countData['insert'] = $arrayInfo['insert'] + 1;
|
|
|
break;
|
|
|
case 'error':
|
|
|
- $arrayInfo['error'] = $arrayInfo['insert'] + 1;
|
|
|
+ $countData['error'] = $arrayInfo['insert'] + 1;
|
|
|
break;
|
|
|
}
|
|
|
|
|
@@ -228,35 +228,14 @@ public function formDataCsvFileAjax() {
|
|
|
$response['insert'] = 1;
|
|
|
|
|
|
} catch (Exception $e) {
|
|
|
-
|
|
|
-
|
|
|
+ DBG::log($e);
|
|
|
+ $response['error'] = 1;
|
|
|
}
|
|
|
|
|
|
return $response;
|
|
|
}
|
|
|
|
|
|
|
|
|
-
|
|
|
- * Update data in database
|
|
|
- */
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
|
|
|
* Get name table by enum
|
|
|
*/
|
|
@@ -477,7 +456,7 @@ public function showPowiazaniaEnergaRumKontrahenciPowiazania($items) {
|
|
|
$idGroup = V::get('filterIdGroup', 0, $_REQUEST, 'int');
|
|
|
if ($idGroup < 0) $idGroup = 0;
|
|
|
|
|
|
- $limit = 5;
|
|
|
+ $limit = 20;
|
|
|
|
|
|
$limitstart = V::get('limitstart', 0, $_REQUEST, 'int');
|
|
|
if ($limitstart < 0) $limitstart = 0;
|
|
@@ -582,36 +561,6 @@ public function showPowiazaniaEnergaRumKontrahenciPowiazania($items) {
|
|
|
];
|
|
|
}
|
|
|
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
|
|
|
public function showTableKontrahenci($items) {
|
|
|
$view = '<form class="form-horizontal" method="post">
|
|
@@ -776,7 +725,7 @@ public function showPowiazaniaEnergaRumKontrahenciPowiazania($items) {
|
|
|
$idGroup = V::get('filterIdGroup', 0, $_REQUEST, 'int');
|
|
|
if ($idGroup < 0) $idGroup = 0;
|
|
|
|
|
|
- $limit = 2;
|
|
|
+ $limit = 20;
|
|
|
|
|
|
$limitstart = V::get('limitstart', 0, $_REQUEST, 'int');
|
|
|
if ($limitstart < 0) $limitstart = 0;
|
|
@@ -917,7 +866,6 @@ public function showPowiazaniaEnergaRumKontrahenciPowiazania($items) {
|
|
|
|
|
|
public function createPracownicyGroupAjaxAction() {
|
|
|
Response::sendTryCatchJson(array($this, 'createPracownicyGroupAjax'), $args = 'JSON_FROM_REQUEST_BODY');
|
|
|
-
|
|
|
}
|
|
|
public function createPracownicyGroupAjax($args) {
|
|
|
$nazwa = V::get('NAZWA', '', $args);
|