Bugzilla – Attachment 85876 Details for
Bug 17702
Create configuration for account credit types
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 17702: Account types configuration - Admin page
Bug-17702-Account-types-configuration---Admin-page.patch (text/plain), 22.99 KB, created by
Martin Renvoize (ashimema)
on 2019-02-28 13:58:08 UTC
(
hide
)
Description:
Bug 17702: Account types configuration - Admin page
Filename:
MIME Type:
Creator:
Martin Renvoize (ashimema)
Created:
2019-02-28 13:58:08 UTC
Size:
22.99 KB
patch
obsolete
>From 5bd60e763cf5a811ca724393197be36864fc743c Mon Sep 17 00:00:00 2001 >From: Josef Moravec <josef.moravec@gmail.com> >Date: Wed, 23 Nov 2016 14:58:01 +0000 >Subject: [PATCH] Bug 17702: Account types configuration - Admin page > >Test plan: >1) Go to admin home, note there is new Account types page in Patrons and >circulation section >2) Go to any other admin page and confirm there is link to Account types >in admin menu as welll >3) Go to Account types page >4) You should see two datatables, one for debit types and one for >credit types, ensure the datatables are working corectly >5) Try to create, edit and delete some debit types, note, that some of >them can't be deleted - they are neede for Koha internally >6) Do the same with credit types >7) Try to add some default amount to internal debits - like Acccount >management fee, New card, ... >8) Go to Patron fines page and play with account type select, when you >change thy account type, the description and amount should change as you >set it on the admin page >9) Try to add some fees and ensure they are inserted corectly >10) Pay the inserted fees >11) Try to add manual credit and ensure it is added corectly >--- > admin/account_types.pl | 130 +++++++++++ > .../prog/en/includes/admin-menu.inc | 5 +- > .../prog/en/modules/admin/account_types.tt | 210 ++++++++++++++++++ > .../prog/en/modules/admin/admin-home.tt | 58 ++--- > 4 files changed, 375 insertions(+), 28 deletions(-) > create mode 100755 admin/account_types.pl > create mode 100644 koha-tmpl/intranet-tmpl/prog/en/modules/admin/account_types.tt > >diff --git a/admin/account_types.pl b/admin/account_types.pl >new file mode 100755 >index 0000000000..7cd395f336 >--- /dev/null >+++ b/admin/account_types.pl >@@ -0,0 +1,130 @@ >+#! /usr/bin/perl >+ >+# Copyright 2016 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 <http://www.gnu.org/licenses>. >+ >+use Modern::Perl; >+use CGI qw ( -utf8 ); >+use C4::Context; >+use C4::Auth; >+use C4::Output; >+ >+use Koha::Account::CreditTypes; >+use Koha::Account::DebitTypes; >+ >+my $input = new CGI; >+my $type_code = $input->param('type_code'); >+my $op = $input->param('op') || 'list'; >+my $type = $input->param('type'); >+my @messages; >+ >+my ( $template, $loggedinuser, $cookie ) = get_template_and_user( >+ { template_name => "admin/account_types.tt", >+ query => $input, >+ type => "intranet", >+ authnotrequired => 0, >+ flagsrequired => { parameters => 'parameters_remaining_permissions' }, >+ debug => 1, >+ } >+); >+ >+#my $dbh = C4::Context->dbh; >+if ( $op eq 'add_form' ) { >+ my $account_type; >+ if ($type_code) { >+ if ($type eq "debit") { >+ $account_type = Koha::Account::DebitTypes->find($type_code); >+ } else { >+ $account_type = Koha::Account::CreditTypes->find($type_code); >+ } >+ } >+ $template->param( account_type => $account_type ); >+ $template->param( type => $type ); >+} elsif ( $op eq 'add_validate' ) { >+ my $description = $input->param('description'); >+ my $can_be_added_manually = $input->param('can_be_added_manually') || 0; >+ my $default_amount; >+ if ($type eq "debit") { >+ $default_amount = $input->param('default_amount') || undef; >+ } >+ >+ my $account_type; >+ if($type eq "debit") { >+ $account_type = Koha::Account::DebitTypes->find($type_code); >+ if (not defined $account_type) { >+ $account_type = Koha::Account::DebitType->new( { type_code => $type_code } ); >+ } >+ } else { >+ $account_type = Koha::Account::CreditTypes->find($type_code); >+ if (not defined $account_type) { >+ $account_type = Koha::Account::CreditType->new( { type_code => $type_code } ); >+ } >+ } >+ $account_type->description($description); >+ $account_type->can_be_added_manually($can_be_added_manually); >+ if($type eq "debit") { >+ $account_type->default_amount($default_amount); >+ } >+ eval { $account_type->store; }; >+ if ($@) { >+ push @messages, { type => 'error', code => 'error_on_saving' }; >+ } else { >+ push @messages, { type => 'message', code => 'success_on_saving' }; >+ } >+ $op = 'list'; >+} elsif ( $op eq 'delete_confirm' ) { >+ my $account_type; >+ if($type eq "debit") { >+ $account_type = Koha::Account::DebitTypes->find($type_code); >+ } else { >+ $account_type = Koha::Account::CreditTypes->find($type_code); >+ } >+ $template->param( account_type => $account_type ); >+ $template->param( type => $type ); >+} elsif ( $op eq 'delete_confirmed' ) { >+ my $account_type; >+ if($type eq "debit") { >+ $account_type = Koha::Account::DebitTypes->find($type_code); >+ } else { >+ $account_type = Koha::Account::CreditTypes->find($type_code); >+ } >+ my $deleted = eval { $account_type->delete; }; >+ >+ if ( $@ or not $deleted ) { >+ push @messages, { type => 'error', code => 'error_on_delete' }; >+ } else { >+ push @messages, { type => 'message', code => 'success_on_delete' }; >+ } >+ $op = 'list'; >+} >+ >+if ( $op eq 'list' ) { >+ my $credit_types = Koha::Account::CreditTypes->search(); >+ my $debit_types = Koha::Account::DebitTypes->search(); >+ $template->param( >+ debit_types => $debit_types, >+ credit_types => $credit_types, >+ ); >+} >+ >+$template->param( >+ type_code => $type_code, >+ messages => \@messages, >+ op => $op, >+); >+ >+output_html_with_http_headers $input, $cookie, $template->output; >diff --git a/koha-tmpl/intranet-tmpl/prog/en/includes/admin-menu.inc b/koha-tmpl/intranet-tmpl/prog/en/includes/admin-menu.inc >index 817b5a6355..0fec9b6d49 100644 >--- a/koha-tmpl/intranet-tmpl/prog/en/includes/admin-menu.inc >+++ b/koha-tmpl/intranet-tmpl/prog/en/includes/admin-menu.inc >@@ -26,7 +26,7 @@ > </ul> > [% END %] > >- [% IF ( CAN_user_parameters_manage_patron_categories || CAN_user_parameters_manage_circ_rules || CAN_user_parameters_manage_patron_attributes || CAN_user_parameters_manage_transfers || CAN_user_parameters_manage_item_circ_alerts || CAN_user_parameters_manage_cities ) %] >+ [% IF ( CAN_user_parameters_manage_patron_categories || CAN_user_parameters_manage_circ_rules || CAN_user_parameters_manage_patron_attributes || CAN_user_parameters_manage_transfers || CAN_user_parameters_manage_item_circ_alerts || CAN_user_parameters_manage_cities || CAN_user_parameters_manage_accounts) %] > <h5>Patrons and circulation</h5> > <ul> > [% IF ( CAN_user_parameters_manage_patron_categories ) %] >@@ -48,6 +48,9 @@ > [% IF ( CAN_user_parameters_manage_cities ) %] > <li><a href="/cgi-bin/koha/admin/cities.pl">Cities and towns</a></li> > [% END %] >+ [% IF ( CAN_user_parameters_manage_accounts ) %] >+ <li><a href="/cgi-bin/koha/admin/account_types.pl">Account types</a></li> >+ [% END %] > </ul> > [% END %] > >diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/account_types.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/admin/account_types.tt >new file mode 100644 >index 0000000000..5349be6e57 >--- /dev/null >+++ b/koha-tmpl/intranet-tmpl/prog/en/modules/admin/account_types.tt >@@ -0,0 +1,210 @@ >+[% INCLUDE 'doc-head-open.inc' %] >+<title>Koha › Administration › [% IF op =='add_form' %]Account types › [% IF account_type.type_code %] Modify account [% type %] type[% ELSE %] New account [% type %] type[% END %][% ELSE %][% IF op == 'delete_confirm' %]Account types › Confirm deletion of account [% type %]type[% ELSE %] Account types[% END %][% END %]</title> >+[% INCLUDE 'doc-head-close.inc' %] >+<link rel="stylesheet" type="text/css" href="[% interface %]/[% theme %]/css/datatables.css" /> >+[% INCLUDE 'datatables.inc' %] >+<script type="text/javascript"> >+//<![CDATA[ >+ $(document).ready(function() { >+ $("#table_credit_types, #table_debit_types").dataTable($.extend(true, {}, dataTablesDefaults, { >+ "aoColumnDefs": [ >+ { "aTargets": [ -1 ], "bSortable": false, "bSearchable": false }, >+ ], >+ "aaSorting": [[ 1, "asc" ]], >+ "iDisplayLength": 10, >+ "sPaginationType": "full_numbers" >+ })); >+ }); >+//]]> >+</script> >+</head> >+<body id="admin_account_types" class="admin"> >+[% INCLUDE 'header.inc' %] >+[% INCLUDE 'cat-search.inc' %] >+ >+<div id="breadcrumbs"> >+ <a href="/cgi-bin/koha/mainpage.pl">Home</a> >+ › <a href="/cgi-bin/koha/admin/admin-home.pl">Administration</a> >+ › <a href="/cgi-bin/koha/admin/account_types.pl">Account types</a> >+ [% IF op == 'add_form' %] >+ › [% IF account_type.type_code %]Modify[% ELSE %]New[% END %] Account [% type %] type >+ [% ELSIF op == 'delete_confirm' %] >+ › Confirm deletion of account [% type %] type >+ [% END %] >+</div> >+ >+<div id="doc3" class="yui-t2"> >+ >+ <div id="bd"> >+ <div id="yui-main"> >+ <div class="yui-b"> >+ >+[% FOR m IN messages %] >+ <div class="dialog [% m.type %]"> >+ [% SWITCH m.code %] >+ [% CASE 'error_on_saving' %] >+ An error occurred when saving this account type. >+ [% CASE 'error_on_delete' %] >+ An error occurred when deleting this account type. Check the logs. >+ [% CASE 'success_on_saving' %] >+ Account type saved successfully. >+ [% CASE 'success_on_delete' %] >+ Account type deleted successfully. >+ [% CASE %] >+ [% m.code %] >+ [% END %] >+ </div> >+[% END %] >+ >+[% IF op == 'add_form' %] >+ [% IF account_type %] >+ <h1>Modify an account [% type %] type</h1> >+ [% ELSE %] >+ <h1>New account [% type %] type</h1> >+ [% END %] >+ >+ <form action="/cgi-bin/koha/admin/account_types.pl" name="Aform" method="post" class="validated"> >+ <input type="hidden" name="op" value="add_validate" /> >+ <input type="hidden" name="type" value="[% type %]" /> >+ <fieldset class="rows"> >+ <ol> >+ <li> >+ <label for="type_code" class="required">Account [% type %] type code: </label> >+ [% IF account_type %] >+ <strong>[% account_type.type_code %]</strong> >+ <input type="hidden" name="type_code" value="[% type_code %]" /> >+ [% ELSE %] >+ <input type="text" name="type_code" id="type_code" size="10" maxlength="5" class="required" required="required"><span class="required">Required. Maximum length is 5 letters</span> >+ [% END %] >+ </li> >+ [% IF type == 'debit' %] >+ <li> >+ <label for="default_amount">Default amount: </label> >+ <input type="text" name="default_amount" id="default_amount" size="80" maxlength="100" value="[% account_type.default_amount |html %]" /> >+ </li> >+ [% END %] >+ <li> >+ <label for="description" class="required">Description: </label> >+ <input type="text" name="description" id="description" required="required" class="required" size="80" maxlength="100" value="[% account_type.description |html %]" /> <span class="required">Required</span> >+ </li> >+ <li> >+ <label for="can_be_added_manually">Can be added manually? </label> >+ [% IF account_type.can_be_added_manually %] >+ <input type="checkbox" name="can_be_added_manually" id="can_be_added_manually" checked="checked" value="1" /> >+ [% ELSE %] >+ <input type="checkbox" name="can_be_added_manually" id="can_be_added_manually" value="1" /> >+ [% END %] >+ </li> >+ </ol> >+ </fieldset> >+ >+ <fieldset class="action"> >+ <button id="save_account_type" class="btn"><i class="fa fa-save"></i> Save</button> >+ <a class="cancel btn-link" href="/cgi-bin/koha/admin/account_types.pl"><i class="fa fa-times"></i> Cancel</a> >+ </fieldset> >+ </form> >+[% END %] >+ >+[% IF op == 'delete_confirm' %] >+ <div class="dialog alert"> >+ <h3>Delete account [% type %] type "[% account_type.description %]?"</h3> >+ <table> >+ <tr><th>Account type code</th> >+ <td>[% account_type.type_code %]</td> >+ </tr> >+ <tr><th>Account type description</th> >+ <td>[% account_type.description %]</td> >+ </tr> >+ </table> >+ <form action="/cgi-bin/koha/admin/account_types.pl" method="post"> >+ <input type="hidden" name="op" value="delete_confirmed" /> >+ <input type="hidden" name="type_code" value="[% account_type.type_code %]" /> >+ <input type="hidden" name="type" value="[% type %]" /> >+ <button type="submit" class="btn approve"><i class="fa fa-fw fa-check"></i> Yes, delete</button> >+ </form> >+ <form action="/cgi-bin/koha/admin/account_types.pl" method="get"> >+ <button type=submit" class="btn deny"><i class="fa fa-fw fa-remove"></i> No, do not delete</button> >+ </form> >+ </div> >+[% END %] >+ >+[% IF op == 'list' %] >+ >+ <div id="toolbar" class="btn-toolbar"> >+ <a class="btn btn-small" id="newdebittype" href="/cgi-bin/koha/admin/account_types.pl?op=add_form&type=debit"><i class="fa fa-plus"></i> New debit type</a> >+ <a class="btn btn-small" id="newcreditype" href="/cgi-bin/koha/admin/account_types.pl?op=add_form&type=credit"><i class="fa fa-plus"></i> New credit type</a> >+ </div> >+ >+ <h2>Account debit types</h2> >+ [% IF debit_types.count %] >+ <table id="table_debit_types"> >+ <thead> >+ <th>Account type code</th> >+ <th>Description</th> >+ <th>Default amount</th> >+ <th>Can be added manually</th> >+ <th>Actions</th> >+ </thead> >+ <tbody> >+ [% FOREACH debit_type IN debit_types %] >+ <tr> >+ <td>[% debit_type.type_code %]</td> >+ <td>[% debit_type.description %]</td> >+ <td>[% debit_type.default_amount %]</td> >+ <td>[% IF debit_type.can_be_added_manually %]Yes[% ELSE %]No[% END %]</td> >+ <td class="actions"> >+ <a class="btn btn-mini" href="/cgi-bin/koha/admin/account_types.pl?op=add_form&type_code=[% debit_type.type_code %]&type=debit"><i class="fa fa-pencil"></i> Edit</a> >+ [% IF debit_type.can_be_deleted %] >+ <a class="btn btn-mini" href="/cgi-bin/koha/admin/account_types.pl?op=delete_confirm&type_code=[% debit_type.type_code %]&type=debit"><i class="fa fa-trash"></i> Delete</a> >+ [% END %] >+ </td> >+ </tr> >+ [% END %] >+ </tbody> >+ </table> >+ [% ELSE %] >+ <div class="dialog message"> >+ There are no account debit types defined. <a href="/cgi-bin/koha/admin/account_types.pl?op=add_form&type=debit">Create new debit type</a> >+ </div> >+ [% END %] >+ >+ <h2>Account credit types</h2> >+ [% IF credit_types.count %] >+ <table id="table_credit_types"> >+ <thead> >+ <th>Account type code</th> >+ <th>Description</th> >+ <th>Can be added manually</th> >+ <th>Actions</th> >+ </thead> >+ <tbody> >+ [% FOREACH credit_type IN credit_types %] >+ <tr> >+ <td>[% credit_type.type_code %]</td> >+ <td>[% credit_type.description %]</td> >+ <td>[% IF credit_type.can_be_added_manually %]Yes[% ELSE %]No[% END %]</td> >+ <td class="actions"> >+ <a class="btn btn-mini" href="/cgi-bin/koha/admin/account_types.pl?op=add_form&type_code=[% credit_type.type_code %]&type=credit"><i class="fa fa-pencil"></i> Edit</a> >+ [% IF credit_type.can_be_deleted %] >+ <a class="btn btn-mini" href="/cgi-bin/koha/admin/account_types.pl?op=delete_confirm&type_code=[% credit_type.type_code %]&type=credit"><i class="fa fa-trash"></i> Delete</a> >+ [% END %] >+ </td> >+ </tr> >+ [% END %] >+ </tbody> >+ </table> >+ [% ELSE %] >+ <div class="dialog message"> >+ There are no account credit types defined. <a href="/cgi-bin/koha/admin/account_types.pl?op=add_form&type=credit">Create new credit type</a> >+ </div> >+ [% END %] >+ >+[% END %] >+ >+</div> >+</div> >+<div class="yui-b"> >+[% INCLUDE 'admin-menu.inc' %] >+</div> >+</div> >+[% INCLUDE 'intranet-bottom.inc' %] >diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/admin-home.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/admin/admin-home.tt >index 33312ed089..ea3f0d8774 100644 >--- a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/admin-home.tt >+++ b/koha-tmpl/intranet-tmpl/prog/en/modules/admin/admin-home.tt >@@ -66,35 +66,39 @@ > </dl> > [% END %] > >- [% IF ( CAN_user_parameters_manage_patron_categories || CAN_user_parameters_manage_circ_rules || CAN_user_parameters_manage_patron_attributes || CAN_user_parameters_manage_transfers || CAN_user_parameters_manage_item_circ_alerts || CAN_user_parameters_manage_cities ) %] >+ [% IF ( CAN_user_parameters_manage_patron_categories || CAN_user_parameters_manage_circ_rules || CAN_user_parameters_manage_patron_attributes || CAN_user_parameters_manage_transfers || CAN_user_parameters_manage_item_circ_alerts || CAN_user_parameters_manage_cities || CAN_user_parameters_manage_accounts ) %] > <h3>Patrons and circulation</h3> > <dl> >- [% IF ( CAN_user_parameters_manage_patron_categories ) %] >- <dt><a href="/cgi-bin/koha/admin/categories.pl">Patron categories</a></dt> >- <dd>Define patron categories.</dd> >- [% END %] >- [% IF ( CAN_user_parameters_manage_circ_rules ) %] >- <dt><a href="/cgi-bin/koha/admin/smart-rules.pl">Circulation and fines rules</a></dt> >- <dd>Define circulation and fines rules for combinations of libraries, patron categories, and item types</dd> >- [% END %] >- [% IF ( CAN_user_parameters_manage_patron_attributes ) %] >- <dt><a href="/cgi-bin/koha/admin/patron-attr-types.pl">Patron attribute types</a></dt> >- <dd>Define extended attributes (identifiers and statistical categories) for patron records</dd> >- [% END %] >- [% IF ( CAN_user_parameters_manage_transfers ) %] >- <dt><a href="/cgi-bin/koha/admin/branch_transfer_limits.pl">Library transfer limits</a></dt> >- <dd>Limit the ability to transfer items between libraries based on the library sending, the library receiving, and the item type involved. These rules only go into effect if the preference UseBranchTransferLimits is set to ON.</dd> >- <dt><a href="/cgi-bin/koha/admin/transport-cost-matrix.pl">Transport cost matrix</a></dt> >- <dd>Define transport costs between branches</dd> >- [% END %] >- [% IF ( CAN_user_parameters_manage_item_circ_alerts ) %] >- <dt><a href="/cgi-bin/koha/admin/item_circulation_alerts.pl">Item circulation alerts</a></dt> >- <dd>Define rules for check-in and checkout notifications for combinations of libraries, patron categories, and item types</dd> >- [% END %] >- [% IF ( CAN_user_parameters_manage_cities ) %] >- <dt><a href="/cgi-bin/koha/admin/cities.pl">Cities and towns</a></dt> >- <dd>Define cities and towns that your patrons live in.</dd> >- [% END %] >+ [% IF ( CAN_user_parameters_manage_patron_categories ) %] >+ <dt><a href="/cgi-bin/koha/admin/categories.pl">Patron categories</a></dt> >+ <dd>Define patron categories.</dd> >+ [% END %] >+ [% IF CAN_user_parameters_manage_circ_rules %] >+ <dt><a href="/cgi-bin/koha/admin/smart-rules.pl">Circulation and fines rules</a></dt> >+ <dd>Define circulation and fines rules for combinations of libraries, patron categories, and item types</dd> >+ [% END %] >+ [% IF ( CAN_user_parameters_manage_patron_attributes ) %] >+ <dt><a href="/cgi-bin/koha/admin/patron-attr-types.pl">Patron attribute types</a></dt> >+ <dd>Define extended attributes (identifiers and statistical categories) for patron records</dd> >+ [% END %] >+ [% IF ( CAN_user_parameters_manage_transfers ) %] >+ <dt><a href="/cgi-bin/koha/admin/branch_transfer_limits.pl">Library transfer limits</a></dt> >+ <dd>Limit the ability to transfer items between libraries based on the library sending, the library receiving, and the item type involved. These rules only go into effect if the preference UseBranchTransferLimits is set to ON.</dd> >+ <dt><a href="/cgi-bin/koha/admin/transport-cost-matrix.pl">Transport cost matrix</a></dt> >+ <dd>Define transport costs between branches</dd> >+ [% END %] >+ [% IF ( CAN_user_parameters_manage_item_circ_alerts ) %] >+ <dt><a href="/cgi-bin/koha/admin/item_circulation_alerts.pl">Item circulation alerts</a></dt> >+ <dd>Define rules for check-in and checkout notifications for combinations of libraries, patron categories, and item types</dd> >+ [% END %] >+ [% IF ( CAN_user_parameters_manage_cities ) %] >+ <dt><a href="/cgi-bin/koha/admin/cities.pl">Cities and towns</a></dt> >+ <dd>Define cities and towns that your patrons live in.</dd> >+ [% END %] >+ [% IF ( CAN_user_parameters_manage_accounts ) %] >+ <dt><a href="/cgi-bin/koha/admin/account_types.pl">Account types</a></dt> >+ <dd>Define debit and credit types.</dd> >+ [% END %] > </dl> > [% END %] > >-- >2.20.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 17702
:
57856
|
57857
|
57858
|
58066
|
85874
|
85875
|
85876
|
85877
|
98564
|
98659
|
98660
|
99306
|
99307
|
99322
|
99454