foodsoft/app/views/orders/_template_orders_script.html.erb
2009-01-06 11:49:19 +01:00

18 lines
No EOL
780 B
Text

<script type="text/javascript">
//<![CDATA[
// Preset selected order articles per template order:
var template = new Array();
<% i = -1; for order in @template_orders -%>
template[<%= i += 1 %>] = new Array(<%= @order.supplier.getArticlesAvailableForOrdering.collect{|a| !order.order_article_results.detect{|t| t.name == a.name }.nil?}.join(', ') %>);
<% 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 in @order.supplier.getArticlesAvailableForOrdering -%>
var status = template[id][<%= i += 1 %>]
$('checkbox_<%= article.id %>').checked = status;
highlightRow('<%= article.id %>',status);
<% end -%>}
}
//]]>
</script>