Lines 19-24
package C4::Acquisition;
Link Here
|
19 |
|
19 |
|
20 |
|
20 |
|
21 |
use Modern::Perl; |
21 |
use Modern::Perl; |
|
|
22 |
use JSON qw(to_json); |
22 |
use Carp; |
23 |
use Carp; |
23 |
use C4::Context; |
24 |
use C4::Context; |
24 |
use C4::Debug; |
25 |
use C4::Debug; |
Lines 26-31
use C4::Suggestions;
Link Here
|
26 |
use C4::Biblio; |
27 |
use C4::Biblio; |
27 |
use C4::Contract; |
28 |
use C4::Contract; |
28 |
use C4::Debug; |
29 |
use C4::Debug; |
|
|
30 |
use C4::Log qw(logaction); |
29 |
use C4::Templates qw(gettemplate); |
31 |
use C4::Templates qw(gettemplate); |
30 |
use Koha::DateUtils qw( dt_from_string output_pref ); |
32 |
use Koha::DateUtils qw( dt_from_string output_pref ); |
31 |
use Koha::Acquisition::Baskets; |
33 |
use Koha::Acquisition::Baskets; |
Lines 203-208
sub NewBasket {
Link Here
|
203 |
$basketbooksellernote ||= q{}; |
205 |
$basketbooksellernote ||= q{}; |
204 |
ModBasketHeader( $basket, $basketname, $basketnote, $basketbooksellernote, |
206 |
ModBasketHeader( $basket, $basketname, $basketnote, $basketbooksellernote, |
205 |
$basketcontractnumber, $booksellerid, $deliveryplace, $billingplace, $is_standing, $create_items ); |
207 |
$basketcontractnumber, $booksellerid, $deliveryplace, $billingplace, $is_standing, $create_items ); |
|
|
208 |
|
209 |
# Log the basket creation |
210 |
# We need the creation timestamp, so need to get the newly created basket |
211 |
my $new_basket = GetBasket($basket); |
212 |
my $bookseller = Koha::Acquisition::Booksellers->find( |
213 |
$new_basket->{booksellerid} |
214 |
); |
215 |
my $patron = Koha::Patrons->find( $authorisedby ); |
216 |
my $infos = { |
217 |
basketno => $basket, |
218 |
basketname => $new_basket->{basketname}, |
219 |
creationdate => $new_basket->{creationdate}, |
220 |
vendorname => $bookseller->name, |
221 |
creatorname => $patron->firstname . ' ' . $patron->surname |
222 |
}; |
223 |
logaction('ACQUISITIONS', 'ADD', $basket, to_json($infos)); |
224 |
|
206 |
return $basket; |
225 |
return $basket; |
207 |
} |
226 |
} |
208 |
|
227 |
|
Lines 217-223
close a basket (becomes unmodifiable, except for receives)
Link Here
|
217 |
=cut |
236 |
=cut |
218 |
|
237 |
|
219 |
sub CloseBasket { |
238 |
sub CloseBasket { |
220 |
my ($basketno) = @_; |
239 |
my ($basketno, $edi_approval) = @_; |
221 |
my $dbh = C4::Context->dbh; |
240 |
my $dbh = C4::Context->dbh; |
222 |
$dbh->do('UPDATE aqbasket SET closedate=now() WHERE basketno=?', {}, $basketno ); |
241 |
$dbh->do('UPDATE aqbasket SET closedate=now() WHERE basketno=?', {}, $basketno ); |
223 |
|
242 |
|
Lines 225-230
sub CloseBasket {
Link Here
|
225 |
q{UPDATE aqorders SET orderstatus = 'ordered' WHERE basketno = ? AND orderstatus NOT IN ( 'complete', 'cancelled')}, |
244 |
q{UPDATE aqorders SET orderstatus = 'ordered' WHERE basketno = ? AND orderstatus NOT IN ( 'complete', 'cancelled')}, |
226 |
{}, $basketno |
245 |
{}, $basketno |
227 |
); |
246 |
); |
|
|
247 |
|
248 |
# Log the closure |
249 |
my $basket = GetBasket($basketno); |
250 |
my $bookseller = Koha::Acquisition::Booksellers->find( |
251 |
$basket->{booksellerid} |
252 |
); |
253 |
my ($day, $mon, $year) = (localtime->mday, localtime->mon, localtime->year); |
254 |
$mon = sprintf '%02d', $mon + 1; |
255 |
$day = sprintf '%02d', $day; |
256 |
$year += 1900; |
257 |
my $action = $edi_approval ? 'APPROVE_BASKET' : 'CLOSE_BASKET'; |
258 |
my $infos = { |
259 |
basketno => $basketno, |
260 |
basketname => $basket->{basketname}, |
261 |
closeddate => "$year-$mon-$day", |
262 |
vendorname => $bookseller->name, |
263 |
}; |
264 |
logaction( |
265 |
'ACQUISITIONS', |
266 |
$action, |
267 |
$basketno, |
268 |
to_json($infos) |
269 |
); |
270 |
|
228 |
return; |
271 |
return; |
229 |
} |
272 |
} |
230 |
|
273 |
|
Lines 548-553
sub ModBasket {
Link Here
|
548 |
my $sth = $dbh->prepare($query); |
591 |
my $sth = $dbh->prepare($query); |
549 |
$sth->execute(@params); |
592 |
$sth->execute(@params); |
550 |
|
593 |
|
|
|
594 |
# Log the basket update |
595 |
my $edited_basket = GetBasket($basketinfo->{'basketno'}); |
596 |
my $bookseller = Koha::Acquisition::Booksellers->find( |
597 |
$edited_basket->{booksellerid} |
598 |
); |
599 |
my ($day, $mon, $year) = (localtime->mday, localtime->mon, localtime->year); |
600 |
$mon = sprintf '%02d', $mon + 1; |
601 |
$day = sprintf '%02d', $day; |
602 |
$year += 1900; |
603 |
my $infos = { |
604 |
basketno => $basketinfo->{'basketno'}, |
605 |
basketname => $edited_basket->{basketname}, |
606 |
updatedate => "$year-$mon-$day", |
607 |
vendorname => $bookseller->name, |
608 |
}; |
609 |
if ($basketinfo->{borrowernumber}) { |
610 |
my $patron = Koha::Patrons->find( $basketinfo->{borrowernumber} ); |
611 |
$infos->{editorname} = $patron->firstname . ' ' . $patron->surname; |
612 |
} |
613 |
logaction( |
614 |
'ACQUISITIONS', |
615 |
'MODIFY', |
616 |
$basketinfo->{'basketno'}, |
617 |
to_json($infos) |
618 |
); |
619 |
|
551 |
return; |
620 |
return; |
552 |
} |
621 |
} |
553 |
|
622 |
|
Lines 587-593
case the AcqCreateItem syspref takes precedence).
Link Here
|
587 |
=cut |
656 |
=cut |
588 |
|
657 |
|
589 |
sub ModBasketHeader { |
658 |
sub ModBasketHeader { |
590 |
my ($basketno, $basketname, $note, $booksellernote, $contractnumber, $booksellerid, $deliveryplace, $billingplace, $is_standing, $create_items) = @_; |
659 |
my ($basketno, $basketname, $note, $booksellernote, $contractnumber, $booksellerid, $deliveryplace, $billingplace, $is_standing, $create_items, $borrowernumber) = @_; |
591 |
|
660 |
|
592 |
$is_standing ||= 0; |
661 |
$is_standing ||= 0; |
593 |
my $query = qq{ |
662 |
my $query = qq{ |
Lines 605-610
sub ModBasketHeader {
Link Here
|
605 |
my $sth2 = $dbh->prepare($query2); |
674 |
my $sth2 = $dbh->prepare($query2); |
606 |
$sth2->execute($contractnumber,$basketno); |
675 |
$sth2->execute($contractnumber,$basketno); |
607 |
} |
676 |
} |
|
|
677 |
|
678 |
# Log the basket update |
679 |
my $bookseller = Koha::Acquisition::Booksellers->find($booksellerid); |
680 |
my ($day, $mon, $year) = (localtime->mday, localtime->mon, localtime->year); |
681 |
$mon = sprintf '%02d', $mon + 1; |
682 |
$day = sprintf '%02d', $day; |
683 |
$year += 1900; |
684 |
my $infos = { |
685 |
basketno => $basketno, |
686 |
basketname => $basketname, |
687 |
updatedate => "$year-$mon-$day", |
688 |
vendorname => $bookseller->name, |
689 |
}; |
690 |
if ($borrowernumber) { |
691 |
my $patron = Koha::Patrons->find( $borrowernumber ); |
692 |
$infos->{editorname} = $patron->firstname . ' ' . $patron->surname; |
693 |
} |
694 |
logaction('ACQUISITIONS', 'MODIFY', $basketno, to_json($infos)); |
695 |
|
608 |
return; |
696 |
return; |
609 |
} |
697 |
} |
610 |
|
698 |
|