@@ -, +, @@ --- Koha/Desk.pm | 46 +++++ Koha/Desks.pm | 56 ++++++ admin/desks.pl | 116 +++++++++++++ .../intranet-tmpl/prog/en/includes/admin-menu.inc | 1 + .../prog/en/includes/desks-admin-search.inc | 31 ++++ .../prog/en/modules/admin/admin-home.tt | 2 + .../intranet-tmpl/prog/en/modules/admin/desks.tt | 190 +++++++++++++++++++++ 7 files changed, 442 insertions(+) create mode 100644 Koha/Desk.pm create mode 100644 Koha/Desks.pm create mode 100755 admin/desks.pl create mode 100644 koha-tmpl/intranet-tmpl/prog/en/includes/desks-admin-search.inc create mode 100644 koha-tmpl/intranet-tmpl/prog/en/modules/admin/desks.tt --- a/Koha/Desk.pm +++ a/Koha/Desk.pm @@ -0,0 +1,46 @@ +package Koha::Desk; + +# Copyright BULAC 2014 +# +# 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, write to the Free Software Foundation, Inc., +# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. + +use Modern::Perl; + +use Carp; + +use Koha::Database; + +use base qw(Koha::Object); + +=head1 NAME + +Koha::Desk - Koha Desk Object class + +=head1 API + +=head2 Class Methods + +=cut + +=head3 type + +=cut + +sub _type { + return 'Desk'; +} + +1; --- a/Koha/Desks.pm +++ a/Koha/Desks.pm @@ -0,0 +1,56 @@ +package Koha::Desks; + +# Copyright BULAC 2014 +# +# 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, write to the Free Software Foundation, Inc., +# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. + +use Modern::Perl; + +use Carp; + +use Koha::Database; + +use Koha::Desk; + +use base qw(Koha::Objects); + +=head1 NAME + +Koha::Desks - Koha Desk Object set class + +=head1 API + +=head2 Class Methods + +=cut + +=head3 type + +=cut + +sub _type { + return 'Desk'; +} + +=head3 object_class + +=cut + +sub object_class { + return 'Koha::Desk'; +} + +1; --- a/admin/desks.pl +++ a/admin/desks.pl @@ -0,0 +1,116 @@ +#! /usr/bin/perl + +# Copyright 2006 SAN OUEST-PROVENCE et Paul POULAIN +# Copyright 2015 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 C4::Context; +use C4::Auth; +use C4::Output; + +use Koha::Desks; + +my $input = new CGI; +my $searchfield = $input->param('desk_name') // q||; +my $desk_id = $input->param('desk_id') || ''; +my $op = $input->param('op') || 'list'; +my @messages; + +my ( $template, $loggedinuser, $cookie ) = get_template_and_user( + { template_name => "admin/desks.tt", + query => $input, + type => "intranet", + authnotrequired => 0, + flagsrequired => { parameters => 'manage_desks' }, + debug => 1, + } +); + +my $branches = Koha::Libraries->search( {}, { order_by => ['branchname'] } )->unblessed; + +if ( $op eq 'add_form' ) { + my $desk; + if ($desk_id) { + $desk = Koha::Desks->find($desk_id); + } + + $template->param( desk => $desk, ); +} elsif ( $op eq 'add_validate' ) { + my $desk_id = $input->param('desk_id'); + my $desk_name = $input->param('desk_name'); + my $branchcode = $input->param('branchcode'); + + if (Koha::Desks->find($desk_id)) { + my $desk = Koha::Desks->find($desk_id); + $desk->desk_name($desk_name); + $desk->branchcode($branchcode); + eval { $desk->store; }; + if ($@) { + push @messages, { type => 'error', code => 'error_on_update' }; + } else { + push @messages, { type => 'message', code => 'success_on_update' }; + } + } else { + my $desk = Koha::Desk->new( + { + desk_id => $desk_id, + desk_name => $desk_name, + branchcode => $branchcode, + } + ); + eval { $desk->store; }; + if ($@) { + push @messages, { type => 'error', code => 'error_on_insert' }; + } else { + push @messages, { type => 'message', code => 'success_on_insert' }; + } + } + $searchfield = q||; + $op = 'list'; +} elsif ( $op eq 'delete_confirm' ) { + my $desk = Koha::Desks->find($desk_id); + $template->param( desk => $desk, ); +} elsif ( $op eq 'delete_confirmed' ) { + my $desk = Koha::Desks->find($desk_id); + my $deleted = eval { $desk->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' || ! $op) { + my $desks = Koha::Desks->search( { desk_name => { -like => "%$searchfield%" } } ); + $template->param( desks => $desks, ); +} + +use Data::Dumper; + +$template->param( + desk_id => $desk_id, + searchfield => $searchfield, + messages => \@messages, + op => $op, + branches => $branches, +); + +output_html_with_http_headers $input, $cookie, $template->output; --- a/koha-tmpl/intranet-tmpl/prog/en/includes/admin-menu.inc +++ a/koha-tmpl/intranet-tmpl/prog/en/includes/admin-menu.inc @@ -16,6 +16,7 @@ [% IF ( CAN_user_parameters_manage_libraries ) %]
  • Libraries
  • Library groups
  • +
  • Desks
  • [% END %] [% IF ( CAN_user_parameters_manage_itemtypes ) %]
  • Item types
  • --- a/koha-tmpl/intranet-tmpl/prog/en/includes/desks-admin-search.inc +++ a/koha-tmpl/intranet-tmpl/prog/en/includes/desks-admin-search.inc @@ -0,0 +1,31 @@ +[% USE Koha %] +
    +

    [% LibraryName|html %]

    + +
    + --- a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/admin-home.tt +++ a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/admin-home.tt @@ -63,6 +63,8 @@
    Define libraries.
    Library groups
    Define hierarchical library groups.
    +
    Desks
    +
    Define desks.
    [% END %] [% IF ( CAN_user_parameters_manage_itemtypes ) %]
    Item types
    --- a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/desks.tt +++ a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/desks.tt @@ -0,0 +1,190 @@ +[% USE raw %] +[% USE Branches %] +[% USE Asset %] +[% SET footerjs = 1 %] +[% INCLUDE 'doc-head-open.inc' %] +Koha › Administration › [% IF op =='add_form' %]Desks › [% IF desk.desk_id %] Modify desk[% ELSE %] New desk[% END %][% ELSE %][% IF op == 'delete_confirm' %]Desks › Confirm deletion of desk[% ELSE %] Desks[% END %][% END %] +[% INCLUDE 'doc-head-close.inc' %] + + + +[% INCLUDE 'header.inc' %] +[% INCLUDE 'desks-admin-search.inc' %] + + + +
    +
    +
    +
    + +[% FOR m IN messages %] +
    + [% SWITCH m.code %] + [% CASE 'error_on_update' %] + An error occurred when updating this desk. Perhaps it already exists. + [% CASE 'error_on_insert' %] + An error occurred when adding this desk. The desk id might already exist. + [% CASE 'error_on_delete' %] + An error occurred when deleting this desk. Check the logs. + [% CASE 'success_on_update' %] + Desk updated successfully. + [% CASE 'success_on_insert' %] + Desk added successfully. + [% CASE 'success_on_delete' %] + Desk deleted successfully. + [% CASE 'already_exists' %] + This desk already exists. + [% CASE %] + [% m.code | html %] + [% END %] +
    +[% END %] + +[% IF op == 'add_form' %] + [% IF desk %] +

    Modify a desk

    + [% ELSE %] +

    New desk

    + [% END %] + +
    + + + +
    +
      + [% IF desk %] +
    1. Desk ID: [% desk.desk_id | html %]
    2. + [% END %] +
    3. + + Required +
    4. +
    5. + + +
    6. + +
    +
    + +
    + + Cancel +
    +
    +[% END %] + +[% IF op == 'delete_confirm' %] +
    +

    Delete desk "[% desk.desk_name | html %]?"

    + + + + + + + + + + +
    Desk id[% desk.desk_id | html %]
    Desk[% desk.desk_name | html %]
    Branchcode[% desk.branchcode | html %]
    +
    + + + +
    +
    + +
    +
    +[% END %] + +[% IF op == 'list' %] + + + +

    Desks

    + [% IF searchfield %] + Searching: [% searchfield | html %] + [% END %] + + [% IF desks.count %] + + + + + + + + + + + [% FOREACH desk IN desks %] + + + + + + + [% END %] + +
    Desk IDDeskLibraryAction
    [% desk.desk_id | html %][% desk.desk_name | html %][% desk.branchcode | html %] + Edit + Delete +
    + [% ELSE %] +
    + There are no desks defined. Create a new desk. +
    + [% END %] +[% END %] + +
    +
    + +
    + +
    +
    + +[% MACRO jsinclude BLOCK %] + [% Asset.js("js/admin-menu.js") | $raw %] + [% INCLUDE 'datatables.inc' %] + +[% END %] +[% INCLUDE 'intranet-bottom.inc' %] --