panel($idProject, $idCompany);
$this->execPostTasks();
if (1 != V::get('_print', '', $_GET)) {
UI::startContainer(['style'=>'text-align:right']);
UI::link('link', " Drukuj", Request::getPathUri() . "index.php?_route=UrlAction_ProjektyKosztorys&ID_PROJECT={$idProject}&_print=1");
UI::endContainer();
}
$this->kosztorys($idProject, $idCompany);
} catch (Exception $e) {
UI::alert('danger', "Error #" . $e->getCode() . "|" . $e->getLine() . ": " . $e->getMessage());
}
UI::dol();
}
public function kosztorys($idProject) {
$idCompany = 0;
$admin = false;
$companyAdmin = false;
$priceEditJs = (1 != V::get('_print', '', $_GET)) ? Request::getPathUri() . "index.php?_route=UrlAction_ProjektyKosztorys&_task=updateProjektyOfertaAjax&idProject={$idProject}" : false;
$model = $this->getModel($idProject);
//DBG::table("subProjectList", $model->subProjectList, __CLASS__, __FUNCTION__, __LINE__);
$schema = ProjectKosztorysSchema::getSchema($showErrors = true);
$projCosts = $this->getProjectCostByCennik($idProject, $idCompany);
//DBG::_(true, true, "projCosts", $projCosts, __CLASS__, __FUNCTION__, __LINE__);
$viewLayerDataArgs = compact('idProject', 'idCompany', 'admin', 'companyAdmin', 'projCosts', 'priceEditJs');
UI::setTitleJsTag("Kosztorys wstępny robót telekomunikacyjnych [{$idProject}]");
?>
Kosztorys wstępny robót telekomunikacyjnych
|
|
|
|
| idProject; ?> |
title; ?> |
ownerName; ?> |
|
viewLayersData($viewLayerDataArgs); ?>
0', "schema", $schema, __CLASS__, __FUNCTION__, __LINE__);
DBG::_('DBG', '>0', "projCosts", $projCosts, __CLASS__, __FUNCTION__, __LINE__);
}
public function updateProjektyOfertaAjaxAction() {
$args = array();
$args['idProject'] = V::get('idProject', 0, $_GET, 'int');
$args['idType'] = V::get('idType', 0, $_GET, 'int');
$args['unitType'] = V::get('unitType', '', $_GET, 'word');
Response::sendTryCatchJson(array($this, 'updateProjektyOfertaAjax'), $args);
}
public function updateProjektyOfertaAjax($args) {
$idProject = V::get('idProject', 0, $args, 'int');
$idType = V::get('idType', 0, $args, 'int');
$unitType = V::get('unitType', '', $args, 'word');
if (empty($idProject) || $idProject <= 0) throw new Exception("Wrong param idProject");
if (empty($idType) || $idType <= 0) throw new Exception("Wrong param idType");
if (empty($unitType) || !in_array($unitType, array('zasob', 'robocizna'))) throw new Exception("Wrong param unitType");
$response = array();
if (DBG::isActive()) $response['_idProject'] = $idProject;
if (DBG::isActive()) $response['_idType'] = $idType;
$jednostka = '';
if ('robocizna' == $unitType) $jednostka = 'ROBOCIZNA';
else if ('zasob' == $unitType) {
$schema = ProjectKosztorysSchema::getSchema();
foreach ($schema['config']['layer'] as $idLayer => $layData) {
if (array_key_exists($idType, $layData['type'])) $jednostka = $layData['jednostka'];
}
}
if (DBG::isActive()) $response['_unit'] = $jednostka;
$reqJson = Request::getRequestJson();
if (!empty($reqJson)) {
if (!array_key_exists('price', $reqJson)) throw new Exception("Missing param price");
$price = V::get('price', 0, $reqJson, 'float');
DBG::log("updating price '{$price}' for (\$idType: {$idType}, \$idProject: {$idProject}, \$jednostka: {$jednostka})");
ProjectKosztorysCennik::updatePriceProjectCennik($idType, $idProject, $price, $jednostka);
}
$response['id'] = $idType;
$response['unitType'] = $unitType;
$response['label'] = ProjectKosztorysCennik::getTypeLabel($idType);
$response['defaultPrice'] = ProjectKosztorysCennik::getPriceDefaultCennik($idType, 0, $jednostka);
$response['price'] = ProjectKosztorysCennik::getPrice($idType, $idProject, $idCompany = 0, $jednostka);
$response['msg'] = "";
$response['type'] = "success";
DBG::log($response, 'array', "response");
return $response;
}
}