|
@@ -753,6 +753,25 @@ jQuery(document).on('p5UIBtnAjax:Storage:addCellToZasoby:ajaxLoaded', function(e
|
|
|
jQuery.notify(payload.msg, payload.type);
|
|
jQuery.notify(payload.msg, payload.type);
|
|
|
});
|
|
});
|
|
|
</script>
|
|
</script>
|
|
|
|
|
+<?php
|
|
|
|
|
+
|
|
|
|
|
+ $ajaxAddZasobLink = Request::getPathUri() . "index.php?_route=Storage&_task=addGeomEtykietaCells&idStorage={$idStorage}&tblName={$tblName}";
|
|
|
|
|
+ $onClick = "return p5UI__ButtonAjax(this, 'p5UIBtnAjax:Storage:addGeomEtykietaCells', { href: '{$ajaxAddZasobLink}' })";
|
|
|
|
|
+ UI::tag('a', ['onclick'=>$onClick, 'class'=>"btn btn-xs btn-primary", 'href'=>"#"], "Dodaj komórki etykiet", true);
|
|
|
|
|
+ echo "<i>(<code>`etykieta_x`</code>, <code>`etykieta_y`</code>, <code>`etykieta_obrot`</code>)</i>";
|
|
|
|
|
+?>
|
|
|
|
|
+<script>
|
|
|
|
|
+jQuery(document).on('p5UIBtnAjax:Storage:addGeomEtykietaCells:ajaxLoaded', function(e, n, payload) {
|
|
|
|
|
+ console.log('event p5UIBtnAjax:Storage:addGeomEtykietaCells:ajaxLoaded', n, payload);
|
|
|
|
|
+ if ('success' == payload.type && payload.body && payload.body.id > 0) {
|
|
|
|
|
+ var cellUwagi$Node = jQuery(n).parents('td').next('td');
|
|
|
|
|
+ cellUwagi$Node.text(cellUwagi$Node.text().replace('!Zasob', ''))
|
|
|
|
|
+ jQuery(n).parents('td').text(payload.body.id);
|
|
|
|
|
+ jQuery(n).remove();
|
|
|
|
|
+ }
|
|
|
|
|
+ jQuery.notify(payload.msg, payload.type);
|
|
|
|
|
+});
|
|
|
|
|
+</script>
|
|
|
<?php
|
|
<?php
|
|
|
} catch (Exception $e) {
|
|
} catch (Exception $e) {
|
|
|
UI::alert('danger', "Error #" . $e->getCode() . "|" . $e->getLine() . ": " . $e->getMessage());
|
|
UI::alert('danger', "Error #" . $e->getCode() . "|" . $e->getLine() . ": " . $e->getMessage());
|
|
@@ -760,6 +779,80 @@ jQuery(document).on('p5UIBtnAjax:Storage:addCellToZasoby:ajaxLoaded', function(e
|
|
|
UI::dol();
|
|
UI::dol();
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
+ public function addGeomEtykietaCellsAction() {
|
|
|
|
|
+ Response::sendTryCatchJson(array($this, 'addGeomEtykietaCells'), $_REQUEST);
|
|
|
|
|
+ }
|
|
|
|
|
+ public function addGeomEtykietaCells($args) {
|
|
|
|
|
+ $return = [
|
|
|
|
|
+ 'type' => 'error',
|
|
|
|
|
+ 'msg' => 'todo: F.' . __FUNCTION__ . ' L.' . __LINE__,
|
|
|
|
|
+ ];
|
|
|
|
|
+
|
|
|
|
|
+ $return['_DBG_request'] = $args;
|
|
|
|
|
+ // idStorage: "36"
|
|
|
|
|
+ // tblName: "test_geom_linestring"
|
|
|
|
|
+ $idStorage = V::get('idStorage', 0, $args, 'int');
|
|
|
|
|
+ if ($idStorage <= 0) throw new HttpException("Missing idStorage", 400);
|
|
|
|
|
+ $storage = DB::getStorage($idStorage);
|
|
|
|
|
+ $tblName = V::get('tblName', 0, $args, 'word');
|
|
|
|
|
+ if (empty($tblName)) throw new HttpException("Missing tblName", 400);
|
|
|
|
|
+
|
|
|
|
|
+ $tableStruct = $storage->getTableStruct($tblName);
|
|
|
|
|
+ $return['_DBG_$tableStruct'] = $tableStruct;
|
|
|
|
|
+
|
|
|
|
|
+ if ('mysql' == DB::getPDO($idStorage)->getType()) {
|
|
|
|
|
+ $dbName = DB::getPDO($idStorage)->getDatabaseName();
|
|
|
|
|
+ $fixedTableName = DB::getPDO($idStorage)->fetchValue("
|
|
|
|
|
+ select t.TABLE_NAME
|
|
|
|
|
+ from `information_schema`.`TABLES` t
|
|
|
|
|
+ where t.TABLE_SCHEMA = '{$dbName}'
|
|
|
|
|
+ and t.TABLE_NAME LIKE '{$tblName}'
|
|
|
|
|
+ ");
|
|
|
|
|
+ $return['_DBG_sql_fix__$tblName'] = "
|
|
|
|
|
+ select t.TABLE_NAME
|
|
|
|
|
+ from `information_schema`.`TABLES` t
|
|
|
|
|
+ where t.TABLE_SCHEMA = '{$dbName}'
|
|
|
|
|
+ and t.TABLE_NAME LIKE '{$tblName}'
|
|
|
|
|
+ ";
|
|
|
|
|
+ if (empty($fixedTableName)) return $return;
|
|
|
|
|
+ if (empty($fixedTableName)) throw new HttpException("Database Error", 500);
|
|
|
|
|
+ $return['_DBG_$fixedTableName'] = $fixedTableName;
|
|
|
|
|
+ $tblName = $fixedTableName;
|
|
|
|
|
+ }
|
|
|
|
|
+ $return['_DBG_$tableStruct'] = $tableStruct;
|
|
|
|
|
+
|
|
|
|
|
+ $return['_DBG_has_field__etykieta_x'] = (null != V::geti('etykieta_x', null, $tableStruct));
|
|
|
|
|
+ $return['_DBG_has_field__etykieta_y'] = (null != V::geti('etykieta_y', null, $tableStruct));
|
|
|
|
|
+ $return['_DBG_has_field__etykieta_obrot'] = (null != V::geti('etykieta_obrot', null, $tableStruct));
|
|
|
|
|
+
|
|
|
|
|
+ if (!V::geti('etykieta_x', null, $tableStruct)) {
|
|
|
|
|
+ try {
|
|
|
|
|
+ DB::getPDO($idStorage)->exec("ALTER TABLE `{$tblName}_HIST` ADD `etykieta_x` varchar(16) DEFAULT 'N/S;'");
|
|
|
|
|
+ } catch (Exception $e) {
|
|
|
|
|
+ $return['__DBG_hist_errors__etykieta_x'] = $e->getMessage();
|
|
|
|
|
+ }
|
|
|
|
|
+ DB::getPDO($idStorage)->exec("ALTER TABLE `{$tblName}` ADD `etykieta_x` decimal(16,10) DEFAULT NULL COMMENT 'przesuniecie etykiety elementu w GIS'");
|
|
|
|
|
+ }
|
|
|
|
|
+ if (!V::geti('etykieta_y', null, $tableStruct)) {
|
|
|
|
|
+ try {
|
|
|
|
|
+ DB::getPDO($idStorage)->exec("ALTER TABLE `{$tblName}_HIST` ADD `etykieta_y` varchar(16) DEFAULT 'N/S;'");
|
|
|
|
|
+ } catch (Exception $e) {
|
|
|
|
|
+ $return['__DBG_hist_errors__etykieta_y'] = $e->getMessage();
|
|
|
|
|
+ }
|
|
|
|
|
+ DB::getPDO($idStorage)->exec("ALTER TABLE `{$tblName}` ADD `etykieta_y` decimal(16,10) DEFAULT NULL COMMENT 'przesuniecie etykiety elementu w GIS'");
|
|
|
|
|
+ }
|
|
|
|
|
+ if (!V::geti('etykieta_obrot', null, $tableStruct)) {
|
|
|
|
|
+ try {
|
|
|
|
|
+ DB::getPDO($idStorage)->exec("ALTER TABLE `{$tblName}_HIST` ADD `etykieta_obrot` varchar(16) DEFAULT 'N/S;'");
|
|
|
|
|
+ } catch (Exception $e) {
|
|
|
|
|
+ $return['__DBG_hist_errors__etykieta_obrot'] = $e->getMessage();
|
|
|
|
|
+ }
|
|
|
|
|
+ DB::getPDO($idStorage)->exec("ALTER TABLE `{$tblName}` ADD `etykieta_obrot` decimal(16,10) DEFAULT NULL");
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ return $return;
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
public function xsdAction() {
|
|
public function xsdAction() {
|
|
|
$idStorage = V::get('idStorage', 0, $_REQUEST, 'int');
|
|
$idStorage = V::get('idStorage', 0, $_REQUEST, 'int');
|
|
|
$storage = DB::getStorage($idStorage);
|
|
$storage = DB::getStorage($idStorage);
|