Class: Admin::ActivitiesWithPricesController

Inherits:
ActivitiesController
  • Object
show all
Defined in:
app/controllers/admin/activities_with_prices_controller.rb

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.active_scaffold_pathsObject

We need to be sure the view is looking in the right place, this little hack should do it:



23
24
25
26
27
# File 'app/controllers/admin/activities_with_prices_controller.rb', line 23

def self.active_scaffold_paths
  super_view_path = BRISKBILLS_ROOT+'/app/views/admin/activities'
  @active_scaffold_overrides << super_view_path unless @active_scaffold_overrides.include? super_view_path
  super
end

Instance Method Details

#move_to_invoiceObject



32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
# File 'app/controllers/admin/activities_with_prices_controller.rb', line 32

def move_to_invoice
  @errors_during_move = []
  
  activity = Activity.find params[:id].to_i
  
  dest_conditions = ['invoices.is_published = ?',false]
  dest_conditions[0] += ' AND invoices.id != ?' and dest_conditions << activity.invoice_id if activity
  
  @dest_invoices = Invoice.find_with_totals(
    :all, 
    :conditions => dest_conditions, 
    :order => 'invoices.issued_on DESC, invoices.id DESC', 
    :include => [:client]
  )

  if params.has_key? :move_to_invoice_id
    begin
      invoice_dest = Invoice.find(params[:move_to_invoice_id].to_i)
      activity.move_to_invoice invoice_dest

      do_list
      
      flash[:warning]  = '%s successfully moved to "%s"' % [activity.label,invoice_dest.long_name]
    rescue
      @errors_during_move << $!
    end
    
    render :action => 'move_to_invoice.rjs'
  else
    render :action => 'move_to_invoice.rhtml', :layout => false
  end
end