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

(-)a/C4/Serials.pm (-5 / +30 lines)
Lines 691-697 a table of hashref. Each hash containt the subscription. Link Here
691
sub SearchSubscriptions {
691
sub SearchSubscriptions {
692
    my ( $args ) = @_;
692
    my ( $args ) = @_;
693
693
694
    my $query = qq{
694
    my $additional_fields = $args->{additional_fields} // [];
695
    my $matching_record_ids_for_additional_fields = [];
696
    if ( @$additional_fields ) {
697
        $matching_record_ids_for_additional_fields = Koha::AdditionalField->get_matching_record_ids({
698
                fields => $args->{additional_fields},
699
                tablename => 'subscription',
700
        });
701
        return () unless @$matching_record_ids_for_additional_fields;
702
    }
703
704
    my $query = q|
695
        SELECT
705
        SELECT
696
            subscription.notes AS publicnotes,
706
            subscription.notes AS publicnotes,
697
            subscription.*,
707
            subscription.*,
Lines 705-717 sub SearchSubscriptions { Link Here
705
            LEFT JOIN biblio ON biblio.biblionumber = subscription.biblionumber
715
            LEFT JOIN biblio ON biblio.biblionumber = subscription.biblionumber
706
            LEFT JOIN biblioitems ON biblioitems.biblionumber = subscription.biblionumber
716
            LEFT JOIN biblioitems ON biblioitems.biblionumber = subscription.biblionumber
707
            LEFT JOIN aqbooksellers ON subscription.aqbooksellerid = aqbooksellers.id
717
            LEFT JOIN aqbooksellers ON subscription.aqbooksellerid = aqbooksellers.id
708
    };
718
    |;
719
    $query .= q| WHERE 1|;
709
    my @where_strs;
720
    my @where_strs;
710
    my @where_args;
721
    my @where_args;
711
    if( $args->{biblionumber} ) {
722
    if( $args->{biblionumber} ) {
712
        push @where_strs, "biblio.biblionumber = ?";
723
        push @where_strs, "biblio.biblionumber = ?";
713
        push @where_args, $args->{biblionumber};
724
        push @where_args, $args->{biblionumber};
714
    }
725
    }
726
715
    if( $args->{title} ){
727
    if( $args->{title} ){
716
        my @words = split / /, $args->{title};
728
        my @words = split / /, $args->{title};
717
        my (@strs, @args);
729
        my (@strs, @args);
Lines 748-763 sub SearchSubscriptions { Link Here
748
        push @where_strs, "subscription.closed = ?";
760
        push @where_strs, "subscription.closed = ?";
749
        push @where_args, "$args->{closed}";
761
        push @where_args, "$args->{closed}";
750
    }
762
    }
763
751
    if(@where_strs){
764
    if(@where_strs){
752
        $query .= " WHERE " . join(" AND ", @where_strs);
765
        $query .= ' AND ' . join(' AND ', @where_strs);
766
    }
767
    if ( @$additional_fields ) {
768
        $query .= ' AND subscriptionid IN ('
769
            . join( ', ', @$matching_record_ids_for_additional_fields )
770
        . ')';
753
    }
771
    }
754
772
755
    my $dbh = C4::Context->dbh;
773
    my $dbh = C4::Context->dbh;
756
    my $sth = $dbh->prepare($query);
774
    my $sth = $dbh->prepare($query);
757
    $sth->execute(@where_args);
775
    $sth->execute(@where_args);
758
    my $results = $sth->fetchall_arrayref( {} );
759
    $sth->finish;
760
776
777
    my $results =  $sth->fetchall_arrayref( {} );
778
779
    for my $subscription ( @$results ) {
780
        my $additional_field_values = Koha::AdditionalField->fetch_all_values({
781
            record_id => $subscription->{subscriptionid},
782
            tablename => 'subscription'
783
        });
784
        %$subscription = ( %$subscription, additional_fields => $additional_field_values->{$subscription->{subscriptionid}} );
785
    }
761
    return @$results;
786
    return @$results;
762
}
787
}
763
788
(-)a/koha-tmpl/intranet-tmpl/prog/en/includes/serials-menu.inc (+1 lines)
Lines 30-33 Link Here
30
            Manage numbering patterns
30
            Manage numbering patterns
31
        </a>
31
        </a>
32
    </li>
32
    </li>
33
    <li><a href="/cgi-bin/koha/serials/add_fields.pl">Add subscription fields</a></li>
33
</ul>
34
</ul>
(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/serials/serials-search.tt (-3 / +54 lines)
Lines 1-5 Link Here
1
[% INCLUDE 'doc-head-open.inc' %]
1
[% INCLUDE 'doc-head-open.inc' %]
2
[% USE KohaDates %]
2
[% USE KohaDates %]
3
[% USE KohaAuthorisedValues %]
3
<title>Koha &rsaquo; Serials [% biblionumber %]</title>
4
<title>Koha &rsaquo; Serials [% biblionumber %]</title>
4
<link rel="stylesheet" type="text/css" href="[% themelang %]/css/datatables.css" />
5
<link rel="stylesheet" type="text/css" href="[% themelang %]/css/datatables.css" />
5
[% INCLUDE 'doc-head-close.inc' %]
6
[% INCLUDE 'doc-head-close.inc' %]
Lines 14-19 Link Here
14
    [% END %]
15
    [% END %]
15
    var osrlt = $("#osrlt").dataTable($.extend(true, {}, dataTablesDefaults, {
16
    var osrlt = $("#osrlt").dataTable($.extend(true, {}, dataTablesDefaults, {
16
17
18
        // FIXME sort function of additional_fields!
17
        "aoColumnDefs": [
19
        "aoColumnDefs": [
18
            { "aTargets": [ -1, -2, -3 ], "bSortable": false, "bSearchable": false },
20
            { "aTargets": [ -1, -2, -3 ], "bSortable": false, "bSearchable": false },
19
        ],
21
        ],
Lines 21-26 Link Here
21
    } ) );
23
    } ) );
22
24
23
    var csrlt = $("#csrlt").dataTable($.extend(true, {}, dataTablesDefaults, {
25
    var csrlt = $("#csrlt").dataTable($.extend(true, {}, dataTablesDefaults, {
26
        // FIXME sort function of additional_fields!
24
        "aoColumnDefs": [
27
        "aoColumnDefs": [
25
            { "aTargets": [ -1, -2 ], "bSortable": false, "bSearchable": false },
28
            { "aTargets": [ -1, -2 ], "bSortable": false, "bSearchable": false },
26
        ],
29
        ],
Lines 92-97 Link Here
92
                    [% END %]
95
                    [% END %]
93
                  </select>
96
                  </select>
94
                </li>
97
                </li>
98
                [% FOR field IN additional_fields_for_subscription %]
99
                  <li>
100
                    <label for="additional_field_[% field.name %]"> [% field.name %]: </label>
101
                    [% IF field.authorised_value_choices %]
102
                      <select id="additional_field_[% field.name %]" name="additional_field_[% field.name %]_filter">
103
                        <option value="">All</option>
104
                        [% FOREACH av IN field.authorised_value_choices %]
105
                          <option value="[% av.authorised_value %]">[% av.lib %]</option>
106
                        [% END %]
107
                      </select>
108
                    [% ELSE %]
109
                      <input id="additional_field_[% field.name %]" type="text" value="[% additional_fields.${field.name} %]" name="additional_field_[% field.name %]_filter" />
110
                    [% END %]
111
                  </li>
112
                [% END %]
95
              </ol>
113
              </ol>
96
              <input type="hidden" name="searched" value="1" />
114
              <input type="hidden" name="searched" value="1" />
97
              <fieldset class="action">
115
              <fieldset class="action">
Lines 119-124 Link Here
119
                        <th>Library</th>
137
                        <th>Library</th>
120
                        <th>Call number</th>
138
                        <th>Call number</th>
121
                        <th>Expiration date</th>
139
                        <th>Expiration date</th>
140
                        [% FOR field IN additional_fields_for_subscription %]
141
                          <th>[% field.name %]</th>
142
                        [% END %]
122
                        [% IF ( routing && CAN_user_serials_routing ) %]
143
                        [% IF ( routing && CAN_user_serials_routing ) %]
123
                          <th>Routing list</th>
144
                          <th>Routing list</th>
124
                        [% END %]
145
                        [% END %]
Lines 134-139 Link Here
134
                      <td><input type="text" class="filter" data-column_num="3" placeholder="Search library" /></td>
155
                      <td><input type="text" class="filter" data-column_num="3" placeholder="Search library" /></td>
135
                      <td><input type="text" class="filter" data-column_num="4" placeholder="Search callnumber" /></td>
156
                      <td><input type="text" class="filter" data-column_num="4" placeholder="Search callnumber" /></td>
136
                      <td><input type="text" class="filter" data-column_num="5" placeholder="Search expiration date" /></td>
157
                      <td><input type="text" class="filter" data-column_num="5" placeholder="Search expiration date" /></td>
158
                      [% FOR field IN additional_fields_for_subscription %]
159
                        <td><input type="text" class="filter" data-column_num="[% loop.count + 5 %]" placeholder="Search [% field.name %]" /></td>
160
                      [% END %]
137
                      [% IF ( routing && CAN_user_serials_routing ) %]<td></td>[% END %]
161
                      [% IF ( routing && CAN_user_serials_routing ) %]<td></td>[% END %]
138
                      <td></td>
162
                      <td></td>
139
                      <td></td>
163
                      <td></td>
Lines 161-166 Link Here
161
                          [% IF ( subscription.enddate ) %][% subscription.enddate | $KohaDates %][% END %]
185
                          [% IF ( subscription.enddate ) %][% subscription.enddate | $KohaDates %][% END %]
162
                        </td>
186
                        </td>
163
                        [% IF ( routing && CAN_user_serials_routing ) %]
187
                        [% IF ( routing && CAN_user_serials_routing ) %]
188
                        [% END %]
189
                        [% FOR field IN additional_fields_for_subscription %]
190
                          [% IF field.authorised_value_category %]
191
                            <td>[% KohaAuthorisedValues.GetByCode( field.authorised_value_category, subscription.additional_fields.${field.name} ) %]</td>
192
                          [% ELSE %]
193
                            <td>[% subscription.additional_fields.${field.name} %]</td>
194
                          [% END %]
195
                        [% END %]
196
                        <td><a href="/cgi-bin/koha/serials/serials-collection.pl?subscriptionid=[% subscription.subscriptionid %]">Issue history</a>
197
                        </td>
164
                        <td>
198
                        <td>
165
                          [% IF ( subscription.cannotedit ) %]
199
                          [% IF ( subscription.cannotedit ) %]
166
                            &nbsp;
200
                            &nbsp;
Lines 173-181 Link Here
173
                            [% END %]
207
                            [% END %]
174
                          [% END %]
208
                          [% END %]
175
                        </td>
209
                        </td>
176
                        [% END %]
177
                        <td><a href="/cgi-bin/koha/serials/serials-collection.pl?subscriptionid=[% subscription.subscriptionid %]">Issue history</a>
178
                        </td>
179
                        <td>
210
                        <td>
180
                        [% IF ( subscription.cannotedit ) %]
211
                        [% IF ( subscription.cannotedit ) %]
181
                          &nbsp;
212
                          &nbsp;
Lines 196-201 Link Here
196
            <div id="closed">
227
            <div id="closed">
197
              [% IF closedsubscriptions %]
228
              [% IF closedsubscriptions %]
198
                <table id="csrlt">
229
                <table id="csrlt">
230
                <!-- FIXME add additional_fields for closed subs -->
199
                  <thead>
231
                  <thead>
200
                    <tr>
232
                    <tr>
201
                        <th>ISSN</th>
233
                        <th>ISSN</th>
Lines 312-317 Link Here
312
                    [% END %]
344
                    [% END %]
313
                  </select>
345
                  </select>
314
                </li>
346
                </li>
347
                [% FOR field IN additional_fields_for_subscription %]
348
                  <li>
349
                    <label for="additional_field_[% field.name %]"> [% field.name %]: </label>
350
                    [% IF field.authorised_value_choices %]
351
                      <select id="additional_field_[% field.name %]" name="additional_field_[% field.name %]_filter">
352
                        <option value="">All</option>
353
                        [% FOREACH av IN field.authorised_value_choices %]
354
                          [% IF av.authorised_value == additional_field_filters.${field.name} %]
355
                            <option value="[% av.authorised_value %]" selected="selected">[% av.lib %]</option>
356
                          [% ELSE %]
357
                            <option value="[% av.authorised_value %]">[% av.lib %]</option>
358
                          [% END %]
359
                        [% END %]
360
                      </select>
361
                    [% ELSE %]
362
                      <input id="additional_field_[% field.name %]" type="text" value="[% additional_field_filters.${field.name} %]" name="additional_field_[% field.name %]_filter" />
363
                    [% END %]
364
                  </li>
365
                [% END %]
315
              </ol>
366
              </ol>
316
              <input type="hidden" name="searched" value="1" />
367
              <input type="hidden" name="searched" value="1" />
317
              <fieldset class="action">
368
              <fieldset class="action">
(-)a/serials/serials-search.pl (-1 / +17 lines)
Lines 33-40 use CGI; Link Here
33
use C4::Auth;
33
use C4::Auth;
34
use C4::Branch;
34
use C4::Branch;
35
use C4::Context;
35
use C4::Context;
36
use C4::Koha qw( GetAuthorisedValues );
36
use C4::Output;
37
use C4::Output;
37
use C4::Serials;
38
use C4::Serials;
39
use Koha::AdditionalField;
38
40
39
my $query         = new CGI;
41
my $query         = new CGI;
40
my $title         = $query->param('title_filter') || '';
42
my $title         = $query->param('title_filter') || '';
Lines 70-75 if ( $op and $op eq "close" ) { Link Here
70
    }
72
    }
71
}
73
}
72
74
75
76
my $additional_fields = Koha::AdditionalField->all( { table => 'subscription', searchable => 1 } );
77
my $additional_field_filters;
78
for my $field ( @$additional_fields ) {
79
    if ( my $filter_value = $query->param('additional_field_' . $field->{name} . '_filter') ) {
80
        $additional_field_filters->{ $field->{name} } = $filter_value;
81
    }
82
    if ( $field->{authorised_value_category} ) {
83
        $field->{authorised_value_choices} = GetAuthorisedValues( $field->{authorised_value_category} );
84
    }
85
}
86
73
my @subscriptions;
87
my @subscriptions;
74
if ($searched){
88
if ($searched){
75
    @subscriptions = SearchSubscriptions(
89
    @subscriptions = SearchSubscriptions(
Lines 81-86 if ($searched){ Link Here
81
            publisher    => $publisher,
95
            publisher    => $publisher,
82
            bookseller   => $bookseller,
96
            bookseller   => $bookseller,
83
            branch       => $branch,
97
            branch       => $branch,
98
            additional_fields => [ map{ { name => $_, value => $additional_field_filters->{$_}} } keys %$additional_field_filters ],
84
        }
99
        }
85
    );
100
    );
86
}
101
}
Lines 127-132 $template->param( Link Here
127
    branches_loop => \@branches_loop,
142
    branches_loop => \@branches_loop,
128
    done_searched => $searched,
143
    done_searched => $searched,
129
    routing       => $routing,
144
    routing       => $routing,
145
    additional_field_filters => $additional_field_filters,
146
    additional_fields_for_subscription => $additional_fields,
130
    marcflavour   => (uc(C4::Context->preference("marcflavour")))
147
    marcflavour   => (uc(C4::Context->preference("marcflavour")))
131
);
148
);
132
149
133
- 

Return to bug 10855