Ignore:
Timestamp:
Jan 21, 2014, 12:02:53 AM (11 years ago)
Author:
chronos
Message:
  • Upraveno: Tabulka měsíčních přehledů přepracována s použitím obecných tříd. Nyní podporuje řazení a stránkování. Celkové součty byly odebrány.
File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/Modules/Finance/MonthlyOverall.php

    r548 r636  
    1111    global $MonthNames;
    1212
    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       
    1437    $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);
    1639    while($Month = $DbResult->fetch_array())
    1740    {
    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']);
    2046
    2147      $Total['Money'] += $Month['Money'];
     
    2652      //if($DateParts[1] == '01') echo('<tr><td style="font-size: 4;" colspan="10">&nbsp;</td></tr>');
    2753    }
    28     $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>';
    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   
    3059    return($Output);
    3160  }
Note: See TracChangeset for help on using the changeset viewer.