Bugzilla – Attachment 181584 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), 15.53 KB, created by
Jonathan Druart
on 2025-04-28 10:24:17 UTC
(
hide
)
Description:
Bug 39711: Use ->contract for basketheader
Filename:
MIME Type:
Creator:
Jonathan Druart
Created:
2025-04-28 10:24:17 UTC
Size:
15.53 KB
patch
obsolete
>From 691cc201d2626a387e8c3a8085c5688168c4621c 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 | 57 ++++-------------- > admin/aqcontract.pl | 1 - > .../prog/en/modules/acqui/basketheader.tt | 60 +++++++++---------- > .../prog/en/modules/acqui/neworderempty.tt | 7 ++- > 4 files changed, 45 insertions(+), 80 deletions(-) > >diff --git a/acqui/basketheader.pl b/acqui/basketheader.pl >index 2ad821060eb..0b43cfc5e3a 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; > > my $input = CGI->new; >@@ -70,64 +69,30 @@ 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'}; >- } >- >- for (@contractloop) { >- if ( $basket->{'contractnumber'} eq $_->{'contractnumber'} ) { >- $_->{selected} = 1; >- } >- } >- $template->param( is_an_edit => 1 ); >+ my $basket = Koha::Acquisition::Baskets->find($basketno); >+ >+ $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'} >- ); >- } > > $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}, >+ add_form => 1, >+ 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 cf4cdf12025..2e04da100cc 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 1468aab6da8..a11ff26f459 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,65 +50,65 @@ > [% 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> >- <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> > </li> > <li> > <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> >@@ -116,15 +116,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> >@@ -153,10 +153,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 b4bea46f4c4..c60d7b35927 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.34.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