View | Details | Raw Unified | Return to bug 14828
Collapse All | Expand All

(-)a/admin/itemtypes.pl (-213 / +97 lines)
Lines 1-6 Link Here
1
#!/usr/bin/perl
1
#!/usr/bin/perl
2
2
3
# Copyright 2000-2002 Katipo Communications
3
# Copyright 2000-2002 Katipo Communications
4
# Copyright 2002 Paul Poulain
4
#
5
#
5
# This file is part of Koha.
6
# This file is part of Koha.
6
#
7
#
Lines 19-50 Link Here
19
20
20
=head1 admin/itemtypes.pl
21
=head1 admin/itemtypes.pl
21
22
22
script to administer the categories table
23
written 20/02/2002 by paul.poulain@free.fr
24
 This software is placed under the gnu General Public License, v2 (http://www.gnu.org/licenses/gpl.html)
25
26
 ALGO :
27
 this script use an $op to know what to do.
28
 if $op is empty or none of the above values,
29
	- the default screen is build (with all records, or filtered datas).
30
	- the   user can clic on add, modify or delete record.
31
 if $op=add_form
32
	- if primkey exists, this is a modification,so we read the $primkey record
33
	- builds the add/modify form
34
 if $op=add_validate
35
	- the user has just send datas, so we create/modify the record
36
 if $op=delete_form
37
	- we show the record having primkey=$primkey and ask for deletion validation form
38
 if $op=delete_confirm
39
	- we delete the record having primkey=$primkey
40
41
=cut
23
=cut
42
24
43
use strict;
25
use Modern::Perl;
44
#use warnings; FIXME - Bug 2505
45
use CGI qw ( -utf8 );
26
use CGI qw ( -utf8 );
46
27
47
use List::Util qw/min/;
48
use File::Spec;
28
use File::Spec;
49
29
50
use C4::Koha;
30
use C4::Koha;
Lines 52-69 use C4::Context; Link Here
52
use C4::Auth;
32
use C4::Auth;
53
use C4::Output;
33
use C4::Output;
54
34
35
use Koha::ItemTypes;
55
use Koha::Localizations;
36
use Koha::Localizations;
56
37
57
my $input       = new CGI;
38
my $input         = new CGI;
58
my $searchfield = $input->param('description');
39
my $searchfield   = $input->param('description');
59
my $script_name = "/cgi-bin/koha/admin/itemtypes.pl";
40
my $itemtype_code = $input->param('itemtype');
60
my $itemtype    = $input->param('itemtype');
41
my $op            = $input->param('op') // 'list';
61
my $op          = $input->param('op') // 'list';
62
my @messages;
42
my @messages;
63
$searchfield =~ s/\,//g;
43
$searchfield =~ s/\,//g if $searchfield;
64
my ( $template, $borrowernumber, $cookie ) = get_template_and_user(
44
my ( $template, $borrowernumber, $cookie ) = get_template_and_user(
65
    {
45
    {   template_name   => "admin/itemtypes.tt",
66
        template_name   => "admin/itemtypes.tt",
67
        query           => $input,
46
        query           => $input,
68
        type            => "intranet",
47
        type            => "intranet",
69
        authnotrequired => 0,
48
        authnotrequired => 0,
Lines 72-287 my ( $template, $borrowernumber, $cookie ) = get_template_and_user( Link Here
72
    }
51
    }
73
);
52
);
74
53
75
$template->param(script_name => $script_name);
76
if ($op) {
77
	$template->param($op  => 1); # we show only the TMPL_VAR names $op
78
}
79
80
my $dbh = C4::Context->dbh;
54
my $dbh = C4::Context->dbh;
81
55
82
my $sip_media_type = $input->param('sip_media_type');
56
my $sip_media_type = $input->param('sip_media_type');
83
undef($sip_media_type) if defined($sip_media_type) and $sip_media_type =~ /^\s*$/;
57
undef($sip_media_type) if defined($sip_media_type) and $sip_media_type =~ /^\s*$/;
84
58
85
################## ADD_FORM ##################################
86
# called by default. Used to create form to add or  modify a record
87
if ( $op eq 'add_form' ) {
59
if ( $op eq 'add_form' ) {
88
    #---- if primkey exists, it's a modify action, so read values to modify...
60
    my $itemtype = Koha::ItemTypes->find($itemtype_code);
89
    my $data;
61
    my $imagesets = C4::Koha::getImageSets( checked => ( $itemtype ? $itemtype->imageurl : undef ) );
90
    if ($itemtype) {
91
        my $sth = $dbh->prepare(q|
92
            SELECT
93
                   itemtypes.itemtype,
94
                   itemtypes.description,
95
                   itemtypes.rentalcharge,
96
                   itemtypes.notforloan,
97
                   itemtypes.imageurl,
98
                   itemtypes.summary,
99
                   itemtypes.checkinmsg,
100
                   itemtypes.checkinmsgtype,
101
                   itemtypes.sip_media_type,
102
                   COALESCE( localization.translation, itemtypes.description ) AS translated_description
103
            FROM   itemtypes
104
            LEFT JOIN localization ON itemtypes.itemtype = localization.code
105
                AND localization.entity='itemtypes'
106
                AND localization.lang = ?
107
            WHERE itemtype = ?
108
        |);
109
        my $language = C4::Languages::getlanguage();
110
        $sth->execute($language, $itemtype);
111
        $data = $sth->fetchrow_hashref;
112
    }
113
114
    my $imagesets = C4::Koha::getImageSets( checked => $data->{'imageurl'} );
115
116
    my $remote_image = undef;
117
    if ( defined $data->{imageurl} and $data->{imageurl} =~ /^http/i ) {
118
        $remote_image = $data->{imageurl};
119
    }
120
121
    $template->param(
62
    $template->param(
122
        itemtype        => $itemtype,
63
        itemtype  => $itemtype,
123
        description     => $data->{'description'},
64
        imagesets => $imagesets,
124
        rentalcharge    => sprintf( "%.2f", $data->{'rentalcharge'} ),
125
        notforloan      => $data->{'notforloan'},
126
        imageurl        => $data->{'imageurl'},
127
        template        => C4::Context->preference('template'),
128
        summary         => $data->{summary},
129
        checkinmsg      => $data->{'checkinmsg'},
130
        checkinmsgtype  => $data->{'checkinmsgtype'},
131
        imagesets       => $imagesets,
132
        remote_image    => $remote_image,
133
        sip_media_type  => $data->{sip_media_type},
134
    );
65
    );
135
66
} elsif ( $op eq 'add_validate' ) {
136
    # END $OP eq ADD_FORM
67
    my $is_a_modif   = $input->param('is_a_modif');
137
################## ADD_VALIDATE ##################################
68
    my $itemtype     = Koha::ItemTypes->find($itemtype_code);
138
    # called by add_form, used to insert/modify data in DB
69
    my $description  = $input->param('description');
139
}
70
    my $rentalcharge = $input->param('rentalcharge');
140
elsif ( $op eq 'add_validate' ) {
71
    my $image = $input->param('image') || q||;
141
    my $is_a_modif = $input->param('is_a_modif');
72
142
    my ( $already_exists ) = $dbh->selectrow_array(q|
73
    my $notforloan = $input->param('notforloan') ? 1 : 0;
143
        SELECT itemtype
74
    my $imageurl =
144
        FROM   itemtypes
75
      $image eq 'removeImage' ? ''
145
        WHERE  itemtype = ?
76
      : (
146
    |, undef, $itemtype );
77
          $image eq 'remoteImage' ? $input->param('remoteImage')
147
    if ( $already_exists and $is_a_modif ) { # it's a modification
78
        : $image
148
        my $query2 = '
79
      );
149
            UPDATE itemtypes
80
    my $summary        = $input->param('summary');
150
            SET    description = ?
81
    my $checkinmsg     = $input->param('checkinmsg');
151
                 , rentalcharge = ?
82
    my $checkinmsgtype = $input->param('checkinmsgtype');
152
                 , notforloan = ?
83
153
                 , imageurl = ?
84
    if ( $itemtype and $is_a_modif ) {    # it's a modification
154
                 , summary = ?
85
        $itemtype->description($description);
155
                 , checkinmsg = ?
86
        $itemtype->rentalcharge($rentalcharge);
156
                 , checkinmsgtype = ?
87
        $itemtype->notforloan($notforloan);
157
                 , sip_media_type = ?
88
        $itemtype->imageurl($imageurl);
158
            WHERE itemtype = ?
89
        $itemtype->summary($summary);
159
        ';
90
        $itemtype->checkinmsg($checkinmsg);
160
        my $sth = $dbh->prepare($query2);
91
        $itemtype->checkinmsgtype($checkinmsgtype);
161
        $sth->execute(
92
        $itemtype->sip_media_type($sip_media_type);
162
            $input->param('description'),
93
        eval { $itemtype->store; };
163
            $input->param('rentalcharge'),
94
164
            ( $input->param('notforloan') ? 1 : 0 ),
95
        if ($@) {
165
            (
96
            push @messages, { type => 'error', code => 'error_on_update' };
166
                $input->param('image') eq 'removeImage' ? '' : (
97
        } else {
167
                      $input->param('image') eq 'remoteImage'
98
            push @messages, { type => 'message', code => 'success_on_update' };
168
                    ? $input->param('remoteImage')
99
        }
169
                    : $input->param('image') . ""
100
    } elsif ( not $itemtype and not $is_a_modif ) {
170
                )
101
        my $itemtype = Koha::ItemType->new(
171
            ),
102
            {   itemtype       => $itemtype_code,
172
            $input->param('summary'),
103
                description    => $description,
173
            $input->param('checkinmsg'),
104
                rentalcharge   => $rentalcharge,
174
            $input->param('checkinmsgtype'),
105
                notforloan     => $notforloan,
175
            $sip_media_type,
106
                imageurl       => $imageurl,
176
            $input->param('itemtype')
107
                summary        => $summary,
177
        );
108
                checkinmsg     => $checkinmsg,
178
    }
109
                checkinmsgtype => $checkinmsgtype,
179
    elsif ( not $already_exists and not $is_a_modif ) {
110
                sip_media_type => $sip_media_type,
180
        my $query = "
111
            }
181
            INSERT INTO itemtypes
182
                (itemtype,description,rentalcharge, notforloan, imageurl, summary, checkinmsg, checkinmsgtype, sip_media_type)
183
            VALUES
184
                (?,?,?,?,?,?,?,?,?);
185
            ";
186
        my $sth = $dbh->prepare($query);
187
		my $image = $input->param('image');
188
        $sth->execute(
189
            $input->param('itemtype'),
190
            $input->param('description'),
191
            $input->param('rentalcharge'),
192
            $input->param('notforloan') ? 1 : 0,
193
            $image eq 'removeImage' ?           ''                 :
194
            $image eq 'remoteImage' ? $input->param('remoteImage') :
195
            $image,
196
            $input->param('summary'),
197
            $input->param('checkinmsg'),
198
            $input->param('checkinmsgtype'),
199
            $sip_media_type,
200
        );
112
        );
201
    }
113
        eval { $itemtype->store; };
202
    else {
114
203
        push @messages, {
115
        if ($@) {
204
            type => 'error',
116
            push @messages, { type => 'error', code => 'error_on_insert' };
117
        } else {
118
            push @messages, { type => 'message', code => 'success_on_insert' };
119
        }
120
    } else {
121
        push @messages,
122
          { type => 'error',
205
            code => 'already_exists',
123
            code => 'already_exists',
206
        };
124
          };
207
    }
125
    }
208
126
209
    $searchfield = '';
127
    $searchfield = '';
210
    $op = 'list';
128
    $op          = 'list';
211
    # END $OP eq ADD_VALIDATE
129
} elsif ( $op eq 'delete_confirm' ) {
212
################## DELETE_CONFIRM ##################################
130
213
    # called by default form, used to confirm deletion of data in DB
214
}
215
elsif ( $op eq 'delete_confirm' ) {
216
    # Check both items and biblioitems
131
    # Check both items and biblioitems
217
    my $sth = $dbh->prepare('
132
    my ($total) = $dbh->selectrow_array( '
218
        SELECT COUNT(*) AS total FROM (
133
        SELECT COUNT(*) AS total FROM (
219
            SELECT itemtype AS t FROM biblioitems
134
            SELECT itemtype AS t FROM biblioitems
220
            UNION ALL
135
            UNION ALL
221
            SELECT itype AS t FROM items
136
            SELECT itype AS t FROM items
222
        ) AS tmp
137
        ) AS tmp
223
        WHERE tmp.t=?
138
        WHERE tmp.t=?
224
    ');
139
    ', {}, $itemtype_code );
225
    $sth->execute($itemtype);
140
226
    my $total = $sth->fetchrow_hashref->{'total'};
141
    if ($total) {
142
        push @messages, { type => 'error', code => 'cannot_be_deleted', total => $total };
143
        $op = 'list';
144
    } else {
145
        my $itemtype = Koha::ItemTypes->find($itemtype_code);
146
        $template->param( itemtype => $itemtype, );
147
    }
227
148
228
    my $sth =
149
} elsif ( $op eq 'delete_confirmed' ) {
229
      $dbh->prepare(
150
    my $itemtype = Koha::ItemTypes->find($itemtype_code);
230
"select itemtype,description,rentalcharge from itemtypes where itemtype=?"
151
    my $deleted = eval { $itemtype->delete };
231
      );
152
    if ( $@ or not $deleted ) {
232
    $sth->execute($itemtype);
153
        push @messages, { type => 'error', code => 'error_on_delete' };
233
    my $data = $sth->fetchrow_hashref;
154
    } else {
234
    $template->param(
155
        push @messages, { type => 'message', code => 'success_on_delete' };
235
        itemtype        => $itemtype,
156
    }
236
        description     => $data->{description},
237
        rentalcharge    => sprintf( "%.2f", $data->{rentalcharge} ),
238
        imageurl        => $data->{imageurl},
239
        total           => $total
240
    );
241
157
242
    # END $OP eq DELETE_CONFIRM
158
    $op = 'list';
243
################## DELETE_CONFIRMED ##################################
244
  # called by delete_confirm, used to effectively confirm deletion of data in DB
245
}
246
elsif ( $op eq 'delete_confirmed' ) {
247
    my $itemtype = uc( $input->param('itemtype') );
248
    my $sth      = $dbh->prepare("delete from itemtypes where itemtype=?");
249
    $sth->execute($itemtype);
250
    $sth = $dbh->prepare("delete from issuingrules where itemtype=?");
251
    $sth->execute($itemtype);
252
    print $input->redirect('itemtypes.pl');
253
    exit;
254
    # END $OP eq DELETE_CONFIRMED
255
################## DEFAULT ##################################
256
}
159
}
257
160
258
if ( $op eq 'list' ) {
161
if ( $op eq 'list' ) {
259
    my $results = C4::Koha::GetItemTypes( style => 'array' );
162
    my $itemtypes = Koha::ItemTypes->search;
260
    my @loop;
261
    foreach my $itemtype ( @{$results} ) {
262
        $itemtype->{imageurl} = getitemtypeimagelocation( 'intranet', $itemtype->{imageurl} );
263
        $itemtype->{rentalcharge} = sprintf( '%.2f', $itemtype->{rentalcharge} );
264
265
        my @translated_descriptions = Koha::Localizations->search(
266
            {   entity => 'itemtypes',
267
                code   => $itemtype->{itemtype},
268
            }
269
        );
270
        $itemtype->{translated_descriptions} = [ map {
271
            {
272
                lang => $_->lang,
273
                translation => $_->translation,
274
            }
275
        } @translated_descriptions ];
276
277
        push( @loop, $itemtype );
278
    }
279
280
    $template->param(
163
    $template->param(
281
        loop     => \@loop,
164
        itemtypes => $itemtypes,
282
        else     => 1,
165
        messages  => \@messages,
283
        messages => \@messages,
284
    );
166
    );
285
}
167
}
286
168
169
$template->param( op => $op );
170
287
output_html_with_http_headers $input, $cookie, $template->output;
171
output_html_with_http_headers $input, $cookie, $template->output;
(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/itemtypes.tt (-246 / +270 lines)
Lines 1-20 Link Here
1
[% USE Koha %]
1
[% USE AuthorisedValues %]
2
[% USE AuthorisedValues %]
3
[% USE Price %]
2
[% INCLUDE 'doc-head-open.inc' %]
4
[% INCLUDE 'doc-head-open.inc' %]
3
<title>Koha &rsaquo; Administration &rsaquo; Item types [% IF ( add_form ) %]&rsaquo;
5
<title>Koha &rsaquo; Administration &rsaquo; Item types [% IF op == 'add_form' %]&rsaquo;
4
  [% IF ( itemtype ) %]
6
  [% IF ( itemtype ) %]
5
Modify item type '[% itemtype %]'
7
Modify item type '[% itemtype.itemtype %]'
6
  [% ELSE %]
8
  [% ELSE %]
7
Add item type
9
Add item type
8
  [% END %]
10
  [% END %]
9
[% END %]
11
[% END %]
10
[% IF ( delete_confirm ) %]&rsaquo; 
12
[% IF op == 'delete_confirm' %]&rsaquo; 
11
  [% IF ( total ) %]
13
  [% IF ( total ) %]
12
Cannot delete item type '[% itemtype %]'
14
Cannot delete item type '[% itemtype.itemtype %]'
13
  [% ELSE %]
15
  [% ELSE %]
14
Delete item type '[% itemtype %]'?
16
Delete item type '[% itemtype.itemtype %]'?
15
  [% END %]
17
  [% END %]
16
[% END %]
18
[% END %]
17
[% IF ( delete_confirmed ) %]&rsaquo; 
19
[% IF op == 'delete_confirmed' %]&rsaquo; 
18
Data deleted
20
Data deleted
19
[% END %]
21
[% END %]
20
</title>
22
</title>
Lines 55-335 Data deleted Link Here
55
[% INCLUDE 'header.inc' %]
57
[% INCLUDE 'header.inc' %]
56
[% INCLUDE 'cat-search.inc' %]
58
[% INCLUDE 'cat-search.inc' %]
57
59
58
<div id="breadcrumbs"><a href="/cgi-bin/koha/mainpage.pl">Home</a> &rsaquo; <a href="/cgi-bin/koha/admin/admin-home.pl">Administration</a> &rsaquo; [% IF ( add_form ) %]
60
<div id="breadcrumbs"><a href="/cgi-bin/koha/mainpage.pl">Home</a> &rsaquo; <a href="/cgi-bin/koha/admin/admin-home.pl">Administration</a> &rsaquo; [% IF op == 'add_form' %]
59
  [% IF ( itemtype ) %]
61
  [% IF itemtype %]
60
<a href="/cgi-bin/koha/admin/itemtypes.pl">Item types</a> &rsaquo; Modify item type '[% itemtype %]'
62
<a href="/cgi-bin/koha/admin/itemtypes.pl">Item types</a> &rsaquo; Modify item type '[% itemtype.itemtype %]'
61
  [% ELSE %]
63
  [% ELSE %]
62
<a href="/cgi-bin/koha/admin/itemtypes.pl">Item types</a> &rsaquo; Add item type
64
<a href="/cgi-bin/koha/admin/itemtypes.pl">Item types</a> &rsaquo; Add item type
63
  [% END %]
65
  [% END %]
64
[% END %]
66
[% END %]
65
[% IF ( delete_confirm ) %]
67
[% IF op == 'delete_confirm' %]
66
  [% IF ( total ) %]
68
  [% IF total %]
67
<a href="/cgi-bin/koha/admin/itemtypes.pl">Item types</a> &rsaquo; Cannot delete item type '[% itemtype %]'
69
<a href="/cgi-bin/koha/admin/itemtypes.pl">Item types</a> &rsaquo; Cannot delete item type '[% itemtype.itemtype %]'
68
  [% ELSE %]
70
  [% ELSE %]
69
<a href="/cgi-bin/koha/admin/itemtypes.pl">Item types</a> &rsaquo; Delete item type '[% itemtype %]'?
71
<a href="/cgi-bin/koha/admin/itemtypes.pl">Item types</a> &rsaquo; Delete item type '[% itemtype.itemtype %]'?
70
  [% END %]
72
  [% END %]
71
[% END %]
73
[% END %]
72
[% IF ( delete_confirmed ) %]
74
[% IF op == 'delete_confirmed' %]
73
<a href="/cgi-bin/koha/admin/itemtypes.pl">Item types</a> &rsaquo;Data deleted
75
<a href="/cgi-bin/koha/admin/itemtypes.pl">Item types</a> &rsaquo;Data deleted
74
[% END %]
76
[% END %]
75
[% IF ( else ) %]
77
[% IF op == 'list' %]
76
Item types administration
78
Item types administration
77
[% END %]</div>
79
[% END %]</div>
78
80
79
<div id="doc3" class="yui-t2">
81
<div id="doc3" class="yui-t2">
80
   
82
81
   <div id="bd">
83
   <div id="bd">
82
	<div id="yui-main">
84
	<div id="yui-main">
83
	<div class="yui-b">
85
	<div class="yui-b">
84
	
86
85
[% IF ( else ) %]<div id="toolbar" class="btn-toolbar">
87
[% IF op == 'list' %]<div id="toolbar" class="btn-toolbar">
86
    <a class="btn btn-small" id="newitemtype" href="/cgi-bin/koha/admin/itemtypes.pl?op=add_form"><i class="icon-plus"></i> New item type</a>
88
    <a class="btn btn-small" id="newitemtype" href="/cgi-bin/koha/admin/itemtypes.pl?op=add_form"><i class="icon-plus"></i> New item type</a>
87
</div>[% END %]
89
</div>[% END %]
88
90
89
[% FOREACH message IN messages %]
91
[% FOREACH m IN messages %]
90
  [% IF message.type == 'success' %]
92
    <div class="dialog [% m.type %]">
91
    <div class="dialog message">
93
        [% SWITCH m.code %]
92
  [% ELSIF message.type == 'warning' %]
94
        [% CASE 'error_on_update' %]
93
    <div class="dialog alert">
95
            An error occurred when updating this item type. Perhaps the value already exists.
94
  [% ELSIF message.type == 'error' %]
96
        [% CASE 'error_on_insert' %]
95
    <div class="dialog error" style="margin:auto;">
97
            An error occurred when inserting this item type. Perhaps the value already exists.
96
  [% END %]
98
        [% CASE 'error_on_delete' %]
97
  [% IF message.code == 'already_exists' %]
99
            An error occurred when deleting this item type. Check the logs.
98
    This item type already exists.
100
        [% CASE 'success_on_update' %]
99
  [% END %]
101
            Item type updated successfully.
100
  </div>
102
        [% CASE 'success_on_insert' %]
103
            Item type inserted successfully.
104
        [% CASE 'success_on_delete' %]
105
            Item type deleted successfully.
106
        [% CASE 'already_exists' %]
107
            This item type already exists.
108
        [% CASE 'cannot_be_deleted' %]
109
            Cannot delete this item type. <p><strong>This record is used [% m.total %] times</strong>. Deletion is not possible.</p>
110
        [% CASE %]
111
            [% m.code %]
112
        [% END %]
113
    </div>
101
[% END %]
114
[% END %]
102
115
103
116
104
[% IF ( add_form ) %]
117
[% IF op == 'add_form' %]
105
  [% IF ( itemtype ) %]
118
    [% IF itemtype %]
106
      <h3>Modify item type</h3>
119
        <h3>Modify item type</h3>
107
  [% ELSE %]
108
      <h3>Add item type</h3>
109
  [% END %]
110
<form action="[% script_name %]" name="Aform" method="post" id="itemtypeentry">
111
  <input type="hidden" name="op" value="add_validate" />
112
    <input type="hidden" name="checked" value="0" />
113
		
114
    <fieldset class="rows">
115
	<ol>
116
  [% IF ( itemtype ) %]
117
      <li>
118
          <input type="hidden" name="is_a_modif" value="1" />
119
          <span class="label">Item type: </span> <input type="hidden" name="itemtype" value="[% itemtype %]" />
120
          [% itemtype %]
121
     </li>
122
  [% ELSE %]
123
      <li>
124
          <label for="itemtype" class="required">Item type: </label> <input type="text" id="itemtype" name="itemtype" size="10" maxlength="10" onblur="toUC(this)" required="required" /> <span class="required">Required</span>
125
      </li>
126
  [% END %]
127
      <li>
128
          <label for="description" class="required">Description: </label><input type="text" id="description" name="description" size="48" value="[% description |html %]" required="required" /> <span class="required">Required</span>
129
          <a href="/cgi-bin/koha/admin/localization.pl?entity=itemtypes&code=[% itemtype %]" title="Translate" rel="gb_page_center[600,500]"><i class="icon-edit"></i> Translate for other languages</a>
130
      </li>
131
     [% IF ( noItemTypeImages ) %]
132
	 <li><span class="label">Image: </span>Item type images are disabled. To enable them, turn off the <a href="/cgi-bin/koha/admin/preferences.pl?op=search&amp;searchfield=noItemTypeImages">noItemTypeImages system preference</a></li></ol>
133
	 [% ELSE %]</ol>
134
    <div id="icons" class="toptabs" style="clear:both">
135
        <h5 style="margin-left:10px;">Choose an icon:</h5>
136
			<ul>
137
          <li><a href="#none">None</a></li>
138
				  [% FOREACH imageset IN imagesets %]
139
            [% IF ( imageset.imagesetactive ) %]<li class="ui-tabs-active">[% ELSE %]<li>[% END %]<a href="#[% imageset.imagesetname %]">[% imageset.imagesetname %]</a></li>
140
				  [% END %]
141
                  [% IF ( remote_image ) %]<li class="ui-tabs-active">[% ELSE %]<li>[% END %]<a href="#remote">Remote image</a></li>
142
			</ul>
143
  <div id="none"><ul>
144
  <li><label for="noimage">No image: </label><input type="radio" name="image" id="noimage" value="removeImage" /></li>
145
  </ul>
146
  <br class="clear" /></div>
147
148
  [% FOREACH imageset IN imagesets %]
149
  <div id="[% imageset.imagesetname %]"><ul>
150
  [% FOREACH image IN imageset.images %]
151
			<li style="float: none; display: inline-block; clear : none; width: auto;">
152
            <label> [% IF ( image.StaffImageUrl ) %]
153
              <img src="[% image.StaffImageUrl %]" alt="[% image.StaffImageUrl %]" title="[% image.StaffImageUrl %]" />
154
        [% ELSE %]
155
        [% END %]
156
    [% IF ( image.checked ) %]
157
              <input type="radio" name="image" value="[% image.KohaImage %]" checked="checked" />
158
    [% ELSE %]
120
    [% ELSE %]
159
              [% IF ( image.KohaImage ) %] <!-- to delete the radio button if there is no image after -->
121
        <h3>Add item type</h3>
160
              <input type="radio" name="image" value="[% image.KohaImage %]" />
161
              [% END %]
162
    [% END %]
122
    [% END %]
163
            </label>
123
    <form action="/cgi-bin/koha/admin/itemtypes.pl" name="Aform" method="post" id="itemtypeentry">
164
			</li>
124
        <input type="hidden" name="op" value="add_validate" />
165
  [% END %]
125
        <fieldset class="rows">
166
  </ul>
126
            <ol>
167
  <br class="clear" />
127
                [% IF itemtype %]
168
  </div>
128
                    <li>
169
  [% END %]
129
                        <input type="hidden" name="is_a_modif" value="1" />
170
<div id="remote"><ul>
130
                        <span class="label">Item type: </span> <input type="hidden" name="itemtype" value="[% itemtype.itemtype %]" />
171
<li> <label for="remote_image_check"> Remote image:</label>
131
                        [% itemtype.itemtype %]
172
  [% IF ( remote_image ) %]
132
                    </li>
173
            <input type="radio" id="remote_image_check" name="image" value="remoteImage" checked="checked" />
133
                [% ELSE %]
174
  [% ELSE %]
134
                    <li>
175
            <input type="radio" id="remote_image_check" name="image" value="remoteImage" />
135
                        <label for="itemtype" class="required">Item type: </label>
176
  [% END %]<input type="text" name="remoteImage" size="48" maxlength="200" value="[% remote_image %]" onmousedown="document.getElementById('remote_image_check').checked = true;" /> [% IF ( remote_image ) %]
136
                        <input type="text" id="itemtype" name="itemtype" size="10" maxlength="10" onblur="toUC(this)" required="required" /> <span class="required">Required</span>
177
            <img src="[% remote_image %]" alt="" />
137
                    </li>
178
  [% END %]</li>
138
                [% END %]
179
</ul>
139
                <li>
180
  <br class="clear" />
140
                    <label for="description" class="required">Description: </label>
181
</div>
141
                    <input type="text" id="description" name="description" size="48" value="[% itemtype.description |html %]" required="required" /> <span class="required">Required</span>
182
</div>
142
                    <a href="/cgi-bin/koha/admin/localization.pl?entity=itemtypes&code=[% itemtype.itemtype %]" title="Translate" rel="gb_page_center[600,500]"><i class="icon-edit"></i> Translate for other languages</a>
183
[% END %]
143
                </li>
184
<ol>
144
                [% IF Koha.Preference('noItemTypeImages') %]
185
      <li>
145
                    <li>
186
          <label for="notforloan">Not for loan: </label>   [% IF ( notforloan ) %]
146
                        <span class="label">Image: </span>Item type images are disabled. To enable them, turn off the <a href="/cgi-bin/koha/admin/preferences.pl?op=search&amp;searchfield=noItemTypeImages">noItemTypeImages system preference</a>
187
                <input type="checkbox" id="notforloan" name="notforloan" checked="checked" value="1" />
147
                    </li>
188
            [% ELSE %]
148
                [% END %]
189
                <input type="checkbox" id="notforloan" name="notforloan" value="1" />
149
            </ol>
190
            [% END %]
150
            [% UNLESS Koha.Preference('noItemTypeImages') %]
191
          (if checked, no item of this type can be issued. If not checked, every item of this type can be issued unless notforloan is set for a specific item)
151
                <div id="icons" class="toptabs" style="clear:both">
192
        
152
                    <h5 style="margin-left:10px;">Choose an icon:</h5>
193
      </li>
153
                    <ul>
194
      <li>
154
                        <li><a href="#none">None</a></li>
195
          <label for="rentalcharge">Rental charge: </label>
155
                        [% FOREACH imageset IN imagesets %]
196
		  <input type="text" id="rentalcharge" name="rentalcharge" size="10" value="[% rentalcharge %]" />
156
                            [% IF ( imageset.imagesetactive ) %]
197
         </li>
157
                                <li class="ui-tabs-active">
198
      <li>
158
                            [% ELSE %]
199
          <label for="checkinmsg">Checkin message: </label>
159
                                <li>
200
          <textarea id="checkinmsg" name="checkinmsg" cols="55" rows="5">[% checkinmsg %]</textarea>
160
                            [% END %]
201
      </li>
161
                            <a href="#[% imageset.imagesetname %]">[% imageset.imagesetname %]</a>
202
      <li>
162
                            </li>
203
          <label for="checkinmsgtype">Checkin message type: </label>
163
                        [% END %]
204
          <select type="text" id="checkinmsgtype" name="checkinmsgtype">
164
                        [% IF itemtype.image_location.match('^http') %]<li class="ui-tabs-active">[% ELSE %]<li>[% END %]<a href="#remote">Remote image</a></li>
205
              [% IF ( checkinmsgtype == 'message' ) %]
165
                    </ul>
206
              <option value="message" selected="selected">Message</option>
166
                    <div id="none">
207
              [% ELSE %]
167
                        <ul>
208
                 <option value="message">Message</option>
168
                            <li><label for="noimage">No image: </label><input type="radio" name="image" id="noimage" value="removeImage" /></li>
209
              [% END %]
169
                        </ul>
210
              [% IF ( checkinmsgtype == 'alert' ) %]
170
                        <br class="clear" />
211
              <option value="alert" selected="selected">Alert</option>
171
                    </div>
212
              [% ELSE %]
213
                  <option value="alert">Alert</option>
214
              [% END %]
215
          </select>
216
      </li>
217
      <li>
218
          <label for="sip_media_type">SIP media type: </label>
219
          <select id="sip_media_type" name="sip_media_type">
220
              <option value=""></option>
221
              [% FOREACH a IN AuthorisedValues.Get('SIP_MEDIA_TYPE', sip_media_type ) %]
222
                  [% IF a.selected %]
223
                      <option value="[% a.authorised_value %]" selected="selected">[% a.lib %]</option>
224
                  [% ELSE %]
225
                      <option value="[% a.authorised_value %]">[% a.lib %]</option>
226
                  [% END %]
227
              [% END %]
228
          </select>
229
      </li>
230
      <li>
231
          <label for="summary">Summary: </label>
232
         <textarea id="summary" name="summary" cols="55" rows="5">[% summary %]</textarea>
233
          <p>Enter a summary that will overwrite the default one in search results lists. Example, for a website itemtype : </p>
234
          <p><b>&lt;a href="[856u]"&gt;open site&lt;/a&gt;</b> will show the link just below the title</p>
235
      </li>
236
	  </ol>
237
    </fieldset>
238
172
239
    <fieldset class="action">
173
                    [% FOREACH imageset IN imagesets %]
240
      <input type="submit" value="Save changes" />
174
                        <div id="[% imageset.imagesetname %]">
241
	  <a href="/cgi-bin/koha/admin/itemtypes.pl" class="cancel">Cancel</a>
175
                            <ul>
242
    </fieldset>
176
                                [% FOREACH image IN imageset.images %]
243
</form>
177
                                    <li style="float: none; display: inline-block; clear : none; width: auto;">
244
[% END %]
178
                                        <label>
179
                                            [% IF image.StaffImageUrl %]
180
                                                <img src="[% image.StaffImageUrl %]" alt="[% image.StaffImageUrl %]" title="[% image.StaffImageUrl %]" />
181
                                            [% END %]
182
                                            [% IF image.checked %]
183
                                                <input type="radio" name="image" value="[% image.KohaImage %]" checked="checked" />
184
                                            [% ELSIF image.KohaImage %] <!-- to delete the radio button if there is no image after -->
185
                                                <input type="radio" name="image" value="[% image.KohaImage %]" />
186
                                            [% END %]
187
                                        </label>
188
                                    </li>
189
                                [% END %]
190
                            </ul>
191
                            <br class="clear" />
192
                        </div>
193
                    [% END %]
245
194
246
[% IF ( delete_confirm ) %]
195
                    <div id="remote">
247
[% IF ( total ) %]<div class="dialog message">
196
                        <ul>
248
<h3>Cannot delete item type</h3>
197
                            <li>
249
<p><strong>This record is used [% total %] times</strong>. Deletion is not possible.</p>
198
                                <label for="remote_image_check"> Remote image:</label>
250
[% ELSE %]<div class="dialog alert">
199
                                [% IF remote_image %]
251
<h3>Delete item type '[% itemtype %]'?</h3>
200
                                    <input type="radio" id="remote_image_check" name="image" value="remoteImage" checked="checked" />
201
                                [% ELSE %]
202
                                    <input type="radio" id="remote_image_check" name="image" value="remoteImage" />
203
                                [% END %]
204
                                <input type="text" name="remoteImage" size="48" maxlength="200" value="[% remote_image %]" onmousedown="document.getElementById('remote_image_check').checked = true;" />
205
                                [% IF ( remote_image ) %]
206
                                    <img src="[% remote_image %]" alt="" />
207
                                [% END %]
208
                            </li>
209
                        </ul>
210
                        <br class="clear" />
211
                    </div>
212
                </div>
213
            [% END %]
214
            <ol>
215
                <li>
216
                    <label for="notforloan">Not for loan: </label>
217
                        [% IF itemtype.notforloan %]
218
                            <input type="checkbox" id="notforloan" name="notforloan" checked="checked" value="1" />
219
                        [% ELSE %]
220
                            <input type="checkbox" id="notforloan" name="notforloan" value="1" />
221
                        [% END %]
222
                      (if checked, no item of this type can be issued. If not checked, every item of this type can be issued unless notforloan is set for a specific item)
223
                </li>
224
                <li>
225
                    <label for="rentalcharge">Rental charge: </label>
226
                    <input type="text" id="rentalcharge" name="rentalcharge" size="10" value="[% itemtype.rentalcharge %]" />
227
                </li>
228
                <li>
229
                    <label for="checkinmsg">Checkin message: </label>
230
                    <textarea id="checkinmsg" name="checkinmsg" cols="55" rows="5">[% itemtype.checkinmsg %]</textarea>
231
                </li>
232
                <li>
233
                    <label for="checkinmsgtype">Checkin message type: </label>
234
                    <select type="text" id="checkinmsgtype" name="checkinmsgtype">
235
                        [% IF itemtype.checkinmsgtype == 'message' %]
236
                            <option value="message" selected="selected">Message</option>
237
                        [% ELSE %]
238
                            <option value="message">Message</option>
239
                        [% END %]
240
                        [% IF itemtype.checkinmsgtype == 'alert' %]
241
                            <option value="alert" selected="selected">Alert</option>
242
                        [% ELSE %]
243
                            <option value="alert">Alert</option>
244
                        [% END %]
245
                    </select>
246
                </li>
247
                <li>
248
                    <label for="sip_media_type">SIP media type: </label>
249
                    <select id="sip_media_type" name="sip_media_type">
250
                        <option value=""></option>
251
                        [% FOREACH a IN AuthorisedValues.Get('SIP_MEDIA_TYPE', itemtype.sip_media_type ) %]
252
                            [% IF a.selected %]
253
                                <option value="[% a.authorised_value %]" selected="selected">[% a.lib %]</option>
254
                            [% ELSE %]
255
                                <option value="[% a.authorised_value %]">[% a.lib %]</option>
256
                            [% END %]
257
                        [% END %]
258
                    </select>
259
                </li>
260
                <li>
261
                    <label for="summary">Summary: </label>
262
                   <textarea id="summary" name="summary" cols="55" rows="5">[% itemtype.summary %]</textarea>
263
                    <p>Enter a summary that will overwrite the default one in search results lists. Example, for a website itemtype : </p>
264
                    <p><b>&lt;a href="[856u]"&gt;open site&lt;/a&gt;</b> will show the link just below the title</p>
265
                </li>
266
            </ol>
267
        </fieldset>
268
269
        <fieldset class="action">
270
            <input type="submit" value="Save changes" />
271
            <a href="/cgi-bin/koha/admin/itemtypes.pl" class="cancel">Cancel</a>
272
        </fieldset>
273
    </form>
252
[% END %]
274
[% END %]
253
<table>
254
		<tr>
255
			<th scope="row">Item type</th>
256
			<td>[% itemtype %]</td>
257
		</tr>
258
275
259
	<tr><th scope="row">Description</th><td>[% translated_description %]</td></tr>
276
[% IF op == 'delete_confirm' %]
260
	<tr><th scope="row">Loan length</th><td>[% loanlength %]</td></tr>
277
    <div class="dialog message">
261
<tr><th scope="row">Rental charge</th><td>[% rentalcharge %]</td></tr></table>
278
        <h3>Delete item type '[% itemtype.itemtype %]'?</h3>
262
		<form action="[% script_name %]" method="post">
279
        <table>
263
		<input type="hidden" name="op" value="delete_confirmed" /><input type="hidden" name="itemtype" value="[% itemtype %]" />[% IF ( total ) %]
280
            <tr>
264
		</form>
281
                <th scope="row">Item type</th>
265
		
282
                <td>[% itemtype.itemtype %]</td>
266
		<form action="[% script_name %]" method="post"><input type="submit" class="approve" value="OK" /></form>
283
            </tr>
267
	[% ELSE %]
284
            <tr><th scope="row">Description</th><td>[% itemtype.translated_description %]</td></tr>
268
		<input type="submit" class="approve" value="Delete this Item Type" /></form> <form action="[% script_name %]" method="post"><input type="submit" class="deny" value="Do Not Delete" /></form>
285
            [% UNLESS Koha.Preference('noItemTypeImages') %]
269
	[% END %]
286
                <tr>
270
</div>
287
                    <th scope="row">Image</th>
271
	
288
                    <td>
289
                        [% IF itemtype.image_location %]<img src="[% itemtype.image_location %]" alt="" />[% END %]
290
                    </td>
291
                </tr>
292
            [% END %]
293
            <tr><th scope="row">Rental charge</th><td>[% itemtype.rentalcharge | $Price %]</td></tr>
294
        </table>
295
        <form action="/cgi-bin/koha/admin/itemtypes.pl" method="post">
296
            <input type="hidden" name="op" value="delete_confirmed" /><input type="hidden" name="itemtype" value="[% itemtype.itemtype %]" />
297
            <input type="submit" class="approve" value="Delete this Item Type" />
298
        </form>
299
        <form action="/cgi-bin/koha/admin/itemtypes.pl" method="post"><input type="submit" class="deny" value="Do Not Delete" /></form>
300
    </div>
272
[% END %]
301
[% END %]
273
302
274
[% IF ( else ) %]
303
[% IF op == 'list' %]
275
<h2>Item types administration</h2>
304
    <h2>Item types administration</h2>
276
[% IF ( loop ) %]
305
    [% IF itemtypes %]
277
<table id="table_item_type">
306
        <table id="table_item_type">
278
  <thead>
307
          <thead>
279
    [% UNLESS ( noItemTypeImages ) %]<th>Image</th>[% END %]
308
            [% UNLESS Koha.Preference('noItemTypeImages') %]<th>Image</th>[% END %]
280
    <th>Code</th>
309
            <th>Code</th>
281
    <th>Description</th>
310
            <th>Description</th>
282
    <th>Not for loan</th>
311
            <th>Not for loan</th>
283
    <th>Charge</th>
312
            <th>Charge</th>
284
    <th>Checkin message</th>
313
            <th>Checkin message</th>
285
    <th>Actions</th>
314
            <th>Actions</th>
286
  </thead>
315
          </thead>
287
  [% FOREACH loo IN loop %]
316
          [% FOREACH itemtype IN itemtypes %]
288
    <tr>
317
            <tr>
289
   [% UNLESS ( noItemTypeImages ) %] <td>[% IF ( loo.imageurl ) %]<img src="[% loo.imageurl %]" alt="" />[% ELSE %]&nbsp;[% END %]</td>[% END %]
318
           [% UNLESS Koha.Preference('noItemTypeImages') %] <td>[% IF itemtype.image_location %]<img src="[% itemtype.image_location %]" alt="" />[% ELSE %]&nbsp;[% END %]</td>[% END %]
290
    <td>
319
            <td>
291
      <a href="[% loo.script_name %]?op=add_form&amp;itemtype=[% loo.itemtype |html %]">
320
              <a href="/cgi-bin/koha/admin/itemtypes.pl?op=add_form&amp;itemtype=[% itemtype.itemtype |html %]">
292
        [% loo.itemtype %]
321
                [% itemtype.itemtype %]
293
      </a>
322
              </a>
294
    </td>
323
            </td>
295
    <td>
324
            <td>
296
        [% IF loo.translated_descriptions.size %]
325
                [% IF itemtype.translated_descriptions.size %]
297
            [% loo.description %] (default)<br/>
326
                    [% itemtype.description %] (default)<br/>
298
            [% FOR description IN loo.translated_descriptions %]
327
                    [% FOR description IN itemtype.translated_descriptions %]
299
                [% IF description.translation == loo.translated_description %]
328
                        [% IF description.translation == itemtype.translated_description %]
300
                    <b>[% description.translation %]</b>
329
                            <b>[% description.translation %]</b>
330
                        [% ELSE %]
331
                            [% description.translation %] ([% description.lang %])
332
                        [% END %]
333
                        <br/>
334
                    [% END %]
301
                [% ELSE %]
335
                [% ELSE %]
302
                    [% description.translation %] ([% description.lang %])
336
                    [% itemtype.description %]
303
                [% END %]
337
                [% END %]
304
                <br/>
338
            </td>
339
            <td>[% IF ( itemtype.notforloan ) %]Yes[% ELSE %]&nbsp;[% END %]</td>
340
            <td>
341
            [% UNLESS ( itemtype.notforloan ) %]
342
              [% itemtype.rentalcharge | $Price %]
305
            [% END %]
343
            [% END %]
306
        [% ELSE %]
344
            </td>
307
            [% loo.description %]
345
            <td>[% itemtype.checkinmsg | html_line_break %]</td>
308
        [% END %]
346
            <td>
309
    </td>
347
              <a href="/cgi-bin/koha/admin/itemtypes.pl?op=add_form&amp;itemtype=[% itemtype.itemtype |html %]">Edit</a>
310
    <td>[% IF ( loo.notforloan ) %]Yes[% ELSE %]&nbsp;[% END %]</td>
348
              <a href="/cgi-bin/koha/admin/itemtypes.pl?op=delete_confirm&amp;itemtype=[% itemtype.itemtype |html %]">Delete</a>
311
    <td>
349
            </td>
312
    [% UNLESS ( loo.notforloan ) %]
350
          </tr>
313
      [% loo.rentalcharge %]
351
          [% END %]
352
        </table>
353
    [% ELSE %]
354
        <div class="dialog message">There are no itemtypes defined</div>
314
    [% END %]
355
    [% END %]
315
    </td>
316
    <td>[% loo.checkinmsg | html_line_break %]</td>
317
    <td>
318
      <a href="[% loo.script_name %]?op=add_form&amp;itemtype=[% loo.itemtype |html %]">Edit</a>
319
      <a href="[% loo.script_name %]?op=delete_confirm&amp;itemtype=[% loo.itemtype |html %]">Delete</a>
320
    </td>
321
  </tr>
322
  [% END %]
323
</table>[% ELSE %]
324
<div class="dialog message">There are no itemtypes defined</div>
325
[% END %]
356
[% END %]
326
357
327
<div class="pages">[% pagination_bar %]</div>
328
329
[% END %]
330
331
332
333
</div>
358
</div>
334
</div>
359
</div>
335
<div class="yui-b">
360
<div class="yui-b">
336
- 

Return to bug 14828