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 | html %]"><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 | html%]"><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 | html %]"><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 | html %]"><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 | html %]"><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 | html %]"><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 2-8 Link Here
2
[% USE Asset %]
2
[% USE Asset %]
3
[% SET footerjs = 1 %]
3
[% SET footerjs = 1 %]
4
[% INCLUDE 'doc-head-open.inc' %]
4
[% INCLUDE 'doc-head-open.inc' %]
5
<title>Koha &rsaquo; Tools &rsaquo; Rotating collections &rsaquo; Collection [% colTitle | html %] &rsquo; Add or remove items</title>
5
<title>Koha &rsaquo; Tools &rsaquo; Rotating collections &rsaquo; Collection [% collection.colTitle | html %] &rsquo; Add or remove items</title>
6
[% INCLUDE 'doc-head-close.inc' %]
6
[% INCLUDE 'doc-head-close.inc' %]
7
</head>
7
</head>
8
8
Lines 10-30 Link Here
10
[% INCLUDE 'header.inc' %]
10
[% INCLUDE 'header.inc' %]
11
[% INCLUDE 'cat-search.inc' %]
11
[% INCLUDE 'cat-search.inc' %]
12
12
13
<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 | html %]">Collection <i>[% colTitle | html %]</i></a> &rsaquo; Add or remove items</div>
13
<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 | html %]</i></a> &rsaquo; Add or remove items</div>
14
14
15
<div id="doc3" class="yui-t2">
15
<div id="doc3" class="yui-t2">
16
    <div id="bd">
16
    <div id="bd">
17
        <div id="yui-main">
17
        <div id="yui-main">
18
            <div class="yui-b">
18
            <div class="yui-b">
19
19
20
              [% IF ( ! colId ) %]
20
              [% IF ( ! collection ) %]
21
                <div class="dialog message">
21
                <div class="dialog message">
22
                    <p>Invalid collection id</p>
22
                    <p>Invalid collection id</p>
23
                    <p><a href="/cgi-bin/koha/rotating_collections/rotatingCollections.pl">Return to rotating collections home</a></p>
23
                    <p><a href="/cgi-bin/koha/rotating_collections/rotatingCollections.pl">Return to rotating collections home</a></p>
24
                </div>
24
                </div>
25
              [% ELSE %]
25
              [% ELSE %]
26
              [% INCLUDE 'rotating-collections-toolbar.inc' %]
26
              [% INCLUDE 'rotating-collections-toolbar.inc' %]
27
              <h1>Collection <i>[% colTitle | html %]</i></h1>
27
              <h1>Collection <i>[% collection.colTitle | html %]</i></h1>
28
28
29
              [% IF ( previousActionAdd ) %]
29
              [% IF ( previousActionAdd ) %]
30
                [% IF ( addSuccess ) %]
30
                [% IF ( addSuccess ) %]
Lines 82-88 Link Here
82
                            </li>
82
                            </li>
83
                        </ol>
83
                        </ol>
84
                        <p>
84
                        <p>
85
                            <input type="hidden" id="colId" name="colId" value="[% colId | html %]" />
85
                            <input type="hidden" id="colId" name="colId" value="[% collection.colId | html %]" />
86
                            <input type="hidden" name="action" value="addItem" />
86
                            <input type="hidden" name="action" value="addItem" />
87
                            <input type="submit" value="Submit" />
87
                            <input type="submit" value="Submit" />
88
                        </p>
88
                        </p>
Lines 92-99 Link Here
92
              </div>
92
              </div>
93
93
94
              <div>
94
              <div>
95
                <h2>Items in <i>[% colTitle | html %]</i></h2>
95
                <h2>Items in <i>[% collection.colTitle | html %]</i></h2>
96
                [% IF ( collectionItemsLoop ) %]
96
                [% IF ( collection.items ) %]
97
                  <table>
97
                  <table>
98
                    <tr>
98
                    <tr>
99
                      <th>Title</th>
99
                      <th>Title</th>
Lines 101-112 Link Here
101
                      <th>Barcode</th>
101
                      <th>Barcode</th>
102
                      <th>&nbsp;</th>
102
                      <th>&nbsp;</th>
103
                    </tr>
103
                    </tr>
104
                    [% FOREACH collectionItemsLoo IN collectionItemsLoop %]
104
                    [% FOREACH item IN collection.items %]
105
                      <tr>
105
                      <tr>
106
                        <td>[% INCLUDE 'biblio-default-view.inc' biblionumber = collectionItemsLoo.biblionumber %][% collectionItemsLoo.title | html %]</a></td>
106
                        <td>[% INCLUDE 'biblio-default-view.inc' biblionumber = item.biblionumber %][% item.biblio.title |html %]</a></td>
107
                        <td>[% collectionItemsLoo.itemcallnumber | html %]</td>
107
                        <td>[% item.itemcallnumber | html%]</td>
108
                        <td>[% collectionItemsLoo.barcode | html %]</td>
108
                        <td>[% item.barcode | html %]</td>
109
                        <td><a href="/cgi-bin/koha/rotating_collections/addItems.pl?colId=[% colId | html %]&amp;barcode=[% collectionItemsLoo.barcode | html %]&amp;removeItem=1&amp;action=addItem">Remove</a></td>
109
                        <td><a href="/cgi-bin/koha/rotating_collections/addItems.pl?colId=[% collection.colId | html %]&amp;barcode=[% item.barcode | html %]&amp;removeItem=1&amp;action=addItem">Remove</a></td>
110
                      </tr>
110
                      </tr>
111
                    [% END %]
111
                    [% END %]
112
                  </table>
112
                  </table>
(-)a/rotating_collections/addItems.pl (-10 / +1 lines)
Lines 94-109 if ( $query->param('action') eq 'addItem' ) { Link Here
94
my $colId = $query->param('colId');
94
my $colId = $query->param('colId');
95
my $collection = Koha::RotatingCollections->find($colId);
95
my $collection = Koha::RotatingCollections->find($colId);
96
96
97
my $collectionItems = GetItemsInCollection($colId);
98
if ($collectionItems) {
99
    $template->param( collectionItemsLoop => $collectionItems );
100
}
101
102
$template->param(
97
$template->param(
103
    colId          => $collection->colId,
98
    collection => $collection,
104
    colTitle       => $collection->colTitle,
105
    colDescription => $collection->colDesc,
106
    colBranchcode  => $collection->colBranchcode,
107
);
99
);
108
100
109
output_html_with_http_headers $query, $cookie, $template->output;
101
output_html_with_http_headers $query, $cookie, $template->output;
110
- 

Return to bug 18606