[Jifty-commit] r5921 - in JiftyX-ExpenseApp/trunk: . lib/Jifty/Plugin/ExpenseApp
Jifty commits
jifty-commit at lists.jifty.org
Fri Oct 10 12:50:26 EDT 2008
Author: gugod
Date: Fri Oct 10 12:50:26 2008
New Revision: 5921
Modified:
JiftyX-ExpenseApp/trunk/ (props changed)
JiftyX-ExpenseApp/trunk/lib/Jifty/Plugin/ExpenseApp/Dispatcher.pm
JiftyX-ExpenseApp/trunk/lib/Jifty/Plugin/ExpenseApp/View.pm
JiftyX-ExpenseApp/trunk/share/web/static/css/jiftyx_expenseapp.css
Log:
r24492 at yra: gugod | 2008-10-10 15:28:00 +0800
Provide an all-time summary report for now.
Modified: JiftyX-ExpenseApp/trunk/lib/Jifty/Plugin/ExpenseApp/Dispatcher.pm
==============================================================================
--- JiftyX-ExpenseApp/trunk/lib/Jifty/Plugin/ExpenseApp/Dispatcher.pm (original)
+++ JiftyX-ExpenseApp/trunk/lib/Jifty/Plugin/ExpenseApp/Dispatcher.pm Fri Oct 10 12:50:26 2008
@@ -52,7 +52,32 @@
};
on '/=/x/expenses/reports' => run {
- # ...
+
+ my $sum = ExpenseCollection;
+
+ $sum->column( column => "category" );
+ $sum->column( column => "currency" );
+ $sum->column( column => "amount", function => "SUM" );
+ $sum->order_by(
+ { column => "currency"},
+ { function => "SUM(amount)", order => "DES" }
+ );
+
+ $sum->group_by({ column => "category" }, { column => "currency" });
+
+ Jifty->log->info($sum->build_select_query);
+ my $sql_query = $sum->build_select_query;
+ my $records = $sum->_handle->simple_query($sql_query);
+ my $summary = [];
+ while ( my $row = $records->fetchrow_hashref() ) {
+ push @$summary, {
+ category => $row->{main_category},
+ amount => $row->{main_amount},
+ currency => $row->{main_currency}
+ };
+ }
+
+ set summary => $summary;
};
1;
Modified: JiftyX-ExpenseApp/trunk/lib/Jifty/Plugin/ExpenseApp/View.pm
==============================================================================
--- JiftyX-ExpenseApp/trunk/lib/Jifty/Plugin/ExpenseApp/View.pm (original)
+++ JiftyX-ExpenseApp/trunk/lib/Jifty/Plugin/ExpenseApp/View.pm Fri Oct 10 12:50:26 2008
@@ -101,9 +101,30 @@
template '/=/x/expenses/reports' => page {
title => _("Expenses Reports")
} content {
+ div {
+ class is "expenseapp";
- div { "(Not Implemented Yet)" };
+ h2 { _("All-time Summary") };
+ div {
+ class is "summary";
+ my $sum = get("summary");
+ table {
+ row {
+ th { _("Category") };
+ th { _("Amount") };
+ th { _("Currency") };
+ };
+ for my $row (@$sum) {
+ row {
+ cell { $row->{category} };
+ cell { $row->{amount} };
+ cell { $row->{currency} };
+ }
+ }
+ };
+ };
+ };
};
1;
Modified: JiftyX-ExpenseApp/trunk/share/web/static/css/jiftyx_expenseapp.css
==============================================================================
--- JiftyX-ExpenseApp/trunk/share/web/static/css/jiftyx_expenseapp.css (original)
+++ JiftyX-ExpenseApp/trunk/share/web/static/css/jiftyx_expenseapp.css Fri Oct 10 12:50:26 2008
@@ -1,3 +1,7 @@
+/*
+ * All rules in this files should be have '.expenseapp' in the beginning.
+ */
+
.expenseapp .create {
background: #ffc;
margin: 5px 0;
@@ -7,24 +11,24 @@
-moz-border-radius: 5px;
}
-.expenseapp .list table {
+.expenseapp table {
width: 100%;
border-collapse: collapse;
}
-.expenseapp .list table th {
+.expenseapp table th {
padding: 5px;
background: #fcc;
border: 1px solid #999;
}
-.expenseapp .list table td {
+.expenseapp table td {
padding: 5px;
text-align: center;
border: 1px solid #999;
}
-.expenseapp .list table tr:nth-child(2n) {
+.expenseapp table tr:nth-child(2n) {
background: #ccf;
}
@@ -36,3 +40,7 @@
.expenseapp .expense.record.delete.action:hover {
color: #f00;
}
+
+.expenseapp .summary table {
+ width: 100%;
+}
\ No newline at end of file
More information about the Jifty-commit
mailing list