|
|
@@ -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();
|
|
|
}
|
|
|
|
|
|
@@ -1453,7 +1491,8 @@ Router::getRoute("UrlAction_BiAuditGenerate")->' . $function . ';
|
|
|
];
|
|
|
|
|
|
$query = "select * from `BI_audit_ENERGA_PRACOWNICY_import` where `importResult` = 'none'";
|
|
|
- $pracownicy = DB::getPDO()->queryNotBuffered($query);
|
|
|
+ //$pracownicy = DB::getPDO()->queryNotBuffered($query);
|
|
|
+ $pracownicy = DB::getPDO()->query($query);
|
|
|
while ($pracownik = $pracownicy->fetch()) {
|
|
|
$ID_pracownik = DB::getPDO()->fetchValue("select `ID` from `BI_audit_ENERGA_PRACOWNICY` where `pesel` = '{$pracownik['pesel']}'");
|
|
|
$sqlArr = [];
|
|
|
@@ -1801,7 +1840,8 @@ SQL;
|
|
|
$insertFields = "`" . implode("`, `", array_keys($tableConf['fieldsTeryt'])) . "`";
|
|
|
$selectFields = "`" . implode("`, `", $tableConf['fieldsTeryt']) . "`";
|
|
|
|
|
|
- $adresy = DB::getPDO()->queryNotBuffered($query);
|
|
|
+ //$adresy = DB::getPDO()->queryNotBuffered($query);
|
|
|
+ $adresy = DB::getPDO()->query($query);
|
|
|
while ($adres = $adresy->fetch()) {
|
|
|
DB::getPDO()->query("delete from `{$refTable}` where `PRIMARY_KEY` = '{$adres['ID']}'");
|
|
|
|
|
|
@@ -2092,7 +2132,8 @@ SQL;
|
|
|
}
|
|
|
|
|
|
$BiAuditRelations = new BiAuditRelations();
|
|
|
- $result = DB::getPDO()->queryNotBuffered("select `ID` from `BI_audit_ALL` where `reffed` = 0 order by `ID`");
|
|
|
+ //$result = DB::getPDO()->queryNotBuffered("select `ID` from `BI_audit_ALL` where `reffed` = 0 order by `ID`");
|
|
|
+ $result = DB::getPDO()->query("select `ID` from `BI_audit_ALL` where `reffed` = 0 order by `ID`");
|
|
|
while ($row = $result->fetch()) $BiAuditRelations->findRelations($row['ID']);
|
|
|
DB::getPDO()->query("update `BI_audit_ALL` set `reffed` = 1");
|
|
|
}
|
|
|
@@ -3038,9 +3079,11 @@ class BiAuditPowiazania {
|
|
|
$antDir = "/Library/Server/Web/Data/Sites/Default/SE/schema/WPS_Functions/default_db/recurse_ant/out";
|
|
|
$antXmlFilename = "relations-{$id_part}.out_task.dita.final_with_RelatedFeatureLoop.xml";
|
|
|
$antXmlFile = $antDir . "/" . $antXmlFilename;
|
|
|
- $ditamapFile = "/Library/Server/Web/Data/Sites/Default/SE/schema/WPS_Functions/default_db/CRM_PROCES_tree/temp/relations-{$id_part}/relations-{$id_part}.ditamap";
|
|
|
- $pdfFile = "/Library/Server/Web/Data/Sites/Default/SE/schema/WPS_Functions/default_db/CRM_PROCES_tree/temp/relations-{$id_part}/pdf/relations-{$id_part}.pdf";
|
|
|
- $htmlDir = "/Library/Server/Web/Data/Sites/Default/SE/schema/WPS_Functions/default_db/CRM_PROCES_tree/temp/relations-{$id_part}/html";
|
|
|
+ //$baseDir = "/Library/Server/Web/Data/Sites/Default/SE/schema/WPS_Functions/default_db/CRM_PROCES_tree/temp/relations-{$id_part}";
|
|
|
+ $baseDir = "/opt/local/pl.procesy5/p5build_SE/temp/WPS_Functions/temp/default_db/CRM_PROCES_tree/relations-{$id_part}";
|
|
|
+ $ditamapFile = "{$baseDir}/relations-{$id_part}.ditamap";
|
|
|
+ $pdfFile = "{$baseDir}/pdf/relations-{$id_part}.pdf";
|
|
|
+ $htmlDir = "{$baseDir}/html";
|
|
|
$htmlFile = "{$htmlDir}/relations-{$id_part}.html";
|
|
|
|
|
|
//if (!file_exists($xmlFile))
|
|
|
@@ -3067,7 +3110,7 @@ class BiAuditPowiazania {
|
|
|
}
|
|
|
|
|
|
self::saveToLog("Generuję plik PDF ({$resultsPart})");
|
|
|
- self::exec("cd \"/Library/Server/Web/Data/Sites/Default/SE/schema/WPS_Functions/default_db/CRM_PROCES_tree/temp/relations-{$id_part}\" && /Library/Server/Web/Data/Sites/Default/SE/stuff/dita-ot-2.3.3/bin/dita -o pdf -i relations-{$id_part}.ditamap -f pdf");
|
|
|
+ self::exec("cd \"{$baseDir}\" && /Library/Server/Web/Data/Sites/Default/SE/stuff/dita-ot-2.3.3/bin/dita -o pdf -i relations-{$id_part}.ditamap -f pdf");
|
|
|
if (file_exists($pdfFile)) {
|
|
|
rename($pdfFile, $pdfDestFile);
|
|
|
self::saveToLog("Wygenerowano plik PDF ({$resultsPart})");
|
|
|
@@ -3075,9 +3118,9 @@ class BiAuditPowiazania {
|
|
|
$this->saveProgress(['reportsCreated' => 0.45]);
|
|
|
|
|
|
self::saveToLog("Generuję pliki HTML ({$resultsPart})");
|
|
|
- self::exec("cd \"/Library/Server/Web/Data/Sites/Default/SE/schema/WPS_Functions/default_db/CRM_PROCES_tree/temp/relations-{$id_part}\" && /Library/Server/Web/Data/Sites/Default/SE/stuff/dita-ot-2.3.3/bin/dita -o html -i relations-{$id_part}.ditamap -f tocjs");
|
|
|
+ self::exec("cd \"{$baseDir}\" && /Library/Server/Web/Data/Sites/Default/SE/stuff/dita-ot-2.3.3/bin/dita -o html -i relations-{$id_part}.ditamap -f tocjs");
|
|
|
if (file_exists($htmlDir) && is_dir($htmlDir) && file_exists($htmlFile)) {
|
|
|
- self::exec("cd \"/Library/Server/Web/Data/Sites/Default/SE/schema/WPS_Functions/default_db/CRM_PROCES_tree/temp/relations-{$id_part}\" && zip -r \"{$htmlZipDestFile}\" html");
|
|
|
+ self::exec("cd \"{$baseDir}\" && zip -r \"{$htmlZipDestFile}\" html");
|
|
|
if (file_exists($htmlDestDir)) self::exec("rm -rf \"{$htmlDestDir}\"");
|
|
|
self::exec("mv \"{$htmlDir}\" \"{$htmlDestDir}\"");
|
|
|
self::saveToLog("Wygenerowano pliki HTML ({$resultsPart})");
|