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

(-)a/C4/ItemType.pm (+27 lines)
Lines 90-95 sub all { Link Here
90
90
91
91
92
92
93
=head3 C4::ItemType->get
94
95
Return the itemtype indicated by the itemtype given as argument, as
96
an object.
97
98
=cut
99
100
sub get {
101
    my ($class, $itemtype) = @_;
102
    my $dbh = C4::Context->dbh;
103
104
    my $data = $dbh->selectrow_hashref(
105
        "SELECT * FROM itemtypes WHERE itemtype = ?", undef, $itemtype
106
    );
107
    if ( $data->{description} ) {
108
        utf8::encode($data->{description});
109
    }
110
    return $class->new($data);
111
}
112
113
114
115
93
=head2 Object Methods
116
=head2 Object Methods
94
117
95
These are read-only accessors for attributes of a C4::ItemType object.
118
These are read-only accessors for attributes of a C4::ItemType object.
Lines 118-123 These are read-only accessors for attributes of a C4::ItemType object. Link Here
118
141
119
=cut
142
=cut
120
143
144
=head3 $itemtype->checkinmsg
145
146
=cut
147
121
=head3 $itemtype->summary
148
=head3 $itemtype->summary
122
149
123
=cut
150
=cut
(-)a/admin/itemtypes.pl (-1 / +5 lines)
Lines 117-122 if ( $op eq 'add_form' ) { Link Here
117
        imageurl        => $data->{'imageurl'},
117
        imageurl        => $data->{'imageurl'},
118
        template        => C4::Context->preference('template'),
118
        template        => C4::Context->preference('template'),
119
        summary         => $data->{summary},
119
        summary         => $data->{summary},
120
        checkinmsg      => $data->{'checkinmsg'},
120
        imagesets       => $imagesets,
121
        imagesets       => $imagesets,
121
        remote_image    => $remote_image,
122
        remote_image    => $remote_image,
122
    );
123
    );
Lines 140-145 elsif ( $op eq 'add_validate' ) { Link Here
140
                 , rentalcharge = ?
141
                 , rentalcharge = ?
141
                 , notforloan = ?
142
                 , notforloan = ?
142
                 , imageurl = ?
143
                 , imageurl = ?
144
                 , checkinmsg = ?
143
                 , summary = ?
145
                 , summary = ?
144
            WHERE itemtype = ?
146
            WHERE itemtype = ?
145
        ';
147
        ';
Lines 155-160 elsif ( $op eq 'add_validate' ) { Link Here
155
                    : $input->param('image') . ""
157
                    : $input->param('image') . ""
156
                )
158
                )
157
            ),
159
            ),
160
            $input->param('checkinmsg'),
158
            $input->param('summary'),
161
            $input->param('summary'),
159
            $input->param('itemtype')
162
            $input->param('itemtype')
160
        );
163
        );
Lines 162-168 elsif ( $op eq 'add_validate' ) { Link Here
162
    else {    # add a new itemtype & not modif an old
165
    else {    # add a new itemtype & not modif an old
163
        my $query = "
166
        my $query = "
164
            INSERT INTO itemtypes
167
            INSERT INTO itemtypes
165
                (itemtype,description,rentalcharge, notforloan, imageurl,summary)
168
                (itemtype,description,rentalcharge, notforloan, imageurl, checkinmsg, summary)
166
            VALUES
169
            VALUES
167
                (?,?,?,?,?,?);
170
                (?,?,?,?,?,?);
168
            ";
171
            ";
Lines 176-181 elsif ( $op eq 'add_validate' ) { Link Here
176
            $image eq 'removeImage' ?           ''                 :
179
            $image eq 'removeImage' ?           ''                 :
177
            $image eq 'remoteImage' ? $input->param('remoteImage') :
180
            $image eq 'remoteImage' ? $input->param('remoteImage') :
178
            $image,
181
            $image,
182
            $input->param('checkinmsg'),
179
            $input->param('summary'),
183
            $input->param('summary'),
180
        );
184
        );
181
    }
185
    }
(-)a/circ/returns.pl (+9 lines)
Lines 225-230 if ($barcode) { Link Here
225
    # fix up item type for display
225
    # fix up item type for display
226
    $biblio->{'itemtype'} = C4::Context->preference('item-level_itypes') ? $biblio->{'itype'} : $biblio->{'itemtype'};
226
    $biblio->{'itemtype'} = C4::Context->preference('item-level_itypes') ? $biblio->{'itype'} : $biblio->{'itemtype'};
227
227
228
    # Check if we should display a check in message, based on the the item
229
    # type of the checked in item
230
    my $itemtype = C4::ItemType->get( $biblio->{'itemtype'} );
231
    if ( $itemtype->{'checkinmsg'} ) {
232
        $template->param(
233
            checkinmsg => $itemtype->{'checkinmsg'},
234
        );
235
    }
236
228
    $template->param(
237
    $template->param(
229
        title            => $biblio->{'title'},
238
        title            => $biblio->{'title'},
230
        homebranch       => $biblio->{'homebranch'},
239
        homebranch       => $biblio->{'homebranch'},
(-)a/installer/data/mysql/kohastructure.sql (-6 / +7 lines)
Lines 1204-1215 CREATE TABLE `items` ( -- holdings/item information Link Here
1204
1204
1205
DROP TABLE IF EXISTS `itemtypes`;
1205
DROP TABLE IF EXISTS `itemtypes`;
1206
CREATE TABLE `itemtypes` ( -- defines the item types
1206
CREATE TABLE `itemtypes` ( -- defines the item types
1207
  `itemtype` varchar(10) NOT NULL default '', -- unique key, a code associated with the item type
1207
  itemtype varchar(10) NOT NULL default '', -- unique key, a code associated with the item type
1208
  `description` mediumtext, -- a plain text explanation of the item type
1208
  description mediumtext, -- a plain text explanation of the item type
1209
  `rentalcharge` double(16,4) default NULL, -- the amount charged when this item is checked out/issued
1209
  rentalcharge double(16,4) default NULL, -- the amount charged when this item is checked out/issued
1210
  `notforloan` smallint(6) default NULL, -- 1 if the item is not for loan, 0 if the item is available for loan
1210
  notforloan smallint(6) default NULL, -- 1 if the item is not for loan, 0 if the item is available for loan
1211
  `imageurl` varchar(200) default NULL, -- URL for the item type icon
1211
  imageurl varchar(200) default NULL, -- URL for the item type icon
1212
  `summary` text, -- information from the summary field, may include HTML
1212
  summary text, -- information from the summary field, may include HTML
1213
  checkinmsg VARCHAR(255), -- message that is displayed when an item with the given item type is checked in
1213
  PRIMARY KEY  (`itemtype`),
1214
  PRIMARY KEY  (`itemtype`),
1214
  UNIQUE KEY `itemtype` (`itemtype`)
1215
  UNIQUE KEY `itemtype` (`itemtype`)
1215
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
1216
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
(-)a/installer/data/mysql/updatedatabase.pl (+7 lines)
Lines 7017-7022 if ( CheckVersion($DBversion) ) { Link Here
7017
    SetVersion($DBversion);
7017
    SetVersion($DBversion);
7018
}
7018
}
7019
7019
7020
$DBversion = "3.13.00.XXX";
7021
if ( CheckVersion($DBversion) ) {
7022
    $dbh->do("ALTER TABLE itemtypes ADD COLUMN checkinmsg VARCHAR(255);");
7023
    print "Upgrade to $DBversion done (Bug 10513 - Light up a warning/message when returning a chosen item type)\n";
7024
    SetVersion($DBversion);
7025
}
7026
7020
=head1 FUNCTIONS
7027
=head1 FUNCTIONS
7021
7028
7022
=head2 TableExists($table)
7029
=head2 TableExists($table)
(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/itemtypes.tt (+6 lines)
Lines 229-234 Item types administration Link Here
229
		  <input type="text" id="rentalcharge" name="rentalcharge" size="10" value="[% rentalcharge %]" />
229
		  <input type="text" id="rentalcharge" name="rentalcharge" size="10" value="[% rentalcharge %]" />
230
         </li>
230
         </li>
231
      <li>
231
      <li>
232
          <label for="checkinmsg">Check in message: </label>
233
		  <input type="text" id="checkinmsg" name="checkinmsg" size="48" value="[% checkinmsg %]" />
234
      </li>
235
      <li>
232
          <label for="summary">Summary: </label>
236
          <label for="summary">Summary: </label>
233
         <textarea id="summary" name="summary" cols="55" rows="5">[% summary %]</textarea>
237
         <textarea id="summary" name="summary" cols="55" rows="5">[% summary %]</textarea>
234
          <p>Enter a summary that will overwrite the default one in search results lists. Example, for a website itemtype : </p>
238
          <p>Enter a summary that will overwrite the default one in search results lists. Example, for a website itemtype : </p>
Lines 282-287 Item types administration Link Here
282
    <th>Description</th>
286
    <th>Description</th>
283
    <th>Not for loan</th>
287
    <th>Not for loan</th>
284
    <th>Charge</th>
288
    <th>Charge</th>
289
    <th>Check in message</th>
285
    <th>Actions</th>
290
    <th>Actions</th>
286
  </thead>
291
  </thead>
287
  [% FOREACH loo IN loop %]
292
  [% FOREACH loo IN loop %]
Lines 303-308 Item types administration Link Here
303
      [% loo.rentalcharge %]
308
      [% loo.rentalcharge %]
304
    [% END %]
309
    [% END %]
305
    </td>
310
    </td>
311
    <td>[% loo.checkinmsg %]</td>
306
    <td>
312
    <td>
307
      <a href="[% loo.script_name %]?op=add_form&amp;itemtype=[% loo.itemtype |html %]">Edit</a>
313
      <a href="[% loo.script_name %]?op=add_form&amp;itemtype=[% loo.itemtype |html %]">Edit</a>
308
      <a href="[% loo.script_name %]?op=delete_confirm&amp;itemtype=[% loo.itemtype |html %]">Delete</a>
314
      <a href="[% loo.script_name %]?op=delete_confirm&amp;itemtype=[% loo.itemtype |html %]">Delete</a>
(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/circ/returns.tt (-1 / +4 lines)
Lines 315-321 $(document).ready(function () { Link Here
315
    [% END %]
315
    [% END %]
316
[% ELSE %]
316
[% ELSE %]
317
317
318
[% IF ( errmsgloop ) %]
318
[% IF ( errmsgloop || checkinmsg ) %]
319
    <div class="dialog alert">
319
    <div class="dialog alert">
320
        <h3>Check in message</h3>
320
        <h3>Check in message</h3>
321
        [% FOREACH errmsgloo IN errmsgloop %]
321
        [% FOREACH errmsgloo IN errmsgloop %]
Lines 359-364 $(document).ready(function () { Link Here
359
<audio src="[% interface %]/[% theme %]/sound/beep.ogg" autoplay="autoplay" autobuffer="autobuffer"></audio>
359
<audio src="[% interface %]/[% theme %]/sound/beep.ogg" autoplay="autoplay" autobuffer="autobuffer"></audio>
360
[% END %]
360
[% END %]
361
        [% END %]
361
        [% END %]
362
        [% IF ( checkinmsg ) %]
363
            <p class="problem">[% checkinmsg %]</p>
364
        [% END%]
362
    </div>
365
    </div>
363
[% END %]
366
[% END %]
364
367
(-)a/t/ItemType.t (-10 / +38 lines)
Lines 1-11 Link Here
1
#!/usr/bin/perl
1
#!/usr/bin/perl
2
#
3
# Add more tests here!!!
4
2
5
use strict;
3
use strict;
6
use warnings;
4
use warnings;
7
use DBI;
5
use DBI;
8
use Test::More tests => 15;
6
use Test::More tests => 26;
9
use Test::MockModule;
7
use Test::MockModule;
10
8
11
BEGIN {
9
BEGIN {
Lines 26-41 $module->mock( Link Here
26
my $itemtypes = [
24
my $itemtypes = [
27
    [
25
    [
28
        'itemtype', 'description', 'rentalcharge', 'notforloan',
26
        'itemtype', 'description', 'rentalcharge', 'notforloan',
29
        'imageurl', 'summary'
27
        'imageurl', 'summary', 'checkinmsg'
30
    ],
28
    ],
31
    [ 'BK', 'Books', 0, 0, '', '' ],
29
    [ 'BK', 'Books', 0, 0, '', '', 'foo' ],
32
    [ 'CD', 'CDRom', 0, 0, '', '' ]
30
    [ 'CD', 'CDRom', 0, 0, '', '', 'bar' ]
33
];
31
];
34
32
35
my $itemtypes_empty = [
33
my $itemtypes_empty = [
36
    [
34
    [
37
        'itemtype', 'description', 'rentalcharge', 'notforloan',
35
        'itemtype', 'description', 'rentalcharge', 'notforloan',
38
        'imageurl', 'summary'
36
        'imageurl', 'summary', 'checkinmsg'
39
    ],
37
    ],
40
];
38
];
41
39
Lines 53-58 is( scalar( @{$history} ), 1, 'Correct number of statements executed' ); Link Here
53
$dbh->{mock_add_resultset} = $itemtypes;
51
$dbh->{mock_add_resultset} = $itemtypes;
54
52
55
@itemtypes = C4::ItemType->all();
53
@itemtypes = C4::ItemType->all();
54
55
$history = $dbh->{mock_all_history};
56
is( scalar( @{$history} ), 2, 'Correct number of statements executed' );
57
56
is( @itemtypes, 2, 'ItemType->all should return an array with 2 elements' );
58
is( @itemtypes, 2, 'ItemType->all should return an array with 2 elements' );
57
59
58
is( $itemtypes[0]->fish, undef, 'Calling a bad descriptor gives undef' );
60
is( $itemtypes[0]->fish, undef, 'Calling a bad descriptor gives undef' );
Lines 73-78 is( $itemtypes[0]->notforloan, '0', 'first not for loan is 0' ); Link Here
73
75
74
is( $itemtypes[1]->notforloan, '0', 'second not for loan is 0' );
76
is( $itemtypes[1]->notforloan, '0', 'second not for loan is 0' );
75
77
76
is( $itemtypes[0]->imageurl, '', 'first not for loan is undef' );
78
is( $itemtypes[0]->imageurl, '', 'first imageurl is undef' );
79
80
is( $itemtypes[1]->imageurl, '', 'second imageurl is undef' );
81
82
is( $itemtypes[0]->checkinmsg, 'foo', 'first checkinmsg is foo' );
83
84
is( $itemtypes[1]->checkinmsg, 'bar', 'second checkinmsg is bar' );
85
86
# Mock the data again
87
$dbh->{mock_add_resultset} = $itemtypes;
88
89
# Test get(), which should return one itemtype
90
my $itemtype = C4::ItemType->get( 'BK' );
91
92
$history = $dbh->{mock_all_history};
93
is( scalar( @{$history} ), 3, 'Correct number of statements executed' );
94
95
is( $itemtype->fish, undef, 'Calling a bad descriptor gives undef' );
96
97
is( $itemtype->itemtype, 'BK', 'itemtype is bk' );
98
99
is( $itemtype->description, 'Books', 'description is books' );
100
101
is( $itemtype->rentalcharge, '0', 'rental charge is 0' );
102
103
is( $itemtype->notforloan, '0', 'not for loan is 0' );
104
105
is( $itemtype->imageurl, '', ' not for loan is undef' );
77
106
78
is( $itemtypes[1]->imageurl, '', 'second not for loan is undef' );
107
is( $itemtype->checkinmsg, 'foo', 'checkinmsg is foo' );
79
- 

Return to bug 10513