Changeset 377


Ignore:
Timestamp:
Jan 20, 2012, 3:05:24 PM (13 years ago)
Author:
chronos
Message:
  • Upraveno: Testována instalace čisté databáze na základě definic modulů a jejich modelů.
  • Opraveno: Doplněny definice modelů pro FinanceMonthlyOverall a FinanceCharge.
  • Přidáno: Podpora pro nastavitelnost NULL hodnoty u vlastností modelů.
  • Opraveno: Řešení správného kaskádového načítání závislostí modulů.
Location:
trunk
Files:
2 added
12 edited

Legend:

Unmodified
Added
Removed
  • trunk/Common/Global.php

    r373 r377  
    6161  $System = new System($Database);
    6262  $System->Config = &$Config;
     63  $System->Install();
    6364  $System->ReloadList();
    6465  $System->Install();
     
    375376}
    376377
    377 GlobalInit();
     378function ProcessURL()
     379{
     380  if(array_key_exists('REDIRECT_QUERY_STRING', $_SERVER))
     381    $PathString = $_SERVER['REDIRECT_QUERY_STRING'];
     382    else $PathString = '';
     383  if(substr($PathString, -1, 1) == '/') $PathString = substr($PathString, 0, -1);
     384  //echo('"'.$QueryString.'"');
     385  $PathItems = explode('/', $PathString);
     386  if(strpos($_SERVER['REQUEST_URI'], '?') !== false)
     387    $_SERVER['QUERY_STRING'] = substr($_SERVER['REQUEST_URI'], strpos($_SERVER['REQUEST_URI'], '?') + 1);
     388    else $_SERVER['QUERY_STRING'] = '';   
     389  parse_str($_SERVER['QUERY_STRING'], $_GET);
     390  return($PathItems);
     391}
    378392
    379393?>
  • trunk/Common/Model.php

    r373 r377  
    3131  var $Properties;
    3232  var $System;
     33  var $Module;
     34  var $Installed;
    3335 
    3436  function __construct($Database, $System)
     
    3638    $this->Database = &$Database;
    3739    $this->System = &$System;
    38     $this->AddPropertyDateTime('TimeCreate');
    39     $this->AddPropertyOneToMany('UserCreate', 'User');
    40     $this->AddPropertyDateTime('TimeModify');
    41     $this->AddPropertyOneToMany('UserModify', 'User');
    42     $this->AddPropertyOneToMany('Module', 'Module');
    43   }
    44  
    45   function AddPropertyDateTime($Name)
    46   {
    47     $this->Properties[] = array('Name' => $Name, 'Type' => PropertyDateTime);
    48   }
    49  
    50   function AddPropertyDate($Name)
    51   {
    52     $this->Properties[] = array('Name' => $Name, 'Type' => PropertyDate);
    53   }
    54  
    55   function AddPropertyTime($Name)
    56   {
    57     $this->Properties[] = array('Name' => $Name, 'Type' => PropertyTime);
    58   }
    59  
    60   function AddPropertyOneToMany($Name, $TargetModel)
    61   {     
    62     $this->Properties[] = array('Name' => $Name, 'Type' => PropertyOneToMany, 'TargetModel' => $TargetModel);
    63   }
    64  
    65   function AddPropertyText($Name)
    66   {     
    67     $this->Properties[] = array('Name' => $Name, 'Type' => PropertyText);
    68   }
    69 
    70   function AddPropertyText8($Name)
    71   {     
    72     $this->Properties[] = array('Name' => $Name, 'Type' => PropertyText8);
    73   }
    74 
    75   function AddPropertyText16($Name)
    76   {     
    77     $this->Properties[] = array('Name' => $Name, 'Type' => PropertyText16);
    78   }
    79 
    80   function AddPropertyText24($Name)
    81   {     
    82     $this->Properties[] = array('Name' => $Name, 'Type' => PropertyText24);
    83   }
    84 
    85   function AddPropertyText32($Name)
    86   {     
    87     $this->Properties[] = array('Name' => $Name, 'Type' => PropertyText32);
    88   }
    89 
    90   function AddPropertyString($Name)
    91   {     
    92     $this->Properties[] = array('Name' => $Name, 'Type' => PropertyString);
    93   }
    94 
    95   function AddPropertyInteger($Name)
    96   {     
    97     $this->Properties[] = array('Name' => $Name, 'Type' => PropertyInteger);
    98   }
    99 
    100   function AddPropertyInteger8($Name)
    101   {     
    102     $this->Properties[] = array('Name' => $Name, 'Type' => PropertyInteger8);
    103   }
    104 
    105   function AddPropertyInteger16($Name)
    106   {     
    107     $this->Properties[] = array('Name' => $Name, 'Type' => PropertyInteger16);
    108   }
    109 
    110   function AddPropertyInteger24($Name)
    111   {     
    112     $this->Properties[] = array('Name' => $Name, 'Type' => PropertyInteger24);
    113   }
    114 
    115   function AddPropertyInteger32($Name)
    116   {     
    117     $this->Properties[] = array('Name' => $Name, 'Type' => PropertyInteger32);
    118   }
    119 
    120   function AddPropertyInteger64($Name)
    121   {     
    122     $this->Properties[] = array('Name' => $Name, 'Type' => PropertyInteger64);
    123   }
    124 
    125   function AddPropertyFloat($Name)
    126   {     
    127     $this->Properties[] = array('Name' => $Name, 'Type' => PropertyFloat);
    128   }
    129 
    130   function AddPropertyDouble($Name)
    131   {     
    132     $this->Properties[] = array('Name' => $Name, 'Type' => PropertyDouble);
    133   }
    134 
    135   function AddPropertyBoolean($Name)
    136   {
    137     $this->Properties[] = array('Name' => $Name, 'Type' => PropertyBoolean);
     40    $this->AddPropertyOneToMany('ItemOwnerModule', 'SystemModule', true);
     41    $this->AddPropertyDateTime('ItemTimeCreate', true);
     42    $this->AddPropertyOneToMany('ItemUserCreate', 'User', true);
     43    $this->AddPropertyDateTime('ItemTimeModify', true);
     44    $this->AddPropertyOneToMany('ItemUserModify', 'User', true);   
     45  }
     46 
     47  function AddPropertyDateTime($Name, $Null = false)
     48  {
     49    $this->Properties[] = array('Name' => $Name, 'Type' => PropertyDateTime,
     50      'Null' => $Null);
     51  }
     52 
     53  function AddPropertyDate($Name, $Null = false)
     54  {
     55    $this->Properties[] = array('Name' => $Name, 'Type' => PropertyDate,
     56      'Null' => $Null);
     57  }
     58 
     59  function AddPropertyTime($Name, $Null = false)
     60  {
     61    $this->Properties[] = array('Name' => $Name, 'Type' => PropertyTime,
     62      'Null' => $Null);
     63  }
     64 
     65  function AddPropertyOneToMany($Name, $TargetModel, $Null = false)
     66  {     
     67    $this->Properties[] = array('Name' => $Name, 'Type' => PropertyOneToMany,
     68      'TargetModel' => $TargetModel, 'Null' => $Null);
     69  }
     70 
     71  function AddPropertyText($Name, $Null = false)
     72  {     
     73    $this->Properties[] = array('Name' => $Name, 'Type' => PropertyText,
     74      'Null' => $Null);
     75  }
     76
     77  function AddPropertyText8($Name, $Null = false)
     78  {     
     79    $this->Properties[] = array('Name' => $Name, 'Type' => PropertyText8,
     80      'Null' => $Null);
     81  }
     82
     83  function AddPropertyText16($Name, $Null = false)
     84  {     
     85    $this->Properties[] = array('Name' => $Name, 'Type' => PropertyText16,
     86      'Null' => $Null);
     87  }
     88
     89  function AddPropertyText24($Name, $Null = false)
     90  {     
     91    $this->Properties[] = array('Name' => $Name, 'Type' => PropertyText24,
     92      'Null' => $Null);
     93  }
     94
     95  function AddPropertyText32($Name, $Null = false)
     96  {     
     97    $this->Properties[] = array('Name' => $Name, 'Type' => PropertyText32,
     98      'Null' => $Null);
     99  }
     100
     101  function AddPropertyString($Name, $Null = false)
     102  {     
     103    $this->Properties[] = array('Name' => $Name, 'Type' => PropertyString,
     104      'Null' => $Null);
     105  }
     106
     107  function AddPropertyInteger($Name, $Null = false)
     108  {     
     109    $this->Properties[] = array('Name' => $Name, 'Type' => PropertyInteger,
     110      'Null' => $Null);
     111  }
     112
     113  function AddPropertyInteger8($Name, $Null = false)
     114  {     
     115    $this->Properties[] = array('Name' => $Name, 'Type' => PropertyInteger8,
     116      'Null' => $Null);
     117  }
     118
     119  function AddPropertyInteger16($Name, $Null = false)
     120  {     
     121    $this->Properties[] = array('Name' => $Name, 'Type' => PropertyInteger16,
     122      'Null' => $Null);
     123  }
     124
     125  function AddPropertyInteger24($Name, $Null = false)
     126  {     
     127    $this->Properties[] = array('Name' => $Name, 'Type' => PropertyInteger24,
     128      'Null' => $Null);
     129  }
     130
     131  function AddPropertyInteger32($Name, $Null = false)
     132  {     
     133    $this->Properties[] = array('Name' => $Name, 'Type' => PropertyInteger32,
     134      'Null' => $Null);
     135  }
     136
     137  function AddPropertyInteger64($Name, $Null = false)
     138  {     
     139    $this->Properties[] = array('Name' => $Name, 'Type' => PropertyInteger64,
     140      'Null' => $Null);
     141  }
     142
     143  function AddPropertyFloat($Name, $Null = false)
     144  {     
     145    $this->Properties[] = array('Name' => $Name, 'Type' => PropertyFloat,
     146      'Null' => $Null);
     147  }
     148
     149  function AddPropertyDouble($Name, $Null = false)
     150  {     
     151    $this->Properties[] = array('Name' => $Name, 'Type' => PropertyDouble,
     152      'Null' => $Null);
     153  }
     154
     155  function AddPropertyBoolean($Name, $Null = false)
     156  {
     157    $this->Properties[] = array('Name' => $Name, 'Type' => PropertyBoolean,
     158      'Null' => $Null);
    138159  }
    139160 
    140   function AddPropertyManyToMany($TargetModel, $Relation, $ColumOwn, $ColumnTarget)
     161  function AddPropertyManyToMany($TargetModel, $Relation, $ColumnOwn, $ColumnTarget, $Null = false)
    141162  {     
    142163    $this->Properties[] = array('Type' => PropertyManyToMany,
    143       'TargetModel' => $TargetModel, 'Relation' => $Relation, 'ColumnOwn' => $ColumnOwn,
    144       'ColumnTarget' => $ColumnTarget);
     164      'TargetModel' => $TargetModel, 'Name' => $Relation, 'ColumnOwn' => $ColumnOwn,
     165      'ColumnTarget' => $ColumnTarget, 'Null' => $Null);
    145166  }
    146167 
    147168  function Install()
    148169  {
     170    if($this->Installed) return;
     171    $this->Installed = true;
    149172    $this->Database->insert('SystemModel', array('Name' => $this->Name, 'Module' => $this->Module->Id));
    150173    $this->Id = $this->Database->insert_id;
     
    156179      $this->Database->insert('SystemModelProperty', array('Name' => $Property['Name'],
    157180        'Model' => $this->Id, 'Type' => $Property['Type']));
     181      if($Property['Null']) $Null = 'NULL';
     182        else $Null = 'NOT NULL';
    158183      if($Property['Type'] == PropertyDateTime)
    159         $Query .= '`'.$Property['Name'].'` DATETIME NOT NULL,';
     184        $Query .= '`'.$Property['Name'].'` DATETIME '.$Null.',';
    160185      else if($Property['Type'] == PropertyDate)
    161         $Query .= '`'.$Property['Name'].'` DATE NOT NULL,';
     186        $Query .= '`'.$Property['Name'].'` DATE '.$Null.',';
    162187      else if($Property['Type'] == PropertyTime)
    163         $Query .= '`'.$Property['Name'].'` TIME NOT NULL,';
     188        $Query .= '`'.$Property['Name'].'` TIME '.$Null.',';
    164189      else if($Property['Type'] == PropertyString)
    165         $Query .= '`'.$Property['Name'].'` VARCHAR(255) COLLATE utf8_general_ci NOT NULL,';
     190        $Query .= '`'.$Property['Name'].'` VARCHAR(255) COLLATE utf8_general_ci '.$Null.',';
    166191      else if($Property['Type'] == PropertyText8)
    167         $Query .= '`'.$Property['Name'].'` TINYTEXT COLLATE utf8_general_ci NOT NULL,';
     192        $Query .= '`'.$Property['Name'].'` TINYTEXT COLLATE utf8_general_ci '.$Null.',';
    168193      else if($Property['Type'] == PropertyText16)
    169         $Query .= '`'.$Property['Name'].'` TEXT COLLATE utf8_general_ci NOT NULL,';
     194        $Query .= '`'.$Property['Name'].'` TEXT COLLATE utf8_general_ci '.$Null.',';
    170195      else if($Property['Type'] == PropertyText24)
    171         $Query .= '`'.$Property['Name'].'` MEDIUMTEXT COLLATE utf8_general_ci NOT NULL,';
     196        $Query .= '`'.$Property['Name'].'` MEDIUMTEXT COLLATE utf8_general_ci '.$Null.',';
    172197      else if($Property['Type'] == PropertyText32)
    173         $Query .= '`'.$Property['Name'].'` LONGTEXT COLLATE utf8_general_ci NOT NULL,';
     198        $Query .= '`'.$Property['Name'].'` LONGTEXT COLLATE utf8_general_ci '.$Null.',';
    174199      else if($Property['Type'] == PropertyInteger8)
    175         $Query .= '`'.$Property['Name'].'` TINYINT(4) NOT NULL,';
     200        $Query .= '`'.$Property['Name'].'` TINYINT(4) '.$Null.',';
    176201      else if($Property['Type'] == PropertyInteger16)
    177         $Query .= '`'.$Property['Name'].'` SMALLINT(6) NOT NULL,';
     202        $Query .= '`'.$Property['Name'].'` SMALLINT(6) '.$Null.',';
    178203      else if($Property['Type'] == PropertyInteger24)
    179         $Query .= '`'.$Property['Name'].'` MEDIUMINT(9) NOT NULL,';
     204        $Query .= '`'.$Property['Name'].'` MEDIUMINT(9) '.$Null.',';
    180205      else if($Property['Type'] == PropertyInteger32)
    181         $Query .= '`'.$Property['Name'].'` INT(11) NOT NULL,';
     206        $Query .= '`'.$Property['Name'].'` INT(11) '.$Null.',';
    182207      else if($Property['Type'] == PropertyInteger64)
    183         $Query .= '`'.$Property['Name'].'` BIGINT(20) NOT NULL,';
     208        $Query .= '`'.$Property['Name'].'` BIGINT(20) '.$Null.',';
    184209      else if($Property['Type'] == PropertyBoolean)
    185         $Query .= '`'.$Property['Name'].'` BOOLEAN NOT NULL,';
     210        $Query .= '`'.$Property['Name'].'` BOOLEAN '.$Null.',';
    186211      else if($Property['Type'] == PropertyFloat)
    187         $Query .= '`'.$Property['Name'].'` FLOAT NOT NULL,';
     212        $Query .= '`'.$Property['Name'].'` FLOAT '.$Null.',';
    188213      else if($Property['Type'] == PropertyDouble)
    189         $Query .= '`'.$Property['Name'].'` DOUBLE NOT NULL,';
     214        $Query .= '`'.$Property['Name'].'` DOUBLE '.$Null.',';
    190215      else if($Property['Type'] == PropertyOneToMany)
    191         $Query .= '`'.$Property['Name'].'` INT(255) NOT NULL,'.
     216        $Query .= '`'.$Property['Name'].'` INT(255)'.$Null.','.
    192217          'KEY `'.$Property['Name'].'` (`'.$Property['Name'].'`),';
    193218      else if($Property['Type'] == PropertyManyToMany) ;
     
    195220        //$Query .= '`'.$Property['Name'].'` INT(255) NOT NULL,'.
    196221        //  'KEY `'.$Property['Name'].'` (`'.$Property['Name'].'`),';
     222     
    197223    }
    198224    $Query .= 'PRIMARY KEY (`Id`)'.
     
    202228    {
    203229      if($Property['Type'] == PropertyOneToMany)
    204         $this->Database->query('ALTER TABLE `'.$this->Name.'` ADD CONSTRAINT '.
    205           '`'.$this->Name.'_ibfk_'.$Property['Name'].'` FOREIGN KEY (`'.$Property['TargetModel'].'`) REFERENCES `'.$Property['TargetModel'].'` (`Id`);');
     230      {
     231        if(!$this->Module->Models[$Property['TargetModel']]->Installed)
     232          $this->Module->Models[$Property['TargetModel']]->Install();
     233        $this->Database->query('ALTER TABLE `'.$this->Name.'` ADD FOREIGN KEY (`'.$Property['Name'].'`) REFERENCES `'.$Property['TargetModel'].'` (`Id`);');
     234      }
    206235    }
    207236  }
  • trunk/Common/Module.php

    r374 r377  
    2727  function Install()
    2828  {
     29    if($this->Installed) return;
    2930    DebugLog('Installing module '.$this->Name.'...');
     31    $this->Installed = true;
     32    foreach($this->Dependencies as $Dependency) 
     33      $this->System->Modules[$Dependency]->Install();
     34    $this->LoadModels();
    3035    foreach($this->Models as $ModelName)
    3136    {
    32       $Model = new $ModelName($this->Database, $this->System);
    33       $Model->Module = &$this;
    34       $Model->Install();
    35       unset($Model);
     37      $this->System->Models[$ModelName]->Install();
    3638    }
    3739    $this->Database->query('UPDATE SystemModule SET Installed=1 WHERE Name="'.$this->Name.'"');
     
    5254  function Init()
    5355  {
     56    if($this->Initialized) return;
    5457    $this->Initialized = true;
    5558    foreach($this->Dependencies as $Dependency) 
    56       if(!$this->System->Modules[$Dependency]->Initialized)
    57         $this->System->Modules[$Dependency]->Init();
     59      $this->System->Modules[$Dependency]->Init();
     60  }
     61 
     62  function LoadModels()
     63  {
     64    foreach($this->Models as $ModelName)
     65    {
     66      $this->System->Models[$ModelName] = new $ModelName($this->Database, $this->System);
     67      $this->System->Models[$ModelName]->Module = &$this;
     68    }       
    5869  }
    5970}
     
    7586  }
    7687
    77   function Init($Installed = true)
     88  function LoadModules($Installed = true)
    7889  {
    7990    $Query = 'SELECT `Id`, `Name` FROM `SystemModule`';
     
    8899      $this->Modules[$Module['Name']]->Id = $Module['Id'];
    89100    }     
     101  }
     102 
     103  function Init()
     104  {
    90105    foreach($this->Modules as $Index => $Module)
    91106      $this->Modules[$Index]->Init();
     
    103118  `Installed` int(11) NOT NULL,
    104119  `Description` text COLLATE utf8_czech_ci NOT NULL,
    105   `Dependecies` varchar(255) COLLATE utf8_czech_ci NOT NULL,
     120  `Dependencies` varchar(255) COLLATE utf8_czech_ci NOT NULL,
    106121  PRIMARY KEY (`Id`)
    107122) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_czech_ci AUTO_INCREMENT=1;');
     
    122137) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_czech_ci AUTO_INCREMENT=1;');
    123138    $this->ReloadList();
    124     $this->Init(false);
     139    $this->LoadModules(false);
    125140    foreach($this->Modules as $Index => $Module)
    126141    {
  • trunk/Modules/Finance/Finance.php

    r373 r377  
    8383}
    8484
     85class FinanceBillingPeriod extends Model
     86{
     87  function __construct($Database, $System)
     88  {
     89    parent::__construct($Database, $System);
     90    $this->Name = 'FinanceBillingPeriod';
     91    $this->AddPropertyString('Name');
     92    $this->AddPropertyInteger('MonthCount');
     93  }
     94}
     95
    8596class FinanceTariff extends Model
    8697{
     
    127138    $this->AddPropertyString('BillCode');
    128139    $this->AddPropertyOneToMany('Subject', 'Subject');
    129     $this->AddPropertyDateTime('TimeCreate');
     140    $this->AddPropertyDateTime('TimeCreation');
    130141    $this->AddPropertyDateTime('TimeDue');
    131142    $this->AddPropertyDateTime('TimePayment');
     
    163174    $this->AddPropertyFloat('Price');
    164175    $this->AddPropertyFloat('Quantity');
     176  }
     177}
     178
     179class FinanceCharge extends Model
     180{
     181  function __construct($Database, $System)
     182  {
     183    parent::__construct($Database, $System);
     184    $this->Name = 'FinanceCharge';
     185    $this->AddPropertyInteger('Period');
     186    $this->AddPropertyInteger('Internet');
     187    $this->AddPropertyInteger('InternetSpeed');
     188    $this->AddPropertyInteger('InternetSpeedReserve');
     189    $this->AddPropertyInteger('AdministrationPerUser');
     190    $this->AddPropertyInteger('kWh');
     191    $this->AddPropertyInteger('BaseSpeedElement');
     192    $this->AddPropertyInteger('BaseTariffPrice');
     193    $this->AddPropertyInteger('TopTariffPrice');
     194  }
     195}
     196
     197class FinanceMonthlyOverall extends Model
     198{
     199  function __construct($Database, $System)
     200  {
     201    parent::__construct($Database, $System);
     202    $this->Name = 'FinanceMonthlyOverall';
     203    $this->AddPropertyInteger('Money');
     204    $this->AddPropertyDate('Date');
     205    $this->AddPropertyInteger('Administration');
     206    $this->AddPropertyInteger('kWh');
     207    $this->AddPropertyInteger('AdministrationTotal');
     208    $this->AddPropertyInteger('ConsumptionTotal');
     209    $this->AddPropertyInteger('TotalPaid');
     210    $this->AddPropertyInteger('BaseTariffPrice');
     211    $this->AddPropertyInteger('TopTariffPrice');
     212    $this->AddPropertyInteger('MemberCount');
     213    $this->AddPropertyInteger('Investment');
    165214  }
    166215}
     
    237286    $this->License = 'GNU/GPL';
    238287    $this->Description = 'Accounting processing';
    239     $this->Dependencies = array('User');
     288    $this->Dependencies = array('User', 'Subject');
    240289    $this->Models = array('FinanceYear', 'DocumentLine', 'DocumentLineSequence',
    241290      'FinanceTariff', 'FinanceOperation', 'FinanceClaimsLiabilities',
    242       'FinanceBills', 'FinanceBillsItems');
     291      'FinanceBills', 'FinanceBillsItems', 'FinanceBillingPeriod', 'FinanceCharge',
     292      'FinanceMonthlyOverall');
    243293    $this->Views = array('FinanceOperation', 'FinanceClaimsLiabilities');
    244294  }
     
    331381      $this->BillingPeriods[$BillingPeriod['Id']] = $BillingPeriod;
    332382   
    333     $DbResult = $this->Database->query('SELECT * FROM finance_charge WHERE period='.$Period);
     383    $DbResult = $this->Database->query('SELECT * FROM FinanceCharge WHERE period='.$Period);
    334384    $Row = $DbResult->fetch_array();
    335385    $this->kWh = $Row['kWh'];
    336     $this->Internet = $Row['internet'];
    337     $this->Sprava = $Row['administration_per_user'];
    338     $this->RealMaxSpeed = $Row['internet_speed'];
    339     $this->SpeedReserve = $Row['internet_speed_reserve'];
    340     $this->BaseSpeedElement = $Row['base_speed_element'];
     386    $this->Internet = $Row['Internet'];
     387    $this->Sprava = $Row['AdministrationPerUser'];
     388    $this->RealMaxSpeed = $Row['InternetSpeed'];
     389    $this->SpeedReserve = $Row['InternetSpeedReserve'];
     390    $this->BaseSpeedElement = $Row['BaseSpeedElement'];
    341391    $this->MaxSpeed = $this->RealMaxSpeed - $this->SpeedReserve;
    342392    $this->TopTariffPrice = $Row['TopTariffPrice'];
     
    348398   
    349399    $this->SpravaUsers = $this->InternetUsers;
    350     $DbResult = $this->Database->query('SELECT SUM(`consumption`) FROM `network_segments`');
     400    $DbResult = $this->Database->query('SELECT SUM(`Consumption`) FROM `network_segments`');
    351401    $TotalConsumption = $DbResult->fetch_array();
    352402    $this->TotalConsumption = $TotalConsumption[0];
  • trunk/Modules/Finance/FinanceOverview.php

    r366 r377  
    2323    $Output .= '<br /><strong>Souhrn:</strong><br />';
    2424
    25     $DbResult = $this->Database->query('SELECT * FROM finance_monthly_overall ORDER BY date DESC LIMIT 0,1');
     25    $DbResult = $this->Database->query('SELECT * FROM FinanceMonthlyOverall ORDER BY Date DESC LIMIT 0,1');
    2626    $Row = $DbResult->fetch_array();
    2727    $Output .= 'Platba za internetovou linku ('.$Finance->RealMaxSpeed.'/'.$Finance->RealMaxSpeed.' kbit/s): <strong>'.$Finance->Internet.' Kč</strong><br />';
     
    6060    $TotalGain = 0;
    6161    $TotalExpense = 0;
    62     $DbResult = $this->Database->query('SELECT SUM(consumption) FROM network_devices WHERE used=1');
     62    $DbResult = $this->Database->query('SELECT SUM(Consumption) FROM network_devices WHERE used=1');
    6363    $Row = $DbResult->fetch_array();
    6464    $TotalConsumption = $this->System->Modules['Finance']->W2Kc($Row[0]);
  • trunk/Modules/Finance/Manage.php

    r375 r377  
    279279   
    280280    // Načti poslední měsíční přehled a nastavení
    281     $DbResult = $this->Database->select('finance_monthly_overall', '*', '1 ORDER BY date DESC LIMIT 1');
     281    $DbResult = $this->Database->select('FinanceMonthlyOverall', '*', '1 ORDER BY Date DESC LIMIT 1');
    282282    $Overall = $DbResult->fetch_array();
    283283
    284284    $Output -= 'Datum: '.date('j.n.Y').'<br />';
    285285   
    286     $Datum = explode('-', $Overall['date']);
     286    $Datum = explode('-', $Overall['Date']);
    287287    $Mesic = date('m') + 0;
    288288
     
    359359      // Update finance charge
    360360      $Output .= 'Měním aktuální parametry sítě...<br>';
    361       $this->Database->delete('finance_charge', 'period = 0');
    362       $DbResult = $this->Database->select('finance_charge', '*', 'period = 1');
     361      $this->Database->delete('FinanceCharge', 'Period = 0');
     362      $DbResult = $this->Database->select('FinanceCharge', '*', 'Period = 1');
    363363      $Charge = $DbResult->fetch_assoc();
    364364      //print_r($Charge);
    365       $DbResult = $this->Database->insert('finance_charge', array('period' => 0, 'internet' => $Charge['internet'], 'internet_speed' => $Charge['internet_speed'], 'internet_speed_reserve' => $Charge['internet_speed_reserve'], 'administration_per_user' => $Charge['administration_per_user'], 'kWh' => $Charge['kWh'], 'base_speed_element' => $Charge['base_speed_element'], 'BaseTariffPrice' => $Charge['BaseTariffPrice'], 'TopTariffPrice' => $Charge['TopTariffPrice']));
     365      $DbResult = $this->Database->insert('FinanceCharge', array('Period' => 0,
     366         'Internet' => $Charge['Internet'], 'InternetSpeed' => $Charge['InternetSpeed'],
     367          'InternetSpeedReserve' => $Charge['InternetSpeedReserve'],
     368          'AdministrationPerUser' => $Charge['AdministrationPerUser'],
     369          'kWh' => $Charge['kWh'], 'BaseSpeedElement' => $Charge['BaseSpeedElement'],
     370          'BaseTariffPrice' => $Charge['BaseTariffPrice'], 'TopTariffPrice' => $Charge['TopTariffPrice']));
    366371
    367372      $Output .= 'Přidávám měsíční přehled...<br />';
    368       $this->Database->insert('finance_monthly_overall', array('date' => 'NOW()', 'money' => $Finance->Internet, 'kWh' => $Finance->kWh, 'administration' => $Finance->Sprava, 'administration_total' => $SpravaCelkem, 'consumption_total' => $TotalConsumptionCost, 'total_paid' => $Finance->TotalPaid, 'BaseTariffPrice' => $Charge['BaseTariffPrice'], 'TopTariffPrice' => $Charge['TopTariffPrice'], 'member_count' => $Finance->InternetUsers));
     373      $this->Database->insert('FinanceMonthlyOverall', array('Date' => 'NOW()',
     374        'Money' => $Finance->Internet, 'kWh' => $Finance->kWh,
     375        'Administration' => $Finance->Sprava, 'AdministrationTotal' => $SpravaCelkem,
     376        'ConsumptionTotal' => $TotalConsumptionCost, 'TotalPaid' => $Finance->TotalPaid,
     377        'BaseTariffPrice' => $Charge['BaseTariffPrice'], 'TopTariffPrice' => $Charge['TopTariffPrice'], 'MemberCount' => $Finance->InternetUsers));
    369378
    370379      // Update tarrifs
  • trunk/Modules/Finance/MonthlyOverall.php

    r370 r377  
    1111
    1212    $Output = '<table class="WideTable"><tr><th>Rok</th><th>Měsíc</th><th>Internet [Kč]</th><th>Účastníků</th><th>Správa [Kč/účastníka]</th><th>Správa [Kč]</th><th>Spotřeba [Kč/kWh]</th><th>Spotřeba [Kč]</th><th>Obrat [Kč]</th><th>Průměrná cena [Kč/účastníka]</th><th align="center">Investice [Kč]</th></tr>';
    13     $Total = array('money' => 0, 'administration_total' => 0, 'consumption_total' => 0, 'total_paid' => 0, 'investment' => 0);
    14     $DbResult = $this->Database->select('finance_monthly_overall', '*', '1 ORDER BY date DESC');
     13    $Total = array('Money' => 0, 'AdministrationTotal' => 0, 'ConsumptionTotal' => 0, 'TotalPaid' => 0, 'Investment' => 0);
     14    $DbResult = $this->Database->select('FinanceMonthlyOverall', '*', '1 ORDER BY Date DESC');
    1515    while($Month = $DbResult->fetch_array())
    1616    {
    17       $DateParts = explode('-', $Month['date']);
    18       $Output .= '<tr><td>'.$DateParts[0].'</td><td align="center">'.$MonthNames[$DateParts[1] * 1].'</td><td align="center">'.$Month['money'].'</td><td align="center">'.$Month['member_count'].'</td><td align="center">'.$Month['administration'].'</td><td align="center">'.$Month['administration_total'].'</td><td align="center">'.$Month['kWh'].'</td><td align="center">'.$Month['consumption_total'].'</td><td align="center">'.$Month['total_paid'].'</td><td align="center">'.round($Month['total_paid'] / $Month['member_count']).'</td><td align="center">'.$Month['investment'].'</td></tr>';
     17      $DateParts = explode('-', $Month['Date']);
     18      $Output .= '<tr><td>'.$DateParts[0].'</td><td align="center">'.
     19        $MonthNames[$DateParts[1] * 1].'</td><td align="center">'.$Month['Money'].
     20        '</td><td align="center">'.$Month['MemberCount'].'</td><td align="center">'.
     21        $Month['Administration'].'</td><td align="center">'.$Month['AdministrationTotal'].
     22        '</td><td align="center">'.$Month['kWh'].'</td><td align="center">'.
     23        $Month['Consumption_Total'].'</td><td align="center">'.$Month['TotalPaid'].
     24        '</td><td align="center">'.round($Month['TotalPaid'] / $Month['MemberCount']).
     25        '</td><td align="center">'.$Month['Investment'].'</td></tr>';
    1926
    20       $Total['money'] += $Month['money'];
    21       $Total['administration_total'] += $Month['administration_total'];
    22       $Total['consumption_total'] += $Month['consumption_total'];
    23       $Total['total_paid'] += $Month['total_paid'];
    24           $Total['investment'] += $Month['investment'];
     27      $Total['Money'] += $Month['Money'];
     28      $Total['AdministrationTotal'] += $Month['AdministrationTotal'];
     29      $Total['ConsumptionTotal'] += $Month['ConsumptionTotal'];
     30      $Total['TotalPaid'] += $Month['TotalPaid'];
     31      $Total['Investment'] += $Month['Investment'];
    2532      //if($DateParts[1] == '01') echo('<tr><td style="font-size: 4;" colspan="10">&nbsp;</td></tr>');
    2633    }
    27     $Output .= '<tr><th colspan="2">Celkem</th><th>'.$Total['money'].'</th><th>&nbsp;</th><th>&nbsp;</th><th>'.$Total['administration_total'].'</th><th>&nbsp;</th><th>'.$Total['consumption_total'].'</th><th>'.$Total['total_paid'].'</th><th>&nbsp;</th><th>'.$Total['investment'].'</th>';
     34    $Output .= '<tr><th colspan="2">Celkem</th><th>'.$Total['Money'].'</th><th>&nbsp;</th><th>&nbsp;</th><th>'.$Total['AdministrationTotal'].'</th><th>&nbsp;</th><th>'.$Total['ConsumptionTotal'].'</th><th>'.$Total['TotalPaid'].'</th><th>&nbsp;</th><th>'.$Total['Investment'].'</th>';
    2835    $Output .= '</table>';
    2936    return($Output);
  • trunk/Modules/Network/Network.php

    r373 r377  
    162162    $this->Title = 'Nový email';
    163163    $this->SubmitText = 'Odeslat';
    164     AddItemString('Address', 'Adresa', '');
    165     AddItemString('Subject', 'Předmět', '');
    166     AddItemText('Content', 'Obsah', '');
     164    $this->AddItemString('Address', 'Adresa', '');
     165    $this->AddItemString('Subject', 'Předmět', '');
     166    $this->AddItemText('Content', 'Obsah', '');
    167167  }
    168168}
  • trunk/Modules/NetworkShare/NetworkShare.php

    r362 r377  
    1212    $this->Name = 'NetworkShareItem';
    1313    $this->AddPropertyString('Name');
    14     $this->AddPropertyOneToMany('Parent', 'NetworkShareItems');
     14    $this->AddPropertyOneToMany('Parent', 'NetworkShareItem');
    1515    $this->AddPropertyOneToMany('Host', 'NetworkDevice');
    1616    $this->AddPropertyInteger64('Size');
  • trunk/Modules/Project/Project.php

    r364 r377  
    99    $this->AddPropertyDateTime('TimeSchedule');
    1010    $this->AddPropertyOneToMany('UserAssignedTo', 'User');
    11     $this->AddPropertyManyToOne('Comments', 'ProjectComment', 'Project');
    1211    $this->AddPropertyText('Description');
    1312  }
  • trunk/Modules/User/User.php

    r376 r377  
    5050    $this->AddPropertyDateTime('LastLoginTime');
    5151    $this->AddPropertyDateTime('RegistrationTime');
    52     $this->AddPropertyOneToMany('User', 'User');
     52    $this->AddPropertyOneToMany('Member', 'Member');
    5353    $this->AddPropertyBoolean('Locked');
    5454    $this->AddPropertyInteger('ICQ');
  • trunk/index.php

    r364 r377  
    22
    33include_once('Common/Global.php');
    4 
    5 function ProcessURL()
    6 {
    7   if(array_key_exists('REDIRECT_QUERY_STRING', $_SERVER))
    8     $PathString = $_SERVER['REDIRECT_QUERY_STRING'];
    9     else $PathString = '';
    10   if(substr($PathString, -1, 1) == '/') $PathString = substr($PathString, 0, -1);
    11   //echo('"'.$QueryString.'"');
    12   $PathItems = explode('/', $PathString);
    13   if(strpos($_SERVER['REQUEST_URI'], '?') !== false)
    14     $_SERVER['QUERY_STRING'] = substr($_SERVER['REQUEST_URI'], strpos($_SERVER['REQUEST_URI'], '?') + 1);
    15     else $_SERVER['QUERY_STRING'] = '';   
    16   parse_str($_SERVER['QUERY_STRING'], $_GET);
    17   return($PathItems);
    18 }
     4GlobalInit();
    195
    206$System->PathItems = ProcessURL();
Note: See TracChangeset for help on using the changeset viewer.