|
|
@@ -939,32 +939,45 @@ function validateCompany(source) {
|
|
|
return;
|
|
|
}
|
|
|
|
|
|
+ $refs = []; $backRefs = [];
|
|
|
switch ($this->SOURCE['TABLE']) {
|
|
|
case "BI_audit_ENERGA_PRACOWNICY":
|
|
|
+ break;
|
|
|
case "BI_audit_ENERGA_RUM_KONTRAHENCI":
|
|
|
- $query = "delete from `{$this->SOURCE['TABLE']}`";
|
|
|
+ $backRefs = ['BI_audit_ENERGA_RUM_UMOWY', 'BI_audit_ENERGA_FAKTURY'];
|
|
|
+ break;
|
|
|
+ case "BI_audit_ENERGA_RUM_UMOWY":
|
|
|
+ $refs = ['BI_audit_ENERGA_RUM_KONTRAHENCI'];
|
|
|
+ break;
|
|
|
+ case "BI_audit_ENERGA_FAKTURY":
|
|
|
+ $refs = ['BI_audit_ENERGA_RUM_KONTRAHENCI'];
|
|
|
break;
|
|
|
case "BI_audit_ENERGA_RUM_KONTRAHENCI_POWIAZANIA":
|
|
|
- //throw new Exception('Not implemented yet');//TODO
|
|
|
- if ($deleteFiles) {
|
|
|
- $query = "select ID from `BI_audit_ENERGA_RUM_KONTRAHENCI_POWIAZANIA`";
|
|
|
- $result = DB::getPDO()->fetchAll($query);
|
|
|
- foreach ($result as $row) {
|
|
|
+ $query = "select ID from `BI_audit_ENERGA_RUM_KONTRAHENCI_POWIAZANIA`";
|
|
|
+ $result = DB::getPDO()->fetchAll($query);
|
|
|
+ foreach ($result as $row) {
|
|
|
+ if ($deleteFiles) {
|
|
|
$dir = self::getDirectory('BI_audit_ENERGA_RUM_KONTRAHENCI_POWIAZANIA', $row['ID']);
|
|
|
if (!file_exists($dir)) continue;
|
|
|
$deleted = V::deleteWholeDirectory($dir, true, false);
|
|
|
$deletedDirs += count($deleted['dirs']);
|
|
|
$deletedFiles += count($deleted['files']);
|
|
|
}
|
|
|
+ self::deleteResultsFromDB($row['ID']);
|
|
|
+ self::truncatePowiazaniaFromDB($row['ID']);
|
|
|
}
|
|
|
- $query = "";
|
|
|
break;
|
|
|
default: throw new Exception('Błąd parametru');
|
|
|
- //DB::getPDO()->query($query);
|
|
|
}
|
|
|
+
|
|
|
+ $queries = [];
|
|
|
+ $queries[] = "delete from `{$this->SOURCE['TABLE']}`";
|
|
|
+ foreach ($refs as $ref) $queries[] = 'truncate table `' . BiAuditRefTables::getRefTable($this->SOURCE['TABLE'], $ref, true) . '`';
|
|
|
+ foreach ($backRefs as $backRef) $queries[] = 'truncate table `' . BiAuditRefTables::getRefTable($backRef, $this->SOURCE['TABLE'], true) . '`';
|
|
|
+ foreach ($queries as $query) DB::getPDO()->query($query);
|
|
|
?>
|
|
|
<div style="text-align: center;">
|
|
|
- <h2>Pomyślnie wyczyszczono tabelę.</h2>
|
|
|
+ <h2>Pomyślnie wyczyszczono tabelę <?=$this->clearTable_tables[$this->SOURCE['TABLE']]?>.</h2>
|
|
|
<?php
|
|
|
if ($deleteFiles && ($deletedDirs || $deletedFiles)):
|
|
|
?>
|
|
|
@@ -981,12 +994,7 @@ function validateCompany(source) {
|
|
|
}
|
|
|
|
|
|
private function clearTable_form() {
|
|
|
- $tables = [
|
|
|
- 'BI_audit_ENERGA_PRACOWNICY' => 'pracowników',
|
|
|
- 'BI_audit_ENERGA_RUM_KONTRAHENCI' => 'kontrahentów',
|
|
|
- 'BI_audit_ENERGA_RUM_KONTRAHENCI_POWIAZANIA' => 'raportów',
|
|
|
- ];
|
|
|
- if (!isset($tables[$this->SOURCE['TABLE']])) SE_Layout::alert('danger', 'Błąd parametru');
|
|
|
+ if (!isset($this->clearTable_tables[$this->SOURCE['TABLE']])) SE_Layout::alert('danger', 'Błąd parametru');
|
|
|
|
|
|
$a = rand(10, 50);
|
|
|
$b = rand(10, 50);
|
|
|
@@ -1040,7 +1048,7 @@ function validateCompany(source) {
|
|
|
|
|
|
?>
|
|
|
<div style="text-align: center;">
|
|
|
- <h2>Czy jesteś pewien, że chcesz usunąć<br/><b>wszystkie dane</b> z tabeli <?=$tables[$this->SOURCE['TABLE']]?>?</h2><br/>
|
|
|
+ <h2>Czy jesteś pewien, że chcesz usunąć<br/><b>wszystkie dane</b> z tabeli <?=$this->clearTable_tables[$this->SOURCE['TABLE']]?>?</h2><br/>
|
|
|
<h3>Podaj wynik działania:</h3>
|
|
|
<form method="post">
|
|
|
<img src="data:image/png;base64,<?=$imageBase64?>" height="36px"/><input type="text" name="wynik" style="font-size: 24px; width: 50px;" pattern="^[0-9]{1,3}$" oninvalid="setCustomValidity('Nieprawidłowy format')" maxlength="3" autofocus required autocomplete="off"/><br/><br/>
|
|
|
@@ -1060,7 +1068,13 @@ function validateCompany(source) {
|
|
|
}
|
|
|
|
|
|
private function clearTable() {
|
|
|
- SE_Layout::alert('warning', 'Funkcja w fazie testów - niczego jeszcze nie usuwa');
|
|
|
+ $this->clearTable_tables = [
|
|
|
+ 'BI_audit_ENERGA_PRACOWNICY' => 'pracowników',
|
|
|
+ 'BI_audit_ENERGA_RUM_KONTRAHENCI' => 'kontrahentów',
|
|
|
+ 'BI_audit_ENERGA_RUM_KONTRAHENCI_POWIAZANIA' => 'raportów',
|
|
|
+ 'BI_audit_ENERGA_RUM_UMOWY' => 'umów',
|
|
|
+ 'BI_audit_ENERGA_FAKTURY' => 'faktur',
|
|
|
+ ];
|
|
|
$query = "select count(*) from `BI_audit_ENERGA_RUM_KONTRAHENCI_POWIAZANIA` where `FILE_STATUS` = 'IN_PROGRESS'";
|
|
|
if (DB::getPDO()->fetchValue($query)) {
|
|
|
?>
|
|
|
@@ -1102,6 +1116,7 @@ function validateCompany(source) {
|
|
|
$_subUrlAction = V::get('_subUrlAction', '', $_GET);
|
|
|
switch ($TABLE) {
|
|
|
case "default_db/BI_audit_ENERGA_PRACOWNICY":
|
|
|
+ case "default_db/BI_audit_ENERGA_PRACOWNICY/BI_audit_ENERGA_PRACOWNICY":
|
|
|
$this->SOURCE['TABLE'] = 'BI_audit_ENERGA_PRACOWNICY';
|
|
|
switch ($_subUrlAction) {
|
|
|
case "clearTable":
|
|
|
@@ -1115,6 +1130,7 @@ function validateCompany(source) {
|
|
|
}
|
|
|
break;
|
|
|
case "default_db/BI_audit_ENERGA_RUM_KONTRAHENCI":
|
|
|
+ case "default_db/BI_audit_ENERGA_RUM_KONTRAHENCI/BI_audit_ENERGA_RUM_KONTRAHENCI":
|
|
|
$this->SOURCE['TABLE'] = 'BI_audit_ENERGA_RUM_KONTRAHENCI';
|
|
|
switch ($_subUrlAction) {
|
|
|
case "clearTable":
|
|
|
@@ -1123,19 +1139,41 @@ function validateCompany(source) {
|
|
|
default: SE_Layout::alert('danger', 'Błąd parametru #22');
|
|
|
}
|
|
|
break;
|
|
|
+ case "default_db/BI_audit_ENERGA_RUM_UMOWY":
|
|
|
+ case "default_db/BI_audit_ENERGA_RUM_UMOWY/BI_audit_ENERGA_RUM_UMOWY":
|
|
|
+ $this->SOURCE['TABLE'] = 'BI_audit_ENERGA_RUM_UMOWY';
|
|
|
+ switch ($_subUrlAction) {
|
|
|
+ case "clearTable":
|
|
|
+ $this->clearTable();
|
|
|
+ break;
|
|
|
+ default: SE_Layout::alert('danger', 'Błąd parametru #23');
|
|
|
+ }
|
|
|
+ break;
|
|
|
+ case "default_db/BI_audit_ENERGA_FAKTURY":
|
|
|
+ case "default_db/BI_audit_ENERGA_FAKTURY/BI_audit_ENERGA_FAKTURY":
|
|
|
+ $this->SOURCE['TABLE'] = 'BI_audit_ENERGA_FAKTURY';
|
|
|
+ switch ($_subUrlAction) {
|
|
|
+ case "clearTable":
|
|
|
+ $this->clearTable();
|
|
|
+ break;
|
|
|
+ default: SE_Layout::alert('danger', 'Błąd parametru #24');
|
|
|
+ }
|
|
|
+ break;
|
|
|
case "default_db/BI_audit_ENERGA_RUM_KONTRAHENCI_POWIAZANIA":
|
|
|
+ case "default_db/BI_audit_ENERGA_RUM_KONTRAHENCI_POWIAZANIA/BI_audit_ENERGA_RUM_KONTRAHENCI_POWIAZANIA":
|
|
|
$this->SOURCE['TABLE'] = 'BI_audit_ENERGA_RUM_KONTRAHENCI_POWIAZANIA';
|
|
|
switch ($_subUrlAction) {
|
|
|
case "clearTable":
|
|
|
$this->clearTable();
|
|
|
break;
|
|
|
- efault: SE_Layout::alert('danger', 'Błąd parametru #23');
|
|
|
+ default: SE_Layout::alert('danger', 'Błąd parametru #25');
|
|
|
}
|
|
|
break;
|
|
|
default: SE_Layout::alert('danger', 'Błąd parametru #1');
|
|
|
}
|
|
|
}
|
|
|
else SE_Layout::alert('danger', 'Błąd parametru #0');
|
|
|
+ echo "<br/><br/>";
|
|
|
SE_Layout::dol();
|
|
|
}
|
|
|
|