2009-01-06 11:49:19 +01:00
|
|
|
<script type="text/javascript">
|
|
|
|
//<![CDATA[
|
|
|
|
// Preset selected order articles per template order:
|
2009-02-04 16:41:01 +01:00
|
|
|
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 -%>
|
2009-02-04 16:41:01 +01:00
|
|
|
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) {
|
2009-02-04 16:41:01 +01:00
|
|
|
<% 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>
|