Bugzilla – Attachment 189404 Details for
Bug 39711
Migrate C4::Contract to object classes
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 39711: Use ->contract for basketheader
Bug-39711-Use--contract-for-basketheader.patch (text/plain), 16.48 KB, created by
Matt Blenkinsop
on 2025-11-10 13:22:02 UTC
(
hide
)
Description:
Bug 39711: Use ->contract for basketheader
Filename:
MIME Type:
Creator:
Matt Blenkinsop
Created:
2025-11-10 13:22:02 UTC
Size:
16.48 KB
patch
obsolete
>From 456c283c2edc2784939baecd794743cfd219b8ae Mon Sep 17 00:00:00 2001 >From: Jonathan Druart <jonathan.druart@bugs.koha-community.org> >Date: Mon, 28 Apr 2025 12:19:58 +0200 >Subject: [PATCH] Bug 39711: Use ->contract for basketheader > >--- > acqui/basketheader.pl | 53 +++------------- > admin/aqcontract.pl | 1 - > .../prog/en/modules/acqui/basketheader.tt | 62 +++++++++---------- > .../prog/en/modules/acqui/neworderempty.tt | 7 ++- > 4 files changed, 44 insertions(+), 79 deletions(-) > >diff --git a/acqui/basketheader.pl b/acqui/basketheader.pl >index 3583b6efb40..65b5752a093 100755 >--- a/acqui/basketheader.pl >+++ b/acqui/basketheader.pl >@@ -54,7 +54,6 @@ use C4::Acquisition qw( GetBasket ModBasket ModBasketHeader NewBasket ); > > use Koha::Acquisition::Booksellers; > use Koha::Acquisition::Baskets; >-use Koha::Acquisition::Contracts; > use Koha::AdditionalFields; > use Koha::Database; > >@@ -71,44 +70,24 @@ my ( $template, $loggedinuser, $cookie ) = get_template_and_user( > #parameters: > my $booksellerid = $input->param('booksellerid'); > my $basketno = $input->param('basketno'); >-my $basket; >-my $op = $input->param('op'); >-my $is_an_edit = $input->param('is_an_edit'); >+my $op = $input->param('op'); >+my $is_an_edit = $input->param('is_an_edit'); > > $template->param( available_additional_fields => Koha::AdditionalFields->search( { tablename => 'aqbasket' } ) ); > > if ( $op eq 'add_form' ) { >- my @contracts = Koha::Acquisition::Contracts->search( >- { booksellerid => $booksellerid, contractenddate => { '>=' => \'now()' } } )->as_list; >- my @contractloop; >- foreach my $contract (@contracts) { >- push( @contractloop, $contract->unblessed ); >- } >+ my $bookseller = Koha::Acquisition::Booksellers->find($booksellerid); >+ my $contracts = $bookseller->contracts->search( { contractenddate => { '>=' => \'now()' } } ); >+ > if ($basketno) { > > #this is an edit >- $basket = GetBasket($basketno); >- if ( !$booksellerid ) { >- $booksellerid = $basket->{'booksellerid'}; >- } >+ my $basket = Koha::Acquisition::Baskets->find($basketno); > >- for (@contractloop) { >- if ( $basket->{'contractnumber'} eq $_->{'contractnumber'} ) { >- $_->{selected} = 1; >- } >- } >- $template->param( is_an_edit => 1 ); >+ $template->param( basket => $basket ); > $template->param( additional_field_values => > Koha::Acquisition::Baskets->find($basketno)->get_additional_field_values_for_template ); > } >- my $bookseller = Koha::Acquisition::Booksellers->find($booksellerid); >- my $count = scalar @contractloop; >- if ( $count > 0 ) { >- $template->param( >- contractloop => \@contractloop, >- basketcontractnumber => $basket->{'contractnumber'} >- ); >- } > > # Check if basket name should be read-only (EDI-generated with PO number setting) > my $basket_name_readonly = 0; >@@ -130,24 +109,10 @@ if ( $op eq 'add_form' ) { > > $template->param( > add_form => 1, >- basketname => $basket->{'basketname'}, >- basketnote => $basket->{'note'}, >- basketbooksellernote => $basket->{'booksellernote'}, >- booksellername => $bookseller->name, >- booksellerid => $booksellerid, >- basketno => $basketno, >- is_standing => $basket->{is_standing}, >- create_items => $basket->{create_items}, >- basket_name_readonly => $basket_name_readonly, >+ vendor => $bookseller, >+ contracts => $contracts > ); > >- my $billingplace = $basket->{'billingplace'} || C4::Context->userenv->{"branch"}; >- my $deliveryplace = $basket->{'deliveryplace'} || C4::Context->userenv->{"branch"}; >- >- $template->param( billingplace => $billingplace ); >- $template->param( deliveryplace => $deliveryplace ); >- >- #End Edit > } elsif ( $op eq 'cud-add_validate' ) { > > #we are confirming the changes, save the basket >diff --git a/admin/aqcontract.pl b/admin/aqcontract.pl >index 09d19248ba0..57e75f2f779 100755 >--- a/admin/aqcontract.pl >+++ b/admin/aqcontract.pl >@@ -28,7 +28,6 @@ use C4::Output qw( output_html_with_http_headers ); > use Koha::DateUtils qw( dt_from_string ); > > use Koha::Acquisition::Booksellers; >-use Koha::Acquisition::Contract; > use Koha::Acquisition::Contracts; > > my $input = CGI->new; >diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/acqui/basketheader.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/acqui/basketheader.tt >index e50b1e89473..c132b6e393a 100644 >--- a/koha-tmpl/intranet-tmpl/prog/en/modules/acqui/basketheader.tt >+++ b/koha-tmpl/intranet-tmpl/prog/en/modules/acqui/basketheader.tt >@@ -8,10 +8,10 @@ > <title > >[% FILTER collapse %] > [% IF ( add_form ) %] >- [% IF ( basketno ) %] >- [% tx("Edit basket '{basketname}'", { basketname = basketname }) | html %] >+ [% IF ( basket ) %] >+ [% tx("Edit basket '{basketname}'", { basketname = basket.basketname }) | html %] > [% ELSE %] >- [% tx("Add basket to {vendor}", { vendor = booksellername }) | html %] >+ [% tx("Add basket to {vendor}", { vendor = vendor.name}) | html %] > [% END %] > [% END %] > › [% t("Acquisitions") | html %] › [% t("Koha") | html %] >@@ -31,16 +31,16 @@ > <a href="/cgi-bin/koha/acqui/acqui-home.pl">Acquisitions</a> > [% END %] > [% WRAPPER breadcrumb_item %] >- <a href="/cgi-bin/koha/acquisition/vendors/[% booksellerid | uri %]">[% booksellername | html %]</a> >+ <a href="/cgi-bin/koha/acquisition/vendors/[% vendor.id | uri %]">[% vendor.name | html %]</a> > [% END %] > [% IF ( add_form ) %] >- [% IF ( basketno ) %] >+ [% IF basket %] > [% WRAPPER breadcrumb_item bc_active= 1 %] >- <span>Edit basket '[% basketname | html %]'</span> >+ <span>Edit basket '[% basket.basketname | html %]'</span> > [% END %] > [% ELSE %] > [% WRAPPER breadcrumb_item bc_active= 1 %] >- <span>Add a basket to [% booksellername | html %]</span> >+ <span>Add a basket to [% vendor.name | html %]</span> > [% END %] > [% END %] > [% END %] >@@ -50,30 +50,30 @@ > [% WRAPPER 'main-container.inc' %] > > [% IF ( add_form ) %] >- [% IF ( basketno ) %] >- <h1>Edit basket [% basketname | html %]</h1> >+ [% IF basket %] >+ <h1>Edit basket [% basket.basketname | html %]</h1> > [% ELSE %] >- <h1>Add a basket to [% booksellername | html %]</h1> >+ <h1>Add a basket to [% vendor.name | html %]</h1> > [% END %] > <form name="Aform" action="/cgi-bin/koha/acqui/basketheader.pl" method="post" class="validated"> > [% INCLUDE 'csrf-token.inc' %] >- <input type="hidden" name="booksellerid" value="[% booksellerid | html %]" /> >+ <input type="hidden" name="booksellerid" value="[% vendor.id | html %]" /> > <fieldset class="rows"> > <ol> >- [% IF ( basketno ) %] >+ [% IF basket %] > <li> >- <input type="hidden" name="basketno" value="[% basketno | html %]" /> >+ <input type="hidden" name="basketno" value="[% basket.basketno | html %]" /> > <input type="hidden" name="is_an_edit" value="1" /> > </li> > [% END %] > <li> > <label for="basketname" class="required">Basket name: </label> > [% IF basket_name_readonly %] >- <input type="text" name="basketname" id="basketname" size="40" maxlength="80" value="[% basketname | html %]" required="required" class="focus required" readonly="readonly" /> >+ <input type="text" name="basketname" id="basketname" size="40" maxlength="80" value="[% basket.basketname | html %]" required="required" class="focus required" readonly="readonly" /> > <span class="required">Required</span> > <div class="hint">This basket name is derived from the purchase order number and cannot be changed.</div> > [% ELSE %] >- <input type="text" name="basketname" id="basketname" size="40" maxlength="80" value="[% basketname | html %]" required="required" class="focus required" /> >+ <input type="text" name="basketname" id="basketname" size="40" maxlength="80" value="[% basket.basketname | html %]" required="required" class="focus required" /> > <span class="required">Required</span> > [% END %] > </li> >@@ -81,40 +81,40 @@ > <label for="billingplace">Billing place: </label> > <select name="billingplace" id="billingplace"> > <option value="">--</option> >- [% PROCESS options_for_libraries libraries => Branches.all( selected => billingplace ) %] >+ [% PROCESS options_for_libraries libraries => Branches.all( selected => basket.billingplace || Branches.GetLoggedInBranchcode() ) %] > </select> > </li> > <li> > <label for="deliveryplace">Delivery place: </label> > <select name="deliveryplace" id="deliveryplace"> > <option value="">--</option> >- [% PROCESS options_for_libraries libraries => Branches.all( selected => deliveryplace ) %] >+ [% PROCESS options_for_libraries libraries => Branches.all( selected => deliveryplace || Branches.GetLoggedInBranchcode() ) %] > </select> > </li> > <li> > <label for="basketbooksellerid">Vendor: </label> > <select name="basketbooksellerid" id="basketbooksellerid"> >- <option value="[% booksellerid | html %]" selected="selected">Current vendor ([% booksellername | html %])</option> >+ <option value="[% vendor.id | html %]" selected="selected">Current vendor ([% vendor.name | html %])</option> > </select> > </li> > <li> > <label for="basketnote">Internal note: </label> >- <textarea name="basketnote" id="basketnote" rows="5" cols="40">[% basketnote |html %]</textarea> >+ <textarea name="basketnote" id="basketnote" rows="5" cols="40">[% basket.note |html %]</textarea> > </li> > <li> > <label for="basketbooksellernote">Vendor note: </label> >- <textarea name="basketbooksellernote" id="basketbooksellernote" rows="5" cols="40">[% basketbooksellernote |html %]</textarea> >+ <textarea name="basketbooksellernote" id="basketbooksellernote" rows="5" cols="40">[% basket.booksellernote |html %]</textarea> > </li> >- [% IF ( contractloop ) %] >+ [% IF contracts.count %] > <li > ><label for="basketcontractnumber">Contract: </label> > <select id="basketcontractnumber" name="basketcontractnumber"> > <option value=""></option> >- [% FOREACH contractloo IN contractloop %] >- [% IF ( contractloo.selected ) %] >- <option value="[% contractloo.contractnumber | html %]" selected="selected">[% contractloo.contractname | html %]</option> >+ [% FOREACH contract IN contracts %] >+ [% IF contract.contractnumber == basket.contractnumber %] >+ <option value="[% contract.contractnumber | html %]" selected="selected">[% contract.contractname | html %]</option> > [% ELSE %] >- <option value="[% contractloo.contractnumber | html %]">[% contractloo.contractname | html %]</option> >+ <option value="[% contract.contractnumber | html %]">[% contract.contractname | html %]</option> > [% END %] > [% END %] > </select> >@@ -122,15 +122,15 @@ > [% END %] > <li> > <label for="is_standing">Orders are standing:</label> >- [% IF is_standing %] >+ [% IF basket.is_standing %] > <input type="checkbox" id="is_standing" name="is_standing" checked="checked" /> > [% ELSE %] > <input type="checkbox" id="is_standing" name="is_standing" /> > [% END %] > <div class="hint">Standing orders do not close when received.</div> > </li> >- [% IF basketno %] >- <input type="hidden" name="create_items" value="[% create_items | html %]" /> >+ [% IF basket %] >+ <input type="hidden" name="create_items" value="[% basket.create_items | html %]" /> > [% ELSE %] > <li> > <label for="create_items">Create items when:</label> >@@ -159,10 +159,10 @@ > <fieldset class="action"> > <input type="hidden" name="op" value="cud-add_validate" /> > <input type="submit" class="btn btn-primary" value="Save" /> >- [% IF ( basketno ) %] >- <a class="cancel" href="/cgi-bin/koha/acqui/basket.pl?basketno=[% basketno | html %]">Cancel</a> >+ [% IF basket %] >+ <a class="cancel" href="/cgi-bin/koha/acqui/basket.pl?basketno=[% basket.basketno | html %]">Cancel</a> > [% ELSE %] >- <a class="cancel" href="/cgi-bin/koha/acquisition/vendors/[% booksellerid | html %]">Cancel</a> >+ <a class="cancel" href="/cgi-bin/koha/acquisition/vendors/[% vendor.id | html %]">Cancel</a> > [% END %] > </fieldset> > </form> >diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/acqui/neworderempty.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/acqui/neworderempty.tt >index 782f0dc2d94..5c2e3df529f 100644 >--- a/koha-tmpl/intranet-tmpl/prog/en/modules/acqui/neworderempty.tt >+++ b/koha-tmpl/intranet-tmpl/prog/en/modules/acqui/neworderempty.tt >@@ -276,9 +276,10 @@ > <ol> > [% IF ( basketnote ) %]<li><span class="label">Internal note:</span> [% basketnote | html %]</li>[% END %] > [% IF ( basketbooksellernote ) %]<li><span class="label">Vendor note:</span> [% basketbooksellernote | html %]</li>[% END %] >- [% IF ( basketcontractno ) %] >- <li><span class="label">Contract number: </span>[% basketcontractno | html %]</li> >- <li><span class="label">Contract name:</span> <a href="/cgi-bin/koha/admin/aqcontract.pl?op=add_form&contractnumber=[% basketcontractno | uri %]">[% basketcontractname | html %]</a></li> >+ [% SET contract = basket_obj.contract %] >+ [% IF contract %] >+ <li><span class="label">Contract number: </span>[% contract.contractnumber | html %]</li> >+ <li><span class="label">Contract name:</span> <a href="/cgi-bin/koha/admin/aqcontract.pl?op=add_form&contractnumber=[% contract.contractnumber | uri %]">[% contract.contractname | html %]</a></li> > [% END %] > [% IF ( authorisedbyname ) %]<li><span class="label">[% tp('Acquisitions basket managed by user', 'Managed by:') | html %]</span> [% authorisedbyname | html %]</li>[% END %] > [% IF ( creationdate ) %]<li><span class="label">Open on:</span> [% creationdate | $KohaDates %]</li>[% END %] >-- >2.50.1
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
|
Splinter Review
Attachments on
bug 39711
:
181453
|
181454
|
181455
|
181456
|
181457
|
181458
|
181459
|
181460
|
181461
|
181580
|
181581
|
181582
|
181583
|
181584
|
181586
|
181587
|
181588
|
189393
|
189394
|
189395
|
189396
|
189397
|
189398
|
189399
|
189400
|
189401
|
189402
|
189403
| 189404 |
189405
|
189406
|
189407