Переглянути джерело

updated Zaliczka, SimpleSchema

Piotr Labudda 9 роки тому
батько
коміт
5e29e720ba

+ 66 - 34
SE/se-lib/Core/AclSimpleSchemaBase.php

@@ -172,34 +172,46 @@ class Core_AclSimpleSchemaBase extends Core_AclBase {
   public function getSimpleSchema() { return $this->_simpleSchema; }
   public function getSimpleSchemaTree() {
     $tree = array();
-    foreach ($this->_simpleSchema['root'] as $fieldName => $field) {
-      $tree[ $fieldName ] = $field;
-      if (is_array($field) && !empty($field['@ref'])) {
-        $tree[ $fieldName ] = $this->_getSimpleSchemaTreeRec($field['@ref']);
+    $tree['@namespace'] = $this->getNamespace();
+    foreach ($this->getXsdTypes() as $fieldName => $field) {
+      $tree[$fieldName] = $field;
+      if (is_array($field) && 'ref_uri:' == substr($field['xsdType'], 0, 8)) {
+        $tree[$fieldName] = $this->_getSimpleSchemaTreeRec(substr($field['xsdType'], 8), $this->getNamespace());
       }
     }
     return $tree;
   }
-  public function _getSimpleSchemaTreeRec($ref) {
-    // echo "<p>DBG: F._getSimpleSchemaTreeRec({$ref})</p>";
+  public function _getSimpleSchemaTreeRec($ref, $namespacePath = '', $loopCount = 0) {
+    if (++$loopCount > 100) die("Recurse limit in getSimpleSchemaTree for schema({$this->_namespace})");
+    // echo "<p>DBG: F._getSimpleSchemaTreeRec({$ref}) \$namespacePath[$namespacePath]</p>";
     $tree = array();
-    if (!empty($this->_simpleSchema[ $ref ])) {
+    if (!empty($this->_simpleSchema[$ref])) {
       $tree = array();
-      foreach ($this->_simpleSchema[ $ref ] as $fieldName => $field) {
-        // echo "<p>DBG: F._getSimpleSchemaTreeRec({$ref}) 1/'{$fieldName}'</p>";
-        $tree[ $fieldName ] = $field;
-        if (is_array($field) && !empty($field['@ref'])) {
-          $tree[ $fieldName ] = $this->_getSimpleSchemaTreeRec($field['@ref']);
+      foreach ($this->_simpleSchema[$ref] as $fieldName => $field) {
+        // echo "<p>DBG: F._getSimpleSchemaTreeRec({$ref}) \$namespacePath[$namespacePath] - 1/'{$fieldName}'</p>";
+        $tree[$fieldName] = $field;
+        if (is_array($field) && 'ref_uri:' == substr($field['xsdType'], 0, 8)) {
+          $nsField = substr($field['xsdType'], 8);
+          if (in_array($nsField, explode(',', $namespacePath))) {
+            $tree[$fieldName]['@recurse_namespace'] = true;
+            continue;
+          }
+          $tree[$fieldName] = $this->_getSimpleSchemaTreeRec($nsField, "{$namespacePath},{$nsField}", $loopCount);
         }
       }
     } else {
       $acl = Core_AclHelper::getAclByNamespace($ref);
-      $tree[ '@namespace' ] = $acl->getNamespace();
+      $tree['@namespace'] = $acl->getNamespace();
       foreach ($acl->getXsdTypes() as $fieldName => $field) {
-        // echo "<p>DBG: F._getSimpleSchemaTreeRec({$ref}) 2/'{$fieldName}'</p>";
-        $tree[ $fieldName ] = $field;
-        if (is_array($field) && !empty($field['@ref'])) {
-          $tree[ $fieldName ] = $this->_getSimpleSchemaTreeRec($field['@ref']);
+        // echo "<p>DBG: F._getSimpleSchemaTreeRec({$ref}) \$namespacePath[$namespacePath] - 2/'{$fieldName}'</p>";
+        $tree[$fieldName] = $field;
+        if (is_array($field) && 'ref_uri:' == substr($field['xsdType'], 0, 8)) {
+          $nsField = substr($field['xsdType'], 8);
+          if (in_array($nsField, explode(',', $namespacePath))) {
+            $tree[$fieldName]['@recurse_namespace'] = true;
+            continue;
+          }
+          $tree[$fieldName] = $this->_getSimpleSchemaTreeRec($nsField, "{$namespacePath},{$nsField}", $loopCount);
         }
       }
     }
@@ -357,13 +369,10 @@ class Core_AclSimpleSchemaBase extends Core_AclBase {
     }
   }
 
-  public function fixParams(&$params) {// validate and fix params for getItem, getItems, etc. @see Api_WfsServerBase::parseGetFeatureArgsFromRequest()
-    $params['cols'] = $this->parseParamCols($params['cols']);
-  }
-
-  public function parseParamCols($filterCols = []) {
-    V::get('cols', [], $params);// wfs:propertyName
-    if (empty($filterCols)) {// set default filter cols
+  public function getParamCols($params = []) {
+    $filterCols = [];
+    $cols = V::get('cols', [], $params);// wfs:propertyName
+    if (empty($cols)) {// set default filter cols
       foreach ($this->_simpleSchema['root'] as $fieldName => $field) {
         if ('@' == substr($fieldName, 0, 1)) continue;
         if ('unbounded' == V::get('maxOccurs', '', $field)) continue;// TODO:?: default load only single value fields (skip maxOccurs="unbounded")?
@@ -371,16 +380,22 @@ class Core_AclSimpleSchemaBase extends Core_AclBase {
           if ('xsd:' === substr($field['@type'], 0, 4)) $filterCols[$fieldName] = true;
           else if ('p5:' === substr($field['@type'], 0, 3)) $filterCols[$fieldName] = true;
         } else if (!empty($field['@ref'])) {
-          $filterCols[$fieldName] = true;
+          $filterCols[$fieldName] = [];
         } else throw new Exception("Schema error for field '{$fieldName}' ns({$this->_namespace})");
       }
-    }
-
-    {// fix xpath for ref fields
-      foreach ($filterCols as $fieldName => $bool) {
-        $field = $this->_simpleSchema['root'][$fieldName];
-        if (!empty($field['@ref'])) {
-          $filterCols[$fieldName] = [];
+    } else {
+      foreach ($cols as $fieldXPath) {
+        if (false === strpos($fieldXPath, '/')) {// not xpath - field name
+          if (!array_key_exists($fieldXPath, $this->_simpleSchema['root'])) throw new Exception("Field name '{$fieldXPath}' not exists in '{$this->_namespace}'");
+          $field = $this->_simpleSchema['root'][$fieldXPath];
+          if (!empty($field['@type'])) {
+            $filterCols[$fieldXPath] = true;
+          } else if (!empty($field['@ref'])) {
+            $filterCols[$fieldXPath] = [];
+          }
+        } else {// is xpath
+          list($fieldName, $subXPath) = explode('/', $fieldXPath, 2);// split only by first '/'
+          $filterCols[$fieldXPath][$fieldName] = $subXPath;
         }
       }
     }
@@ -389,7 +404,7 @@ class Core_AclSimpleSchemaBase extends Core_AclBase {
 
   public function buildFromSqlRow($row, $params = []) {
     $object = [];
-    $filterCols = $this->parseParamCols($params['cols']);
+    $filterCols = $this->getParamCols($params);
     $object['_raw'] = $row;
     foreach ($this->_simpleSchema['root'] as $fieldName => $field) {
       if ('@' == substr($fieldName, 0, 1)) continue;
@@ -403,7 +418,24 @@ class Core_AclSimpleSchemaBase extends Core_AclBase {
           $object[$fieldName] = "TODO: generate value for type {$field['@type']} - field '{$fieldName}' ns({$this->_namespace})";// TODO: single field method like addP5Types
         } else throw new Exception("Not Implemented type for field '{$fieldName}' ns({$this->_namespace})");
       } else if (!empty($field['@ref'])) {
-        $object[$fieldName] = $this->fetchItemFieldRefs($primaryKey, $fieldName);
+        // $object[$fieldName] = $this->fetchItemFieldRefs($primaryKey, $fieldName);
+        $refTable = ACL::getRefTable($this->getNamespace(), $fieldName);
+        $primaryKey = $row['ID'];// TODO: get primary key
+        $sqlPk = DB::getPDO()->quote($primaryKey, PDO::PARAM_STR);
+        $remoteIds = array_map(
+          function ($row) {
+            return $row['REMOTE_PRIMARY_KEY'];
+          }
+          , DB::getPDO()->fetchAll("
+              select r.REMOTE_PRIMARY_KEY, r.REMOTE_TYPENAME
+                from `{$refTable}` r
+              where r.PRIMARY_KEY = {$sqlPk}
+                and r.A_STATUS != 'DELETED'
+            ")
+        );
+        $object[$fieldName] = (!empty($remoteIds))
+          ? array_values(ACL::getAclByNamespace($field['@ref'])->getItems(['@primaryKey' => $remoteIds]))
+          : [];
       } else throw new Exception("Schema error for field '{$fieldName}' ns({$this->_namespace})");
     }
     return $object;

+ 83 - 36
SE/se-lib/Route/UrlAction/UserProNetMediaZaliczka.php

@@ -10,12 +10,11 @@ Lib::loadClass('Route_UrlAction');
 Lib::loadClass('UI');
 Lib::loadClass('Core_AclHelper');
 
-// TODO: zaliczkaListaView:
-// TODO: btn "Dodaj Zaliczkę" $acl->addItem($item); // @require only 'worker' => [ 'id', 'login', 'name' ]
-// TODO: lista 10 najnowszych + btn "load more ..."
-// TODO: Rozlicz / Podgląd - tylko najnowsza Zaliczka
-// TODO: Rozlicz / Podgląd - edytowć może tylko właściciel / grupa / user connected by REF ?
-// TODO: create view for printZaliczka to view older rows
+// - [ ] zaliczkaListaView:
+//   - [ ] btn "Dodaj Zaliczkę" $acl->addItem($item); // @require only 'worker' => [ 'id', 'login', 'name' ]
+//   - [ ] lista wszystkich zaliczek danego usera + btn "load more ..."
+//   - [x] Rozlicz / Podgląd - tylko najnowsza Zaliczka
+//   - [ ] Rozlicz / Podgląd - edytowć może tylko właściciel / grupa / user connected by REF ?
 
 class Route_UrlAction_UserProNetMediaZaliczka extends RouteBase {// TODO: UrlActionBase @see Route_UrlAction
 
@@ -61,14 +60,24 @@ class Route_UrlAction_UserProNetMediaZaliczka extends RouteBase {// TODO: UrlAct
 		$args['idZaliczka'] = V::get('idZaliczka', 0, $_REQUEST, 'int');// (int)$args['idZaliczka'];
 		if ($args['idZaliczka'] <= 0) throw new HttpException("Error Parsing Request - missing idZaliczka", 400);
 
-		$acl = Core_AclHelper::getAclByNamespace("default_db/ZALICZKA/Zaliczka");
+		$acl = ACL::getAclByNamespace("default_db/ZALICZKA/Zaliczka");
 		$schema = $acl->getSimpleSchemaTree();
 		if (!empty($args['updates'])) {
-			throw new Exception("TODO: F." . __FUNCTION__ . " L." . __LINE__);
+			throw new Exception("TODO: updates! F." . __FUNCTION__ . " L." . __LINE__);
 		}
 
-		$zaliczkaData = $this->fetchDataBySchema($schema, $args['idUser']);
+		$zaliczkaData = $acl->getItem($args['idZaliczka'], [
+			'cols' => [
+				'id',
+				'created',
+				'kwota',
+				'nierozliczona_kwota',
+				'pozycja',
+				'worker',
+			]
+		]);// $this->fetchDataBySchema($schema, $args['idUser']);
 		return [
+			'type' => 'success',
 			'nierozliczonaKwota' => V::get('nierozliczona_kwota', 0, $zaliczkaData),
 			'schema' => [
 				'zaliczka' => $schema,
@@ -83,7 +92,7 @@ class Route_UrlAction_UserProNetMediaZaliczka extends RouteBase {// TODO: UrlAct
 	public function fetchDataAjaxReponseCallback($args) {
 		if (empty($args) || empty($args['schema']['@namespace']) || empty($args['schema']['@namespace'])) throw new HttpException("Error Parsing Request - missing @namespace", 400);
 		$nsUri = $args['schema']['@namespace'];
-		if ('default_db/IN7_DZIENNIK_KORESP' == $nsUri) {
+		if ('default_db/IN7_DZIENNIK_KORESP/ZaliczkaKoresp' == $nsUri) {
 			return [
 				'options' => [
 					[ 'id' => "65432", 'title' => "testowa koresp 1", 'kategoriaKosztu' => "KOSZT1" ],
@@ -92,7 +101,7 @@ class Route_UrlAction_UserProNetMediaZaliczka extends RouteBase {// TODO: UrlAct
 				]
 			];
 		}
-		if ('default_db/IN7_MK_BAZA_DYSTRYBUCJI' == $nsUri) {
+		if ('default_db/IN7_MK_BAZA_DYSTRYBUCJI/ZaliczkaProjekt' == $nsUri) {
 			return [
 				'options' => [
 					[ 'id' => 100, 'nrBudowy' => 'Budowa 100/2016' ],
@@ -133,33 +142,36 @@ class Route_UrlAction_UserProNetMediaZaliczka extends RouteBase {// TODO: UrlAct
 	public function zaliczkaListaView($data) {
 		$idUser = V::get('idUser', User::getID(), $data);
 
+		$ownerAcl = Core_AclHelper::getAclByNamespace("default_objects/AccessOwner");
+		$user = $ownerAcl->getItem($idUser);// [id, login, name]
+		if (!$user) throw new Exception("Nie znaleziono pracownika o nr '{$idUser}'");
+
 		$acl = Core_AclHelper::getAclByNamespace("default_db/ZALICZKA/Zaliczka");
 		$schema = $acl->getSimpleSchemaTree();
 		$zaliczkaData = $this->fetchDataBySchema($schema, $idUser);
 
-		UI::startContainer();
+		UI::startContainer(['style' => "padding-top:20px"]);
 		UI::setTitle("Zaliczka");
 
-		UI::startTag('form', ['action'=>'', 'method'=>'POST']);
-			UI::emptyTag('input', ['type'=>"hidden", 'name'=>'_route', 'value'=>"UrlAction_UserProNetMediaZaliczka"]);
-			UI::emptyTag('input', ['type'=>"hidden", 'name'=>'_task', 'value'=>"add"]);
-			UI::emptyTag('input', ['type'=>"hidden", 'name'=>'idUser', 'value'=>$idUser]);
-			UI::emptyTag('input', ['type'=>"submit", 'value'=>"Dodaj nową zaliczkę", 'class'=>'btn btn-primary']);
-		UI::endTag('form');
-
 		UI::table([
-			'caption' => "Zaliczki:",
+			'caption' => "Zaliczki pracownika {$user['name']} " . UI::hButtonPost("Dodaj nową zaliczkę", [
+				'data' => [
+					'_route' => "UrlAction_UserProNetMediaZaliczka",
+					'_task' => "add",
+					'idUser' => $idUser,
+				],
+				'class' => 'btn-xs btn-primary'
+			]),
 			'rows' => array_map(
 				function ($row) use ($idUser) {
-					static $isFirst = true;
+					$instance = DB::getPDO()->fetchValue("select INSTANCE_NAME from `ZALICZKA__#INSTANCE` where PRIMARY_KEY = {$row['ID']}");
 					$editLink = Request::getPathUri() . "index.php?_route=UrlAction_UserProNetMediaZaliczka&idUser={$idUser}&idZaliczka={$row['ID']}";
-					$editLabel = ($isFirst) ? "Rozlicz / Podgląd" : "Podgląd";
-					if ($isFirst) $isFirst = false;
+					$editLabel = ('ZaliczkaAktywna' == $instance) ? "Rozlicz / Podgląd" : "Podgląd";
 					$histLink = Request::getPathUri() . "index.php?_route=UrlAction_UserProNetMediaZaliczka&_task=hist&idUser={$idUser}&idZaliczka={$row['ID']}";
 					return [
 						'Nr' => $row['ID'],
 						'Status' => $row['A_STATUS'],
-						'INSTANCE' => DB::getPDO()->fetchValue("select INSTANCE_NAME from `ZALICZKA__#INSTANCE` where PRIMARY_KEY = {$row['ID']}"),
+						'INSTANCE' => $instance,
 						'L_APPOITMENT_USER' => $row['L_APPOITMENT_USER'],
 						'KWOTA' => $row['KWOTA'],
 						'NIEROZLICZONA_KWOTA' => $row['NIEROZLICZONA_KWOTA'],
@@ -167,17 +179,16 @@ class Route_UrlAction_UserProNetMediaZaliczka extends RouteBase {// TODO: UrlAct
 						'DBG' => '<a href="' . $histLink . '">' . "DBG HIST" . '</a>'
 					];
 				},
-				DB::getPDO()->fetchAll("
-					select z.*
-					from ZALICZKA z
-						join ADMIN_USERS u on(z.L_APPOITMENT_USER = u.ADM_ACCOUNT and u.ID = {$idUser})
-					order by z.ID DESC
-				")
+				$acl->getItems([
+					'#refFrom' => [
+						'namespace' => 'default_db__x3A__ADMIN_USERS/Worker',
+						'primaryKey' => $idUser
+					]
+				])
 			),
 			'empty_msg' => "Brak",
 			'disable_lp' => true,
 		]);
-		UI::alert('danger', "TODO: pierwsza na liście - aktualna - btn(Rozlicz)");// -> Edycja zaliczki
 
 		UI::endContainer();
 	}
@@ -303,6 +314,41 @@ window.location.href='{$redirectUrl}';
 			}
 			UI::endTag('pre');
 
+			ACL::getRefTable('default_db/ZALICZKA/Zaliczka', 'worker');
+			ACL::getRefTable('default_db/ZALICZKA/Zaliczka', 'pozycja');
+			ACL::getRefTable('default_db/ZALICZKA_POZYCJA/ZaliczkaPozycja', 'projekt');
+			ACL::getRefTable('default_db/ZALICZKA_POZYCJA/ZaliczkaPozycja', 'korespondencja');
+			$refZaliczkaTables = DB::getPDO()->fetchAll("
+				select t.*
+				from `CRM_REF_CONFIG` t
+				where t.ROOT_OBJECT_NS like 'default_db/ZALICZKA%'
+			");
+			UI::startTag('div', ['style'=>"margin:10px 0; max-width:100%; overflow:scroll; border:1px solid #ccc"]);
+			UI::table([
+				'caption' => "Tabela 'CRM_REF_CONFIG'",
+				'rows' => $refZaliczkaTables
+			]);
+			UI::endTag('div');
+			foreach ($refZaliczkaTables as $refInfo) {
+				$tableName = "CRM__#REF_TABLE__" . $refInfo['ID'];
+				UI::startTag('div', ['style'=>"margin:10px 0; max-width:100%; overflow:scroll; border:1px solid #ccc"]);
+				UI::table([
+					'caption' => "Tabela REF '{$tableName}' - <small><i>{$refInfo['ROOT_OBJECT_NS']} REF {$refInfo['CHILD_NAME']} ({$refInfo['CHILD_NS']})</i></small>",
+					'rows' => DB::getPDO()->fetchAll("
+						select t.*
+						from `{$tableName}` t
+					")
+				]);
+				UI::endTag('div');
+			}
+			if ('1' == V::get('_clear', '', $_GET)) {
+				foreach ($refZaliczkaTables as $refInfo) {
+					$tableName = "CRM__#REF_TABLE__" . $refInfo['ID'];
+					DB::getPDO()->exec("TRUNCATE `{$tableName}`");
+				}
+				UI::tag('a', ['class'=>"btn btn-primary", 'href'=>"index.php?_route=UrlAction_UserProNetMediaZaliczka&_task=reinstall"], "Dane usunięte - odśwież stronę");
+			}
+
 			UI::endContainer();
 		} catch (Exception $e) {
 			UI::alert('danger', $e->getMessage());
@@ -319,17 +365,18 @@ window.location.href='{$redirectUrl}';
 
 		$acl = Core_AclHelper::getAclByNamespace("default_db/ZALICZKA/Zaliczka");
 		$schema = $acl->getSimpleSchemaTree();
+		DBG::nicePrint($schema, '$schema');
 		$zaliczkaData = $this->fetchDataBySchema($schema, $idUser);
 
-		DBG::nicePrint($zaliczkaData, '$zaliczkaData');// TODO: DBG
+		// DBG::nicePrint($zaliczkaData, '$zaliczkaData');// TODO: DBG
 
 		UI::inlineJS(__FILE__ . '.fetchData.js', [
-			'_initData' => $initData,
-			'syncUrl' => Request::getPathUri() . "index.php?_route=UrlAction_UserProNetMediaZaliczka&_task=fetchDataAjax&idUser={$idUser}&idZaliczka={$idZaliczka}"
+			'SYNC_URL' => Request::getPathUri() . "index.php?_route=UrlAction_UserProNetMediaZaliczka&_task=fetchDataAjax&idUser={$idUser}&idZaliczka={$idZaliczka}",
+			'DBG' => (DBG::isActive())
 		]);
 		UI::inlineJS(__FILE__ . '.syncState.js', [
-			'_initData' => $initData,
-			'syncUrl' => Request::getPathUri() . "index.php?_route=UrlAction_UserProNetMediaZaliczka&_task=syncStataAjax&idUser={$idUser}&idZaliczka={$idZaliczka}"
+			'SYNC_URL' => Request::getPathUri() . "index.php?_route=UrlAction_UserProNetMediaZaliczka&_task=syncStataAjax&idUser={$idUser}&idZaliczka={$idZaliczka}",
+			'DBG' => (DBG::isActive())
 		]);
 		UI::tag('script', ['src'=>'static/vendor.js' . (V::get('DBG', '', $_GET) ? '?_ts=' . time() : ''), 'type'=>'text/javascript']);
 		UI::tag('script', ['src'=>'static/zaliczka/main.js' . (V::get('DBG', '', $_GET) ? '?_ts=' . time() : ''), 'type'=>'text/javascript']);

+ 24 - 24
SE/se-lib/Route/UrlAction/UserProNetMediaZaliczka.php.fetchData.js

@@ -1,9 +1,9 @@
-// @require var syncUrl = ''
+// @require var SYNC_URL
 
 function zaliczkaFetchData(query, fieldType, resultCallback) {
   console.warn('TODO: zaliczkaFetchData(query, fieldType, resultCallback)  query('+query+') fieldType:', fieldType);
 
-  // fieldType: Object {"@baseTypeName": "default_db:IN7_DZIENNIK_KORESP", id: "xsd:integer", title: "xsd:string", kategoriaKosztu: "xsd:string"}
+  // fieldType: Object {"@namespace": "default_db:IN7_DZIENNIK_KORESP", id: "xsd:integer", title: "xsd:string", kategoriaKosztu: "xsd:string"}
   if ('object' === typeof fieldType) {
     if (!fieldType['@namespace']) {
       // TODO: log error
@@ -11,31 +11,31 @@ function zaliczkaFetchData(query, fieldType, resultCallback) {
       return;
     }
     switch (fieldType['@namespace']) {
-			case 'default_db/IN7_MK_BAZA_DYSTRYBUCJI':
-      case 'default_db/IN7_DZIENNIK_KORESP':
-			{
-				superagent
-					.post(syncUrl)
-					.type('json') // header ĺapplication/x-www-form-urlencoded' requires type('form');
-					.send({
-						schema: fieldType,
-						query: query
-					})
-					.set('Accept', 'application/json')
-					.end(function(err, res) {
-						var payload = (err || !res.ok || 'application/json' !== res.type)
-							? {type: 'warning', msg: (res.body && res.body.msg) ? res.body.msg : 'Request error', body: res.body}
-							: {type: 'success', msg: res.body.msg || '', body: res.body}
-						jQuery(document).trigger('DBG:notify', payload)
-						console.log('F.fetchDataAjax res.body', res.body)
-						console.log('F.fetchDataAjax payload', payload)
-						jQuery.notify(payload.msg, payload.type)
-						resultCallback(payload.body)
-					});
+      case 'default_db/IN7_MK_BAZA_DYSTRYBUCJI/ZaliczkaProjekt':
+      case 'default_db/IN7_DZIENNIK_KORESP/ZaliczkaKoresp':
+      {
+        superagent
+          .post(SYNC_URL)
+          .type('json') // header ĺapplication/x-www-form-urlencoded' requires type('form');
+          .send({
+            schema: fieldType,
+            query: query
+          })
+          .set('Accept', 'application/json')
+          .end(function(err, res) {
+            var payload = (err || !res.ok || 'application/json' !== res.type)
+              ? {type: 'warning', msg: (res.body && res.body.msg) ? res.body.msg : 'Request error', body: res.body}
+              : {type: 'success', msg: res.body.msg || '', body: res.body}
+            jQuery(document).trigger('DBG:notify', payload)
+            console.log('F.fetchDataAjax res.body', res.body)
+            console.log('F.fetchDataAjax payload', payload)
+            jQuery.notify(payload.msg, payload.type)
+            resultCallback(payload.body)
+          });
 			}
       break;
       default: {
-        console.log("BUG: Unsupported type namespace '" + fieldType['@baseTypeName'] + "'");
+        console.log("BUG: Unsupported type namespace '" + fieldType['@namespace'] + "'");
       }
     }
   } else {

+ 30 - 18
SE/se-lib/Route/UrlAction/UserProNetMediaZaliczka.php.syncState.js

@@ -1,26 +1,38 @@
-// @require var syncUrl = ''
+// @require var SYNC_URL
+// @require var DBG
 
 function syncZaliczkaState(state, updates, stateSyncSyccessCallback, stateSyncErrorCallback) {
   // TODO: if ajax success then stateSyncSyccessCallback(Response.data)
   // TODO: if ajax fail then stateSyncErrorCallback(Response.data)
-  console.log('====== TODO: syncZaliczkaState updates:', updates, 'state:', state);
-	superagent
-		.post(syncUrl)
-		.type('json') // header ĺapplication/x-www-form-urlencoded' requires type('form');
-		.send({
-			updates: updates,
-		})
-		.set('Accept', 'application/json')
-		.end(function(err, res) {
-			var payload = (err || !res.ok || 'application/json' !== res.type)
-				? {type: 'warning', msg: (res.body && res.body.msg) ? res.body.msg : 'Request error', body: res.body}
-				: {type: 'success', msg: res.body.msg || '', body: res.body}
-			jQuery(document).trigger('DBG:notify', payload)
-			console.log('F.syncZaliczkaState res.body', res.body)
-			console.log('F.syncZaliczkaState payload', payload)
-			jQuery.notify(payload.msg, payload.type)
+  if(DBG){console.log('====== TODO: syncZaliczkaState updates:', updates, 'state:', state);}
+
+  fetch(SYNC_URL, {
+    method: 'POST',
+    credentials: 'same-origin',// add cookies
+    headers: {
+      "Content-Type": "application/json",
+      "Accept": "application/json"
+    },
+    body: JSON.stringify({
+      updates: updates
+    })
+  }).then(function (res) {
+    return res.json()
+  }).then(function (body) {
+    if(DBG){console.log('====== syncZaliczkaState:fetch: req finished. body:', body);}
+    var payload = (!body || 'success' !== body.type)
+      ? { type: 'warning', msg: (body && body.msg) ? body.msg : 'Request error', body: body }
+      : { type: 'success', msg: body.msg || '', body: body }
+
+    if(DBG){console.log('====== syncZaliczkaState:fetch: req finished. payload:', payload);}
+
+    if ('success' == payload.type) {
 			stateSyncSyccessCallback({data: payload.body})
-		});
+    } else {
+      p5UI__notifyAjaxCallback(payload)
+      stateSyncErrorCallback({data: payload.body});
+    }
+  });
 }
 
 global.syncZaliczkaState = syncZaliczkaState

+ 18 - 0
SE/se-lib/Schema/DefaultDb/in7_dziennik_koresp/ZaliczkaKorespStorageAcl.php

@@ -0,0 +1,18 @@
+<?php
+
+Lib::loadClass('Core_AclSimpleSchemaBase');// extends Core_AclBase
+Lib::loadClass('Core_AclHelper');
+
+class Schema_DefaultDb_in7_dziennik_koresp_ZaliczkaKorespStorageAcl extends Core_AclSimpleSchemaBase {
+
+  public $_simpleSchema = [
+    'root' => [
+      '@namespace' => 'default_db/IN7_DZIENNIK_KORESP/ZaliczkaKoresp',
+      '@primaryKey' => 'id',
+      'id' => [ '@type' => 'xsd:integer', '@alias' => 'ID' ],
+      'title' => [ '@type' => 'xsd:string', '@alias' => 'K_ZAWARTOS' ],
+      'kategoriaKosztu' => [ '@type' => 'xsd:string', '@alias' => 'KATEGORIA_KOSZTU' ],
+    ],
+  ];
+
+}

+ 17 - 0
SE/se-lib/Schema/DefaultDb/in7_mk_baza_dystrybucji/ZaliczkaProjektStorageAcl.php

@@ -0,0 +1,17 @@
+<?php
+
+Lib::loadClass('Core_AclSimpleSchemaBase');// extends Core_AclBase
+Lib::loadClass('Core_AclHelper');
+
+class Schema_DefaultDb_in7_mk_baza_dystrybucji_ZaliczkaProjektStorageAcl extends Core_AclSimpleSchemaBase {
+
+  public $_simpleSchema = [
+    'root' => [
+      '@namespace' => 'default_db/IN7_MK_BAZA_DYSTRYBUCJI/ZaliczkaProjekt',
+      '@primaryKey' => 'id',
+      'id' => [ '@type' => 'xsd:integer', '@alias' => 'ID' ],
+      'nrBudowy' => [ '@type' => 'xsd:string', '@alias' => 'M_DIST_DEALNUM' ],// TODO: ? M_DIST_DESC (szerszy opis)
+    ],
+  ];
+
+}

+ 26 - 0
SE/se-lib/Schema/DefaultDb/zaliczka/ZaliczkaAktywnaStorageAcl.php

@@ -0,0 +1,26 @@
+<?php
+
+Lib::loadClass('Core_AclSimpleSchemaBase');// extends Core_AclBase
+Lib::loadClass('Core_AclHelper');
+Lib::loadClass('Schema_DefaultDb_zaliczka_ZaliczkaStorageAcl');
+
+class Schema_DefaultDb_zaliczka_ZaliczkaAktywnaStorageAcl extends Schema_DefaultDb_zaliczka_ZaliczkaStorageAcl {
+
+  public $_simpleSchema = [
+    'root' => [
+      '@namespace' => 'default_db/ZALICZKA/ZaliczkaAktywna',// Api_WfsNs::getBaseWfsUri() . '/default_db/Zaliczka'
+      '@derived' => [
+        'default_db/ZALICZKA/Zaliczka'
+      ],
+      '@primaryKey' => 'id',
+      'id' => 'xsd:integer',
+      'created' => [ '@type' => 'xsd:date', '@alias' => 'A_RECORD_CREATE_DATE' ],
+      'worker' => [ '@ref' => 'default_objects/AccessOwner' ],// 'alias_ref:default_objects:AccessOwner'
+      // 'worker' => [ '@ref' => 'Worker' ],
+      'kwota' => [ '@type' => 'xsd:decimal', '@totalDigits' => 16, '@fractionDigits' => 2 ],
+      'nierozliczona_kwota' => [ '@type' => 'xsd:decimal', '@totalDigits' => 16, '@fractionDigits' => 2 ],
+      'pozycja' => [ '@ref' => 'default_db/ZALICZKA_POZYCJA/ZaliczkaPozycja', '@maxOccurs' => 'unbounded' ]
+    ],
+  ];
+
+}

+ 1 - 11
SE/se-lib/Schema/DefaultDb/zaliczka/ZaliczkaAnulowanaStorageAcl.php

@@ -12,6 +12,7 @@ class Schema_DefaultDb_zaliczka_ZaliczkaAnulowanaStorageAcl extends Schema_Defau
       '@derived' => [
         'default_db/ZALICZKA/Zaliczka'
       ],
+      '@primaryKey' => 'id',
       'id' => 'xsd:integer',
       'created' => [ '@type' => 'xsd:date', '@alias' => 'A_RECORD_CREATE_DATE' ],
       'worker' => [ '@ref' => 'default_objects/AccessOwner' ],// 'alias_ref:default_objects:AccessOwner'
@@ -20,17 +21,6 @@ class Schema_DefaultDb_zaliczka_ZaliczkaAnulowanaStorageAcl extends Schema_Defau
       'nierozliczona_kwota' => [ '@type' => 'xsd:decimal', '@totalDigits' => 16, '@fractionDigits' => 2 ],
       'pozycja' => [ '@ref' => 'default_db/ZALICZKA_POZYCJA/ZaliczkaPozycja', '@maxOccurs' => 'unbounded' ]
     ],
-    'Korespondencja' => [
-      '@namespace' => 'default_db/IN7_DZIENNIK_KORESP',
-      'id' => [ '@type' => 'xsd:integer', '@alias' => 'ID' ],
-      'title' => [ '@type' => 'xsd:string', '@alias' => 'K_ZAWARTOS' ],
-      'kategoriaKosztu' => [ '@type' => 'xsd:string', '@alias' => 'KATEGORIA_KOSZTU' ]
-    ],
-    'Projekt' => [
-      '@namespace' => 'default_db/IN7_MK_BAZA_DYSTRYBUCJI',
-      'id' => [ '@type' => 'xsd:integer', '@alias' => 'ID' ],
-      'nrBudowy' => [ '@type' => 'xsd:string', '@alias' => 'M_DIST_DEALNUM' ],// TODO: ? M_DIST_DESC (szerszy opis)
-    ],
   ];
 
 }

+ 26 - 0
SE/se-lib/Schema/DefaultDb/zaliczka/ZaliczkaArchiwalnaStorageAcl.php

@@ -0,0 +1,26 @@
+<?php
+
+Lib::loadClass('Core_AclSimpleSchemaBase');// extends Core_AclBase
+Lib::loadClass('Core_AclHelper');
+Lib::loadClass('Schema_DefaultDb_zaliczka_ZaliczkaStorageAcl');
+
+class Schema_DefaultDb_zaliczka_ZaliczkaArchiwalnaStorageAcl extends Schema_DefaultDb_zaliczka_ZaliczkaStorageAcl {
+
+  public $_simpleSchema = [
+    'root' => [
+      '@namespace' => 'default_db/ZALICZKA/ZaliczkaArchiwalna',// Api_WfsNs::getBaseWfsUri() . '/default_db/Zaliczka'
+      '@derived' => [
+        'default_db/ZALICZKA/Zaliczka'
+      ],
+      '@primaryKey' => 'id',
+      'id' => 'xsd:integer',
+      'created' => [ '@type' => 'xsd:date', '@alias' => 'A_RECORD_CREATE_DATE' ],
+      'worker' => [ '@ref' => 'default_objects/AccessOwner' ],// 'alias_ref:default_objects:AccessOwner'
+      // 'worker' => [ '@ref' => 'Worker' ],
+      'kwota' => [ '@type' => 'xsd:decimal', '@totalDigits' => 16, '@fractionDigits' => 2 ],
+      'nierozliczona_kwota' => [ '@type' => 'xsd:decimal', '@totalDigits' => 16, '@fractionDigits' => 2 ],
+      'pozycja' => [ '@ref' => 'default_db/ZALICZKA_POZYCJA/ZaliczkaPozycja', '@maxOccurs' => 'unbounded' ]
+    ],
+  ];
+
+}

+ 49 - 91
SE/se-lib/Schema/DefaultDb/zaliczka/ZaliczkaStorageAcl.php

@@ -8,98 +8,67 @@ class Schema_DefaultDb_zaliczka_ZaliczkaStorageAcl extends Core_AclSimpleSchemaB
   public $_simpleSchema = [
     'root' => [
       '@namespace' => 'default_db/ZALICZKA/Zaliczka',// Api_WfsNs::getBaseWfsUri() . '/default_db/Zaliczka'
-      'id' => 'xsd:integer',
+      '@primaryKey' => 'id',
+      'id' => [ '@type' => 'xsd:integer', '@alias' => 'ID' ],
       'created' => [ '@type' => 'xsd:date', '@alias' => 'A_RECORD_CREATE_DATE' ],
       'worker' => [ '@ref' => 'default_objects/AccessOwner' ],// 'alias_ref:default_objects:AccessOwner'
-      // 'worker' => [ '@ref' => 'Worker' ],
-      'kwota' => [ '@type' => 'xsd:decimal', '@totalDigits' => 16, '@fractionDigits' => 2 ],
-      'nierozliczona_kwota' => [ '@type' => 'xsd:decimal', '@totalDigits' => 16, '@fractionDigits' => 2 ],
+      'kwota' => [ '@type' => 'xsd:decimal', '@totalDigits' => 16, '@fractionDigits' => 2, '@alias' => 'KWOTA' ],
+      'nierozliczona_kwota' => [ '@type' => 'xsd:decimal', '@totalDigits' => 16, '@fractionDigits' => 2, '@alias' => 'NIEROZLICZONA_KWOTA' ],
       'pozycja' => [ '@ref' => 'default_db/ZALICZKA_POZYCJA/ZaliczkaPozycja', '@maxOccurs' => 'unbounded' ]
     ],
-    // 'ZaliczkaPozycja' => [
-    //   '@namespace' => 'default_db/ZALICZKA_POZYCJA/ZaliczkaPozycja',// Api_WfsNs::getBaseWfsUri() . '/default_db/Zaliczka'
-    //   'id' => 'xsd:integer',
-    //   'kwota' => [ '@type' => 'xsd:decimal', '@totalDigits' => 16, '@fractionDigits' => 2 ],
-    //   'korespondencja' => [ '@ref' => 'Korespondencja' ],
-    //   'projekt' => [ '@ref' => 'Projekt' ]
-    // ],
-    'Korespondencja' => [
-      '@namespace' => 'default_db/IN7_DZIENNIK_KORESP',
-      'id' => [ '@type' => 'xsd:integer', '@alias' => 'ID' ],
-      'title' => [ '@type' => 'xsd:string', '@alias' => 'K_ZAWARTOS' ],
-      'kategoriaKosztu' => [ '@type' => 'xsd:string', '@alias' => 'KATEGORIA_KOSZTU' ]
-    ],
-    'Projekt' => [
-      '@namespace' => 'default_db/IN7_MK_BAZA_DYSTRYBUCJI',
-      'id' => [ '@type' => 'xsd:integer', '@alias' => 'ID' ],
-      'nrBudowy' => [ '@type' => 'xsd:string', '@alias' => 'M_DIST_DEALNUM' ],// TODO: ? M_DIST_DESC (szerszy opis)
-    ],
-    // 'worker' => [
-    //   '@namespace' => 'default_objects/AccessOwner',
-    //   'login' => 'xsd:string',
-    //   'name' => 'xsd:string'
-    // ]
   ];
-  // [
-  //   '@typeName' => 'default_db__x3A__ZALICZKA:Zaliczka',
-  //   '@baseTypeName' => 'default_db:ZALICZKA',
-  //   '@namespace' => 'default_db/ZALICZKA/Zaliczka',// Api_WfsNs::getBaseWfsUri() . '/default_db/Zaliczka'
-  //   'id' => 'xsd:integer',
-  //   'created' => 'xsd:date',
-  //   'worker' => [
-  //     '@namespace' => 'default_objects/AccessOwner',// alias_ref:default_objects:AccessOwner
-  //   ],
-  //   'kwota' => 'xsd:decimal',
-  //   'pozycja' => [
-  //     '@namespace' => 'default_db/ZALICZKA_POZYCJA/ZaliczkaPozycja',// alias_ref:default_db__x3A__ZALICZKA_POZYCJA:ZaliczkaPozycja
-  //     '@maxOccurs' => 'unbounded',
-  //     // 'id' => 'xsd:integer',
-  //     // 'kwota' => 'xsd:decimal',
-  //     // 'korespondencja' => [// 'ref:korespondencja'
-  //     // 	'@namespace' => 'default_db/IN7_DZIENNIK_KORESP',
-  //     // 	'id' => 'xsd:integer',
-  //     // 	'title' => 'xsd:string',
-  //     // 	'kategoriaKosztu' => 'xsd:string'
-  //     // ],
-  //     // 'projekt' => [// 'ref:projekt'
-  //     // 	'@namespace' => 'default_db/IN7_MK_BAZA_DYSTRYBUCJI',
-  //     // 	'id' => 'xsd:integer',
-  //     // 	'nrBudowy' => 'xsd:string'
-  //     // ]
-  //   ]
-  // ];
 
   public function getTotal($params = array()) {
-    return 10;
+    if (!isset($params['#refFrom'])) {
+      throw new Exception("Missing param #refFrom/primaryKey (id user)");
+    }
+    $idUser = V::get('primaryKey', 0, $params['#refFrom'], 'int');
+    return DB::getPDO()->fetchValue("
+      select count(*) as cnt
+      from ZALICZKA z
+        join ADMIN_USERS u on(z.L_APPOITMENT_USER = u.ADM_ACCOUNT and u.ID = {$idUser})
+    ");
   }
 
   public function getItems($params = array()) {
-    return [
-      [ 'id'=>1, 'created' => date("Y-m-d") ],
-      [ 'id'=>2, 'created' => date("Y-m-d") ],
-    ];
+    // '#refFrom' => [
+    //   'namespace' => 'default_db__x3A__ADMIN_USERS/Worker',
+    //   'primaryKey' => $idUser
+    // ]
+    if (!isset($params['#refFrom'])) {
+      throw new Exception("Missing param #refFrom/primaryKey (id user)");
+    }
+    $idUser = V::get('primaryKey', 0, $params['#refFrom'], 'int');
+    return DB::getPDO()->fetchAll("
+      select z.*
+      from ZALICZKA z
+        join ADMIN_USERS u on(z.L_APPOITMENT_USER = u.ADM_ACCOUNT and u.ID = {$idUser})
+      order by z.ID DESC
+    ");
   }
 
   public function addItem($itemTodo) {
     // TODO: btn "Dodaj Zaliczkę" $acl->addItem($item); // @require only 'worker' => [ 'id', 'login', 'name' ]
-    DBG::nicePrint($itemTodo, '$itemTodo');// TODO: DBG
+    $DBG = V::get('DBG', '', $_GET);
+    if($DBG){DBG::nicePrint($itemTodo, '$itemTodo');}
 
     if (!is_array($itemTodo) || empty($itemTodo['worker'])) throw new Exception("Missing worker");
     if (empty($itemTodo['worker']['id'])) throw new Exception("Missing worker id");
     $idUser = intval($itemTodo['worker']['id']);
     if ($idUser <= 0) throw new Exception("Wrong worker id");
 
+    // TODO: use default_objects/AccessOwner -> getItem($idUser)
     $userLogin = DB::getPDO()->fetchValue("
       select u.ADM_ACCOUNT
       from `ADMIN_USERS` u
       where u.ID = {$idUser}
     ");
     if (empty($userLogin)) throw new Exception("User not exists ID={$idUser}");
-    DBG::nicePrint($userLogin, '$userLogin');// TODO: DBG
+    if($DBG){DBG::nicePrint($userLogin, '$userLogin');}
 
     $idTransaction = Core_AclHelper::startTransaction('ZALICZKA', $idUser, $userLogin);
 
-    $zaliczkaRefWorker = Core_AclHelper::getRefTable('Zaliczka', 'worker');// `Zaliczka__#REF__worker`
+    $zaliczkaRefWorker = ACL::getRefTable('default_db/ZALICZKA/Zaliczka', 'worker');
     $idActiveZaliczka = DB::getPDO()->fetchValue("
       select MAX(t.ID)
       from `ZALICZKA` t
@@ -109,8 +78,7 @@ class Schema_DefaultDb_zaliczka_ZaliczkaStorageAcl extends Core_AclSimpleSchemaB
       where r.ID = {$idUser}
         and t.A_STATUS in('WAITING', 'NORMAL') -- TODO cache use #INSTANCE table
     ");
-    $zaliczkaRefWorker = Core_AclHelper::getRefTable('Zaliczka', 'worker');// `Zaliczka__#REF__worker`
-    DBG::nicePrint("
+    if($DBG){DBG::nicePrint("
       select MAX(t.ID)
       from `ZALICZKA` t
         -- join `ADMIN_USERS` u on(t.L_APPOITMENT_USER = u.ADM_ACCOUNT)
@@ -118,12 +86,12 @@ class Schema_DefaultDb_zaliczka_ZaliczkaStorageAcl extends Core_AclSimpleSchemaB
         left join `ADMIN_USERS` r on(r.ID = ref.REMOTE_PRIMARY_KEY)
       where r.ID = {$idUser}
         and t.A_STATUS in('WAITING', 'NORMAL') -- TODO cache use #INSTANCE table
-    ", 'sql');// TODO: DBG
-    DBG::nicePrint($idActiveZaliczka, '$idActiveZaliczka');// TODO: DBG
+    ", 'sql');}
+    if($DBG){DBG::nicePrint($idActiveZaliczka, '$idActiveZaliczka');}
 
     $userSaldo = 0;
     if ($idActiveZaliczka > 0) {
-      $zaliczkaRefPozycja = Core_AclHelper::getRefTable('Zaliczka', 'pozycja');// `Zaliczka__#REF__pozycja`
+      $zaliczkaRefPozycja = ACL::getRefTable('default_db/ZALICZKA/Zaliczka', 'pozycja');
       $userSaldo = DB::getPDO()->fetchValue("
     		select t.KWOTA + t.NIEROZLICZONA_KWOTA - sum(r.KWOTA)
     		from `ZALICZKA` t
@@ -131,7 +99,7 @@ class Schema_DefaultDb_zaliczka_ZaliczkaStorageAcl extends Core_AclSimpleSchemaB
     			left join `ZALICZKA_POZYCJA` r on(r.ID = ref.REMOTE_PRIMARY_KEY)
         where t.ID = {$idActiveZaliczka}
     	");
-      DBG::nicePrint($userSaldo, '$userSaldo');// TODO: DBG
+      if($DBG){DBG::nicePrint($userSaldo, '$userSaldo');}
     }
 
     $usrLogin = User::getLogin();
@@ -143,9 +111,9 @@ class Schema_DefaultDb_zaliczka_ZaliczkaStorageAcl extends Core_AclSimpleSchemaB
         from ADMIN_USERS u
         where u.ID = {$idUser}
     ");
-    DBG::nicePrint($execRet, '$execRet');// TODO: DBG
+    if($DBG){DBG::nicePrint($execRet, '$execRet');}
     $id = DB::getPDO()->lastInsertId();
-    DBG::nicePrint($id, '$id');// TODO: DBG
+    if($DBG){DBG::nicePrint($id, '$id');}
     if (!$id) throw new Exception("Wystąpiły błędy podczas dodawania Zaliczki do bazy danych");
 
     DB::getPDO()->exec("
@@ -160,7 +128,7 @@ class Schema_DefaultDb_zaliczka_ZaliczkaStorageAcl extends Core_AclSimpleSchemaB
       where z.ID != {$id}
         and z.L_APPOITMENT_USER = '{$userLogin}'
     ") as $instance) {
-      DBG::nicePrint($instance, '$instance');// TODO: DBG
+      if($DBG){DBG::nicePrint($instance, '$instance');}
 
       // FIX Instance name
       foreach (DB::getPDO()->fetchAll("
@@ -172,7 +140,7 @@ class Schema_DefaultDb_zaliczka_ZaliczkaStorageAcl extends Core_AclSimpleSchemaB
         where z.ID != {$id}
           and z.L_APPOITMENT_USER = '{$userLogin}'
       ") as $instance) {
-        DBG::nicePrint($instance, '$instance');// TODO: DBG
+        if($DBG){DBG::nicePrint($instance, '$instance');}
   			if (!$instance['has_instance']) {
           DB::getPDO()->exec("
     				insert into `ZALICZKA__#INSTANCE_HIST` (PRIMARY_KEY, INSTANCE_NAME)
@@ -216,27 +184,17 @@ class Schema_DefaultDb_zaliczka_ZaliczkaStorageAcl extends Core_AclSimpleSchemaB
     return $id;
   }
 
-  public function getItem($primaryKey) {
+  public function getItem($primaryKey, $params = []) {
     $zaliczkaRaw = DB::getPDO()->fetchAll("
       select t.*
       from `ZALICZKA` t
       where t.ID = {$primaryKey}
     ");
     $zaliczkaRaw = (!empty($zaliczkaRaw)) ? reset($zaliczkaRaw) : null;
-    DBG::nicePrint($zaliczkaRaw, '$zaliczkaRaw');
+    // DBG::nicePrint($zaliczkaRaw, '$zaliczkaRaw');
     if (!$zaliczkaRaw) return null;
-
-    foreach ($this->_simpleSchema['root'] as $fieldName => $field) {
-      if ('@' == substr($fieldName, 0, 1)) continue;
-      DBG::nicePrint($field, '$field['.$fieldName.']');
-      if (!empty($field['@type'])) {
-        UI::alert('warning', "TODO: field({$fieldName}) type({$field['@type']})");
-      } else if (!empty($field['@ref'])) {
-        UI::alert('warning', "TODO: field({$fieldName}) get ref table -> fetch value/s -> fetch HIST");
-      } else {
-        throw new Exception("Schema error for field '{$fieldName}'");
-      }
-    }
+    $filterCols = $this->getParamCols($params);
+    return $this->buildFromSqlRow($zaliczkaRaw, $params);
   }
 
   public function reinstall() {
@@ -308,10 +266,10 @@ class Schema_DefaultDb_zaliczka_ZaliczkaStorageAcl extends Core_AclSimpleSchemaB
 			) ENGINE=MyISAM  DEFAULT CHARSET=latin2;
 		");
 
-    Core_AclHelper::getRefTable('Zaliczka', 'worker');// `ZaliczkaPozycja__#REF__worker`
-    Core_AclHelper::getRefTable('Zaliczka', 'pozycja');// `Zaliczka__#REF__pozycja`
-    Core_AclHelper::getRefTable('ZaliczkaPozycja', 'korespondencja');// `ZaliczkaPozycja__#REF__Kkorespondencja`
-    Core_AclHelper::getRefTable('ZaliczkaPozycja', 'projekt');// `ZaliczkaPozycja__#REF__projekt`
+    ACL::getRefTable('default_db/ZALICZKA/Zaliczka', 'worker');
+    ACL::getRefTable('default_db/ZALICZKA/Zaliczka', 'pozycja');
+    ACL::getRefTable('default_db/ZALICZKA_POZYCJA/ZaliczkaPozycja', 'projekt');
+    ACL::getRefTable('default_db/ZALICZKA_POZYCJA/ZaliczkaPozycja', 'korespondencja');
 
     Core_AclHelper::getInstanceTable('ZALICZKA');// `ZALICZKA__#INSTANCE`
     // TODO: ZaliczkaOczekujaca   A_STATUS = WAITING  -- dodane przez pracownika

+ 19 - 0
SE/se-lib/Schema/DefaultDb/zaliczka_pozycja/ZaliczkaPozycjaStorageAcl.php

@@ -0,0 +1,19 @@
+<?php
+
+Lib::loadClass('Core_AclSimpleSchemaBase');// extends Core_AclBase
+Lib::loadClass('Core_AclHelper');
+
+class Schema_DefaultDb_zaliczka_pozycja_ZaliczkaPozycjaStorageAcl extends Core_AclSimpleSchemaBase {
+
+  public $_simpleSchema = [
+    'root' => [
+      '@namespace' => 'default_db/ZALICZKA_POZYCJA/ZaliczkaPozycja',// Api_WfsNs::getBaseWfsUri() . '/default_db/Zaliczka'
+      '@primaryKey' => 'id',
+      'id' => 'xsd:integer',
+      'kwota' => [ '@type' => 'xsd:decimal', '@totalDigits' => 16, '@fractionDigits' => 2 ],
+      'korespondencja' => [ '@ref' => 'default_db/IN7_DZIENNIK_KORESP/ZaliczkaKoresp' ],
+      'projekt' => [ '@ref' => 'default_db/IN7_MK_BAZA_DYSTRYBUCJI/ZaliczkaProjekt' ]
+    ],
+  ];
+
+}

Різницю між файлами не показано, бо вона завелика
+ 0 - 0
SE/static/zaliczka/main.js


Деякі файли не було показано, через те що забагато файлів було змінено