From 58893050b93731a3cfa1ad3df2df58c4d81953d4 Mon Sep 17 00:00:00 2001 From: Jonathan Druart Date: Tue, 11 Apr 2023 23:01:53 +0200 Subject: [PATCH] Bug 33105: Add vendor issues Content-Type: text/plain; charset=utf-8 This patch is the main patch of this patch set, it contains the controller acqui/vendor_issues.pl, its corresponding template, and some links to this script. It adds: * A new DB table aqbookseller_issues linked with the aqbooksellers table * A new subpermission acquisition.issue_manage * A new authorised value category VENDOR_ISSUE_TYPE and two examples MAINTENANCE and OUTAGE * A new controller couple acqui/vendor_issues.[pl,tt] Test plan: 0. Apply the patches, run updatedatabase and restart_all 1. Go to the acquisition module, create a new vendor or use an existing one 2. Create a couple of issues for this vendor 3. Edit/Delete and search for those issues This is the basics for tracking issues with vendors. Suggestions welcome, on follow-up bug reports. Signed-off-by: Jonathan Field --- acqui/vendor_issues.pl | 113 +++++++ .../prog/en/includes/permissions.inc | 5 + .../prog/en/includes/vendor-menu.inc | 1 + .../prog/en/modules/acqui/vendor_issues.tt | 282 ++++++++++++++++++ .../en/modules/admin/authorised_values.tt | 2 + 5 files changed, 403 insertions(+) create mode 100755 acqui/vendor_issues.pl create mode 100644 koha-tmpl/intranet-tmpl/prog/en/modules/acqui/vendor_issues.tt diff --git a/acqui/vendor_issues.pl b/acqui/vendor_issues.pl new file mode 100755 index 0000000000..561769c28e --- /dev/null +++ b/acqui/vendor_issues.pl @@ -0,0 +1,113 @@ +#!/usr/bin/perl + +# Copyright 2023 Koha Development Team +# +# This file is part of Koha. +# +# Koha is free software; you can redistribute it and/or modify it +# under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 3 of the License, or +# (at your option) any later version. +# +# Koha is distributed in the hope that it will be useful, but +# WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with Koha; if not, see . + +use Modern::Perl; +use CGI qw ( -utf8 ); +use Try::Tiny; +use C4::Context; +use C4::Auth qw( get_template_and_user ); +use C4::Output qw( output_html_with_http_headers ); + +use Koha::Acquisition::Booksellers; + +my $input = CGI->new; +my $booksellerid = $input->param('booksellerid'); +my $issue_id = $input->param('issue_id'); +my $op = $input->param('op') || 'list'; +my @messages; + +my ( $template, $loggedinuser, $cookie ) = get_template_and_user( + { + template_name => "acqui/vendor_issues.tt", + query => $input, + type => "intranet", + flagsrequired => { acquisition => 'issues_manage' }, + } +); + +my $issue; +if ( $issue_id ) { + $issue = Koha::Acquisition::Bookseller::Issues->find($issue_id); + $booksellerid = $issue->vendor_id; +} +my $vendor = Koha::Acquisition::Booksellers->find($booksellerid); + +if ( $op eq 'add_form' || $op eq 'show' ) { + $template->param( issue => $issue ); +} elsif ( $op eq 'add_validate' ) { + my $type = $input->param('type'); + my $started_on = $input->param('started_on'); + my $ended_on = $input->param('ended_on'); + my $notes = $input->param('notes'); + + if ($issue_id) { + try { + $issue->set( + { + type => $type, + started_on => $started_on, + ended_on => $ended_on, + notes => $notes + } + )->store; + push @messages, { type => 'message', code => 'success_on_update' }; + } catch { + push @messages, { type => 'error', code => 'error_on_update' }; + }; + } else { + try { + Koha::Acquisition::Bookseller::Issue->new( + { + vendor_id => $booksellerid, + type => $type, + started_on => $started_on, + ended_on => $ended_on, + notes => $notes, + } + )->store; + push @messages, { type => 'message', code => 'success_on_insert' }; + } catch { + push @messages, { type => 'error', code => 'error_on_insert' }; + }; + } + $op = 'list'; +} elsif ( $op eq 'delete_confirm' ) { + $template->param( issue => $issue ); +} elsif ( $op eq 'delete_confirmed' ) { + try { + $issue->delete; + push @messages, { type => 'message', code => 'success_on_delete' }; + } catch { + push @messages, { type => 'error', code => 'error_on_delete' }; + }; + $op = 'list'; +} + +if ( $op eq 'list' ) { + $template->param( issues_count => $vendor->issues->search->count ); +} + +$template->param( + messages => \@messages, + op => $op, + vendor => $vendor, + booksellerid => $vendor->id, # Used by vendor-menu.inc +); + +output_html_with_http_headers $input, $cookie, $template->output; diff --git a/koha-tmpl/intranet-tmpl/prog/en/includes/permissions.inc b/koha-tmpl/intranet-tmpl/prog/en/includes/permissions.inc index 9466b94cf7..f718ee8260 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/includes/permissions.inc +++ b/koha-tmpl/intranet-tmpl/prog/en/includes/permissions.inc @@ -454,6 +454,11 @@ Manage all baskets and order lines, regardless of restrictions on them ([% name | html %]) + [%- CASE 'issue_manage' -%] + + Manage issues + + ([% name | html %]) [%- CASE 'order_receive' -%] Receive orders and manage shipments diff --git a/koha-tmpl/intranet-tmpl/prog/en/includes/vendor-menu.inc b/koha-tmpl/intranet-tmpl/prog/en/includes/vendor-menu.inc index 3fc669e840..82415521c0 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/includes/vendor-menu.inc +++ b/koha-tmpl/intranet-tmpl/prog/en/includes/vendor-menu.inc @@ -4,6 +4,7 @@ [% IF ( CAN_user_acquisition_order_manage ) %]
  • Baskets
  • [% END %] [% IF ( CAN_user_acquisition_group_manage ) %]
  • Basket groups
  • [% END %] [% IF ( CAN_user_acquisition_contracts_manage ) %]
  • Contracts
  • [% END %] + [% IF ( CAN_user_acquisition_issue_manage ) %]
  • Issues
  • [% END %]
  • Invoices
  • [% IF ( CAN_user_acquisition_order_manage ) %][% IF ( basketno ) %]
  • Uncertain prices
  • diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/acqui/vendor_issues.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/acqui/vendor_issues.tt new file mode 100644 index 0000000000..4a6a672875 --- /dev/null +++ b/koha-tmpl/intranet-tmpl/prog/en/modules/acqui/vendor_issues.tt @@ -0,0 +1,282 @@ +[% USE raw %] +[% USE Asset %] +[% USE AuthorisedValues %] +[% USE KohaDates %] +[% SET footerjs = 1 %] +[% INCLUDE 'doc-head-open.inc' %] + + [% IF op =='add_form' %] + [% IF issue.issue_id %] + Modify vendor issue + [% ELSE %] + New vendor issue + [% END %] › [% ELSE %] + [% IF op == 'delete_confirm' %] + Confirm deletion of vendor issue › [% END %] + [% END %] + Vendor issue › Acquisition › Koha + +[% INCLUDE 'doc-head-close.inc' %] + + + +[% WRAPPER 'header.inc' %] + [% INCLUDE 'acquisitions-search.inc' %] +[% END %] + +[% WRAPPER 'sub-header.inc' %] + +[% END %] + +
    +
    +
    +
    + +[% FOR m IN messages %] +
    + [% SWITCH m.code %] + [% CASE 'error_on_update' %] + An error occurred when updating this issue. + [% CASE 'error_on_insert' %] + An error occurred when adding this issue + [% CASE 'error_on_delete' %] + An error occurred when deleting this issue. Check the logs. + [% CASE 'success_on_update' %] + Issue updated successfully. + [% CASE 'success_on_insert' %] + Issue created successfully. + [% CASE 'success_on_delete' %] + Issue deleted successfully. + [% CASE %] + [% m.code | html %] + [% END %] +
    +[% END %] + +[% IF op == 'add_form' %] + [% IF issue %] +

    Modify a vendor issue

    + [% ELSE %] +

    New vendor issue

    + [% END %] + +
    + + + + +
    +
      + [% IF issue %] +
    1. Issue ID: [% issue.issue_id | html %]
    2. + [% END %] +
    3. + + [% PROCESS 'av-build-dropbox.inc' name="type", category="VENDOR_ISSUE_TYPE", default=issue.type, empty=1, size = 20 %] +
    4. +
    5. + + +
      [% INCLUDE 'date-format.inc' %]
      +
    6. +
    7. + + +
      [% INCLUDE 'date-format.inc' %]
      +
    8. +
    9. + + +
    10. +
    +
    + +
    + + Cancel +
    +
    +[% END %] + +[% IF op == 'delete_confirm' %] +
    +

    Delete issue #[% issue.issue_id | html %]?

    +
    + + + +
    +
    + +
    +

    +[% END %] + +[% IF op == 'show' %] +

    Vendor issue #[% issue.issue_id | html %]

    + +
    +
      + [% IF issue %] +
    1. Issue ID: [% issue.issue_id | html %]
    2. + [% END %] +
    3. + + [% AuthorisedValues.GetByCode( 'VENDOR_ISSUE_TYPE', issue.type, 0 ) | html %] +
    4. +
    5. + + [% issue.started_on | $KohaDates %] +
    6. +
    7. + + [% issue.ended_on | $KohaDates %] +
    8. +
    9. + + [% issue.notes | html %] +
    10. +
    +
    + +
    + Back +
    + +[% END %] +[% IF op == 'list' %] + + + +

    Vendor issues

    + + [% IF issues_count > 0 %] +
    +
    + + + + + + + + + + +
    Issue IDTypeStarted onEnded onActions
    +
    + [% ELSE %] +
    + There are no issues defined. Create a new issue. +
    + [% END %] +[% END %] + +
    +
    + +
    + +
    +
    + +[% MACRO jsinclude BLOCK %] + [% Asset.js("js/acquisitions-menu.js") | $raw %] + [% INCLUDE 'calendar.inc' %] + [% INCLUDE 'datatables.inc' %] + +[% END %] +[% INCLUDE 'intranet-bottom.inc' %] diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/authorised_values.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/admin/authorised_values.tt index 1a5265ff3b..9609fc38bc 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/authorised_values.tt +++ b/koha-tmpl/intranet-tmpl/prog/en/modules/admin/authorised_values.tt @@ -497,6 +497,8 @@

    Values that can be entered to fill in the 'Vendor type' field in the acquisitions module, that can be used for statistical purposes

    [% CASE 'VENDOR_INTERFACE_TYPE' %]

    Values that can be entered to fill in the 'Vendor interface type' field in the acquisitions module

    + [% CASE 'VENDOR_ISSUE_TYPE' %] +

    Values that can be entered to fill in the 'Vendor issue type' field in the acquisitions module

    [% CASE 'WITHDRAWN' %]

    Description of a withdrawn item (appears when adding or editing an item)

    [% CASE 'YES_NO' %] -- 2.30.2