$searchstring=~ s/\'/\\\'/g;
my @data=split(' ',$searchstring);
my $count=@data;
- my $sth=$dbh->prepare("Select * from letter where (code like ?) order by code");
+ my $sth=$dbh->prepare("Select * from letter where (code like ?) order by module,code");
$sth->execute("$data[0]%");
my @results;
my $cnt=0;
my $offset=$input->param('offset');
my $script_name="/cgi-bin/koha/admin/letter.pl";
my $code=$input->param('code');
+my $module = $input->param('module');
my $pagesize=20;
my $op = $input->param('op');
$searchfield=~ s/\,//g;
#---- 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 code=?");
- $sth->execute($code);
+ my $sth=$dbh->prepare("select * from letter where module=? and code=?");
+ $sth->execute($module,$code);
$letter=$sth->fetchrow_hashref;
$sth->finish;
}
# build field list
my @SQLfieldname;
+ my %line = ('value' => "LibrarianFirstname", 'text' => 'LibrarianFirstname');
+ push @SQLfieldname, \%line;
+ my %line = ('value' => "LibrarianSurname", 'text' => 'LibrarianSurname');
+ push @SQLfieldname, \%line;
+ my %line = ('value' => "LibrarianEmailaddress", 'text' => 'LibrarianEmailaddress');
+ push @SQLfieldname, \%line;
+ my $sth2=$dbh->prepare("SHOW COLUMNS from branches");
+ $sth2->execute;
+ my %line = ('value' => "", 'text' => '---BRANCHES---');
+ push @SQLfieldname, \%line;
+ while ((my $field) = $sth2->fetchrow_array) {
+ my %line = ('value' => "branches.".$field, 'text' => "branches.".$field);
+ push @SQLfieldname, \%line;
+ }
my $sth2=$dbh->prepare("SHOW COLUMNS from biblio");
$sth2->execute;
my %line = ('value' => "", 'text' => '---BIBLIO---');
+
push @SQLfieldname, \%line;
while ((my $field) = $sth2->fetchrow_array) {
+ # note : %line is redefined, otherwise \%line contains the same value for every entry of the list
my %line = ('value' => "biblio.".$field, 'text' => "biblio.".$field);
- warn "$line{value}";
push @SQLfieldname, \%line;
}
my $sth2=$dbh->prepare("SHOW COLUMNS from biblioitems");
push @SQLfieldname, \%line;
while ((my $field) = $sth2->fetchrow_array) {
my %line = ('value' => "biblioitems.".$field, 'text' => "biblioitems.".$field);
- warn "$line{value}";
push @SQLfieldname, \%line;
}
my %line = ('value' => "", 'text' => '---ITEMS---');
push @SQLfieldname, \%line;
while ((my $field) = $sth2->fetchrow_array) {
my %line = ('value' => "borrowers.".$field, 'text' => "borrowers.".$field);
- warn "$line{value}";
push @SQLfieldname, \%line;
}
if ($code) {
} else {
$template->param(adding => 1);
}
- $template->param(name => $letter->{name},
+ $template->param(name => $letter->{name},title => $letter->{title},
content => $letter->{content},
+ $letter->{module} => 1,
SQLfieldname => \@SQLfieldname,);
# END $OP eq ADD_FORM
################## ADD_VALIDATE ##################################
# called by add_form, used to insert/modify data in DB
} elsif ($op eq 'add_validate') {
my $dbh = C4::Context->dbh;
- my $sth=$dbh->prepare("replace letter (code,name,content) values (?,?,?)");
- $sth->execute($input->param('code'),$input->param('name'),$input->param('content'));
+ my $sth=$dbh->prepare("replace letter (module,code,name,title,content) values (?,?,?,?,?)");
+ $sth->execute($input->param('module'),$input->param('code'),$input->param('name'),$input->param('title'),$input->param('content'));
$sth->finish;
print $input->redirect("letter.pl");
exit;
$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'});
} elsif ($op eq 'delete_confirmed') {
my $dbh = C4::Context->dbh;
my $code=uc($input->param('code'));
- my $sth=$dbh->prepare("delete from letter where code=?");
- $sth->execute($code);
+ my $module=$input->param('module');
+ my $sth=$dbh->prepare("delete from letter where module=? and code=?");
+ $sth->execute($module,$code);
$sth->finish;
print $input->redirect("letter.pl");
return;
}
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'};
push(@loop_data, \%row_data);