Преглед на файлове

added dbg zaliczka hist, added Zaliczka::getItem

Piotr Labudda преди 9 години
родител
ревизия
95de952288
променени са 2 файла, в които са добавени 43 реда и са изтрити 0 реда
  1. 20 0
      SE/se-lib/Route/UrlAction/UserProNetMediaZaliczka.php
  2. 23 0
      SE/se-lib/Schema/DefaultDb/zaliczka/ZaliczkaStorageAcl.php

+ 20 - 0
SE/se-lib/Route/UrlAction/UserProNetMediaZaliczka.php

@@ -335,6 +335,26 @@ window.location.href='{$redirectUrl}';
 		UI::tag('script', ['src'=>'static/zaliczka/main.js' . (V::get('DBG', '', $_GET) ? '?_ts=' . time() : ''), 'type'=>'text/javascript']);
 	}
 
+	public function histAction() {
+		UI::gora();
+		// UI::menu();
+		try {
+			$idZaliczka = V::get('idZaliczka', 0, $_GET, 'int');
+			if ($idZaliczka <= 0) throw new Exception("Missing idZaliczka");
+
+			$acl = Core_AclHelper::getAclByNamespace("default_db/ZALICZKA/Zaliczka");
+			$zaliczka = $acl->getItem($idZaliczka);
+			if (!$zaliczka) throw new Exception("Zaliczka not found!");
+
+			DBG::nicePrint($zaliczka, '$zaliczka');
+
+
+		} catch (Exception $e) {
+			UI::alert('danger', $e->getMessage());
+		}
+		UI::dol();
+	}
+
 }
 
 /*    Akcje

+ 23 - 0
SE/se-lib/Schema/DefaultDb/zaliczka/ZaliczkaStorageAcl.php

@@ -207,6 +207,29 @@ class Schema_DefaultDb_zaliczka_ZaliczkaStorageAcl extends Core_AclSimpleSchemaB
     return $id;
   }
 
+  public function getItem($primaryKey) {
+    $zaliczkaRaw = DB::getPDO()->fetchAll("
+      select t.*
+      from `ZALICZKA` t
+      where t.ID = {$primaryKey}
+    ");
+    $zaliczkaRaw = (!empty($zaliczkaRaw)) ? reset($zaliczkaRaw) : null;
+    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}'");
+      }
+    }
+  }
+
   public function reinstall() {
     // TODO: mv to Core_AclSimpleSchemaBase and reainstall by _simpleSchema - read current data from `information_schema`
 		DB::getPDO()->exec("