Skip to content

Instantly share code, notes, and snippets.

Created August 9, 2011 14:54
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save anonymous/1134257 to your computer and use it in GitHub Desktop.
Save anonymous/1134257 to your computer and use it in GitHub Desktop.
...
<td class="Text13Grey numeric">
<span id="invoice_paid_status_<%= invoice.url_id %>"> <%= partial_payment_in_redbox(invoice) %></span>
</td>
...
<div id="redbox-for-partial-payment-<%=invoice.id%>" class="redbox_contents" style="display: none; width: 300px;">
<% remote_form_for PartialPayment.new, :url => invoice_partial_payments_path(invoice, :locale => "es") do |f| %>
<div id="total_payment_<%=invoice.id%>" class="box">
<p class="Text13Grey text"><%= t('.choose_payment') %></p>
<div class="buttonbar">
<%= button_to_function t('.full_payment'), :class=> "button", :id => "full-payment", :onclick => "fullPayment(#{invoice.id});"%>
<%= button_to_function t('.partial_payment'), :class=> "button", :id => "partial-payment", :onclick => "partialPayment(#{invoice.id});" %>
</div>
</div>
<div id="partial_payment_form_<%=invoice.id%>" class="box" style="display: none;">
<label class="Text13Grey text"><%= t('.amount_message') %><%= f.text_field :amount, :maxlength => 13, :size => 13, :class => "amount", :value => (invoice.total - invoice.total_paid)%></label>
<div class="buttonbar">
<%= button_to_function t ('.cancel'), "RedBox.close()", :class => 'button' %>
<%= f.submit t('.accept'), :class => 'button' %>
</div>
</div>
</div>
<% end %>
</div>
...
def partial_payment_in_redbox (invoice)
pending = invoice.total-invoice.total_paid
if pending > 0
html = render(:partial => 'invoices/redbox/partial_payment', :object => invoice)
html << link_to_redbox (format_money_as_decimal (pending), 'redbox-for-partial-payment', :class => "Text13Orange")
html
else
html = format_money_as_decimal (0)
end
end
...
ActionController::Routing::Routes.draw do |map|
map.filter 'locale'
# The priority is based upon order of creation: first created -> highest priority.
# Sample of regular route:
# map.connect 'products/:id', :controller => 'catalog', :action => 'view'
# Keep in mind you can assign values other than :controller and :action
# Sample of named route:
# map.purchase 'products/:id/purchase', :controller => 'catalog', :action => 'purchase'
# This route can be invoked with purchase_url(:id => product.id)
# You can have the root of your site routed by hooking up ''
# -- just remember to delete public/index.html.
map.home_public '', :controller => "public", :action => 'index', :conditions => {:subdomain => 'www'}
map.who 'who', :controller => "public", :action => 'who', :conditions => {:subdomain => 'www'}
map.connect '', :controller => "invoices", :action => 'index'
# A/B testing routes
map.home1 'home1', :controller => 'public', :action => 'home1', :conditions => {:subdomain => 'www'}
map.home2 'home2', :controller => 'public', :action => 'home2', :conditions => {:subdomain => 'www'}
map.home3 'home3', :controller => 'public', :action => 'home3', :conditions => {:subdomain => 'www'}
map.home4 'home4', :controller => 'public', :action => 'home4', :conditions => {:subdomain => 'www'}
map.pymesyautonomos 'pymesyautonomos', :controller => "public", :action => 'pymesyautonomos'
map.with_options :controller => 'apidocs' do |doc|
doc.api 'api', :action => 'index'
doc.api_concepts 'api/concepts', :action => 'concepts'
doc.api_routes 'api/routes', :action => 'routes'
doc.api_model 'api/:model', :action => 'model'
end
map.namespace(:api_v1, :path_prefix => 'api/1') do |api|
api.resource :account, :except => [:new, :create, :edit, :update, :destroy], :member => {:token => :get}
api.resources :countries, :except => [:new, :create, :edit, :update, :destroy]
api.resources :customers, :except => [:new, :edit], :collection => {:search => :get} do |customer|
customer.resources :invoices, :except => [:new, :edit, :update],
:collection => {:search => :get, :pending => :get, :paid => :get}
end
api.resources :invoices, :except => [:new, :edit, :update],
:collection => {:search => :get, :pending => :get, :paid => :get},
:member => {:mail_to => :post, :toggle_paid => :post} do |invoice|
invoice.resources :invoice_lines, :except => [:new, :edit]
end
end
# These promotion URLs have this schema for historical reasosn
map.connect 'public/signup/:promotion_code', :controller => 'public', :action => 'promotion', :promotion_code => /\w+/
map.account_login_token 'account/login/:login_token', :controller => 'login_token', :action => 'login', :requirements => {:login_token => /.+/}
map.account_login 'account/login', :controller => 'account', :action => 'login'
map.account_logout 'account/logout', :controller => 'account', :action => 'logout'
map.resource 'password', :only => [:new, :create, :edit, :update]
map.connect 'promotion/:promotion_code', :controller => 'public', :action => 'promotion'
map.connect 'facturagem/mo', :controller => 'mo', :action => 'index'
map.connect 'invoices/new/:from/:id', :controller => 'invoices', :action => 'new'
map.resources 'invoices', :only => [:index, :new], :collection => {:list => :get, :search => :get}, :member => {:deliver => :post} do |invoice|
invoice.resources :partial_payments, :only => [:create]
end
map.resources 'customers', :only => [:index, :new, :create, :show, :edit, :update], :collection => {:list => :get, :search => :get, :export => :get}
map.resource 'fiscal_data', :controller => 'fdata',
:as => "fdata",
:only => [:show, :new, :create, :edit, :update],
:collection => { :edit_plan => :get, :update_plan => :put }
map.resources 'drafts', :path_prefix => 'invoices'
map.unassign_report_assignment 'report_assignments/:id/unassign',
:controller => 'report_assignments', :action => 'unassign', :conditions => {:method => :get}
map.change_format '/format/:f', :controller => 'public', :action => 'change_format'
# Public paths
map.new_contact_form '/public/contact', :controller => 'contact_form', :action => 'new', :conditions => {:method => :get}
map.contact_form '/public/contact', :controller => 'contact_form', :action => 'create', :conditions => {:method => :post}
map.help '/help', :controller => 'help', :action => 'index', :conditions => {:method => :get}
map.videos '/help/videos', :controller => 'help', :action => 'videos', :conditions => {:method => :get}
map.tour '/tour', :controller => 'tour', :action => 'index', :conditions => {:method => :get}
map.signup '/public/signup', :controller => 'public', :action => 'signup', :conditions => {:method => :get}
# Backoffice paths
map.flat_rate_backoffice '/backoffice/flat_rate', :controller => :backoffice, :action => "flat_rate"
map.yearly_plan_backoffice '/backoffice/yearly_plan', :controller => :backoffice, :action => "yearly_plan"
map.resume_backoffice '/backoffice', :controller => :backoffice, :action => "index"
map.namespace(:backoffice) do |backoffice|
backoffice.resources :accounts, :only => [:index, :update], :collection => {:list => :get, :search => :get}
backoffice.resources :promotions, :collection => {:list => :get, :search => :get}
end
# Orders & Payments
map.resources :orders, :collection => { :success => :get, :failure => :get},
:member => { :cancel => :get }
map.resources :payments
# Call center external requests paths
map.connect 'externals/call_center_create_account', :controller => :externals, :action => :call_center_create_account, :conditions => {:method => :post}
map.welcome 'welcome', :controller => "fdata", :action => 'welcome'
map.connect ':controller/:action/:id'
# Install the default route as the lowest priority.
# map.connect ':controller/:action/:id.:format'
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment