Class: YDIM::Html::View::InvoiceComposite

Inherits:
HtmlGrid::DivComposite
  • Object
show all
Includes:
HtmlGrid::FormMethods
Defined in:
lib/ydim/html/view/invoice.rb

Direct Known Subclasses

AutoInvoiceComposite

Constant Summary collapse

FORM_ID =
'invoice'
COMPONENTS =
{
	[0,0]	=>	InvoiceInnerComposite,
	[0,1]	=>	:items,
	[0,2]	=>	InvoiceTotalComposite,
	[0,3]	=>	:submit,
	[1,3]	=>	:pdf,
	[2,3]	=>	:send_invoice,
}
CSS_MAP =
{
	3	=>	'padded'
}
EVENT =
:update

Instance Method Summary collapse

Instance Method Details

#button(key, model) ⇒ Object



200
201
202
203
204
205
206
# File 'lib/ydim/html/view/invoice.rb', line 200

def button(key, model)
	button = HtmlGrid::Button.new(key, model, @session, self)
	url = @lookandfeel._event_url(key, {:unique_id => model.unique_id})
	button.set_attribute('onClick', 
     "this.form.event.value='#{key}'; this.form.submit()")
	button
end

#hidden_fields(context) ⇒ Object



185
186
187
# File 'lib/ydim/html/view/invoice.rb', line 185

def hidden_fields(context)
	super << context.hidden('unique_id', @model.unique_id)
end

#initObject



168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
# File 'lib/ydim/html/view/invoice.rb', line 168

def init
	if(@model.unique_id.nil?)
		@components = {
			[0,0]	=>	components[[0,0]],
			[0,1]	=>	:submit,
		}
		@css_map = { 1 => 'padded' }
	elsif(@model.items.empty?)
		@components = {
			[0,0]	=>	components[[0,0]],
			[0,1]	=>	:items,
			[0,2]	=>	:submit,
		}
		@css_map = { 2 => 'padded' }
	end
	super
end

#items(model) ⇒ Object



188
189
190
# File 'lib/ydim/html/view/invoice.rb', line 188

def items(model)
	ItemList.new(model.items, @session, self)
end

#pdf(model) ⇒ Object



191
192
193
194
195
196
# File 'lib/ydim/html/view/invoice.rb', line 191

def pdf(model)
	button = HtmlGrid::Button.new(:pdf, model, @session, self)
	url = @lookandfeel._event_url(:pdf, {:unique_id => model.unique_id})
	button.set_attribute('onClick', "document.location.href='#{url}'")
	button
end

#send_invoice(model) ⇒ Object



197
198
199
# File 'lib/ydim/html/view/invoice.rb', line 197

def send_invoice(model)
  button(:send_invoice, model)
end