Adding a parameter to allow acces to people with management flag
[koha.git] / admin / issuingrules.pl
index 0e27bf5..c27dccb 100755 (executable)
@@ -43,7 +43,7 @@ my ($template, $loggedinuser, $cookie)
                              query => $input,
                              type => "intranet",
                              authnotrequired => 0,
-                            flagsrequired => {parameters => 1},
+                            flagsrequired => {parameters => 1, management => 1},
                              debug => 1,
                              });
 # save the values entered
@@ -66,7 +66,7 @@ if ($op eq 'save') {
                        my $cat = $3; # item type
                        my $data=$input->param($key);
                        my ($issuelength,$maxissueqty)=split(',',$data);
-                       if ($maxissueqty >0) {
+#                      if ($maxissueqty >0) {
                                $sth_search->execute($br,$bor,$cat);
                                my $res = $sth_search->fetchrow_hashref();
                                if ($res->{total}) {
@@ -74,9 +74,9 @@ if ($op eq 'save') {
                                } else {
                                        $sth_Iinsert->execute($br,$bor,$cat,$maxissueqty,$issuelength);
                                }
-                       } else {
-                               $sth_Idelete->execute($br,$bor,$cat);
-                       }
+#                      } else {
+#                              $sth_Idelete->execute($br,$bor,$cat);
+#                      }
                }
                # FINES
                if ($key =~ /F-(.*)-(.*)\.(.*)/) {
@@ -85,7 +85,7 @@ if ($op eq 'save') {
                        my $cat = $3; # item type
                        my $data=$input->param($key);
                        my ($fine,$firstremind,$chargeperiod)=split(',',$data);
-                       if ($fine >0) {
+#                      if ($fine >0) {
                                $sth_search->execute($br,$bor,$cat);
                                my $res = $sth_search->fetchrow_hashref();
                                if ($res->{total}) {
@@ -93,9 +93,9 @@ if ($op eq 'save') {
                                } else {
                                        $sth_Finsert->execute($br,$bor,$cat,$fine,$firstremind,$chargeperiod);
                                }
-                       } else {
-                               $sth_Fdelete->execute($br,$bor,$cat);
-                       }
+#                      } else {
+#                              $sth_Fdelete->execute($br,$bor,$cat);
+#                      }
                }
        }
 
@@ -131,7 +131,7 @@ $sth->finish;
 $sth=$dbh->prepare("Select description,itemtype from itemtypes order by description");
 $sth->execute;
 # $i=0;
-my $toggle="white";
+my $toggle= 1;
 my @row_loop;
 my @itemtypes;
 while (my $row=$sth->fetchrow_hashref){
@@ -145,10 +145,10 @@ push @itemtypes,\$line;
 foreach my $data (@itemtypes) {
        my @trow2;
        my @cell_loop;
-       if ( $toggle eq 'white' ) {
-               $toggle = '#ffffcc';
+       if ( $toggle eq 1 ) {
+               $toggle = 0;
        } else {
-               $toggle = 'white';
+               $toggle = 1;
        }
        for (my $i=0;$i<=$#trow3;$i++){
                my $sth2=$dbh->prepare("select * from issuingrules where branchcode=? and categorycode=? and itemtype=?");
@@ -159,15 +159,15 @@ foreach my $data (@itemtypes) {
                my $maxissueqty = $dat->{'maxissueqty'}+0;
                my $issuelength = $dat->{'issuelength'}+0;
                my $finesvalue;
-               $finesvalue= "$fine,$dat->{'firstremind'},$dat->{'chargeperiod'}" if $fine>0;
+               $finesvalue= "$fine,$dat->{'firstremind'},$dat->{'chargeperiod'}" if $fine+$dat->{'firstremind'}+$dat->{'chargeperiod'}>0;
                my $issuingvalue;
-               if ($maxissueqty>0) {
-                   $issuingvalue = "$issuelength,$maxissueqty" ;
-               }
-               else {          
-                   $issuingvalue = "$issuelength, 5";
-                   $maxissueqty = 5;
-               }
+#              if ($maxissueqty>0) {
+                   $issuingvalue = "$issuelength,$maxissueqty" if $issuelength+$maxissueqty>0;
+#              }
+#              else {          
+#                  $issuingvalue = "$issuelength, 5";
+#                  $maxissueqty = 5;
+#              }
                my %row = (finesname=> "F-$branch-$trow3[$i].$$data->{'itemtype'}",
                                        finesvalue => $finesvalue,
                                        issuingname => "I-$branch-$trow3[$i].$$data->{itemtype}",