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 (-5 / +4 lines)
Lines 3-18 Link Here
3
    <div class="btn-group">
3
    <div class="btn-group">
4
        <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>
4
        <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>
5
    </div>
5
    </div>
6
6
    [% IF ( collection.colId ) %]
7
    [% IF ( colId ) %]
8
        <div class="btn-group">
7
        <div class="btn-group">
9
            <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>
8
            <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>
10
        </div>
9
        </div>
11
        <div class="btn-group">
10
        <div class="btn-group">
12
            <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>
11
            <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>
13
        </div>
12
        </div>
14
        <div class="btn-group">
13
        <div class="btn-group">
15
            <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>
14
            <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>
16
        </div>
15
        </div>
17
    [% END %]
16
    [% END %]
18
</div>
17
</div>
(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/rotating_collections/addItems.tt (-12 / +12 lines)
Lines 1-6 Link Here
1
[% SET footerjs = 1 %]
1
[% SET footerjs = 1 %]
2
[% INCLUDE 'doc-head-open.inc' %]
2
[% INCLUDE 'doc-head-open.inc' %]
3
<title>Koha &rsaquo; Tools &rsaquo; Rotating collections &rsaquo; Collection [% colTitle %] &rsquo; Add or remove items</title>
3
<title>Koha &rsaquo; Tools &rsaquo; Rotating collections &rsaquo; Collection [% collection.colTitle %] &rsquo; Add or remove items</title>
4
[% INCLUDE 'doc-head-close.inc' %]
4
[% INCLUDE 'doc-head-close.inc' %]
5
</head>
5
</head>
6
6
Lines 8-28 Link Here
8
[% INCLUDE 'header.inc' %]
8
[% INCLUDE 'header.inc' %]
9
[% INCLUDE 'cat-search.inc' %]
9
[% INCLUDE 'cat-search.inc' %]
10
10
11
<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>
11
<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>
12
12
13
<div id="doc3" class="yui-t2">
13
<div id="doc3" class="yui-t2">
14
    <div id="bd">
14
    <div id="bd">
15
        <div id="yui-main">
15
        <div id="yui-main">
16
            <div class="yui-b">
16
            <div class="yui-b">
17
17
18
              [% IF ( ! colId ) %]
18
              [% IF ( ! collection ) %]
19
                <div class="dialog message">
19
                <div class="dialog message">
20
                    <p>Invalid collection id</p>
20
                    <p>Invalid collection id</p>
21
                    <p><a href="/cgi-bin/koha/rotating_collections/rotatingCollections.pl">Return to rotating collections home</a></p>
21
                    <p><a href="/cgi-bin/koha/rotating_collections/rotatingCollections.pl">Return to rotating collections home</a></p>
22
                </div>
22
                </div>
23
              [% ELSE %]
23
              [% ELSE %]
24
              [% INCLUDE 'rotating-collections-toolbar.inc' %]
24
              [% INCLUDE 'rotating-collections-toolbar.inc' %]
25
              <h1>Collection <i>[% colTitle %]</i></h1>
25
              <h1>Collection <i>[% collection.colTitle %]</i></h1>
26
26
27
              [% IF ( previousActionAdd ) %]
27
              [% IF ( previousActionAdd ) %]
28
                [% IF ( addSuccess ) %]
28
                [% IF ( addSuccess ) %]
Lines 80-86 Link Here
80
                            </li>
80
                            </li>
81
                        </ol>
81
                        </ol>
82
                        <p>
82
                        <p>
83
                            <input type="hidden" id="colId" name="colId" value="[% colId %]" />
83
                            <input type="hidden" id="colId" name="colId" value="[% collection.colId %]" />
84
                            <input type="hidden" name="action" value="addItem" />
84
                            <input type="hidden" name="action" value="addItem" />
85
                            <input type="submit" value="Submit" />
85
                            <input type="submit" value="Submit" />
86
                        </p>
86
                        </p>
Lines 90-97 Link Here
90
              </div>
90
              </div>
91
91
92
              <div>
92
              <div>
93
                <h2>Items in <i>[% colTitle %]</i></h2>
93
                <h2>Items in <i>[% collection.colTitle %]</i></h2>
94
                [% IF ( collectionItemsLoop ) %]
94
                [% IF ( collection.items ) %]
95
                  <table>
95
                  <table>
96
                    <tr>
96
                    <tr>
97
                      <th>Title</th>
97
                      <th>Title</th>
Lines 99-110 Link Here
99
                      <th>Barcode</th>
99
                      <th>Barcode</th>
100
                      <th>&nbsp;</th>
100
                      <th>&nbsp;</th>
101
                    </tr>
101
                    </tr>
102
                    [% FOREACH collectionItemsLoo IN collectionItemsLoop %]
102
                    [% FOREACH item IN collection.items %]
103
                      <tr>
103
                      <tr>
104
                        <td>[% INCLUDE 'biblio-default-view.inc' biblionumber = collectionItemsLoo.biblionumber %][% collectionItemsLoo.title |html %]</a></td>
104
                        <td>[% INCLUDE 'biblio-default-view.inc' biblionumber = item.biblionumber %][% item.biblio.title |html %]</a></td>
105
                        <td>[% collectionItemsLoo.itemcallnumber %]</td>
105
                        <td>[% item.itemcallnumber %]</td>
106
                        <td>[% collectionItemsLoo.barcode %]</td>
106
                        <td>[% item.barcode %]</td>
107
                        <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>
107
                        <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>
108
                      </tr>
108
                      </tr>
109
                    [% END %]
109
                    [% END %]
110
                  </table>
110
                  </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