Overview

Namespaces

  • App
    • Components
    • Interfaces
    • Lib
      • Files
      • Forms
        • Controls
      • Html
      • Repair
      • Statics
    • Model
    • Modules
      • BaseModule
        • Presenters
      • PartnersModule
        • Presenters
      • ProductModule
        • Presenters
      • SaleModule
        • Model
        • Presenters
      • SettingsModule
        • Model
        • Presenters
      • StoreModule
        • Model
        • Presenters
    • Presenters
    • Router
  • PHP

Classes

  • DateTime
  • SplFileInfo

Interfaces

  • ArrayAccess
  • Countable
  • Exception
  • Iterator
  • Traversable
  • Overview
  • Namespace
  • Class
  • Tree
  • Deprecated
  • Download
  1: <?php
  2: 
  3: /**
  4:  * Project sberp
  5:  *
  6:  * @file Structure
  7:  * @author Jaromír Polášek
  8:  * @version 0.7.1.FORM
  9:  * Encoding UTF-8
 10:  */
 11: 
 12: namespace App\Lib;
 13: 
 14: use Nette\Database\Table\ActiveRow,
 15:     App\Lib\Statics\Cons;
 16: 
 17: /**
 18:  * Zpřístupňuje tabulky, jejich vlastnosti a sloupce 
 19:  */
 20: class Structure extends Container {
 21: 
 22:     /** @var Nette\Database\Table\ActiveRow */
 23:     private $table;
 24: 
 25:     /**
 26:      * Konstruktor vytváří instanci struktury tabulky a jejich polí
 27:      * @param string $table
 28:      */
 29:     public function __construct(ActiveRow $table) {
 30:     $this->table = $table;
 31:     $fields = $this->toArray($table->related(Cons::TABLE_TABLE . '_' . Cons::TABLE_FIELDS)->order(Cons::COLUMN_SEQ, 'ASC'));
 32:     parent::__construct($fields);
 33:     }
 34: 
 35:     /**
 36:      * Vrací název tabulky
 37:      * @return string
 38:      */
 39:     public function getName() {
 40:     return $this->table[Cons::COLUMN_NAME];
 41:     }
 42: 
 43:     /**
 44:      * Vrací Info o tabulce
 45:      * @return string
 46:      */
 47:     public function getDesc() {
 48:     return $this->table[Cons::COLUMN_DESC];
 49:     }
 50: 
 51:     /**
 52:      * Vrací položky tabulky
 53:      * @return Nette\Database\Table\Selection
 54:      */
 55:     public function getFields() {
 56:     return $this->fields;
 57:     }
 58: 
 59:     /**
 60:      * Vrací typ dat v tabulce (list - tree)
 61:      * @return string
 62:      */
 63:     public function getType() {
 64:     return $this->table[Cons::COLUMN_TYPE];
 65:     }
 66: 
 67:     /**
 68:      * Vrací název tabulky v Databázi
 69:      * @return string 
 70:      */
 71:     public function getObject() {
 72:     return $this->table[Cons::COLUMN_OBJECT];
 73:     }
 74: 
 75:     /**
 76:      * Vrací true, pokud má tabulka zápatí
 77:      * @return boolean
 78:      */
 79:     public function getFooter() {
 80:     return $this->table[Cons::COLUMN_FOOTER];
 81:     }
 82:     
 83:     /**
 84:      * Znemožní editaci u všech položek formuláře
 85:      * @return \App\Lib\Structure
 86:      */
 87:     public function disableFields() {
 88:     foreach ($this->container as $field) {
 89:         $this->disableField($field);
 90:     }
 91:     return $this;
 92:     }
 93: 
 94:     /**
 95:      * Znemožní editaci u položky formuláře
 96:      * @param \Nette\Database\GroupedSelection $field
 97:      * @return \App\Lib\Structure
 98:      */
 99:     public function disableField($field) {
100:     $field[Cons::COLUMN_READONLY] = '1';
101:     return $this;
102:     }
103: 
104:     /**
105:      * Odebere položku z formuláře
106:      * @param \Nette\Database\Table\ActiveRow  $field
107:      * @return \App\Lib\Structure
108:      */
109:     public function removeField($field) {
110:     unset($field);
111:     return $this;
112:     }
113: 
114:     /**
115:      * Zpřístupní metodu where z Nette\Database\Table\Selection
116:      * @param string $condition Podmínka
117:      * @param mixed $parameters Parametr
118:      */
119:     public function getColumn() {
120:     $column = array();
121:     foreach ($this->container as $key => $val) {
122:         if ($val[Cons::COLUMN_ROW] == '1') {
123:         $column[$key] = $val;
124:         }
125:     }
126:     return $column;
127:     }
128: 
129:     /**
130:      * Převede dotaz(objekt) na asociované pole.
131:      * @param array $array
132:      */
133:     private function toArray($selection, $array = array()) {
134:     foreach ($selection as $activeRow) {
135:         $array[$activeRow[Cons::COLUMN_FIELD]] = $activeRow->toArray();
136:         $array[$activeRow[Cons::COLUMN_FIELD]][Cons::TABLE_TABLE.'_'.Cons::COLUMN_ID] = $this->table[Cons::COLUMN_OBJECT];  
137:         $relation = $activeRow[Cons::TABLE_TABLE.'_'.Cons::TABLE_ELEMENTS];
138:         $array[$activeRow[Cons::COLUMN_FIELD]][Cons::TABLE_TABLE.'_'.Cons::TABLE_ELEMENTS.'_'.Cons::COLUMN_ID] = $relation[Cons::COLUMN_TYPE];
139:         $array[$activeRow[Cons::COLUMN_FIELD]][Cons::COLUMN_CLASS] = $relation[Cons::COLUMN_CLASS];
140:     }
141:     return $array;
142:     }
143: 
144: }
145: 
sberp API API documentation generated by ApiGen