use C4::Context;
use C4::Output;
use C4::Biblio;
-use C4::Date;
+use C4::Dates;
use C4::Koha;
use C4::Branch; # GetBranches
$template->param(branchloop => \@branch_loop,
authorised_values=>\@authorised_value_list,
- DHTMLcalendar_dateformat => get_date_format_string_for_DHTMLcalendar(),
+ DHTMLcalendar_dateformat => C4::Dates->DHTMLcalendar(),
minlocation => $minlocation,
maxlocation => $maxlocation,
location=>$location,
);
if ($uploadbarcodes && length($uploadbarcodes)>0){
my $dbh=C4::Context->dbh;
- my $date=format_date_in_iso($input->param('setdate'));
- $date = format_date_in_iso("today") unless $date;
+ my $date = format_date_in_iso($input->param('setdate')) || C4::Dates->today('iso');
# warn "$date";
my $strsth="update items set (datelastseen = $date) where items.barcode =?";
my $qupdate = $dbh->prepare($strsth);
- my $strsth="select * from issues, items where items.itemnumber=issues.itemnumber and items.barcode =? and issues.returndate is null";
+ $strsth="select * from issues, items where items.itemnumber=issues.itemnumber and items.barcode =? and issues.returndate is null";
my $qonloan = $dbh->prepare($strsth);
- my $strsth="select * from items where items.barcode =? and issues.wthdrawn=1";
+ $strsth="select * from items where items.barcode =? and issues.wthdrawn=1";
my $qwthdrawn = $dbh->prepare($strsth);
my @errorloop;
my $count=0;
$template->param(errorloop=>\@errorloop) if (@errorloop);
}else{
if ($markseen) {
- foreach my $field ($input->param) {
- if ($field =~ /SEEN-(.*)/) {
- &ModDateLastSeen($1);
- }
+ foreach ($input->param) {
+ /SEEN-(.+)/ and &ModDateLastSeen($1);
}
- my $res = GetItemsForInventory($minlocation,$maxlocation,$location,$datelastseen,$branchcode,$offset,$pagesize);
- $template->param(loop =>$res,
- nextoffset => ($offset+$pagesize),
- prevoffset => ($offset?$offset-$pagesize:0),
- );
}
- if ($op) {
+ if ($markseen or $op) {
my $res = GetItemsForInventory($minlocation,$maxlocation,$location,$datelastseen,$branchcode,$offset,$pagesize);
$template->param(loop =>$res,
nextoffset => ($offset+$pagesize),
use strict;
use CGI;
-use C4::Date;
+use C4::Dates;
use C4::Auth;
use C4::Context;
use C4::Output;
push( @results, $data );
$cnt++;
}
-
- # $sth->execute;
$sth->finish;
return ( $cnt, \@results );
}
#---- if primkey exists, it's a modify action, so read values to modify...
my $letter;
if ($code) {
- my $sth =
- $dbh->prepare("select * from letter where module=? and code=?");
+ my $sth = $dbh->prepare("select * from letter where module=? and code=?");
$sth->execute( $module, $code );
$letter = $sth->fetchrow_hashref;
$sth->finish;
my @SQLfieldname;
my %line = ( 'value' => "LibrarianFirstname", 'text' => 'LibrarianFirstname' );
push @SQLfieldname, \%line;
- my %line = ( 'value' => "LibrarianSurname", 'text' => 'LibrarianSurname' );
+ %line = ( 'value' => "LibrarianSurname", 'text' => 'LibrarianSurname' );
push @SQLfieldname, \%line;
- my %line = ( 'value' => "LibrarianEmailaddress", 'text' => 'LibrarianEmailaddress' );
+ %line = ( 'value' => "LibrarianEmailaddress", 'text' => 'LibrarianEmailaddress' );
push @SQLfieldname, \%line;
my $sth2 = $dbh->prepare("SHOW COLUMNS from branches");
$sth2->execute;
- my %line = ( 'value' => "", 'text' => '---BRANCHES---' );
+ %line = ( 'value' => "", 'text' => '---BRANCHES---' );
push @SQLfieldname, \%line;
while ( ( my $field ) = $sth2->fetchrow_array ) {
- my %line = ( 'value' => "branches." . $field, 'text' => "branches." . $field );
+ %line = ( 'value' => "branches." . $field, 'text' => "branches." . $field );
push @SQLfieldname, \%line;
}
# add acquisition specific tables
if ( index( $module, "acquisition" ) > 0 ) {
- my $sth2 = $dbh->prepare("SHOW COLUMNS from aqbooksellers");
+ $sth2 = $dbh->prepare("SHOW COLUMNS from aqbooksellers");
$sth2->execute;
- my %line = ( 'value' => "", 'text' => '---BOOKSELLERS---' );
+ %line = ( 'value' => "", 'text' => '---BOOKSELLERS---' );
push @SQLfieldname, \%line;
while ( ( my $field ) = $sth2->fetchrow_array ) {
- my %line = (
+ %line = (
'value' => "aqbooksellers." . $field,
'text' => "aqbooksellers." . $field
);
push @SQLfieldname, \%line;
}
- my $sth2 = $dbh->prepare("SHOW COLUMNS from aqorders");
+ $sth2 = $dbh->prepare("SHOW COLUMNS from aqorders");
$sth2->execute;
- my %line = ( 'value' => "", 'text' => '---ORDERS---' );
+ %line = ( 'value' => "", 'text' => '---ORDERS---' );
push @SQLfieldname, \%line;
while ( ( my $field ) = $sth2->fetchrow_array ) {
- my %line = (
+ %line = (
'value' => "aqorders." . $field,
'text' => "aqorders." . $field
);
# add issues specific tables
}
elsif ( index( $module, "issues" ) > 0 ) {
- my $sth2 = $dbh->prepare("SHOW COLUMNS from aqbooksellers");
+ $sth2 = $dbh->prepare("SHOW COLUMNS from aqbooksellers");
$sth2->execute;
- my %line = ( 'value' => "", 'text' => '---BOOKSELLERS---' );
+ %line = ( 'value' => "", 'text' => '---BOOKSELLERS---' );
push @SQLfieldname, \%line;
while ( ( my $field ) = $sth2->fetchrow_array ) {
- my %line = (
+ %line = (
'value' => "aqbooksellers." . $field,
'text' => "aqbooksellers." . $field
);
push @SQLfieldname, \%line;
}
- my $sth2 = $dbh->prepare("SHOW COLUMNS from serial");
+ $sth2 = $dbh->prepare("SHOW COLUMNS from serial");
$sth2->execute;
- my %line = ( 'value' => "", 'text' => '---SERIALS---' );
+ %line = ( 'value' => "", 'text' => '---SERIALS---' );
push @SQLfieldname, \%line;
while ( ( my $field ) = $sth2->fetchrow_array ) {
- my %line = ( 'value' => "serial." . $field, 'text' => "serial." . $field );
+ %line = ( 'value' => "serial." . $field, 'text' => "serial." . $field );
push @SQLfieldname, \%line;
}
- my $sth2 = $dbh->prepare("SHOW COLUMNS from subscription");
+ $sth2 = $dbh->prepare("SHOW COLUMNS from subscription");
$sth2->execute;
- my %line = ( 'value' => "", 'text' => '---SUBSCRIPTION---' );
+ %line = ( 'value' => "", 'text' => '---SUBSCRIPTION---' );
push @SQLfieldname, \%line;
while ( ( my $field ) = $sth2->fetchrow_array ) {
- my %line = (
+ %line = (
'value' => "subscription." . $field,
'text' => "subscription." . $field
);
push @SQLfieldname, \%line;
}
- my %line = ( 'value' => "", 'text' => '---Biblio---' );
- push @SQLfieldname, \%line;
- my %line = ('value' => "biblio.title",'text' => "Title");
- push @SQLfieldname, \%line;
- my %line = ('value' => "biblio.author",'text' => "Author");
- push @SQLfieldname, \%line;
- my %line = ('value' => "biblio.serial",'text' => "Serial");
+ %line = ('value' => "", 'text' => '---Biblio---' );
push @SQLfieldname, \%line;
+ foreach(qw(title author serial)) {
+ %line = ('value' => "biblio.$_", 'text' => ucfirst($_));
+ push @SQLfieldname, \%line;
+ }
}
else {
- my $sth2 = $dbh->prepare("SHOW COLUMNS from biblio");
+ $sth2 = $dbh->prepare("SHOW COLUMNS from biblio");
$sth2->execute;
- my %line = ( 'value' => "", 'text' => '---BIBLIO---' );
+ %line = ( 'value' => "", 'text' => '---BIBLIO---' );
push @SQLfieldname, \%line;
while ( ( my $field ) = $sth2->fetchrow_array ) {
my %line = ( 'value' => "biblio." . $field, 'text' => "biblio." . $field );
push @SQLfieldname, \%line;
}
- my $sth2 = $dbh->prepare("SHOW COLUMNS from biblioitems");
+ $sth2 = $dbh->prepare("SHOW COLUMNS from biblioitems");
$sth2->execute;
- my %line = ( 'value' => "", 'text' => '---BIBLIOITEMS---' );
+ %line = ( 'value' => "", 'text' => '---BIBLIOITEMS---' );
push @SQLfieldname, \%line;
while ( ( my $field ) = $sth2->fetchrow_array ) {
- my %line = (
+ %line = (
'value' => "biblioitems." . $field,
'text' => "biblioitems." . $field
);
push @SQLfieldname, \%line;
}
- my %line = ( 'value' => "", 'text' => '---ITEMS---' );
+ %line = ( 'value' => "", 'text' => '---ITEMS---' );
push @SQLfieldname, \%line;
- my %line = ( 'value' => "items.content", 'text' => 'items.content' );
+ %line = ( 'value' => "items.content", 'text' => 'items.content' );
push @SQLfieldname, \%line;
- my $sth2 = $dbh->prepare("SHOW COLUMNS from borrowers");
+ $sth2 = $dbh->prepare("SHOW COLUMNS from borrowers");
$sth2->execute;
- my %line = ( 'value' => "", 'text' => '---BORROWERS---' );
+ %line = ( 'value' => "", 'text' => '---BORROWERS---' );
push @SQLfieldname, \%line;
while ( ( my $field ) = $sth2->fetchrow_array ) {
- my %line = (
+ %line = (
'value' => "borrowers." . $field,
'text' => "borrowers." . $field
);
( $module ? $module : $letter->{module} ) => 1,
SQLfieldname => \@SQLfieldname,
);
-
- # END $OP eq ADD_FORM
################## ADD_VALIDATE ##################################
# called by add_form, used to insert/modify data in DB
}
$sth->finish;
print $input->redirect("letter.pl");
exit;
-
- # END $OP eq ADD_VALIDATE
################## DELETE_CONFIRM ##################################
# called by default form, used to confirm deletion of data in DB
}
$sth->execute($code);
my $data = $sth->fetchrow_hashref;
$sth->finish;
- $template->param( module => $data->{module} );
- $template->param( code => $code );
- $template->param( name => $data->{'name'} );
- $template->param( content => $data->{'content'} );
-
- # END $OP eq DELETE_CONFIRM
+ $template->param( code => $code );
+ foreach (qw(module name content)) {
+ $template->param( $_ => $data->{$_} );
+ }
################## DELETE_CONFIRMED ##################################
# called by delete_confirm, used to effectively confirm deletion of data in DB
}
$sth->finish;
print $input->redirect("/cgi-bin/koha/tools/letter.pl");
return;
-
- # END $OP eq DELETE_CONFIRMED
################## DEFAULT ##################################
}
else { # DEFAULT
$i++
)
{
- if ( $toggle ) {
- $toggle = 0;
- }
- else {
- $toggle = 1;
- }
+ $toggle = ($toggle) ? 0 : 1;
my %row_data;
$row_data{toggle} = $toggle;
- $row_data{module} = $results->[$i]{'module'};
- $row_data{code} = $results->[$i]{'code'};
- $row_data{name} = $results->[$i]{'name'};
+ foreach (qw(module code name)) {
+ $row_data{$_} = $results->[$i]{$_};
+ }
push( @loop_data, \%row_data );
}
$template->param( letter => \@loop_data );
my ( @directories, %errors );
$errors{'NOTZIP'} = 1 unless ( $uploadfilename =~ /\.zip$/i );
- $errors{'NOWRITETEMP'} = 1 unless ( -w "$dirname" );
- $errors{'NOWRITEDEST'} = 1 unless ( -w "$destdir" );
+ $errors{'NOWRITETEMP'} = 1 unless ( -w $dirname );
+ $errors{'NOWRITEDEST'} = 1 unless ( -w $destdir );
$errors{'EMPTYUPLOAD'} = 1 unless ( length( $uploadfile ) > 0 );
if ( %errors ) {
close $tfh;
- `unzip $tempfile -d $dirname`;
+ system("unzip $tempfile -d $dirname");
push @directories, "$dirname";
foreach $recursive_dir ( @directories ) {
opendir $dir, $recursive_dir;
while ( my $entry = readdir $dir ) {
- push @directories, "$recursive_dir/$entry" if ( -d "$recursive_dir/$entry" and $entry !~ /^\./ );
+ push @directories, "$recursive_dir/$entry" if ( -d "$recursive_dir/$entry" and $entry !~ /^\./ );
}
closedir $dir;
}
output_html_with_http_headers $input, $cookie, $template->output;
-
sub handle_dir {
my ( $dir ) = @_;
my ( %count );
$count{filenames} = ();
- return 0 unless ( -r "$dir/IDLINK.TXT" or -r "$dir/DATALINK.TXT" );
-
my $file = ( -r "$dir/IDLINK.TXT" ) ? "$dir/IDLINK.TXT" : "$dir/DATALINK.TXT";
-
- open $fh, $file or { print "Openning $dir/$filename failed!\n" and return 0 };
-
- while (my $line = <$fh>) {
- chomp $line;
-
- my ( $filename, $cardnumber );
-
- my $delim = ($line =~ /\t/) ? "\t" : ",";
-
- ($cardnumber, $filename) = split $delim, $line;
- $cardnumber =~ s/[\"\r\n]//g; # remove offensive characters
- $filename =~ s/[\"\r\n]//g;
-
- if ($cardnumber && $filename) {
- my $result = move ( "$dir/$filename", "$destdir/$cardnumber.jpg" );
- if ( $result ) {
- $count{count}++;
- push @{ $count{filenames} }, { source => $filename, dest => $cardnumber .".jpg" };
- }
- }
+ unless (open (FILE, $file)) {
+ print "Openning $dir/$file failed!\n";
+ return 0;
+ };
+
+ while (my $line = <FILE>) {
+ chomp $line;
+ my ( $filename, $cardnumber );
+ my $delim = ($line =~ /\t/) ? "\t" : ",";
+ ($cardnumber, $filename) = split $delim, $line;
+ $cardnumber =~ s/[\"\r\n]//g; # remove offensive characters
+ $filename =~ s/[\"\r\n]//g;
+
+ if ($cardnumber && $filename) {
+ my $result = move ( "$dir/$filename", "$destdir/$cardnumber.jpg" );
+ if ( $result ) {
+ $count{count}++;
+ push @{ $count{filenames} }, { source => $filename, dest => $cardnumber .".jpg" };
+ }
+ }
}
$count{source} = $dir;
$count{dest} = $destdir;
push @counts, \%count;
-
- close $fh;
-
+ close FILE;
return 1;
}