|
@@ -21,6 +21,7 @@ class Route_UrlAction_ProjektyZamowieniaKosztorys extends Route_ProjektyKosztory
|
|
|
$idProject = V::get('ID_PROJECT', 0, $_REQUEST, 'int');
|
|
$idProject = V::get('ID_PROJECT', 0, $_REQUEST, 'int');
|
|
|
if (!$idProject) throw new Exception("Wrong param in 'ID_PROJECT' - expected integer!");
|
|
if (!$idProject) throw new Exception("Wrong param in 'ID_PROJECT' - expected integer!");
|
|
|
$this->panel($idProject);
|
|
$this->panel($idProject);
|
|
|
|
|
+ $this->execPostTasks();
|
|
|
$this->zamowienia($idProject);
|
|
$this->zamowienia($idProject);
|
|
|
} catch (Exception $e) {
|
|
} catch (Exception $e) {
|
|
|
UI::alert('danger', "Error #" . $e->getCode() . "|" . $e->getLine() . ": " . $e->getMessage());
|
|
UI::alert('danger', "Error #" . $e->getCode() . "|" . $e->getLine() . ": " . $e->getMessage());
|
|
@@ -94,7 +95,7 @@ ALTER TABLE `IN7_DZIENNIK_KORESP__TEST_ZLECENIA` ADD PRIMARY KEY ( `ID` ) ;
|
|
|
UI::tag('input', ['type'=>'hidden', 'name'=>'_route', 'value'=>'UrlAction_ProjektyZamowieniaKosztorys']);
|
|
UI::tag('input', ['type'=>'hidden', 'name'=>'_route', 'value'=>'UrlAction_ProjektyZamowieniaKosztorys']);
|
|
|
UI::tag('input', ['type'=>'hidden', 'name'=>'ID_PROJECT', 'value'=>$idProject]);
|
|
UI::tag('input', ['type'=>'hidden', 'name'=>'ID_PROJECT', 'value'=>$idProject]);
|
|
|
if (empty($orders)) UI::alert('info', "Brak zamówień w korespondencji dotyczących projektu {$idProject}");
|
|
if (empty($orders)) UI::alert('info', "Brak zamówień w korespondencji dotyczących projektu {$idProject}");
|
|
|
- else UI::table(['caption'=>"Wybierz zamówienie", 'rows'=>$orders]);
|
|
|
|
|
|
|
+ else UI::table(['caption'=>"Wybierz zamówienie/zlecenie", 'rows'=>$orders]);
|
|
|
UI::endTag('form');
|
|
UI::endTag('form');
|
|
|
UI::tag('hr');
|
|
UI::tag('hr');
|
|
|
if (null != $order) {
|
|
if (null != $order) {
|
|
@@ -103,61 +104,153 @@ ALTER TABLE `IN7_DZIENNIK_KORESP__TEST_ZLECENIA` ADD PRIMARY KEY ( `ID` ) ;
|
|
|
$printLink .= "&ID_ORDER={$order['ID']}";
|
|
$printLink .= "&ID_ORDER={$order['ID']}";
|
|
|
$printLink .= "&_print=1";
|
|
$printLink .= "&_print=1";
|
|
|
UI::startTag('div', ['style'=>'text-align:right']);
|
|
UI::startTag('div', ['style'=>'text-align:right']);
|
|
|
- UI::tag('a', ['_target'=>'blank', 'href'=>$printLink], '<i class="glyphicon glyphicon-print"></i>'. "Drukuj zamówienie");
|
|
|
|
|
|
|
+ UI::tag('a', ['_target'=>'blank', 'href'=>$printLink], '<i class="glyphicon glyphicon-print"></i>'. "Drukuj");
|
|
|
UI::endTag('div');
|
|
UI::endTag('div');
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
+ DBG::log($order, 'array', '$order');
|
|
|
if (null !== $order) {
|
|
if (null !== $order) {
|
|
|
$schema = ProjectKosztorysSchema::getSchema();// OK only 'config'
|
|
$schema = ProjectKosztorysSchema::getSchema();// OK only 'config'
|
|
|
$model = $this->getModel($idProject);
|
|
$model = $this->getModel($idProject);
|
|
|
- $data = $this->getKosztorysData($idProject, $order['ID']);
|
|
|
|
|
|
|
+ $data = $this->getKosztorysData($idProject, $korespType = 'ZLECENIE', $idKoresp = $order['ID'], $admin = 0, $fetchAllRows = true);
|
|
|
|
|
|
|
|
{
|
|
{
|
|
|
- $idCompany = null;
|
|
|
|
|
- $admin = false;
|
|
|
|
|
- $companyAdmin = null;
|
|
|
|
|
- $projCosts = null;
|
|
|
|
|
- $hidePrices = true;
|
|
|
|
|
-
|
|
|
|
|
$model = $this->getModel($idProject);
|
|
$model = $this->getModel($idProject);
|
|
|
//DBG::table("subProjectList", $model->subProjectList, __CLASS__, __FUNCTION__, __LINE__);
|
|
//DBG::table("subProjectList", $model->subProjectList, __CLASS__, __FUNCTION__, __LINE__);
|
|
|
$schema = ProjectKosztorysSchema::getSchema();
|
|
$schema = ProjectKosztorysSchema::getSchema();
|
|
|
// $projCosts = $this->getProjectCostByCennik($idProject, $idCompany);
|
|
// $projCosts = $this->getProjectCostByCennik($idProject, $idCompany);
|
|
|
//DBG::_(true, true, "projCosts", $projCosts, __CLASS__, __FUNCTION__, __LINE__);
|
|
//DBG::_(true, true, "projCosts", $projCosts, __CLASS__, __FUNCTION__, __LINE__);
|
|
|
- $viewLayerDataArgs = compact('idProject', 'idCompany', 'admin', 'companyAdmin', 'projCosts', 'hidePrices');
|
|
|
|
|
UI::startTag('h1', ['style'=>'margin-bottom:1em']);
|
|
UI::startTag('h1', ['style'=>'margin-bottom:1em']);
|
|
|
echo "Zamówienie nr {$order['ID']}";
|
|
echo "Zamówienie nr {$order['ID']}";
|
|
|
UI::tag('small', ['style'=>"display:block"], $order['K_ZAWARTOS']);
|
|
UI::tag('small', ['style'=>"display:block"], $order['K_ZAWARTOS']);
|
|
|
UI::endTag('h1');
|
|
UI::endTag('h1');
|
|
|
UI::setTitleJsTag("Zamówienie nr {$order['ID']} (Kosztorys projektu [{$idProject}])");
|
|
UI::setTitleJsTag("Zamówienie nr {$order['ID']} (Kosztorys projektu [{$idProject}])");
|
|
|
|
|
|
|
|
- UI::startTag('table', ['class'=>'table']);
|
|
|
|
|
- UI::startTag('tr');
|
|
|
|
|
- UI::tag('th', null, "Nr zamówienia");
|
|
|
|
|
- UI::tag('th', null, $schema['nr']);
|
|
|
|
|
- UI::tag('th', null, $schema['title']);
|
|
|
|
|
- UI::tag('th', null, $schema['ownerName']);
|
|
|
|
|
- // UI::tag('th', ['style'=>'text-align:right'], $schema['cost_total']);
|
|
|
|
|
- UI::endTag('tr');
|
|
|
|
|
- UI::startTag('tr');
|
|
|
|
|
- UI::tag('td', null, $order['ID']);
|
|
|
|
|
- UI::tag('td', null, $model->idProject);
|
|
|
|
|
- UI::tag('td', null, $model->title);
|
|
|
|
|
- UI::tag('td', null, $model->ownerName);
|
|
|
|
|
- // UI::tag('td', ['style'=>'text-align:right'], number_format($projCosts['cost_total'], 2, ',', ' '));
|
|
|
|
|
- UI::endTag('tr');
|
|
|
|
|
- UI::endTag('table');
|
|
|
|
|
- $this->viewLayersData($viewLayerDataArgs);
|
|
|
|
|
|
|
+ echo UI::h('table', [ 'style' => "width:100%; margin-bottom: 12px" ], [
|
|
|
|
|
+ UI::h('tr', [], [
|
|
|
|
|
+ UI::h('th', [ 'style' => "padding-bottom: 8px; text-align:center" ], "ZLECENIE WEWNĘTRZNE PRAC BUDOWLANYCH BIALL-NET"),
|
|
|
|
|
+ UI::h('th', [], ""),
|
|
|
|
|
+ UI::h('th', [ 'style' => "padding-bottom: 8px; text-align:center" ], "PROTOKÓŁ ODBIORU PRAC BUDOWLANYCH BIALL-NET"),
|
|
|
|
|
+ ]),
|
|
|
|
|
+ UI::h('tr', [], [
|
|
|
|
|
+ UI::h('td', [ 'style' => "width:44%; padding: 3px 6px; border: 1px solid #ddd; vertical-align:top" ], [
|
|
|
|
|
+ UI::h('div', [], "NR KRESPONDENCJI: {$order['ID']}"),
|
|
|
|
|
+ UI::h('div', [], "ADRES ZLECENIA: "),
|
|
|
|
|
+ UI::h('div', [], "DATA ZLECENIA: "),
|
|
|
|
|
+ UI::h('div', [], "WYKONAWCA/Y ZLECENIA: {$order['K_OD_KOGO']}"),
|
|
|
|
|
+ UI::h('div', [], "ROZPOCZĘCIE PRAC: "),
|
|
|
|
|
+ UI::h('div', [], "ZAKOŃCZENIE PRAC: "),
|
|
|
|
|
+ UI::h('div', [], "PRACE ZLECA: {$order['ID']}"),
|
|
|
|
|
+ UI::h('div', [], "PRACE PRZYJMUJE: "),
|
|
|
|
|
+ ]),
|
|
|
|
|
+ UI::h('td', [ 'style' => "width:10%" ], [
|
|
|
|
|
+ ]),
|
|
|
|
|
+ UI::h('td', [ 'style' => "width:44%; padding: 3px 6px; border: 1px solid #ddd; vertical-align:top" ], [
|
|
|
|
|
+ UI::h('div', [], "NR KRESPONDENCJI: "),
|
|
|
|
|
+ UI::h('div', [], "DATA ODBIORU: "),
|
|
|
|
|
+ UI::h('div', [], "WYKONAWCA/Y ZLECENIA: "),
|
|
|
|
|
+ UI::h('div', [], "ROZPOCZĘCIE PRAC: "),
|
|
|
|
|
+ UI::h('div', [], "ZAKOŃCZENIE PRAC: "),
|
|
|
|
|
+ UI::h('div', [], "PRACE PRZEKAZUJE: "),
|
|
|
|
|
+ UI::h('div', [], "PRACE ODBIERA: "),
|
|
|
|
|
+ UI::h('div', [], "UWAGI: <br><br>"),
|
|
|
|
|
+ ]),
|
|
|
|
|
+ ]),
|
|
|
|
|
+ ]);
|
|
|
|
|
+
|
|
|
|
|
+ $conf = $schema['config'];
|
|
|
|
|
+ // [summary] => array(1) {
|
|
|
|
|
+ // [22478] => array(2) {
|
|
|
|
|
+ // [label] => string(14) "Rury osłonowe"
|
|
|
|
|
+ // [data] => array(1) {
|
|
|
|
|
+ // [48415] => array(6) {
|
|
|
|
|
+ // [ID_PROJECT] => string(4) "6906"
|
|
|
|
|
+ // [ilosc] => string(2) "10"
|
|
|
|
|
+ // [type] => string(13) "1xHDPE 40/3,7"
|
|
|
|
|
+ // [idType] => int(48415)
|
|
|
|
|
+ // [idLayer] => int(22478)
|
|
|
|
|
+ // [jednostka] => string(4) "METR"
|
|
|
|
|
+ echo UI::h('div', [], array_map(function ($summary, $idLayer) use ($conf, $data) {
|
|
|
|
|
+ $rows = $data['summary'][$idLayer]['data'];
|
|
|
|
|
+ $layer = $conf['layer'][$idLayer];
|
|
|
|
|
+ $cols = [
|
|
|
|
|
+ 'primaryKey' => "Nr",// string(4) "6906"
|
|
|
|
|
+ 'ID_PROJECT' => "Nr projektu",// string(4) "6906"
|
|
|
|
|
+ 'ilosc' => "ilosc",// string(2) "10"
|
|
|
|
|
+ 'type' => "typ",// string(13) "1xHDPE 40/3,7"
|
|
|
|
|
+ // 'idType' => "idType",// int(48415)
|
|
|
|
|
+ // 'idLayer' => "idLayer",// int(22478)
|
|
|
|
|
+ 'jednostka' => "jednostka",// string(4) "METR"
|
|
|
|
|
+ ];
|
|
|
|
|
+ $addCols = [];
|
|
|
|
|
+ if ('Rozdzielcza_Kabel_Swiatlowodowy_wsg84' === $layer['tabela_name']) {
|
|
|
|
|
+ $addCols['ZapasA'] = "ZapasA";
|
|
|
|
|
+ $addCols['ZapasB'] = "ZapasB";
|
|
|
|
|
+ $addCols['wlokien_j'] = "wlokien_j";
|
|
|
|
|
+ }
|
|
|
|
|
+ if (!empty($rows) && !empty($addCols)) {
|
|
|
|
|
+ $tableName = $layer['tabela_name'];
|
|
|
|
|
+ array_walk($rows, function (&$row, $key) use ($addCols, $tableName) {
|
|
|
|
|
+ $sqlCols = implode(", ", array_map(function ($col) { return "t.`{$col}`"; }, array_keys($addCols)));
|
|
|
|
|
+ $moreInfo = DB::getPDO()->fetchFirst("
|
|
|
|
|
+ select {$sqlCols}
|
|
|
|
|
+ from `{$tableName}` as t
|
|
|
|
|
+ where ID = :id
|
|
|
|
|
+ ", [ ':id' => $row['primaryKey'] ]);
|
|
|
|
|
+ $row = array_merge($row, $moreInfo);
|
|
|
|
|
+ });
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ // $tableName = $layer['tabela_name'];
|
|
|
|
|
+ // $cols = [];
|
|
|
|
|
+ // if ('Rozdzielcza_rura_oslonowa_magistralna' === $tableName) {
|
|
|
|
|
+ // $cols = [
|
|
|
|
|
+ // 'ID' => "Nr",
|
|
|
|
|
+ // 'ID_PROJECT' => "Nr projektu",
|
|
|
|
|
+ // 'Dlugosc' => "Długość",
|
|
|
|
|
+ // 'PROJECT_INFO_FULL' => "Nazwa",
|
|
|
|
|
+ // ];
|
|
|
|
|
+ // }
|
|
|
|
|
+ // if ('Rozdzielcza_koszty_dodatkowe_wsg84' === $tableName) {
|
|
|
|
|
+ // $cols = [
|
|
|
|
|
+ // 'ID' => "Nr",
|
|
|
|
|
+ // 'ID_PROJECT' => "Nr projektu",
|
|
|
|
|
+ // 'Przeznaczenie' => "Przeznaczenie",
|
|
|
|
|
+ // 'ilosc' => "Ilość",
|
|
|
|
|
+ // 'ilosc' => "Ilość",
|
|
|
|
|
+ // ];
|
|
|
|
|
+ // }
|
|
|
|
|
+ $allCols = array_merge($cols, $addCols);
|
|
|
|
|
+ return UI::h('div', [], [
|
|
|
|
|
+ UI::h('table', [ 'class' => "table table-bordered table-condensed", 'style' => "width:auto" ], [
|
|
|
|
|
+ UI::h('thead', [], [
|
|
|
|
|
+ UI::h('tr', [], [
|
|
|
|
|
+ UI::h('td', [ 'colspan' => count($allCols), 'style' => "padding:0 6px; font-size:1.2em; line-height:2em" ], " — {$summary['label']}"),
|
|
|
|
|
+ ]),
|
|
|
|
|
+ UI::h('tr', [], array_map(function ($label, $fieldName) {
|
|
|
|
|
+ return UI::h('th', [ 'style' => "padding:1px 3px" ], $label);
|
|
|
|
|
+ }, $allCols, array_keys($allCols)))
|
|
|
|
|
+ ]),
|
|
|
|
|
+ UI::h('tbody', [], array_map(function ($row) use ($allCols) {
|
|
|
|
|
+ return UI::h('tr', [], array_map(function ($label, $fieldName) use ($row) {
|
|
|
|
|
+ return UI::h('td', [ 'style' => "padding:1px 3px" ], $row[$fieldName]);
|
|
|
|
|
+ }, $allCols, array_keys($allCols)));
|
|
|
|
|
+ }, $rows)),
|
|
|
|
|
+ ])
|
|
|
|
|
+ ]);
|
|
|
|
|
+ }, $data['summary'], array_keys($data['summary'])));
|
|
|
|
|
+
|
|
|
|
|
+ echo UI::h('div', [ 'style' => "border: 1px solid #ddd; padding: 3px 6px 120px 6px" ], "UWAGI - PRACE DODATKOWE:");
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
- if (DBG::isActive()) DBG::nicePrint($data, '$data');
|
|
|
|
|
|
|
+ // if (DBG::isActive()) DBG::nicePrint($data, '$data');
|
|
|
// if (DBG::isActive()) DBG::nicePrint($schema, '$schema');
|
|
// if (DBG::isActive()) DBG::nicePrint($schema, '$schema');
|
|
|
// if (DBG::isActive()) DBG::nicePrint($model, '$model');
|
|
// if (DBG::isActive()) DBG::nicePrint($model, '$model');
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
- if (DBG::isActive()) UI::tag('hr');
|
|
|
|
|
- if (DBG::isActive()) $this->checkDBData();
|
|
|
|
|
|
|
+ // if (DBG::isActive()) UI::tag('hr');
|
|
|
|
|
+ // if (DBG::isActive()) $this->checkDBData();
|
|
|
UI::endContainer();
|
|
UI::endContainer();
|
|
|
}
|
|
}
|
|
|
|
|
|
|
@@ -198,6 +291,7 @@ ALTER TABLE `IN7_DZIENNIK_KORESP__TEST_ZLECENIA` ADD PRIMARY KEY ( `ID` ) ;
|
|
|
left join IN7_DZIENNIK_KORESP k on(k.ID = g.ID_KORESP_ZLECENIE)
|
|
left join IN7_DZIENNIK_KORESP k on(k.ID = g.ID_KORESP_ZLECENIE)
|
|
|
", $key = 'ID_KORESP_ZLECENIE');
|
|
", $key = 'ID_KORESP_ZLECENIE');
|
|
|
} catch (Exception $e) {
|
|
} catch (Exception $e) {
|
|
|
|
|
+ DBG::log($e);
|
|
|
if ("SQLSTATE[42S22]: Column not found: 1054 Unknown column 't.ID_KORESP_ZLECENIE' in 'field list'" == $e->getMessage()) {
|
|
if ("SQLSTATE[42S22]: Column not found: 1054 Unknown column 't.ID_KORESP_ZLECENIE' in 'field list'" == $e->getMessage()) {
|
|
|
UI::alert('danger', "Brak komórki `ID_KORESP_ZLECENIE` w tabeli `{$layer['tabela_name']}`");
|
|
UI::alert('danger', "Brak komórki `ID_KORESP_ZLECENIE` w tabeli `{$layer['tabela_name']}`");
|
|
|
} else UI::alert('danger', $e->getMessage());
|
|
} else UI::alert('danger', $e->getMessage());
|
|
@@ -228,141 +322,4 @@ ALTER TABLE `IN7_DZIENNIK_KORESP__TEST_ZLECENIA` ADD PRIMARY KEY ( `ID` ) ;
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
- public function getKosztorysData($idProject, $idOrder = 0, $admin = 0) {
|
|
|
|
|
- static $_data = null;
|
|
|
|
|
- if (null === $_data) {
|
|
|
|
|
- $idSubProject = $this->getModel($idProject)->getSubProjectIds();
|
|
|
|
|
- $idSubProject[] = $idProject;
|
|
|
|
|
- $_data = $this->fetchData($idSubProject, $idOrder, $admin);
|
|
|
|
|
- }
|
|
|
|
|
- return $_data;
|
|
|
|
|
- }
|
|
|
|
|
-
|
|
|
|
|
- public function fetchData($idProject, $idOrder = 0, $admin = 0) {
|
|
|
|
|
- $data = array();
|
|
|
|
|
- $data['summary'] = array();// [ $idType ] = ['type', 'jednostka', 'ilosc']
|
|
|
|
|
- $data['rawDataByType'] = array();
|
|
|
|
|
- if (empty($idProject)) return $data;
|
|
|
|
|
- $schema = ProjectKosztorysSchema::getSchema();// OK only 'config'
|
|
|
|
|
- $conf = $schema['config'];
|
|
|
|
|
- foreach ($conf['layer'] as $idLayer => $layer) {
|
|
|
|
|
- if (!$layer['tabela_name']) continue;// TODO: throw error in validate
|
|
|
|
|
- if ('ZASOB' == $layer['zasob_type']) {
|
|
|
|
|
- } else if ('ZASOB_ID' == $layer['zasob_type']) {
|
|
|
|
|
- } else if ('ID_ZASOB' == $layer['zasob_type']) {
|
|
|
|
|
- } else {
|
|
|
|
|
- continue;// TODO: validate config error
|
|
|
|
|
- }
|
|
|
|
|
-
|
|
|
|
|
- $tblName = $layer['tabela_name'];
|
|
|
|
|
- $sqlIloscField = (!empty($layer['ilosc_field']))? $layer['ilosc_field'] : 'ID';
|
|
|
|
|
- $sqlIlosc = ('SZTUKA' == $layer['jednostka'])? "count(1)" : "sum(t.{$sqlIloscField})";
|
|
|
|
|
- $sqlZasobField = (!empty($layer['zasob_field']))? $layer['zasob_field'] : 'ID';
|
|
|
|
|
- $sqlGroupBy = "group by t.ID_PROJECT" . ((!empty($layer['zasob_field']))? ", t.{$sqlZasobField}" : '');
|
|
|
|
|
- $sqlIdProject = (is_array($idProject))? implode(",", $idProject) : (int)$idProject;
|
|
|
|
|
- $sql = "
|
|
|
|
|
- select t.{$sqlZasobField}
|
|
|
|
|
- , t.ID_PROJECT
|
|
|
|
|
- , {$sqlIlosc} as ilosc
|
|
|
|
|
- , count(1) as ilosc_sztuk
|
|
|
|
|
- from {$tblName} t
|
|
|
|
|
- where t.ID_PROJECT in({$sqlIdProject})
|
|
|
|
|
- and t.the_geom is not null
|
|
|
|
|
- -- WHERE
|
|
|
|
|
- {$sqlGroupBy}
|
|
|
|
|
- ";
|
|
|
|
|
- $data['_DBG_sql'][$idLayer] = $sql;
|
|
|
|
|
- try {
|
|
|
|
|
- if ($idOrder > 0) {
|
|
|
|
|
- $sqlWithOrder = str_replace("-- WHERE", "and t.ID_KORESP_ZLECENIE = '{$idOrder}'", $sql);
|
|
|
|
|
- $data['_DBG_sql_idOrder'][$idLayer] = $sqlWithOrder;
|
|
|
|
|
- $rawLayData = DB::getPDO()->fetchAll($sqlWithOrder);
|
|
|
|
|
- }
|
|
|
|
|
- } catch (Exception $e) {
|
|
|
|
|
- UI::alert('danger', "Error: " . $e->getMessage());
|
|
|
|
|
- if (1 != V::get('_print', '', $_GET)) UI::alert('danger', "Brak pola `ID_KORESP_ZLECENIE` w tabeli `$tblName`");
|
|
|
|
|
- $rawLayData = DB::getPDO()->fetchAll($sql);
|
|
|
|
|
- }
|
|
|
|
|
- $rawLayData = array_filter($rawLayData, function($row) {
|
|
|
|
|
- return ($row['ilosc'] > 0);
|
|
|
|
|
- });
|
|
|
|
|
- foreach ($rawLayData as $idx => &$row) {
|
|
|
|
|
- if ('ZASOB' == $layer['zasob_type']) {
|
|
|
|
|
- $row['type'] = trim($row[$sqlZasobField]);
|
|
|
|
|
- $row['idType'] = array_search($row['type'], $conf['type']);
|
|
|
|
|
- } else if ('ZASOB_ID' == $layer['zasob_type']) {
|
|
|
|
|
- $row['type'] = $layer['zasob_label'];
|
|
|
|
|
- $row['idType'] = (array_key_exists($layer['zasob_id'], $conf['type']))? $layer['zasob_id'] : null;
|
|
|
|
|
- } else if ('ID_ZASOB' == $layer['zasob_type']) {
|
|
|
|
|
- $row['type'] = (array_key_exists($row[$sqlZasobField], $conf['type']))? $conf['type'][ $row[$sqlZasobField] ] : null;
|
|
|
|
|
- $row['idType'] = $row[$sqlZasobField];
|
|
|
|
|
- }
|
|
|
|
|
- $idType = $row['idType'];
|
|
|
|
|
- $row['idLayer'] = $idLayer;
|
|
|
|
|
-
|
|
|
|
|
- $row['jednostka'] = $conf['layer'][$idLayer]['jednostka'];
|
|
|
|
|
- if (!empty($conf['layer'][$idLayer]['jednostka_zasob_id'][$idType])) {
|
|
|
|
|
- $row['jednostka'] = $conf['layer'][$idLayer]['jednostka_zasob_id'][$idType];
|
|
|
|
|
- if ('SZTUKA' == $row['jednostka']) {
|
|
|
|
|
- $row['ilosc'] = $row['ilosc_sztuk'];
|
|
|
|
|
- }
|
|
|
|
|
- }
|
|
|
|
|
- unset($row['ilosc_sztuk']);
|
|
|
|
|
-
|
|
|
|
|
- unset($row[$sqlZasobField]);
|
|
|
|
|
- $data['rawDataByType'][] = $row;
|
|
|
|
|
- }
|
|
|
|
|
- }
|
|
|
|
|
- //DBG::_(true, true, "data", $data, __CLASS__, __FUNCTION__, __LINE__);
|
|
|
|
|
- //DBG::table("data['rawDataByType']", $data['rawDataByType'], __CLASS__, __FUNCTION__, __LINE__);
|
|
|
|
|
- if ($admin) {
|
|
|
|
|
- foreach ($data['rawDataByType'] as $row) {
|
|
|
|
|
- $layer = $conf['layer'][$row['idLayer']];
|
|
|
|
|
- if ($row['idType'] <= 0) {
|
|
|
|
|
- UI::alert('warning', "Pomijanie nieznanego oznaczenia '{$row['type']}' w ilości {$row['ilosc']} - warstwa '{$layer['label']}' ({$layer['tabela_name']}), projekt nr {$row['ID_PROJECT']}");
|
|
|
|
|
- }
|
|
|
|
|
- }
|
|
|
|
|
- }
|
|
|
|
|
- $data['rawDataByType'] = array_filter($data['rawDataByType'], function($row) {
|
|
|
|
|
- return ($row['idType'] > 0);
|
|
|
|
|
- });
|
|
|
|
|
- //DBG::table("data['rawDataByType'] - clean", $data['rawDataByType'], __CLASS__, __FUNCTION__, __LINE__);
|
|
|
|
|
- $data['by_layer'] = array_reduce($data['rawDataByType'], function($result, $row) {
|
|
|
|
|
- $idLayer = $row['idLayer'];
|
|
|
|
|
- $idType = $row['idType'];
|
|
|
|
|
- if (!array_key_exists($idLayer, $result)) $result[$idLayer] = array();
|
|
|
|
|
- if (!array_key_exists($idType, $result[$idLayer])) {
|
|
|
|
|
- $result[$idLayer][$idType] = $row;
|
|
|
|
|
- } else {
|
|
|
|
|
- $result[$idLayer][$idType]['ilosc'] += $row['ilosc'];
|
|
|
|
|
- }
|
|
|
|
|
- return $result;
|
|
|
|
|
- }, array());
|
|
|
|
|
- //DBG::_(true, true, "data['by_layer']", $data['by_layer'], __CLASS__, __FUNCTION__, __LINE__);
|
|
|
|
|
- $data['summary'] = array();
|
|
|
|
|
- foreach ($data['by_layer'] as $idLayer => $iloscByType) {
|
|
|
|
|
- $layData = array();
|
|
|
|
|
- $layData['label'] = $conf['layer'][$idLayer]['label'];
|
|
|
|
|
- $layData['data'] = $iloscByType;
|
|
|
|
|
- $data['summary'][$idLayer] = $layData;
|
|
|
|
|
- }
|
|
|
|
|
- //DBG::_(true, true, "data['summary']", $data['summary'], __CLASS__, __FUNCTION__, __LINE__);
|
|
|
|
|
-
|
|
|
|
|
- $data['by_project'] = array_reduce($data['rawDataByType'], function($result, $row) {
|
|
|
|
|
- $idProj = $row['ID_PROJECT'];
|
|
|
|
|
- $idLayer = $row['idLayer'];
|
|
|
|
|
- $idType = $row['idType'];
|
|
|
|
|
- if (!array_key_exists($idProj, $result)) $result[$idProj] = array();
|
|
|
|
|
- if (!array_key_exists($idLayer, $result[$idProj])) $result[$idProj][$idLayer] = array();
|
|
|
|
|
- if (!array_key_exists($idType, $result[$idProj][$idLayer])) {
|
|
|
|
|
- $result[$idProj][$idLayer][$idType] = $row;
|
|
|
|
|
- } else {
|
|
|
|
|
- $result[$idProj][$idLayer][$idType]['ilosc'] += $row['ilosc'];
|
|
|
|
|
- }
|
|
|
|
|
- return $result;
|
|
|
|
|
- }, array());
|
|
|
|
|
- //DBG::_(true, true, "data['by_project']", $data['by_project'], __CLASS__, __FUNCTION__, __LINE__);
|
|
|
|
|
- return $data;
|
|
|
|
|
- }
|
|
|
|
|
-
|
|
|
|
|
}
|
|
}
|