|
|
@@ -3017,7 +3017,7 @@ function hidePopover() {
|
|
|
|
|
|
if ($DBG) echo "fieldID: {$fieldID}\n";
|
|
|
|
|
|
- $row = $this->_dataSource->getItem($rowID);
|
|
|
+ $row = $this->_acl->getItem($rowID);
|
|
|
if (!$row) {
|
|
|
echo "404: No item ID({$rowID})";
|
|
|
exit;
|
|
|
@@ -3172,7 +3172,7 @@ function hidePopover() {
|
|
|
|
|
|
$cols = array();
|
|
|
|
|
|
- $record = $this->_dataSource->getItem($id);
|
|
|
+ $record = $this->_acl->getItem($id);
|
|
|
if (!$this->_acl->canWriteRecord($record) && !$this->_acl->hasPermSuperWrite()) {
|
|
|
echo '<div class="alert alert-danger">';
|
|
|
echo "Brak dostępu do rekordu";// TODO: more info - reason
|
|
|
@@ -3627,44 +3627,29 @@ jQuery(document).ready(function(){
|
|
|
}
|
|
|
|
|
|
private function ajaxCreateSave($args) {
|
|
|
- $DBG = ('1' == V::get('DBG', '', $_REQUEST));
|
|
|
-
|
|
|
- if($DBG){echo'<pre style="max-height:200px;overflow:auto;border:1px solid red;text-align:left;">TODO: save ID(' . $id . ') (' . __CLASS__ . '::' . __FUNCTION__ . ':' . __LINE__ . '): ';print_r($args);echo'</pre>';}
|
|
|
- if($DBG){echo'<pre style="max-height:200px;overflow:auto;border:1px solid red;text-align:left;">acl (' . __CLASS__ . '::' . __FUNCTION__ . ':' . __LINE__ . '): ';print_r($this->_acl);echo'</pre>';}
|
|
|
-
|
|
|
+ $response = new stdClass();
|
|
|
+ $createdId = null;
|
|
|
try {
|
|
|
$item = $this->_acl->convertObjectFromUserInput($args, $type = 'array_by_id', $prefix = 'f');
|
|
|
|
|
|
- // TODO: if empty $obj - return error - no data sent from user
|
|
|
$createdId = $this->_acl->addItem($item);
|
|
|
|
|
|
- $response->type = 'success';
|
|
|
- $response->msg = "Utworzono pomyślnie rekord nr {$retID}";
|
|
|
- $response->id = $createdId;
|
|
|
- $response->record = $this->_acl->getItem($createdId);
|
|
|
- return $response;
|
|
|
+ if ($createdId) {
|
|
|
+ $response->type = 'success';
|
|
|
+ $response->msg = "Utworzono pomyślnie rekord nr {$createdId}";
|
|
|
+ $response->id = $createdId;
|
|
|
+ $response->record = $this->_acl->getItem($createdId);
|
|
|
+ }
|
|
|
+ else {
|
|
|
+ $response->type = 'error';
|
|
|
+ $response->msg = "Nie udało się utworzyć nowego rekordu!";
|
|
|
+ }
|
|
|
|
|
|
- } catch (Exception $e) {
|
|
|
- $response = new stdClass();
|
|
|
- $response->type = 'error';
|
|
|
- $response->msg = $e->getMessage();
|
|
|
- return $response;
|
|
|
}
|
|
|
-
|
|
|
- $retID = $this->_dataSource->addItem($sqlObj);
|
|
|
-
|
|
|
- $response = new stdClass();
|
|
|
- $response->type = '';
|
|
|
- $response->msg = '';
|
|
|
- if ($retID > 0) {
|
|
|
- $response->type = 'success';
|
|
|
- $response->msg = "Utworzono pomyślnie rekord nr {$retID}";
|
|
|
- $response->id = $retID;
|
|
|
- $response->record = $this->_dataSource->getItem($retID);
|
|
|
- } else {
|
|
|
+ catch (Exception $e) {
|
|
|
$response->type = 'error';
|
|
|
$response->msg = "Wystąpiły błędy!";
|
|
|
- $response->errors = $this->_dataSource->getDbErrors();
|
|
|
+ $response->msg = $e->getMessage();
|
|
|
}
|
|
|
return $response;
|
|
|
}
|
|
|
@@ -3675,45 +3660,34 @@ jQuery(document).ready(function(){
|
|
|
throw new HttpException("Wrong param ID!", 404);
|
|
|
}
|
|
|
|
|
|
- $row = $this->_dataSource->getItem($id);
|
|
|
- if (!$row) {
|
|
|
+ $item = $this->_acl->getItem($id);
|
|
|
+ if (!$item) {
|
|
|
throw new HttpException("Item '{$id}' not exists!", 404);
|
|
|
}
|
|
|
|
|
|
- $types = $this->_acl->getTypes();
|
|
|
- $uniqKeys = $this->_acl->getUniqueKeys();
|
|
|
+ $response = new stdClass();
|
|
|
+ $itemCopy = $this->_acl->createItemCopy($item);
|
|
|
|
|
|
- $sqlObj = new stdClass();
|
|
|
- foreach ($types as $kName => $vType) {
|
|
|
- if ($kName == 'ID') {
|
|
|
- continue;
|
|
|
- } else if (in_array($kName, array('A_RECORD_UPDATE_AUTHOR','A_RECORD_UPDATE_DATE'))) {
|
|
|
- continue;
|
|
|
- }
|
|
|
- $value = V::get($kName, '', $row);
|
|
|
- if (in_array($kName, $uniqKeys)) {
|
|
|
- $value .= '?';
|
|
|
+ $createdId = null;
|
|
|
+ try {
|
|
|
+
|
|
|
+ $createdId = $this->_acl->addItem($itemCopy);
|
|
|
+
|
|
|
+ if ($createdId) {
|
|
|
+ $response->type = 'success';
|
|
|
+ $response->msg = "Rekord skopiowany pomyślnie - utworzono rekord nr {$createdId}";
|
|
|
+ $response->id = $createdId;
|
|
|
+ $response->record = $this->_acl->getItem($createdId);
|
|
|
}
|
|
|
- if ($this->_dataSource->isGeomField($kName)) {
|
|
|
- $value = "GeomFromText('{$value}')";
|
|
|
+ else {
|
|
|
+ $response->type = 'error';
|
|
|
+ $response->msg = "Nie udało się utworzyć nowego rekordu!";
|
|
|
}
|
|
|
- $sqlObj->{$kName} = $value;
|
|
|
}
|
|
|
-
|
|
|
- $retID = $this->_dataSource->addItem($sqlObj);
|
|
|
-
|
|
|
- $response = new stdClass();
|
|
|
- $response->type = '';
|
|
|
- $response->msg = '';
|
|
|
- if ($retID > 0) {
|
|
|
- $response->type = 'success';
|
|
|
- $response->msg = "Rekord skopiowany pomyślnie - utworzono rekord nr {$retID}";
|
|
|
- $response->id = $retID;
|
|
|
- $response->record = $this->_dataSource->getItem($retID);
|
|
|
- } else {
|
|
|
+ catch (Exception $e) {
|
|
|
$response->type = 'error';
|
|
|
$response->msg = "Wystąpiły błędy!";
|
|
|
- $response->errors = $this->_dataSource->getDbErrors();
|
|
|
+ $response->msg = $e->getMessage();
|
|
|
}
|
|
|
return $response;
|
|
|
}
|