foodsoft/app/views/orders/_template_orders_script.htm...

18 lines
780 B
Plaintext

<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>