Sfoglia il codice sorgente

Merge branch 'master' of biuro.biall-net.pl:plabudda/se

# By Piotr Labudda
# Via Piotr Labudda
* 'master' of biuro.biall-net.pl:plabudda/se:
  TableAjax: resizable modal inline box
  FixCrmProcesInitIdx: remove error msg - conflicts usage of mysql insert_id and afected_rows
  FixCrmProcesInitIdx: test map proces with goto and groups
  Map: change strategy cluster params for babidol layer
a.binder 10 anni fa
parent
commit
342e78f5fa

+ 205 - 0
SE/se-lib/CrmProcesMap.php

@@ -0,0 +1,205 @@
+<?php
+
+class CrmProcesMap {
+
+	public $initData = array();
+	public $initProcesWithGroups = array();
+	public $initProcesIds = array();
+	public $stepToRecDeepLvl = array();// Recurce Deep Level => ID_PROCES
+	public $stepToGroup = array();// recurse deep => [ID_PROCES => ?]
+	public $usedGroups = array();// ID_GROUPS => group name
+	public $gotoIds = array();
+	public $gotoData = array();
+
+	public function __construct($idProcesInit) {
+		$this->initData = $this->fetchProcesIdxForInit($idProcesInit);
+		$gotoIdsTodo = array();
+		foreach ($this->initData as $r) {
+			$this->stepToRecDeepLvl[$r->ID_PROCES] = 0;
+			$this->initProcesIds[$r->ID_PROCES] = true;
+			$this->initProcesWithGroups[$r->idx_PROCES_WITH_GROUPS_ID] = true;
+			if ($r->ID_GOTO_AND_RETURN > 0) {
+				$gotoIdsTodo[$r->ID_GOTO_AND_RETURN][] = $r->ID_PROCES;
+			}
+		}
+		if(V::get('DBG', '', $_REQUEST)){echo '<pre style="width:600px;border:1px solid red;max-height:300px;overflow:auto">TODO: $gotoIdsTodo = ';print_r($gotoIdsTodo);echo'</pre>';}
+		$loopLimit = 10;
+		for ($i = 1; $i <= $loopLimit && !empty($gotoIdsTodo); $i++) {
+			foreach ($gotoIdsTodo as $gotoId => $fromIds) {
+				foreach ($fromIds as $fromId) {
+					$this->gotoIds[$gotoId][] = $fromId;
+				}
+			}
+			$gotoData = $this->fetchProcesIdxForGotoIds($gotoIdsTodo);
+			$gotoIdsTodo = array();
+			if(V::get('DBG', '', $_REQUEST)){echo '<pre style="width:600px;border:1px solid red;max-height:300px;overflow:auto">TODO:loop('.$i.'): $gotoData = ';print_r($gotoData);echo'</pre>';}
+			foreach ($gotoData as $r) {
+				if (!array_key_exists($r->ID_PROCES, $this->stepToRecDeepLvl)) {
+					$this->stepToRecDeepLvl[$r->ID_PROCES] = $i;
+				} else {
+					continue;// ? throw new Exception("Loop detected");
+				}
+				if ($r->ID_GOTO_AND_RETURN > 0) {
+					$gotoIdsTodo[$r->ID_GOTO_AND_RETURN][] = $r->ID_PROCES;
+				}
+			}
+		}
+		$this->stepToGroup = $this->fetchGroupsByProcesIds(array_keys($this->stepToRecDeepLvl));
+		foreach ($this->stepToGroup as $idProces => $idGroups) {
+			foreach ($idGroups as $idGroup) {
+				$this->usedGroups[$idGroup] = true;
+			}
+		}
+		?>
+		<table class="table table-bordered">
+			<thead>
+				<tr>
+					<th>Lp.</th>
+					<th>idGroup</th>
+					<?php foreach ($this->stepToRecDeepLvl as $idProces => $deepLvl) : ?>
+						<th><?php echo $idProces; ?></th>
+					<?php endforeach; ?>
+				</tr>
+			</thead>
+			<tbody>
+				<?php $i = 0; foreach ($this->usedGroups as $idGroup => $groupName) : ?>
+					<tr>
+						<td><?php echo $i; ?></td>
+						<td><?php echo $idGroup; ?></td>
+						<?php foreach ($this->stepToRecDeepLvl as $idProces => $deepLvl) : ?>
+							<td><?php
+		if (array_key_exists($idProces, $this->stepToGroup)) {
+			if (in_array($idGroup, $this->stepToGroup[$idProces])) {
+				echo '#';
+			} else {
+				echo '.';
+			}
+		} else {
+			echo 'x';
+		}
+								?></td>
+						<?php endforeach; ?>
+					</tr>
+				<?php $i++; endforeach; ?>
+			</tbody>
+		</table>
+		<?php
+		if(V::get('DBG', '', $_REQUEST)){
+			echo '<pre style="width:600px;border:1px solid red;max-height:300px;overflow:auto">$this->initData = ';print_r($this->initData);echo'</pre>';
+			echo '<pre style="width:600px;border:1px solid red;max-height:300px;overflow:auto">$this->stepToGroup = ';print_r($this->stepToGroup);echo'</pre>';
+			echo '<pre style="width:600px;border:1px solid red;max-height:300px;overflow:auto">$this->stepToRecDeepLvl = ';print_r($this->stepToRecDeepLvl);echo'</pre>';
+			echo '<pre style="width:600px;border:1px solid red;max-height:300px;overflow:auto">$this->gotoIds = ';print_r($this->gotoIds);echo'</pre>';
+			echo '<pre style="width:600px;border:1px solid red;max-height:300px;overflow:auto">$this->initProcesIds = ';print_r($this->initProcesIds);echo'</pre>';
+			echo '<pre style="width:600px;border:1px solid red;max-height:300px;overflow:auto">$this->initProcesWithGroups = ';print_r($this->initProcesWithGroups);echo'</pre>';
+			echo '<pre style="width:600px;border:1px solid red;max-height:300px;overflow:auto">$this = ';print_r($this);echo'</pre>';
+		}
+		$usedGroups = $this->getGroupIdsForProcesInit($idProcesInit);
+		$usedGoto = $this->getGotoAnReturnIdsForProcesInit($idProcesInit);
+		if(V::get('DBG', '', $_REQUEST)){
+			echo '<pre style="width:600px;border:1px solid red;max-height:300px;overflow:auto">$usedGroups = ';print_r($usedGroups);echo'</pre>';
+			echo '<pre style="width:600px;border:1px solid red;max-height:300px;overflow:auto">$usedGoto = ';print_r($usedGoto);echo'</pre>';
+		}
+	}
+
+	public function fetchProcesIdxForInit($idProcesInit) {
+		$db = DB::getDB();
+		$data = array();
+		$sql = "select i.*
+				, IF(p.`IF_TRUE_GOTO_FLAG`='GOTO_AND_RETURN' and p.`IF_TRUE_GOTO`>0
+					, p.`IF_TRUE_GOTO`
+					, 0) as `ID_GOTO_AND_RETURN`
+			from `CRM_PROCES_idx` i
+				join `CRM_PROCES` p on(p.`ID`=i.`ID_PROCES`)
+			where (i.`idx_PROCES_INIT_ID`='{$idProcesInit}'
+			 or i.`idx_PROCES_WITH_GROUPS_ID`='{$idProcesInit}')
+		";
+		$res = $db->query($sql);
+		while ($r = $db->fetch($res)) {
+			$data[] = $r;
+		}
+		return $data;
+	}
+
+	public function fetchProcesIdxForGotoIds($gotoIdsTodo) {
+		$db = DB::getDB();
+		if (empty($gotoIdsTodo)) return;
+		$sqlIds = array_keys($gotoIdsTodo);
+		if (empty($sqlIds)) return;
+		$sqlIds = implode(",", $sqlIds);
+		$data = array();
+		$sql = "select i.*
+				, IF(p.`IF_TRUE_GOTO_FLAG`='GOTO_AND_RETURN' and p.`IF_TRUE_GOTO`>0
+					, p.`IF_TRUE_GOTO`
+					, 0) as `ID_GOTO_AND_RETURN`
+			from `CRM_PROCES_idx` i
+				join `CRM_PROCES` p on(p.`ID`=i.`ID_PROCES`)
+			where (i.`idx_PROCES_INIT_ID` in({$sqlIds})
+			 or i.`idx_PROCES_WITH_GROUPS_ID` in({$sqlIds}))
+		";
+		$res = $db->query($sql);
+		while ($r = $db->fetch($res)) {
+			$data[] = $r;
+		}
+		return $data;
+	}
+
+	public function fetchGroupsByProcesIds($procesIds) {
+		$db = DB::getDB();
+		if (empty($procesIds)) return;
+		$sqlIds = implode(",", $procesIds);
+		$data = array();
+		$sql = "select gp.`ID_PROCES`, gp.`ID_GROUP`
+			from `CRM_PROCES_idx_GROUP_to_PROCES` gp
+			where gp.`ID_PROCES` in({$sqlIds})
+		";
+		$res = $db->query($sql);
+		while ($r = $db->fetch($res)) {
+			$data[$r->ID_PROCES][] = $r->ID_GROUP;
+		}
+		return $data;
+	}
+
+	public function getGroupIdsForProcesInit($idProcesInit) {
+		$usedGroups = array();
+		$db = DB::getDB();
+		$sql = "
+			select gp.`ID_PROCES`, gp.`ID_GROUP`
+			from (
+					select i.`idx_PROCES_WITH_GROUPS_ID` as `ID_PROCES`
+					from `CRM_PROCES_idx` i
+					where i.`idx_PROCES_INIT_ID`='{$idProcesInit}'
+					group by i.`idx_PROCES_WITH_GROUPS_ID`
+				) gids
+				join `CRM_PROCES_idx_GROUP_to_PROCES` gp on (gp.`ID_PROCES`=gids.`ID_PROCES`)
+		";
+		$res = $db->query($sql);
+		while ($r = $db->fetch($res)) {
+			$usedGroups[$r->ID_PROCES][] = $r->ID_GROUP;
+		}
+		return $usedGroups;
+	}
+
+	public function getGotoAnReturnIdsForProcesInit($idProcesInit) {
+		$usedGoto = array();
+		$db = DB::getDB();
+		$sql = "
+			select p.`ID`, p.`IF_TRUE_GOTO`
+			from (
+					select i.`ID_PROCES` as `ID_PROCES`
+					from `CRM_PROCES_idx` i
+					where i.`idx_PROCES_INIT_ID`='{$idProcesInit}'
+					group by i.`ID_PROCES`
+				) pids
+				join `CRM_PROCES` p on (p.`ID`=pids.`ID_PROCES`
+						and p.`IF_TRUE_GOTO_FLAG`='GOTO_AND_RETURN'
+						and p.`IF_TRUE_GOTO`>0
+					)
+		";
+		$res = $db->query($sql);
+		while ($r = $db->fetch($res)) {
+			$usedGoto[$r->IF_TRUE_GOTO][] = $r->ID;
+		}
+		return $usedGoto;
+	}
+
+}

+ 41 - 4
SE/se-lib/Route/FixCrmProcesInitIdx.php

@@ -38,6 +38,43 @@ jQuery(document).ready(function () {
 		SE_Layout::dol();
 	}
 
+	public function mapAction() {
+		SE_Layout::gora();
+		// echo '<a href="index.php?_route=FixCrmProcesInitIdx&_task=run">aktualizuj uprawnienia</a>';
+		$idProcesInit = V::get('id_proces_init', '', $_REQUEST, 'int');
+		?>
+<div class="jumbotron">
+  <div class="container">
+		<form class="form-inline" method="POST">
+			<input type="hidden" name="_route" value="FixCrmProcesInitIdx" />
+			<input type="hidden" name="_task" value="map" />
+			<input type="text" class="form-control" name="id_proces_init" value="<?php echo $idProcesInit; ?>" />
+			<button type="submit" id="fldExecuteBtn" class="btn btn-primary" autocomplete="off">
+				Pokaż mapę
+			</button>
+		</form>
+	</div>
+</div>
+<script type="text/javascript">
+jQuery(document).ready(function () {
+  jQuery('#fldExecuteBtn').on('click', function () {
+    jQuery(this).text(jQuery(this).text() + '...').attr('disabled', 'disabled');
+		jQuery(this).parent().submit();
+  })
+});
+</script>
+		<?php
+		if ($idProcesInit) {
+			$this->printProcesInitMap($idProcesInit);
+		}
+		SE_Layout::dol();
+	}
+
+	public function printProcesInitMap($idProcesInit) {
+		Lib::loadClass('CrmProcesMap');
+		$map = new CrmProcesMap($idProcesInit);
+	}
+
 	public function runAction() {
 		SE_Layout::gora();
 		SE_Layout::menu();
@@ -632,7 +669,7 @@ SQL;
 									, NOW(), coalesce(NEW.A_RECORD_UPDATE_AUTHOR,'trigger:FixCrmProcesInitIdx_CRM_PROCES_AFTER_INSERT')
 								);
 						END IF;
-						UPDATE `P5-MSG:Route_FixCrmProcesInitIdx:ERROR: Update perms` SET x=1;
+						-- UPDATE `P5-MSG:Route_FixCrmProcesInitIdx:ERROR: Update perms` SET x=1;
 					END IF;
 				END
 		";
@@ -661,7 +698,7 @@ SQL;
 									, NOW(), coalesce(NEW.A_RECORD_UPDATE_AUTHOR,'trigger:FixCrmProcesInitIdx_CRM_PROCES_AFTER_UPDATE')
 								);
 						END IF;
-						UPDATE `P5-MSG:Route_FixCrmProcesInitIdx:ERROR: Update perms` SET x=1;
+						-- UPDATE `P5-MSG:Route_FixCrmProcesInitIdx:ERROR: Update perms` SET x=1;
 					END IF;
 				END
 		";
@@ -698,7 +735,7 @@ SQL;
 									, NOW(), coalesce(NEW.A_RECORD_UPDATE_AUTHOR,'trigger:FixCrmProcesInitIdx_CRM_WSKAZNIK_AFTER_INSERT')
 								);
 						END IF;
-						UPDATE `P5-MSG:Route_FixCrmProcesInitIdx:ERROR: Update perms` SET x=1;
+						-- UPDATE `P5-MSG:Route_FixCrmProcesInitIdx:ERROR: Update perms` SET x=1;
 					END IF;
 				END
 		";
@@ -744,7 +781,7 @@ SQL;
 									, NOW(), coalesce(NEW.A_RECORD_UPDATE_AUTHOR,'trigger:FixCrmProcesInitIdx_CRM_WSKAZNIK_AFTER_UPDATE')
 								);
 						END IF;
-						UPDATE `P5-MSG:Route_FixCrmProcesInitIdx:ERROR: Update perms` SET x=1;
+						-- UPDATE `P5-MSG:Route_FixCrmProcesInitIdx:ERROR: Update perms` SET x=1;
 					END IF;
 				END
 		";

+ 12 - 3
SE/se-lib/TableAjax.php

@@ -385,7 +385,10 @@ class TableAjax extends ViewAjax {
 .ui-dialog-content .mapEditor-btnBackToWindowItemActive { display:none; }
 
 .AjaxTableCont .valign-btns-bottom a { vertical-align:text-bottom; font-weight:normal; font-size:12px; line-height:14px; }
-		</style>
+
+.ui-resizable-s { bottom:0; }
+.ui-resizable-e { right:0; }
+	</style>
 
 		<div class="AjaxTableCont">
 			<ul class="breadcrumb">
@@ -1379,7 +1382,8 @@ class TableAjax extends ViewAjax {
 				var iebHead = $('<div class="modal-header">').appendTo(frmInlineEdit);
 				$('<button type="button" class="close" data-dismiss="modal" aria-hidden="true"><i class="glyphicon glyphicon-remove"></i></button>').appendTo(iebHead);
 				$('<h3 id="myModalLabel">Edytuj</h3>').appendTo(iebHead);
-				var iebBody = $('<div class="modal-body"></div>').appendTo(frmInlineEdit);
+				var iebBodyWrap = $('<div class="modal-body" style="padding:0"></div>').appendTo(frmInlineEdit);
+				var iebBody = $('<div style="padding:15px"></div>').appendTo(iebBodyWrap);
 				$('<input type="hidden" name="ID" value="">').appendTo(iebBody);
 				$('<input type="hidden" name="col" value="">').appendTo(iebBody);
 				$('<div class="inlineEditBox-cnt"></div>').appendTo(iebBody);
@@ -2268,8 +2272,13 @@ class TableAjax extends ViewAjax {
 			// e.clientX: 1002; e.clientY: 245
 			if ('id' in e.data && 'col' in e.data && e.data.id > 0) {
 				_inlineEditBox.modal();
-				//_inlineEditBox.css({'position':'absolute', 'top':'100px', 'left':'100px'});
 				_inlineEditBox.show();
+				_inlineEditBox.on('shown.bs.modal', function(e) {
+					var dialogBox = jQuery(this).find('.modal-dialog'),
+							modalBody = dialogBox.find('.modal-body');
+					modalBody.css({overflow: 'scroll'});
+					dialogBox.resizable({minHeight: 300, minWidth: 300, alsoResize: modalBody});
+				});
 				_inlineEditBox.find('input[name=ID]').val(e.data.id);
 				_inlineEditBox.find('input[name=col]').val(e.data.col);
 				_inlineEditBox.find('.inlineEditBox-cnt').html('<span class="loading-info"> loading ...</span>');

+ 1 - 1
SE/se-lib/TableAjaxMap.php

@@ -197,7 +197,7 @@ var myOpenLayers_Control_ManageLayers = OpenLayers.Class(OpenLayers.Control, {
 			})
 		});
 		var testLayerBabidol = new OpenLayers.Layer.Vector(layerName, {
-			strategies: [new OpenLayers.Strategy.BBOX(), new OpenLayers.Strategy.Cluster({distance:30, threshold:3})],
+			strategies: [new OpenLayers.Strategy.BBOX(), new OpenLayers.Strategy.Cluster({distance:20, threshold:10})],
 			projection: new OpenLayers.Projection("EPSG:4326"),
 			protocol: new OpenLayers.Protocol.WFS({
 				version: "1.1.0",