|
|
@@ -1582,7 +1582,7 @@ Router::getRoute("UrlAction_BiAuditGenerate")->' . $function . ';
|
|
|
'TERYT_SYM_UL',
|
|
|
],
|
|
|
'BI_audit_KRS' => [
|
|
|
- '"Zaimportowanoz KRS na podstawie umowy"',
|
|
|
+ '"Zaimportowano z KRS na podstawie faktury/umowy"',
|
|
|
'nazwa',
|
|
|
'nip',
|
|
|
'regon',
|
|
|
@@ -1597,7 +1597,7 @@ Router::getRoute("UrlAction_BiAuditGenerate")->' . $function . ';
|
|
|
'TERYT_SYM_UL',
|
|
|
],
|
|
|
'BI_audit_CEIDG' => [
|
|
|
- '"Zaimportowano z CEiDG na podstawie umowy"',
|
|
|
+ '"Zaimportowano z CEiDG na podstawie faktury/umowy"',
|
|
|
'firma',
|
|
|
'nip',
|
|
|
'regon',
|
|
|
@@ -1631,14 +1631,17 @@ Router::getRoute("UrlAction_BiAuditGenerate")->' . $function . ';
|
|
|
$query = "delete from `{$refTableFakturyToKontrahenci}` where PRIMARY_KEY = '{$row['ID']}'";
|
|
|
DB::getPDO()->query($query);
|
|
|
}
|
|
|
- if (!$nip) continue;
|
|
|
+ if (!$nip) {
|
|
|
+ DB::getPDO()->update('BI_audit_ENERGA_FAKTURY', "ID", $ID, ['A_STATUS' => 'OFF_SOFT']);
|
|
|
+ continue;
|
|
|
+ }
|
|
|
|
|
|
$K_IDs = [];
|
|
|
$query = "select `ID` from `BI_audit_ENERGA_RUM_KONTRAHENCI` where `NIP` = '{$nip}'";
|
|
|
if ($result2 = DB::getPDO()->fetchall($query)) {
|
|
|
foreach ($result2 as $item) $K_IDs[] = $item['ID'];
|
|
|
} else {
|
|
|
- $query = "select ID from BI_audit_KRS where nip = '{$nip}'";
|
|
|
+ $query = "select ID from BI_audit_KRS where nip = '{$nip}' order by `ID` desc limit 1";
|
|
|
if ($result2 = DB::getPDO()->fetchall($query)) {
|
|
|
foreach ($result2 as $item) {
|
|
|
$query = "insert into `BI_audit_ENERGA_RUM_KONTRAHENCI` (" . implode(', ', $fields['BI_audit_ENERGA_RUM_KONTRAHENCI']) . ")" .
|
|
|
@@ -1646,7 +1649,7 @@ Router::getRoute("UrlAction_BiAuditGenerate")->' . $function . ';
|
|
|
if (DB::getPDO()->query($query)) $K_IDs[] = DB::getPDO()->lastInsertId();
|
|
|
}
|
|
|
} else {
|
|
|
- $query = "select `ID` from `BI_audit_CEIDG` where `nip` = '{$nip}'";
|
|
|
+ $query = "select `ID` from `BI_audit_CEIDG` where `nip` = '{$nip}' order by `ID` desc limit 1";
|
|
|
if ($result2 = DB::getPDO()->fetchall($query)) {
|
|
|
foreach ($result2 as $item) {
|
|
|
$query = "insert into `BI_audit_ENERGA_RUM_KONTRAHENCI` (" . implode(', ', $fields['BI_audit_ENERGA_RUM_KONTRAHENCI']) . ")" .
|
|
|
@@ -1716,7 +1719,7 @@ SQL;
|
|
|
if ($result2 = DB::getPDO()->fetchall($query)) {
|
|
|
foreach ($result2 as $item) $K_IDs[] = $item['ID'];
|
|
|
} else {
|
|
|
- $query = "select ID from BI_audit_KRS where nip = '{$nip}' or regon = '{$regon}'";
|
|
|
+ $query = "select ID from BI_audit_KRS where nip = '{$nip}' or regon = '{$regon}' order by `ID` desc limit 1";
|
|
|
if ($result2 = DB::getPDO()->fetchall($query)) {
|
|
|
foreach ($result2 as $item) {
|
|
|
$query = "insert into BI_audit_ENERGA_RUM_KONTRAHENCI (" . implode(', ', $fields['BI_audit_ENERGA_RUM_KONTRAHENCI']) . ")" .
|
|
|
@@ -1724,7 +1727,7 @@ SQL;
|
|
|
if (DB::getPDO()->query($query)) $K_IDs[] = DB::getPDO()->lastInsertId();
|
|
|
}
|
|
|
} else {
|
|
|
- $query = "select ID from BI_audit_CEIDG where nip = '{$nip}' or regon = '{$regon}'";
|
|
|
+ $query = "select ID from BI_audit_CEIDG where nip = '{$nip}' or regon = '{$regon}' order by `ID` desc limit 1";
|
|
|
if ($result2 = DB::getPDO()->fetchall($query)) {
|
|
|
foreach ($result2 as $item) {
|
|
|
$query = "insert into BI_audit_ENERGA_RUM_KONTRAHENCI (" . implode(', ', $fields['BI_audit_ENERGA_RUM_KONTRAHENCI']) . ")" .
|
|
|
@@ -2205,7 +2208,7 @@ SQL;
|
|
|
$values[] = "`{$value}`";
|
|
|
$updates[] = "`BI_audit_ALL`.`{$field}` = `{$table}`.`{$value}`";
|
|
|
}
|
|
|
- $queries[] = "update `BI_audit_ALL` join `{$table}` on `BI_audit_ALL`.`REMOTE_ID` = `{$table}`.`ID` set " . implode(", ", $updates) . " {$where}";
|
|
|
+ $queries[] = "update `BI_audit_ALL` join `{$table}` on `BI_audit_ALL`.`REMOTE_TABLE` = '{$table}' and `BI_audit_ALL`.`REMOTE_ID` = `{$table}`.`ID` set " . implode(", ", $updates) . " {$where}";
|
|
|
$queries[] = "insert into `BI_audit_ALL` (" . implode(", ", $fields) . ") select " . implode(", ", $values) . " from `{$table}` {$where}";
|
|
|
$queries[] = "update `{$table}` set `cached` = 1 {$where}";
|
|
|
}
|