Bug 10409 - Do not show course entry form if no departments are found

The course reserves entry form should not be shown if there are no
DEPARTMENT authorized values, since this prevents the form from being
submitted. This patch replaces the form with an error message when no
DEPARTMENT authorized values are found.

Also corrected:

- Corrected grid structure for more standard display
- Converted labels with no corresponding inputs to <span class="label">
- Closed unclosed tags
- Corrected incorrect capitalization

This patch contains whitespace changes, so please ignore whitespace when
examining changes.

To test, delete any DEPARTMENT authorized values, if present. Create a
new course in Course Reserves. You should see a warning that no
DEPARTMENT values were found.

If you are logged in with the correct permission, the warning should
contain a link to the correct authorized value page. If you do no, the
warning should refer the problem to an administrator.

After creating one or more DEPARTMENT values, the form should display
and submit correctly.

Signed-off-by: Jared Camins-Esakov <jcamins@cpbibliography.com>
After this patch has been applied, I get an error message and no form
if I don't have any DEPARTMENTs defined, which makes sense given that
the form can't be submitted without a DEPARTMENT.

Signed-off-by: Katrin Fischer <Katrin.Fischer.83@web.de>
Passes all tests and QA script.
You now see a useful error message, when no departments have been
defined. Else you are taken to the correct form.
Signed-off-by: Galen Charlton <gmc@esilibrary.com>
Bug 10409: Follow up - improving strings for easier translation

Fixing this line:
<legend>[% IF course_id %] Edit [% ELSE %] Create [% END %] course</legend>

As grammar works different in different languages, having single
strings like that in a predefined order makes having a nice translation
unnecessarily hard.

This will make it a little easier:
<legend>[% IF course_id %]Edit course[% ELSE %]Create course[% END %]</legend>

Signed-off-by: Kyle M Hall <kyle@bywatersolutions.com>
Signed-off-by: Galen Charlton <gmc@esilibrary.com>
Bug 7019: fix sorting by return date in Circulation History

The "return date" column sort is not using the date sort algorithm because it is
confused by the combination of date data and text data ("Checked out").

This patch adds the use of datatable "title-string" sort type.
With that, the date in ISO format are used for sorting and because
letters are before numbers, "Checked out" rows are more recent than any date.

Test plan :
- set dateformat syspref to "dd/mm/yyyy"
- Go to members/readingrec.pl for a borrower having a old issues and
checked out issues
=> Check that sort of "Return date" is correct.
For example :
With patch :
  20/01/2011
  06/03/2011
  20/03/2011
  Checked Out
Without patch :
  06/03/2011
  20/01/2011
  20/03/2011
  Checked Out
- Test also with dateformat syspref "mm/dd/yyyy"

Signed-off-by: Srdjan <srdjan@catalyst.net.nz>
Signed-off-by: Jonathan Druart <jonathan.druart@biblibre.com>
Signed-off-by: Galen Charlton <gmc@esilibrary.com>
Bug 10563: Fix broken 'Edit' link on check expiration page

This fixes the broken 'Edit' (subscription) link on the
check expiration page in serials.

To test:
- Add a subscription
- Go to the check expiration page
- Search for your subscription, use an expiration date in the
  far future
- Verify the edit link on the result list doesn't work right
  before applying the patch, but works after

Signed-off-by: Owen Leonard <oleonard@myacpl.org>
Signed-off-by: Jonathan Druart <jonathan.druart@biblibre.com>
Signed-off-by: Galen Charlton <gmc@esilibrary.com>
Bug 9576: can now control whether max loans limit can be overriden

Adds a new system preference AllowTooManyOverride to control whether
a librarian can override the 'Too many checked out' message which is
currently always overridable.

Test Plan:
1) Apply patch
2) Run updatedatabase.pl
3) Attempt to check out 1 more item to a patron than the max issues
4) You should be allowed to override by default ( current behavior )
5) Set AllowTooManyOverride to "Don't allow"
6) Repeat step 3
7) You should be blocked from being able to issue the item

Signed-off-by: Srdjan <srdjan@catalyst.net.nz>
Signed-off-by: Katrin Fischer <Katrin.Fischer.83@web.de>

The new system preference is activated by default, which mean there
will be no change in behaviour on update.

The system preference is correctly added to the database and .pref
files.

Test plan and QA script passes.

Signed-off-by: Galen Charlton <gmc@esilibrary.com>
Bug 9576: DBRev 3.13.00.013

Signed-off-by: Galen Charlton <gmc@esilibrary.com>
Bug 9362: fix query that finds upcoming due loans

C4:Circulation:GetUpcomingDueIssues is used in the advance_notices.pl
script.  This patch corrects an error in its handling of the maxdays
parameter that resulted in it picking up *all* upcoming due loans and
recently overdue loans.

Test plan :
- Create an issue with a date due in the paste
- Create an issue with a date due in two days
- Launch advance notices with due date in max 2 days : perl misc/cronjobs/advance_notices.pl -c -n -v -m=2
=> You get a warn "found 0 issues"
- Launch advance notices with due date in max 3 days : perl misc/cronjobs/advance_notices.pl -c -n -v -m=3
=> You get a warn "found 1 issues"

Signed-off-by: Mathieu Saby <mathieu.saby@univ-rennes2.fr>
I did the following test :

- 1 book to check in 2 days
- 2 books to check in in the past

before applying the patch :

$perl ../misc/cronjobs/advance_notices.pl -c -n -v -m=2
getting upcoming due issues at ../misc/cronjobs/advance_notices.pl line 203.
found 1 issues at ../misc/cronjobs/advance_notices.pl line 205.

I changed the value of "-m" : 0, 1, 2, 3, 4
=> always 1 issue found (the book to check in in 2 days)

after applying the patch :

$perl ../misc/cronjobs/advance_notices.pl -c -n -v -m=2
found 0 issues
for m = 0, 1, 2 => 0 issues

$perl ../misc/cronjobs/advance_notices.pl -c -n -v -m=3
found 1 issues
for m = 3,4,5 => 1 issues (the book to check in in 2 days)

Signed-off-by: Kyle M Hall <kyle@bywatersolutions.com>
Passes koha-qa.pl, works as advertised.

Signed-off-by: Galen Charlton <gmc@esilibrary.com>
Bug 10541: enable cross-browser AJAX in additem.js

Currently, the additem.js is using "indexOf" to search
for a value in an array. While this works in Chrome, Firefox,
and IE > 9, it fails miserably in IE 8 and 7 (which don't have
the indexOf method). This means that users aren't able to add
items using the acquisitions module!

Instead of using "indexOf", we should be using the jQuery function
$.inArray. It was added in jQuery v1.2 (3.8.0 uses v1.3.2 so even
our oldest supported release can use this method). It's perfectly
cross-browser compatible...works in Chrome, Firefox, and every
version of IE that I've tried (i.e. 7, 8, 9).

Test Plan:

Before applying patch:

0) Switch to Internet Explorer 7, or 8, or 9, or 10.

If you're using IE 9 or 10, you'll need to change the Document Mode to
IE7 standards or IE8 standards.

You can do this by opening Internet Explorer 9 or 10, pressing F12 (or
clicking on the gear in the top right corner and choosing
F12 Developer Tools), and then clicking on "Document Mode" on the
top toolbar. There, you can change to IE7 or IE8 standards.

N.B. This is not always a perfect emulation in every case, but this
time it does show you the bug.

1) Set the system preference AcqCreateItem to "receiving an order"
2) Go to Acquisitions
3) Either:
    a) Receive a shipment for a basket with items
    b) Create a new basket, create an order, close the basket, and
       then do 3a)
4) In the "Item" fieldset, fill out some fields such as barcode,
   Date acquiried, Public note, etc.
5) Click "Add" at the bottom of the fieldset
6) Note that while the item may have been added, the "Item" fieldset
is not being shown again. You may also notice a Javascript error
appearing in a pop-up window or you might see a yellow warning flag
on the bottom status bar.

APPLY THE PATCH

7) Do a full refresh of the page (hold down shift and press the refresh
button on the browser next to the address bar), and try adding items
again.
8) Note that you receive no warnings and that items are added correctly
as they would be in Firefox or Chrome.

OPTIONALLY

9) To be sure that I haven't broken anything, go through the same steps
in IE9 (with IE9 standards) or Chrome or Firefox. Everything should be
working.

Signed-off-by: Owen Leonard <oleonard@myacpl.org>

Tested in IE10 in IE7 mode and IE9 mode. Also tested in Firefox.

Signed-off-by: Kyle M Hall <kyle@bywatersolutions.com>
Passes koha-qa.pl, works as advertised.

Signed-off-by: Galen Charlton <gmc@esilibrary.com>
Bug 10515: make behavior of library category fetchers consistent with other fetchers

The prototype is not consistent, GetBranchCategory should return only 1 result
and GetBranchCategories should not have a categorycode argument.
This patch fixes that.

Test plan:
1/ Try to add/remove/modify a library.
2/ Add some groups
3/ Add these groups to a library

Signed-off-by: Srdjan <srdjan@catalyst.net.nz>
Signed-off-by: Kyle M Hall <kyle@bywatersolutions.com>
Signed-off-by: Galen Charlton <gmc@esilibrary.com>
Bug 10515: add regression tests

Signed-off-by: Galen Charlton <gmc@esilibrary.com>
Bug 10515: (follow-up) fix use of GetBranchCategories

Adjusting to reflect the removal of the branchcode parameter
to GetBranchCategories; also filter on the 'searchdomain'
library group type, as appears to have been intended.

Signed-off-by: Galen Charlton <gmc@esilibrary.com>
bug 10549: make the ILS-DI services advertise that they return UTF-8

This patch changes a few occurences of ISO-8859-1 to UTF-8
within the XML generation of the ILS-DI module.

To test:
- Activate ILS-DI system preference
- Go to [youropac]/cgi-bin/koha/ilsdi.pl
- Check all examples in the documentation for the correct
  encoding
- Check GetAvailability gives you the correct encoding and
  check the source for the correct encoding

Signed-off-by: Katrin Fischer <Katrin.Fischer.83@web.de>
Signed-off-by: Kyle M Hall <kyle@bywatersolutions.com>
Signed-off-by: Galen Charlton <gmc@esilibrary.com>
Bug 10549: (follow-up) make sure ILS-DI GetAvailability response is emitted as UTF-8

Signed-off-by: Galen Charlton <gmc@esilibrary.com>
Bug 10411: add cache control headers for static resources (Debian package)

This adds caching directives to the static resources so that the browser
doesn't ask about them all the time.

By default, Debian apache doesn't have the required module (mod_expires)
enabled, and so this patch will have no effect. In order to enable this
function, run:

a2enmod expires

and restart apache.

Test Plan:
* Using firebug or equivalent, load a page.
* Note that none of the images, css, or js files have a Cache-Control or
  Expires header set.
* Add this patch, redeploy the package with it (or overwrite the
  apache-share.conf file) enable the 'expires' module, restart apache.
* Force-reload the page
* Note that the images, css, js now have Cache-Control and Expires set
  for 12 hours into the future.

Signed-off-by: Galen Charlton <gmc@esilibrary.com>
Signed-off-by: Jonathan Druart <jonathan.druart@biblibre.com>
Signed-off-by: Galen Charlton <gmc@esilibrary.com>
Bug 10595: don't display OpacTopissue page when system preference is turned off

When the syspref is turned off, the link is hidden but the page is still
accessible. This patch checks the syspref and redirects to 404 if it is disabled.

Test plan:

Before applying the patch

Enable OpacTopissue
  Observe there is a link to opac-topissues.pl next to Advanced search etc.
  Follow that link, observe that opac-topissues.pl is loading
Disable OpacTopissue
  Observe the link is gone
  Manually open /koha/opac-topissues.pl and check that it is loading even though the feature is disabled

Apply patch

(OpacTopissue still diabled)
Manually open /koha/opac-topissues.pl and observe that you are being redirected to the 404 page.
Enable OpacTopissue
  Follow the link or manuall open opac-topissues.pl and check that it is working

Signoff the patch.

Signed-off-by: Srdjan <srdjan@catalyst.net.nz>
Signed-off-by: Jonathan Druart <jonathan.druart@biblibre.com>
Signed-off-by: Galen Charlton <gmc@esilibrary.com>
Bug 10597: fix Search to hold button on record details page

The holds button in cat-toolbar is broken for "search to hold". It is a
split button rather than a dropdown button. Clicking the caret works
fine, but clicked the button sends you to the marc editor!

Test Plan:
1) View a patron's details page
2) Click 'search to hold'
3) Search for something
4) On the results page, click a result line's title link (
    catalogue/detail.pl )
5) Note the "Place hold" button is a split button, click the left half
    of the button, note it redirects you to the editor.
6) Apply this patch
7) Repeat steps 1-5

Signed-off-by: Srdjan <srdjan@catalyst.net.nz>
Signed-off-by: Jonathan Druart <jonathan.druart@biblibre.com>
Signed-off-by: Galen Charlton <gmc@esilibrary.com>
bug 10559: remove spurious "statement handle still active" warnings

Generating (e.g.) overdue notices can result in spurious warnings in
the cronjob logs:

$ ./misc/cronjobs/overdue_notices.pl -t -library CPL
prepare_cached(SELECT * FROM issues WHERE     itemnumber = ?) statement handle DBI::st=HASH(0x54a7828) still Active at C4/Letters.pm line 589

This patch removes the warning by making sure that the relevant statement
handle is finished after fetching its first row of results.

To test:

[1] Set up an overdue loan such that running overdue_notices.pl will
    trigger the generation of a notice.
[2] Run overdue_notices.pl -t and note the warning message.
[3] Apply the patch.
[4] Run overdue_notices.pl -t again and note that the warning message
    is no longer displayed.
[5] Check the message_queue table and verify that the overdue
    notices generated in steps 2 and 4 have the same text.

Signed-off-by: Galen Charlton <gmc@esilibrary.com>
Signed-off-by: Srdjan <srdjan@catalyst.net.nz>
Signed-off-by: Jonathan Druart <jonathan.druart@biblibre.com>
Signed-off-by: Galen Charlton <gmc@esilibrary.com>
Bug 10553: make public lists available on OPAC login page

If you are not logged in to the OPAC, looking at the login page, and you
click the Lists button to see public lists it says there are none. This
patch corrects Auth.pm so that it loads the list of public lists in this
situation.

To test you must have at least one public list. Make sure you are logged
out of the OPAC and visit the login page (/cgi-bin/koha/opac-user.pl).
Clicking the "Lists" button should show you a list of public shelves.

Signed-off-by: Liz Rea <liz@catalyst.net.nz>
works as described, and list button is not shown when opacpublic is disabled.

Signed-off-by: Marcel de Rooy <m.de.rooy@rijksmuseum.nl>
Signed-off-by: Galen Charlton <gmc@esilibrary.com>
Bug 10457: fix SQL error when using 'export select items data' in serials claims page

Currently, if you use the "check all" checkbox next to the "Vendor"
table header, and try to "Export selected items data", you'll
see the following SQL error in the Apache error log:

DBD::mysql::st execute failed: You have an error in your SQL syntax;
check the manual that corresponds to your MySQL server version for
the right syntax to use near 'on ORDER BY title' at line 12 at
/.../lib/C4/Serials.pm line 1828.

This is because the Javascript that produces the re-direct URL is
including the value of the checkall checkbox, which is "on",
as a "serialid".

We need to only take checkboxes with a name of "serialid" when
crafting the re-direct link.

This patch adds the [name=serialid] attribute selector to the Jquery
that creates the URL to lateissues-excel.pl from claims.pl.

Test Plan:

Before applying the patch:

1) Go to Serials > Claims (found on the left navigation bar of Serials)
2) Choose a vendor that has serials to claim (or create some late
serials for a vendor so that they will show up)
3) Click on the checkbox to the left of the "Vendor" table heading.
4) Click "Export selected items data" at the bottom of the page
5) Check the Apache error log.  Notice that you'll get a SQL error
   like the one in the message above.

Apply the patch.

Repeat Steps 1-4.

Note that you should now have a CSV file downloading rather than
getting a SQL error.

Signed-off-by: Kyle M Hall <kyle@bywatersolutions.com>
Signed-off-by: Jonathan Druart <jonathan.druart@biblibre.com>
Signed-off-by: Galen Charlton <gmc@esilibrary.com>
Bug 2774 - Path to theme is hard-coded in many places

This patch corrects more places in Koha where the path to the "prog"
theme is hard-coded in templates, CSS, and scripts.

Staff client home page:

Paths to the Koha logo background image and the module image sprite have
been corrected. Inactive and hover states of the module links
(circulation, patrons, etc) should look correct.

addbiblio.pl:

An <img> tag is replaced with a text link and an
additional CSS class. CSS uses an image-replacement technique to display
the image as before.

To test, open a blank or existing bibliographic record for editing.
Confirm that the "tag editor" icon displays correctly in two cases: 1)
tags linked to plugin editors and 2) tags linked to authorities. Both
should look correct and work correctly.

System preferences:

The system preferences editor appends a "loading" image to system
preference submit buttons when they are clicked. This patch changes
ajax.js to insert a <span> styled with a background-image instead.

To test, open system preferences and modify any preference. Submit the
change and confirm that the "loading" image appears correctly.

Background jobs:

Any place in Koha where a background job is used displays a progress
bar. This patch corrects the path in CSS to the progress bar image. To
test, perform an action which triggers the display of a progress bar.
For instance, batch modification of items. Confirm that the progress bar
image displays correctly.

blue.css:

I don't know if this is still used by anyone, but a couple of image
paths in this CSS file have been corrected.

Signed-off-by: Chris Cormack <chrisc@catalyst.net.nz>
Signed-off-by: Katrin Fischer <Katrin.Fischer.83@web.de>
Passes all tests, QA script and test plan.

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