|
|
@@ -1757,28 +1757,29 @@ SQL;
|
|
|
],
|
|
|
'base' => 1,
|
|
|
],
|
|
|
- // refy dodatkowe do obsluzenia
|
|
|
- 'BI_audit_MSIG' => [
|
|
|
- 'refTablesTo' => [
|
|
|
- 'BI_audit_KRS',
|
|
|
- ],
|
|
|
- 'base' => 0,
|
|
|
- ],
|
|
|
- 'BI_audit_MSIG_address' => [
|
|
|
- 'refTablesTo' => [
|
|
|
- 'BI_audit_KRS_address',
|
|
|
- ],
|
|
|
- 'base' => 0,
|
|
|
- ],
|
|
|
- 'BI_audit_MSIG_person' => [
|
|
|
- 'refTablesTo' => [
|
|
|
- 'BI_audit_KRS_person',
|
|
|
- ],
|
|
|
- 'base' => 0,
|
|
|
- ],
|
|
|
+
|
|
|
+
|
|
|
|
|
|
];
|
|
|
-
|
|
|
+
|
|
|
+ $RefExtraTables = [
|
|
|
+ 'BI_audit_MSIG_person' => [
|
|
|
+ 'refTablesTo' => [
|
|
|
+ 'BI_audit_KRS_person',
|
|
|
+ ],
|
|
|
+ ],
|
|
|
+ 'BI_audit_MSIG' => [
|
|
|
+ 'refTablesTo' => [
|
|
|
+ 'BI_audit_KRS',
|
|
|
+ ],
|
|
|
+ ],
|
|
|
+ 'BI_audit_MSIG_address' => [
|
|
|
+ 'refTablesTo' => [
|
|
|
+ 'BI_audit_KRS_address',
|
|
|
+ ],
|
|
|
+ ],
|
|
|
+ ];
|
|
|
+
|
|
|
$sourceTables = ['BI_audit_ENERGA_PRACOWNICY'];
|
|
|
|
|
|
if ($full) {
|
|
|
@@ -1794,6 +1795,9 @@ SQL;
|
|
|
$queryes[] = "delete from `{$refTable}` where `TRANSACTION_ID` = '-1'";
|
|
|
}
|
|
|
}
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
}
|
|
|
|
|
|
foreach ($tablesConf as $table => $tableConf) {
|
|
|
@@ -1833,10 +1837,7 @@ SQL;
|
|
|
}
|
|
|
}
|
|
|
// echo implode(";\n", $queries) . ";\n";
|
|
|
- foreach ($queries as $query) {
|
|
|
-// echo "SQL: {$query}\n";
|
|
|
- DB::getPDO()->query($query);
|
|
|
- }
|
|
|
+
|
|
|
|
|
|
$BiAuditRelations = new BiAuditRelations();
|
|
|
// DB::getPDO()->query("lock tables `BI_audit_ALL` write");
|
|
|
@@ -1844,6 +1845,37 @@ SQL;
|
|
|
while ($row = $result->fetch()) $BiAuditRelations->findRelations($row['ID']);
|
|
|
DB::getPDO()->query("update `BI_audit_ALL` set `reffed` = 1");
|
|
|
// DB::getPDO()->query("unlock tables");
|
|
|
+
|
|
|
+ $queries = array();
|
|
|
+ //uzupelnienie extra refow dla dzialania schematow
|
|
|
+ foreach ($RefExtraTables as $refTableFrom => $refTableConf) {
|
|
|
+ foreach ($refTableConf['refTablesTo'] as $refTableTo) {
|
|
|
+ $refTable = ACL::getRefTable("default_db/{$refTableFrom}/{$refTableFrom}", "default_db__x3A__{$refTableTo}:{$refTableTo}");
|
|
|
+ $queries[] = "update `{$refTable}` set `A_STATUS` = 'WAITNG' where `A_STATUS` = 'NORMAL'";
|
|
|
+ $queryes[] = "delete from `{$refTable}` where `TRANSACTION_ID` = '-1'";
|
|
|
+ $queryes[] = " insert into `{$refTable}` (
|
|
|
+ `PRIMARY_KEY`
|
|
|
+ `REMOTE_PRIMARY_KEY`
|
|
|
+ )
|
|
|
+ select
|
|
|
+ LT.REMOTE_ID as PRIMARY_KEY, RT.REMOTE_ID as REMOTE_PRIMARY_KEY
|
|
|
+ from BI_audit_ALL as LT
|
|
|
+ left join BI_audit_ALL_ref as LT_ref on ( LT_ref.ID1=LT.ID )
|
|
|
+ left join BI_audit_ALL as RT on ( LT_ref.ID2 = RT.ID )
|
|
|
+ where
|
|
|
+ LT.REMOTE_TABLE='{$refTableFrom}'
|
|
|
+ and RT.REMOTE_TABLE='{$refTableTo}' ";
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ foreach ($queries as $query) {
|
|
|
+ echo "
|
|
|
+ #1878 extra refs SQL: {$query}\n";
|
|
|
+ error_log("\n
|
|
|
+ #1878 extra refs ".$query);
|
|
|
+ DB::getPDO()->query($query);
|
|
|
+ }
|
|
|
+
|
|
|
}
|
|
|
|
|
|
public static function doReloadCache($full = false) {
|