From e04b2551597c8f7a8feb69ba944404b48fb500e8 Mon Sep 17 00:00:00 2001
From: Marcel de Rooy <m.de.rooy@rijksmuseum.nl>
Date: Thu, 3 Apr 2014 14:15:11 +0200
Subject: [PATCH] [SIGNED OFF] Bug 9088: neworderempty should preselect the
 only fund

If there is only one fund in the select combo (and the fund is mandatory),
neworderempty should just select it already.
If there are more choices, behavior does not change.

This patch implements this change in the template itself.

Test plan:
With more funds, check if neworderempty does not preselect a fund (at least
when adding a line; when you modify, you should see what you had chosen).
With one fund, check if it is already selected (add or modify).
Toggle the setting of AcqCreateItem and check again.

Signed-off-by: Mark Tompsett <mtompset@hotmail.com>

NOTE: I don't think AcqCreateItem affects this.
       However, I did toggle AcqCreateItem to
       'receiving an order' from 'placing an order'.
      Tested before and after patch with 1 fund
      Tested after patch with 2 funds.
      Tiny patch, does what it says. Defaults fund dropdown
       if there is only one fund.
---
 .../prog/en/modules/acqui/neworderempty.tt         |    3 +++
 1 file changed, 3 insertions(+)

diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/acqui/neworderempty.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/acqui/neworderempty.tt
index 596aa07..e57ea13 100644
--- a/koha-tmpl/intranet-tmpl/prog/en/modules/acqui/neworderempty.tt
+++ b/koha-tmpl/intranet-tmpl/prog/en/modules/acqui/neworderempty.tt
@@ -416,6 +416,9 @@ $(document).ready(function()
                 <label class="required" for="budget_id">Fund: </label>
                 <select id="budget_id" onchange="fetchSortDropbox(this.form)" size="1" name="budget_id">
                         <option value="">Select a fund</option>
+                [% IF budget_loop.size == 1 %]
+                    [% budget_loop.first.b_sel = 1 %]
+                [% END %]
                 [% FOREACH budget_loo IN budget_loop %]
                     [% IF ( budget_loo.b_sel ) %]
                         <option value="[% budget_loo.b_id %]" selected="selected">[% budget_loo.b_txt %]</option>
-- 
1.7.9.5