panel($idProject);
$this->execPostTasks();
$this->zamowienia($idProject);
} catch (Exception $e) {
UI::alert('danger', "Error #" . $e->getCode() . "|" . $e->getLine() . ": " . $e->getMessage());
}
UI::dol();
}
public function zamowienia($idProject) {
$idProject = (int)$idProject;
if ($idProject <= 0) throw new Exception("Error Processing Request - wrong param id project");
$idOrder = V::get('ID_ORDER', 0, $_REQUEST, 'int');
$sqlTableZlecenia = "IN7_DZIENNIK_KORESP";
// $sqlTableZlecenia = (DBG::isActive()) ? "IN7_DZIENNIK_KORESP__TEST_ZLECENIA" : "IN7_DZIENNIK_KORESP";
// if (DBG::isActive()) {
// UI::startContainer();
// UI::alert('warning', "Uwaga: Zlecenie z testowej tabeli Koresp (IN7_DZIENNIK_KORESP__TEST_ZLECENIA)");
// UI::endContainer();
/*
DROP TABLE IF EXISTS IN7_DZIENNIK_KORESP__TEST_ZLECENIA;
CREATE TABLE IN7_DZIENNIK_KORESP__TEST_ZLECENIA
select k.ID
, k.ID_PROJECT
, k.A_STATUS
, k.K_DATA_OTRZYM_KORESP
, k.K_DATA_OTRZYMANEJ_KORESP
, k.K_OD_KOGO
, k.OD_KOGO_ADRES
, k.K_ZAWARTOS
, k.CRM_LISTA_ZASOBOW_ID
, k.K_TYP_KORESP
from IN7_DZIENNIK_KORESP k
where k.CRM_LISTA_ZASOBOW_ID = 24121
and k.K_TYP_KORESP in('OUT','WEW') ;
ALTER TABLE `IN7_DZIENNIK_KORESP__TEST_ZLECENIA` ADD PRIMARY KEY ( `ID` ) ;
*/
// }
$ordersRaw = DB::getPDO()->fetchAllByKey("
select k.ID
, k.ID_PROJECT
, k.A_STATUS
, k.K_DATA_OTRZYM_KORESP
, k.K_DATA_OTRZYMANEJ_KORESP
, k.K_OD_KOGO
, k.OD_KOGO_ADRES
, k.K_ZAWARTOS
from {$sqlTableZlecenia} k
where k.CRM_LISTA_ZASOBOW_ID = {$this->_ID_ZASOB_ZAMOWIENIE}
and k.ID_PROJECT = {$idProject}
and k.K_TYP_KORESP in('OUT','WEW')
", $key = 'ID');
$orders = array();
foreach ($ordersRaw as $r) {
$item = array();
$chkd = ($r['ID'] == $idOrder) ? ' checked="checked"' : '';
$item['ID'] = '';
$item['Projekt'] = $r['ID_PROJECT'];
$item['Status'] = $r['A_STATUS'];
$item['K_DATA_OTRZYM_KORESP'] = $r['K_DATA_OTRZYM_KORESP'];
$item['K_DATA_OTRZYMANEJ_KORESP'] = $r['K_DATA_OTRZYMANEJ_KORESP'];
$item['K_OD_KOGO'] = $r['K_OD_KOGO'];
$item['OD_KOGO_ADRES'] = $r['OD_KOGO_ADRES'];
$item['K_ZAWARTOS'] = $r['K_ZAWARTOS'];
$orders[] = $item;
}
$order = ($idOrder > 0 && array_key_exists($idOrder, $ordersRaw)) ? $ordersRaw[$idOrder] : null;
UI::startContainer();
if (1 != V::get('_print', '', $_GET)) {
UI::startTag('form', ['action'=>'', 'method'=>'get']);
UI::tag('input', ['type'=>'hidden', 'name'=>'_route', 'value'=>'UrlAction_ProjektyZamowieniaKosztorys']);
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}");
else UI::table(['caption'=>"Wybierz zamówienie/zlecenie", 'rows'=>$orders]);
UI::endTag('form');
UI::tag('hr');
if (null != $order) {
$printLink = Request::getPathUri() . "index.php?_route=UrlAction_ProjektyZamowieniaKosztorys";
$printLink .= "&ID_PROJECT={$idProject}";
$printLink .= "&ID_ORDER={$order['ID']}";
$printLink .= "&_print=1";
UI::startTag('div', ['style'=>'text-align:right']);
UI::tag('a', ['_target'=>'blank', 'href'=>$printLink], ''. "Drukuj");
UI::endTag('div');
}
}
DBG::log($order, 'array', '$order');
if (null !== $order) {
$schema = ProjectKosztorysSchema::getSchema();// OK only 'config'
$model = $this->getModel($idProject);
$data = $this->getKosztorysData($idProject, $korespType = 'ZLECENIE', $idKoresp = $order['ID'], $admin = 0, $fetchAllRows = true);
{
$model = $this->getModel($idProject);
//DBG::table("subProjectList", $model->subProjectList, __CLASS__, __FUNCTION__, __LINE__);
$schema = ProjectKosztorysSchema::getSchema();
// $projCosts = $this->getProjectCostByCennik($idProject, $idCompany);
//DBG::_(true, true, "projCosts", $projCosts, __CLASS__, __FUNCTION__, __LINE__);
UI::startTag('h1', ['style'=>'margin-bottom:1em']);
echo "Zamówienie nr {$order['ID']}";
UI::tag('small', ['style'=>"display:block"], $order['K_ZAWARTOS']);
UI::endTag('h1');
UI::setTitleJsTag("Zamówienie nr {$order['ID']} (Kosztorys projektu [{$idProject}])");
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:
"),
]),
]),
]);
$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, $order) {
$rows = $data['summary'][$idLayer]['data'];
$layer = $conf['layer'][$idLayer];
$cols = [
// 'primaryKey' => "Nr",// string(4) "6906" // grouped data by ID_ZASOB, so primaryKey is not correct
'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']) { // TODO: to config - additional columns
$addCols['Suma_ZapasA'] = "Suma_ZapasA";
$addCols['Suma_ZapasB'] = "Suma_ZapasB";
}
// $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($schema, '$schema');
// if (DBG::isActive()) DBG::nicePrint($model, '$model');
}
// if (DBG::isActive()) UI::tag('hr');
// if (DBG::isActive()) $this->checkDBData();
UI::endContainer();
}
public function checkDBData() {
$schema = ProjectKosztorysSchema::getSchema();// OK only 'config'
foreach ($schema['config']['layer'] as $idLayer => $layer) {
//