|
|
@@ -105,15 +105,78 @@ class AntAclBase extends Core_AclBase {
|
|
|
}
|
|
|
public function getRealFieldListByIdZasob() {
|
|
|
$cols = array();
|
|
|
- $fakeZasobId = 1000000; // TODO: RMME
|
|
|
foreach ($this->getFields() as $field) {
|
|
|
- $idZasobField = ($field['idZasob']) ? $field['idZasob'] : $fakeZasobId++; // TODO: RMME
|
|
|
if (!$field['isActive']) continue;
|
|
|
if (!$field['idZasob']) continue;
|
|
|
- $cols[$idZasobField] = $field['fieldNamespace'];
|
|
|
+ $cols[ $field['idZasob'] ] = $field['fieldNamespace'];
|
|
|
}
|
|
|
return $cols;
|
|
|
}
|
|
|
+ public function getRealFieldList() {
|
|
|
+ $pkField = $this->getPrimaryKeyField();
|
|
|
+ $cols = array_merge([ $pkField ], array_filter($this->getLocalFieldList(), function ($fieldName) use ($pkField) {
|
|
|
+ if ($pkField === $fieldName) return false;
|
|
|
+ return true;
|
|
|
+ }));
|
|
|
+ return $cols;
|
|
|
+ }
|
|
|
+ public function getHistItems($id, $params = array()) {
|
|
|
+ DBG::log($params, 'array', "getHistItems({$id}, \$params)");
|
|
|
+ $sqlPkField = $this->getSqlPrimaryKeyField();
|
|
|
+ $ret = array();
|
|
|
+ $sql_tbl = $this->getRootTableName() . "_HIST";
|
|
|
+ $sql_cols = array_map(function ($fieldName) {
|
|
|
+ return "t.`{$fieldName}`";
|
|
|
+ }, $this->getRealFieldList());
|
|
|
+ $sql_cols = implode(", ", $sql_cols);
|
|
|
+ $sql_where = "t.`ID_USERS2`='{$id}'";
|
|
|
+
|
|
|
+ $idHist = V::get('ID', 0, $params, 'int');
|
|
|
+ if ($idHist > 0) {
|
|
|
+ $sql_where .= "\n and t.`ID`='{$idHist}'";
|
|
|
+ }
|
|
|
+ $paramNotEmptyFlds = V::get('notEmptyFlds', '', $params);
|
|
|
+ if (!empty($paramNotEmptyFlds) && is_array($paramNotEmptyFlds)) {
|
|
|
+ $sqlWhereOr = array();
|
|
|
+ foreach ($paramNotEmptyFlds as $fldName) {
|
|
|
+ if (array_key_exists($fldName, $this->_cols)) {
|
|
|
+ $sqlWhereOr[] = "t.`{$fldName}`!='N/S;'";
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if (!empty($sqlWhereOr)) $sql_where .= "\n and (" . implode(" or ", $sqlWhereOr) . ")";
|
|
|
+ }
|
|
|
+
|
|
|
+ $histRows = DB::getPDO()->fetchAllByKey("
|
|
|
+ select {$sql_cols}
|
|
|
+ from {$sql_tbl} as t
|
|
|
+ where {$sql_where}
|
|
|
+ order by ID DESC
|
|
|
+ ", 'ID');
|
|
|
+ return array_map(function ($row) {
|
|
|
+ $r = (object)$row;
|
|
|
+ $r->_author = $r->A_RECORD_UPDATE_AUTHOR;
|
|
|
+ $r->_created = $r->A_RECORD_UPDATE_DATE;
|
|
|
+
|
|
|
+ if (!$r->_author || $r->_author == 'N/S;') {
|
|
|
+ $r->_author = $r->A_RECORD_CREATE_AUTHOR;
|
|
|
+ }
|
|
|
+ if (!$r->_created || $r->_created == 'N/S;') {
|
|
|
+ $r->_created = $r->A_RECORD_CREATE_DATE;
|
|
|
+ }
|
|
|
+ return $r;
|
|
|
+ }, $histRows);
|
|
|
+ }
|
|
|
+ public function getFieldIdByName($fieldName) {
|
|
|
+ if (!$fieldName) return null;
|
|
|
+ $idZasob = null;
|
|
|
+ foreach ($this->getFields() as $field) {
|
|
|
+ if ($fieldName === $field['name']) {
|
|
|
+ if ($field['idZasob']) $idZasob = $field['idZasob'];
|
|
|
+ }
|
|
|
+ }
|
|
|
+ return $idZasob;
|
|
|
+ }
|
|
|
+
|
|
|
public function getFieldType($fieldName) { return null; }
|
|
|
// try {
|
|
|
// throw new Exception("TODO: AntAclBase::getFieldType({$fieldName})");
|