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 (-2 / +10 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'},
121
        checkinmsgtype  => $data->{'checkinmsgtype'},
120
        imagesets       => $imagesets,
122
        imagesets       => $imagesets,
121
        remote_image    => $remote_image,
123
        remote_image    => $remote_image,
122
    );
124
    );
Lines 141-146 elsif ( $op eq 'add_validate' ) { Link Here
141
                 , notforloan = ?
143
                 , notforloan = ?
142
                 , imageurl = ?
144
                 , imageurl = ?
143
                 , summary = ?
145
                 , summary = ?
146
                 , checkinmsg = ?
147
                 , checkinmsgtype = ?
144
            WHERE itemtype = ?
148
            WHERE itemtype = ?
145
        ';
149
        ';
146
        $sth = $dbh->prepare($query2);
150
        $sth = $dbh->prepare($query2);
Lines 156-170 elsif ( $op eq 'add_validate' ) { Link Here
156
                )
160
                )
157
            ),
161
            ),
158
            $input->param('summary'),
162
            $input->param('summary'),
163
            $input->param('checkinmsg'),
164
            $input->param('checkinmsgtype'),
159
            $input->param('itemtype')
165
            $input->param('itemtype')
160
        );
166
        );
161
    }
167
    }
162
    else {    # add a new itemtype & not modif an old
168
    else {    # add a new itemtype & not modif an old
163
        my $query = "
169
        my $query = "
164
            INSERT INTO itemtypes
170
            INSERT INTO itemtypes
165
                (itemtype,description,rentalcharge, notforloan, imageurl,summary)
171
                (itemtype,description,rentalcharge, notforloan, imageurl, summary, checkinmsg, checkinmsgtype)
166
            VALUES
172
            VALUES
167
                (?,?,?,?,?,?);
173
                (?,?,?,?,?,?,?,?);
168
            ";
174
            ";
169
        my $sth = $dbh->prepare($query);
175
        my $sth = $dbh->prepare($query);
170
		my $image = $input->param('image');
176
		my $image = $input->param('image');
Lines 177-182 elsif ( $op eq 'add_validate' ) { Link Here
177
            $image eq 'remoteImage' ? $input->param('remoteImage') :
183
            $image eq 'remoteImage' ? $input->param('remoteImage') :
178
            $image,
184
            $image,
179
            $input->param('summary'),
185
            $input->param('summary'),
186
            $input->param('checkinmsg'),
187
            $input->param('checkinmsgtype'),
180
        );
188
        );
181
    }
189
    }
182
190
(-)a/circ/returns.pl (+10 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
            checkinmsgtype => $itemtype->{'checkinmsgtype'},
235
        );
236
    }
237
228
    $template->param(
238
    $template->param(
229
        title            => $biblio->{'title'},
239
        title            => $biblio->{'title'},
230
        homebranch       => $biblio->{'homebranch'},
240
        homebranch       => $biblio->{'homebranch'},
(-)a/installer/data/mysql/kohastructure.sql (-6 / +8 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
1214
  checkinmsgtype CHAR(16) DEFAULT 'message' NOT NULL, -- type (CSS class) for the checkinmsg, can be "alert" or "message"
1213
  PRIMARY KEY  (`itemtype`),
1215
  PRIMARY KEY  (`itemtype`),
1214
  UNIQUE KEY `itemtype` (`itemtype`)
1216
  UNIQUE KEY `itemtype` (`itemtype`)
1215
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
1217
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
(-)a/installer/data/mysql/updatedatabase.pl (+8 lines)
Lines 7067-7072 if ( CheckVersion($DBversion) ) { Link Here
7067
    SetVersion($DBversion);
7067
    SetVersion($DBversion);
7068
}
7068
}
7069
7069
7070
$DBversion = "3.13.00.XXX";
7071
if ( CheckVersion($DBversion) ) {
7072
    $dbh->do("ALTER TABLE itemtypes ADD COLUMN checkinmsg VARCHAR(255) AFTER summary;");
7073
    $dbh->do("ALTER TABLE itemtypes ADD COLUMN checkinmsgtype CHAR(16) DEFAULT 'message' NOT NULL AFTER checkinmsg;");
7074
    print "Upgrade to $DBversion done (Bug 10513 - Light up a warning/message when returning a chosen item type)\n";
7075
    SetVersion($DBversion);
7076
}
7077
7070
=head1 FUNCTIONS
7078
=head1 FUNCTIONS
7071
7079
7072
=head2 TableExists($table)
7080
=head2 TableExists($table)
(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/itemtypes.tt (+21 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>
236
          <label for="checkinmsgtype">Check in message type: </label>
237
		  <select type="text" id="checkinmsgtype" name="checkinmsgtype">
238
		      [% IF ( checkinmsgtype == 'message' ) %]
239
		      <option value="message" selected="selected">Message</option>
240
		      [% ELSE %]
241
		          <option value="message">Message</option>
242
	          [% END %]
243
		      [% IF ( checkinmsgtype == 'alert' ) %]
244
		      <option value="alert" selected="selected">Alert</option>
245
		      [% ELSE %]
246
		          <option value="alert">Alert</option>
247
	          [% END %]
248
		  <select>
249
      </li>
250
      <li>
232
          <label for="summary">Summary: </label>
251
          <label for="summary">Summary: </label>
233
         <textarea id="summary" name="summary" cols="55" rows="5">[% summary %]</textarea>
252
         <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>
253
          <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>
301
    <th>Description</th>
283
    <th>Not for loan</th>
302
    <th>Not for loan</th>
284
    <th>Charge</th>
303
    <th>Charge</th>
304
    <th>Check in message</th>
285
    <th>Actions</th>
305
    <th>Actions</th>
286
  </thead>
306
  </thead>
287
  [% FOREACH loo IN loop %]
307
  [% FOREACH loo IN loop %]
Lines 303-308 Item types administration Link Here
303
      [% loo.rentalcharge %]
323
      [% loo.rentalcharge %]
304
    [% END %]
324
    [% END %]
305
    </td>
325
    </td>
326
    <td>[% loo.checkinmsg %]</td>
306
    <td>
327
    <td>
307
      <a href="[% loo.script_name %]?op=add_form&amp;itemtype=[% loo.itemtype |html %]">Edit</a>
328
      <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>
329
      <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 (+10 lines)
Lines 362-367 $(document).ready(function () { Link Here
362
    </div>
362
    </div>
363
[% END %]
363
[% END %]
364
364
365
[% IF ( checkinmsg ) %]
366
    [% IF ( checkinmsgtype == 'alert' ) %]
367
        <div class="dialog alert">
368
    [% ELSE %]
369
        <div class="dialog message">
370
    [% END %]
371
            <p class="problem">[% checkinmsg %]</p>
372
        </div>
373
[% END%]
374
365
    <div id="exemptfines" class="dialog message" style="display:none;">
375
    <div id="exemptfines" class="dialog message" style="display:none;">
366
        <p>Fines for returned items are forgiven.</p>
376
        <p>Fines for returned items are forgiven.</p>
367
    </div>
377
    </div>
(-)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