Lines 27-40
use C4::Context;
Link Here
|
27 |
use C4::Koha; |
27 |
use C4::Koha; |
28 |
use C4::Output; |
28 |
use C4::Output; |
29 |
|
29 |
|
30 |
|
|
|
31 |
sub AuthorizedValuesForCategory { |
30 |
sub AuthorizedValuesForCategory { |
32 |
my ($searchstring) = shift or return; |
31 |
my ($searchstring) = shift or return; |
33 |
my $dbh = C4::Context->dbh; |
32 |
my $dbh = C4::Context->dbh; |
34 |
$searchstring=~ s/\'/\\\'/g; |
33 |
$searchstring=~ s/\'/\\\'/g; |
35 |
my @data=split(' ',$searchstring); |
34 |
my @data=split(' ',$searchstring); |
36 |
my $sth=$dbh->prepare(' |
35 |
my $sth=$dbh->prepare(' |
37 |
SELECT id, category, authorised_value, lib, lib_opac, imageurl |
36 |
#SELECT id, category, authorised_value, lib, lib_opac, imageurl |
|
|
37 |
SELECT * |
38 |
FROM authorised_values |
38 |
FROM authorised_values |
39 |
WHERE (category = ?) |
39 |
WHERE (category = ?) |
40 |
ORDER BY category, authorised_value |
40 |
ORDER BY category, authorised_value |
Lines 114-120
if ($op eq 'add_form') {
Link Here
|
114 |
offset => $offset, |
114 |
offset => $offset, |
115 |
branches_loop => \@branches_loop, |
115 |
branches_loop => \@branches_loop, |
116 |
); |
116 |
); |
117 |
|
117 |
##################################### |
|
|
118 |
# Add borrower's categories select list, in case we'd like to bind a sort1 criteria to a category |
119 |
my @typeloop; |
120 |
my $no_categories = 1; |
121 |
foreach (qw(C A S P I X)) { |
122 |
my $action="WHERE category_type=?"; |
123 |
my ($categories,$labels) = C4::Members::GetborCatFromCatType($_,$action); |
124 |
if(scalar(@$categories) > 0){ $no_categories = 0; } |
125 |
my @categoryloop; |
126 |
foreach my $cat (@$categories){ |
127 |
push @categoryloop,{ |
128 |
'categorycode' => $cat, |
129 |
'categoryname' => $labels->{$cat}, |
130 |
}; |
131 |
} |
132 |
my %typehash; |
133 |
$typehash{'typename'}=$_; |
134 |
my $typedescription = "typename_".$typehash{'typename'}; |
135 |
$typehash{'categoryloop'}=\@categoryloop; |
136 |
push @typeloop,{ |
137 |
'typename' => $_, |
138 |
$typedescription => 1, |
139 |
'categoryloop' => \@categoryloop |
140 |
}; |
141 |
} |
142 |
$template->param('typeloop' => \@typeloop, |
143 |
no_categories => $no_categories); |
144 |
|
118 |
################## ADD_VALIDATE ################################## |
145 |
################## ADD_VALIDATE ################################## |
119 |
# called by add_form, used to insert/modify data in DB |
146 |
# called by add_form, used to insert/modify data in DB |
120 |
} elsif ($op eq 'add_validate') { |
147 |
} elsif ($op eq 'add_validate') { |
Lines 141-153
if ($op eq 'add_form') {
Link Here
|
141 |
authorised_value = ?, |
168 |
authorised_value = ?, |
142 |
lib = ?, |
169 |
lib = ?, |
143 |
lib_opac = ?, |
170 |
lib_opac = ?, |
|
|
171 |
linked_with = ?, |
144 |
imageurl = ? |
172 |
imageurl = ? |
145 |
WHERE id=?' ); |
173 |
WHERE id=?' ); |
146 |
my $lib = $input->param('lib'); |
174 |
my $lib = $input->param('lib'); |
147 |
my $lib_opac = $input->param('lib_opac'); |
175 |
my $lib_opac = $input->param('lib_opac'); |
148 |
undef $lib if ($lib eq ""); # to insert NULL instead of a blank string |
176 |
undef $lib if ($lib eq ""); # to insert NULL instead of a blank string |
149 |
undef $lib_opac if ($lib_opac eq ""); # to insert NULL instead of a blank string |
177 |
undef $lib_opac if ($lib_opac eq ""); # to insert NULL instead of a blank string |
150 |
$sth->execute($new_category, $new_authorised_value, $lib, $lib_opac, $imageurl, $id); |
178 |
my $linked_with = $input->param('categorycode'); |
|
|
179 |
$sth->execute($new_category, $new_authorised_value, $lib, $lib_opac, $linked_with, $imageurl, $id); |
151 |
if ( @branches ) { |
180 |
if ( @branches ) { |
152 |
$sth = $dbh->prepare("DELETE FROM authorised_values_branches WHERE av_id = ?"); |
181 |
$sth = $dbh->prepare("DELETE FROM authorised_values_branches WHERE av_id = ?"); |
153 |
$sth->execute( $id ); |
182 |
$sth->execute( $id ); |
Lines 173-185
if ($op eq 'add_form') {
Link Here
|
173 |
($duplicate_entry) = $sth->fetchrow_array(); |
202 |
($duplicate_entry) = $sth->fetchrow_array(); |
174 |
unless ( $duplicate_entry ) { |
203 |
unless ( $duplicate_entry ) { |
175 |
my $sth=$dbh->prepare( 'INSERT INTO authorised_values |
204 |
my $sth=$dbh->prepare( 'INSERT INTO authorised_values |
176 |
( category, authorised_value, lib, lib_opac, imageurl ) |
205 |
( category, authorised_value, lib, lib_opac, linked_with, imageurl ) |
177 |
values (?, ?, ?, ?, ?)' ); |
206 |
values (?, ?, ?, ?, ?, ?)' ); |
178 |
my $lib = $input->param('lib'); |
207 |
my $lib = $input->param('lib'); |
179 |
my $lib_opac = $input->param('lib_opac'); |
208 |
my $lib_opac = $input->param('lib_opac'); |
180 |
undef $lib if ($lib eq ""); # to insert NULL instead of a blank string |
209 |
undef $lib if ($lib eq ""); # to insert NULL instead of a blank string |
181 |
undef $lib_opac if ($lib_opac eq ""); # to insert NULL instead of a blank string |
210 |
undef $lib_opac if ($lib_opac eq ""); # to insert NULL instead of a blank string |
182 |
$sth->execute( $new_category, $new_authorised_value, $lib, $lib_opac, $imageurl ); |
211 |
my $linked_with = $input->param('categorycode'); |
|
|
212 |
$sth->execute( $new_category, $new_authorised_value, $lib, $lib_opac, $linked_with, $imageurl ); |
183 |
$id = $dbh->{'mysql_insertid'}; |
213 |
$id = $dbh->{'mysql_insertid'}; |
184 |
if ( @branches ) { |
214 |
if ( @branches ) { |
185 |
$sth = $dbh->prepare( |
215 |
$sth = $dbh->prepare( |
Lines 280-285
sub default_form {
Link Here
|
280 |
$row_data{authorised_value} = $results->[$i]{'authorised_value'}; |
310 |
$row_data{authorised_value} = $results->[$i]{'authorised_value'}; |
281 |
$row_data{lib} = $results->[$i]{'lib'}; |
311 |
$row_data{lib} = $results->[$i]{'lib'}; |
282 |
$row_data{lib_opac} = $results->[$i]{'lib_opac'}; |
312 |
$row_data{lib_opac} = $results->[$i]{'lib_opac'}; |
|
|
313 |
$row_data{linked_with} = C4::Members::GetBorrowercategory($results->[$i]{'linked_with'})->{description} if $results->[$i]{'linked_with'} ; |
283 |
$row_data{imageurl} = getitemtypeimagelocation( 'intranet', $results->[$i]{'imageurl'} ); |
314 |
$row_data{imageurl} = getitemtypeimagelocation( 'intranet', $results->[$i]{'imageurl'} ); |
284 |
$row_data{edit} = "$script_name?op=add_form&id=".$results->[$i]{'id'}."&offset=$offset"; |
315 |
$row_data{edit} = "$script_name?op=add_form&id=".$results->[$i]{'id'}."&offset=$offset"; |
285 |
$row_data{delete} = "$script_name?op=delete_confirm&searchfield=$searchfield&id=".$results->[$i]{'id'}."&offset=$offset"; |
316 |
$row_data{delete} = "$script_name?op=delete_confirm&searchfield=$searchfield&id=".$results->[$i]{'id'}."&offset=$offset"; |