(bug #3284) fix borrower deletion in independantbranches mode
authorNahuel ANGELINETTI <nahuel.angelinetti@biblibre.com>
Thu, 25 Jun 2009 10:57:35 +0000 (12:57 +0200)
committerHenri-Damien LAURENT <henridamien.laurent@biblibre.com>
Wed, 16 Sep 2009 21:19:40 +0000 (23:19 +0200)
This patch fix the checks deleting a borrower in independantbranches mode.
Now, we check the user and the librarian are from the same branch, else we deny the deletion(and disable the link to delete).

Signed-off-by: Galen Charlton <galen.charlton@liblime.com>
koha-tmpl/intranet-tmpl/prog/en/includes/members-toolbar.inc
members/deletemem.pl
members/moremember.pl

index ed490d2..eecf2f1 100644 (file)
@@ -57,7 +57,7 @@ function update_child() {
                var moremenu = [
                        { text: _("Renew Patron"),  onclick: { fn: confirm_reregistration } },
                        { text: _("Set Permissions"), url: "/cgi-bin/koha/members/member-flags.pl?member=<!-- TMPL_VAR NAME="borrowernumber" -->"<!-- TMPL_UNLESS NAME="CAN_user_permissions" -->, disabled: true<!-- /TMPL_UNLESS -->},
-                       { text: _("Delete"), onclick: { fn: confirm_deletion } },
+                       { text: _("Delete"), onclick: { fn: confirm_deletion}<!-- TMPL_UNLESS NAME="samebranch" -->, disabled: true<!-- /TMPL_IF --> },
                        { text: _("Update Child to Adult Patron") , onclick: { fn: update_child }<!-- TMPL_UNLESS NAME="is_child" -->, disabled: true<!-- /TMPL_UNLESS -->}
                ];
 
index e41157b..a1694f6 100755 (executable)
@@ -57,14 +57,15 @@ if ($bor->{category_type} eq "S") {
 }
 
 if (C4::Context->preference("IndependantBranches")) {
-    unless ($userenv->{flags} == 1){
-        unless ($userenv->{'branch'} eq $bor->{'branchcode'}){
-#           warn "user ".$userenv->{'branch'} ."borrower :". $bor->{'branchcode'};
+    my $userenv = C4::Context->userenv;
+    if ($userenv->{flags} != 1 && $bor->{'branchcode'}){
+        unless ($userenv->{branch} eq $bor->{'branchcode'}){
             print $input->redirect("/cgi-bin/koha/members/moremember.pl?borrowernumber=$member&error=CANT_DELETE_OTHERLIBRARY");
-            exit 1;
+            exit;
         }
     }
 }
+
 my $dbh = C4::Context->dbh;
 my $sth=$dbh->prepare("Select * from borrowers where guarantorid=?");
 $sth->execute($member);
index 941272d..1fcfa57 100755 (executable)
@@ -202,7 +202,9 @@ if ( C4::Context->preference("IndependantBranches") ) {
     unless ( $userenv->{flags} == 1 ) {
         $samebranch = ( $data->{'branchcode'} eq $userenv->{branch} );
     }
-    $samebranch = 1 if ( $userenv->{flags} == 1 );
+    $samebranch = 1 if ( $userenv->{flags} % 2 == 1 );
+}else{
+    $samebranch = 1;
 }
 my $branchdetail = GetBranchDetail( $data->{'branchcode'});
 $data->{'branchname'} = $branchdetail->{branchname};
@@ -353,6 +355,7 @@ if (C4::Context->preference('ExtendedPatronAttributes')) {
 $template->param(
     detailview => 1,
     AllowRenewalLimitOverride => C4::Context->preference("AllowRenewalLimitOverride"),
+<<<<<<< HEAD:members/moremember.pl
     DHTMLcalendar_dateformat=>C4::Dates->DHTMLcalendar(),
     roaddetails      => $roaddetails,
     borrowernumber   => $borrowernumber,
@@ -370,6 +373,27 @@ $template->param(
        is_child        => ($category_type eq 'C'),
        #                reserveloop     => \@reservedata,
        dateformat    => C4::Context->preference("dateformat"),
+=======
+    DHTMLcalendar_dateformat => C4::Dates->DHTMLcalendar(),
+    roaddetails     => $roaddetails,
+    borrowernumber  => $borrowernumber,
+    categoryname    => $data->{'description'},
+    reregistration  => $reregistration,
+    branch          => $branch,
+    totalprice      => sprintf("%.2f", $totalprice),
+    totaldue        => sprintf("%.2f", $total),
+    totaldue_raw    => $total,
+    issueloop       => \@issuedata,
+    overdues_exist  => $overdues_exist,
+    error           => $error,
+    $error          => 1,
+    StaffMember     => ($category_type eq 'S'),
+    is_child        => ($category_type eq 'C'),
+#   reserveloop     => \@reservedata,
+    dateformat      => C4::Context->preference("dateformat"),
+    "dateformat_" . (C4::Context->preference("dateformat") || '') => 1,
+    samebranch     => $samebranch,
+>>>>>>> 1be2c41... (bug #3284) fix borrower deletion in independantbranches mode:members/moremember.pl
 );
 
 output_html_with_http_headers $input, $cookie, $template->output;