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

(-)a/C4/RotatingCollections.pm (-51 lines)
Lines 48-55 BEGIN { Link Here
48
    require Exporter;
48
    require Exporter;
49
    @ISA    = qw( Exporter );
49
    @ISA    = qw( Exporter );
50
    @EXPORT = qw(
50
    @EXPORT = qw(
51
      GetItemsInCollection
52
53
      AddItemToCollection
51
      AddItemToCollection
54
      RemoveItemFromCollection
52
      RemoveItemFromCollection
55
      TransferCollection
53
      TransferCollection
Lines 58-112 BEGIN { Link Here
58
    );
56
    );
59
}
57
}
60
58
61
=head2 GetItemsInCollection
62
63
 ( $results, $success, $errorcode, $errormessage ) = GetItemsInCollection( $colId );
64
65
 Returns information about the items in the given collection
66
 
67
 Input:
68
   $colId: The id of the collection
69
70
 Output:
71
   $results: Reference to an array of associated arrays
72
   $success: 1 if all database operations were successful, 0 otherwise
73
   $errorCode: Code for reason of failure, good for translating errors in templates
74
   $errorMessage: English description of error
75
76
=cut
77
78
sub GetItemsInCollection {
79
    my ($colId) = @_;
80
81
    ## Parameter check
82
    if ( !$colId ) {
83
        return ( 0, 0, 1, "NO_ID" );
84
    }
85
86
    my $dbh = C4::Context->dbh;
87
88
    my $sth = $dbh->prepare(
89
        "SELECT
90
                             biblio.title,
91
                             biblio.biblionumber,
92
                             items.itemcallnumber,
93
                             items.barcode
94
                           FROM collections, collections_tracking, items, biblio
95
                           WHERE collections.colId = collections_tracking.colId
96
                           AND collections_tracking.itemnumber = items.itemnumber
97
                           AND items.biblionumber = biblio.biblionumber
98
                           AND collections.colId = ? ORDER BY biblio.title"
99
    );
100
    $sth->execute($colId) or return ( 0, 0, 2, $sth->errstr() );
101
102
    my @results;
103
    while ( my $row = $sth->fetchrow_hashref ) {
104
        push( @results, $row );
105
    }
106
107
    return \@results;
108
}
109
110
=head2 AddItemToCollection
59
=head2 AddItemToCollection
111
60
112
 ( $success, $errorcode, $errormessage ) = AddItemToCollection( $colId, $itemnumber );
61
 ( $success, $errorcode, $errormessage ) = AddItemToCollection( $colId, $itemnumber );
(-)a/Koha/RotatingCollection.pm (+19 lines)
Lines 22-27 use Modern::Perl; Link Here
22
use Carp;
22
use Carp;
23
23
24
use Koha::Database;
24
use Koha::Database;
25
use Koha::Items;
25
26
26
use base qw(Koha::Object);
27
use base qw(Koha::Object);
27
28
Lines 35-40 Koha::RotatingCollection - Koha Rotating collection Object class Link Here
35
36
36
=cut
37
=cut
37
38
39
=head3 items
40
41
=cut
42
43
sub items {
44
    my ( $self ) = @_;
45
    my $items = Koha::Items->search(
46
        {
47
            'collections_trackings.colId' => $self->colId
48
        },
49
        {
50
            join => [ 'collections_trackings' ]
51
        }
52
    );
53
54
    return $items;
55
}
56
38
=head3 type
57
=head3 type
39
58
40
=cut
59
=cut
(-)a/koha-tmpl/intranet-tmpl/prog/en/includes/rotating-collections-toolbar.inc (-4 / +4 lines)
Lines 17-31 Link Here
17
                    <a class="btn btn-default btn-sm" href="/cgi-bin/koha/rotating_collections/editCollections.pl?action=new"><i class="fa fa-plus"></i> New collection</a>
17
                    <a class="btn btn-default btn-sm" href="/cgi-bin/koha/rotating_collections/editCollections.pl?action=new"><i class="fa fa-plus"></i> New collection</a>
18
                </div>
18
                </div>
19
19
20
                [% IF ( colId ) %]
20
                [% IF ( collection.colId ) %]
21
                    <div class="btn-group">
21
                    <div class="btn-group">
22
                        <a class="btn btn-default btn-sm" href="/cgi-bin/koha/rotating_collections/transferCollection.pl?colId=[% colId %]"><i class="fa fa-exchange"></i> Transfer</a>
22
                        <a class="btn btn-default btn-sm" href="/cgi-bin/koha/rotating_collections/transferCollection.pl?colId=[% collection.colId %]"><i class="fa fa-exchange"></i> Transfer</a>
23
                    </div>
23
                    </div>
24
                    <div class="btn-group">
24
                    <div class="btn-group">
25
                        <a class="btn btn-default btn-sm" href="/cgi-bin/koha/rotating_collections/editCollections.pl?action=edit&amp;colId=[% colId %]"><i class="fa fa-pencil"></i> Edit</a>
25
                        <a class="btn btn-default btn-sm" href="/cgi-bin/koha/rotating_collections/editCollections.pl?action=edit&amp;colId=[% collection.colId %]"><i class="fa fa-pencil"></i> Edit</a>
26
                    </div>
26
                    </div>
27
                    <div class="btn-group">
27
                    <div class="btn-group">
28
                        <a class="btn btn-default btn-sm confirmdelete" href="/cgi-bin/koha/rotating_collections/editCollections.pl?action=delete&amp;colId=[% colId %]"><i class="fa fa-trash"></i> Delete</a>
28
                        <a class="btn btn-default btn-sm confirmdelete" href="/cgi-bin/koha/rotating_collections/editCollections.pl?action=delete&amp;colId=[% collection.colId %]"><i class="fa fa-trash"></i> Delete</a>
29
                    </div>
29
                    </div>
30
                [% END %]
30
                [% END %]
31
            </div>
31
            </div>
(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/rotating_collections/addItems.tt (-12 / +12 lines)
Lines 1-5 Link Here
1
[% INCLUDE 'doc-head-open.inc' %]
1
[% INCLUDE 'doc-head-open.inc' %]
2
<title>Koha &rsaquo; Tools &rsaquo; Rotating collections &rsaquo; Collection [% colTitle %] &rsquo; Add or remove items</title>
2
<title>Koha &rsaquo; Tools &rsaquo; Rotating collections &rsaquo; Collection [% collection.colTitle %] &rsquo; Add or remove items</title>
3
[% INCLUDE 'doc-head-close.inc' %]
3
[% INCLUDE 'doc-head-close.inc' %]
4
<script type="text/javascript">
4
<script type="text/javascript">
5
    //<![CDATA[
5
    //<![CDATA[
Lines 13-33 Link Here
13
[% INCLUDE 'header.inc' %]
13
[% INCLUDE 'header.inc' %]
14
[% INCLUDE 'cat-search.inc' %]
14
[% INCLUDE 'cat-search.inc' %]
15
15
16
<div id="breadcrumbs"><a href="/cgi-bin/koha/mainpage.pl">Home</a> &rsaquo; <a href="/cgi-bin/koha/tools/tools-home.pl">Tools</a> &rsaquo; <a href="/cgi-bin/koha/rotating_collections/rotatingCollections.pl">Rotating collections</a> &rsaquo; <a href="/cgi-bin/koha/rotating_collections/addItems.pl?colId=[% colId %]">Collection <i>[% colTitle %]</i></a> &rsaquo; Add or remove items</div>
16
<div id="breadcrumbs"><a href="/cgi-bin/koha/mainpage.pl">Home</a> &rsaquo; <a href="/cgi-bin/koha/tools/tools-home.pl">Tools</a> &rsaquo; <a href="/cgi-bin/koha/rotating_collections/rotatingCollections.pl">Rotating collections</a> &rsaquo; <a href="/cgi-bin/koha/rotating_collections/addItems.pl?colId=[% collection.colId %]">Collection <i>[% collection.colTitle %]</i></a> &rsaquo; Add or remove items</div>
17
17
18
<div id="doc3" class="yui-t2">
18
<div id="doc3" class="yui-t2">
19
    <div id="bd">
19
    <div id="bd">
20
        <div id="yui-main">
20
        <div id="yui-main">
21
            <div class="yui-b">
21
            <div class="yui-b">
22
22
23
              [% IF ( ! colId ) %]
23
              [% IF ( ! collection ) %]
24
                <div class="dialog message">
24
                <div class="dialog message">
25
                    <p>Invalid collection id</p>
25
                    <p>Invalid collection id</p>
26
                    <p><a href="/cgi-bin/koha/rotating_collections/rotatingCollections.pl">Return to rotating collections home</a></p>
26
                    <p><a href="/cgi-bin/koha/rotating_collections/rotatingCollections.pl">Return to rotating collections home</a></p>
27
                </div>
27
                </div>
28
              [% ELSE %]
28
              [% ELSE %]
29
              [% INCLUDE 'rotating-collections-toolbar.inc' %]
29
              [% INCLUDE 'rotating-collections-toolbar.inc' %]
30
              <h1>Collection <i>[% colTitle %]</i></h1>
30
              <h1>Collection <i>[% collection.colTitle %]</i></h1>
31
31
32
              [% IF ( previousActionAdd ) %]
32
              [% IF ( previousActionAdd ) %]
33
                [% IF ( addSuccess ) %]
33
                [% IF ( addSuccess ) %]
Lines 85-91 Link Here
85
                            </li>
85
                            </li>
86
                        </ol>
86
                        </ol>
87
                        <p>
87
                        <p>
88
                            <input type="hidden" id="colId" name="colId" value="[% colId %]" />
88
                            <input type="hidden" id="colId" name="colId" value="[% collection.colId %]" />
89
                            <input type="hidden" name="action" value="addItem" />
89
                            <input type="hidden" name="action" value="addItem" />
90
                            <input type="submit" value="Submit" />
90
                            <input type="submit" value="Submit" />
91
                        </p>
91
                        </p>
Lines 95-102 Link Here
95
              </div>
95
              </div>
96
96
97
              <div>
97
              <div>
98
                <h2>Items in <i>[% colTitle %]</i></h2>
98
                <h2>Items in <i>[% collection.colTitle %]</i></h2>
99
                [% IF ( collectionItemsLoop ) %]
99
                [% IF ( collection.items ) %]
100
                  <table>
100
                  <table>
101
                    <tr>
101
                    <tr>
102
                      <th>Title</th>
102
                      <th>Title</th>
Lines 104-115 Link Here
104
                      <th>Barcode</th>
104
                      <th>Barcode</th>
105
                      <th>&nbsp;</th>
105
                      <th>&nbsp;</th>
106
                    </tr>
106
                    </tr>
107
                    [% FOREACH collectionItemsLoo IN collectionItemsLoop %]
107
                    [% FOREACH item IN collection.items %]
108
                      <tr>
108
                      <tr>
109
                        <td>[% INCLUDE 'biblio-default-view.inc' biblionumber = collectionItemsLoo.biblionumber %][% collectionItemsLoo.title |html %]</a></td>
109
                        <td>[% INCLUDE 'biblio-default-view.inc' biblionumber = item.biblionumber %][% item.biblio.title |html %]</a></td>
110
                        <td>[% collectionItemsLoo.itemcallnumber %]</td>
110
                        <td>[% item.itemcallnumber %]</td>
111
                        <td>[% collectionItemsLoo.barcode %]</td>
111
                        <td>[% item.barcode %]</td>
112
                        <td><a href="/cgi-bin/koha/rotating_collections/addItems.pl?colId=[% colId %]&amp;barcode=[% collectionItemsLoo.barcode %]&amp;removeItem=1&amp;action=addItem">Remove</a></td>
112
                        <td><a href="/cgi-bin/koha/rotating_collections/addItems.pl?colId=[% collection.colId %]&amp;barcode=[% item.barcode %]&amp;removeItem=1&amp;action=addItem">Remove</a></td>
113
                      </tr>
113
                      </tr>
114
                    [% END %]
114
                    [% END %]
115
                  </table>
115
                  </table>
(-)a/rotating_collections/addItems.pl (-10 / +1 lines)
Lines 92-107 if ( $query->param('action') eq 'addItem' ) { Link Here
92
my $colId = $query->param('colId');
92
my $colId = $query->param('colId');
93
my $collection = Koha::RotatingCollections->find($colId);
93
my $collection = Koha::RotatingCollections->find($colId);
94
94
95
my $collectionItems = GetItemsInCollection($colId);
96
if ($collectionItems) {
97
    $template->param( collectionItemsLoop => $collectionItems );
98
}
99
100
$template->param(
95
$template->param(
101
    colId          => $collection->colId,
96
    collection => $collection,
102
    colTitle       => $collection->colTitle,
103
    colDescription => $collection->colDesc,
104
    colBranchcode  => $collection->colBranchcode,
105
);
97
);
106
98
107
output_html_with_http_headers $query, $cookie, $template->output;
99
output_html_with_http_headers $query, $cookie, $template->output;
108
- 

Return to bug 18606