Class: BookingsController

Inherits:
HasAccountsController
  • Object
show all
Defined in:
app/controllers/bookings_controller.rb

Instance Method Summary collapse

Instance Method Details

#copyObject



54
55
56
57
58
59
60
# File 'app/controllers/bookings_controller.rb', line 54

def copy
  original_booking = Booking.find(params[:id])

  @booking = original_booking.dup

  render 'edit'
end

#createObject



43
44
45
46
47
48
49
50
51
52
# File 'app/controllers/bookings_controller.rb', line 43

def create
  @booking = Booking.new(params[:booking])

  create! do |success, failure|
    success.html do
      redirect_to new_booking_path
    end
    failure.html {render 'edit'}
  end
end

#indexObject

Actions



7
8
9
10
# File 'app/controllers/bookings_controller.rb', line 7

def index
  # @bookings = apply_scopes(Booking).accessible_by(current_ability, :list).includes(:credit_account, :debit_account).paginate(:page => params[:page], :per_page => params[:per_page])
  index!
end

#newObject



12
13
14
15
16
17
# File 'app/controllers/bookings_controller.rb', line 12

def new
  @booking = Booking.new(:value_date => Date.today)
  # Only include base class records
  @booking_templates = BookingTemplate.where(:type => [nil, 'BookingTemplate']).where("NOT(code LIKE '%:%')").paginate(:page => params[:page])
  new!
end

#selectObject



36
37
38
39
40
41
# File 'app/controllers/bookings_controller.rb', line 36

def select
  @booking = Booking.new(params[:booking])
  increment_booking_code
  @booking_templates = BookingTemplate.where(:type => [nil, 'BookingTemplate']).where("NOT(code LIKE '%:%')").paginate(:page => params[:page])
  @bookings = Booking.where("title LIKE ?", '%' + @booking.title + '%').order('value_date DESC').paginate(:page => params[:page])
end

#select_bookingObject



19
20
21
22
23
24
25
26
27
28
29
30
# File 'app/controllers/bookings_controller.rb', line 19

def select_booking
  @booking = Booking.find(params[:id]).dup

  # Clear reference
  @booking.reference  = nil

  increment_booking_code
  # Take value date from form
  @booking.value_date = params[:booking][:value_date]

  render :action => 'simple_edit'
end

#simple_editObject



32
33
34
# File 'app/controllers/bookings_controller.rb', line 32

def simple_edit
  new!
end