% form_tag with_detour(:controller => 'works', :action => 'create'), :id => "work_form" do %>
<%=submit_tag('checkmark', :value => l(:save), :style => 'display: none')%>
<%=hidden_field :work, :started_on, :value => @date %>
<%=select :work, :work_account_id, [['', '']] + @work_accounts.map {|wa| [wa.name, wa.id]}, :value => '' %>
|
<%=text_field_with_auto_complete :work, :description, :class => :task_description,
:onkeypress => "
if(event.ctrlKey && event.keyCode == 40) { // CTRL-Down-arrow
$('work_notes_div').style.visibility = 'visible';
e = $('work_notes');
e.focus();
// e.select();
} else if(event.keyCode == 38) {
e = $('work#{"_#{last_work.id}" if last_work}_description');
e.focus();
e.select();
} else if(event.keyCode == 13) {
e = $('work_work_account_id');
if(e.value == '') {
e.focus();
e.select();
return false;
}
}"
%>
<% field = 'notes' %>
<% next_field = 'description' %>
<%=text_area :work, :notes, :id => "work_#{field}",
#:onchange => "new Ajax.Request('/works/update_new_row?field=#{field}&next_field=#{next_field}', {asynchronous:true, evalScripts:true, parameters:Form.serialize(form)});",
:onkeypress => "
if(event.ctrlKey && event.keyCode == 38) { // CTRL-UP-arrow
e = $('work_description');
e.focus();
//e.select();
} else if(event.keyCode == 38) { // Up-arrow
notes_field = $('work_#{field}');
if (notes_field.selectionStart == 0 || notes_field.value.indexOf('\\n') == -1 || notes_field.value.indexOf('\\n') > notes_field.selectionStart) {
description_field = $('work_description');
description_field.focus();
//description_field.select();
return false;
}
}",
:onBlur => "
$('work_notes_div').style.visibility = 'hidden';
",
:cols => 80
%>
|
<% field = 'start_time'; next_field = 'completed_at_time' %>
<%=text_field :work, :start_time, :value => last_work && last_work.completed_at && last_work.completed_at.strftime('%H:%M'), :class => 'task_time',
:onchange => remote_function(:url => {:action => :update_new_row, :field => field,
:next_field => next_field},
:with => "
'work[started_on]=' + work_started_on.value
+ '&work[start_time]=' + work_start_time.value
+ '&work[completed_at_time]=' + work_completed_at_time.value
+ '&work[hours_time]=' + work_hours_time.value
"
),
:onkeypress => "
if(event.keyCode == 38) {
e = $('work#{"_#{last_work.id}" if last_work}_start_time');
e.focus();
e.select();
} else if(event.keyCode == 13) {
e = $('work_work_account_id');
if(e.value == '') {
e.focus();
e.select();
return false;
}
}"
%>
|
<% field = 'completed_at_time'; next_field = 'hours_time' %>
<%=text_field :work, :completed_at_time, :class => 'task_time',
:onchange => remote_function(:url => {:action => :update_new_row, :field => field,
:next_field => next_field},
:with => "
'work[started_on]=' + work_started_on.value
+ '&work[start_time]=' + work_start_time.value
+ '&work[completed_at_time]=' + work_completed_at_time.value
+ '&work[hours_time]=' + work_hours_time.value
"
),
:onkeypress => "
if(event.keyCode == 38) {
e = $('work#{"_#{last_work.id}" if last_work}_completed_at_time');
e.focus();
e.select();
} else if(event.keyCode == 13) {
e = $('work_work_account_id');
if(e.value == '') {
e.focus();
e.select();
return false;
}
}",
:value => @work && @work.completed_at_time.strftime('%H:%M')
%>
|
<%=text_field :work, :hours_time, :value => '', :class => 'task_hours',
:onkeypress => "
if(event.keyCode == 38) {
e = $('work#{"_#{last_work.id}" if last_work}_hours_time');
e.focus();
e.select();
} else if(event.keyCode == 13) {
e = $('work_work_account_id');
if(e.value == '') {
e.focus();
e.select();
return false;
}
}"
%>
|
<%=text_field_with_auto_complete :work, :task_id, {:value => '', :size => 16, :class => :task_id} %>
|
<%=check_box :work, :invoice %>
|
<%=text_field_with_auto_complete :work, :customer_name, {:value => '', :size => 16, :class => :task_description} %>
|
|
<% end %>