Pārlūkot izejas kodu

Funkcje binderowe do GIS glownie

Arkadiusz Binder 11 gadi atpakaļ
vecāks
revīzija
5023999e05

+ 8 - 4
SE/se-lib/Core/Database/Mysql.php

@@ -139,7 +139,7 @@ class Core_Database_Mysql extends Core_Database {
 		
 		$col=self::GET_DB_OBJ_cols($table);
 		$sql='select '.implode(',', $col).' from `'.$table.'` where  unix_timestamp(`'.$date_column.'`) >  '.$timestamp.'  and  unix_timestamp(`'.$date_column.'`) < '.$now.' ';
-		$sql='select '.implode(',', $col).' from `'.$table.'` where  unix_timestamp(`'.$date_column.'`) >  '.$timestamp.' '; //TODO trzeba zmienic jak piotr zmieni ze A_RECORD_UPDATE_DATE sa trzymane w UTC
+//		$sql='select '.implode(',', $col).' from `'.$table.'` where  unix_timestamp(`'.$date_column.'`) >  '.$timestamp.' '; //TODO trzeba zmienic jak piotr zmieni ze A_RECORD_UPDATE_DATE sa trzymane w UTC
 
 			//if(empty($timestamp)) 
 			$sql.=' or `'.$date_column.'` is null';
@@ -413,6 +413,7 @@ class Core_Database_Mysql extends Core_Database {
 						//echo $Struct->Type;
 						if(strstr($Struct->Type,"multipoint"))  $col[]=' AsWKT(`'.$Field.'`) as "'.$Field.'"';
 						else if(strstr($Struct->Type,"linestring")) $col[]=' AsWKT(`'.$Field.'`) as "'.$Field.'"';
+						else if(strstr($Struct->Type,"multilinestring")) $col[]=' AsWKT(`'.$Field.'`) as "'.$Field.'"';
 						else if(strstr($Struct->Type,"polygon")) $col[]=' AsWKT(`'.$Field.'`) as "'.$Field.'"';
 						else if(strstr($Struct->Type,"multipolygon")) $col[]=' AsWKT(`'.$Field.'`) as "'.$Field.'"';
 
@@ -424,10 +425,10 @@ class Core_Database_Mysql extends Core_Database {
 	 *
 	 */
 	
-	function MAKE_DB_OBJ($table,$obj) {
+	function MAKE_DB_OBJ($table,$obj,$dieonerror=null) {
 		$structure=self::describe_table_value($table); //todo to cache optimize
 		foreach(get_object_vars($obj) as $k=>$v) {
-			if(($structure[$k]->Type=='multipoint')||($structure[$k]->Type=='linestring')||($structure[$k]->Type=='polygon')||($structure[$k]->Type=='multipolygon')) {
+			if(($structure[$k]->Type=='multipoint')||($structure[$k]->Type=='linestring')||($structure[$k]->Type=='polygon')||($structure[$k]->Type=='multipolygon')||($structure[$k]->Type=='multilinestring')) {
 				if(empty($v)) {
 					unset($k);
 					unset($v);
@@ -564,7 +565,10 @@ class Core_Database_Mysql extends Core_Database {
 		$this->query($sql);
 
 		if ($this->has_errors()) {
-			//echo'<pre style="max-height:200px;overflow:auto;border:1px solid red;text-align:left;">db errors: (' . __CLASS__ . '::' . __FUNCTION__ . ':' . __LINE__ . '): ';print_r($this->get_errors());echo'</pre>';
+			if(!empty($dieonerror)) {
+			  echo'<pre style="max-height:200px;overflow:auto;border:1px solid red;text-align:left;">db errors: (' . __CLASS__ . '::' . __FUNCTION__ . ':' . __LINE__ . '): ';print_r($this->get_errors());echo'</pre>';
+			  DEBUG_S(-3,'Bledne zapytanie sql',$sql,__FILE__,__FUNCTION__,__LINE__);
+			}
 		}
 
 		$ret_id = $this->insert_id();

+ 14 - 3
SE/se-lib/Core/Database/Pgsql.php

@@ -125,7 +125,10 @@ class Core_Database_Pgsql extends Core_Database {
     
     CASE 
      when pg_catalog.format_type(f.atttypid,f.atttypmod) like 'double precision' then 'double(8,2)'
+     when pg_catalog.format_type(f.atttypid,f.atttypmod) like 'numeric' then 'double(8,2)'
+
      when pg_catalog.format_type(f.atttypid,f.atttypmod) like 'smallint' then 'int(11)'
+     when pg_catalog.format_type(f.atttypid,f.atttypmod) like 'bigint' then 'int(11)'
      when pg_catalog.format_type(f.atttypid,f.atttypmod) like 'integer' then 
        ( select cast(replace(pg_catalog.format_type(f.atttypid,f.atttypmod), 'integer', 'int(11)') as char(255)) )
      when pg_catalog.format_type(f.atttypid,f.atttypmod) like '%character varying%'   then 
@@ -197,7 +200,7 @@ WHERE c.relkind = 'r'::char
 		
 	//	echo "<pre>".$sql."</pre>";
 		$result = $this->query($sql) or self::die1('\nProblem z '.$sql);
-		DEBUG_S(-3,'describe table '.$table,array($sql,$res,$this->num_rows),__FILE__,__FUNCTION__,__LINE__);
+		DEBUG_S(-3,'describe table '.$table,array($sql,$result,$this->num_rows),__FILE__,__FUNCTION__,__LINE__);
 		
 		return $result;
 	}
@@ -354,7 +357,7 @@ FROM information_schema.triggers
 			self::query($sql) or die1($sql);
 			$sql='alter table "'.$table.'" add "'.$column.'" "'.$table.'_'.$column.'"';
 			self::query($sql) or die1($sql);
-		} 	else if(strstr($type, "datetime('")) {
+		} 	else if(strstr($type, "datetime")) {
 			$sql='alter table "'.$table.'" add "'.$column.'" timestamp without time zone ';
 			self::query($sql) or die1($sql);
 		} else {
@@ -1350,7 +1353,7 @@ FROM information_schema.triggers
 	 * 
 	 * TODO: sprawdzac czy w hist mozna odczytac aktualny stan, jesli nie to dodac caly rekord do HIST, jako 'procesy-fix-hist-data'
 	 */
-	public function UPDATE_OBJ($table, $sql_obj) {
+	public function UPDATE_OBJ($table, $sql_obj,$timestamp=null) {
 		$structure=self::describe_table_value($table);
 		$primary=self::show_index_value($table);
 
@@ -1388,6 +1391,9 @@ FROM information_schema.triggers
 		$admin_col []= 'A_RECORD_CREATE_AUTHOR';
 		// ...
 //		$sql_obj->A_RECORD_UPDATE_DATE = date('Y-m-d H:i');
+		if(!empty($timestamp))  //fixed timestamp option TODO @2015-01-not working due to trigger?
+			$sql_obj->A_RECORD_UPDATE_DATE = $timestamp;	
+		else 
 		$sql_obj->A_RECORD_UPDATE_DATE = self::get_current_timestamp();
 
 		$sql_obj->A_RECORD_UPDATE_AUTHOR = User::getName();
@@ -1466,7 +1472,12 @@ FROM information_schema.triggers
 				else $v = $v;
 			} else if(trim($structure[$k]->Type)=='datetime') {
 				if(empty($v)) $v='null';
+				else if(strstr($v,'-00')) $v="'".str_replace("-00","-01",$v)."'" ;
 				else $v = "'".$v."'::timestamp";
+			} else if(trim($structure[$k]->Type)=='date') {
+				if($v=='0000-00-00') $v='null';
+				else if(strstr($v,'-00')) $v="'".str_replace("-00","-01",$v)."'" ;
+				else $v = "'".$v."'";
 			} else if (strtoupper($v) == 'NOW()') {
 				$v = 'NOW()';
 			} else if (strtoupper($v) == 'NULL' && substr($table, -5) != '_HIST') {

+ 133 - 20
SE/superedit-GIS_OPT_STRUCTURES2.php

@@ -5,6 +5,7 @@
 
 include_once('se-lib/DB_Dump.php');
 include_once('se-lib/UsersHelper.php');
+Lib::Loadclass('Nodes_path_analys');
 
 
 
@@ -235,6 +236,9 @@ class GIS_OPT_STRUCTURES2 {
 		$this->tables->$src_table->obj_cursor[$obj]->x=$this->tables->$src_table->cursor->x;
 		$this->tables->$src_table->obj_cursor[$obj]->y=$this->tables->$src_table->cursor->y;
 	}
+	function get_obj_cursor_layer($src_table,$obj,$xy) {
+		return $this->tables->$src_table->obj_cursor[$obj]->$xy;
+	}
 	
 	function set_obj_size_width($src_table,$obj,$width) {
 		$this->tables->$src_table->obj_width[$obj]=$width+20;
@@ -265,7 +269,7 @@ class GIS_OPT_STRUCTURES2 {
 	function set_obj_coords_by_parent($parent_table,$parent_obj,$src_table,$obj) {
 		echo "\n// set_obj_coords_by_parent  (".$parent_table.",".$parent_obj.",".$src_table.",".$obj.") ";
 		$this->tables->$src_table->obj_cursor[$obj]->x=$this->tables->$parent_table->obj_cursor[$parent_obj]->x+10;
-		$this->tables->$src_table->obj_cursor[$obj]->y=$this->tables->$parent_table->obj_cursor[$parent_obj]->y+10;
+		$this->tables->$src_table->obj_cursor[$obj]->y=$this->tables->$parent_table->obj_cursor[$parent_obj]->y+15;
 		echo " - i setted ".$this->tables->$parent_table->obj_cursor[$parent_obj]->x."/ ".$this->tables->$parent_table->obj_cursor[$parent_obj]->y;
 	}
 	
@@ -281,13 +285,13 @@ class GIS_OPT_STRUCTURES2 {
 			echo " - ".$child_table;
 			$count+=count($child_table_arr)*20;
 
-			if(strlen(self::get_obj_name($src_table,$obj)) > $width) $width=strlen(self::get_obj_name($src_table,$obj))*5;
+			if(strlen(self::get_obj_name($src_table,$obj)) > $width) $width=strlen(self::get_obj_name($src_table,$obj))*6; //TODO trzeba przesunac obiekt obok
 		}
 			$count_local=count($this->tables->$src_table->childs[$obj]->objects)*20;
 		
 		if($width<100) $width=100;   
 		if($count_local>$count) $count=$count_local;
-		$count=$count+15+self::get_layer_deepth($src_table)*15;
+		$count=$count+15+self::get_layer_deepth($src_table)*20;
 //		$this->tables->$src_table->min_y_size[$obj]=$count;
 		
 		self::set_obj_min_y_size($src_table,$obj,$count);
@@ -310,14 +314,33 @@ class GIS_OPT_STRUCTURES2 {
 	
 	//funkcja do zwracania pierwszego obiektu wg roznych kryteriow : najmniej_powiazan, powiazanie z poprzednim, etc...
 	function get_next_obj($src_table,$situation) {
-		echo "\n /* 313: Situation <-- ";
+		echo "\n /* 313: Situation <-- for  ".$src_table;
 		print_r($situation);
 		print_r($this->get_next_obj);
 		echo "*/\n";
 		
+		$ret=self::get_next_obj_by_path($src_table);
+		if(!empty($ret)) { $this->get_next_obj->last_obj=$ret;  return $ret; }
+		//die('327 Skonczyla sie nowa sciezka uzyc/przeliczyc!');
+		
+		
+		echo "\n //322 Skonczyla sie sciezka, nowa przeliczamy";
+		self::analyze_arrange_paths($src_table,self::get_next_obj_unlayed($src_table));
+		self::make_offset_layer_coords_by_fit_new_path($src_table);
+
+		$ret=self::get_next_obj_by_path($src_table);
+		if(!empty($ret)) {
+			 $this->get_next_obj->last_obj=$ret;
+			 if(!empty($ret)) return $ret;
+			 }
+		
+		
+		
 		if($situation->count>1) {
 			if($situation->min_links==0) $ret=$situation->min_links_id;
 			else if($situation->min_links==1) { echo "\n// 320:Sytuacja min_links==1";
+				//bierzemy pod uwage rozmieszczenie sciezek - sprobujemy analizowac tylko te, ktore sa wyswietlone
+				
 				if(isset($this->get_next_obj->last_obj)) {
 					if(isset($this->get_next_obj->last_obj_count)) {
 						
@@ -343,12 +366,77 @@ class GIS_OPT_STRUCTURES2 {
 		
 
 		if(!isset($ret)) $ret=$situation->id;
+		
 		return $ret;	
 
 		
 	}
 	
 	
+	function analyze_arrange_paths($src_table,$unlayed) {
+		//do szukania najdluzszej sciezki
+		echo "\n /* 370 f.analyze_arrange_paths unlayed";
+			print_r($unlayed);
+			echo "*/";
+		$w = new Nodes_path_analys;
+		$sciezki=$w->trasuj_wezly($this->tables->$src_table->links,$unlayed);
+		$najdluzsza=$w->najdluzsza_sciezka();
+		$this->tables->$src_table->Nodes_path_analys->paths=$sciezki;
+		$this->tables->$src_table->Nodes_path_analys->longest=$najdluzsza;
+		//print_r($sciezki);
+	}
+	
+	
+	function make_offset_layer_coords_by_fit_new_path($src_table) {
+		//przyklad 
+		//stara sceizka 41,23,24,31 
+		//nowa sciezka 25,28,27,32,29,30
+		//wezel 25 ma powiazanie z 24, zatem sciezka nowa powinna wystartowac pod namalowanym wezlem 24
+		//offset_layer_coords(,,)
+		echo "\n /* 392: tables->".$src_table.">layed ";
+		print_r($this->tables->$src_table->layed);
+		//print_r($this->tables->$src_table->obj_cursor);
+
+		//szukam do ktorego moge sie przylozyc wezla na podstawie sciezki
+		$najdluzsza=$this->tables->$src_table->Nodes_path_analys->longest;
+		foreach($this->tables->$src_table->Nodes_path_analys->paths[$najdluzsza] as $wezel) {
+		//	echo " 402: sprawdzam:".$wezel;
+			foreach($this->tables->$src_table->links->$wezel as $link=>$link_) {
+		//		echo " sprawdzam:".$link;
+				if(isset($this->tables->$src_table->layed[$link]))  {
+					echo "\n 403 znalazlem wezel do podl ".$link." TODO jest wiecej powiazan. Paper used=>y ".$this->paper_used->y; //TODO trzeba wiedziec jakie jest ulozenie max kursora etc...
+					$height=self::get_obj_size_by_child_recurs($src_table,$wezel);
+					echo "\n nowe dla(".$link.") xy:(".$this->tables->$src_table->layed[$link]->start_x."+100 y:".$this->tables->$src_table->layed[$link]->start_y."+".$this->tables->$src_table->layed[$link]->height." ";
+					$this->tables->$src_table->layed[$link]->start_y=+$height;
+					self::set_layer_coords($src_table,$this->tables->$src_table->layed[$link]->start_x+200+self::notify_lay_nextrow()*150,$this->paper_used->y+50);
+					//self::notify_layed_obj_xyh($src_table,$link,$this->tables->$src_table->layed[$link]->start_x+100,$this->tables->$src_table->layed[$link]->start_y+$this->tables->$src_table->layed[$link]->height+50);
+					print_r($this->tables->$src_table->layed);
+					echo "*/";
+					return ;
+				}
+			}
+			echo " 402:".$wezel;
+		}
+		echo "najdluzsza:".$najdluzsza." */";		
+		
+		
+	}
+	
+	
+	function get_next_obj_by_path($src_table) {
+		//proba skorzystania z pierwszej sciezki
+		$longest=$this->tables->$src_table->Nodes_path_analys->longest;
+		foreach($this->tables->$src_table->Nodes_path_analys->paths[$longest] as $ret) {
+			foreach(self::get_next_obj_unlayed($src_table) as $obj) {
+			echo "\n //322: get_next_obj_unlayed testuje  ".$obj." dla ".$src_table;
+						if($obj==$ret)	{ 
+				echo "\n //327: zwracam ze sciezki ".$ret;
+				return $ret; 
+				}
+			}
+			
+		}
+	}
 	
 	
 	function analyze_arrange_situation($src_table) {
@@ -409,7 +497,7 @@ class GIS_OPT_STRUCTURES2 {
 			 	}
 			 
 			}
-		 
+			
 
 		 	$ret->min_links=$min_links;
 		 	$ret->max_links=$max_links;
@@ -420,6 +508,7 @@ class GIS_OPT_STRUCTURES2 {
 		 	$ret->count=count($cnt);
 			$ret->id=$cnt[0];
 			
+			echo "\n/* Analiza wezlow do rozmieszczenia" ; print_r($ret); echo "*/\n";
 			return $ret;
 			
 		
@@ -450,19 +539,21 @@ class GIS_OPT_STRUCTURES2 {
 	
 
 				//echo "\nvar ".$src_table."_".$obj." = new joint.shapes.basic.Rect({
+				$height=self::get_obj_size_by_child_recurs($src_table,$obj);
+				$width=self::get_obj_size_width($src_table,$obj);
 				echo "\nvar ".$src_table."_".$obj." = new joint.shapes.devs.".self::get_type_table($src_table)."({
 				
 
-				position: { x: ".$this->tables->$src_table->obj_cursor[$obj]->x.", y: ".$this->tables->$src_table->obj_cursor[$obj]->y." },
-				size: { width: ".self::get_obj_size_width($src_table,$obj).", height: ".self::get_obj_size_by_child_recurs($src_table,$obj)." }
+				position: { x: ".self::get_obj_cursor_layer($src_table,$obj,'x').", y: ".self::get_obj_cursor_layer($src_table,$obj,'y')." },
+				size: { width: ".$width.", height: ".$height." }
 				, attrs: {
-				    text: { text: '".self::get_obj_name($src_table,$obj).$obj."', fill: 'white' , 'y-alignment': 'top', 'x-alignment': 'left'  } ,
+				    text: { text: '".self::get_obj_name($src_table,$obj).$obj."', fill: 'black' , 'y-alignment': 'top', 'x-alignment': 'left'  } ,
 				    'inPorts circle': { fill: 'PaleGreen' }
 				  } , label: { text: 'Dupa' }
 
 				".self::get_ports_for_obj($src_table,$obj)."				  
 				});\n";
-			self::notify_layed_object($src_table,$obj);
+			self::notify_layed_object($src_table,$obj,self::get_obj_cursor_layer($src_table,$obj,'x'),self::get_obj_cursor_layer($src_table,$obj,'y'),$height,$width);
 			self::lay_object_child($src_table,$obj);
 	}
 	
@@ -470,8 +561,25 @@ class GIS_OPT_STRUCTURES2 {
 		  return in_array($src_table."_".$obj, $this->cells);
 	}
 	
-	function notify_layed_object($src_table,$obj) {
+	function notify_layed_object($src_table,$obj,$start_x,$start_y,$height,$width) {
 		$this->cells[]=$src_table."_".$obj;
+		if(isset($this->paper_used)) {
+			if($this->paper_used->y<$start_y+$height) $this->paper_used->y=$start_y+$height;
+		} else $this->paper_used->y=$start_y+$height;
+		self::notify_layed_obj_xyh($src_table,$obj,$start_x,$start_y,$height);
+	}
+	
+	function notify_lay_nextrow() {
+		if(isset($this->paper_used->rows))	$this->paper_used->rows++;
+		else $this->paper_used->rows=1;
+		return $this->paper_used->rows;
+		
+	}
+	
+	function notify_layed_obj_xyh($src_table,$obj,$start_x,$start_y,$height=null) {
+		$this->tables->$src_table->layed[$obj]->start_x=$start_x;
+		$this->tables->$src_table->layed[$obj]->start_y=$start_y;
+		if(isset($height)) $this->tables->$src_table->layed[$obj]->height=$height;
 	}
 	
 	function lay_object_child($src_table,$obj) {
@@ -482,7 +590,7 @@ class GIS_OPT_STRUCTURES2 {
 					self::calculate_obj_size_by_child_recurs($child_table,$child_id);
 					self::set_obj_coords_by_parent($src_table,$obj,$child_table,$child_id);
 					self::set_obj_size_width_by_parent($src_table,$obj,$child_table,$child_id,array('ratio'=>0.3) );
-					self::lay_object($child_table,$child_id,$this->tables->$src_table->obj_cursor[$obj]->x,$this->tables->$src_table->obj_cursor[$obj]->y);
+					self::lay_object($child_table,$child_id);
 				} else if($this->tables->$child_table->set_type_table=='Ports') {
 				//	echo "\n //282 Trafilem na Ports";
 				}
@@ -576,6 +684,9 @@ class GIS_OPT_STRUCTURES2 {
 		DEBUG_S(-3,'DEBUG_ports_obj',$this->ports_obj,__FILE__,__FUNCTION__,__LINE__);
 		DEBUG_S(-3,'DEBUG_ports_tables',$this->ports_tables,__FILE__,__FUNCTION__,__LINE__);
 		DEBUG_S(-3,'ports_to_add_connect_link',$this->ports_to_add_connect_link,__FILE__,__FUNCTION__,__LINE__);
+		DEBUG_S(-3,'opt_przelacznice_mufy->links',$this->tables->opt_przelacznice_mufy->links,__FILE__,__FUNCTION__,__LINE__);
+		DEBUG_S(-3,'opt_lokalizacje->links',$this->tables->opt_lokalizacje->links,__FILE__,__FUNCTION__,__LINE__);
+		DEBUG_S(-3,'opt_przelacznice_mufy->Nodes_path_analys',$this->tables->opt_przelacznice_mufy->Nodes_path_analys,__FILE__,__FUNCTION__,__LINE__);
 
 	}
 
@@ -627,8 +738,6 @@ var connect = function(source, sourcePort, target, targetPort) {
 		//	self::get_next_obj($src_table,null,array('less_connections'));
 		$situation=self::analyze_arrange_situation($src_table);
 		
-	//	print_r($situation);
-		
 		while($obj=self::get_next_obj($src_table,$situation)) {
 	
 			echo "\n//631:: wzialem ID ".$obj;
@@ -645,7 +754,7 @@ var connect = function(source, sourcePort, target, targetPort) {
 
 			self::lay_object($src_table,$obj);
 			echo "\n //606: robie offset o ".self::get_obj_size_width($src_table,$obj)." dla obj ".$obj." bo x:".$this->tables->$src_table->obj_cursor[$obj]->x ." a width:".self::get_obj_size_width($src_table,$obj);
-			self::offset_layer_coords($src_table,self::get_obj_size_width($src_table,$obj)+100,0);
+			self::offset_layer_coords($src_table,self::get_obj_size_width($src_table,$obj)+150,0);
 			$situation=self::analyze_arrange_situation($src_table);
 
 		}
@@ -727,7 +836,7 @@ function GIS_OPT_STRUCTURES2() {
 	 
 	 
 	 //$wezly=$cp->get_opt_objects('opt_przelacznice_mufy','id_0','Nazwa','id_wezel','Rozdzielcza_wezly','id_opt_lokalizacja','opt_lokalizacje',"where \"Nazwa\" like '%test%'");
-	 $wezly=$cp->get_opt_objects('opt_przelacznice_mufy','id_0','Nazwa','id_wezel','Rozdzielcza_wezly','id_opt_lokalizacja','opt_lokalizacje',"where \"id_0\" in(23,24,32,31,25,28,27) ");
+	 $wezly=$cp->get_opt_objects('opt_przelacznice_mufy','id_0','Nazwa','id_wezel','Rozdzielcza_wezly','id_opt_lokalizacja','opt_lokalizacje',"where \"id_0\" in(23,24,32,31,25,28,27,41) ");
 
 
 	 $cp->set_type_table('opt_przelacznice_mufy','Coupled');
@@ -744,10 +853,10 @@ function GIS_OPT_STRUCTURES2() {
 	 $wlokna2=$cp->get_opt_objects('opt_wlokna','id',null,null,null,'id_spaw_b','opt_spawy');
 
 	
-	 $spawy_b=$cp->get_opt_objects_parent('opt_spawy','id_0',null,null,null,'id_tacka','opt_tacki','1=1','opt_wlokna','id_spaw_b','id'); //chce znalezc te sprawy ktore sa w wloknach jako B
-	 $spawy_b2=$cp->get_opt_objects_parent('opt_spawy','id_0',null,null,null,'id_tacka','opt_tacki','1=1','opt_wlokna','id_spaw_a','id'); //chce znalezc te sprawy ktore sa w wloknach jako B
+	 $spawy_b=$cp->get_opt_objects_parent('opt_spawy','id_0',null,null,null,'id_tacka','opt_tacki','1=1','opt_wlokna','id_spaw_b','id'); //try to find splices which are in fibres as B
+	 $spawy_b2=$cp->get_opt_objects_parent('opt_spawy','id_0',null,null,null,'id_tacka','opt_tacki','1=1','opt_wlokna','id_spaw_a','id'); //try to find splices which are in fibres as A
 
-	 $tacki_b=$cp->get_opt_objects_parent('opt_tacki','id_0',null,null,null,'id_przelac','opt_przelacznice_mufy','1=1','opt_spawy','id_tacka','id_0'); //chce znalezc te sprawy ktore sa w wloknach jako B	
+	 $tacki_b=$cp->get_opt_objects_parent('opt_tacki','id_0',null,null,null,'id_przelac','opt_przelacznice_mufy','1=1','opt_spawy','id_tacka','id_0'); //try to find splices which are in fibres as B
 	 $wezly_b=$cp->get_opt_objects_parent('opt_przelacznice_mufy','id_0','Nazwa','id_wezel','Rozdzielcza_wezly','id_opt_lokalizacja','opt_lokalizacje','1=1','opt_tacki','id_przelac','id_0');	 
 
 	// $cp->layer_arrange(1,array('opt_przelacznice_mufy'));
@@ -768,7 +877,11 @@ function GIS_OPT_STRUCTURES2() {
 	 */
 
 
-	 	 $cp->find_connect_paths('opt_przelacznice_mufy');
+	 	 $cp->find_connect_paths('opt_lokalizacje');
+	 	 echo "<pre>";
+	 	 $cp->analyze_arrange_paths('opt_przelacznice_mufy'); //analizuje jakie sa sciezki glowne i ustalam dla nich rozmieszczenie
+	 	 echo "</pre>";
+//	 	 $cp->find_connect_paths('opt_przelacznice_mufy');
 		 $cp->invert_layer_deepth();
 
 	 //	 $cp->arrange_objects_layer('opt_przelacznice_mufy');
@@ -779,7 +892,7 @@ function GIS_OPT_STRUCTURES2() {
 
 	 $cp->to_html('opt_przelacznice_mufy');
 	 
-	 
+	 $cp->DEBUG('opt_lokalizacje');
 	 $cp->DEBUG('opt_przelacznice_mufy');	 $cp->DEBUG('opt_spawy');
 	 $cp->DEBUG('opt_tacki');
 	 $cp->DEBUG('opt_spawy');

+ 1 - 1
SE/superedit-SQIX_STRUCTURE_DB_SYNC.php

@@ -287,7 +287,7 @@ $config_base_structure=".config_base_structure.php";
 						 
 
 //! set tables used to generate main structure
-$TABLES_STRUCTURE=array('SALES_PLAN','SALES_PLAN_HIST','ITEM_LINK_TYPES','ITEM_LINK_TYPES_HIST','ITEM_LINKS','ITEM_LINKS_HIST','TEST_PERMS','TEST_PERMS_HIST','DEVICES','_CRM_PROCES_INIT_STATS','_CRM_PROCES_USER_STATS_wiev','BUILDINGS','BUILDINGS_HIST','SES_VOIP_A','SES_VOIP_A_HIST','SES_TV_A','SES_TV_A_HIST','USERS2_DEALS','USERS2_DEALS_HIST','DEALS_TABLE','DEALS_TABLE_HIST','USERS2_MARKETING','USERS2_MARKETING_HIST','IN7_MK_BAZA_DYSTRYBUCJI','IN7_MK_BAZA_DYSTRYBUCJI_HIST','TELBOXES','TELBOXES_HIST','NETWORKS_SERVERS','NETWORKS_SERVERS_HIST','ADMIN_USERS','ADMIN_USERS_HIST','CRM_IMPORT_TRANSLATE','IN7_PRODUKTY_CECHY','IN7_CECHY','CRM_AUTH_PROFILE','CRM_AUTH_PROFILE_HIST','CRM_CZYNNOSCI','CRM_CZYNNOSCI_HIST','CRM_IMAGE','CRM_LISTA_ZASOBOW','CRM_LISTA_ZASOBOW_HIST','CRM_PROCES','CRM_PROCES_HIST','CRM_PROCES_LOG','CRM_PROCES_LOG_HIST','CRM_PRZYPADEK','CRM_TESTY','CRM_TESTY_HIST','CRM_TESTY_ODPOWIEDZI','CRM_TESTY_ODPOWIEDZI_HIST','CRM_TESTY_PYTANIA','CRM_TESTY_PYTANIA_HIST','CRM_TESTY_WYNIKI','CRM_TESTY_WYNIKI_HIST','CRM_WSKAZNIK','CRM_WSKAZNIK_HIST','DEVICES_HIST','IN7_DZIENNIK_KORESP','IN7_DZIENNIK_KORESP_HIST','USERS2_OFFERS','USERS2_OFFERS_HIST','USERS2_OFFERS_GROUPS','USERS2_OFFERS_GROUPS_HIST','USERS2_OFFERS_COSTS','USERS2_OFFERS_COSTS_HIST','USERS2_OFFERS_COSTS','USERS2_OFFERS_COSTS_HIST','SERVICES','SES_USERS2_A','USERS2','KIKE_AUTH_PROFILE','LDAP_GROUPS','CRM_TESTY_PYTANIA_TO_IMPORT','CRM_TESTY_PYTANIA_TO_IMPORT_HIST','PROBLEMS','PROBLEMS_HIST','COMPANIES','COMPANIES_HIST','_CRM_PROCES_STATS_proc_wiev','_CRM_PROCES_STATS','CRM_PROCES_USER_OCENA_OKRES','CRM_PROCES_USER_OCENA_OKRES_HIST');
+$TABLES_STRUCTURE=array('SALES_PLAN','SALES_PLAN_HIST','ITEM_LINK_TYPES','ITEM_LINK_TYPES_HIST','ITEM_LINKS','ITEM_LINKS_HIST','TEST_PERMS','TEST_PERMS_HIST','DEVICES','_CRM_PROCES_INIT_STATS','_CRM_PROCES_USER_STATS_wiev','BUILDINGS','BUILDINGS_HIST','SES_VOIP_A','SES_VOIP_A_HIST','SES_TV_A','SES_TV_A_HIST','USERS2_DEALS','USERS2_DEALS_HIST','DEALS_TABLE','DEALS_TABLE_HIST','USERS2_MARKETING','USERS2_MARKETING_HIST','IN7_MK_BAZA_DYSTRYBUCJI','IN7_MK_BAZA_DYSTRYBUCJI_HIST','TELBOXES','TELBOXES_HIST','NETWORKS_SERVERS','NETWORKS_SERVERS_HIST','ADMIN_USERS','ADMIN_USERS_HIST','CRM_IMPORT_TRANSLATE','IN7_PRODUKTY_CECHY','IN7_CECHY','CRM_AUTH_PROFILE','CRM_AUTH_PROFILE_HIST','CRM_CZYNNOSCI','CRM_CZYNNOSCI_HIST','CRM_IMAGE','CRM_LISTA_ZASOBOW','CRM_LISTA_ZASOBOW_HIST','CRM_PROCES','CRM_PROCES_HIST','CRM_PROCES_LOG','CRM_PROCES_LOG_HIST','CRM_PRZYPADEK','CRM_TESTY','CRM_TESTY_HIST','CRM_TESTY_ODPOWIEDZI','CRM_TESTY_ODPOWIEDZI_HIST','CRM_TESTY_PYTANIA','CRM_TESTY_PYTANIA_HIST','CRM_TESTY_WYNIKI','CRM_TESTY_WYNIKI_HIST','CRM_WSKAZNIK','CRM_WSKAZNIK_HIST','DEVICES_HIST','IN7_DZIENNIK_KORESP','IN7_DZIENNIK_KORESP_HIST','USERS2_OFFERS','USERS2_OFFERS_HIST','USERS2_OFFERS_GROUPS','USERS2_OFFERS_GROUPS_HIST','USERS2_OFFERS_COSTS','USERS2_OFFERS_COSTS_HIST','USERS2_OFFERS_COSTS','USERS2_OFFERS_COSTS_HIST','SERVICES','SES_USERS2_A','USERS2','KIKE_AUTH_PROFILE','LDAP_GROUPS','CRM_TESTY_PYTANIA_TO_IMPORT','CRM_TESTY_PYTANIA_TO_IMPORT_HIST','PROBLEMS','PROBLEMS_HIST','COMPANIES','COMPANIES_HIST','_CRM_PROCES_STATS_proc_wiev','_CRM_PROCES_STATS','CRM_PROCES_USER_OCENA_OKRES','CRM_PROCES_USER_OCENA_OKRES_HIST','_CRM_PROCES_USER_STATS_wiev_to_group');
 $TABLES_STRUCTURE_DATA=array('CRM_PRZYPADEK');
 
 DEBUG_S(-3,'Lacze z bazami param: REMOTE_DB_ZASOB_ID',array($REMOTE_DB_ZASOB_ID,$CNF_ZASOB[$REMOTE_DB_ZASOB_ID]['INTERFACE_ADDR'],$CNF_ZASOB[$REMOTE_DB_ZASOB_ID]['SQL_USER'],$CNF_ZASOB[$REMOTE_DB_ZASOB_ID]['SQL_DATABASE']),__FILE__,__FUNCTION__,__LINE__ );

+ 42 - 5
SE/superedit-SYNC_DATABASES.php

@@ -127,7 +127,7 @@ class SYNC_DATABASES {
 			 // 	DEBUG_S(-3,'this->ids_rem',$this->ids_rem,__FILE__,__FUNCTION__,__LINE__);
 			 // 	DEBUG_S(-3,'this->ids_loc',$this->ids_loc,__FILE__,__FUNCTION__,__LINE__);
 			  	DEBUG_S(-3,'structure',$this->db->describe_table_value($table),__FILE__,__FUNCTION__,__LINE__);
-
+//			  	die('test');
 
 			  //	$ds_loc = new Data_Source($this->local_db_id);
 			  //	$ds_loc->setTable($table);
@@ -140,7 +140,7 @@ class SYNC_DATABASES {
 				  		//nowe rekordy ze zdalnego 
 				  	//	echo "<br> Adding to ".$table." ".print_r($val);
 				  		//DEBUG_S(-3,'Dodajemy to tabeli',$val,__FILE__,__FUNCTION__,__LINE__);
-					  	$last_id=$this->db->ADD_NEW_OBJ($table,$this->db->MAKE_DB_OBJ($table,$val)) or die('Blad dodania: '.$sql);
+					  	$last_id=$this->db->ADD_NEW_OBJ($table,$this->db->MAKE_DB_OBJ($table,$val),'die_on_error') or die('Blad dodania: '.__LINE__." ".$sql);
 						  	$sql='update "'.$table.'" set "'.$loc_key.'"=\''.$last_id.'\' where "'.$rem_key.'"='.$val->$rem_key;
 						  	DEBUG_S(-3,'notified new obj to rem',$sql,__FILE__,__FUNCTION__,__LINE__);
 						  	$this->gdb->query($sql);
@@ -157,7 +157,7 @@ class SYNC_DATABASES {
 					  	
 				  	}
 			  	}
-			  	DEBUG_S(-3,'Jade z LOCAL do REM',null,__FILE__,__FUNCTION__,__LINE__);
+			  	DEBUG_S(-3,'Jade z LOCAL(se) do REM(gis)',null,__FILE__,__FUNCTION__,__LINE__);
 			  	//insert lokalnych nowych do zdalnego
 			  	foreach($this->ids_loc as $ind=>$val) {
 				  	if(!($val->$rem_key)) {
@@ -203,16 +203,53 @@ class SYNC_DATABASES {
 $sd = new SYNC_DATABASES;
 $sd->set_local_db_id(36);
 $sd->set_remote_db_id(13102);
+//$sd->set_table_to_sync('opt_tuby');
+
+//$sd->set_table_to_sync('opt_porty');
+
+
+
+//$sd->set_table_to_sync('opt_przelacznice_mufy');
+//$sd->set_table_to_sync('opt_tacki');
+//$sd->set_table_to_sync('opt_spawy');
+
+//$sd->set_table_to_sync('opt_wlokna');
+    
+
+
+
+
+
+
+
+
+$sd->set_table_to_sync('Kabel_TPSA_dzierzawa');
+/*$sd->set_table_to_sync('Rozdzielcza_Przeciski_110mm');
+$sd->set_table_to_sync('Rozdzielcza_Wykop_przedmiar_na_mikrorurki');
+$sd->set_table_to_sync('Rozdzielcza_Zabruki');
+$sd->set_table_to_sync('Rozdzielcza_koszty_dodatkowe_wsg84');
+$sd->set_table_to_sync('Rozdzielcza_rurociag_wsg84');
+$sd->set_table_to_sync('Rozdzielcza_wewn_kabel_ethernet');
+$sd->set_table_to_sync('Studnie');
+$sd->set_table_to_sync('pod_816_3');
+$sd->set_table_to_sync('gminy_wsg84');
+$sd->set_table_to_sync('solectwa_poligon');
+
+$sd->set_table_to_sync('Rozdzielcza_Kabel_Swiatlowodowy_wsg84');
 $sd->set_table_to_sync('Rozdzielcza_PionyKablowe');
 $sd->set_table_to_sync('Rozdzielcza_Mikrokanalizacja_do_klienta');
 $sd->set_table_to_sync('BUILDINGS');
+$sd->set_table_to_sync('USERS2_MARKETING');
 
-$sd->set_table_to_sync('IN7_MK_BAZA_DYSTRYBUCJI');
 $sd->set_table_to_sync('TELBOXES');
 $sd->set_table_to_sync('Rozdzielcza_rurociag_wsg84');
 $sd->set_table_to_sync('MK_Rewiry');
 
-//$sd->sync_struct();
+
+$sd->set_table_to_sync('IN7_MK_BAZA_DYSTRYBUCJI');
+*/
+$sd->sync_struct();
+
 $sd->sync_data();