a.binder %!s(int64=8) %!d(string=hai) anos
pai
achega
29f0095382

+ 4 - 2
SE/schema/WPS_Functions/BI_audit/1_import_kw_person_and_optimize_db.php

@@ -1,7 +1,9 @@
 #!/usr/bin/env php
 <?php
-$_SERVER['SERVER_NAME'] = "biuro.biall-net.pl";
-require("/Library/Server/Web/Data/Sites/SE-production-git/SE/se-lib/bootstrap.php");
+//$_SERVER['SERVER_NAME'] = "biuro.biall-net.pl";
+//require("/Library/Server/Web/Data/Sites/SE-production-git/SE/se-lib/bootstrap.php");
+require("config_inc.php");
+
 date_default_timezone_set('Europe/Warsaw');// PHP 5 >= 5.1.0 required by date functions
 
 

+ 4 - 2
SE/schema/WPS_Functions/BI_audit/1_rum_create_ref.php

@@ -1,7 +1,9 @@
 #!/usr/bin/env php
 <?php
-$_SERVER['SERVER_NAME'] = "biuro.biall-net.pl";
-require("/Library/Server/Web/Data/Sites/Default/dev-bzyk/se-lib/bootstrap.php");
+//$_SERVER['SERVER_NAME'] = "biuro.biall-net.pl";
+//require("/Library/Server/Web/Data/Sites/Default/dev-bzyk/se-lib/bootstrap.php");
+require("config_inc.php");
+
 #require("/Library/Server/Web/Data/Sites/SE-producition-git/SE/se-lib/bootstrap.php");
 date_default_timezone_set('Europe/Warsaw');// PHP 5 >= 5.1.0 required by date functions
 

+ 4 - 2
SE/schema/WPS_Functions/BI_audit/2_verify_kontrahenci.php

@@ -1,7 +1,9 @@
 #!/usr/bin/env php
 <?php
-$_SERVER['SERVER_NAME'] = "biuro.biall-net.pl";
-require("/Library/Server/Web/Data/Sites/Default/dev-bzyk/se-lib/bootstrap.php");
+//$_SERVER['SERVER_NAME'] = "biuro.biall-net.pl";
+//require("/Library/Server/Web/Data/Sites/Default/dev-bzyk/se-lib/bootstrap.php");
+require("config_inc.php"); //generated by build_BI_audit.xml
+
 #require("/Library/Server/Web/Data/Sites/SE-producition-git/SE/se-lib/bootstrap.php");
 date_default_timezone_set('Europe/Warsaw');// PHP 5 >= 5.1.0 required by date functions
 

+ 4 - 2
SE/schema/WPS_Functions/BI_audit/3_create_all.php

@@ -1,7 +1,9 @@
 #!/usr/bin/env php
 <?php
-$_SERVER['SERVER_NAME'] = "biuro.biall-net.pl";
-require("/Library/Server/Web/Data/Sites/Default/dev-bzyk/se-lib/bootstrap.php");
+//$_SERVER['SERVER_NAME'] = "biuro.biall-net.pl";
+//require("/Library/Server/Web/Data/Sites/Default/dev-bzyk/se-lib/bootstrap.php");
+require("config_inc.php"); //generated by build_BI_audit.xml
+
 #require("/Library/Server/Web/Data/Sites/SE-producition-git/SE/se-lib/bootstrap.php");
 date_default_timezone_set('Europe/Warsaw');// PHP 5 >= 5.1.0 required by date functions
 

+ 4 - 2
SE/schema/WPS_Functions/BI_audit/4_find_corelations.php

@@ -1,7 +1,9 @@
 #!/usr/bin/env php
 <?php
-$_SERVER['SERVER_NAME'] = "biuro.biall-net.pl";
-require("/Library/Server/Web/Data/Sites/Default/dev-bzyk/se-lib/bootstrap.php");
+//$_SERVER['SERVER_NAME'] = "biuro.biall-net.pl";
+//require("/Library/Server/Web/Data/Sites/Default/dev-bzyk/se-lib/bootstrap.php");
+require("config_inc.php");
+
 #require("/Library/Server/Web/Data/Sites/SE-producition-git/SE/se-lib/bootstrap.php");
 date_default_timezone_set('Europe/Warsaw');// PHP 5 >= 5.1.0 required by date functions
 

+ 4 - 2
SE/schema/WPS_Functions/BI_audit/5_analyse.php

@@ -1,7 +1,9 @@
 #!/usr/bin/env php
 <?php
-$_SERVER['SERVER_NAME'] = "biuro.biall-net.pl";
-require("/Library/Server/Web/Data/Sites/Default/dev-bzyk/se-lib/bootstrap.php");
+//$_SERVER['SERVER_NAME'] = "biuro.biall-net.pl";
+//require("/Library/Server/Web/Data/Sites/Default/dev-bzyk/se-lib/bootstrap.php");
+require("config_inc.php"); //generated by build_BI_audit.xml
+
 #require("/Library/Server/Web/Data/Sites/SE-producition-git/SE/se-lib/bootstrap.php");
 date_default_timezone_set('Europe/Warsaw');// PHP 5 >= 5.1.0 required by date functions
 Lib::loadClass('V');

+ 4 - 2
SE/schema/WPS_Functions/BI_audit/5_generate_xml.php

@@ -1,7 +1,9 @@
 #!/usr/bin/env php
 <?php
-$_SERVER['SERVER_NAME'] = "biuro.biall-net.pl";
-require("/Library/Server/Web/Data/Sites/Default/dev-bzyk/se-lib/bootstrap.php");
+//$_SERVER['SERVER_NAME'] = "biuro.biall-net.pl";
+//require("/Library/Server/Web/Data/Sites/Default/dev-bzyk/se-lib/bootstrap.php");
+require("config_inc.php"); //generated by build_BI_audit.xml
+
 #require("/Library/Server/Web/Data/Sites/SE-producition-git/SE/se-lib/bootstrap.php");
 date_default_timezone_set('Europe/Warsaw');// PHP 5 >= 5.1.0 required by date functions
 Lib::loadClass('V');

+ 82 - 0
SE/schema/WPS_Functions/BI_audit/5_generate_xml.php.ok

@@ -0,0 +1,82 @@
+#!/usr/bin/env php
+<?php
+$_SERVER['SERVER_NAME'] = "biuro.biall-net.pl";
+require("/Library/Server/Web/Data/Sites/Default/dev-bzyk/se-lib/bootstrap.php");
+#require("/Library/Server/Web/Data/Sites/SE-producition-git/SE/se-lib/bootstrap.php");
+date_default_timezone_set('Europe/Warsaw');// PHP 5 >= 5.1.0 required by date functions
+Lib::loadClass('V');
+
+if (!isset($argv[1])) die("Missing parameter\n");
+if ($argv[1] == "-") $data = stream_get_contents(STDIN);
+else {
+	if (!is_file($argv[1])) die("File {$argv[1]} not found\n");
+	$data = @file_get_contents($argv[1]);
+	if (!$data) die("Error loading file\n");
+}
+//preg_match('/.*\.([[:alpha:]]*)$/', $argv[1], $match);
+//switch ($match[1]) {
+//	case "data":
+		$results = @json_decode(gzuncompress(base64_decode($data)), true);
+//		break;
+//	case "txt":
+//		$results = unserialize($data);
+//		break;
+//	default:
+//		die("Unknown file type\n");
+//}
+
+
+if (!$results) die("Error loading data\n");
+$TABLE = "BI_audit_ALL";
+
+//$query = "select `DATA` from BI_audit_ALL_results where ID=4";
+//$data = DB::getPDO()->fetchvalue($query);
+//$results = json_decode(gzuncompress(base64_decode($data)), true);
+
+$xmlRoot = "RelatedFeatureRoot";
+$xmlRoot2 = "BI_audit_ENERGA_RUM_KONTRAHENCI_POWIAZANIA";
+$xmlElements = "BI_audit_ENERGA_RUM_KONTRAHENCI_POWIAZANIA_row";
+
+$items_results = [];
+foreach ($results as $result) {
+	$item_results = [];
+	foreach ($result as $ID => $rel) {
+		$query = "select REMOTE_TABLE, REMOTE_ID from {$TABLE} where ID = '{$ID}'";
+		$row = DB::getPDO()->fetchFirst($query);
+		$query = "select * from `{$row['REMOTE_TABLE']}` where ID = '{$row['REMOTE_ID']}'";
+		$obj = DB::fetch(DB::query($query));
+		$item_result = [$row['REMOTE_TABLE'] => (array) $obj];
+		if ($rel) $item_result['relation_from'] = $rel;
+		$item_results['object'][] = $item_result;
+		if ($row['REMOTE_TABLE'] == "BI_audit_ENERGA_RUM_KONTRAHENCI") {
+			$query = "select umowy.* from BI_audit_ENERGA_RUM_UMOWY umowy join `CRM__#REF_TABLE__23` ref on umowy.ID = ref.PRIMARY_KEY where ref.REMOTE_PRIMARY_KEY = '{$row['REMOTE_ID']}'";
+			$res = DB::query($query);
+			$umowy = [];
+			$i = 0;
+			while ($obj = DB::fetch($res)) {
+				if (++$i > 50) {
+					//$umowy[] = "Przekroczono limit 50 rekordów (pominięto " . (mysql_num_rows($res) - 50) . " z " . mysql_num_rows($res) . ")";
+					break;
+				}
+				$umowy[] = (array) $obj;
+			}
+			if ($umowy) {
+				$item_results['deal'] = $umowy;
+			}
+		} elseif ($row['REMOTE_TABLE'] == "BI_audit_KW_requested_person") {
+			$query = "select kw.* from BI_audit_KW_requested kw join `CRM__#REF_TABLE__24` ref on kw.ID = ref.PRIMARY_KEY where ref.REMOTE_PRIMARY_KEY = '{$row['REMOTE_ID']}'";
+			$res = DB::query($query);
+			$kw = [];
+			while ($obj = DB::fetch($res)) {
+				$kw[] = (array) $obj;
+			}
+			if ($kw) {
+				$item_results['kw'] = $kw;
+			}
+		}
+	}
+	$items_results[$xmlRoot2][$xmlElements][] = $item_results;
+}
+//print_r($items_results);
+$test = V::arrayToXML($items_results, true, $xmlRoot);
+echo $test;

+ 1 - 1
SE/schema/WPS_Functions/BI_audit/build_BI_audit.xml

@@ -54,7 +54,7 @@
         <echo file="${BI_audit:config_inc.php}">
 #!/usr/bin/env php
 <![CDATA[<?php]]>
-$_SERVER['SERVER_NAME'] = "${SERVER_NAME}";
+$_SERVER['SERVER_NAME'] = "${SERVER_ADDRESS}";
 require("${bootstrap.php}");
 <![CDATA[?>]]>
         </echo>