Ver código fonte

added allow 0 to set in Kosztorys as project price

Piotr Labudda 9 anos atrás
pai
commit
59dcd0f292

+ 6 - 6
SE/se-lib/ProjectKosztorysCennik.php

@@ -23,11 +23,11 @@ class ProjectKosztorysCennik {
         , o.REQUIRED_RESOURCE_UNITS as quantity
       from CRM_LISTA_ZASOBOW_OFFERS o
       where o.CRM_LISTA_ZASOBOW_ID in({$sqlTypeIdList})
-    --		and o.A_STATUS not in ('DELETED')
+        and (o.A_STATUS is null or o.A_STATUS not in ('DELETED'))
         and o.ID_PROJECT = :id_project
         and o.COMPANIES_ID = :id_company
         and o.RESOURCE_UNIT_TYPE != 'ROBOCIZNA'
-        and o.OFFER_PRICE_PER_RESOURCE_UNIT > 0
+        and o.OFFER_PRICE_PER_RESOURCE_UNIT >= 0
     ");
     $sth->bindValue(':id_project', $idProject, PDO::PARAM_INT);
     $sth->bindValue(':id_company', $idCompany, PDO::PARAM_INT);
@@ -61,11 +61,11 @@ class ProjectKosztorysCennik {
         , o.REQUIRED_RESOURCE_UNITS as quantity
       from CRM_LISTA_ZASOBOW_OFFERS o
       where o.CRM_LISTA_ZASOBOW_ID in({$sqlTypeIdList})
-    --		and o.A_STATUS not in ('DELETED')
+        and (o.A_STATUS is null or o.A_STATUS not in ('DELETED'))
         and o.ID_PROJECT = :id_project
         and o.COMPANIES_ID = :id_company
         and o.RESOURCE_UNIT_TYPE = 'ROBOCIZNA'
-        and o.OFFER_PRICE_PER_RESOURCE_UNIT > 0
+        and o.OFFER_PRICE_PER_RESOURCE_UNIT >= 0
     ");
     $sth->bindValue(':id_project', $idProject, PDO::PARAM_INT);
     $sth->bindValue(':id_company', $idCompany, PDO::PARAM_INT);
@@ -99,7 +99,7 @@ class ProjectKosztorysCennik {
 				, o.REQUIRED_RESOURCE_UNITS as quantity
 			from CRM_LISTA_ZASOBOW_OFFERS o
 			where o.CRM_LISTA_ZASOBOW_ID in({$sqlTypeIdList})
-    --		and o.A_STATUS not in ('DELETED')
+        and (o.A_STATUS is null or o.A_STATUS not in ('DELETED'))
 				and o.ID_PROJECT = 0
 				and o.COMPANIES_ID = :id_company
 		");
@@ -219,7 +219,7 @@ class ProjectKosztorysCennik {
       from CRM_LISTA_ZASOBOW_OFFERS o
       where o.CRM_LISTA_ZASOBOW_ID = {$sqlIdType}
         and (o.A_STATUS is null or o.A_STATUS not in ('DELETED'))
-        and o.OFFER_PRICE_PER_RESOURCE_UNIT > 0
+        and o.OFFER_PRICE_PER_RESOURCE_UNIT >= 0
         {$sqlFiltrProject}
     ");
     DBG::_('DBG', '>1', 'cennikRaw', $cennikRaw, __CLASS__, __FUNCTION__, __LINE__);

+ 7 - 4
SE/se-lib/Route/ProjektyKosztorysBase.php

@@ -1143,6 +1143,9 @@ SQL_FUN;
 
 		$defCennik = ProjectKosztorysCennik::getDefaultCennik($idCompany);
 		$cennik = ProjectKosztorysCennik::getCennik($idProject, $idCompany);
+		DBG::_('DBG', '>1', "cennik", $cennik, __CLASS__, __FUNCTION__, __LINE__);
+		DBG::_('DBG', '>1', "defCennik", $defCennik, __CLASS__, __FUNCTION__, __LINE__);
+
 		$workCennik = ProjectKosztorysCennik::getWorkCennik($idProject, $idCompany);
 		if (!empty($summaryTypeCost)) {
 			$additionalCosts = array();
@@ -1225,11 +1228,11 @@ SQL_FUN;
 				<?php else : ?>
 					<?php $idType = $typeData['idType']; ?>
 					<?php $defPrice = (!empty($defCennik[$idType]['price']))? $defCennik[$idType]['price'] : 0; ?>
-					<?php $price = (!empty($cennik[$idType]['price']))? $cennik[$idType]['price'] : $defPrice; ?>
+					<?php $price = (!empty($cennik[$idType]) && array_key_exists('price', $cennik[$idType]))? $cennik[$idType]['price'] : $defPrice; ?>
 					<?php
 						$typePrice = 'UNDEFINED';
 						if (!empty($defCennik[$idType]['price'])) $typePrice = 'GLOBAL';
-						if (!empty($cennik[$idType]['price'])) $typePrice = 'PROJECT';
+						if (!empty($cennik[$idType]) && array_key_exists('price', $cennik[$idType])) $typePrice = 'PROJECT';
 					?>
 					<?php $workPrice = (!empty($workCennik[$idType]['price']))? $workCennik[$idType]['price'] : 0; ?>
 					<?php $uwagi = (!empty($cennik[$idType]['notes']))? $cennik[$idType]['notes'] : '';// TODO: uwagi ?>
@@ -1465,6 +1468,7 @@ SQL_FUN;
 		}
 		var id = payload.body.id;
 		var price = payload.body.price;
+		<?php if (DBG::isActive()) : ?>console.log('event p5UIBtnAjax:Kosztorys:updateProjektyOferta:ajaxLoaded price', price, 'PL', p5Utils__pricePrintPL(price));<?php endif; ?>
 		var unitType = payload.body.unitType;
 		var label = payload.body.label || '['+id+']';
 		if ('robocizna' != unitType) label += '<br><i style="color:#999">(cena domyślna: ' + p5Utils__pricePrintPL(payload.body.defaultPrice) + ')</i>';
@@ -1474,8 +1478,7 @@ SQL_FUN;
 			animation: false,
 			input: 'text',
 			inputPlaceholder: '0,00',
-			inputValue: p5Utils__pricePrintPL(price),
-			// inputAttributes: {'step': '0.01'},
+			inputValue: (0 === price) ? price : p5Utils__pricePrintPL(price),
 			showCancelButton: true,
 			confirmButtonText: 'Zapisz',
 			showLoaderOnConfirm: true,

+ 1 - 1
SE/se-lib/tmpl/_layout_gora.php

@@ -217,7 +217,7 @@ function p5Utils__pricePrintPL(value, defaultValue) {
 
 function p5Utils__pricePrintFormat(value, defaultValue, decPoint, thousands_sep) {
 	if (undefined === defaultValue) defaultValue = '';
-	if (!value) return defaultValue;
+	if (!value && value !== 0 && value !== '0') return defaultValue;
 	if ("number" === typeof value) {
 	} else if ("string" === typeof value) {
 		value = p5Utils__parseFloatOrZero(value);