Bläddra i källkod

Merge branch 'master' of bn.git:plabudda/se

Piotr Labudda 8 år sedan
förälder
incheckning
e3e9a24e8a

+ 1 - 1
SE/projects/bocian

@@ -1 +1 @@
-Subproject commit 2471c059a8bda4378d6026a9aa0215910876eb4e
+Subproject commit d5d6fc961a2240763be3d46e12b7a05467233614

+ 1 - 0
SE/schema/WPS_Functions/default_db/CRM_PROCES_tree/build_CRM_PROCES_tree.xml

@@ -8,6 +8,7 @@
     <include file="build.CRM_PROCES_tree.PRODUCT.xml"/>
     <include file="../recurse_ant/build.recurse_ant.PRODUCT.xml"/>
     <include file="../../mapserver_gml_to_png/build.mapserver_gml_to_png.PRODUCT.xml"/>
+    <include file="../../graph_gnuplot/build.graph_gnuplot.PRODUCT.xml"/>
     <!--<include file="../../build.WPS_Functions.PRODUCT.xml"/>-->
     <!-- modules WPS_Functions - to be copied to any module needed -->
     <!--<property name="WPS_Functions" value="${basedir}/WPS_Functions"/>-->

+ 26 - 0
SE/schema/WPS_Functions/graph_gnuplot/build.graph_gnuplot.PRODUCT.xml

@@ -0,0 +1,26 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<project xmlns:graph_gnuplot="http://biuro.biall-net.pl/xmlschema_procesy5/WPS_Functions/graph_gnuplot/graph_gnuplot.xsd"
+         xmlns:p5xsl="http://biuro.biall-net.pl/xmlschema_procesy5/WPS_Functions/xsl_interface/xsl_interface.xsd"
+         basedir="../../."
+         name="graph_gnuplot.PRODUCT">
+   
+   <include as="WPS_Functions" file="../build.WPS_Functions.PRODUCT.xml"/>
+   
+   <property name="graph_gnuplot.PRODUCT.name"
+             value="${WPS_Functions.PRODUCT.name}.graph_gnuplot"/>
+   <property name="graph_gnuplot.PRODUCT.vendor-domain"
+             value="${WPS_Functions.PRODUCT.name}.graph_gnuplot"/>
+   <property name="graph_gnuplot.basedir"
+             value="${WPS_Functions.basedir}/graph_gnuplot"/>
+   <property name="graph_gnuplot.repository"
+             value="${WPS_Functions.repository}/graph_gnuplot"/>
+   
+   
+   <property name="graph_gnuplot.build.xml" location="${basedir}/WPS_Functions/graph_gnuplot/build_graph_gnuplot.xml"/>
+   
+   
+   <property name="graph_gnuplot" location="${graph_gnuplot.build.xml}"/>
+   
+ 
+   
+</project>

+ 3 - 3
SE/schema/WPS_Functions/graph_gnuplot/build_graph_gnuplot.xml

@@ -2,8 +2,8 @@
 <project basedir="../../." name="graph_gnuplot" default="graph_to_image">
   <description>to use from to dita conversion from xsl/ant to generate png graphs</description>
     
-    
-    <include file="../build.WPS_Functions.PRODUCT.xml"/>
+    <include file="build.graph_gnuplot.PRODUCT.xml"/>
+    <!--<include file="../build.WPS_Functions.PRODUCT.xml"/>-->
     <!-- modules WPS_Functions - to be copied to any module needed -->
     <property name="WPS_Functions" location="${WPS_Functions.basedir}"/>
     <property name="build_WPS_Functions.xml" location="${WPS_Functions.build}"/> <!-- call it to get properties -->
@@ -12,7 +12,7 @@
     
     
     <!-- local shared module individual properties should contain ${project.name} basedir ant its .temp -->
-    <property name="graph_gnuplot" location="${basedir}/WPS_Functions/graph_gnuplot/build_graph_gnuplot.xml"/>
+    <!--<property name="graph_gnuplot" location="${basedir}/WPS_Functions/graph_gnuplot/build_graph_gnuplot.xml"/>-->
     <property name="build_graph_gnuplot.childproperties" location="${WPS_Functions.childproperties}/build_graph_gnuplot.properties"/>
     <property name="graph_gnuplot_basedir" location="${basedir}/WPS_Functions/graph_gnuplot"  />                         
     <property name="graph_gnuplot_basedir.temp" location="${graph_gnuplot_basedir}/temp"  />

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

@@ -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})");