|
|
@@ -1145,25 +1145,17 @@ Router::getRoute("UrlAction_BiAuditGenerate")->' . $function . ';
|
|
|
$generatePowiazaniaResultFile = "{$tasksDirLocation}/generatePowiazania-{$row['ID']}.result";
|
|
|
$generatePowiazaniaPidFile = "{$tasksDirLocation}/generatePowiazania-{$row['ID']}.pid";
|
|
|
$generatePowiazaniaPhpFile = "{$tasksDirLocation}/generatePowiazania-{$row['ID']}.php";
|
|
|
- $generatePowiazaniaPdfFile = "{$tasksDirLocation}/generatePowiazania-{$row['ID']}.pdf";
|
|
|
- $generatePowiazaniaHtmlDir = "{$tasksDirLocation}/generatePowiazania-{$row['ID']}.html";
|
|
|
- $generatePowiazaniaHtmlZipFile = "{$tasksDirLocation}/generatePowiazania-{$row['ID']}.zip";
|
|
|
- $xmlFile = "{$tasksDirLocation}/generatePowiazania-{$row['ID']}.xml";
|
|
|
$error = false;
|
|
|
$success = false;
|
|
|
$sqlArr = [];
|
|
|
if (file_exists($generatePowiazaniaResultFile)) {
|
|
|
- $generatePowiazaniaResult = file_get_contents($generatePowiazaniaResultFile);
|
|
|
- if ($generatePowiazaniaResult == "ok") {
|
|
|
- if (file_exists($xmlFile)) {
|
|
|
- if (filesize($xmlFile)) {
|
|
|
- $powiazanieDirLocation = $this->getDirectory('BI_audit_ENERGA_RUM_KONTRAHENCI_POWIAZANIA', $row['ID']);
|
|
|
- if (!file_exists($powiazanieDirLocation)) mkdir($powiazanieDirLocation, 0777, false);
|
|
|
- if (!file_exists($powiazanieDirLocation)) $error = "Nie udało się wgrać pliku xml - nie można utworzyć katalogu dla rekordu";
|
|
|
- else $success = true;
|
|
|
- } else $error = "Wystąpił nieznany błąd - plk xml został wygenerowany niepoprawnie";
|
|
|
- } else $error = "Wystąpił nienzany błąd - nie znaleziono pliku xml";
|
|
|
- } else $error = "Wystąpił błąd podczas generowania powiązań ({$generatePowiazaniaResult})";
|
|
|
+ $generatePowiazaniaResult = json_decode(file_get_contents($generatePowiazaniaResultFile), true);
|
|
|
+ if ($generatePowiazaniaResult['result'] == "ok") {
|
|
|
+ $powiazanieDirLocation = $this->getDirectory('BI_audit_ENERGA_RUM_KONTRAHENCI_POWIAZANIA', $row['ID']);
|
|
|
+ if (!file_exists($powiazanieDirLocation)) mkdir($powiazanieDirLocation, 0777, false);
|
|
|
+ if (!file_exists($powiazanieDirLocation)) $error = "Nie udało się wgrać pliku xml - nie można utworzyć katalogu dla rekordu";
|
|
|
+ else $success = true;
|
|
|
+ } else $error = "Wystąpił błąd podczas generowania powiązań ({$generatePowiazaniaResult['message']})";
|
|
|
} elseif (file_exists($generatePowiazaniaPidFile)) {
|
|
|
$pid = file_get_contents($generatePowiazaniaPidFile);
|
|
|
$processRunning = trim(shell_exec("ps -p {$pid} -o command | grep -v '^COMMAND$'"));
|
|
|
@@ -1179,24 +1171,49 @@ Router::getRoute("UrlAction_BiAuditGenerate")->' . $function . ';
|
|
|
'FILE_STATUS_info' => $error,
|
|
|
];
|
|
|
self::deleteResultsFromDB($row['ID']);
|
|
|
- if (file_exists($xmlFile)) unlink($xmlFile);
|
|
|
+ //if (file_exists($xmlFile)) unlink($xmlFile);
|
|
|
} elseif ($success) {
|
|
|
$sqlArr = [
|
|
|
'FILE_STATUS' => 'GENERATED',
|
|
|
'FILE_STATUS_info' => 'Poprawnie wygenerowano powiązania',
|
|
|
];
|
|
|
- $destXmlFile = "{$powiazanieDirLocation}/relations.xml";
|
|
|
- $destPdfFile = "{$powiazanieDirLocation}/relations.pdf";
|
|
|
- $destHtmlDir = "{$powiazanieDirLocation}/html";
|
|
|
- $destHtmlZipFile = "{$powiazanieDirLocation}/html.zip";
|
|
|
-
|
|
|
- rename($xmlFile, $destXmlFile);
|
|
|
- if (file_exists($generatePowiazaniaPdfFile)) rename($generatePowiazaniaPdfFile, $destPdfFile);
|
|
|
- if (file_exists($generatePowiazaniaHtmlDir)) {
|
|
|
- if (file_exists($destHtmlDir)) shell_exec("rm -rf \"{$destHtmlDir}\"");
|
|
|
- rename($generatePowiazaniaHtmlDir, $destHtmlDir);
|
|
|
+ if ($generatePowiazaniaResult['parts']) {
|
|
|
+ for ($i = 1; $i <= $generatePowiazaniaResult['parts']; $i++) {
|
|
|
+ $partNo = str_pad($i, 6, '0', STR_PAD_LEFT);
|
|
|
+ $generateFilesName = "{$tasksDirLocation}/generatePowiazania-{$row['ID']}_{$partNo}";
|
|
|
+ $generatePowiazaniaXmlFile = "{$generateFilesName}.xml";
|
|
|
+ $generatePowiazaniaPdfFile = "{$generateFilesName}.pdf";
|
|
|
+ $generatePowiazaniaHtmlDir = "{$generateFilesName}.html";
|
|
|
+ $generatePowiazaniaHtmlZipFile = "{$generateFilesName}.zip";
|
|
|
+ $destXmlFile = "{$powiazanieDirLocation}/relations_{$partNo}.xml";
|
|
|
+ $destPdfFile = "{$powiazanieDirLocation}/relations_{$partNo}.pdf";
|
|
|
+ $destHtmlDir = "{$powiazanieDirLocation}/html_{$partNo}";
|
|
|
+ $destHtmlZipFile = "{$powiazanieDirLocation}/html_{$partNo}.zip";
|
|
|
+ if (file_exists($generatePowiazaniaXmlFile)) rename($generatePowiazaniaXmlFile, $destXmlFile);
|
|
|
+ if (file_exists($generatePowiazaniaPdfFile)) rename($generatePowiazaniaPdfFile, $destPdfFile);
|
|
|
+ if (file_exists($generatePowiazaniaHtmlDir)) {
|
|
|
+ if (file_exists($destHtmlDir)) shell_exec("rm -rf \"{$destHtmlDir}\"");
|
|
|
+ rename($generatePowiazaniaHtmlDir, $destHtmlDir);
|
|
|
+ }
|
|
|
+ if (file_exists($generatePowiazaniaHtmlZipFile)) rename($generatePowiazaniaHtmlZipFile, $destHtmlZipFile);
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ $generateFilesName = "{$tasksDirLocation}/generatePowiazania-{$row['ID']}";
|
|
|
+ $generatePowiazaniaPdfFile = "{$generateFilesName}.pdf";
|
|
|
+ $generatePowiazaniaHtmlDir = "{$generateFilesName}.html";
|
|
|
+ $generatePowiazaniaHtmlZipFile = "{$generateFilesName}.zip";
|
|
|
+ $destXmlFile = "{$powiazanieDirLocation}/relations.xml";
|
|
|
+ $destPdfFile = "{$powiazanieDirLocation}/relations.pdf";
|
|
|
+ $destHtmlDir = "{$powiazanieDirLocation}/html";
|
|
|
+ $destHtmlZipFile = "{$powiazanieDirLocation}/html.zip";
|
|
|
+ if (file_exists($generatePowiazaniaXmlFile)) rename($generatePowiazaniaXmlFile, $destXmlFile);
|
|
|
+ if (file_exists($generatePowiazaniaPdfFile)) rename($generatePowiazaniaPdfFile, $destPdfFile);
|
|
|
+ if (file_exists($generatePowiazaniaHtmlDir)) {
|
|
|
+ if (file_exists($destHtmlDir)) shell_exec("rm -rf \"{$destHtmlDir}\"");
|
|
|
+ rename($generatePowiazaniaHtmlDir, $destHtmlDir);
|
|
|
+ }
|
|
|
+ if (file_exists($generatePowiazaniaHtmlZipFile)) rename($generatePowiazaniaHtmlZipFile, $destHtmlZipFile);
|
|
|
}
|
|
|
- if (file_exists($generatePowiazaniaHtmlZipFile)) rename($generatePowiazaniaHtmlZipFile, $destHtmlZipFile);
|
|
|
}
|
|
|
|
|
|
if ($sqlArr) {
|
|
|
@@ -1759,7 +1776,6 @@ Router::getRoute("UrlAction_BiAuditGenerate")->' . $function . ';
|
|
|
$tasksDirLocation = $powiazaniaDirLocation . "/.tasks";
|
|
|
$resultFile = "{$tasksDirLocation}/generatePowiazania-{$ID}.result";
|
|
|
$xmlFile = "{$tasksDirLocation}/generatePowiazania-{$ID}.xml";
|
|
|
- $pdfFile = "{$tasksDirLocation}/generatePowiazania-{$ID}.pdf";
|
|
|
$pidFile = "{$tasksDirLocation}/generatePowiazania-{$ID}.pid";
|
|
|
file_put_contents($pidFile, getmypid());
|
|
|
|
|
|
@@ -1779,11 +1795,12 @@ Router::getRoute("UrlAction_BiAuditGenerate")->' . $function . ';
|
|
|
try {
|
|
|
$BiAuditPowiazania = new BiAuditPowiazania($ID, $tasksDirLocation);
|
|
|
if (!$BiAuditPowiazania->powiazaniaFound()) throw new Exception("Nie znaleziono żadnych powiązań");
|
|
|
- file_put_contents($xmlFile, $BiAuditPowiazania->asXml());
|
|
|
+ //file_put_contents($xmlFile, $BiAuditPowiazania->asXml());
|
|
|
+ $BiAuditPowiazania->saveXml();
|
|
|
$BiAuditPowiazania->generatePdfAndHtml();
|
|
|
- file_put_contents($resultFile, "ok");
|
|
|
+ file_put_contents($resultFile, json_encode(['result' => 'ok', 'parts' => $BiAuditPowiazania->getPartsCount()]));
|
|
|
} catch (Exception $e) {
|
|
|
- file_put_contents($resultFile, $e->getMessage());
|
|
|
+ file_put_contents($resultFile, json_encode(['result' => 'error', 'message' => $e->getMessage()]));
|
|
|
}
|
|
|
}
|
|
|
|
|
|
@@ -1931,6 +1948,7 @@ class BiAuditPowiazania {
|
|
|
private $startTimestamp = null;
|
|
|
private $lowProgressCount = 0;
|
|
|
private $count, $i;
|
|
|
+ private $splittedResults = [];
|
|
|
|
|
|
private function getRefTable($tableFrom, $tableTo, $returnException = true) {
|
|
|
if (!isset($this->refTables[$tableFrom][$tableTo])) {
|
|
|
@@ -1977,8 +1995,9 @@ class BiAuditPowiazania {
|
|
|
$result = DB::getPDO()->fetchAll($query);
|
|
|
if (!$result) $this->throwException("Błąd danych");
|
|
|
|
|
|
+ $this->ID = $ID;
|
|
|
if ($this->loadResults()) {
|
|
|
- $this->saveToLog("Wczytano wcześnie wyliczone dane");
|
|
|
+ $this->splitResults();
|
|
|
return;
|
|
|
}
|
|
|
|
|
|
@@ -1989,7 +2008,6 @@ class BiAuditPowiazania {
|
|
|
if (!$this->minDepth) $this->minDepth = 1;
|
|
|
if (!$this->maxDepth) $this->throwException("Błąd danych - nieokreślono maksymalnej głębokości analizy");
|
|
|
if ($this->minDepth > $this->maxDepth) $this->throwException("Wartość minimalnej głębokości analizy jest większa od wartości maksymalnej głębokości analizy");
|
|
|
- $this->ID = $ID;
|
|
|
|
|
|
$subQueries = [];
|
|
|
foreach ($this->destTables as $destTable) {
|
|
|
@@ -2022,8 +2040,8 @@ class BiAuditPowiazania {
|
|
|
$this->nodes = [];
|
|
|
$this->saveToLog("Zakończono wyszukiwanie powiązań");
|
|
|
$this->saveResults();
|
|
|
- $this->saveToLog("Zapisano wyliczone dane do pliku");
|
|
|
$this->saveToDb();
|
|
|
+ $this->splitResults();
|
|
|
}
|
|
|
|
|
|
public function findPowiazania($ID, $progress = 0, $steps = 1, $relation = "", $end = 0) {
|
|
|
@@ -2097,10 +2115,11 @@ class BiAuditPowiazania {
|
|
|
private function loadResults() {
|
|
|
$this->saveToLog("Próbuję wczytać wcześniej wyliczone dane");
|
|
|
$dataFile = "{$this->tasksDirLocation}/generatePowiazania-{$this->ID}.data";
|
|
|
- if (!file_exists($dateFile)) {
|
|
|
+ if (!file_exists($dataFile)) {
|
|
|
$this->saveToLog("Nie znaleziono pliku z wyliczonymi danymi");
|
|
|
return false;
|
|
|
}
|
|
|
+ $data = file_get_contents($dataFile);
|
|
|
$results = @json_decode(gzuncompress(base64_decode($data)), true);
|
|
|
if (!$results) {
|
|
|
$this->saveToLog("Wystąpił błąd wczytywania wcześniej wyliczonych danych");
|
|
|
@@ -2108,6 +2127,7 @@ class BiAuditPowiazania {
|
|
|
}
|
|
|
$this->results = $results;
|
|
|
$this->saveToLog("Wczytano wcześniej wyliczone dane");
|
|
|
+
|
|
|
return true;
|
|
|
}
|
|
|
|
|
|
@@ -2121,8 +2141,44 @@ class BiAuditPowiazania {
|
|
|
return $this->relations[$ID];
|
|
|
}
|
|
|
|
|
|
- private function generateItemsResults() {
|
|
|
- $this->saveToLog("Generuję dane na potrzeby utworzenia pliku XML");
|
|
|
+ private function splitResults() {
|
|
|
+ $MAX = 1000;
|
|
|
+
|
|
|
+ $countBySource = [];
|
|
|
+ $resultsKeys = [];
|
|
|
+ foreach ($this->results as $resultKey => $result) $countBySource[reset(array_keys($result))][] = $resultKey;
|
|
|
+ foreach ($countBySource as $resultKeys) {
|
|
|
+ if (count($resultKeys) > $MAX) {
|
|
|
+ $countByDest = [];
|
|
|
+ foreach ($resultKeys as $resultKey) $countByDest[end(array_keys($this->results[$resultKey]))][] = $resultKey;
|
|
|
+ foreach ($countByDest as $resultKeys2) {
|
|
|
+ while (count($resultKeys2) > $MAX) $resultsKeys[] = array_splice($resultKeys2, 0, $MAX);
|
|
|
+ $resultsKeys[] = $resultKeys2;
|
|
|
+ }
|
|
|
+ } else $resultsKeys[] = $resultKeys;
|
|
|
+ }
|
|
|
+
|
|
|
+ $results = [];
|
|
|
+ while ($resultsKeys) {
|
|
|
+ $resultKeys = array_shift($resultsKeys);
|
|
|
+ while ($next = current($resultsKeys)) {
|
|
|
+ if (count($resultKeys) + count($next) <= $MAX) {
|
|
|
+ $resultKeys = array_merge($resultKeys, $next);
|
|
|
+ unset($resultsKeys[key($resultsKeys)]);
|
|
|
+ } else next($resultsKeys);
|
|
|
+ }
|
|
|
+ $results[] = array_map(function ($resultKey) {return $this->results[$resultKey];}, $resultKeys);
|
|
|
+ }
|
|
|
+
|
|
|
+ $this->splittedResults = $results;
|
|
|
+ }
|
|
|
+
|
|
|
+ public function getPartsCount() {
|
|
|
+ return count($this->splittedResults);
|
|
|
+ }
|
|
|
+
|
|
|
+ private function generateItemsResults($resultsPart = null) {
|
|
|
+ $this->saveToLog("Generuję dane na potrzeby utworzenia pliku XML ({$resultsPart})");
|
|
|
$xmlRoot2 = "BI_audit_ENERGA_RUM_KONTRAHENCI_POWIAZANIA";
|
|
|
$xmlElements = "BI_audit_ENERGA_RUM_KONTRAHENCI_POWIAZANIA_row";
|
|
|
|
|
|
@@ -2131,11 +2187,15 @@ class BiAuditPowiazania {
|
|
|
$items_kw_person = [];
|
|
|
$kontrahenci = [];
|
|
|
$kw_person = [];
|
|
|
+ $_items_results = [];
|
|
|
|
|
|
$refUmowyToKontrahenci = $this->getRefTable('BI_audit_ENERGA_RUM_UMOWY', 'BI_audit_ENERGA_RUM_KONTRAHENCI');
|
|
|
$refKwRequestedToKwRequestedPerson = $this->getRefTable('BI_audit_KW_requested', 'BI_audit_KW_requested_person');
|
|
|
|
|
|
- foreach ($this->results as $result) {
|
|
|
+ if ($resultsPart === null) $results = $this->results;
|
|
|
+ else $results = (!empty($this->splittedResults[$resultsPart])) ? $this->splittedResults[$resultsPart] : [];
|
|
|
+
|
|
|
+ foreach ($results as $result) {
|
|
|
$item_results = [];
|
|
|
foreach ($result as $ID => $rel) {
|
|
|
$query = "select REMOTE_TABLE, REMOTE_ID from BI_audit_ALL where ID = '{$ID}'";
|
|
|
@@ -2181,11 +2241,11 @@ class BiAuditPowiazania {
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
- $this->items_results[$xmlRoot2][$xmlElements][] = $item_results;
|
|
|
+ $this->items_results[$resultsPart][$xmlRoot2][$xmlElements][] = $item_results;
|
|
|
}
|
|
|
- $this->items_results[$xmlRoot2]['BI_audit_ENERGA_RUM_KONTRAHENCI'] = $items_kontrahenci;
|
|
|
- $this->items_results[$xmlRoot2]['BI_audit_KW_requested_person'] = $items_kw_person;
|
|
|
- $this->saveToLog("Wygenerowano dane na potrzeby utworzenia pliku XML");
|
|
|
+ $this->items_results[$resultsPart][$xmlRoot2]['BI_audit_ENERGA_RUM_KONTRAHENCI'] = $items_kontrahenci;
|
|
|
+ $this->items_results[$resultsPart][$xmlRoot2]['BI_audit_KW_requested_person'] = $items_kw_person;
|
|
|
+ $this->saveToLog("Wygenerowano dane na potrzeby utworzenia pliku XML ({$resultsPart})");
|
|
|
}
|
|
|
|
|
|
private function saveToDb() {
|
|
|
@@ -2211,22 +2271,47 @@ class BiAuditPowiazania {
|
|
|
$this->saveToLog("Zapisano wyliczone dane do bazy");
|
|
|
}
|
|
|
|
|
|
- public function asXml() {
|
|
|
- $this->saveToLog("Tworzę plik XML");
|
|
|
- if (!$this->results) return null;
|
|
|
- if (!$this->items_results) $this->generateItemsResults();
|
|
|
+ public function saveXml() {
|
|
|
+ if ($this->getPartsCount()) {
|
|
|
+ $this->saveToLog("Generuję pliki XML (liczba plików do wygenerowania: {$this->getPartsCount()})");
|
|
|
+ for ($i =0; $i < $this->getPartsCount(); $i++) {
|
|
|
+ $partNo = str_pad($i + 1, 6, '0', STR_PAD_LEFT);
|
|
|
+ $xmlFile = "{$this->tasksDirLocation}/generatePowiazania-{$this->ID}_{$partNo}.xml";
|
|
|
+ file_put_contents($xmlFile, $this->asXml($i));
|
|
|
+ }
|
|
|
+ $this->saveToLog("Zakończono generowanie plików XML");
|
|
|
+ } else {
|
|
|
+ $xmlFile = "{$this->tasksDirLocation}/generatePowiazania-{$this->ID}.xml";
|
|
|
+ file_put_contents($xmlFile, $this->asXml());
|
|
|
+ }
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+ public function asXml($resultsPart = null) {
|
|
|
+ $this->saveToLog("Generuję plik XML ({$resultsPart})");
|
|
|
+ if (!$this->results) {
|
|
|
+ $this->saveToLog("Brak wyników (#1), nie wygenerowano pliku XML ({$resultsPart})");
|
|
|
+ return null;
|
|
|
+ }
|
|
|
+ if (!$this->items_results[$resultsPart]) $this->generateItemsResults($resultsPart);
|
|
|
+ if (!$this->items_results[$resultsPart]) {
|
|
|
+ $this->saveToLog("Brak wyników (#2), nie wygenerowano pliku XML ({$resultsPart})");
|
|
|
+ return null;
|
|
|
+ }
|
|
|
$xmlRoot = "RelatedFeatureRoot";
|
|
|
- return V::arrayToXML($this->items_results, true, $xmlRoot);
|
|
|
- $this->saveToLog("Utworzono plik XML");
|
|
|
+ $return = V::arrayToXML($this->items_results[$resultsPart], true, $xmlRoot);
|
|
|
+ $this->saveToLog("Wygenerowano plik XML ({$resultsPart})");
|
|
|
+ return $return;
|
|
|
}
|
|
|
|
|
|
- public function asArray($subArray = null) {
|
|
|
+ public function asArray($resultsPart = null, $subArray = null) {
|
|
|
if (!$this->results) return null;
|
|
|
- if (!$this->items_results) $this->generateItemsResults();
|
|
|
+ if (!$this->items_results[$resultsPart]) $this->generateItemsResults($resultsPart);
|
|
|
+ if (!$this->items_results[$resultsPart]) return null;
|
|
|
if ($subArray) {
|
|
|
- if (isset($this->items_results[$subArray])) return $this->items_results[$subArray];
|
|
|
+ if (isset($this->items_results[$resultsPart][$subArray])) return $this->items_results[$subArray];
|
|
|
else return [];
|
|
|
- } else return $this->items_results;
|
|
|
+ } else return $this->items_results[$resultsPart];
|
|
|
}
|
|
|
|
|
|
public function powiazaniaFound() {
|
|
|
@@ -2235,35 +2320,46 @@ class BiAuditPowiazania {
|
|
|
}
|
|
|
|
|
|
public function generatePdfAndHtml() {
|
|
|
- $xmlFile = "{$this->tasksDirLocation}/generatePowiazania-{$this->ID}.xml";
|
|
|
- $pdfDestFile = "{$this->tasksDirLocation}/generatePowiazania-{$this->ID}.pdf";
|
|
|
- $htmlDestDir = "{$this->tasksDirLocation}/generatePowiazania-{$this->ID}.html";
|
|
|
- $htmlZipDestFile = "{$this->tasksDirLocation}/generatePowiazania-{$this->ID}.zip";
|
|
|
+ if ($this->getPartsCount()) {
|
|
|
+ $this->saveToLog("Generuję raporty w plikach PDF oraz HTML (liczba raportów do wygenerowania: {$this->getPartsCount()})");
|
|
|
+ for ($i =0; $i < $this->getPartsCount(); $i++) $this->_generatePdfAndHtml($i);
|
|
|
+ $this->saveToLog("Zakończono generowanie raportów w plikach PDF oraz HTML");
|
|
|
+ } else $this->_generatePdfAndHtml();
|
|
|
+ }
|
|
|
+
|
|
|
+ private function _generatePdfAndHtml($resultsPart = null) {
|
|
|
+ $id_part = $resultsPart === null ? $this->ID : $this->ID . "_" . str_pad($resultsPart + 1, 6, '0', STR_PAD_LEFT);
|
|
|
+ $this->saveToLog("Generuję raport w pliku PDF oraz HTML ({$resultsPart})");
|
|
|
+ $xmlFile = "{$this->tasksDirLocation}/generatePowiazania-{$id_part}.xml";
|
|
|
+ $pdfDestFile = "{$this->tasksDirLocation}/generatePowiazania-{$id_part}.pdf";
|
|
|
+ $htmlDestDir = "{$this->tasksDirLocation}/generatePowiazania-{$id_part}.html";
|
|
|
+ $htmlZipDestFile = "{$this->tasksDirLocation}/generatePowiazania-{$id_part}.zip";
|
|
|
$antDir = "/Library/Server/Web/Data/Sites/Default/SE/schema/WPS_Functions/default_db/recurse_ant/out";
|
|
|
- $antXmlFilename = "relations-{$this->ID}.out_task.dita.final_with_RelatedFeatureLoop.xml";
|
|
|
+ $antXmlFilename = "relations-{$id_part}.out_task.dita.final_with_RelatedFeatureLoop.xml";
|
|
|
$antXmlFile = $antDir . "/" . $antXmlFilename;
|
|
|
- $pdfFile = "/Library/Server/Web/Data/Sites/Default/SE/schema/WPS_Functions/default_db/CRM_PROCES_tree/temp/relations-{$this->ID}/pdf/relations-{$this->ID}.pdf";
|
|
|
- $htmlDir = "/Library/Server/Web/Data/Sites/Default/SE/schema/WPS_Functions/default_db/CRM_PROCES_tree/temp/relations-{$this->ID}/html";
|
|
|
+ $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";
|
|
|
if (!file_exists($antDir)) mkdir($antDir, 0755, true);
|
|
|
- if (!is_dir($antDir)) $sqlArr['FILE_STATUS_info'] .= ", ale nie udało się utworzyć pliku PDF";
|
|
|
- else {
|
|
|
+ if (!is_dir($antDir)) {
|
|
|
+ $sqlArr['FILE_STATUS_info'] .= ", ale nie udało się utworzyć plików PDF i HTML";
|
|
|
+ $this->saveToLog("Nie wygenerowano plików PDF oraz HTML - problem z utworzeniem katalogu dla ant ({$resultsPart})");
|
|
|
+ } else {
|
|
|
copy($xmlFile, $antXmlFile);
|
|
|
- $this->saveToLog("Tworzę raport w pliku PDF oraz HTML");
|
|
|
- shell_exec("cd /Library/Server/Web/Data/Sites/Default/SE/schema/WPS_Functions/default_db/CRM_PROCES_tree && /opt/local/bin/ant -f build_CRM_PROCES_tree.xml default_db:PROCES_INIT:tree:dita -Duuid=relations-{$this->ID}");
|
|
|
- $this->saveToLog("Tworzę plik PDF");
|
|
|
- shell_exec("cd \"/Library/Server/Web/Data/Sites/Default/SE/schema/WPS_Functions/default_db/CRM_PROCES_tree/temp/relations-{$this->ID}\" && /Library/Server/Web/Data/Sites/Default/SE/stuff/dita-ot-2.3.3/bin/dita -o pdf -i relations-{$this->ID}.ditamap -f pdf");
|
|
|
+ shell_exec("cd /Library/Server/Web/Data/Sites/Default/SE/schema/WPS_Functions/default_db/CRM_PROCES_tree && /opt/local/bin/ant -f build_CRM_PROCES_tree.xml default_db:PROCES_INIT:tree:dita -Duuid=relations-{$id_part}");
|
|
|
+ $this->saveToLog("Generuję plik PDF ({$resultsPart})");
|
|
|
+ shell_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");
|
|
|
if (file_exists($pdfFile)) {
|
|
|
rename($pdfFile, $pdfDestFile);
|
|
|
- $this->saveToLog("Utworzono plik PDF");
|
|
|
- } $this->saveToLog("Nie udało się utworzyć pliku PDF");
|
|
|
- $this->saveToLog("Tworzę pliki HTML");
|
|
|
- shell_exec("cd \"/Library/Server/Web/Data/Sites/Default/SE/schema/WPS_Functions/default_db/CRM_PROCES_tree/temp/relations-{$this->ID}\" && /Library/Server/Web/Data/Sites/Default/SE/stuff/dita-ot-2.3.3/bin/dita -o html -i relations-{$this->ID}.ditamap -f tocjs");
|
|
|
+ $this->saveToLog("Wygenerowano plik PDF ({$resultsPart})");
|
|
|
+ } else $this->saveToLog("Nie udało się wygenerować pliku PDF ({$resultsPart})");
|
|
|
+ $this->saveToLog("Generuję pliki HTML ({$resultsPart})");
|
|
|
+ shell_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");
|
|
|
if (file_exists($htmlDir) && is_dir($htmlDir)) {
|
|
|
- shell_exec("cd \"/Library/Server/Web/Data/Sites/Default/SE/schema/WPS_Functions/default_db/CRM_PROCES_tree/temp/relations-{$this->ID}\" && zip -r \"{$htmlZipDestFile}\" html");
|
|
|
+ shell_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");
|
|
|
if (file_exists($htmlDestDir)) shell_exec("rm -rf \"{$htmlDestDir}\"");
|
|
|
shell_exec("mv \"{$htmlDir}\" \"{$htmlDestDir}\"");
|
|
|
- $this->saveToLog("Utworono pliki HTML");
|
|
|
- } else $this->saveToLog("Nie udało się utworzyć plików HTML");
|
|
|
+ $this->saveToLog("Wygenerowano pliki HTML ({$resultsPart})");
|
|
|
+ } else $this->saveToLog("Nie udało się wygenerować plików HTML {$resultsPart})");
|
|
|
}
|
|
|
}
|
|
|
}
|