Class: Extface::DevicesController

Inherits:
ApplicationController show all
Defined in:
app/controllers/extface/devices_controller.rb

Instance Method Summary collapse

Methods inherited from ApplicationController

#extfaceable

Instance Method Details

#createObject

POST /devices



28
29
30
31
32
33
34
35
# File 'app/controllers/extface/devices_controller.rb', line 28

def create
  @device = extfaceable.extface_devices.new(device_params)
  if @device.save
    redirect_to @device, notice: 'Device was successfully created.'
  else
    render action: :form
  end
end

#destroyObject

DELETE /devices/1



47
48
49
50
# File 'app/controllers/extface/devices_controller.rb', line 47

def destroy
  @device.destroy
  redirect_to devices_url, notice: 'Device was successfully destroyed.'
end

#editObject

GET /devices/1/edit



23
24
25
# File 'app/controllers/extface/devices_controller.rb', line 23

def edit
  render action: :form
end

#fiscalObject



72
73
74
75
76
77
78
79
80
81
82
83
84
85
# File 'app/controllers/extface/devices_controller.rb', line 72

def fiscal
  set_device
  if @device.fiscal?
    @job = case
      when params[:non_fiscal_test].present? then @device.driver.non_fiscal_test
      when params[:fiscal_test].present? then @device.driver.fiscal_test
      when params[:x_report].present? then @device.driver.x_report_session
      when params[:z_report].present? then @device.driver.z_report_session
      when params[:cancel_fiscal_doc].present? then @device.driver.cancel_doc_session
      when params[:paper_cut].present? then @device.driver.paper_cut
    end
  end
  render action: :show
end

#indexObject

GET /devices



8
9
10
# File 'app/controllers/extface/devices_controller.rb', line 8

def index
  @devices = extfaceable.extface_devices.load
end

#newObject

GET /devices/new



17
18
19
20
# File 'app/controllers/extface/devices_controller.rb', line 17

def new
  @device = extfaceable.extface_devices.new
  render action: :form
end

#rawObject



87
88
89
90
91
92
93
# File 'app/controllers/extface/devices_controller.rb', line 87

def raw
  set_device
  if @device.raw?
    @device.driver.test(params[:test])
  end
  render action: :show
end

#showObject

GET /devices/1



13
14
# File 'app/controllers/extface/devices_controller.rb', line 13

def show
end

#test_pageObject



52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
# File 'app/controllers/extface/devices_controller.rb', line 52

def test_page
  set_device
  if @device.fiscal?
    @job = @device.session("Print Test") do |s|
      s.notify "Printing Text"
      s.open_non_fiscal_doc
      s.print "********************************"
      s.print "Extface Print Test".center(32)
      s.print "********************************"
      s.print ""
      s.print "Driver: " + "#{@device.driver.class::NAME}".truncate(24)
      s.close_non_fiscal_doc
      s.notify "Printing finished"
    end
  else
    @job = @device.driver.print_test_page if params[:test_page]
  end
  render action: :show
end

#updateObject

PATCH/PUT /devices/1



38
39
40
41
42
43
44
# File 'app/controllers/extface/devices_controller.rb', line 38

def update
  if @device.update(device_params)
    redirect_to @device, notice: 'Device was successfully updated.'
  else
    render action: :form
  end
end