|
Link Here
|
| 51 |
use C4::Auth qw( get_template_and_user ); |
51 |
use C4::Auth qw( get_template_and_user ); |
| 52 |
use C4::Output qw( output_html_with_http_headers ); |
52 |
use C4::Output qw( output_html_with_http_headers ); |
| 53 |
use C4::Acquisition qw( GetBasket ModBasket ModBasketHeader NewBasket ); |
53 |
use C4::Acquisition qw( GetBasket ModBasket ModBasketHeader NewBasket ); |
| 54 |
use C4::Contract qw( GetContracts GetContract ); |
54 |
use C4::Contract qw( GetContract ); |
| 55 |
|
55 |
|
| 56 |
use Koha::Acquisition::Booksellers; |
56 |
use Koha::Acquisition::Booksellers; |
| 57 |
use Koha::Acquisition::Baskets; |
57 |
use Koha::Acquisition::Baskets; |
|
|
58 |
use Koha::Acquisition::Contracts; |
| 58 |
use Koha::AdditionalFields; |
59 |
use Koha::AdditionalFields; |
| 59 |
use Koha::Database; |
60 |
use Koha::Database; |
| 60 |
|
61 |
|
|
Link Here
|
| 78 |
$template->param( available_additional_fields => Koha::AdditionalFields->search( { tablename => 'aqbasket' } ) ); |
79 |
$template->param( available_additional_fields => Koha::AdditionalFields->search( { tablename => 'aqbasket' } ) ); |
| 79 |
|
80 |
|
| 80 |
if ( $op eq 'add_form' ) { |
81 |
if ( $op eq 'add_form' ) { |
|
|
82 |
my @contracts = Koha::Acquisition::Contracts->search( |
| 83 |
{ booksellerid => $booksellerid, contractenddate => { '>=' => \'now()' } } )->as_list; |
| 81 |
my @contractloop; |
84 |
my @contractloop; |
|
|
85 |
foreach my $contract (@contracts) { |
| 86 |
push( @contractloop, $contract->unblessed ); |
| 87 |
} |
| 82 |
if ($basketno) { |
88 |
if ($basketno) { |
| 83 |
|
89 |
|
| 84 |
#this is an edit |
90 |
#this is an edit |
|
Link Here
|
| 86 |
if ( !$booksellerid ) { |
92 |
if ( !$booksellerid ) { |
| 87 |
$booksellerid = $basket->{'booksellerid'}; |
93 |
$booksellerid = $basket->{'booksellerid'}; |
| 88 |
} |
94 |
} |
| 89 |
my $contracts = GetContracts( |
|
|
| 90 |
{ |
| 91 |
booksellerid => $booksellerid, |
| 92 |
activeonly => 1, |
| 93 |
} |
| 94 |
); |
| 95 |
|
95 |
|
| 96 |
@contractloop = @$contracts; |
|
|
| 97 |
for (@contractloop) { |
96 |
for (@contractloop) { |
| 98 |
if ( $basket->{'contractnumber'} eq $_->{'contractnumber'} ) { |
97 |
if ( $basket->{'contractnumber'} eq $_->{'contractnumber'} ) { |
| 99 |
$_->{'selected'} = 1; |
98 |
$_->{selected} = 1; |
| 100 |
} |
99 |
} |
| 101 |
} |
100 |
} |
| 102 |
$template->param( is_an_edit => 1 ); |
101 |
$template->param( is_an_edit => 1 ); |
| 103 |
$template->param( additional_field_values => |
102 |
$template->param( additional_field_values => |
| 104 |
Koha::Acquisition::Baskets->find($basketno)->get_additional_field_values_for_template ); |
103 |
Koha::Acquisition::Baskets->find($basketno)->get_additional_field_values_for_template ); |
| 105 |
} else { |
|
|
| 106 |
|
| 107 |
#new basket |
| 108 |
my $basket; |
| 109 |
my $contracts = GetContracts( |
| 110 |
{ |
| 111 |
booksellerid => $booksellerid, |
| 112 |
activeonly => 1, |
| 113 |
} |
| 114 |
); |
| 115 |
push( @contractloop, @$contracts ); |
| 116 |
} |
104 |
} |
| 117 |
my $bookseller = Koha::Acquisition::Booksellers->find($booksellerid); |
105 |
my $bookseller = Koha::Acquisition::Booksellers->find($booksellerid); |
| 118 |
my $count = scalar @contractloop; |
106 |
my $count = scalar @contractloop; |