|
|
@@ -1533,12 +1533,32 @@ class TableAjax extends ViewAjax {
|
|
|
wpsUrl: 'http://biuro.biall-net.pl/wps',
|
|
|
wfsUrl: 'http://biuro.biall-net.pl/wps',
|
|
|
layerName: '<?php echo $this->getLabelHtml(); ?>',
|
|
|
- onfeatureselect: function() {
|
|
|
- // this.selectedFeatures
|
|
|
- console.log('onfeatureselect (',this.selectedFeatures.length,'): ', this);
|
|
|
- },
|
|
|
- onfeatureselect: function() {
|
|
|
- console.log('onfeatureselect (',this.selectedFeatures.length,'): ', this);
|
|
|
+ onSaveFeature: function(selectedRecordId, selectedFeatureExtent) {
|
|
|
+ console.log('onSaveFeature (',selectedRecordId,'/',selectedFeatureExtent,') ', this);
|
|
|
+ if (!selectedRecordId) {
|
|
|
+ alert('Brak zaznaczonego rekordu - wybierz rekord z tabeli');
|
|
|
+ return;
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ $.ajax({
|
|
|
+ data: {polygon: selectedFeatureExtent},
|
|
|
+ type: "POST",
|
|
|
+ url: 'index-ajax.php?_zasobID=<?php echo $this->_zasobID; ?>&_cls=<?php echo __CLASS__; ?>&_hash=<?php echo $this->_htmlID; ?>&_task=THE_GEOM_SAVE&ID=' + selectedRecordId
|
|
|
+ })
|
|
|
+ .done(function(data, textStatus, jqXHR){
|
|
|
+ //TODO: update table cell data; that.data("treetable").updateNodeHtmlData(id, jqXHR.responseText);
|
|
|
+ jQuery.notify('Aktualizacja danych dla rekordu ' + selectedRecordId, 'success');
|
|
|
+ })
|
|
|
+ .fail(function(jqXHR){// jqXHR.fail(function( jqXHR, textStatus, errorThrown ) {});
|
|
|
+ var txt = jqXHR.responseText || 'Error';
|
|
|
+ if (jqXHR.status == 404) {
|
|
|
+ jQuery.notify(jqXHR.responseText, 'error');
|
|
|
+ } else {
|
|
|
+ jQuery.notify(jqXHR.responseText, 'warn');
|
|
|
+ }
|
|
|
+ });
|
|
|
+
|
|
|
}
|
|
|
});
|
|
|
|
|
|
@@ -2521,6 +2541,10 @@ function hidePopover() {
|
|
|
$this->sendHiddenColsSave($_REQUEST);
|
|
|
break;
|
|
|
}
|
|
|
+ case 'THE_GEOM_SAVE': {
|
|
|
+ $this->sendTheGeomSave($_REQUEST);
|
|
|
+ break;
|
|
|
+ }
|
|
|
default:
|
|
|
$this->sendAjaxData($_REQUEST);
|
|
|
}
|
|
|
@@ -4469,4 +4493,62 @@ jQuery(document).ready(function(){
|
|
|
UserProfile::save();
|
|
|
}
|
|
|
|
|
|
+ private function sendTheGeomSave($args) {
|
|
|
+ $id = V::get('ID', 0, $args, 'int');
|
|
|
+ $polygon = V::get('polygon', 0, $args);
|
|
|
+ $geomFieldName = 'the_geom';
|
|
|
+
|
|
|
+ if ($id <= 0) {
|
|
|
+ header('HTTP/1.0 404 Not Found');
|
|
|
+ echo "Wrong param ID";
|
|
|
+ exit;
|
|
|
+ }
|
|
|
+ // TODO: validate polygon - ex.: POLYGON((2072030.2315435 7234115.910678,2072029.4815435 7234093.660678,2072115.2315435 7234091.160678,2072115.4815435 7234113.660678,2072115.2315435 7234113.660678,2072094.2315435 7234113.910678,2072030.2315435 7234115.910678)))
|
|
|
+
|
|
|
+ $tblName = $this->_acl->getName();
|
|
|
+
|
|
|
+ $db = DB::getDB();
|
|
|
+ $record = $db->get_by_id($tblName, $id);
|
|
|
+ if (!$this->_acl->canWriteRecord($record) && !$this->_acl->hasPermSuperWrite()) {
|
|
|
+ header('HTTP/1.0 403.3 - Write access forbidden');
|
|
|
+ echo "Brak dostępu do rekordu";
|
|
|
+ exit;
|
|
|
+ }
|
|
|
+
|
|
|
+ $theGeomFieldId = $this->_acl->getFieldIdByName($geomFieldName);
|
|
|
+ if (!$this->_acl->isAllowed($theGeomFieldId, 'W', $record)) {
|
|
|
+ header('HTTP/1.0 403.3 - Write access forbidden');
|
|
|
+ echo "Brak dostępu do zapisu dla pola {$geomFieldName}";
|
|
|
+ exit;
|
|
|
+ }
|
|
|
+
|
|
|
+ $sqlObj = new stdClass();
|
|
|
+ $sqlObj->{$geomFieldName} = "GeomFromText('{$polygon}')";
|
|
|
+ $sqlObj->ID = $id;
|
|
|
+ if($DBG){echo'<pre style="max-height:200px;overflow:auto;border:1px solid red;text-align:left;"> (' . __CLASS__ . '::' . __FUNCTION__ . ':' . __LINE__ . '): ';print_r($sqlObj);echo'</pre>';}
|
|
|
+
|
|
|
+ $ret = $db->UPDATE_OBJ($tblName, $sqlObj);
|
|
|
+
|
|
|
+ if ($ret > 0) {
|
|
|
+ echo '<div class="alert alert-success">';
|
|
|
+ echo "Rekord zapisany pomyślnie";//"Record saved successfully";
|
|
|
+ echo '</div>';
|
|
|
+ } else if ($ret == 0) {
|
|
|
+ echo '<div class="alert alert-info">';
|
|
|
+ echo "Nie wprowadzono żadnych zmian";
|
|
|
+ echo '</div>';
|
|
|
+ } else {
|
|
|
+ header('HTTP/1.0 404 Not Found');
|
|
|
+ echo '<div class="alert alert-error">';
|
|
|
+ echo '<h4>' . "Wystąpiły błędy!" . '</h4>';
|
|
|
+ if ($db->has_errors()) {
|
|
|
+ $errors = $db->get_errors();
|
|
|
+ echo implode('<br>', $errors);
|
|
|
+ }
|
|
|
+ echo '</div>';
|
|
|
+ }
|
|
|
+
|
|
|
+ exit;
|
|
|
+ }
|
|
|
+
|
|
|
}
|