use strict;
use C4::Context;
use C4::Output;
+
+use MIME::Base64 qw(encode_base64 decode_base64);
+use Encode qw(encode decode);
+
use vars qw($VERSION @ISA @EXPORT $DEBUG);
BEGIN {
&GetKohaAuthorisedValues
&GetAuthValCode
&GetManagedTagSubfields
+ &str_to_base64
+ &base64_to_str
$DEBUG
);
return $data;
}
+=head2 str_to_base64
+
+=over 4
+
+my $base64 = str_to_base64($string_containing_unicode);
+
+=back
+
+Get a Base64 version of a string that is in UTF-8. This
+function can be used to convert an arbitrary coded value
+(like a branch code) into a form that can be safely concatenated
+with similarly encoded values for a HTML form input name, as
+in admin/issuingrules.pl.
+
+=cut
+
+sub str_to_base64 {
+ my $in = shift;
+ return encode_base64(encode("UTF-8", $in), '');
+}
+
+=head2 base64_to_str
+
+=over 4
+
+my $base64 = base64_to_str($string_containing_unicode);
+
+=back
+
+Converse of C<str_to_base64()>.
+
+=cut
+
+sub base64_to_str {
+ my $in = shift;
+ return decode("UTF-8", decode_base64($in));
+}
+
1;
__END__
foreach my $key (@names){
# FINES
- if ($key =~ /F-(.*)-(.*)\.(.*)/) {
- my $br = $1; # branch
- my $bor = $2; # borrower category
- my $cat = $3; # item type
+ if ($key =~ /F-(.*)-(.*)-(.*)/) {
+ my $br = base64_to_str($1); # branch
+ my $bor = base64_to_str($2); # borrower category
+ my $cat = base64_to_str($3); # item type
my $data=$input->param($key);
my ($fine,$firstremind,$chargeperiod)=split(',',$data);
$bor="*" unless ($bor);
$fine =~ s/\.*0*$//g;
my $finesvalue;
$finesvalue= "$fine,$dat->{'firstremind'},$dat->{'chargeperiod'}" if $fine ne '';
- my %row = (finesname=> "F-$branch-$trow3[$i].$$data->{'itemtype'}",
+ my $finesname = join("-", "F", map { str_to_base64($_) } ($branch, $trow3[$i], $$data->{'itemtype'}));
+ my %row = (finesname=> $finesname,
finesvalue => $finesvalue,
toggle => $toggle,
);
my $sth_Idelete=$dbh->prepare("DELETE FROM issuingrules WHERE branchcode=? AND categorycode=? AND itemtype=?");
foreach my $key (@names){
# ISSUES
- if ($key =~ /I-(.*)-(.*)\.(.*)/) {
- my $br = $1; # branch
- my $bor = $2; # borrower category
- my $cat = $3; # item type
+ if ($key =~ /I-(.*)-(.*)-(.*)/) {
+ my $br = base64_to_str($1); # branch
+ my $bor = base64_to_str($2); # borrower category
+ my $cat = base64_to_str($3); # item type
my $data=$input->param($key);
my ($issuelength,$maxissueqty,$rentaldiscount)=split(',',$data);
if ($maxissueqty) {
my $issuelength = $dat->{'issuelength'};
my $issuingvalue;
$issuingvalue = "$issuelength,$maxissueqty" if $maxissueqty ne '';
- my %row = (issuingname => "I-$branch-$trow3[$i].$$data->{itemtype}",
+ my $issuingname = join("-", "I", map { str_to_base64($_) } ($branch, $trow3[$i], $$data->{itemtype}) );
+ my %row = (issuingname => $issuingname,
issuingvalue => $issuingvalue,
toggle => $toggle,
);