.row
.col-sm-12
.box
.box-header.dark-background
.box-content
= form_for [:user, @warranty_code], html: { multipart: true, class: 'form form-horizontal'} do |f|
.form-group
%label.col-md-2.control-label Code
.col-md-5
.span.label.label-info
= @warranty_code.code
= form_group(@warranty_code, :first_name) do
%label.col-md-2.control-label{for: :first_name} First Name
.col-md-5
= f.text_field :first_name, class: 'form-control'
= form_group(@warranty_code, :last_name) do
%label.col-md-2.control-label{for: :last_name} Last Name
.col-md-5
= f.text_field :last_name, class: 'form-control'
= form_group(@warranty_code, :company) do
%label.col-md-2.control-label{for: :company} Company
.col-md-5
= f.text_field :company, class: 'form-control'
= form_group(@warranty_code, :email) do
%label.col-md-2.control-label{for: :email} Email
.col-md-5
= f.text_field :email, class: 'form-control'
= form_group(@warranty_code, :printer) do
%label.col-md-2.control-label{for: :printer} Printer
.col-md-5
-if @warranty_code.assigned?
= f.text_field :printer, class: 'form-control'
-else
= f.select :printer, options_for_select([["", ""],["SG400", "SG400"], ["SG800", "SG800"]])
= form_group(@warranty_code, :notes) do
%label.col-md-2.control-label{for: :notes} Notes
.col-md-5
= f.text_area :notes, class: 'form-control'
.form-actions.form-actions-padding-sm
.row
.col-md-10.col-md-offset-2
= f.submit "Save", class: 'btn btn-primary'
:javascript
assigned = "#{ @warranty_code.assigned? }"
$(document).ready(function(){
if (assigned === "true"){
console.log("True")
$('#warranty_code_first_name').attr('disabled', 'disabled');
$('#warranty_code_last_name').attr('disabled', 'disabled');
$('#warranty_code_company').attr('disabled', 'disabled');
$('#warranty_code_email').attr('disabled', 'disabled');
$('#warranty_code_printer').attr('disabled', 'disabled');
}
})