Kaynağa Gözat

Added filter by payment size to payments to suppliers view

pull/3/head
Adrian Short 14 yıl önce
ebeveyn
işleme
f1d82e715e
7 değiştirilmiş dosya ile 120 ekleme ve 43 silme
  1. +12
    -1
      app.rb
  2. BIN
      public/od_80x15_blue.png
  3. BIN
      public/spinner.gif
  4. +30
    -2
      public/style.css
  5. +1
    -0
      views/layout.haml
  6. +53
    -40
      views/servicepayments.haml
  7. +24
    -0
      views/servicepaymentsdetail.haml

+ 12
- 1
app.rb Dosyayı Görüntüle

@@ -100,10 +100,21 @@ end

get '/services/:slug/payments' do
@service = Service.first(:slug => params[:slug])
@total = @service.payments.sum(:amount)
@payments = Payment.all(:service => @service, :amount.gte => 0, :order => 'd')
@total = @payments.sum(:amount)
haml :servicepayments
end

get '/services/:slug/paymentsdetail' do
@service = Service.first(:slug => params[:slug])
min = 500
if params[:min].to_i > 0
min = params[:min].to_i
end
@payments = Payment.all(:service => @service, :amount.gte => min, :order => 'd')
@total = @payments.sum(:amount)
haml :servicepaymentsdetail, :layout => false
end


get '/services/?' do


BIN
public/od_80x15_blue.png Dosyayı Görüntüle

Önce Sonra
Genişlik: 80  |  Yükseklik: 15  |  Boyut: 446 B

BIN
public/spinner.gif Dosyayı Görüntüle

Önce Sonra
Genişlik: 16  |  Yükseklik: 16  |  Boyut: 1.8 KiB

+ 30
- 2
public/style.css Dosyayı Görüntüle

@@ -10,7 +10,6 @@ body
p
{
font-size: 110%;
margin: 30px 0;
}

input
@@ -94,7 +93,7 @@ strong
table
{
border-collapse: collapse;
margin-bottom: 30px 0;
margin-bottom: 50px;
}

td, th
@@ -144,4 +143,33 @@ tr
padding: 0px;
font-size: 150%;
line-height: 1.5em;
}

.spinner
{
display: none;
}

.filter li
{
display: inline;
}

.filter a, .filter a:visited
{
margin: 0 0px 0 0;
padding: 5px 10px;
background-color: #333;
color: #fff;
}

.filter a:hover
{

}

a.filter_selected
{
background-color: red;
color: #fff;
}

+ 1
- 0
views/layout.haml Dosyayı Görüntüle

@@ -7,6 +7,7 @@
%link{ :rel => 'stylesheet', :type => 'text/css', :href => '/breadcrumb/breadcrumb.css' }
%link{ :rel => 'stylesheet', :type => 'text/css', :href => '/print.css', :media => 'print' }
%link{ :rel => 'stylesheet', :type => 'text/css', :href => '/grid.css' }
%script{:type => 'text/javascript', :src => 'http://ajax.googleapis.com/ajax/libs/jquery/1.3.2/jquery.min.js'}
<script type="text/javascript">
var _gaq = _gaq || [];
_gaq.push(['_setAccount', 'UA-3042981-18']);


+ 53
- 40
views/servicepayments.haml Dosyayı Görüntüle

@@ -1,3 +1,22 @@
:javascript
function getPayments(min, objj) {
$('.spinner').show()
$.get("/services/#{@service.slug}/paymentsdetail", { min: min }, function(data) {
$('#payments').html(data);
$('.spinner').hide()
$('.filter a').removeClass('filter_selected');
$(objj).addClass('filter_selected');
});
}

$(function(){
$('#min500').click(function() { getPayments(500, $(this)); return false; });
$('#min1000').click(function() { getPayments(1000, $(this)); return false; });
$('#min2500').click(function() { getPayments(2500, $(this)); return false; });
$('#min5000').click(function() { getPayments(5000, $(this)); return false; });
$('#min10000').click(function() { getPayments(10000, $(this)); return false; });
});

.grid_12
%ul#breadcrumb
%li.home
@@ -8,7 +27,7 @@
%a{ :href => "/services/#{@service.slug}" }
= @service.name
%li Payments to Suppliers
%h2= @page_title = "#{@service.name}: Payments to Suppliers"
%p
@@ -25,45 +44,39 @@
%p.noprint.download
%a{ :href => "/services/#{@service.slug}/payments.csv" }
Download data as CSV

.noprint
%p
Show payments over:&nbsp;&nbsp;
%img.spinner{ :src => "/spinner.gif" } <!-- Thanks, http://ajaxload.info/ -->
%table
%tr
%th Date
%th Ref.
%th Supplier
%th.right &pound;
- for payment in @service.payments
%tr
%td= payment.d.strftime("%d&nbsp;%b&nbsp;%Y")
%td.right
%a{ :href => "/payments/#{payment.id}" }
= payment.id
%td
%a{ :href => '/suppliers/' + payment.supplier.slug }
= payment.supplier.name
%td.right= commify(sprintf("%0d", payment.amount))
%tr
%td
%td
%td
%strong TOTAL
%td.right= commify(sprintf("%0d", @total))
%p.filter
%a#min500.filter_selected{:href => '#'}
&pound;500
%a#min1000{:href => '#'}
&pound;1,000
%a#min2500{:href => '#'}
&pound;2,500
%a#min5000{:href => '#'}
&pound;5,000
%a#min10000{:href => '#'}
&pound;10,000

#payments= haml :servicepaymentsdetail, :layout => false
.clear
<div class="grid_9 noprint">
= haml_partial "comment_header"
<div id="disqus_thread" class="noprint"></div>
<script type="text/javascript">
var disqus_developer = 1;
(function() {
var dsq = document.createElement('script'); dsq.type = 'text/javascript'; dsq.async = true;
dsq.src = 'http://armchairauditor.disqus.com/embed.js';
(document.getElementsByTagName('head')[0] || document.getElementsByTagName('body')[0]).appendChild(dsq);
})();
</script>
<noscript>Please enable JavaScript to view the <a href="http://disqus.com/?ref_noscript=armchairauditor">comments powered by Disqus.</a></noscript>
<a href="http://disqus.com" class="dsq-brlink noprint">Comments powered by <span class="logo-disqus">Disqus</span></a>
</div>
-#
<div class="grid_9 noprint">
= haml_partial "comment_header"
<div id="disqus_thread" class="noprint"></div>
<script type="text/javascript">
var disqus_developer = 1;
(function() {
var dsq = document.createElement('script'); dsq.type = 'text/javascript'; dsq.async = true;
dsq.src = 'http://armchairauditor.disqus.com/embed.js';
(document.getElementsByTagName('head')[0] || document.getElementsByTagName('body')[0]).appendChild(dsq);
})();
</script>
<noscript>Please enable JavaScript to view the <a href="http://disqus.com/?ref_noscript=armchairauditor">comments powered by Disqus.</a></noscript>
<a href="http://disqus.com" class="dsq-brlink noprint">Comments powered by <span class="logo-disqus">Disqus</span></a>
</div>

+ 24
- 0
views/servicepaymentsdetail.haml Dosyayı Görüntüle

@@ -0,0 +1,24 @@
%table
%tr
%th Date
%th Ref.
%th Supplier
%th.right &pound;
- for payment in @payments
%tr
%td= payment.d.strftime("%d&nbsp;%b&nbsp;%Y")
%td.right
%a{ :href => "/payments/#{payment.id}" }
= payment.id
%td
%a{ :href => '/suppliers/' + payment.supplier.slug }
= payment.supplier.name
%td.right= commify(sprintf("%0d", payment.amount))
%tr
%td
%td
%td
%strong TOTAL
%td.right= commify(sprintf("%0d", @total))

Yükleniyor…
İptal
Kaydet