|
Lines 122-131
if it is an order from an existing suggestion : the id of this suggestion.
Link Here
|
| 122 |
use strict; |
122 |
use strict; |
| 123 |
use warnings; |
123 |
use warnings; |
| 124 |
use CGI; |
124 |
use CGI; |
| 125 |
use C4::Auth; # get_template_and_user |
125 |
use C4::Auth; # get_template_and_user |
| 126 |
use C4::Acquisition; # NewOrder DelOrder ModOrder |
126 |
use C4::Acquisition; # NewOrder DelOrder ModOrder |
| 127 |
use C4::Suggestions; # ModStatus |
127 |
use C4::Suggestions; # ModStatus |
| 128 |
use C4::Biblio; # AddBiblio TransformKohaToMarc |
128 |
use C4::Biblio; # AddBiblio TransformKohaToMarc |
|
|
129 |
use C4::Bookseller qw/GetBookSellerFromId/; |
| 129 |
use C4::Items; |
130 |
use C4::Items; |
| 130 |
use C4::Output; |
131 |
use C4::Output; |
| 131 |
|
132 |
|
|
Lines 193-233
my $user = $input->remote_user;
Link Here
|
| 193 |
# delete biblio if delbiblio has been set to 1 by the librarian |
194 |
# delete biblio if delbiblio has been set to 1 by the librarian |
| 194 |
my $bibitemnum; |
195 |
my $bibitemnum; |
| 195 |
if ( $orderinfo->{quantity} ne '0' ) { |
196 |
if ( $orderinfo->{quantity} ne '0' ) { |
|
|
197 |
|
| 198 |
# Getting bookseller's name |
| 199 |
my $supplierreference; |
| 200 |
if ($$orderinfo{booksellerid}) { |
| 201 |
my $bookseller = GetBookSellerFromId($$orderinfo{booksellerid}); |
| 202 |
$supplierreference = $bookseller->{name}; |
| 203 |
} |
| 204 |
|
| 205 |
# Do we have to add order informations to the marc record? |
| 206 |
my ($ordertag, $ordersubtag) = GetMarcFromKohaField('aqorders.ordernumber', 'ACQ'); |
| 207 |
my $record; |
| 208 |
my $existingbiblio; # Was the order made on an existing biblio? |
| 209 |
my $ordermodif; # Is this an order modification? |
| 210 |
|
| 196 |
#TODO:check to see if biblio exists |
211 |
#TODO:check to see if biblio exists |
| 197 |
unless ( $$orderinfo{biblionumber} ) { |
212 |
unless ( $$orderinfo{biblionumber} ) { |
| 198 |
#if it doesnt create it |
213 |
#if it doesnt create it |
| 199 |
my $record = TransformKohaToMarc( |
214 |
my $tmprecord = TransformKohaToMarc( |
| 200 |
{ |
215 |
{ "biblio.title" => "$$orderinfo{title}", |
| 201 |
"biblio.title" => "$$orderinfo{title}", |
216 |
"biblio.author" => $$orderinfo{author} ? $$orderinfo{author} : "", |
| 202 |
"biblio.author" => $$orderinfo{author} ? $$orderinfo{author} : "", |
217 |
"biblio.seriestitle" => $$orderinfo{series} ? $$orderinfo{series} : "", |
| 203 |
"biblio.seriestitle" => $$orderinfo{series} ? $$orderinfo{series} : "", |
218 |
"biblioitems.isbn" => $$orderinfo{isbn} ? $$orderinfo{isbn} : "", |
| 204 |
"biblioitems.isbn" => $$orderinfo{isbn} ? $$orderinfo{isbn} : "", |
219 |
"biblioitems.ean" => $$orderinfo{ean} ? $$orderinfo{ean} : "", |
| 205 |
"biblioitems.publishercode" => $$orderinfo{publishercode} ? $$orderinfo{publishercode} : "", |
220 |
"biblioitems.publishercode" => $$orderinfo{publishercode} ? $$orderinfo{publishercode} : "", |
| 206 |
"biblioitems.publicationyear" => $$orderinfo{publicationyear} ? $$orderinfo{publicationyear}: "", |
221 |
"biblioitems.publicationyear" => $$orderinfo{publicationyear} ? $$orderinfo{publicationyear} : "", |
| 207 |
"biblio.copyrightdate" => $$orderinfo{publicationyear} ? $$orderinfo{publicationyear}: "", |
222 |
"biblioitems.itemtype" => $$orderinfo{itemtype} ? $$orderinfo{itemtype} : "", |
| 208 |
"biblioitems.itemtype" => $$orderinfo{itemtype} ? $$orderinfo{itemtype} : "", |
223 |
"aqorders.branchcode" => $$orderinfo{branchcode} ? $$orderinfo{branchcode} : "", |
| 209 |
}); |
224 |
"aqorders.quantity" => $$orderinfo{quantity} ? $$orderinfo{quantity} : "", |
|
|
225 |
"aqorders.listprice" => $$orderinfo{listprice} ? $$orderinfo{listprice} : "", |
| 226 |
"aqorders.uncertainprice" => $$orderinfo{uncertainprice} ? $$orderinfo{uncertainprice} : "", |
| 227 |
"aqorders.rrp" => $$orderinfo{rrp} ? $$orderinfo{rrp} : "", |
| 228 |
"aqorders.ecost" => $$orderinfo{ecost} ? $$orderinfo{ecost} : "", |
| 229 |
"aqorders.notes" => $$orderinfo{notes} ? $$orderinfo{notes} : "", |
| 230 |
"aqorders.supplierreference" => $supplierreference ? $supplierreference : "", |
| 231 |
"aqorders.sort1" => $$orderinfo{sort1} ? $$orderinfo{sort1} : "", |
| 232 |
"aqorders.sort2" => $$orderinfo{sort2} ? $$orderinfo{sort2} : "" |
| 233 |
} |
| 234 |
); |
| 210 |
|
235 |
|
| 211 |
# create the record in catalogue, with framework '' |
236 |
# create the record in catalogue, with framework '' |
| 212 |
my ($biblionumber,$bibitemnum) = AddBiblio($record,''); |
237 |
my ( $biblionumber, $bibitemnum ) = AddBiblio( $tmprecord, '' ); |
|
|
238 |
|
| 213 |
# change suggestion status if applicable |
239 |
# change suggestion status if applicable |
| 214 |
if ($$orderinfo{suggestionid}) { |
240 |
if ($$orderinfo{suggestionid}) { |
| 215 |
ModSuggestion( {suggestionid=>$$orderinfo{suggestionid}, STATUS=>'ORDERED', biblionumber=>$biblionumber} ); |
241 |
ModSuggestion( {suggestionid=>$$orderinfo{suggestionid}, STATUS=>'ORDERED', biblionumber=>$biblionumber} ); |
| 216 |
} |
242 |
} |
| 217 |
$orderinfo->{biblioitemnumber}=$bibitemnum; |
243 |
$orderinfo->{biblioitemnumber} = $bibitemnum; |
| 218 |
$orderinfo->{biblionumber}=$biblionumber; |
244 |
$orderinfo->{biblionumber} = $biblionumber; |
|
|
245 |
} else { |
| 246 |
$existingbiblio = 1; |
| 219 |
} |
247 |
} |
| 220 |
|
248 |
|
| 221 |
# if we already have $ordernumber, then it's an ordermodif |
249 |
# Getting record |
| 222 |
if ($$orderinfo{ordernumber}) { |
250 |
$record = GetMarcBiblio($$orderinfo{biblionumber}); |
| 223 |
ModOrder( $orderinfo); |
251 |
|
| 224 |
} |
252 |
|
| 225 |
else { # else, it's a new line |
253 |
|
|
|
254 |
# if we already have $ordernumber, then it's an ordermodif |
| 255 |
if ( $$orderinfo{ordernumber} ) { |
| 256 |
ModOrder($orderinfo); |
| 257 |
$ordermodif = 1; |
| 258 |
|
| 259 |
} else { # else, it's a new line |
| 226 |
@$orderinfo{qw(basketno ordernumber )} = NewOrder($orderinfo); |
260 |
@$orderinfo{qw(basketno ordernumber )} = NewOrder($orderinfo); |
|
|
261 |
|
| 262 |
# We have to add the ordernumber in the designated subfield |
| 263 |
if ($ordertag && $record && !$ordermodif) { |
| 264 |
# To which field do we add it : to the one with currently no ordernumber |
| 265 |
foreach ($record->field($ordertag)) { |
| 266 |
if (!$_->subfield($ordersubtag)) { |
| 267 |
$_->update($ordersubtag, $$orderinfo{ordernumber}); |
| 268 |
} |
| 269 |
} |
| 270 |
ModBiblio($record, $$orderinfo{biblionumber}, 'ACQ'); |
| 271 |
} |
| 272 |
|
| 273 |
|
| 274 |
} |
| 275 |
|
| 276 |
if ($record) { |
| 277 |
|
| 278 |
# If we have to add order infos to the marc record |
| 279 |
if ($ordertag) { |
| 280 |
|
| 281 |
# If the order was made on an existing biblio and it is not a modification, we add the field |
| 282 |
$record->insert_fields_ordered(new MARC::Field($ordertag, '', '', $ordersubtag => $$orderinfo{ordernumber})) if (!$ordermodif && $existingbiblio); |
| 283 |
|
| 284 |
foreach ($record->field($ordertag)) { |
| 285 |
# Looking for the matching one |
| 286 |
if ($_->subfield($ordersubtag) eq $$orderinfo{ordernumber}) { |
| 287 |
|
| 288 |
# Replacing or creating subfields |
| 289 |
my ($t, $st); |
| 290 |
for my $tablefield (qw/branchcode quantity listprice uncertainprice rrp ecost notes supplierreference sort1 sort2/) { |
| 291 |
($t, $st) = GetMarcFromKohaField("aqorders.$tablefield", 'ACQ'); |
| 292 |
$_->update($st, $$orderinfo{$tablefield}) if ($$orderinfo{$tablefield} and $st); |
| 293 |
} |
| 294 |
ModBiblio($record, $$orderinfo{biblionumber}, 'ACQ'); |
| 295 |
} |
| 296 |
} |
| 297 |
|
| 298 |
} |
| 299 |
|
| 227 |
} |
300 |
} |
| 228 |
|
301 |
|
| 229 |
# now, add items if applicable |
302 |
|
| 230 |
if (C4::Context->preference('AcqCreateItem') eq 'ordering') { |
303 |
# now, add items if applicable |
|
|
304 |
if ( C4::Context->preference('AcqCreateItem') eq 'ordering' ) { |
| 231 |
|
305 |
|
| 232 |
my @tags = $input->param('tag'); |
306 |
my @tags = $input->param('tag'); |
| 233 |
my @subfields = $input->param('subfield'); |
307 |
my @subfields = $input->param('subfield'); |