Bugzilla – Attachment 173056 Details for
Bug 34355
Automated MARC record ordering process
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 34355: Add account creation
Bug-34355-Add-account-creation.patch (text/plain), 22.33 KB, created by
Matt Blenkinsop
on 2024-10-21 14:40:06 UTC
(
hide
)
Description:
Bug 34355: Add account creation
Filename:
MIME Type:
Creator:
Matt Blenkinsop
Created:
2024-10-21 14:40:06 UTC
Size:
22.33 KB
patch
obsolete
>From 39c8b80da2ded82ac85d23959631dc708c0c8cdb Mon Sep 17 00:00:00 2001 >From: Matt Blenkinsop <matt.blenkinsop@ptfs-europe.com> >Date: Mon, 24 Jul 2023 13:52:41 +0000 >Subject: [PATCH] Bug 34355: Add account creation > >Signed-off-by: Andrew Fuerste Henry <andrewfh@dubcolib.org> >--- > Koha/MarcOrderAccount.pm | 63 +++++ > Koha/MarcOrderAccounts.pm | 51 ++++ > admin/marc_order_accounts.pl | 131 ++++++++++ > .../en/modules/admin/marc_order_accounts.tt | 246 ++++++++++++++++++ > 4 files changed, 491 insertions(+) > create mode 100644 Koha/MarcOrderAccount.pm > create mode 100644 Koha/MarcOrderAccounts.pm > create mode 100644 admin/marc_order_accounts.pl > create mode 100644 koha-tmpl/intranet-tmpl/prog/en/modules/admin/marc_order_accounts.tt > >diff --git a/Koha/MarcOrderAccount.pm b/Koha/MarcOrderAccount.pm >new file mode 100644 >index 00000000000..4c122200aa1 >--- /dev/null >+++ b/Koha/MarcOrderAccount.pm >@@ -0,0 +1,63 @@ >+package Koha::MarcOrderAccount; >+ >+# 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 <http://www.gnu.org/licenses>. >+ >+use Modern::Perl; >+ >+use Koha::Database; >+ >+use base qw(Koha::Object); >+ >+=head1 NAME >+ >+Koha::MarcOrderAccount - Koha Marc Ordering Account Object class >+ >+=head1 API >+ >+=head2 Class Methods >+ >+=cut >+ >+=head3 vendor >+ >+=cut >+ >+sub vendor { >+ my ($self) = @_; >+ my $vendor_rs = $self->_result->vendor; >+ return unless $vendor_rs; >+ return Koha::Acquisition::Bookseller->_new_from_dbic($vendor_rs); >+} >+ >+=head3 budget >+ >+=cut >+ >+sub budget { >+ my ($self) = @_; >+ my $budget_rs = $self->_result->budget; >+ return Koha::Acquisition::Fund->_new_from_dbic($budget_rs); >+} >+ >+=head3 _type >+ >+=cut >+ >+sub _type { >+ return 'MarcOrderAccount'; >+} >+ >+1; >diff --git a/Koha/MarcOrderAccounts.pm b/Koha/MarcOrderAccounts.pm >new file mode 100644 >index 00000000000..f6ee407d658 >--- /dev/null >+++ b/Koha/MarcOrderAccounts.pm >@@ -0,0 +1,51 @@ >+package Koha::MarcOrderAccounts; >+ >+# 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 <http://www.gnu.org/licenses>. >+ >+use Modern::Perl; >+ >+use Koha::Database; >+use Koha::MarcOrderAccount; >+ >+use base qw(Koha::Objects); >+ >+=head1 NAME >+ >+Koha::MarcOrderAccount - Koha Marc Ordering Account Object class >+ >+=head1 API >+ >+=head2 Class Methods >+ >+=cut >+ >+=head3 type >+ >+=cut >+ >+sub _type { >+ return 'MarcOrderAccount'; >+} >+ >+=head3 object_class >+ >+=cut >+ >+sub object_class { >+ return 'Koha::MarcOrderAccount'; >+} >+ >+1; >diff --git a/admin/marc_order_accounts.pl b/admin/marc_order_accounts.pl >new file mode 100644 >index 00000000000..c0e1bf25cb1 >--- /dev/null >+++ b/admin/marc_order_accounts.pl >@@ -0,0 +1,131 @@ >+#!/usr/bin/perl >+ >+# A script that allows the user to create an account and profile for auto-creating orders from imported marc files >+# The script displays account details and allows account creation/editing in the first instance >+# If the "run" operation is passed then the script will run the process of creating orders >+ >+# Copyright 2023 PTFS Europe Ltd >+# >+# 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 <http://www.gnu.org/licenses>. >+ >+use Modern::Perl; >+use CGI qw ( -utf8 ); >+ >+use C4::Context; >+use C4::Auth qw( get_template_and_user ); >+use C4::Budgets qw( GetBudgets ); >+use C4::Output qw( output_html_with_http_headers ); >+use C4::Matcher; >+ >+use Koha::UploadedFiles; >+use Koha::ImportBatchProfiles; >+use Koha::MarcOrder; >+use Koha::Acquisition::Booksellers; >+use Koha::MarcOrderAccount; >+use Koha::MarcOrderAccounts; >+ >+my $input = CGI->new; >+ >+my ( $template, $loggedinuser, $cookie ) = get_template_and_user( >+ { >+ template_name => "admin/marc_order_accounts.tt", >+ query => $input, >+ type => "intranet", >+ } >+); >+ >+my $crypt = Koha::Encryption->new; >+ >+my $op = $input->param('op'); >+$op ||= 'display'; >+ >+if ( $op eq 'acct_form' ) { >+ $template->param( acct_form => 1 ); >+ my @vendors = Koha::Acquisition::Booksellers->search( >+ undef, >+ { >+ columns => [ 'name', 'id' ], >+ order_by => { -asc => 'name' } >+ } >+ )->as_list; >+ my $budgets = GetBudgets(); >+ $template->param( >+ vendors => \@vendors, >+ budgets => $budgets >+ ); >+ my @matchers = C4::Matcher::GetMatcherList(); >+ $template->param( available_matchers => \@matchers ); >+ >+ show_account( $input, $template ); >+} elsif ( $op eq 'delete_acct' ) { >+ show_account( $input, $template ); >+ $template->param( delete_acct => 1 ); >+} else { >+ if ( $op eq 'cud-save' ) { >+ my $fields = { >+ id => scalar $input->param('id'), >+ description => scalar $input->param('description'), >+ vendor_id => scalar $input->param('vendor_id'), >+ budget_id => scalar $input->param('budget_id'), >+ download_directory => scalar $input->param('download_directory'), >+ matcher_id => scalar $input->param('matcher'), >+ overlay_action => scalar $input->param('overlay_action'), >+ nomatch_action => scalar $input->param('nomatch_action'), >+ parse_items => scalar $input->param('parse_items'), >+ item_action => scalar $input->param('item_action'), >+ record_type => scalar $input->param('record_type'), >+ encoding => scalar $input->param('encoding') || 'UTF-8', >+ }; >+ >+ if ( scalar $input->param('id') ) { >+ >+ # Update existing account >+ my $account = Koha::MarcOrderAccounts->find( scalar $input->param('id') ); >+ $account->update($fields); >+ } else { >+ >+ # Add new account >+ my $new_account = Koha::MarcOrderAccount->new($fields); >+ $new_account->store; >+ } >+ } elsif ( $op eq 'cud-delete_acct' ) { >+ my $acct_id = $input->param('id'); >+ my $acct = Koha::MarcOrderAccounts->find($acct_id); >+ $acct->delete; >+ } >+ >+ $template->param( display => 1 ); >+ my @accounts = Koha::MarcOrderAccounts->search( >+ {}, >+ { join => [ 'vendor', 'budget' ] } >+ )->as_list; >+ $template->param( accounts => \@accounts ); >+ >+} >+ >+output_html_with_http_headers $input, $cookie, $template->output; >+ >+sub show_account { >+ my ( $input, $template ) = @_; >+ my $acct_id = $input->param('id'); >+ if ($acct_id) { >+ my $acct = Koha::MarcOrderAccounts->find($acct_id); >+ if ($acct) { >+ $template->param( account => $acct ); >+ } >+ } >+ return; >+} >diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/marc_order_accounts.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/admin/marc_order_accounts.tt >new file mode 100644 >index 00000000000..b81c10b9b51 >--- /dev/null >+++ b/koha-tmpl/intranet-tmpl/prog/en/modules/admin/marc_order_accounts.tt >@@ -0,0 +1,246 @@ >+[% USE raw %] >+[% USE Koha %] >+[% USE Asset %] >+[% PROCESS 'i18n.inc' %] >+[% SET footerjs = 1 %] >+[% INCLUDE 'doc-head-open.inc' %] >+<title> >+MARC Order Accounts >+</title> >+<style> >+ #fileuploadstatus,#fileuploadfailed,#fileuploadcancel { display : none; } >+</style> >+[% INCLUDE 'doc-head-close.inc' %] >+</head> >+<body id="admin_marc_order_acct" class="admin"> >+[% WRAPPER 'header.inc' %] >+ [% INCLUDE 'prefs-admin-search.inc' %] >+[% END %] >+ >+[% WRAPPER 'sub-header.inc' %] >+ [% WRAPPER breadcrumbs %] >+ [% WRAPPER breadcrumb_item %] >+ <a href="/cgi-bin/koha/admin/admin-home.pl">Administration</a> >+ [% END %] >+ >+ [% IF acct_form || delete_confirm %] >+ [% WRAPPER breadcrumb_item %] >+ <a href="/cgi-bin/koha/admin/marc_order_accounts.pl">MARC Order Accounts</a> >+ [% END %] >+ [% ELSE %] >+ [% WRAPPER breadcrumb_item bc_active= 1 %] >+ <span>MARC Order Accounts</span> >+ [% END %] >+ [% END %] >+ [% END #/ WRAPPER breadcrumbs %] >+[% END #/ WRAPPER sub-header.inc %] >+ >+<div class="main container-fluid"> >+ <div class="row"> >+ <div class="col-sm-10 col-sm-push-2"> >+ <main> >+ [% IF display %] >+ <div id="toolbar" class="btn-toolbar"> >+ <a class="btn btn-default" id="newmarcorderacct" href="/cgi-bin/koha/admin/marc_order_accounts.pl?op=acct_form"> >+ <i class="fa fa-plus"></i> >+ New account >+ </a> >+ </div> >+ [% IF ( accounts ) %] >+ <h1>Marc Ordering Accounts</h1> >+ <div class="page-section"> >+ <table> >+ <tr> >+ <th>ID</th> >+ <th>Vendor</th> >+ <th>Budget</th> >+ <th>Description</th> >+ <th>Download directory</th> >+ <th>Actions</th> >+ </tr> >+ [% FOREACH account IN accounts %] >+ <tr> >+ <td>[% account.id | html %]</td> >+ <td><a href="/cgi-bin/koha/acqui/supplier.pl?booksellerid=[% account.vendor_id | uri %]">[% account.vendor.name | html %]</a></td> >+ <td><a href="/cgi-bin/koha/admin/aqbudgets.pl?budget_period_id=[% account.budget.budget_period_id | uri %]">[% account.budget.budget_name | html %]</a></td> >+ <td>[% account.description | html %]</td> >+ <td>[% account.download_directory | html %]</td> >+ <td class="actions"> >+ <a class="btn btn-default btn-xs" href="/cgi-bin/koha/admin/marc_order_accounts.pl?op=acct_form&id=[% account.id | html %]"><i class="fa fa-pencil-alt"></i> Edit</a> >+ <a class="btn btn-default btn-xs" href="/cgi-bin/koha/admin/marc_order_accounts.pl?op=delete_acct&id=[% account.id | html %]"><i class="fa fa-trash-can"></i> Delete</a> >+ </td> >+ </tr> >+ [% END %] >+ </table> >+ </div> >+ [% ELSE %] >+ <div class="dialog message"> >+ There are no MARC Order accounts. >+ </div> >+ [% END %] >+ [% END %] >+ [% IF acct_form %] >+ <h1> >+ [% IF account %] >+ Modify account >+ [% ELSE %] >+ New account >+ [% END %] >+ </h1> >+ <form action="/cgi-bin/koha/admin/marc_order_accounts.pl" name="Actform" method="post"> >+ [% INCLUDE 'csrf-token.inc' %] >+ <input type="hidden" name="op" value="cud-save" /> >+ [% IF account %] >+ <input type="hidden" name="id" value="[% account.id | html %]" /> >+ [% END %] >+ <fieldset class="rows"> >+ <legend>Account details</legend> >+ <ol> >+ <li> >+ <label for="vendor_id">Vendor: </label> >+ <select name="vendor_id" id="vendor_id"> >+ [% FOREACH vendor IN vendors %] >+ [% IF account.vendor_id == vendor.id %] >+ <option value="[% vendor.id | html %]" selected="selected">[% vendor.name | html %]</option> >+ [% ELSE %] >+ <option value="[% vendor.id | html %]">[% vendor.name | html %]</option> >+ [% END %] >+ [% END %] >+ </select> >+ </li> >+ <li> >+ <label for="budget_id">Budget: </label> >+ <select name="budget_id" id="budget_id"> >+ [% FOREACH budget IN budgets %] >+ [% IF account.budget_id == budget.budget_id %] >+ <option value="[% budget.budget_id | html %]" selected="selected">[% budget.budget_name | html %]</option> >+ [% ELSE %] >+ <option value="[% budget.budget_id | html %]">[% budget.budget_name | html %]</option> >+ [% END %] >+ [% END %] >+ </select> >+ <div class="hint">This budget will be used as the fallback value if the MARC records do not contain a mapped value for a budget code.</div> >+ </li> >+ <li> >+ <label for="description">Description: </label> >+ <input type="text" name="description" id="description" size="20" value="[% account.description | html %]" /> >+ </li> >+ <li> >+ <label for="download_directory">Download directory: </label> >+ <input type="text" name="download_directory" id="download_directory" size="20" value="[% account.download_directory | html %]" /> >+ <div class="hint">The download directory specifies the directory in your koha installation that should be searched for new files.</div> >+ </li> >+ </ol> >+ </fieldset> >+ <fieldset class="rows"> >+ <legend>File import settings</legend> >+ <ol> >+ <li> >+ <label for='record_type'>Record type:</label> >+ <select name='record_type' id='record_type'> >+ <option value='biblio' selected='selected'>Bibliographic</option> >+ <option value='auth'>Authority</option> >+ </select> >+ </li> >+ <li> >+ <label for="encoding">Character encoding: </label> >+ <select name="encoding" id="encoding"> >+ <option value="UTF-8" selected="selected">UTF-8 (Default)</option> >+ <option value="MARC-8">MARC 8</option> >+ <option value="ISO_5426">ISO 5426</option> >+ <option value="ISO_6937">ISO 6937</option> >+ <option value="ISO_8859-1">ISO 8859-1</option> >+ <option value="EUC-KR">EUC-KR</option> >+ </select> >+ </li> >+ </ol> >+ </fieldset> >+ <fieldset class="rows"> >+ <legend>Record matching settings</legend> >+ <ol> >+ <li> >+ <label for="matcher">Record matching rule:</label> >+ <select name="matcher" id="matcher"> >+ [% FOREACH available_matcher IN available_matchers %] >+ [% IF available_matcher.id == account.matcher_id %] >+ <option value="[% available_matcher.matcher_id | html %]" selected="selected">[% available_matcher.code | html %] ([% available_matcher.description | html %])</option> >+ [% ELSE %] >+ <option value="[% available_matcher.matcher_id | html %]">[% available_matcher.code | html %] ([% available_matcher.description | html %])</option> >+ [% END %] >+ [% END %] >+ </select> >+ </li> >+ <li> >+ <label for="overlay_action">Action if matching record found: </label> >+ [% INCLUDE 'tools-overlay-action.inc' %] >+ </li> >+ <li> >+ <label for="nomatch_action">Action if no match is found: </label> >+ [% INCLUDE 'tools-nomatch-action.inc' %] >+ </li> >+ </ol> >+ </fieldset> >+ <fieldset class="rows" id="items"> >+ <legend>Check for embedded item record data?</legend> >+ <ol> >+ <li class="radio"> >+ <input type="radio" id="parse_itemsyes" name="parse_items" value="1" checked="checked" /> >+ <label for="parse_itemsyes">Yes</label> >+ </li> >+ <li class="radio"> >+ <input type="radio" id="parse_itemsno" name="parse_items" value="0" /> >+ <label for="parse_itemsno">No</label> >+ </li> >+ </ol> >+ <ol> >+ <li><label for="item_action">How to process items: </label> >+ [% INCLUDE 'tools-item-action.inc' %] >+ </li> >+ </ol> >+ </fieldset> >+ >+ <fieldset class="action"> >+ <input type="submit" class="btn btn-primary" value="Submit" /> >+ <a href="/cgi-bin/koha/admin/marc_order_accounts.pl" class="cancel">Cancel</a> >+ </fieldset> >+ </form> >+ [% END %] >+ [% IF delete_acct %] >+ <div class="dialog alert"> >+ <h1>Delete this account?</h1> >+ <table> >+ <tr> >+ <th>Vendor</th> >+ <th>Description</th> >+ </tr> >+ <tr> >+ <td>[% account.vendor.name | html %]</td> >+ <td>[% account.description | html %]</td> >+ </tr> >+ <tr> >+ </table> >+ <form action="/cgi-bin/koha/admin/marc_order_accounts.pl" method="post"> >+ [% INCLUDE 'csrf-token.inc' %] >+ <input type="hidden" name="op" value="cud-delete_acct" /> >+ <input type="hidden" name="id" value="[% account.id | html %]" /> >+ <button type="submit" class="approve"><i class="fa fa-fw fa-check"></i> Yes, delete</button> >+ </form> >+ <form action="/cgi-bin/koha/admin/marc_order_accounts.pl" method="get"> >+ <button type="submit" class="deny"><i class="fa fa-fw fa-times"></i> No, do not delete</button> >+ </form> >+ </div> >+ [% END %] >+ </main> >+ </div> <!-- /.col-sm-10.col-sm-push-2 --> >+ >+ <div class="col-sm-2 col-sm-pull-10"> >+ <aside> >+ [% INCLUDE 'admin-menu.inc' %] >+ </aside> >+ </div> <!-- /.col-sm-2.col-sm-pull-10 --> >+ </div> <!-- /.row --> >+ >+[% MACRO jsinclude BLOCK %] >+ [% Asset.js("js/admin-menu.js") | $raw %] >+[% END %] >+[% INCLUDE 'intranet-bottom.inc' %] >\ No newline at end of file >-- >2.39.3 (Apple Git-146)
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 34355
:
154705
|
154706
|
154707
|
154708
|
154709
|
154710
|
157092
|
157093
|
157094
|
157095
|
157096
|
157097
|
157098
|
157099
|
157100
|
160858
|
160859
|
160860
|
160861
|
160862
|
160863
|
160864
|
160865
|
160866
|
160867
|
160868
|
160869
|
160870
|
160871
|
160872
|
160873
|
160874
|
160875
|
169896
|
169897
|
169898
|
169899
|
169900
|
169901
|
169902
|
169903
|
169904
|
170395
|
170401
|
170402
|
170403
|
170404
|
170405
|
170406
|
170407
|
170408
|
170409
|
173054
|
173055
|
173056
|
173057
|
173058
|
173059
|
173060
|
173061
|
173062
|
173063
|
173064
|
173065
|
173066
|
173709
|
173805
|
173806
|
173809
|
173824
|
173825
|
173993
|
173994
|
173995
|
173996
|
173997
|
173998
|
173999
|
174000
|
174001
|
174002
|
174003
|
174004
|
174005
|
174006
|
174007
|
174008
|
174009
|
174010
|
174362
|
174363
|
174364
|
174365
|
174366
|
174367
|
174368
|
174369
|
174370
|
174371
|
174372
|
174373
|
174374
|
174375
|
174376
|
174377
|
174378
|
174379
|
174380
|
174382
|
174383