foodsoft/app/views/orders/_template_orders_script.html.erb

20 lines
783 B
Text
Raw Normal View History

2009-01-06 11:49:19 +01:00
<script type="text/javascript">
//<![CDATA[
// Preset selected order articles per template order:
var template = new Array();
<% current_article_ids = @order.supplier.articles.available.map(&:id) -%>
2009-01-06 11:49:19 +01:00
<% i = -1; for order in @template_orders -%>
template[<%= i += 1 %>] = new Array(<%= current_article_ids.collect { |id| order.article_ids.include?(id) }.join(', ') %>);
2009-01-06 11:49:19 +01:00
<% end -%>
// Call with index into template-array to select order articles from template.
function useTemplate(id) {
if (id >= 0 && id < template.length) {
<% i = -1; for article_id in current_article_ids -%>
var status = template[id][<%= i += 1 %>]
$('checkbox_<%= article_id %>').checked = status;
highlightRow('<%= article_id %>',status);
<% end -%>
}
}
2009-01-06 11:49:19 +01:00
//]]>
</script>