|
@@ -203,17 +203,33 @@ public function formDataCsvFileAjax() {
|
|
|
|
|
|
* Save data in database
|
|
|
*/
|
|
|
- public function saveDataToDb( $table, $arrayData ) {
|
|
|
+ public function saveDataToDb( $table, $arrayData, $override = false ) {
|
|
|
$response = array();
|
|
|
|
|
|
try {
|
|
|
-
|
|
|
- $responseInsert = DB::getPDO()->insert($table, $arrayData);
|
|
|
+ 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) {
|
|
|
|
|
|
- $response = $this->updateDataToDb( $table, $arrayData );
|
|
|
+
|
|
|
}
|
|
|
|
|
|
return $response;
|
|
@@ -223,21 +239,21 @@ public function formDataCsvFileAjax() {
|
|
|
|
|
|
* Update data in database
|
|
|
*/
|
|
|
- public function updateDataToDb( $table, $arrayData ) {
|
|
|
- $response = array();
|
|
|
-
|
|
|
-
|
|
|
- try {
|
|
|
- $responseInsert = DB::getPDO()->update($table, $arrayData);
|
|
|
- $response['update'] = 1;
|
|
|
-
|
|
|
- } catch (Exception $e) {
|
|
|
- print_r($e);
|
|
|
- $response['error'] = 1;
|
|
|
- }
|
|
|
-
|
|
|
- return $response;
|
|
|
- }
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
|
|
|
|
|
|
|
|
@@ -248,10 +264,10 @@ public function formDataCsvFileAjax() {
|
|
|
|
|
|
$nameTable = null;
|
|
|
switch ($type) {
|
|
|
- case 'PRACOWNICY':
|
|
|
+ case 'KONTRAHENCI':
|
|
|
$nameTable = 'BI_audit_ENERGA_RUM_KONTRAHENCI';
|
|
|
break;
|
|
|
- case 'KONTRAHENCI':
|
|
|
+ case 'PRACOWNICY':
|
|
|
$nameTable = 'BI_audit_ENERGA_PRACOWNICY';
|
|
|
break;
|
|
|
}
|
|
@@ -652,17 +668,22 @@ public function showPowiazaniaEnergaRumKontrahenciPowiazania($items) {
|
|
|
$nazwa = V::get('NAZWA', '', $args);
|
|
|
|
|
|
|
|
|
- $idGroup = DB::getPDO()->insert('BI_audit_ENERGA_KONTRAHENCI_GRUPY', [
|
|
|
+
|
|
|
+ $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
|
|
|
]
|
|
|
];
|
|
|
}
|
|
@@ -995,19 +1016,6 @@ public function showPowiazaniaEnergaRumKontrahenciPowiazania($items) {
|
|
|
];
|
|
|
}
|
|
|
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
return [
|
|
|
'type' => 'success',
|
|
|
'msg' => 'fetchGroupPracownicyAjax',
|