Changeset 634 for trunk/pages/dotation.php
- Timestamp:
- Sep 14, 2009, 7:53:21 AM (15 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/pages/dotation.php
r627 r634 23 23 </p>'; 24 24 25 $operace = array(26 'buy' => 'Nákup',27 'sell' => 'Prodej',28 'consumption' => 'Spotřeba',29 'internet' => 'Internet',30 'contribution' => 'Příspěvek od',31 );32 33 25 $load_money = $db->query('SELECT SUM(`Money`) FROM `Finance`;')->fetch_row(); 34 26 35 27 $Output .= '<p><strong>Aktuální stav financí: '.$load_money[0].' Kč</strong></p>'; 28 29 $Output .= '<h4 class="Center">Roční přehledy financování</h4>'; 36 30 $Output .= '<table class="BaseTable">'. 37 '<tr>'. 38 '<th>Datum</th>'. 39 '<th>Suma</th>'. 40 '<th>Popis</th>'. 41 '<th>Odměna</th>'. 42 '</tr>'; 31 '<tr><th>Rok</th><th>Příjmy</th><th>Výdaje</th><th>Rozdíl</th></tr>'; 32 $DbResult = $db->query('SELECT MAX(Time), MIN(Time) FROM Finance'); 33 $TimeRange = $DbResult->fetch_array(); 43 34 44 $load_dotation = $db->query('SELECT * FROM `Finance` ORDER BY `Id` DESC'); 45 while($row = $load_dotation->fetch_assoc()) 35 $StartDateTimeParts = explode(' ',$TimeRange['MIN(Time)']); 36 $StartDateParts = explode('-',$StartDateTimeParts[0]); 37 $EndDateTimeParts = explode(' ',$TimeRange['MAX(Time)']); 38 $EndDateParts = explode('-',$EndDateTimeParts[0]); 39 40 $TotalIncome = 0; 41 $TotalExpense = 0; 42 for($Year = $EndDateParts[0]; $Year >= $StartDateParts[0]; $Year--) 46 43 { 47 $odmena = $row['Reward']; 48 49 if($row['Time'] != '') 50 { 51 $date = $server->HumanDate($row['Time'], 0); 52 //$date = $row['time']; 53 } else $date = ''; 54 if($row['Money'] > 0) $plus = '+'; 55 else $plus = ''; 56 $Output .= '<tr>'. 57 '<td>'.$date.'</td>'. 58 '<td>'.$plus.$row['Money'].'</td>'. 59 '<td>'.$operace[$row['Operation']].' '.$row['Description'].'</td>'. 60 '<td>'.$odmena.'</td>'. 61 '</tr>'; 44 $DbResult = $db->query('SELECT SUM(Money) AS Income FROM Finance WHERE (Money > 0) AND (Time >= "'.$Year.'-01-01") AND (Time < DATE_ADD("'.$Year.'-01-01", INTERVAL 1 YEAR))'); 45 $Income = $DbResult->fetch_assoc(); 46 $Income = $Income['Income']; 47 $TotalIncome += $Income; 48 $DbResult = $db->query('SELECT -SUM(Money) AS Expense FROM Finance WHERE (Money < 0) AND (Time >= "'.$Year.'-01-01") AND (Time < DATE_ADD("'.$Year.'-01-01", INTERVAL 1 YEAR))'); 49 $Expense = $DbResult->fetch_assoc(); 50 $Expense = $Expense['Expense']; 51 $TotalExpense += $Expense; 52 $Output .= '<tr><td>'.$Year.'</td><td>'.$Income.'</td><td>'.$Expense.'</td><td>'.($Income - $Expense).'</td></tr>'; 62 53 } 54 $Output .= '<tr><th>Celkem</th><th>'.$TotalIncome.'</th><th>'.$TotalExpense.'</th><th>'.($TotalIncome - $TotalExpense).'</th></tr>'; 63 55 $Output .= '</table>'; 56 57 $Output .= '<br/><div class="Center"><a href="?page=dotation_dump">Výpis jednotlivých příspěvků</a></div>'; 64 58 65 59 echo($Output);
Note:
See TracChangeset
for help on using the changeset viewer.