Link Here
|
56 |
use Koha::Acquisition::Booksellers; |
56 |
use Koha::Acquisition::Booksellers; |
57 |
use Koha::Acquisition::Baskets; |
57 |
use Koha::Acquisition::Baskets; |
58 |
use Koha::AdditionalFields; |
58 |
use Koha::AdditionalFields; |
|
|
59 |
use Koha::Database; |
59 |
|
60 |
|
60 |
my $input = CGI->new; |
61 |
my $input = CGI->new; |
61 |
my ( $template, $loggedinuser, $cookie ) = get_template_and_user( |
62 |
my ( $template, $loggedinuser, $cookie ) = get_template_and_user( |
Link Here
|
122 |
); |
123 |
); |
123 |
} |
124 |
} |
124 |
|
125 |
|
|
|
126 |
# Check if basket name should be read-only (EDI-generated with PO number setting) |
127 |
my $basket_name_readonly = 0; |
128 |
if ( $basketno && $basket ) { |
129 |
my $basket_obj = Koha::Acquisition::Baskets->find($basketno); |
130 |
if ($basket_obj) { |
131 |
my $edi_quote = $basket_obj->edi_quote; |
132 |
if ($edi_quote) { |
133 |
|
134 |
# This basket was created from an EDI quote |
135 |
# Check if the vendor EDI account is configured to use purchase order numbers |
136 |
my $vendor_edi_account = $edi_quote->edi_acct; |
137 |
if ( $vendor_edi_account && $vendor_edi_account->po_is_basketname ) { |
138 |
$basket_name_readonly = 1; |
139 |
} |
140 |
} |
141 |
} |
142 |
} |
143 |
|
125 |
$template->param( |
144 |
$template->param( |
126 |
add_form => 1, |
145 |
add_form => 1, |
127 |
basketname => $basket->{'basketname'}, |
146 |
basketname => $basket->{'basketname'}, |
Link Here
|
132 |
basketno => $basketno, |
151 |
basketno => $basketno, |
133 |
is_standing => $basket->{is_standing}, |
152 |
is_standing => $basket->{is_standing}, |
134 |
create_items => $basket->{create_items}, |
153 |
create_items => $basket->{create_items}, |
|
|
154 |
basket_name_readonly => $basket_name_readonly, |
135 |
); |
155 |
); |
136 |
|
156 |
|
137 |
my $billingplace = $basket->{'billingplace'} || C4::Context->userenv->{"branch"}; |
157 |
my $billingplace = $basket->{'billingplace'} || C4::Context->userenv->{"branch"}; |
Link Here
|
145 |
|
165 |
|
146 |
#we are confirming the changes, save the basket |
166 |
#we are confirming the changes, save the basket |
147 |
if ($is_an_edit) { |
167 |
if ($is_an_edit) { |
|
|
168 |
|
169 |
# Check if basket name should be protected from changes |
170 |
my $basket_name = scalar $input->param('basketname'); |
171 |
my $current_basket = GetBasket($basketno); |
172 |
|
173 |
# If this basket was created from EDI with PO number setting, prevent name changes |
174 |
my $basket_obj = Koha::Acquisition::Baskets->find($basketno); |
175 |
if ($basket_obj) { |
176 |
my $edi_order = $basket_obj->edi_order; |
177 |
if ($edi_order) { |
178 |
|
179 |
# This basket was created from an EDI order/quote |
180 |
# Check if the vendor EDI account is configured to use purchase order numbers |
181 |
my $schema = Koha::Database->new()->schema(); |
182 |
my $vendor_edi_account = $schema->resultset('VendorEdiAccount') |
183 |
->search( { vendor_id => scalar $input->param('basketbooksellerid') } )->first; |
184 |
|
185 |
if ( $vendor_edi_account && $vendor_edi_account->po_is_basketname ) { |
186 |
|
187 |
# Preserve the original basket name |
188 |
$basket_name = $current_basket->{'basketname'}; |
189 |
} |
190 |
} |
191 |
} |
192 |
|
148 |
ModBasketHeader( |
193 |
ModBasketHeader( |
149 |
$basketno, |
194 |
$basketno, |
150 |
scalar $input->param('basketname'), |
195 |
$basket_name, |
151 |
scalar $input->param('basketnote'), |
196 |
scalar $input->param('basketnote'), |
152 |
scalar $input->param('basketbooksellernote'), |
197 |
scalar $input->param('basketbooksellernote'), |
153 |
scalar $input->param('basketcontractnumber') || undef, |
198 |
scalar $input->param('basketcontractnumber') || undef, |