Browse Source

fix schema errors in ajax request - KosztorysSchema::getSchema

Piotr Labudda 9 years ago
parent
commit
c1e24d8d5f

+ 6 - 4
SE/se-lib/ProjectKosztorysSchema.php

@@ -1,8 +1,10 @@
 <?php
 <?php
 
 
+Lib::loadClass('UI');
+
 class ProjectKosztorysSchema {
 class ProjectKosztorysSchema {
 
 
-  public static function getSchema() {
+  public static function getSchema($showErrors = false) {
     static $_schema = null;
     static $_schema = null;
 		if (null !== $_schema) return $_schema;
 		if (null !== $_schema) return $_schema;
     /*
     /*
@@ -110,11 +112,11 @@ class ProjectKosztorysSchema {
 				if (('INNE' == $z['TYPE']) or ('TYP_KOSZTU' == $z['TYPE'])) {
 				if (('INNE' == $z['TYPE']) or ('TYP_KOSZTU' == $z['TYPE'])) {
 				} else if ('TABELA' == $z['TYPE']) {
 				} else if ('TABELA' == $z['TYPE']) {
 				} else {
 				} else {
-					SE_Layout::alert('warnig', "BUG: unimplemented type '{$z['TYPE']}' for zasob nr: {$z['ID']}");
+					if ($showErrors) UI::alert('warnig', "BUG: unimplemented type '{$z['TYPE']}' for zasob nr: {$z['ID']}");
 				}
 				}
 			}
 			}
 			DBG::_('DBG', '>1', "config", $conf, __CLASS__, __FUNCTION__, __LINE__);
 			DBG::_('DBG', '>1', "config", $conf, __CLASS__, __FUNCTION__, __LINE__);
-			{// validate schema - show warnings
+			if ($showErrors) {// validate schema - show warnings
 				foreach ($conf['layer'] as $layer) {
 				foreach ($conf['layer'] as $layer) {
 					try {
 					try {
 						if (empty($layer['tabela_id'])) throw new Exception("brak zdefiniowanego aliasa do tabeli dla warstwy {$layer['label']}");
 						if (empty($layer['tabela_id'])) throw new Exception("brak zdefiniowanego aliasa do tabeli dla warstwy {$layer['label']}");
@@ -125,7 +127,7 @@ class ProjectKosztorysSchema {
 							default: throw new Exception("Nieznana jednostka '{$layer['jednostka']}' dla warstwy  [{$layer['tabela_id']}] {$layer['label']}");
 							default: throw new Exception("Nieznana jednostka '{$layer['jednostka']}' dla warstwy  [{$layer['tabela_id']}] {$layer['label']}");
 						}
 						}
 					} catch (Exception $e) {
 					} catch (Exception $e) {
-						SE_Layout::alert('warning', $e->getMessage());
+						UI::alert('warning', $e->getMessage());
 					}
 					}
 				}
 				}
 			}
 			}

+ 2 - 2
SE/se-lib/Route/ProjektyKosztorysBase.php

@@ -921,7 +921,7 @@ SQL_FUN;
 		if ('1' == V::get('save_offer', '', $_POST)) {
 		if ('1' == V::get('save_offer', '', $_POST)) {
 			$this->saveDefaultOffer($_POST);
 			$this->saveDefaultOffer($_POST);
 		}
 		}
-		$schema = ProjectKosztorysSchema::getSchema();
+		$schema = ProjectKosztorysSchema::getSchema($showErrors = true);
 		if (empty($schema['config']['type'])) throw new Exception("Schema error - brak zdefiniowanych typów");
 		if (empty($schema['config']['type'])) throw new Exception("Schema error - brak zdefiniowanych typów");
 		$cennik = ProjectKosztorysCennik::getDefaultCennik($idCompany);
 		$cennik = ProjectKosztorysCennik::getDefaultCennik($idCompany);
 		//DBG::_(true, true, "cennik", $cennik, __CLASS__, __FUNCTION__, __LINE__);
 		//DBG::_(true, true, "cennik", $cennik, __CLASS__, __FUNCTION__, __LINE__);
@@ -1102,7 +1102,7 @@ SQL_FUN;
 		$projCosts = V::get('projCosts', array(), $args);
 		$projCosts = V::get('projCosts', array(), $args);
 		$showPrices = ! V::get('hidePrices', 0, $args);
 		$showPrices = ! V::get('hidePrices', 0, $args);
 
 
-		$schema = ProjectKosztorysSchema::getSchema();
+		$schema = ProjectKosztorysSchema::getSchema($showErrors = true);
 		$conf = $schema['config'];
 		$conf = $schema['config'];
 		DBG::_('DBG', '>1', "conf", $conf, __CLASS__, __FUNCTION__, __LINE__);
 		DBG::_('DBG', '>1', "conf", $conf, __CLASS__, __FUNCTION__, __LINE__);
 
 

+ 1 - 1
SE/se-lib/Route/UrlAction/ProjektyKosztorys.php

@@ -41,7 +41,7 @@ class Route_UrlAction_ProjektyKosztorys extends Route_ProjektyKosztorysBase {
 		$priceEditJs = (1 != V::get('_print', '', $_GET)) ? Request::getPathUri() . "index.php?_route=UrlAction_ProjektyKosztorys&_task=updateProjektyOfertaAjax&idProject={$idProject}" : false;
 		$priceEditJs = (1 != V::get('_print', '', $_GET)) ? Request::getPathUri() . "index.php?_route=UrlAction_ProjektyKosztorys&_task=updateProjektyOfertaAjax&idProject={$idProject}" : false;
 		$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($showErrors = true);
 
 
 		$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__);