Bugzilla – Attachment 182043 Details for
Bug 32266
Make the late orders page render using the API
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 32266: Make the late orders page use the API
Bug-32266-Make-the-late-orders-page-use-the-API.patch (text/plain), 47.01 KB, created by
Tomás Cohen Arazi (tcohen)
on 2025-05-07 19:08:19 UTC
(
hide
)
Description:
Bug 32266: Make the late orders page use the API
Filename:
MIME Type:
Creator:
Tomás Cohen Arazi (tcohen)
Created:
2025-05-07 19:08:19 UTC
Size:
47.01 KB
patch
obsolete
>From c2894dbae2019b7ecf5c5546869a7a53ade5883f Mon Sep 17 00:00:00 2001 >From: Tomas Cohen Arazi <tomascohen@theke.io> >Date: Fri, 2 May 2025 10:11:07 -0300 >Subject: [PATCH] Bug 32266: Make the late orders page use the API > >This bug makes the late orders page render using the API. >Everything should work as usual. > >To test: >0. Have a bunch of late orders, from different vendors with different > dates >1. Check how the page works without the patches >2. Notice it works similar with the patches >3. Sign off :-D >--- > acqui/lateorders.pl | 87 +-- > .../prog/en/modules/acqui/lateorders.tt | 631 +++++++++++------- > 2 files changed, 387 insertions(+), 331 deletions(-) > >diff --git a/acqui/lateorders.pl b/acqui/lateorders.pl >index eb43a93de15..35814cb46de 100755 >--- a/acqui/lateorders.pl >+++ b/acqui/lateorders.pl >@@ -22,37 +22,20 @@ lateorders.pl > > =head1 DESCRIPTION > >-this script shows late orders for a specific supplier, branch and delay >-given on input arg. >- >-=head1 CGI PARAMETERS >- >-=over 4 >- >-=item booksellerid >-To know on which supplier this script have to display late order. >- >-=item delay >-To know the time boundary. Default value is 30 days. >- >-=item branch >-To know on which branch this script have to display late order. >- >-=back >+This script shows late orders > > =cut > > use Modern::Perl; >-use CGI qw ( -utf8 ); >-use C4::Auth qw( get_template_and_user ); >-use C4::Output qw( output_html_with_http_headers ); >-use C4::Context; >-use C4::Letters qw( SendAlerts GetLetters ); >-use Koha::DateUtils qw( dt_from_string ); >+use CGI qw ( -utf8 ); >+use C4::Auth qw( get_template_and_user ); >+use C4::Output qw( output_html_with_http_headers ); >+use C4::Letters qw( SendAlerts GetLetters ); > use Koha::Acquisition::Orders; > use Koha::CsvProfiles; > > my $input = CGI->new; >+ > my ( $template, $loggedinuser, $cookie ) = get_template_and_user( > { > template_name => "acqui/lateorders.tt", >@@ -62,26 +45,7 @@ my ( $template, $loggedinuser, $cookie ) = get_template_and_user( > } > ); > >-my $booksellerid = $input->param('booksellerid'); >-my $delay = $input->param('delay') // 0; >- >-# Get the "date from" param if !defined is today >-my $estimateddeliverydatefrom = $input->param('estimateddeliverydatefrom'); >-my $estimateddeliverydateto = $input->param('estimateddeliverydateto'); >- >-# Get the "date to" param. If it is not defined and $delay is not defined too, it is the today's date. >-$estimateddeliverydateto ||= >- ( not defined $delay and not defined $estimateddeliverydatefrom ) >- ? dt_from_string() >- : undef; >- >-my $branch = $input->param('branch'); >-my $op = $input->param('op'); >- >-my @errors = (); >-if ( $delay and not $delay =~ /^\d{1,3}$/ ) { >- push @errors, { delay_digits => 1, bad_delay => $delay }; >-} >+my $op = $input->param('op'); > > if ( $op and $op eq "cud-send_alert" ) { > my @ordernums = $input->multi_param("ordernumber"); >@@ -104,42 +68,11 @@ if ( $op and $op eq "cud-send_alert" ) { > } > } > >-my @lateorders = Koha::Acquisition::Orders->filter_by_lates( >- { >- delay => $delay, >- ( >- $estimateddeliverydatefrom >- ? ( estimated_from => dt_from_string( $estimateddeliverydatefrom, 'iso' ) ) >- : () >- ), >- ( >- $estimateddeliverydateto >- ? ( estimated_to => dt_from_string( $estimateddeliverydateto, 'iso' ) ) >- : () >- ) >- }, >-)->as_list; >- >-my $booksellers = Koha::Acquisition::Booksellers->search( >- { >- id => { -in => [ map { $_->basket->booksellerid } @lateorders ] }, >- } >-); >- >-@lateorders = grep { $_->basket->booksellerid eq $booksellerid } @lateorders if $booksellerid; >- > my $letters = GetLetters( { module => "claimacquisition" } ); > >-$template->param( ERROR_LOOP => \@errors ) if (@errors); > $template->param( >- lateorders => \@lateorders, >- booksellers => $booksellers, >- bookseller_filter => ( $booksellerid ? $booksellers->find($booksellerid) : undef ), >- delay => $delay, >- letters => $letters, >- estimateddeliverydatefrom => $estimateddeliverydatefrom, >- estimateddeliverydateto => $estimateddeliverydateto, >- intranetcolorstylesheet => C4::Context->preference("intranetcolorstylesheet"), >- csv_profiles => Koha::CsvProfiles->search( { type => 'sql', used_for => 'late_orders' } ), >+ letters => $letters, >+ csv_profiles => Koha::CsvProfiles->search( { type => 'sql', used_for => 'late_orders' } ), > ); >+ > output_html_with_http_headers $input, $cookie, $template->output; >diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/acqui/lateorders.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/acqui/lateorders.tt >index d53072882af..b359f7067d9 100644 >--- a/koha-tmpl/intranet-tmpl/prog/en/modules/acqui/lateorders.tt >+++ b/koha-tmpl/intranet-tmpl/prog/en/modules/acqui/lateorders.tt >@@ -5,6 +5,7 @@ > [% USE Branches %] > [% USE TablesSettings %] > [% USE Price %] >+[% USE To %] > [% SET footerjs = 1 %] > [% PROCESS 'i18n.inc' %] > [% INCLUDE 'doc-head-open.inc' %] >@@ -53,221 +54,66 @@ > [% IF info_claim %] > <div class="alert alert-info">Email has been sent.</div> > [% END %] >- [% IF lateorders.size %] >- <form action="lateorders.pl" name="claim" method="post"> >- [% INCLUDE 'csrf-token.inc' %] >- <input type="hidden" name="op" value="cud-send_alert" /> >- <input type="hidden" name="delay" value="[% delay | html %]" /> >- <input type="hidden" name="booksellerid" value="[% bookseller_filter.id | html %]" /> >- [% IF ( letters ) %] >- <p >- ><label for="letter_code">Claim using notice: </label >- ><select name="letter_code" id="letter_code"> >- [% FOREACH letter IN letters %] >- <option value="[% letter.code | html %]">[% letter.name | html %]</option> >- [% END %] >- </select> >- </p> >- [% END %] >- [% SET total = 0 %] >- [% SET total_quantity = 0 %] >- [% IF bookseller_filter %] >- <p >- ><a id="CheckAll" href="#"><i class="fa fa-check"></i> Check all</a> <a id="CheckNone" href="#"><i class="fa fa-times"></i> Uncheck all</a></p >- > >- [% END %] >- <table id="late_orders"> >- <thead> >- <tr> >- <th class="no-sort"></th> >- <th>Order line</th> >- <th>Order date</th> >- <th>Estimated delivery date</th> >- <th>Vendor</th> >- <th class="anti-the">Information</th> >- <th>Quantity</th> >- <th>Total cost</th> >- <th>Basket</th> >- <th>Basket date</th> >- <th>Basket group</th> >- <th>Library</th> >- <th>Budget</th> >- <th>Fund</th> >- <th>Claims count</th> >- <th>Claimed date</th> >- <th>Internal note</th> >- <th>Vendor note</th> >- <th>ISBN</th> >- </tr> >- </thead> >- <tbody> >- [% FOREACH lateorder IN lateorders %] >- <tr> >- <td> >- <input type="checkbox" value="[% lateorder.ordernumber | html %]" data-booksellerid="[% lateorder.basket.booksellerid | html %]" name="ordernumber" /> >- </td> >- <td> [% lateorder.ordernumber | $raw %] </td> >- <td data-order="[% lateorder.basket.closedate | html %]"> [% lateorder.basket.closedate | $KohaDates %] ([% lateorder.basket.late_since_days | html %] days) </td> >- [% IF lateorder.get_column('estimated_delivery_date') %] >- [% SET estimated_delivery_date = lateorder.get_column('estimated_delivery_date') %] >- [% ELSIF lateorder.get_column('calculated_estimated_delivery_date') %] >- [% SET estimated_delivery_date = lateorder.get_column('calculated_estimated_delivery_date') %] >- [% END %] >- <td data-order="[% estimated_delivery_date | html %]"> >- <p class="delivery_date"> >- <span>[% estimated_delivery_date | $KohaDates %]</span> >- [% IF CAN_user_acquisition_order_manage %] >- <a >- class="edit_delivery_date no-export" >- data-ordernumber="[% lateorder.ordernumber | html %]" >- data-delivery_date="[% estimated_delivery_date | html %]" >- id="delivery_date_[% lateorder.ordernumber | html %]" >- href="/cgi-bin/koha/acqui/moddeliverydate.pl?ordernumber=[% lateorder.ordernumber | html %]" >- title="Edit delivery date" >- > >- <i class="fa-solid fa-pencil" aria-hidden="true"></i> Edit >- </a> >- [% END %] >- </p> >- </td> >- <td> [% lateorder.basket.bookseller.name | html %] ([% lateorder.basket.bookseller.id | html %]) </td> >- <td> >- <span class="title">[% INCLUDE 'biblio-title.inc' biblio=lateorder.biblio link=1 %]</span> >- [% IF ( lateorder.biblio.author ) %]<br /><em>Author:</em> [% lateorder.biblio.author | html %][% END %] >- [% IF ( lateorder.biblio.biblioitem.publishercode ) %] >- <br /><em>Published by:</em> [% lateorder.biblio.biblioitem.publishercode | html %] >- [% IF ( lateorder.biblio.biblioitem.publicationyear ) %] >- <em> in </em>[% lateorder.biblio.biblioitem.publicationyear | html %] >- [% END %] >- [% END %] >- </td> >- <td> >- [% lateorder.quantity | html %] >- [% SET total_quantity = total_quantity + lateorder.quantity %] >- </td> >- <td> >- [% SET subtotal = (lateorder.quantity - lateorder.quantityreceived) * lateorder.rrp %] >- [% SET total = total + subtotal %] >- [% lateorder.rrp | html %]x[% lateorder.quantity - lateorder.quantityreceived | html %] >- = [% subtotal | $Price %] >- </td> >- <td> >- [% IF ( CAN_user_acquisition_order_manage ) %] >- <a href="basket.pl?basketno=[% lateorder.basketno | uri %]" title="basket">[% lateorder.basket.basketname | html %] ([% lateorder.basketno | html %])</a> >- [% ELSE %] >- [% lateorder.basket.basketname | html %] >- ([% lateorder.basketno | html %]) >- [% END %] >- </td> >- <td data-order="[% lateorder.basket.creationdate | html %]">[% lateorder.basket.creationdate | $KohaDates %]</td> >- <td> >- [% IF ( lateorder.basket.basketgroupid ) %] >- [% IF ( CAN_user_acquisition_group_manage ) %] >- <a href="basketgroup.pl?op=add&booksellerid=[% lateorder.basket.booksellerid | uri %]&basketgroupid=[% lateorder.basket.basketgroupid | uri %]" title="basketgroup" >- >[% lateorder.basket.basket_group.name | html %] ([% lateorder.basket.basketgroupid | html %])</a >- > >- [% ELSE %] >- [% lateorder.basket.basket_group.name | html %] >- ([% lateorder.basket.basketgroupid | html %]) >- [% END %] >- [% END %] >- </td> >- <td>[% Branches.GetName( lateorder.basket.authorizer.branchcode ) | html %] </td> >- <td>[% lateorder.fund.budget.budget_period_description | html %]</td> >- <td>[% lateorder.fund.budget_name | html %]</td> >- <td>[% lateorder.claims.count | html %]</td> >- <td data-order="[% lateorder.claims.last.claimed_on | html %]"> >- [% FOR claim IN lateorder.claims %] >- [% claim.claimed_on | $KohaDates %] >- [% UNLESS loop.last %]<br />[% END %] >- [% END %] >- </td> >- <td> >- [% IF lateorder.order_internalnote %] >- <p class="ordernote"> >- <span id="internal-note-[% lateorder.ordernumber | html %]">[% lateorder.order_internalnote | html %]</span> >- <a >- class="edit_note no-export" >- data-ordernumber="[% lateorder.ordernumber | html %]" >- data-note_type="internal" >- href="/cgi-bin/koha/acqui/modordernotes.pl?ordernumber=[% lateorder.ordernumber | html %]&type=internal" >- title="Edit internal note" >- > >- <i class="fa-solid fa-pencil" aria-hidden="true"></i> Edit internal note >- </a> >- </p> >- [% ELSE %] >- <a >- class="edit_note no-export" >- data-ordernumber="[% lateorder.ordernumber | html %]" >- data-note_type="internal" >- href="/cgi-bin/koha/acqui/modordernotes.pl?ordernumber=[% lateorder.ordernumber | html %]&type=internal" >- title="Add internal note" >- > >- <i class="fa fa-plus"></i> Add internal note >- </a> >- [% END %] >- </td> >- <td> >- [% IF lateorder.order_vendornote %] >- <p class="ordernote"> >- <span id="vendor-note-[% lateorder.ordernumber | html %]">[% lateorder.order_vendornote | html %]</span> >- <a >- class="edit_note no-export" >- data-ordernumber="[% lateorder.ordernumber | html %]" >- data-note_type="vendor" >- href="/cgi-bin/koha/acqui/modordernotes.pl?ordernumber=[% lateorder.ordernumber | html %]&type=vendor" >- title="Edit vendor note" >- > >- <i class="fa-solid fa-pencil" aria-hidden="true"></i> Edit vendor note >- </a> >- </p> >- [% ELSE %] >- <a >- class="edit_note no-export" >- data-ordernumber="[% lateorder.ordernumber | html %]" >- data-note_type="vendor" >- href="/cgi-bin/koha/acqui/modordernotes.pl?ordernumber=[% lateorder.ordernumber | html %]&type=vendor" >- title="Add vendor note" >- > >- <i class="fa fa-plus"></i> Add vendor note >- </a> >- [% END %] >- </td> >- <td>[% lateorder.biblio.biblioitem.isbn | $raw %]</td> >- </tr> >+ <form action="lateorders.pl" name="claim" method="post"> >+ [% INCLUDE 'csrf-token.inc' %] >+ <input type="hidden" name="op" value="cud-send_alert" /> >+ [% IF ( letters ) %] >+ <p >+ ><label for="letter_code">Claim using notice: </label >+ ><select name="letter_code" id="letter_code"> >+ [% FOREACH letter IN letters %] >+ <option value="[% letter.code | html %]">[% letter.name | html %]</option> > [% END %] >- </tbody> >- <tfoot> >- <tr> >- <th colspan="6">Total</th> >- <th>[% total_quantity | html %]</th> >- <th>[% total | $Price %]</th> >- <th colspan="10"> </th> >- </tr> >- </tfoot> >- </table> >- >- <fieldset class="action"> >- <div class="btn-group"> >- <a id="exportbutton" class="btn btn-default" href="/cgi-bin/koha/acqui/lateorders-export.pl"><i class="fa fa-download"></i> Export as CSV</a> >- <a class="btn btn-default dropdown-toggle" data-bs-toggle="dropdown" aria-expanded="false"></a> >- <ul class="dropdown-menu" id="export-csv-menu"> >- <li><a class="dropdown-item dropdown-menu-end" href="#">Default</a></li> >- [% IF csv_profiles.count %] >- [% FOR csv IN csv_profiles %] >- <li><a class="dropdown-item" href="#" data-value="[% csv.export_format_id | html %]">[% csv.profile | html %]</a></li> >- [% END %] >+ </select> >+ </p> >+ [% END %] >+ <p> >+ <a id="CheckAll" href="#"><i class="fa fa-check"></i> Check all</a> >+ <a id="CheckNone" href="#"><i class="fa fa-times"></i> Uncheck all</a> >+ </p> >+ <table id="late_orders"> >+ <thead> >+ <tr> >+ <th class="no-sort"></th> >+ <th>Order line</th> >+ <th>Order date</th> >+ <th>Estimated delivery date</th> >+ <th>Vendor</th> >+ <th class="anti-the">Information</th> >+ <th>Quantity</th> >+ <th>Total cost</th> >+ <th>Basket</th> >+ <th>Basket date</th> >+ <th>Basket group</th> >+ <th>Library</th> >+ <th>Budget</th> >+ <th>Fund</th> >+ <th>Claims count</th> >+ <th>Claimed date</th> >+ <th>Internal note</th> >+ <th>Vendor note</th> >+ <th>ISBN</th> >+ </tr> >+ </thead> >+ </table> >+ >+ <fieldset class="action"> >+ <div class="btn-group"> >+ <a id="exportbutton" class="btn btn-default" href="/cgi-bin/koha/acqui/lateorders-export.pl"><i class="fa fa-download"></i> Export as CSV</a> >+ <a class="btn btn-default dropdown-toggle" data-bs-toggle="dropdown" aria-expanded="false"></a> >+ <ul class="dropdown-menu" id="export-csv-menu"> >+ <li><a class="dropdown-item dropdown-menu-end" href="#">Default</a></li> >+ [% IF csv_profiles.count %] >+ [% FOR csv IN csv_profiles %] >+ <li><a class="dropdown-item" href="#" data-value="[% csv.export_format_id | html %]">[% csv.profile | html %]</a></li> > [% END %] >- </ul> >- </div> >- >- <input type="submit" class="btn btn-default" value="Claim order" /> >- </fieldset> >- </form> >- [% ELSE %] >- <p>There are no late orders.</p> >- [% END %] >+ [% END %] >+ </ul> >+ </div> >+ >+ <input type="submit" class="btn btn-default" value="Claim order" /> >+ </fieldset> >+ </form> > </div> > <!-- /#acqui_lateorders --> > </main> >@@ -276,42 +122,36 @@ > > <div class="col-md-2 order-sm-2 order-md-1"> > <aside> >- <form action="lateorders.pl" method="get"> >+ <form method="get" id="late_orders_filter_form"> > <fieldset class="brief"> >- <h4>Filter results:</h4> >- [% FOREACH ERROR_LOO IN ERROR_LOOP %] >- [% IF ( ERROR_LOO.delay_digits ) %]<p class="error">The number of days ([% ERROR_LOO.bad_delay | html %]) must be a number between 0 and 999.</p>[% END %] >- [% END %] >+ <h3>Filters:</h3> > <ol> >- <li><label for="delay">Order date:</label><input size="3" maxlength="3" id="delay" type="text" name="delay" value="[% delay | html %]" /> days ago</li> >- <li >- ><label for="from">Estimated delivery date from: </label> >- <input type="text" size="10" id="from" name="estimateddeliverydatefrom" value="[% estimateddeliverydatefrom | html %]" class="flatpickr" data-date_to="to" /> >- <div class="hint">[% INCLUDE 'date-format.inc' %]</div> >+ <li> >+ <label for="late_delay">Order date:</label> >+ <input size="3" maxlength="3" id="late_delay" type="text" name="late_delay" value="0" /> days ago > </li> >- <li >- ><label for="to">To: </label> >- <input type="text" size="10" id="to" name="estimateddeliverydateto" value="[% estimateddeliverydateto | html %]" class="flatpickr" /> >- <div class="hint">[% INCLUDE 'date-format.inc' %]</div> >+ <li> >+ <label for="estimated_deliverydate_from">Estimated delivery date from:</label> >+ <input type="text" name="estimated_deliverydate_from" id="estimated_deliverydate_from" class="flatpickr" data-date_to="estimated_deliverydate_from" /> >+ </li> >+ <li> >+ <label for="estimated_deliverydate_to">To:</label> >+ <input type="text" name="estimated_deliverydate_to" id="estimated_deliverydate_to" class="flatpickr" data-date_to="estimated_deliverydate_to" /> > </li> >- > <li >- ><label for="booksellerid">Vendor:</label> >- <select id="booksellerid" tabindex="" name="booksellerid"> >- <option value=""></option> >- [% FOREACH bookseller IN booksellers %] >- [% IF bookseller.id == bookseller_filter.id %] >- <option value="[% bookseller.id | html %]" selected="selected">[% bookseller.name | html %]</option> >- [% ELSE %] >- <option value="[% bookseller.id | html %]">[% bookseller.name | html %]</option> >- [% END %] >- [% END %] >+ ><label for="vendor_filter">Vendor:</label> >+ <select id="vendor_filter" tabindex="" name="vendor_filter"> >+ <option value="">All vendors</option> > </select> >- </li></ol >- > >+ </li> >+ </ol> >+ </fieldset> >+ <fieldset class="action"> >+ <input type="submit" class="btn btn-primary" value="Filter" /> >+ <input type="button" value="Clear" class="clear_search" /> > </fieldset> >- <fieldset class="action"><input type="submit" class="btn btn-primary" value="Filter" /></fieldset> > </form> >+ <!-- /#late_orders_filter_form, --> > [% INCLUDE 'acquisitions-menu.inc' %] > </aside> > </div> >@@ -388,18 +228,6 @@ > > $(document).ready(function() { > >- var table_settings = [% TablesSettings.GetTableSettings( 'acqui', 'lateorders', 'late_orders', 'json' ) | $raw %]; >- late_orderst = $("#late_orders").kohaTable({ >- "sorting": [[ 1, "asc" ]], >- "pagingType": "full", >- "autoWidth": false, >- "drawCallback": function() { >- if ( typeof late_orderst != 'undefined' ) { >- check_uncheck(); >- $('input:checkbox[name=ordernumber]').bind('click', check_uncheck); >- }; >- } >- }, table_settings ); > $('input:checkbox[name=ordernumber]').bind('click', check_uncheck); > $('#CheckAll').click(function(e){ > e.preventDefault(); >@@ -410,7 +238,270 @@ > $("#late_orders input:checkbox").prop("checked", false); > }); > >- // Generates a dynamic link for exporting the selection's data as CSV >+ const buildQuery = () => { >+ const late_delay = parseInt($("#late_delay").val()); >+ const estimated_deliverydate_from = $("#estimated_deliverydate_from").val(); >+ const estimated_deliverydate_to = $("#estimated_deliverydate_to").val(); >+ >+ const queryParams = [ >+ ["only_late", "1"], >+ ...(Number.isNaN(late_delay) ? [] : [["late_delay", late_delay]]), >+ ...(estimated_deliverydate_from ? [["estimated_deliverydate_from", estimated_deliverydate_from]] : []), >+ ...(estimated_deliverydate_to ? [["estimated_deliverydate_to", estimated_deliverydate_to]] : []), >+ ]; >+ >+ return '/api/v1/acquisitions/orders?' + queryParams >+ .map(([key, value]) => `${key}=${encodeURIComponent(value)}`) >+ .join("&"); >+ } >+ >+ let additional_filters = { >+ "basket.vendor_id": () => { >+ let vendor_id = $("#vendor_filter").val(); >+ if (!vendor_id) return ""; >+ return { "=": vendor_id }; >+ } >+ }; >+ >+ var table_settings = [% TablesSettings.GetTableSettings( 'acqui', 'lateorders', 'late_orders', 'json' ) | $raw %]; >+ var late_orderst = $("#late_orders").kohaTable({ >+ order: [[ 1, "asc" ]], >+ paging: true, >+ embed: [ >+ "basket.authorizer+strings", >+ "basket.basket_group", >+ "basket.late_since_days", >+ "basket.vendor", >+ "biblio", >+ "claims+count", >+ "fund.budget" >+ ], >+ ajax: { >+ url: buildQuery(), >+ }, >+ columns: [ >+ { >+ data: "order_id", // checkbox >+ orderable: false, >+ searchable: false, >+ render: function(data, type, row, meta) { >+ return '<input type="checkbox" value="%s" data-booksellerid="%s" name="ordernumber" />'.format(escape_str(data),escape_str(row.basket.vendor_id)); >+ } >+ }, >+ { >+ data: "order_id", >+ orderable: true, >+ searchable: true >+ }, >+ { >+ data: "basket.close_date", >+ type: "date", >+ orderable: true, >+ render: function(data, type, row, meta) { >+ return '%s (%s)'.format($date(data),_("%s days").format(escape_str(row.basket.late_since_days))); >+ } >+ }, >+ { >+ data: "estimated_delivery_date", >+ type: "date", >+ orderable: true, >+ render: function(data, type, row, meta) { >+ return '<p class="delivery_date"><span>%s</span>'.format($date(data)) >+ [% IF CAN_user_acquisition_order_manage %] >+ + '<a class="edit_delivery_date no-export" data-ordernumber="%s" '.format(escape_str(row.order_id)) >+ + 'data-delivery_date="%s" id="delivery_date_%s" '.format(escape_str(data),escape_str(row.order_id)) >+ + 'href="/cgi-bin/koha/acqui/moddeliverydate.pl?ordernumber=%s" title="%s">'.format(encodeURIComponent(row.order_id),_("Edit delivery date")) >+ + '<i class="fa-solid fa-pencil" aria-hidden="true"></i> %s</a>'.format(_("Edit")) >+ [% END %] >+ + '</p>'; >+ } >+ }, >+ { >+ data: 'basket.vendor.name', >+ orderable: false, >+ searchable: true, >+ render: function(data, type, row, meta) { >+ return '%s (%s)'.format(escape_str(data), escape_str(row.basket.vendor_id)); >+ } >+ }, >+ { >+ [% SET summary_fields = "biblio.title:biblio.author:biblio.isbn:biblio.publisher:me.internal_note:me.vendor_note" %] >+ [% IF Koha.Preference('marcflavour')=='UNIMARC' %][% SET summary_fields = summary_fields _ ":biblio.ean" %][% END %] >+ "data": "[% summary_fields | html %]", >+ "render": function(data, type, row, meta) { >+ var result = ''; >+ if ( row && row.biblio_id != null ) { >+ result = '<p><span class="title"><a href="/cgi-bin/koha/catalogue/detail.pl?biblionumber=%s">%s</a></span>'.format(encodeURIComponent(row.biblio_id),escape_str(row.biblio.title)); >+ if ( row.biblio.author != null ) >+ result += '<br /><em>%s:</em> %s'.format(_("Author"),escape_str(row.biblio.author)); >+ if ( row.biblio.publisher != null ) { >+ result += '<br /><em>%s:</em> %s'.format(_("Published by"),escape_str(row.biblio.publisher)); >+ if ( row.biblio.publication_year != null ) { >+ result += '<em> %s </em> %s'.format(__px("Published in <date>","in"),escape_str(row.biblio.publication_year)); >+ } >+ } >+ result += '</p>'; >+ } >+ >+ return result; >+ }, >+ "orderable": true, >+ }, >+ { >+ data: 'quantity', >+ orderable: true, >+ searchable: true >+ }, >+ { >+ data: "", // total cost, calculated >+ orderable: false, >+ searchable: false, >+ render: function(data, type, row, meta) { >+ let reminder_qty = (row.quantity - row.quantity_received); >+ let subtotal = reminder_qty * row.replacement_price; >+ return '%s x %s = %s'.format( escape_price(row.replacement_price), reminder_qty, escape_price(subtotal) ); >+ } >+ }, >+ { >+ data: 'basket.name', >+ orderable: true, >+ searchable: true, >+ render: function(data, type, row, meta) { >+ var basket_name = '%s (%s)'.format(escape_str(data),escape_str(row.basket_id)); >+ [% IF ( CAN_user_acquisition_order_manage ) %] >+ return '<a href="basket.pl?basketno="%s" title="%s">%s</a>'.format(encodeURIComponent(row.basket_id),escape_str(data),basket_name); >+ [% ELSE %] >+ return basket_name; >+ [% END %] >+ } >+ }, >+ { >+ data: 'basket.creation_date', >+ orderable: true, >+ render: function(data, type, row, meta) { >+ return $date(data); >+ } >+ }, >+ { >+ data: 'basket.basket_group_id', >+ orderable: true, >+ searchable: true, >+ render: function(data, type, row, meta) { >+ if ( data != null ) { >+ [%- IF CAN_user_acquisition_group_manage -%] >+ return '<a href="basketgroup.pl?op=add&booksellerid=%s&basketgroupid=%s" title="basketgroup">%s (%s)</a>' >+ .format(encodeURIComponent(row.vendor_id),encodeURIComponent(data),row.basket.basket_group.name, data); >+ [%- ELSE -%] >+ return '%s (%s)'.format(row.basket.basket_group.name, data); >+ [%- END -%] >+ } else { return ''; } >+ } >+ }, >+ { >+ data: 'basket.authorizer.library_id', >+ orderable: false, >+ searchable: false, >+ render: function(data, type, row, meta) { >+ return escape_str(row.basket.authorizer._strings.library_id.str); >+ } >+ }, >+ { >+ data: 'fund.budget.budget_period_description', >+ orderable: true, >+ searchable: true >+ }, >+ { >+ data: 'fund.name', >+ orderable: true, >+ searchable: true >+ }, >+ { >+ data: 'claims_count', >+ orderable: true, >+ searchable: false >+ }, >+ { >+ data: 'claims', >+ orderable: false, >+ searchable: false, >+ render: function(data, type, row, meta) { >+ return data != undefined ? data.map(item => $date(item.date_claimed)).join('<br/>') : ''; >+ } >+ }, >+ { >+ data: "", // internal_note >+ orderable: false, >+ searchable: false, >+ render: function(data, type, row, meta) { >+ if ( row.internal_note != null && row.internal_note != '' ) { >+ return '<p class="ordernote">' >+ + '<span id="internal-note-%s">%s</span>'.format(row.order_id,escape_str(row.internal_note)) >+ + '<a class="edit_note no-export" data-ordernumber="%s" '.format(row.order_id) >+ + 'data-note_type="internal" href="/cgi-bin/koha/acqui/modordernotes.pl?ordernumber=%s&type=internal" '.format(encodeURIComponent(row.order_id)) >+ + 'title="Edit internal note"><i class="fa-solid fa-pencil" aria-hidden="true"></i> Edit internal note</a></p>'.format(_("Edit internal note"),_("Edit internal note")); >+ } >+ else { >+ return '<a class="edit_note no-export" data-ordernumber="%s" '.format(row.order_id) >+ + 'data-note_type="internal" href="/cgi-bin/koha/acqui/modordernotes.pl?ordernumber=%s&type=internal" '.format(encodeURIComponent(row.order_id)) >+ + 'title="%s"><i class="fa fa-plus"></i> %s</a>'.format(_("Add internal note"),_("Add internal note")); >+ } >+ >+ } >+ }, >+ { >+ data: "", // vendor_note >+ orderable: false, >+ searchable: false, >+ render: function(data, type, row, meta) { >+ if ( row.vendor_note != null && row.vendor_note != '' ) { >+ return '<p class="ordernote"><span id="vendor-note-%s">%s</span>'.format(row.order_id,escape_str(row.vendor_note)) >+ + '<a class="edit_note no-export" data-ordernumber="%s" data-note_type="vendor" '.format(row.order_id) >+ + 'href="/cgi-bin/koha/acqui/modordernotes.pl?ordernumber=%s&type=vendor" '.format(encodeURIComponent(row.order_id)) >+ + 'title="%s"><i class="fa-solid fa-pencil" aria-hidden="true"></i> Edit vendor note</a></p>'.format(_("Edit vendor note"),_("Edit vendor note")); >+ } >+ else { >+ return '<a class="edit_note no-export" data-ordernumber="%s" data-note_type="vendor" '.format(row.order_id) >+ + 'href="/cgi-bin/koha/acqui/modordernotes.pl?ordernumber=%s&type=vendor" '.format(row.order_id) >+ + 'title="%s"><i class="fa fa-plus"></i> %s</a>'.format(_("Add vendor note"),_("Add vendor note")); >+ } >+ } >+ }, >+ { >+ data: 'biblio.isbn', >+ orderable: true, >+ searchable: true >+ } >+ ] >+ }, >+ table_settings, >+ false, // add_column_filters >+ additional_filters, // default_filters >+ undefined, // filters_options >+ undefined, //external_filter_nodes >+ ); >+ >+ const redrawTable = () => { >+ late_orderst.api().ajax.url(buildQuery()).load(); >+ }; >+ >+ const clearFilters = () => { >+ $("#late_delay").val("0"); >+ $("#estimated_deliverydate_from")[0]._flatpickr?.clear(); >+ $("#estimated_deliverydate_to")[0]._flatpickr?.clear(); >+ $("#vendor_filter").val("").trigger('change'); >+ >+ redrawTable(); >+ }; >+ >+ $("#late_orders_filter_form").on("submit", (e) => { >+ e.preventDefault(); >+ redrawTable(); >+ }); >+ >+ // Clear all filters >+ $(".clear_search").click(clearFilters); >+ >+ // Generates a dynamic link for exporting the selection's data as CSV > $("#exportbutton, #export-csv-menu a").click(function() { > var all_nodes = late_orderst.DataTable().rows().nodes(); > var selected = $(all_nodes).find("input[name='ordernumber']:checked"); >@@ -474,6 +565,38 @@ > $("#estimated_delivery_date").html( "" ); > $("#date_ordernumber").val(""); > }); >+ >+ function populateVendorsFilter() { >+ $.ajax({ >+ type: "GET", >+ url: "/api/v1/acquisitions/vendors", >+ success: function (vendors) { >+ vendors >+ .sort((a, b) => >+ a.name.localeCompare(b.name) >+ ) >+ .forEach(function (vendor) { >+ if ( >+ $( >+ "#vendor_filter option[value=" + >+ vendor.id + >+ "]" >+ ).length == 0 >+ ) { >+ $("#vendor_filter").append( >+ '<option value="' + >+ vendor.id + >+ '">' + >+ vendor.name + >+ "</option>" >+ ); >+ } >+ }); >+ }, >+ }); >+ } >+ >+ populateVendorsFilter(); > }); > </script> > [% END %] >-- >2.49.0
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 32266
:
144145
|
144165
|
144699
|
182041
|
182042
| 182043 |
182269