Forráskód Böngészése

BiAuditGenerate - poprawienie wyzwalania nowego zadania w trakcie działania innego zadania + drobny tuning

Mariusz Muszyński 8 éve
szülő
commit
799dac13fa
1 módosított fájl, 70 hozzáadás és 67 törlés
  1. 70 67
      SE/se-lib/Route/UrlAction/BiAuditGenerate.php

+ 70 - 67
SE/se-lib/Route/UrlAction/BiAuditGenerate.php

@@ -30,7 +30,7 @@ class Route_UrlAction_BiAuditGenerate extends RouteBase {
 		}
 	}
 
-	private function getDirectory($table, $id) {
+	private static function getDirectory($table, $id) {
 		$folderConf = FoldersConfig::getAll($table.'_COLUMN');
 		$record = new stdClass;
 		$record->ID = $id;
@@ -41,7 +41,7 @@ class Route_UrlAction_BiAuditGenerate extends RouteBase {
 		return $uploader->getDestLocalPath(true);
 	}
 
-	private function getUrl($table, $id) {
+	private static function getUrl($table, $id) {
 		$folderConf = FoldersConfig::getAll($table.'_COLUMN');
 		$record = new stdClass;
 		$record->ID = $id;
@@ -51,7 +51,7 @@ class Route_UrlAction_BiAuditGenerate extends RouteBase {
 		return $uploader->getFolderWeb() . "/" . $uploader->getDestFolder(true);
 	}
 
-	private function getMainDirectory() {
+	private static function getMainDirectory() {
 		$folderConf = FoldersConfig::getAll('BI_audit_ENERGA_RUM_KONTRAHENCI_POWIAZANIA_COLUMN');
 		if (!isset($folderConf['mount_point'])) throw new HttpException("Błąd danych konfiguracyjnych<br>\n{$errMsg}", 404);
 		return $folderConf['mount_point'];
@@ -263,11 +263,11 @@ function toggle(source) {
 
 	private function showPowiazania() {
 //		echo "Statystyki znalezionych powiązań [TODO]";
-		$dir = $this->getDirectory('BI_audit_ENERGA_RUM_KONTRAHENCI_POWIAZANIA', $this->powiazanie['ID']);
+		$dir = self::getDirectory('BI_audit_ENERGA_RUM_KONTRAHENCI_POWIAZANIA', $this->powiazanie['ID']);
 		$pdfFile = "{$dir}/relations.pdf";
 		$htmlFile = "{$dir}/html/relations-{$this->powiazanie['ID']}.html";
 		$htmlZipFile = "{$dir}/html.zip";
-		$url = $this->getUrl('BI_audit_ENERGA_RUM_KONTRAHENCI_POWIAZANIA', $this->powiazanie['ID']);
+		$url = self::getUrl('BI_audit_ENERGA_RUM_KONTRAHENCI_POWIAZANIA', $this->powiazanie['ID']);
 		$pdfUrl = "{$url}/relations.pdf";
 		$htmlUrl = "{$url}/html/relations-{$this->powiazanie['ID']}.html";
 		$htmlZipUrl = "{$url}/html.zip";
@@ -989,7 +989,7 @@ where `BI_audit_ENERGA_RUM_KONTRAHENCI_POWIAZANIA`.`ID` = '{$ID}'";
 
 	public function doGenerate() {
 
-		function generatePhpScript($function) {
+		$generatePhpScript = function($function) {
 			return '<?php
 ini_set("memory_limit", "4G");
 define("DS", DIRECTORY_SEPARATOR);
@@ -1007,7 +1007,7 @@ require_once(APP_PATH_ROOT . DS . "se-lib" . DS . "bootstrap.php");
 Lib::loadClass("Router");
 Router::getRoute("UrlAction_BiAuditGenerate")->' . $function . ';
 ';
-		}
+		};
 
 		try {
 			### Ustawiamy zmienną sesji nazwy użytkownika, aby w rekordach historycznych było widać, że autorem systemu jest moduł BiAuditGenerate
@@ -1020,7 +1020,7 @@ Router::getRoute("UrlAction_BiAuditGenerate")->' . $function . ';
 
 
 			### Ustawienie zmiennych
-			$powiazaniaDirLocation = $this->getMainDirectory();
+			$powiazaniaDirLocation = self::getMainDirectory();
 			$tasksDirLocation = $powiazaniaDirLocation . "/.tasks";
 			$reloadCachePhpFile = $tasksDirLocation . "/reloadCache.php";
 			$reloadCachePidFile = $tasksDirLocation . "/reloadCache.pid";
@@ -1031,6 +1031,7 @@ Router::getRoute("UrlAction_BiAuditGenerate")->' . $function . ';
 			if (!file_exists($tasksDirLocation)) mkdir($tasksDirLocation, 0755, true);
 			if (!file_exists($tasksDirLocation)) throw new Exception('Error during creating temporary directory.');
 
+/*
 			### Wymuszenie częsciowego odświezenia cache
 			$sqlArr = [
 				'BI_analiza_reloadCache' => 'Part',
@@ -1041,10 +1042,11 @@ Router::getRoute("UrlAction_BiAuditGenerate")->' . $function . ';
 			foreach ($result as $row) {
 				DB::getDB()->UPDATE_OBJ('BI_audit_ENERGA_RUM_KONTRAHENCI_POWIAZANIA', array_merge(['ID' => $row['ID']], $sqlArr));
 			}
+*/
 
 			### Sprawdzenie czy któryś rekord wymaga odświeżenia cache
 			$doGenerate = true;
-			$query = "select ID from BI_audit_ENERGA_RUM_KONTRAHENCI_POWIAZANIA where BI_analiza_reloadCache in ('Full', 'Part') and FILE_STATUS = 'TO_GENERATE'";
+			$query = "select ID from BI_audit_ENERGA_RUM_KONTRAHENCI_POWIAZANIA where BI_analiza_reloadCache in ('Full') and FILE_STATUS = 'TO_GENERATE'";
 			$result = DB::getPDO()->fetchAll($query);
 			if ($result) {
 				$doGenerate = false;
@@ -1102,7 +1104,7 @@ Router::getRoute("UrlAction_BiAuditGenerate")->' . $function . ';
 
 						$query = "select count(*) from BI_audit_ENERGA_RUM_KONTRAHENCI_POWIAZANIA where BI_analiza_reloadCache = 'Full' and FILE_STATUS = 'TO_GENERATE'";
 						$fullReloadCache = (DB::getPDO()->fetchValue($query) > 0);
-						file_put_contents($reloadCachePhpFile, generatePhpScript("doReloadCache({$fullReloadCache})"));
+						file_put_contents($reloadCachePhpFile, $generatePhpScript("doReloadCache({$fullReloadCache})"));
 						shell_exec('su - root -c "php ' . $reloadCachePhpFile . ' > ' . $reloadCacheLogFile. ' 2>&1 &"');
 					}
 				}
@@ -1132,7 +1134,7 @@ Router::getRoute("UrlAction_BiAuditGenerate")->' . $function . ';
 					$generatePowiazaniaResultFile = "{$tasksDirLocation}/generatePowiazania-{$row['ID']}.result";
 					$generatePowiazaniaPhpFile = "{$tasksDirLocation}/generatePowiazania-{$row['ID']}.php";
 					$generatePowiazaniaLogFile = "{$tasksDirLocation}/generatePowiazania-{$row['ID']}.log";
-					file_put_contents($generatePowiazaniaPhpFile, generatePhpScript("doGeneratePowiazania({$row['ID']})"));
+					file_put_contents($generatePowiazaniaPhpFile, $generatePhpScript("doGeneratePowiazania({$row['ID']})"));
 					shell_exec('su - root -c "php ' . $generatePowiazaniaPhpFile . ' > ' . $generatePowiazaniaLogFile. ' 2>&1 &"');
 				}
 			}
@@ -1151,7 +1153,7 @@ Router::getRoute("UrlAction_BiAuditGenerate")->' . $function . ';
 				if (file_exists($generatePowiazaniaResultFile)) {
 					$generatePowiazaniaResult = json_decode(file_get_contents($generatePowiazaniaResultFile), true);
 					if ($generatePowiazaniaResult['result'] == "ok") {
-						$powiazanieDirLocation = $this->getDirectory('BI_audit_ENERGA_RUM_KONTRAHENCI_POWIAZANIA', $row['ID']);
+						$powiazanieDirLocation = self::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;
@@ -1404,7 +1406,7 @@ SQL;
 		}
 	}
 
-	private function reloadCache_reTeryt($full = false) {
+	private static function reloadCache_reTeryt($full = false) {
 
 		Lib::loadClass('Teryt');
 
@@ -1756,7 +1758,7 @@ SQL;
 //		DB::getPDO()->query("unlock tables");
 	}
 
-	public function doReloadCache($full = false) {
+	public static function doReloadCache($full = false) {
 		if ($full === 'base') {
 			$onlyBase = true;
 			$full = false;
@@ -1764,26 +1766,24 @@ SQL;
 			$onlyBase = false;
 		}
 
-		$powiazaniaDirLocation = $this->getMainDirectory();
+		$powiazaniaDirLocation = self::getMainDirectory();
 		$tasksDirLocation = $powiazaniaDirLocation . "/.tasks";
 		$reloadCachePidFile = $tasksDirLocation . "/reloadCache.pid";
 		$reloadCacheResultFile = $tasksDirLocation . "/reloadCache.result";
 		file_put_contents($reloadCachePidFile, getmypid());
 		try {
-//			self::reloadCache_reTeryt($full);
+			self::reloadCache_reTeryt($full);
 			self::reloadCache_parseUmowy($full);
 			self::reloadCache_updateAll($full, $onlyBase);
-//			echo "updateall ok\n";
 			file_put_contents($reloadCacheResultFile, "ok");
 		} catch (Exception $e) {
-			echo "\n{$e->getMessage()}\n";
 			var_dump($e);
 			file_put_contents($reloadCacheResultFile, $e->getMessage());
 		}
 	}
 
-	public function doGeneratePowiazania($ID) {
-		$powiazaniaDirLocation = $this->getMainDirectory();
+	public static function doGeneratePowiazania($ID) {
+		$powiazaniaDirLocation = self::getMainDirectory();
 		$tasksDirLocation = $powiazaniaDirLocation . "/.tasks";
 		$resultFile = "{$tasksDirLocation}/generatePowiazania-{$ID}.result";
 		$xmlFile = "{$tasksDirLocation}/generatePowiazania-{$ID}.xml";
@@ -1804,6 +1804,9 @@ SQL;
 		];
 
 		try {
+			BiAuditPowiazania::saveToLog("Uruchamiam częściowe odświeżenie cache");
+			self::doReloadCache();
+			BiAuditPowiazania::saveToLog("Odświeżono częściowo cache");
 			$BiAuditPowiazania = new BiAuditPowiazania($ID, $tasksDirLocation);
 			if (!$BiAuditPowiazania->powiazaniaFound()) throw new Exception("Nie znaleziono żadnych powiązań");
 			//file_put_contents($xmlFile, $BiAuditPowiazania->asXml());
@@ -1973,12 +1976,12 @@ class BiAuditPowiazania {
 		return $this->refTables[$tableFrom][$tableTo];
 	}
 
-	private function generateJson($type, $data) {
+	private static function generateJson($type, $data) {
 		return json_encode(['ts' => microtime(true), 'type' => $type, 'data' => $data]);
 	}
 
-	private function saveToLog($message) {
-		$messageJson = $this->generateJson('message', ['message' => $message]);
+	private static function saveToLog($message) {
+		$messageJson = self::generateJson('message', ['message' => $message]);
 		echo $messageJson . "\n";
 	}
 
@@ -1987,24 +1990,24 @@ class BiAuditPowiazania {
 		$timestamp = microtime(true);
 		if ($progress) $estimated = ($timestamp - $this->startTimestamp) / $progress;
 		else $estimated = "N/A";
-		$progressJson = $this->generateJson('progress', ['progress' => $progress, 'item' => ($this->i + 1) . "/" . $this->count, 'results' => count($this->results), 'step' => $this->step, 'estimated' => $estimated]);
+		$progressJson = self::generateJson('progress', ['progress' => $progress, 'item' => ($this->i + 1) . "/" . $this->count, 'results' => count($this->results), 'step' => $this->step, 'estimated' => $estimated]);
 		echo $progressJson . "\n";
 		file_put_contents($this->progressFile, $progressJson);
 	}
 
-	private function throwException($message) {
-		$this->saveToLog($message);
+	private static function throwException($message) {
+		self::saveToLog($message);
 		throw new Exception($message);
 	}
 
 	public function __construct($ID = 0, $tasksDirLocation = null) {
-		if (!$ID) $this->throwException("Wrong ID parameter");
-		if (!$tasksDirLocation) $this->throwException("Wrong directory of tasks location");
+		if (!$ID) self::throwException("Wrong ID parameter");
+		if (!$tasksDirLocation) self::throwException("Wrong directory of tasks location");
 		$this->tasksDirLocation = $tasksDirLocation;
 
 		$query = "select BI_analiza_minDepth, BI_analiza_maxDepth, BI_analiza_onlyTargets from BI_audit_ENERGA_RUM_KONTRAHENCI_POWIAZANIA where ID = '{$ID}' and FILE_STATUS = 'IN_PROGRESS' and BI_analiza_reloadCache not in ('Full', 'Part')";
 		$result = DB::getPDO()->fetchAll($query);
-		if (!$result) $this->throwException("Błąd danych");
+		if (!$result) self::throwException("Błąd danych");
 
 		$this->ID = $ID;
 		if ($this->loadResults()) {
@@ -2012,13 +2015,13 @@ class BiAuditPowiazania {
 			return;
 		}
 
-		$this->saveToLog("Wczytuję parametry wyszukiwania powiązań");
+		self::saveToLog("Wczytuję parametry wyszukiwania powiązań");
 		$this->minDepth = (int) $result[0]['BI_analiza_minDepth'];
 		$this->maxDepth = (int) $result[0]['BI_analiza_maxDepth'];
 		$this->onlyTargets = ($result[0]['BI_analiza_onlyTargets'] != 'N');
 		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");
+		if (!$this->maxDepth) self::throwException("Błąd danych - nieokreślono maksymalnej głębokości analizy");
+		if ($this->minDepth > $this->maxDepth) self::throwException("Wartość minimalnej głębokości analizy jest większa od wartości maksymalnej głębokości analizy");
 
 		$subQueries = [];
 		foreach ($this->destTables as $destTable) {
@@ -2027,10 +2030,10 @@ class BiAuditPowiazania {
 		}
 		$query = implode(" union ", $subQueries);
 		$result = DB::getPDO()->fetchAll($query);
-		if (!$result) $this->throwException("Błąd danych - nie zdefinowano żadnego końcowego obiektu");
+		if (!$result) self::throwException("Błąd danych - nie zdefinowano żadnego końcowego obiektu");
 		$this->endNodes = array_map('reset', $result);
 
-		$this->saveToLog("Rozpoczynam wyszukiwanie powiązań");
+		self::saveToLog("Rozpoczynam wyszukiwanie powiązań");
 
 		$this->progressFile = "{$this->tasksDirLocation}/generatePowiazania-{$ID}.progress";
 		$refPowiazaniaToPracownicy = $this->getRefTable('BI_audit_ENERGA_RUM_KONTRAHENCI_POWIAZANIA', 'BI_audit_ENERGA_PRACOWNICY');
@@ -2043,13 +2046,13 @@ class BiAuditPowiazania {
 		foreach ($result as $this->i => $row) {
 			if ($this->maxDepth != $this->origMaxDepth) {
 				$this->maxDepth = $this->origMaxDepth;
-				$this->saveToLog("Przywrócono oryginalną maksymalną głębokość przeszukiwania ({$this->origMaxDepth})");
+				self::saveToLog("Przywrócono oryginalną maksymalną głębokość przeszukiwania ({$this->origMaxDepth})");
 			}
 			$this->findPowiazania($row['ID']);
 			$this->saveProgress(1);
 		}
 		$this->nodes = [];
-		$this->saveToLog("Zakończono wyszukiwanie powiązań");
+		self::saveToLog("Zakończono wyszukiwanie powiązań");
 		$this->saveResults();
 		$this->saveToDb();
 		$this->splitResults();
@@ -2063,18 +2066,18 @@ class BiAuditPowiazania {
 
 		if (((++$this->step) % 1000000) == 0) {
 			$progressDiff = $progress - $this->lastProgress;
-//			$this->saveToLog("TEST: " . (number_format($progress - $this->lastProgress, 20)));
+//			self::saveToLog("TEST: " . (number_format($progress - $this->lastProgress, 20)));
 			if ($progressDiff < 0.00005) {
 				$this->lowProgressCount++;
 				if ($this->lowProgressCount == 10) {
 					$this->maxDepth--;
-					$this->saveToLog("Zbyt dużo rekurencji, zmniejszono maksymalną głębokość poszukiwań do {$this->maxDepth} dla bieżącego pracownika");
+					self::saveToLog("Zbyt dużo rekurencji, zmniejszono maksymalną głębokość poszukiwań do {$this->maxDepth} dla bieżącego pracownika");
 				}
 			} else $this->lowProgressCount = 0;
 			$this->saveProgress($progress);
 			if (memory_get_usage(true) > 4000000000) {
 				$this->nodes = [];
-				$this->saveToLog("Too much memory used, cleaning relations cache");
+				self::saveToLog("Too much memory used, cleaning relations cache");
 			}
 		}
 
@@ -2111,33 +2114,33 @@ class BiAuditPowiazania {
 	}
 
 	private function saveResults() {
-		$this->saveToLog("Zapisuję wyliczone dane do pliku");
+		self::saveToLog("Zapisuję wyliczone dane do pliku");
 		if (!$this->results) {
-			$this->saveToLog("Brak wyliczonych danych - niczego nie zapisaono");
+			self::saveToLog("Brak wyliczonych danych - niczego nie zapisaono");
 			return false;
 		}
 		$dataFile = "{$this->tasksDirLocation}/generatePowiazania-{$this->ID}.data";
 		$data = base64_encode(gzcompress(json_encode($this->results)));
 		file_put_contents($dataFile, $data);
-		$this->saveToLog("Zapisano wyliczone dane do pliku");
+		self::saveToLog("Zapisano wyliczone dane do pliku");
 		return true;
 	}
 
 	private function loadResults() {
-		$this->saveToLog("Próbuję wczytać wcześniej wyliczone dane");
+		self::saveToLog("Próbuję wczytać wcześniej wyliczone dane");
 		$dataFile = "{$this->tasksDirLocation}/generatePowiazania-{$this->ID}.data";
 		if (!file_exists($dataFile)) {
-			$this->saveToLog("Nie znaleziono pliku z wyliczonymi danymi");
+			self::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");
+			self::saveToLog("Wystąpił błąd wczytywania wcześniej wyliczonych danych");
 			return false;
 		}
 		$this->results = $results;
-		$this->saveToLog("Wczytano wcześniej wyliczone dane");
+		self::saveToLog("Wczytano wcześniej wyliczone dane");
 
 		return true;
 	}
@@ -2189,7 +2192,7 @@ class BiAuditPowiazania {
 	}
 
 	private function generateItemsResults($resultsPart = null) {
-		$this->saveToLog("Generuję dane na potrzeby utworzenia pliku XML ({$resultsPart})");
+		self::saveToLog("Generuję dane na potrzeby utworzenia pliku XML ({$resultsPart})");
 		$xmlRoot2 = "BI_audit_ENERGA_RUM_KONTRAHENCI_POWIAZANIA";
 		$xmlElements = "BI_audit_ENERGA_RUM_KONTRAHENCI_POWIAZANIA_row";
 
@@ -2256,13 +2259,13 @@ class BiAuditPowiazania {
 		}
 		$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})");
+		self::saveToLog("Wygenerowano dane na potrzeby utworzenia pliku XML ({$resultsPart})");
 	}
 
 	private function saveToDb() {
-		$this->saveToLog("Zapisuję wyliczone dane do bazy");
+		self::saveToLog("Zapisuję wyliczone dane do bazy");
 		if (!$this->results) {
-			$this->saveToLog("Brak wyliczonych danych - nie zapisaono niczego do bazy");
+			self::saveToLog("Brak wyliczonych danych - nie zapisaono niczego do bazy");
 			return null;
 		}
 		$refPowiazaniaToPowiazaniaRow = $this->getRefTable('BI_audit_ENERGA_RUM_KONTRAHENCI_POWIAZANIA', 'BI_audit_ENERGA_RUM_KONTRAHENCI_POWIAZANIA_row');
@@ -2279,18 +2282,18 @@ class BiAuditPowiazania {
 				DB::getPDO()->insert($ref, ['PRIMARY_KEY' => $idPowiazaniaRowObject, 'REMOTE_PRIMARY_KEY' => $object['REMOTE_ID']]);
 			}
 		}
-		$this->saveToLog("Zapisano wyliczone dane do bazy");
+		self::saveToLog("Zapisano wyliczone dane do bazy");
 	}
 
 	public function saveXml() {
 		if ($this->getPartsCount()) {
-			$this->saveToLog("Generuję pliki XML (liczba plików do wygenerowania: {$this->getPartsCount()})");
+			self::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");
+			self::saveToLog("Zakończono generowanie plików XML");
 		} else {
 			$xmlFile = "{$this->tasksDirLocation}/generatePowiazania-{$this->ID}.xml";
 			file_put_contents($xmlFile, $this->asXml());
@@ -2299,19 +2302,19 @@ class BiAuditPowiazania {
 	}
 
 	public function asXml($resultsPart = null) {
-		$this->saveToLog("Generuję plik XML ({$resultsPart})");
+		self::saveToLog("Generuję plik XML ({$resultsPart})");
 		if (!$this->results) {
-			$this->saveToLog("Brak wyników (#1), nie wygenerowano pliku XML ({$resultsPart})");
+			self::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})");
+			self::saveToLog("Brak wyników (#2), nie wygenerowano pliku XML ({$resultsPart})");
 			return null;
 		}
 		$xmlRoot = "RelatedFeatureRoot";
 		$return = V::arrayToXML($this->items_results[$resultsPart], true, $xmlRoot);
-		$this->saveToLog("Wygenerowano plik XML ({$resultsPart})");
+		self::saveToLog("Wygenerowano plik XML ({$resultsPart})");
 		return $return;
 	}
 
@@ -2332,15 +2335,15 @@ class BiAuditPowiazania {
 
 	public function generatePdfAndHtml() {
 		if ($this->getPartsCount()) {
-			$this->saveToLog("Generuję raporty w plikach PDF oraz HTML (liczba raportów do wygenerowania: {$this->getPartsCount()})");
+			self::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");
+			self::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})");
+		self::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";
@@ -2353,24 +2356,24 @@ class BiAuditPowiazania {
 		if (!file_exists($antDir)) mkdir($antDir, 0755, true);
 		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})");
+			self::saveToLog("Nie wygenerowano plików PDF oraz HTML - problem z utworzeniem katalogu dla ant ({$resultsPart})");
 		} else {
 			copy($xmlFile, $antXmlFile);
 			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})");
+			self::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("Wygenerowano plik PDF ({$resultsPart})");
-			} else $this->saveToLog("Nie udało się wygenerować pliku PDF ({$resultsPart})");
-			$this->saveToLog("Generuję pliki HTML ({$resultsPart})");
+				self::saveToLog("Wygenerowano plik PDF ({$resultsPart})");
+			} else $self::saveToLog("Nie udało się wygenerować pliku PDF ({$resultsPart})");
+			self::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-{$id_part}\" && zip -r \"{$htmlZipDestFile}\" html");
 				if (file_exists($htmlDestDir)) shell_exec("rm -rf \"{$htmlDestDir}\"");
 				shell_exec("mv \"{$htmlDir}\" \"{$htmlDestDir}\"");
-				$this->saveToLog("Wygenerowano pliki HTML ({$resultsPart})");
-			} else $this->saveToLog("Nie udało się wygenerować plików HTML {$resultsPart})");
+				self::saveToLog("Wygenerowano pliki HTML ({$resultsPart})");
+			} else self::saveToLog("Nie udało się wygenerować plików HTML {$resultsPart})");
 		}
 	}
 }