Bug 11404: add support for Apache 2.4's config file convention

Apache 2.4 expects the sites definition files use the sufix '.conf'

To reproduce:
- Install the 'koha-common' package on Debian 7 or Ubuntu 13.10+
  (both known to include Apache 2.4).
- Create an instance (for example testlibrary) using the supplied
  commands:
 $ koha-create --create-db testlibrary
> FAIL: apache reports an error like this:
"ERROR: Site testlibrary does not exist!"

This patch adds a test on the Apache version and appends the ".conf"
sufix if needed.

To test:

1st step: koha-create gets fixed:

-- The hard way --
- Apply the patch, and build the koha-common package on top of this
  commit.
- Install the built package on an Apache 2.4 Debian-based distro (Debian 7
  or Ubuntu 13.10 will work)
- Create a test instance:
 $ koha-create --create-db testlibrary
> SUCCESS: no more apache sites related error.

-- The easy way --
- Apply the patch, and copy the koha-create into an Apache 2.4
  Debian-based distro
- Create a test instance using the koha-create script you just
  copied:
 $ ./koha-create --create-db testlibrary
> SUCCESS: no more apache sites related error.

2nd step: the rest of the touched scripts keep working as usual

koha-disable
koha-dump
koha-enable
koha-list
koha-remove
koha-restart-zebra
koha-stop-zebra
koha-start-zebra

They should all keep working. Can be tested "the easy way" too.

Note: there might be another issues regarding Apache 2.4 deployments
like the need for

 $ a2enmod access_compat

and perhaps some directory permissions tweak, which I think should be
properly documented on the install instructions.

Sponsored-by: Universidad Nacional de Cordoba
Signed-off-by: Robin Sheat <robin@catalyst.net.nz>
Signed-off-by: Galen Charlton <gmc@esilibrary.com>
Bug 11404: koha-functions.sh introduced for reuse

As asked by Robin, a bash lib of functions is introduced with the common
functions to be reused. Most of the scripts are modified (reduced) to
include this file and the repeated functions cleaned.

No noticeable change in behaviour should be noticed.

As I've been todl in #debian-mentors, it is used that files for inclusion
should be installed at the apps directory (i.e. /usr/share/koha/) so this
patch makes the install script put the file in the bin/ directory.

All koha-* scripts assume the file is there already (and fail otherwise).

Sponsored-by: Universidad Nacional de Cordoba
Signed-off-by: Robin Sheat <robin@catalyst.net.nz>
Signed-off-by: Galen Charlton <gmc@esilibrary.com>
Bug 11404: Make the install process aware of the changes

This patch makes the install scripts take care of the new file
and prompt for user confirmation on the apache file renaming step.

Both prompt and the renaming actions depend on the fact that there
are instances with their files missing the .conf appendix.

Sponsored-by: Universidad Nacional de Cordoba
Signed-off-by: Robin Sheat <robin@catalyst.net.nz>
Signed-off-by: Galen Charlton <gmc@esilibrary.com>
Bug 11404: (follow-up) only ask user if there are instances needing upgrading

There's no point asking the user if they want their Apache Koha
configuration updated if there's no configuration needing updated.

This also fixes a case where the updating would have failed when running
on Apache 2.4.

Signed-off-by: Tomas Cohen Arazi <tomascohen@gmail.com>
I agree with adding that checks, and the conditions rewrite seems cleaner
than my first approach. So, I sign it.

Signed-off-by: Galen Charlton <gmc@esilibrary.com>
Bug 12168: fix spent and ordered budget values are wrong when depth >= 2

A really weird (and old) code process the calculation for the spent and
ordered sublevel funds.

It only takes into account the direct children.

So if you have:
fund1 (spent=100) parent of fund11 (spent=10) parent of fund111 (spent=1),
you get:

fund     | base-level | total spent
fund1    | 100        | 110
fund11   | 10         | 11
fund111  | 1          | 1

which is wrong, it should be

fund     | base-level | total spent
fund1    | 100        | 111
fund11   | 10         | 11
fund111  | 1          | 1

Test plan:
- Create 1 budget and 3 funds with the same structure as above.
- Create some orders and receive them (not all).
- Go on the fund list view and verify the values are correct.

Signed-off-by: Kyle M Hall <kyle@bywatersolutions.com>
Signed-off-by: Galen Charlton <gmc@esilibrary.com>
Bug 12168: Add unit tests for GetBudgetHierarchySpent & GetBudgetHierarchyOrdered

Test plan:
prove t/db_dependent/Budgets.t

Note: This addition may sound overkill but I found this bug developing
bug 12164 and I will reuse all of that.

Signed-off-by: Kyle M Hall <kyle@bywatersolutions.com>
Signed-off-by: Galen Charlton <gmc@esilibrary.com>
Bug 12168: (follow-up) correct typos in test descriptions

Signed-off-by: Galen Charlton <gmc@esilibrary.com>