|
@@ -1365,7 +1365,7 @@ public function showPowiazaniaEnergaRumKontrahenciPowiazania($items) {
|
|
$backRefFilter = [];
|
|
$backRefFilter = [];
|
|
if ($idGroup > 0) {
|
|
if ($idGroup > 0) {
|
|
$backRefFilter['__backRef'] = [
|
|
$backRefFilter['__backRef'] = [
|
|
- 'namespace' => 'default_db/BI_audit_ENERGA_KONTRAHENCI_group/BI_audit_ENERGA_KONTRAHENCI_group',
|
|
|
|
|
|
+ 'namespace' => 'default_db/BI_audit_ENERGA_PRACOWNICY_group/BI_audit_ENERGA_PRACOWNICY_group',
|
|
'primaryKey' => $idGroup,
|
|
'primaryKey' => $idGroup,
|
|
'fieldName' => 'default_db__x3A__BI_audit_ENERGA_RUM_KONTRAHENCI:BI_audit_ENERGA_RUM_KONTRAHENCI',
|
|
'fieldName' => 'default_db__x3A__BI_audit_ENERGA_RUM_KONTRAHENCI:BI_audit_ENERGA_RUM_KONTRAHENCI',
|
|
];
|
|
];
|
|
@@ -1456,7 +1456,7 @@ public function showPowiazaniaEnergaRumKontrahenciPowiazania($items) {
|
|
$backRefFilter = [];
|
|
$backRefFilter = [];
|
|
if ($idGroup > 0) {
|
|
if ($idGroup > 0) {
|
|
$backRefFilter['__backRef'] = [
|
|
$backRefFilter['__backRef'] = [
|
|
- 'namespace' => 'default_db/BI_audit_ENERGA_KONTRAHENCI_group/BI_audit_ENERGA_KONTRAHENCI_group',
|
|
|
|
|
|
+ 'namespace' => 'default_db/BI_audit_ENERGA_PRACOWNICY_group/BI_audit_ENERGA_PRACOWNICY_group',
|
|
'primaryKey' => $idGroup,
|
|
'primaryKey' => $idGroup,
|
|
'fieldName' => 'default_db__x3A__BI_audit_ENERGA_RUM_KONTRAHENCI:BI_audit_ENERGA_RUM_KONTRAHENCI',
|
|
'fieldName' => 'default_db__x3A__BI_audit_ENERGA_RUM_KONTRAHENCI:BI_audit_ENERGA_RUM_KONTRAHENCI',
|
|
];
|
|
];
|
|
@@ -2078,7 +2078,7 @@ public function showPowiazaniaEnergaRumKontrahenciPowiazania($items) {
|
|
// TODO: vlaidacja nazwy - sprawdzenie czy już nie występuje
|
|
// TODO: vlaidacja nazwy - sprawdzenie czy już nie występuje
|
|
|
|
|
|
|
|
|
|
- $idGroup = DB::getPDO()->insert('BI_audit_ENERGA_KONTRAHENCI_group', [
|
|
|
|
|
|
+ $idGroup = DB::getPDO()->insert('BI_audit_ENERGA_PRACOWNICY_group', [
|
|
'A_RECORD_CREATE_AUTHOR' => User::getLogin(),
|
|
'A_RECORD_CREATE_AUTHOR' => User::getLogin(),
|
|
'A_RECORD_CREATE_DATE' => 'NOW()',
|
|
'A_RECORD_CREATE_DATE' => 'NOW()',
|
|
'NAZWA' => $nazwa,
|
|
'NAZWA' => $nazwa,
|
|
@@ -2117,7 +2117,7 @@ public function showPowiazaniaEnergaRumKontrahenciPowiazania($items) {
|
|
} break;
|
|
} break;
|
|
default: throw new Exception("Missing type");
|
|
default: throw new Exception("Missing type");
|
|
}
|
|
}
|
|
- $group = ACL::getAclByNamespace('default_db/BI_audit_ENERGA_KONTRAHENCI_group/BI_audit_ENERGA_KONTRAHENCI_group')->buildQuery([
|
|
|
|
|
|
+ $group = ACL::getAclByNamespace('default_db/BI_audit_ENERGA_PRACOWNICY_group/BI_audit_ENERGA_PRACOWNICY_group')->buildQuery([
|
|
'cols' => [ // TODO:? propertyName = []
|
|
'cols' => [ // TODO:? propertyName = []
|
|
'ID',
|
|
'ID',
|
|
'ID_USER',
|
|
'ID_USER',
|
|
@@ -2158,7 +2158,7 @@ public function showPowiazaniaEnergaRumKontrahenciPowiazania($items) {
|
|
$backRefFilter = [];
|
|
$backRefFilter = [];
|
|
if ($args__idGroup > 0) {
|
|
if ($args__idGroup > 0) {
|
|
$backRefFilter['__backRef'] = [
|
|
$backRefFilter['__backRef'] = [
|
|
- 'namespace' => 'default_db/BI_audit_ENERGA_KONTRAHENCI_group/BI_audit_ENERGA_KONTRAHENCI_group',
|
|
|
|
|
|
+ 'namespace' => 'default_db/BI_audit_ENERGA_PRACOWNICY_group/BI_audit_ENERGA_PRACOWNICY_group',
|
|
'primaryKey' => $args__idGroup,
|
|
'primaryKey' => $args__idGroup,
|
|
'fieldName' => 'default_db__x3A__BI_audit_ENERGA_RUM_KONTRAHENCI:BI_audit_ENERGA_RUM_KONTRAHENCI',
|
|
'fieldName' => 'default_db__x3A__BI_audit_ENERGA_RUM_KONTRAHENCI:BI_audit_ENERGA_RUM_KONTRAHENCI',
|
|
];
|
|
];
|
|
@@ -2185,12 +2185,12 @@ public function showPowiazaniaEnergaRumKontrahenciPowiazania($items) {
|
|
}, $items);
|
|
}, $items);
|
|
}
|
|
}
|
|
|
|
|
|
- // $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]);
|
|
|
|
- }
|
|
|
|
|
|
+ ACL::addListRef(
|
|
|
|
+ $rootObjectNamespace = 'default_db/BI_audit_ENERGA_PRACOWNICY_group/BI_audit_ENERGA_PRACOWNICY_group',
|
|
|
|
+ $fieldTypeName = 'default_db__x3A__BI_audit_ENERGA_RUM_KONTRAHENCI:BI_audit_ENERGA_RUM_KONTRAHENCI',
|
|
|
|
+ $refPrimaryKey = $idGroup,
|
|
|
|
+ $refListRemotePrimaryKey = $kontrahenciIds
|
|
|
|
+ );
|
|
|
|
|
|
return [
|
|
return [
|
|
'msg' => "Powiązano kontrahentów z grupą {$idGroup}",
|
|
'msg' => "Powiązano kontrahentów z grupą {$idGroup}",
|
|
@@ -2230,15 +2230,12 @@ public function showPowiazaniaEnergaRumKontrahenciPowiazania($items) {
|
|
if (!$group) throw new Exception("Grupa nie istnieje");
|
|
if (!$group) throw new Exception("Grupa nie istnieje");
|
|
if (User::getID() != $group['ID_USER']) throw new Exception("Brak uprawnień do grupy");
|
|
if (User::getID() != $group['ID_USER']) throw new Exception("Brak uprawnień do grupy");
|
|
|
|
|
|
- $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 $pracownikIds) {
|
|
|
|
- $id = (int)$pracownikIds;
|
|
|
|
- DB::getPDO()->execSql(" delete from `{$refGrupyToPracownicy}` where PRIMARY_KEY = :pk and REMOTE_PRIMARY_KEY = :remote_pk ", [
|
|
|
|
- ':pk' => $idGroup,
|
|
|
|
- ':remote_pk' => $id
|
|
|
|
- ]);
|
|
|
|
- }
|
|
|
|
|
|
+ ACL::removeListRef(
|
|
|
|
+ $rootObjectNamespace = 'default_db/BI_audit_ENERGA_PRACOWNICY_group/BI_audit_ENERGA_PRACOWNICY_group',
|
|
|
|
+ $fieldTypeName = 'default_db__x3A__BI_audit_ENERGA_PRACOWNICY:BI_audit_ENERGA_PRACOWNICY',
|
|
|
|
+ $refPrimaryKey = $idGroup,
|
|
|
|
+ $refListRemotePrimaryKey = $pracownicyIds
|
|
|
|
+ );
|
|
|
|
|
|
return [
|
|
return [
|
|
'msg' => "Usunięto osoby z grupy {$idGroup}",
|
|
'msg' => "Usunięto osoby z grupy {$idGroup}",
|
|
@@ -2256,19 +2253,18 @@ public function showPowiazaniaEnergaRumKontrahenciPowiazania($items) {
|
|
$kontrahenciIds = V::get('kontrahenciIds', [], $args, 'array');
|
|
$kontrahenciIds = V::get('kontrahenciIds', [], $args, 'array');
|
|
if ($idGroup === 0) {
|
|
if ($idGroup === 0) {
|
|
foreach ($kontrahenciIds as $kontrahentIds) {
|
|
foreach ($kontrahenciIds as $kontrahentIds) {
|
|
- //TO DO sprawdzanie czy już DELETED
|
|
|
|
$affected = DB::getPDO()->update('BI_audit_ENERGA_RUM_KONTRAHENCI', 'ID', $kontrahentIds, [
|
|
$affected = DB::getPDO()->update('BI_audit_ENERGA_RUM_KONTRAHENCI', 'ID', $kontrahentIds, [
|
|
'A_STATUS' => 'DELETED',
|
|
'A_STATUS' => 'DELETED',
|
|
'A_RECORD_UPDATE_DATE' => 'NOW()',
|
|
'A_RECORD_UPDATE_DATE' => 'NOW()',
|
|
'A_RECORD_UPDATE_AUTHOR' => User::getLogin(),
|
|
'A_RECORD_UPDATE_AUTHOR' => User::getLogin(),
|
|
- ])->debugDumpParams();
|
|
|
|
|
|
+ ]);
|
|
}
|
|
}
|
|
return [
|
|
return [
|
|
'msg' => "Usunięto kontrahentów z systemu",
|
|
'msg' => "Usunięto kontrahentów z systemu",
|
|
'type' => "success",
|
|
'type' => "success",
|
|
];
|
|
];
|
|
} else {
|
|
} else {
|
|
- $group = ACL::getAclByNamespace('default_db/BI_audit_ENERGA_KONTRAHENCI_group/BI_audit_ENERGA_KONTRAHENCI_group')->buildQuery([
|
|
|
|
|
|
+ $group = ACL::getAclByNamespace('default_db/BI_audit_ENERGA_PRACOWNICY_group/BI_audit_ENERGA_PRACOWNICY_group')->buildQuery([
|
|
'cols' => [ // TODO:? propertyName = []
|
|
'cols' => [ // TODO:? propertyName = []
|
|
'ID',
|
|
'ID',
|
|
'ID_USER',
|
|
'ID_USER',
|
|
@@ -2279,16 +2275,12 @@ public function showPowiazaniaEnergaRumKontrahenciPowiazania($items) {
|
|
if (!$group) throw new Exception("Grupa nie istnieje");
|
|
if (!$group) throw new Exception("Grupa nie istnieje");
|
|
if (User::getID() != $group['ID_USER']) throw new Exception("Brak uprawnień do grupy");
|
|
if (User::getID() != $group['ID_USER']) throw new Exception("Brak uprawnień do grupy");
|
|
|
|
|
|
- $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) {
|
|
|
|
- $id = (int)$kontrahentIds;
|
|
|
|
- DBG::log("nazwa grupy {$refGrupyToKontrahenci}");
|
|
|
|
- DB::getPDO()->execSql(" delete from `{$refGrupyToKontrahenci}` where PRIMARY_KEY = :pk and REMOTE_PRIMARY_KEY = :remote_pk ", [
|
|
|
|
- ':pk' => $idGroup,
|
|
|
|
- ':remote_pk' => $id
|
|
|
|
- ]);
|
|
|
|
- }
|
|
|
|
|
|
+ ACL::removeListRef(
|
|
|
|
+ $rootObjectNamespace = 'default_db/BI_audit_ENERGA_PRACOWNICY_group/BI_audit_ENERGA_PRACOWNICY_group',
|
|
|
|
+ $fieldTypeName = 'default_db__x3A__BI_audit_ENERGA_RUM_KONTRAHENCI:BI_audit_ENERGA_RUM_KONTRAHENCI',
|
|
|
|
+ $refPrimaryKey = $idGroup,
|
|
|
|
+ $refListRemotePrimaryKey = $kontrahenciIds
|
|
|
|
+ );
|
|
|
|
|
|
return [
|
|
return [
|
|
'msg' => "Usunięto kontrahentów z grupy {$idGroup}",
|
|
'msg' => "Usunięto kontrahentów z grupy {$idGroup}",
|
|
@@ -2302,7 +2294,7 @@ public function showPowiazaniaEnergaRumKontrahenciPowiazania($items) {
|
|
Response::sendTryCatchJson(array($this, 'fetchGroupKontrahenciAjax'));
|
|
Response::sendTryCatchJson(array($this, 'fetchGroupKontrahenciAjax'));
|
|
}
|
|
}
|
|
public function fetchGroupKontrahenciAjax() {
|
|
public function fetchGroupKontrahenciAjax() {
|
|
- $query = ACL::getAclByNamespace('default_db/BI_audit_ENERGA_KONTRAHENCI_group/BI_audit_ENERGA_KONTRAHENCI_group')->buildQuery([
|
|
|
|
|
|
+ $query = ACL::getAclByNamespace('default_db/BI_audit_ENERGA_PRACOWNICY_group/BI_audit_ENERGA_PRACOWNICY_group')->buildQuery([
|
|
'cols' => [ // TODO:? propertyName = []
|
|
'cols' => [ // TODO:? propertyName = []
|
|
'ID',
|
|
'ID',
|
|
'ID_USER',
|
|
'ID_USER',
|
|
@@ -2587,7 +2579,7 @@ public function showPowiazaniaEnergaRumKontrahenciPowiazania($items) {
|
|
if (!$pracownicyIds || count($pracownicyIds) == 0) throw new Exception("Proszę wybrać pracowników");
|
|
if (!$pracownicyIds || count($pracownicyIds) == 0) throw new Exception("Proszę wybrać pracowników");
|
|
} break;
|
|
} break;
|
|
case 'filter': {
|
|
case 'filter': {
|
|
- if (!isset($args['filter'])) throw new Exception("Proszę wybrać pracowników");
|
|
|
|
|
|
+ if (empty($filter)) throw new Exception("Proszę wybrać pracowników");
|
|
} break;
|
|
} break;
|
|
default: throw new Exception("Missing type");
|
|
default: throw new Exception("Missing type");
|
|
}
|
|
}
|
|
@@ -2608,9 +2600,9 @@ public function showPowiazaniaEnergaRumKontrahenciPowiazania($items) {
|
|
if (User::getID() != $group['ID_USER']) throw new Exception("Brak uprawnień do grupy");
|
|
if (User::getID() != $group['ID_USER']) throw new Exception("Brak uprawnień do grupy");
|
|
|
|
|
|
if ('filter' === $type) {
|
|
if ('filter' === $type) {
|
|
- $args__idGroup = V::get('filterIdGroup', 0, $args['filter'], 'int'); // dla filtrów "Wysokiego ryzyka" - przekazywany ID rekodu
|
|
|
|
|
|
+ $args__idGroup = V::get('filterIdGroup', 0, $filter, 'int'); // dla filtrów "Wysokiego ryzyka" - przekazywany ID rekodu
|
|
if ($args__idGroup < 0) $args__idGroup = 0;
|
|
if ($args__idGroup < 0) $args__idGroup = 0;
|
|
- $search = V::get('search', '', $args['filter']);
|
|
|
|
|
|
+ $search = V::get('search', '', $filter);
|
|
$searchParams = [];
|
|
$searchParams = [];
|
|
if (!empty($search)) {
|
|
if (!empty($search)) {
|
|
$ogcSearch = "*{$search}*"; // wildCard="*" -> mysql '%'
|
|
$ogcSearch = "*{$search}*"; // wildCard="*" -> mysql '%'
|
|
@@ -2640,11 +2632,11 @@ public function showPowiazaniaEnergaRumKontrahenciPowiazania($items) {
|
|
}
|
|
}
|
|
|
|
|
|
$filtersParams = [];
|
|
$filtersParams = [];
|
|
- $fieldFilterKeys = array_filter(array_keys($args['filter']), function ($key) {
|
|
|
|
|
|
+ $fieldFilterKeys = array_filter(array_keys($filter), function ($key) {
|
|
return ('f_' === substr($key, 0, 2));
|
|
return ('f_' === substr($key, 0, 2));
|
|
});
|
|
});
|
|
foreach ($fieldFilterKeys as $key) {
|
|
foreach ($fieldFilterKeys as $key) {
|
|
- $filtersParams[ $key ] = '%' . $args['filter'][ $key ] . '%';
|
|
|
|
|
|
+ $filtersParams[ $key ] = '%' . $filter[ $key ] . '%';
|
|
}
|
|
}
|
|
|
|
|
|
$acl = ACL::getAclByNamespace('default_db/BI_audit_ENERGA_PRACOWNICY/BI_audit_ENERGA_PRACOWNICY');
|
|
$acl = ACL::getAclByNamespace('default_db/BI_audit_ENERGA_PRACOWNICY/BI_audit_ENERGA_PRACOWNICY');
|
|
@@ -2660,12 +2652,12 @@ public function showPowiazaniaEnergaRumKontrahenciPowiazania($items) {
|
|
}, $items);
|
|
}, $items);
|
|
}
|
|
}
|
|
|
|
|
|
- // $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]);
|
|
|
|
- }
|
|
|
|
|
|
+ ACL::addListRef(
|
|
|
|
+ $rootObjectNamespace = 'default_db/BI_audit_ENERGA_PRACOWNICY_group/BI_audit_ENERGA_PRACOWNICY_group',
|
|
|
|
+ $fieldTypeName = 'default_db__x3A__BI_audit_ENERGA_PRACOWNICY:BI_audit_ENERGA_PRACOWNICY',
|
|
|
|
+ $refPrimaryKey = $idGroup,
|
|
|
|
+ $refListRemotePrimaryKey = $pracownicyIds
|
|
|
|
+ );
|
|
|
|
|
|
return [
|
|
return [
|
|
'msg' => "Powiązano pracowników z grupą {$idGroup}",
|
|
'msg' => "Powiązano pracowników z grupą {$idGroup}",
|
|
@@ -2742,15 +2734,11 @@ public function showPowiazaniaEnergaRumKontrahenciPowiazania($items) {
|
|
throw new Exception("Nie podano wartości czy zwracać wyniki tylko z obiektami docelowymi");
|
|
throw new Exception("Nie podano wartości czy zwracać wyniki tylko z obiektami docelowymi");
|
|
}
|
|
}
|
|
|
|
|
|
- // Tworzenie relacji Raport do Pracownicy
|
|
|
|
- $pracownicyIds = []; // array z nr ID na podstawie wysłanego formularza
|
|
|
|
- $pracownicyIds = V::get('pracownicyIds', '', $args);
|
|
|
|
-
|
|
|
|
- $kontrahenciIds = []; // array z nr ID na podstawie wysłanego formularza
|
|
|
|
- $kontrahenciIds = V::get('kontrahenciIds', '', $args);
|
|
|
|
|
|
+ $pracownicyIds = V::get('pracownicyIds', [], $args, 'uint_array'); // array of int > 0
|
|
|
|
+ $kontrahenciIds = V::get('kontrahenciIds', [], $args, 'uint_array'); // array of int > 0
|
|
|
|
|
|
// walidacja listy kontrahentów i pracowników
|
|
// walidacja listy kontrahentów i pracowników
|
|
- if ( !$kontrahenciIds && !$pracownicyIds ) {
|
|
|
|
|
|
+ if ( empty($kontrahenciIds) && empty($pracownicyIds) ) {
|
|
throw new Exception("Nie wybrano pozycji do analizy. Wybierz pracowników/kontrahentów.");
|
|
throw new Exception("Nie wybrano pozycji do analizy. Wybierz pracowników/kontrahentów.");
|
|
}
|
|
}
|
|
|
|
|
|
@@ -2765,56 +2753,59 @@ public function showPowiazaniaEnergaRumKontrahenciPowiazania($items) {
|
|
'BI_analiza_maxDepth' => $depthValue,
|
|
'BI_analiza_maxDepth' => $depthValue,
|
|
'BI_analiza_onlyTargets' => $analizaOnlyTargets
|
|
'BI_analiza_onlyTargets' => $analizaOnlyTargets
|
|
]);
|
|
]);
|
|
|
|
+ if ($idRaport <= 0) throw new Exception("Nie udało się dodać nowego raportu");
|
|
|
|
|
|
- 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()',
|
|
|
|
- 'L_APPOITMENT_INFO' => $smadReaportTitle,
|
|
|
|
- 'FILE_STATUS' => "TO_GENERATE",
|
|
|
|
- 'A_STATUS' => "NORMAL",
|
|
|
|
- 'BI_analiza_minDepth' => 1,
|
|
|
|
- 'BI_analiza_maxDepth' => $depthValue,
|
|
|
|
- 'BI_analiza_onlyTargets' => $analizaOnlyTargets
|
|
|
|
- ]);
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- // 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');
|
|
|
|
-
|
|
|
|
- // 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');
|
|
|
|
|
|
+ DB::getPDO()->insert('BI_audit_ENERGA_RUM_KONTRAHENCI_POWIAZANIA_HIST', [
|
|
|
|
+ 'ID_USERS2' => $idRaport,
|
|
|
|
+ 'A_RECORD_CREATE_AUTHOR' => User::getLogin(),
|
|
|
|
+ 'A_RECORD_CREATE_DATE' => 'NOW()',
|
|
|
|
+ 'L_APPOITMENT_INFO' => $smadReaportTitle,
|
|
|
|
+ 'FILE_STATUS' => "TO_GENERATE",
|
|
|
|
+ 'A_STATUS' => "NORMAL",
|
|
|
|
+ 'BI_analiza_minDepth' => 1,
|
|
|
|
+ 'BI_analiza_maxDepth' => $depthValue,
|
|
|
|
+ 'BI_analiza_onlyTargets' => $analizaOnlyTargets
|
|
|
|
+ ]);
|
|
|
|
|
|
- /* PRACOWNICY */
|
|
|
|
- if ( !$pracownicyIds ) {
|
|
|
|
- // dodajemy wszystkich pracowników
|
|
|
|
- DB::getPDO()->execSql("insert into `{$refPowiazaniaToPracownicy}` (`PRIMARY_KEY`,`REMOTE_PRIMARY_KEY`)
|
|
|
|
- select '{$idRaport}' as PRIMARY_KEY
|
|
|
|
- , ID as REMOTE_PRIMARY_KEY
|
|
|
|
|
|
+ if (!empty($pracownicyIds)) {
|
|
|
|
+ ACL::addListRef(
|
|
|
|
+ $rootObjectNamespace = 'default_db/BI_audit_ENERGA_RUM_KONTRAHENCI_POWIAZANIA/BI_audit_ENERGA_RUM_KONTRAHENCI_POWIAZANIA',
|
|
|
|
+ $fieldTypeName = 'default_db__x3A__BI_audit_ENERGA_PRACOWNICY:BI_audit_ENERGA_PRACOWNICY',
|
|
|
|
+ $refPrimaryKey = $idRaport,
|
|
|
|
+ $refListRemotePrimaryKey = $pracownicyIds
|
|
|
|
+ );
|
|
|
|
+ } else {
|
|
|
|
+ $refRaportToPracownicyConfig = ACL::getRefConfig(
|
|
|
|
+ $rootObjectNamespace = 'default_db/BI_audit_ENERGA_RUM_KONTRAHENCI_POWIAZANIA/BI_audit_ENERGA_RUM_KONTRAHENCI_POWIAZANIA',
|
|
|
|
+ $fieldTypeName = 'default_db__x3A__BI_audit_ENERGA_PRACOWNICY:BI_audit_ENERGA_PRACOWNICY'
|
|
|
|
+ );
|
|
|
|
+ DB::getPDO()->execSql("
|
|
|
|
+ insert into `{$refRaportToPracownicyConfig->tableName}` (`PRIMARY_KEY`,`REMOTE_PRIMARY_KEY`)
|
|
|
|
+ select {$idRaport} as PRIMARY_KEY, ID as REMOTE_PRIMARY_KEY
|
|
from `BI_audit_ENERGA_PRACOWNICY`
|
|
from `BI_audit_ENERGA_PRACOWNICY`
|
|
- ");
|
|
|
|
- } else { // wybrano pracownika/ów
|
|
|
|
- foreach ($pracownicyIds as $idPracownik) {
|
|
|
|
- DB::getPDO()->insert($refPowiazaniaToPracownicy, ['PRIMARY_KEY' => $idRaport, 'REMOTE_PRIMARY_KEY' => $idPracownik]);
|
|
|
|
- }
|
|
|
|
|
|
+ where `A_STATUS` != 'DELETED'
|
|
|
|
+ ");
|
|
}
|
|
}
|
|
|
|
|
|
- /* KONTRAHENCI */
|
|
|
|
- if ( !$kontrahenciIds ) {
|
|
|
|
- // dodajemy wszystkich pracowników
|
|
|
|
- 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 { // wybrano pracownika/ów
|
|
|
|
- foreach ($kontrahenciIds as $idKontrahent) {
|
|
|
|
- DB::getPDO()->insert($refPowiazaniaToKontrahenci, ['PRIMARY_KEY' => $idRaport, 'REMOTE_PRIMARY_KEY' => $idKontrahent ]);
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
|
|
+ if (!empty($kontrahenciIds)) {
|
|
|
|
+ ACL::addListRef(
|
|
|
|
+ $rootObjectNamespace = 'default_db/BI_audit_ENERGA_RUM_KONTRAHENCI_POWIAZANIA/BI_audit_ENERGA_RUM_KONTRAHENCI_POWIAZANIA',
|
|
|
|
+ $fieldTypeName = 'default_db__x3A__BI_audit_ENERGA_RUM_KONTRAHENCI:BI_audit_ENERGA_RUM_KONTRAHENCI',
|
|
|
|
+ $refPrimaryKey = $idRaport,
|
|
|
|
+ $refListRemotePrimaryKey = $kontrahenciIds
|
|
|
|
+ );
|
|
|
|
+ } else {
|
|
|
|
+ $refRaportToKontrahenciConfig = ACL::getRefConfig(
|
|
|
|
+ $rootObjectNamespace = 'default_db/BI_audit_ENERGA_RUM_KONTRAHENCI_POWIAZANIA/BI_audit_ENERGA_RUM_KONTRAHENCI_POWIAZANIA',
|
|
|
|
+ $fieldTypeName = 'default_db__x3A__BI_audit_ENERGA_RUM_KONTRAHENCI:BI_audit_ENERGA_RUM_KONTRAHENCI'
|
|
|
|
+ );
|
|
|
|
+ DB::getPDO()->execSql("
|
|
|
|
+ insert into `{$refRaportToKontrahenciConfig->tableName}` (`PRIMARY_KEY`,`REMOTE_PRIMARY_KEY`)
|
|
|
|
+ select '{$idRaport}' as PRIMARY_KEY, ID as REMOTE_PRIMARY_KEY
|
|
|
|
+ from `BI_audit_ENERGA_RUM_KONTRAHENCI`
|
|
|
|
+ where `A_STATUS` != 'DELETED'
|
|
|
|
+ ");
|
|
|
|
+ }
|
|
|
|
|
|
return [
|
|
return [
|
|
'msg' => "Zadanie do wygnerowania raportu zostało zapisane.",
|
|
'msg' => "Zadanie do wygnerowania raportu zostało zapisane.",
|