Bugzilla – Attachment 57858 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), 17.42 KB, created by
Josef Moravec
on 2016-12-01 12:54:34 UTC
(
hide
)
Description:
Bug 17702: Account types configuration - Admin page
Filename:
MIME Type:
Creator:
Josef Moravec
Created:
2016-12-01 12:54:34 UTC
Size:
17.42 KB
patch
obsolete
>From 52e6bbe978718870ca4e6bbcd369e4bd43d86c7d 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 +++++++++++++ > .../intranet-tmpl/prog/en/includes/admin-menu.inc | 1 + > .../prog/en/modules/admin/account_types.tt | 210 +++++++++++++++++++++ > .../prog/en/modules/admin/admin-home.tt | 2 + > 4 files changed, 343 insertions(+) > 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 0000000..7cd395f >--- /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 e736272..2faf61e 100644 >--- a/koha-tmpl/intranet-tmpl/prog/en/includes/admin-menu.inc >+++ b/koha-tmpl/intranet-tmpl/prog/en/includes/admin-menu.inc >@@ -34,6 +34,7 @@ > <li><a href="/cgi-bin/koha/admin/transport-cost-matrix.pl">Transport cost matrix</a></li> > <li><a href="/cgi-bin/koha/admin/item_circulation_alerts.pl">Item circulation alerts</a></li> > <li><a href="/cgi-bin/koha/admin/cities.pl">Cities and towns</a></li> >+ <li><a href="/cgi-bin/koha/admin/account_types.pl">Account types</a></li> > </ul> > > <h5>Catalog</h5> >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 0000000..5349be6 >--- /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 6c128d6..ac86b96 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 >@@ -55,6 +55,8 @@ > <dd>Define rules for check-in and checkout notifications for combinations of libraries, patron categories, and item types</dd> > <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> >+ <dt><a href="/cgi-bin/koha/admin/account_types.pl">Account types</a></dt> >+ <dd>Define debit and credit types.</dd> > </dl> > [% IF CAN_user_plugins %] > <h3>Plugins</h3> >-- >2.1.4
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