Created
April 26, 2016 13:12
-
-
Save eltonsantos/b89e33149d4a776ac08d90a8c33cb5d0 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<h3>Reserve of refinancing</h3> | |
<table class="table table-condensed table-bordered"> | |
<tr> | |
<td>Name:</td> | |
<td><%= @employee.first.person.name %></td> | |
</tr> | |
<tr> | |
<td>CPF:</td> | |
<td><%= @employee.first.person.cpf %></td> | |
</tr> | |
</table> | |
<%= simple_form_for(@refinancing) do |f| %> | |
<div class="form-inputs"> | |
<%= f.hidden_field :employee_id, value: @employee.first.id %> | |
<%= f.hidden_field :authorization, value: @authorization %> | |
<%= f.input :contract_number %> | |
</div> | |
<h3>Reserved value</h3> | |
<table class="table table-condensed table-bordered table-striped"> | |
<thead> | |
<th>Authorization id</th> | |
<th>Contract number</th> | |
</thead> | |
<% @authorizations.each do |authorization| %> | |
<tbody> | |
<tr> | |
<td><%= authorization.id %></td> | |
<td><%= authorization.contract_number %></td> | |
</tr> | |
</tbody> | |
<% end %> | |
</table> | |
<div class="form-actions"> | |
<%= f.button :submit, "To Reserve" %> | |
</div> | |
<% end %> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def new | |
if params[:authorization].present? | |
@selected_ids = params[:authorization][:contract_number] | |
@authorizations = Authorization.where("contract_number in (?)", @selected_ids) | |
auth_params = params[:authorization] | |
auth_params[:contract_number].zip(auth_params[:value_solve].reject(&:blank?)).each do |contract_number, value_solve| | |
Authorization.where(contract_number: contract_number).update_all(value_solve: value_solve, situation: 2) | |
end | |
@authorizations.ids.each do |auth_id| | |
@historic_refinancing = HistoricRefinancing.create | |
@historic_refinancing = HistoricRefinancing.update_all(authorization_origin_id: auth_id) | |
end | |
end | |
@employee = Employee.search_cpf(params[:search_employee_by_cpf]) | |
@refinancing = Refinancing.new | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment