Bugfix: Adding error trapping for missing or invalid branch code
authorChris Nighswonger <cnighswonger@foundations.edu>
Thu, 4 Feb 2010 15:20:46 +0000 (10:20 -0500)
committerGalen Charlton <gmcharlt@gmail.com>
Thu, 4 Feb 2010 15:28:40 +0000 (10:28 -0500)
This patch adds code to trap, log, and return an intelligent message to the user
when a missing or invalid branch code is passed in. This condition can occur if
the user is logged in as the kohaadmin or the user has multiple instances of the staff
client open and has switched users in some instance.

Signed-off-by: Galen Charlton <gmcharlt@gmail.com>
koha-tmpl/intranet-tmpl/prog/en/includes/error-messages.inc
patroncards/edit-batch.pl

index 0d1c43f..7eb0fe8 100644 (file)
@@ -79,6 +79,8 @@ window.onload=function(){
         An unsupported operation was attempted<!-- TMPL_IF NAME="element_id" --> on <!-- TMPL_VAR NAME="card_element" --> <!-- TMPL_VAR NAME="element_id" --><!-- /TMPL_IF -->. Please have your system administrator check the error log for details.
         <!-- TMPL_ELSIF NAME="202" -->
         An error has occurred. Please ask your system administrator to check the error log for more details.
+        <!-- TMPL_ELSIF NAME="203" -->
+        A non-existent or invalid branch code was supplied. Please <a href="/cgi-bin/koha/circ/selectbranchprinter.pl">verify</a> that you have a branch selected.
         <!-- TMPL_ELSIF NAME="301" -->
         An error has occurred while attempting to upload the image file. Please ask you system administrator to check the error log for more details.
         <!-- TMPL_ELSIF NAME="302" -->
index 9c3a57d..47f0896 100755 (executable)
@@ -105,10 +105,15 @@ elsif ($op eq 'de_duplicate') {
         exit;
     }
 }
-elsif ($op = 'edit') {
+elsif ($op eq 'edit') {
     $batch = C4::Patroncards::Batch->retrieve(batch_id => $batch_id);
 }
 elsif ($op eq 'new') {
+    if (!$branch_code) {
+        warn sprintf('Batch edit interface called with an invalid/non-existent branch code: %s',$branch_code ? $branch_code : 'NULL');
+        print $cgi->redirect("manage.pl?card_element=batch&error=203") if $err;
+        exit;
+    }
     $batch = C4::Patroncards::Batch->new(branch_code => $branch_code);
     $batch_id = $batch->get_attr('batch_id');
 }