Преглед на файлове

updated pdo and ProjektyKosztyWstepnychRobot

Piotr Labudda преди 10 години
родител
ревизия
0a6e58c2f1
променени са 4 файла, в които са добавени 358 реда и са изтрити 49 реда
  1. 67 0
      SE/se-lib/Core/Pdo.php
  2. 38 8
      SE/se-lib/DB.php
  3. 2 28
      SE/se-lib/Route/UrlAction.php
  4. 251 13
      SE/se-lib/Route/UrlAction/ProjektyKosztyWstepnychRobot.php

+ 67 - 0
SE/se-lib/Core/Pdo.php

@@ -2,11 +2,78 @@
 
 class Core_Pdo extends PDO {
 
+	protected $_database_name;
+	protected $_zasob_id;
+
 	// public PDO::__construct ( string $dsn [, string $username [, string $password [, array $options ]]] )
 	public function __construct($dsn, $username, $password, $options = array()) {
+		$this->_database_name = $options['database'];
+		$this->_zasob_id = $options['zasob_id'];
+		unset($options['database']);
+		unset($options['zasob_id']);
 		parent::__construct($dsn, $username, $password, $options);
 		$this->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
 		$this->setAttribute(PDO::ATTR_DEFAULT_FETCH_MODE, PDO::FETCH_ASSOC);
 	}
 
+	public function getDatabaseName() {
+		return $this->_database_name;
+	}
+
+	public function getZasobId() {
+		return $this->_zasob_id;
+	}
+
+	public function fetchAll($sql) {
+		$sth = $this->prepare($sql);
+		$sth->execute();
+		return $sth->fetchAll();
+	}
+
+	public function bindValues($sth, $values) {
+		foreach ($values as $name => $value) {
+			$val = $value;
+			$type = PDO::PARAM_STR;
+			if (is_array($value)) {
+				$val = $value[0];
+				if (count($value) > 1) {
+					$type = $value[1];
+				}
+			}
+			$sth->bindValue($name, $val, $type);
+			if (!isset($sth->bindedValues)) $sth->bindedValues = array();
+			$sth->bindedValues[$name] = array($val, $type);
+		}
+	}
+
+	public function getRawSql($sth, $values = array()) {
+		$sql = $sth->queryString;
+		$params = array();
+		if (!empty($sth->bindedValues)) {
+			foreach ($sth->bindedValues as $name => $value) {
+				$params[$name] = array($value[0], $value[1]);
+			}
+		}
+		foreach ($values as $name => $value) {
+			$val = $value;
+			$type = PDO::PARAM_STR;
+			if (is_array($value)) {
+				$val = $value[0];
+				if (count($value) > 1) {
+					$type = $value[1];
+				}
+			}
+			$params[$name] = array($val, $type);
+		}
+
+		if (!empty($params)) {
+			foreach ($params as $name => $val) {
+				$outValue = $val[0];
+				if (PDO::PARAM_STR == $val[1]) $outValue = "'{$outValue}'";
+				$sql = str_replace(":{$name}", $outValue, $sql);
+			}
+		}
+		return $sql;
+	}
+
 }

+ 38 - 8
SE/se-lib/DB.php

@@ -1,5 +1,31 @@
 <?php
 
+/*
+# Usage:
+
+## Usage - example 1:
+try {
+	$pdo = DB::getPDO();
+	$pdo->getDatabaseName();
+	$pdo->getZasobId();
+
+	$sth = $pdo->prepare("select * from CRM_LISTA_ZASOBOW limit 10");
+	$sth->execute();
+	$rows = $sth->fetchAll();
+} catch (Exception $e) {
+	echo "Error #" . $e->getCode() .  "|" . $e->getLine() .  ": " . $e->getMessage();
+}
+
+## Usage - example 2:
+try {
+	$pdo = DB::getPDO();
+	$rows = $pdo->fetchAll("select * from CRM_LISTA_ZASOBOW limit 10");
+} catch (Exception $e) {
+	echo "Error #" . $e->getCode() .  "|" . $e->getLine() .  ": " . $e->getMessage();
+}
+
+*/
+
 Lib::loadClass('Config');
 Lib::loadClass('DataSourceException');
 Lib::loadClass('Core_Pdo');
@@ -144,21 +170,25 @@ class DB {
 			$port = V::get('port', '', $conf);
 			$user = V::get('user', '', $conf);
 			$pass = V::get('pass', '', $conf);
+			$database = V::get('database', '', $conf);
 			$zasob_id = V::get('zasob_id', '', $conf);
+			if (empty($host)) throw new Exception("Brak zdefiniowanego pola 'host' dla bazy danych '{$dbConfName}'");
+			if (empty($user)) throw new Exception("Brak zdefiniowanego loginu usera dla bazy danych '{$dbConfName}'");
+			if (empty($pass)) throw new Exception("Brak zdefiniowanego hasła usera dla bazy danych '{$dbConfName}'");
+			if (empty($database)) throw new Exception("Brak zdefiniowane nazwy bazy danych dla '{$dbConfName}'");
+			if (empty($zasob_id)) throw new Exception("Brak zdefiniowanego id zasobu dla bazy danych '{$dbConfName}'");
 
-			$database = V::get('database', '', $conf);
+			$options = array();
 			if ($port && $host) $host .= ";port={$port}";
 			$names = 'utf8';
-			if(0){// TODO: mssql tdsver
-				$tdsver = V::get('tdsver', '', $conf);
-				if (!empty($tdsver)) {
-					$params['tdsver'] = $tdsver;
-				}
-			}
+			$tdsver = V::get('tdsver', '', $conf);
+			if (!empty($tdsver)) $options['tdsver'] = $tdsver;
+			$options['zasob_id'] = $zasob_id;
+			if (!empty($database)) $options['database'] = $database;
 			//$pdo = new PDO($type . ':host=' . $host . ';dbname=' . $database, $user, $pass);
 			//$pdo->exec("SET NAMES 'utf8'");
 			//$sdb = new Core_Pdo($pdo);
-			$sdb = new Core_Pdo($type . ':host=' . $host . ';dbname=' . $database, $user, $pass);
+			$sdb = new Core_Pdo($type . ':host=' . $host . ';dbname=' . $database, $user, $pass, $options);
 			$sdb->exec("SET NAMES 'utf8'");
 			$_instance[$dbConfName] = $sdb;
 		}

+ 2 - 28
SE/se-lib/Route/UrlAction.php

@@ -7,7 +7,7 @@ Lib::loadClass('RouteBase');
 
 - new Zasob type: 'URL_ACTION'
 
-## Config in Zasoby tree (TODO: upload from gui xml file):
+## Config in Zasoby tree (TODO: upload from gui xml file or php):
 [100] - TYPESPECIALS
 [110]   - URL_ACTION ProjektyKosztyWstepnychRobot
 [111] 	  - PARAM_IN ID_PROJECT
@@ -53,7 +53,6 @@ class Route_UrlAction extends RouteBase {// TODO: UrlActionBase
 
 	public function getArgsList() {
 		$args = array();
-		$args[] = 'ID_PROJECT';
 		return $args;
 	}
 
@@ -70,24 +69,9 @@ class Route_UrlAction extends RouteBase {// TODO: UrlActionBase
 		echo json_encode($jsonData);
 	}
 
-	public function runAction() {
-		$jsonData = new stdClass();
-		$jsonData->type = 'success';
-		$jsonData->msg = 'Gotowe';
-		try {
-			$idAction = V::get('_idAction', 0, $_REQUEST, 'int');
-			if ($idAction > 0) {
-				$this->runActionById($idAction);
-			}
-		} catch (Exception $e) {
-			$jsonData->type = 'danger';
-			$jsonData->msg = $e->getMessage();
-		}
-		echo json_encode($jsonData);
-	}
-
 	public function reinstall() {
 		$sqlList = array();
+		// alter table enum add URL_ACTION
 		//$sqlList['RemoveTable'] = "DROP TABLE IF EXISTS `CRM_UI_MSGS`";
 		$pdo = DB::getPDO();
 		foreach ($sqlList as $sqlName => $sql) {
@@ -95,14 +79,4 @@ class Route_UrlAction extends RouteBase {// TODO: UrlActionBase
 		}
 	}
 
-	public function runActionById($id) {
-		$msgRow = $this->getActiveMessage($id);
-		$execNotes = '';
-		if (!empty($msgRow->app_className)) {
-			$route = Router::getRoute($msgRow->app_className);
-			$route->runByMessageFromMsgsSystem($msgRow->msg, $execNotes);
-		}
-		$this->forceFinishMessage($id, $execNotes);
-	}
-
 }

+ 251 - 13
SE/se-lib/Route/UrlAction/ProjektyKosztyWstepnychRobot.php

@@ -23,12 +23,231 @@ class Route_UrlAction_ProjektyKosztyWstepnychRobot extends RouteBase {// TODO: U
 		SE_Layout::dol();
 	}
 
-	public function getArgsList() {
+	public function getArgsList() {// TODO: override UrlActionBase::getArgsList action
 		$args = array();
 		$args[] = 'ID_PROJECT';
 		return $args;
 	}
 
+	public function reinstallAction() {// TODO: mv to UrlActionBase
+		$jsonData = new stdClass();
+		$jsonData->type = 'success';
+		$jsonData->msg = 'Gotowe';
+		try {
+			$this->reinstall();
+		} catch (Exception $e) {
+			$jsonData->type = 'danger';
+			$jsonData->msg = $e->getMessage();
+		}
+		echo json_encode($jsonData);
+	}
+
+	public function reinstall() {// TODO: mv to UrlActionBase
+		/* required Zasoby tree structure:
+[25] TYPESPECIALS
+  [:action_id] URL_ACTION 'ProjektyKosztyWstepnychRobot'
+    [:param_id] PARAM_IN :arg_id_project
+[:main_db_id] (DATABASE_MYSQL, BAZA_DANYCH, DATABASE_POSTGRESQL)
+  [:tbl_id] TABELA 'IN7_MK_BAZA_DYSTRYBUCJI'
+    [:cell_id] KOMORKA 'ID'
+    [:link_action_id] (ALIAS DO :action_id) URL_ACTION 'ProjektyKosztyWstepnychRobot'
+      [:link_param_id] (ALIAS DO :cell_id) PARAM_IN :arg_id_project
+
+:arg_id_project = 'ID_PROJECT'
+		*/
+		$pdo = DB::getPDO();
+
+		$args = $this->getArgsList();
+		$clsName = __CLASS__;
+		$urlActionName = str_replace('Route_UrlAction_', '', $clsName);
+		DBG::_(true, true, "reinstall class", __CLASS__, __CLASS__, __FUNCTION__, __LINE__);
+		DBG::_(true, true, "reinstall funName", $urlActionName, __CLASS__, __FUNCTION__, __LINE__);
+
+		DBG::_(true, true, "reinstall test", $args, __CLASS__, __FUNCTION__, __LINE__);
+		$dbFunction = $this->fetchZasobInfo();
+		$usrLogin = User::getLogin();
+		{// check if URL_ACTION already exists
+			if (!$dbFunction) throw new Exception("Brak id zasobu typu TYPESPECIALS - TODO: CREATE");// $this->createZasobTypespecials();
+			DBG::_(true, true, "dbFunction", $dbFunction, __CLASS__, __FUNCTION__, __LINE__);
+			if ($dbFunction['action_id_is_null']) {
+				$sth = $pdo->prepare("
+					insert into CRM_LISTA_ZASOBOW (
+						TYPE,
+						PARENT_ID,
+						`DESC`,
+						A_RECORD_CREATE_AUTHOR,
+						A_RECORD_CREATE_DATE
+					)
+					values (
+						'URL_ACTION',
+						:ts_id,
+						:url_action_name,
+						'system-by-{$usrLogin}',
+						NOW()
+					)
+				");
+				//$sth->bindValue('ts_id', $dbFunction['ts_id'], PDO::PARAM_INT);
+				//$sth->bindValue('url_action_name', $urlActionName, PDO::PARAM_STR);
+				$bindValues = array();
+				$bindValues['ts_id'] = array($dbFunction['ts_id'], PDO::PARAM_INT);
+				$bindValues['url_action_name'] = $urlActionName;
+				$pdo->bindValues($sth, $bindValues);
+				DBG::_(true, true, "sql", $pdo->getRawSql($sth), __CLASS__, __FUNCTION__, __LINE__);
+				$sth->execute();
+				$dbFunction = $this->fetchZasobInfo();
+				if (!$dbFunction || $dbFunction['action_id_is_null']) throw new Exception("Brak zasobu typu URL_ACTION, nie udało się go utworzyć!");
+			}
+		}
+		{// check params
+			if (!empty($args)) {
+				$todoArgs = array();
+				foreach ($args as $argName) {
+					if (empty($dbFunction['url_params'])) {
+						$todoArgs[$argName] = true;
+					} else if (!array_key_exists($argName, $dbFunction['url_params'])) {
+						$todoArgs[$argName] = true;
+					}
+					// OK PARAM_IN exists
+				}
+				$todoArgs = array_keys($todoArgs);
+				DBG::_(true, true, "todoArgs", $todoArgs, __CLASS__, __FUNCTION__, __LINE__);
+				if (!empty($todoArgs)) {
+					$sqlValues = array();
+					foreach ($todoArgs as $argName) {
+						$sqlValues[] = "(
+								'PARAM_IN',
+								{$dbFunction['action_id']},
+								'{$argName}',
+								'system-by-{$usrLogin}',
+								NOW()
+							)
+						";
+					}
+					$sqlValues = implode(", ", $sqlValues);
+					$sth = $pdo->prepare("
+						insert into CRM_LISTA_ZASOBOW (
+							TYPE,
+							PARENT_ID,
+							`DESC`,
+							A_RECORD_CREATE_AUTHOR,
+							A_RECORD_CREATE_DATE
+						)
+						values {$sqlValues}
+					");
+					DBG::_(true, true, "sql", $pdo->getRawSql($sth), __CLASS__, __FUNCTION__, __LINE__);
+					$sth->execute();
+					$dbFunction = $this->fetchZasobInfo();
+				}
+				if (empty($dbFunction['url_params'])) {
+					throw new Exception("Brak zdefiniowanych parametrów, nie udało się ich utworzyć!");
+				}
+			}
+		}
+	}
+
+	public function fetchZasobInfo() {
+		$pdo = DB::getPDO();
+		$args = $this->getArgsList();
+		$clsName = __CLASS__;
+		$urlActionName = str_replace('Route_UrlAction_', '', $clsName);
+		$sth = $pdo->prepare("
+			select zp.ID as ts_id
+				, IF(z.ID is null, 1, 0) as action_id_is_null
+				, z.ID as action_id
+				, z.DESC as action_desc
+			from CRM_LISTA_ZASOBOW zp
+				left join CRM_LISTA_ZASOBOW z on(z.PARENT_ID = zp.ID
+						and z.TYPE = 'URL_ACTION'
+						and z.DESC = :url_action_name
+						and z.A_STATUS not in('DELETED')
+					)
+			where zp.TYPE = 'TYPESPECIALS'
+				and zp.A_STATUS not in('DELETED')
+		");
+		$sth->bindValue('url_action_name', $urlActionName);
+		$sth->execute();
+		$info = $sth->fetch();
+		if (!$info) return $info;
+		$info['url_params'] = array();
+		if ($info['action_id'] > 0) {
+			$sthParams = $pdo->prepare("
+				select z.ID as param_id
+					, z.DESC as param_desc
+				from CRM_LISTA_ZASOBOW z
+				where z.TYPE = 'PARAM_IN'
+					and z.A_STATUS not in('DELETED')
+					and z.PARENT_ID = :url_action_id
+			");
+			$sthParams->bindValue('url_action_id', $info['action_id']);
+			$sthParams->execute();
+			$urlParams = array();
+			$rawUrlParams = $sthParams->fetchAll();
+			foreach ($rawUrlParams as $urlParam) {
+				$urlParams[$urlParam['param_desc']] = $urlParam;
+			}
+			$info['url_params'] = $urlParams;
+		}
+		return $info;
+	}
+
+	public function kosztorysXmlAction() {
+		$idProject = 1921;
+		$schema = $this->_getKosztorysSchema();
+		$data = $this->_fetchKosztorysData($idProject);
+		//DBG::_(true, true, "XMLWriter", class_exists('XMLWriter'), __CLASS__, __FUNCTION__, __LINE__);
+		//header('Content-type: application/xml; charset=utf-8');
+		header('Content-type: text/plain; charset=utf-8');
+		$xmlWriter = new XMLWriter();
+		$xmlWriter->openUri('php://output');
+		$xmlWriter->setIndent(true);
+		if ($xmlWriter) {
+			$xmlWriter->startDocument('1.0','UTF-8');
+			//$xmlWriter->startElementNS(null, 'kosztorysy', 'https://biuro.biall-net.pl/wfs');// adds @xmlns=...
+			$xmlWriter->startElement('kosztorysy');
+			$xmlWriter->writeAttribute('targetNamespace', 'https://biuro.biall-net.pl/wfs');
+			$xmlWriter->writeAttributeNS('xmlns', 'p5', 'http://www.w3.org/2000/xmlns/', 'https://biuro.biall-net.pl/wfs');
+			for ($i = 1; $i <= 10; $i++) {
+				$idProject += 1;
+				$schema = $this->_getKosztorysSchema();
+				$data = $this->_fetchKosztorysData($idProject);
+				$xmlWriter->startElement('kosztorys');
+					$xmlWriter->startElement('projekt');
+						$xmlWriter->writeAttribute('id', $idProject);
+						$xmlWriter->startElement('projekt');
+							$xmlWriter->text("TODO L." . __LINE__);
+						$xmlWriter->endElement();
+					$xmlWriter->endElement();
+				$xmlWriter->endElement();
+			}
+/*
+			$memXmlWriter = new XMLWriter();
+			$memXmlWriter->openMemory();
+			$memXmlWriter->setIndent(true);
+
+			for ($i = 1; $i <= 10; $i++) {
+				$idProject += 1;
+				$schema = $this->_getKosztorysSchema();
+				$data = $this->_fetchKosztorysData($idProject);
+
+				$memXmlWriter->startElement('kosztorys');
+					$memXmlWriter->writeAttribute('id', $idProject);
+					$memXmlWriter->writeAttributeNS('p5', 'typeName', 'https://biuro.biall-net.pl/wfs', 'Kosztorys');
+				$memXmlWriter->text('book_'.$i);
+				$memXmlWriter->endElement();
+
+				if ($i % 5 == 0) {
+					$batchXmlString = $memXmlWriter->outputMemory(true);
+					$xmlWriter->writeRaw($batchXmlString);
+				}
+			}
+			$memXmlWriter->flush();
+			unset($memXmlWriter);
+*/
+			$xmlWriter->endElement();
+			$xmlWriter->endDocument();
+		}
+	}
+
 	public function kosztorys($idProject) {
 		$schema = $this->_getKosztorysSchema();
 		$data = $this->_fetchKosztorysData($idProject);
@@ -39,13 +258,13 @@ class Route_UrlAction_ProjektyKosztyWstepnychRobot extends RouteBase {// TODO: U
 		<tr>
 			<th><?php echo $schema['nr']; ?></th>
 			<th><?php echo $schema['title']; ?></th>
-			<th><?php echo $schema['owner']; ?></th>
+			<th><?php echo $schema['owner_name']; ?></th>
 			<th><?php echo $schema['cost_total']; ?></th>
 		</tr>
 		<tr>
 			<td><?php echo $data['nr']; ?></td>
 			<td><?php echo $data['title']; ?></td>
-			<td><?php echo $data['owner']; ?></td>
+			<td><?php echo $data['owner_name']; ?></td>
 			<td><?php echo $data['cost_total']; ?></td>
 		</tr>
 	</table>
@@ -82,14 +301,14 @@ class Route_UrlAction_ProjektyKosztyWstepnychRobot extends RouteBase {// TODO: U
 	<?php endforeach; ?>
 </div>
 		<?php
-		DBG::_('DBG', '>1', "data", $data, __CLASS__, __FUNCTION__, __LINE__);
-		DBG::_('DBG', '>1', "schema", $schema, __CLASS__, __FUNCTION__, __LINE__);
+		DBG::_('DBG', '>0', "data", $data, __CLASS__, __FUNCTION__, __LINE__);
+		DBG::_('DBG', '>0', "schema", $schema, __CLASS__, __FUNCTION__, __LINE__);
 	}
 
 	public function _getKosztorysSchema() {
 		$schema['nr'] = "Nr projektu";
 		$schema['title'] = "Tytuł projektu";
-		$schema['owner'] = "Osoba prowadząca";
+		$schema['owner_name'] = "Osoba prowadząca";
 		$schema['cost_total'] = "Szacowany koszt projektu [zł]";
 		$schema['sub_costs'] = array();
 		{
@@ -97,7 +316,7 @@ class Route_UrlAction_ProjektyKosztyWstepnychRobot extends RouteBase {// TODO: U
 			$layerConf['label'] = "Wykop";
 			$layerConf['_agr_fields_to_cols'] = array();
 			$layerConf['_agr_fields_to_cols']['ilosc'] = "ilość [m]";
-			$layerConf['_agr_fields_to_cols']['cena'] = "cena [zł/m]";
+			$layerConf['_agr_fields_to_cols']['cena'] = "podstawowa cena [zł/m]";
 			$layerConf['_agr_fields_to_cols']['koszt'] = "koszt [zł]";
 			$schema['sub_costs']['Rozdzielcza_Wykop_przedmiar_na_mikrorurki'] = $layerConf;
 		}
@@ -106,7 +325,7 @@ class Route_UrlAction_ProjektyKosztyWstepnychRobot extends RouteBase {// TODO: U
 			$layerConf['label'] = "Mikrokanalizacja do klienta";
 			$layerConf['_agr_fields_to_cols'] = array();
 			$layerConf['_agr_fields_to_cols']['ilosc'] = "ilość [m]";
-			$layerConf['_agr_fields_to_cols']['cena'] = "cena [zł/m]";
+			$layerConf['_agr_fields_to_cols']['cena'] = "podstawowa cena [zł/m]";
 			$layerConf['_agr_fields_to_cols']['koszt'] = "koszt [zł]";
 			$schema['sub_costs']['Rozdzielcza_Mikrokanalizacja_do_klienta'] = $layerConf;
 		}
@@ -115,7 +334,7 @@ class Route_UrlAction_ProjektyKosztyWstepnychRobot extends RouteBase {// TODO: U
 			$layerConf['label'] = "Przeciski";
 			$layerConf['_agr_fields_to_cols'] = array();
 			$layerConf['_agr_fields_to_cols']['ilosc'] = "ilość [m]";
-			$layerConf['_agr_fields_to_cols']['cena'] = "cena [zł/m]";
+			$layerConf['_agr_fields_to_cols']['cena'] = "podstawowa cena [zł/m]";
 			$layerConf['_agr_fields_to_cols']['koszt'] = "koszt [zł]";
 			$schema['sub_costs']['Rozdzielcza_Przeciski_110mm'] = $layerConf;
 		}
@@ -124,7 +343,7 @@ class Route_UrlAction_ProjektyKosztyWstepnychRobot extends RouteBase {// TODO: U
 			$layerConf['label'] = "Zabruki";
 			$layerConf['_agr_fields_to_cols'] = array();
 			$layerConf['_agr_fields_to_cols']['ilosc'] = "ilość [m]";
-			$layerConf['_agr_fields_to_cols']['cena'] = "cena [zł/m]";
+			$layerConf['_agr_fields_to_cols']['cena'] = "podstawowa cena [zł/m]";
 			$layerConf['_agr_fields_to_cols']['koszt'] = "koszt [zł]";
 			$schema['sub_costs']['Rozdzielcza_Zabruki'] = $layerConf;
 		}
@@ -133,7 +352,7 @@ class Route_UrlAction_ProjektyKosztyWstepnychRobot extends RouteBase {// TODO: U
 			$layerConf['label'] = "Światłowód";
 			$layerConf['_agr_fields_to_cols'] = array();
 			$layerConf['_agr_fields_to_cols']['ilosc'] = "ilość [m]";
-			$layerConf['_agr_fields_to_cols']['cena'] = "cena [zł/m]";
+			$layerConf['_agr_fields_to_cols']['cena'] = "podstawowa cena [zł/m]";
 			$layerConf['_agr_fields_to_cols']['koszt'] = "koszt [zł]";
 			{
 				$layerSubCostsConf = array();
@@ -159,7 +378,7 @@ class Route_UrlAction_ProjektyKosztyWstepnychRobot extends RouteBase {// TODO: U
 			$layerConf = array();
 			$layerConf['label'] = "Rury osłonowe - TODO";
 			$layerConf['_agr_fields_to_cols'] = array();
-			$schema['sub_costs']['__RURY_OSLONOWE__'] = $layerConf;
+			$schema['sub_costs']['Rura_oslonowa_rozdzielcza_magistralna'] = $layerConf;
 		}
 		{
 			$layerConf = array();
@@ -180,6 +399,25 @@ class Route_UrlAction_ProjektyKosztyWstepnychRobot extends RouteBase {// TODO: U
 		$project = array();
 		$schema = $this->_getKosztorysSchema();
 
+		if(0){// TEST join by ogc
+$exampleOgcJoin = <<<OGC_JOIN
+<wfs:Query typeNames="p5_default_db:IN7_MK_BAZA_DYSTRYBUCJI p5_default_db:ADMIN_USERS" aliases="p u">
+	<fes:Filter>
+		 <fes:And>
+				<fes:PropertyIsEqualTo>
+					 <fes:ValueReference>p/ID</fes:ValueReference>
+					 <fes:Literal>{$idProject}</fes:Literal>
+				</fes:PropertyIsEqualTo>
+				<fes:PropertyIsEqualTo>
+					 <fes:ValueReference>u/ADM_ACCOUNT<fes:ValueReference>
+					 <fes:ValueReference>p/L_APPOITMENT_USER</fes:ValueReference>
+				</fes:PropertyIsEqualTo>
+		 </fes:And>
+	</fes:Filter>
+</wfs:Query>
+OGC_JOIN;
+		}
+
 		$pdo = DB::getPDO();
 		{
 			$sth = $pdo->prepare("
@@ -228,7 +466,7 @@ class Route_UrlAction_ProjektyKosztyWstepnychRobot extends RouteBase {// TODO: U
 		{
 			$project['nr'] = $projectRaw['ID'];
 			$project['title'] = $projectRaw['M_DIST_DESC'];
-			$project['owner'] = $this->fetchUserName($projectRaw['L_APPOITMENT_USER']);
+			$project['owner_name'] = $this->fetchUserName($projectRaw['L_APPOITMENT_USER']);
 			$project['cost_total'] = $projectRaw['koszt_wspolny'];
 			foreach ($schema['sub_costs'] as $layerName => $layerConf) {
 				$values = array();