Changeset 636
- Timestamp:
- Jan 21, 2014, 12:02:53 AM (11 years ago)
- Location:
- trunk
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Common/Global.php
r635 r636 137 137 } 138 138 139 class Pag eing139 class Paging 140 140 { 141 141 var $TotalCount; 142 142 var $ItemPerPage; 143 143 var $Around; 144 var $SQLLimit; 145 var $Page; 144 146 145 147 function __construct() … … 147 149 global $System; 148 150 149 $this->ItemPerPage = 5; //$System->Config['Web']['ItemsPerPage'];151 $this->ItemPerPage = $System->Config['Web']['ItemsPerPage']; 150 152 $this->Around = $System->Config['Web']['VisiblePagingItems']; 151 153 } -
trunk/Common/Setup/Setup.php
r635 r636 210 210 $Pageing = new Pageing(); 211 211 $Pageing->TotalCount = count($this->System->ModuleManager->Modules); 212 $Table = new Table();212 $Table = new VisualTable(); 213 213 $Table->SetColumns(array( 214 214 array('Name' => 'Name', 'Title' => 'Jméno'), … … 235 235 } else $Actions .= ' <a href="?action=modules&op=install&name='.$Module->Name.'">Instalovat</a>'; 236 236 237 $Table-> Cells[] = array($Module->Name,237 $Table->Table->Cells[] = array($Module->Name, 238 238 $Module->Creator, $Module->Version, 239 239 $Module->License, $YesNo[$Module->Installed], -
trunk/Common/Table.php
r635 r636 11 11 } 12 12 13 class Table 14 { 15 function GetCell($Y, $X) 16 { 17 return(''); 18 } 19 20 function BeginRead() 21 { 22 } 23 24 function EndRead() 25 { 26 } 27 28 function RowsCount() 29 { 30 return(0); 31 } 32 } 33 34 class TableMemory extends Table 35 { 36 var $Cells; 37 38 function GetCell($Y, $X) 39 { 40 return($this->Cells[$Y][$X]); 41 } 42 43 function RowsCount() 44 { 45 return(count($this->Cells)); 46 } 47 } 48 49 class TableSQL extends Table 50 { 51 var $Query; 52 var $Database; 53 var $Cells; 54 55 function GetCell($Y, $X) 56 { 57 return($this->Cells[$Y][$X]); 58 } 59 60 function BeginRead() 61 { 62 $this->Cells = array(); 63 $DbResult = $this->Database->query($this->Query); 64 while($DbRow = $DbResult->fetch_row()) 65 { 66 $this->Cells[] = $DbRow; 67 } 68 } 69 70 function EndRead() 71 { 72 $this->Cells = array(); 73 } 74 75 function RowsCount() 76 { 77 return(count($this->Cells)); 78 } 79 } 80 13 81 class TableColumn 14 82 { … … 17 85 } 18 86 19 class Table extends Control87 class VisualTable extends Control 20 88 { 21 89 var $Cells; 22 90 var $Columns; 23 var $OrderDirSQL; 91 var $OrderSQL; 92 var $OrderColumn; 93 var $OrderDirection; 24 94 var $OrderArrowImage; 25 95 var $DefaultColumn; 26 96 var $DefaultOrder; 97 var $Table; 27 98 28 99 function __construct() … … 31 102 32 103 $this->Columns = array(); 33 $this-> Cells = array();104 $this->Table = new TableMemory(); 34 105 $this->OrderDirSQL = array('ASC', 'DESC'); 35 106 $this->OrderArrowImage = array($System->Link('/images/sort_asc.png'), … … 57 128 $Output = '<table class="WideTable">'; 58 129 $Output .= $this->GetOrderHeader(); 59 foreach($this->Cells as $Row) 130 $this->Table->BeginRead(); 131 for($Y = 0; $Y < $this->Table->RowsCount(); $Y++) 60 132 { 61 133 $Output .= '<tr>'; 62 foreach($Row as $Cell) 134 135 for($X = 0; $X < count($this->Columns); $X++) 63 136 { 137 $Cell = $this->Table->GetCell($Y, $X); 64 138 if($Cell == '') $Output .= '<td> </td>'; 65 139 else $Output .= '<td>'.$Cell.'</td>'; 66 } 140 } 67 141 $Output .= '</tr>'; 68 142 } 143 $this->Table->EndRead(); 69 144 $Output .= '</table>'; 70 145 return($Output); … … 109 184 else $Result .= '<th><a href="?'.SetQueryStringArray($QueryItems).'">'.$Column->Title.$ArrowImage.'</a></th>'; 110 185 } 111 $this-> SQL = ' ORDER BY `'.$_SESSION['OrderCol'].'` '.$this->OrderDirSQL[$_SESSION['OrderDir']];112 $this-> Column = $_SESSION['OrderCol'];113 $this-> Direction = $_SESSION['OrderDir'];186 $this->OrderSQL = ' ORDER BY `'.$_SESSION['OrderCol'].'` '.$this->OrderDirSQL[$_SESSION['OrderDir']]; 187 $this->OrderColumn = $_SESSION['OrderCol']; 188 $this->OrderDirection = $_SESSION['OrderDir']; 114 189 115 190 return($Result); -
trunk/Modules/Finance/MonthlyOverall.php
r548 r636 11 11 global $MonthNames; 12 12 13 $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 $Output = ''; 14 $Query = 'SELECT *, YEAR(`Date`) AS `Year`, MONTH(`Date`) AS `Month`, ROUND(`TotalPaid` / `MemberCount`) AS `PaidPerCustomer` FROM `FinanceMonthlyOverall`'; 15 $DbResult = $this->Database->query('SELECT COUNT(*) FROM ('.$Query.') AS `T`'); 16 $DbRow = $DbResult->fetch_row(); 17 $Paging = new Paging(); 18 $Paging->TotalCount = $DbRow[0]; 19 $Table = new VisualTable(); 20 $Table->SetColumns(array( 21 array('Name' => 'Year', 'Title' => 'Rok'), 22 array('Name' => 'Month', 'Title' => 'Měsíc'), 23 array('Name' => 'Money', 'Title' => 'Internet [Kč]'), 24 array('Name' => 'MemberCount', 'Title' => 'Zákazníků'), 25 array('Name' => 'Administration', 'Title' => 'Správa [Kč/zákazníka]'), 26 array('Name' => 'AdministrationTotal', 'Title' => 'Správa [Kč]'), 27 array('Name' => 'kWh', 'Title' => 'Spotřeba [Kč/kWh]'), 28 array('Name' => 'ConsumptionTotal', 'Title' => 'Spotřeba [Kč]'), 29 array('Name' => 'TotalPaid', 'Title' => 'Obrat [Kč]'), 30 array('Name' => 'PaidPerCustomer', 'Title' => 'Průměrná cena [Kč/účastníka]'), 31 array('Name' => 'Investment', 'Title' => 'Investice [Kč]'), 32 )); 33 $Output .= $Paging->Show(); 34 35 $Table->GetOrderHeader(); 36 14 37 $Total = array('Money' => 0, 'AdministrationTotal' => 0, 'ConsumptionTotal' => 0, 'TotalPaid' => 0, 'Investment' => 0); 15 $DbResult = $this->Database-> select('FinanceMonthlyOverall', '*', '1 ORDER BY Date DESC');38 $DbResult = $this->Database->query($Query.' WHERE 1 '.$Table->OrderSQL.' '.$Paging->SQLLimit); 16 39 while($Month = $DbResult->fetch_array()) 17 40 { 18 $DateParts = explode('-', $Month['Date']); 19 $Output .= '<tr><td>'.$DateParts[0].'</td><td align="center">'.$MonthNames[$DateParts[1] * 1].'</td><td align="center">'.$Month['Money'].'</td><td align="center">'.$Month['MemberCount'].'</td><td align="center">'.$Month['Administration'].'</td><td align="center">'.$Month['AdministrationTotal'].'</td><td align="center">'.$Month['kWh'].'</td><td align="center">'.$Month['ConsumptionTotal'].'</td><td align="center">'.$Month['TotalPaid'].'</td><td align="center">'.round($Month['TotalPaid'] / $Month['MemberCount']).'</td><td align="center">'.$Month['Investment'].'</td></tr>'; 41 $Table->Table->Cells[] = array($Month['Year'], $MonthNames[$Month['Month']], 42 $Month['Money'], $Month['MemberCount'], $Month['Administration'], 43 $Month['AdministrationTotal'], $Month['kWh'], $Month['ConsumptionTotal'], 44 $Month['TotalPaid'], $Month['PaidPerCustomer'], 45 $Month['Investment']); 20 46 21 47 $Total['Money'] += $Month['Money']; … … 26 52 //if($DateParts[1] == '01') echo('<tr><td style="font-size: 4;" colspan="10"> </td></tr>'); 27 53 } 28 $Output .= '<tr><th colspan="2">Celkem</th><th>'.$Total['Money'].'</th><th> </th><th> </th><th>'.$Total['AdministrationTotal'].'</th><th> </th><th>'.$Total['ConsumptionTotal'].'</th><th>'.$Total['TotalPaid'].'</th><th> </th><th>'.$Total['Investment'].'</th>'; 29 $Output .= '</table>'; 54 //$Table->Table->Cells[] = array('Celkem', '', $Total['Money'], '', '', $Total['AdministrationTotal'], 55 // '', $Total['ConsumptionTotal'], $Total['TotalPaid'], '', $Total['Investment']); 56 $Output .= $Table->Show(); 57 $Output .= $Paging->Show(); 58 30 59 return($Output); 31 60 }
Note:
See TracChangeset
for help on using the changeset viewer.