|
|
@@ -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();
|