[% PROCESS elements.html # Include form elements helper. %] [% accountclass.type = 'hidden'; PROCESS input element_data=accountclass %] [% login.type = 'hidden' ; PROCESS input element_data=login %] [% #WE NEED TO KNOW HOW MANY COLUMNS ARE WE USING, PLEASE DO NOT MOVE THE NEXT LINE -%] [% column_count = 0; FOREACH column IN column_headers; column_count = column_count + 1; END -%]

[% header.text %] [% type.type = 'hidden' ; PROCESS input element_data=type %]

[% IF (type.value == 'receipt') -%] [% text('Customer Name') -%] [% ELSE; text('Vendor Name') -%] [% END -%] | [% vc.name %][% vendorcustomer.type = 'hidden'; PROCESS input element_data=vendorcustomer%]
[% text('Location') %] | [% # this table will show the customer/vendor address, city, phone and others things that could help to reminds them%] [% FOREACH address IN vc.address # Loop through customer/vendor address info %]
[% address.text %]
[% END %]
[% text('Notes') %] | [% PROCESS textarea element_data = { id="notes" name="notes" cols="35" rows="3" text=notes } %]
| [% # the project will be shown if it was selected in the first step %] [% IF project.value # Only process element if the value exists. %]
[% text('Projects') %]: | [% project.text %] [% project.type="hidden"; PROCESS input element_data=project %]
[% END %] [% #the department will be shown if it was selected in the first step %] [% IF department.value # Only process element if one exists. As in project above %]
[% text('Department') %]: | [% department.text %] [% department.type="hidden"; PROCESS input element_data=department %]
[% END %]
[% #here goes all the posible accounts were the paid can be done %] [% text('Account') %] | [% PROCESS select element_data = { name = 'account' options = account text_attr = 'description' value_attr = 'id' default_values = [selected_account] } %]
[% # here goes an input where the date can be written, we can also use a java calendar :). We can use an ajax script to call the Exchange rate of the input date which can be called with the onChange Method %] [% text('Date') %] [%- datepaid.class = 'date' %] | [% ddp="data-dojo-props"; datepaid.$ddp="defaultIsToday:true" ; PROCESS input element_data=datepaid %] [% datepaid.id='olddatepaid'; datepaid.name='olddatepaid'; datepaid.type='hidden'; PROCESS input element_data=datepaid %] [% INCLUDE tooltip element_data = { ref_id => "datepaid" msg => text("Date to register payment") }; %]
[% # here goes all the posible sources which we can use -%] [% text('Source')%] | [% PROCESS input element_data={ class => 'source' name => 'source_value' id => 'source_value' value => source_value } -%] [% INCLUDE tooltip element_data = { ref_id => 'source_value' msg => text("Source documentation") }; %]
[% # here goes the selected currency in step 1 %] [% text('Currency') -%] | [% curr.value -%][% curr.type='hidden'; PROCESS input element_data=curr -%]
[% # here goes the exchange rate of the selected currency, it can be done by the ajax script or the update button %] [% IF defaultcurrency.text != curr.text # Only process element if one exists. %]
[% text('Exchange Rate') %] | [% IF exrate.value -%] [% exrate.text -%] [% exrate.type='hidden'; PROCESS input element_data=exrate -%] [% END -%] [% IF !exrate.value -%] [% PROCESS input element_data=exrate -%] [% END -%]
[% END %]

[% j=1; FOREACH column IN column_headers; # Loop through columns IF j < column_count ; THEN -%] [% column.text %] [% ELSE -%] | [% INCLUDE tooltip element_data = { ref_id => "checkbox_all" msg => text("Toggle all removal checkboxes") }; %] [% END; j = j + 1; %] [% END %]
--- | ---
[% want_descriptions = ''; FOREACH row IN rows; IF row.description; want_descriptions = 1; LAST; END; # IF END; # FOREACH IF want_descriptions; -%]
| [% text("Description") %]
[% END -%] [% # We have to clear i for later usage :) %] [% i = '0'; -%] [% FOREACH row IN rows %] [% i = i + 1; j = i % 2; alternating_style = "listrow$j" %]
[% row.invoice.number %] [% # we can use an href to link this invoice number to the invoice %] | [% row.invoice_date %] [% PROCESS input element_data = { type="hidden" name="invoice_date_" _ row.invoice.id value=row.invoice_date } %] | [% row.amount %] | [% row.paid %] | [% row.discount %] | [% IF row.optional_discount OR first_load ; CHECKED='checked'; ELSE; CHECKED=''; END; %] [% PROCESS input element_data = { name="optional_discount_" _ row.invoice.id id="optional_discount_" _ row.invoice.id type="checkbox" class="checkbox" checked=CHECKED } %] | [% row.memo.id=row.memo.name; PROCESS input element_data=row.memo; -%] [% INCLUDE tooltip element_data = { ref_id => row.memo.name msg => text("Memo to help retrieval") }; %] [% IF defaultcurrency.text != curr.value %] | [% row.exchange_rate %] [% END %] | [% row.due %] [% IF defaultcurrency.text != curr.value %] | [% row.due_fx %] [% INCLUDE tooltip element_data = { ref_id => "div_topay_invoice_$i" msg => text("Amount to pay") }; %] [% END %] [% #This should be computed and updated to the div using %] | [% row.topay_fx.id=row.topay_fx.name; PROCESS input element_data = { type = "text" id = row.topay_fx.id name = row.topay_fx.name value = row.topay_fx.value class = "topay_amount amount" }; PROCESS input element_data = { type = "hidden" id = "orig_" _ row.topay_fx.id name = "orig_" _ row.topay_fx.name value = row.orig_topay_fx } %]
[% # here goes all the posible accounts were the paid can be done %] [% text('Account') %] | [% PROCESS select element_data = { id="account_" _ row.invoice.id name="account_" _ row.invoice.id options=account value_attr='id' text_attr='description' default_values=[row.selected_account] } %]
[% # here goes all the posible sources which we can used %] [% text('Source') %] | [% PROCESS input element_data={ name => "source_text_$row.invoice.id", id => "source_text_$row.invoice.id", value => row.source_text } -%] | [% IF row.optional ; CHECKED='checked' ; ELSE ; CHECKED=''; END ; %] [% PROCESS input element_data = { name="optional_pay_" _ row.invoice.id id="optional_pay_" _ row.invoice.id type="checkbox" class="checkbox" checked=CHECKED } %]
| [% PROCESS input element_data = { type="checkbox" class="remove" id="checkbox_" _ row.invoice.id name="checkbox_" _ row.invoice.id checked="checked" } %] [% INCLUDE tooltip element_data = { ref_id => "checkbox_" _ row.invoice.id msg => text("Uncheck to remove entry from payment") }; %]
[% IF want_descriptions; -%]
| [% row.description %] [%# the ensures the row is not suppressed when there is no description -%]
[% END; -%]
[% END %] [% colspan = column_count - 2 # We will use this later on totals -%]
[% text('Subtotal') -%] | [% topay_subtotal -%] [% curr.value -%]

[% IF overpayment_account.size > 0 %]

[% text('OVERPAYMENT / ADVANCE PAYMENT / PREPAYMENT') %]
[% text('Item') %] | [% text('Account') %] | [% text('Cash Account')%] | [% text('Source') %] | [% text('Memo') %] | [% text('Amount') %] | X
--- | --- | --- | --- | --- | --- | ---
[% # We have to insert the overpayment data -%] [% overpayment_item = 0; -%] [% FOREACH item IN overpayment -%] [% overpayment_item = overpayment_item + 1 -%] [% j = overpayment_item % 2; alterning_style = "listrow$j" %]
[% overpayment_item %] | [% item.account.accno -%]--[% item.account.description -%] [% PROCESS input element_data = { type="hidden" id="overpayment_account_" _ overpayment_item name="overpayment_account_" _ overpayment_item value=item.account.id _ '--' _ item.account.accno _ '--' _ item.account.description } %] | [% item.cashaccount.accno -%]--[% item.cashaccount.description -%] [% PROCESS input element_data = { type="hidden" id="overpayment_cash_account_" _ overpayment_item name="overpayment_cash_account_" _ overpayment_item value=item.cashaccount.id _ '--' _ item.cashaccount.accno _ '--' _ item.cashaccount.description } %] | [% item.source2 -%] [% PROCESS input element_data = { type="hidden" id="overpayment_source2_" _ overpayment_item name="overpayment_source2_" _ overpayment_item value=item.source2 } %] | [% item.memo -%] [% PROCESS input element_data = { type="hidden" id="overpayment_memo_" _ overpayment_item name="overpayment_memo_" _ overpayment_item value=item.memo } %] | [% item.amount -%] [% PROCESS input element_data = { type="hidden" id="overpayment_topay_" _ overpayment_item name="overpayment_topay_" _ overpayment_item value=item.amount } %] | [% PROCESS input element_data = { type="checkbox" class="remove" name="overpayment_checkbox_" _ overpayment_item } %]
[% END -%] [% #Now we insert an empty field to process a new overpayment -%] [% overpayment_item = overpayment_item + 1; j = overpayment_item % 2; alterning_style = "listrow$j" -%]
[% overpayment_item -%] | [% options=[]; FOREACH item IN overpayment_account; options.push( { text = item.description value = item.id _ '--' _ item.accno _ '--' _ item.description }); END; PROCESS select element_data = { id="overpayment_account_" _ overpayment_item name="overpayment_account_" _ overpayment_item options=options } %] | [% options=[]; FOREACH item IN account; options.push( { text = item.description value = item.id _ '--' _ item.accno _ '--' _ item.description }); END; PROCESS select element_data = { id="overpayment_cash_account_" _ overpayment_item name="overpayment_cash_account_" _ overpayment_item options=options } %] | [% PROCESS input element_data = { name="overpayment_source2_" _ overpayment_item class="source" id="overpayment_source2_" _ overpayment_item } %] [% PROCESS input element_data = { type="hidden" name="overpayment_qty" id="overpayment_qty" value=overpayment_item } %] | [% PROCESS input element_data = { name="overpayment_memo_" _ overpayment_item id="overpayment_memo_" _ overpayment_item } %] | [% PROCESS input element_data = { name="overpayment_topay_" _ overpayment_item id="overpayment_topay_" _ overpayment_item value="0" class="overpayment_topay" } %] | [% PROCESS input element_data = { type="checkbox" class="remove" name="overpayment_checkbox_" _ overpayment_item } %]
[% text('Subtotal') -%] | [% overpayment_subtotal -%] [% curr.value -%]
[% text('Total') -%] | [% payment_total -%] [% curr.value -%]

[% ELSE; # IF overpayment_account.size == 0 %]

[% text('Total') -%] | [% payment_total -%] [% curr.value -%]
--- | ---

[% END; # IF overpayment_account.size == 0 %]

[% PROCESS button element_data={ title = "UPDATE ALT+U" name = "__action" value = "update_payment2" text = text("Update") } -%] [% PROCESS button element_data={ title = "POST ALT+P" name = "__action" value = "post_payment" text = text("Post") } -%] [% PROCESS button element_data={ title = "POST AND PRINT ALT+R" name = "__action" value = "post_and_print_payment" text = text("POST AND PRINT") "data-dojo-type" = "lsmb/payments/PostPrintButton" } %]
[% FOREACH item IN topay_state -%] [% PROCESS input element_data= { type = "hidden" name = item.id } %] [% END -%]