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

(-)a/C4/Serials.pm (-5 / +28 lines)
Lines 668-674 subscription expiration date. Link Here
668
sub SearchSubscriptions {
668
sub SearchSubscriptions {
669
    my ( $args ) = @_;
669
    my ( $args ) = @_;
670
670
671
    my $query = qq{
671
    my $additional_fields = $args->{additional_fields} // [];
672
    my $matching_record_ids_for_additional_fields = [];
673
    if ( @$additional_fields ) {
674
        $matching_record_ids_for_additional_fields = Koha::AdditionalField->get_matching_record_ids({
675
                fields => $args->{additional_fields},
676
                tablename => 'subscription',
677
        });
678
        return () unless @$matching_record_ids_for_additional_fields;
679
    }
680
681
    my $query = q|
672
        SELECT
682
        SELECT
673
            subscription.notes AS publicnotes,
683
            subscription.notes AS publicnotes,
674
            subscription.*,
684
            subscription.*,
Lines 682-694 sub SearchSubscriptions { Link Here
682
            LEFT JOIN biblio ON biblio.biblionumber = subscription.biblionumber
692
            LEFT JOIN biblio ON biblio.biblionumber = subscription.biblionumber
683
            LEFT JOIN biblioitems ON biblioitems.biblionumber = subscription.biblionumber
693
            LEFT JOIN biblioitems ON biblioitems.biblionumber = subscription.biblionumber
684
            LEFT JOIN aqbooksellers ON subscription.aqbooksellerid = aqbooksellers.id
694
            LEFT JOIN aqbooksellers ON subscription.aqbooksellerid = aqbooksellers.id
685
    };
695
    |;
696
    $query .= q| WHERE 1|;
686
    my @where_strs;
697
    my @where_strs;
687
    my @where_args;
698
    my @where_args;
688
    if( $args->{biblionumber} ) {
699
    if( $args->{biblionumber} ) {
689
        push @where_strs, "biblio.biblionumber = ?";
700
        push @where_strs, "biblio.biblionumber = ?";
690
        push @where_args, $args->{biblionumber};
701
        push @where_args, $args->{biblionumber};
691
    }
702
    }
703
692
    if( $args->{title} ){
704
    if( $args->{title} ){
693
        my @words = split / /, $args->{title};
705
        my @words = split / /, $args->{title};
694
        my (@strs, @args);
706
        my (@strs, @args);
Lines 737-755 sub SearchSubscriptions { Link Here
737
        push @where_strs, "subscription.closed = ?";
749
        push @where_strs, "subscription.closed = ?";
738
        push @where_args, "$args->{closed}";
750
        push @where_args, "$args->{closed}";
739
    }
751
    }
752
740
    if(@where_strs){
753
    if(@where_strs){
741
        $query .= " WHERE " . join(" AND ", @where_strs);
754
        $query .= ' AND ' . join(' AND ', @where_strs);
755
    }
756
    if ( @$additional_fields ) {
757
        $query .= ' AND subscriptionid IN ('
758
            . join( ', ', @$matching_record_ids_for_additional_fields )
759
        . ')';
742
    }
760
    }
743
761
744
    my $dbh = C4::Context->dbh;
762
    my $dbh = C4::Context->dbh;
745
    my $sth = $dbh->prepare($query);
763
    my $sth = $dbh->prepare($query);
746
    $sth->execute(@where_args);
764
    $sth->execute(@where_args);
747
    my $results = $sth->fetchall_arrayref( {} );
765
    my $results =  $sth->fetchall_arrayref( {} );
748
    $sth->finish;
749
766
750
    for my $subscription ( @$results ) {
767
    for my $subscription ( @$results ) {
751
        $subscription->{cannotedit} = not can_edit_subscription( $subscription );
768
        $subscription->{cannotedit} = not can_edit_subscription( $subscription );
752
        $subscription->{cannotdisplay} = not can_show_subscription( $subscription );
769
        $subscription->{cannotdisplay} = not can_show_subscription( $subscription );
770
771
        my $additional_field_values = Koha::AdditionalField->fetch_all_values({
772
            record_id => $subscription->{subscriptionid},
773
            tablename => 'subscription'
774
        });
775
        $subscription->{addition_fields} = $additional_field_values->{$subscription->{subscriptionid}};
753
    }
776
    }
754
777
755
    return @$results;
778
    return @$results;
(-)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 (-2 / +64 lines)
Lines 28-33 Link Here
28
    } ) );
28
    } ) );
29
29
30
    var csrlt = $("#csrlt").dataTable($.extend(true, {}, dataTablesDefaults, {
30
    var csrlt = $("#csrlt").dataTable($.extend(true, {}, dataTablesDefaults, {
31
        // FIXME sort function of additional_fields!
31
        "aoColumnDefs": [
32
        "aoColumnDefs": [
32
            { "aTargets": [ -1, -2 ], "bSortable": false, "bSearchable": false },
33
            { "aTargets": [ -1, -2 ], "bSortable": false, "bSearchable": false },
33
        ],
34
        ],
Lines 125-130 Link Here
125
                  <label for="to">Expires before:</label>
126
                  <label for="to">Expires before:</label>
126
                  <input type="text" id="to" name="expiration_date_filter" value="[% expiration_date_filter | $KohaDates %]" size="10" maxlength="10" class="datepickerto" />
127
                  <input type="text" id="to" name="expiration_date_filter" value="[% expiration_date_filter | $KohaDates %]" size="10" maxlength="10" class="datepickerto" />
127
                </li>
128
                </li>
129
                [% FOR field IN additional_fields_for_subscription %]
130
                  <li>
131
                    <label for="additional_field_[% field.id %]"> [% field.name %]: </label>
132
                    [% IF field.authorised_value_choices %]
133
                      <select id="additional_field_[% field.id %]" name="additional_field_[% field.id %]_filter">
134
                        <option value="">All</option>
135
                        [% FOREACH av IN field.authorised_value_choices %]
136
                          <option value="[% av.authorised_value %]">[% av.lib %]</option>
137
                        [% END %]
138
                      </select>
139
                    [% ELSE %]
140
                      <input id="additional_field_[% field.id %]" type="text" value="[% additional_fields.${field.name} %]" name="additional_field_[% field.id %]_filter" />
141
                    [% END %]
142
                  </li>
143
                [% END %]
128
              </ol>
144
              </ol>
129
              <input type="hidden" name="searched" value="1" />
145
              <input type="hidden" name="searched" value="1" />
130
              <fieldset class="action">
146
              <fieldset class="action">
Lines 153-158 Link Here
153
                        <th>Location</th>
169
                        <th>Location</th>
154
                        <th>Call number</th>
170
                        <th>Call number</th>
155
                        <th>Expiration date</th>
171
                        <th>Expiration date</th>
172
                        [% FOR field IN additional_fields_for_subscription %]
173
                          <th>[% field.name %]</th>
174
                        [% END %]
156
                        [% IF ( routing && CAN_user_serials_routing ) %]
175
                        [% IF ( routing && CAN_user_serials_routing ) %]
157
                          <th>Routing list</th>
176
                          <th>Routing list</th>
158
                        [% END %]
177
                        [% END %]
Lines 169-174 Link Here
169
                      <td><input type="text" class="filter" data-column_num="4" placeholder="Search location" /></td>
188
                      <td><input type="text" class="filter" data-column_num="4" placeholder="Search location" /></td>
170
                      <td><input type="text" class="filter" data-column_num="5" placeholder="Search callnumber" /></td>
189
                      <td><input type="text" class="filter" data-column_num="5" placeholder="Search callnumber" /></td>
171
                      <td><input type="text" class="filter" data-column_num="6" placeholder="Search expiration date" /></td>
190
                      <td><input type="text" class="filter" data-column_num="6" placeholder="Search expiration date" /></td>
191
                      [% FOR field IN additional_fields_for_subscription %]
192
                        <td><input type="text" class="filter" data-column_num="[% loop.count + 5 %]" placeholder="Search [% field.name %]" /></td>
193
                      [% END %]
172
                      [% IF ( routing && CAN_user_serials_routing ) %]<td></td>[% END %]
194
                      [% IF ( routing && CAN_user_serials_routing ) %]<td></td>[% END %]
173
                      <td></td>
195
                      <td></td>
174
                      <td></td>
196
                      <td></td>
Lines 203-208 Link Here
203
                                <span title="0000-00-00"></span>
225
                                <span title="0000-00-00"></span>
204
                            [% END %]
226
                            [% END %]
205
                        </td>
227
                        </td>
228
                        [% FOR field IN additional_fields_for_subscription %]
229
                          [% IF field.authorised_value_category %]
230
                            <td>[% AuthorisedValues.GetByCode( field.authorised_value_category, subscription.additional_fields.${field.name} ) %]</td>
231
                          [% ELSE %]
232
                            <td>[% subscription.additional_fields.${field.name} %]</td>
233
                          [% END %]
234
                        [% END %]
235
                        <td><a href="/cgi-bin/koha/serials/serials-collection.pl?subscriptionid=[% subscription.subscriptionid %]">Issue history</a>
236
                        </td>
206
                        [% IF ( routing && CAN_user_serials_routing ) %]
237
                        [% IF ( routing && CAN_user_serials_routing ) %]
207
                        <td>
238
                        <td>
208
                          [% IF ( subscription.cannotedit ) %]
239
                          [% IF ( subscription.cannotedit ) %]
Lines 217-224 Link Here
217
                          [% END %]
248
                          [% END %]
218
                        </td>
249
                        </td>
219
                        [% END %]
250
                        [% END %]
220
                        <td><a href="/cgi-bin/koha/serials/serials-collection.pl?subscriptionid=[% subscription.subscriptionid %]">Issue history</a>
221
                        </td>
222
                        <td>
251
                        <td>
223
                        [% IF ( CAN_user_serials_receive_serials ) %]
252
                        [% IF ( CAN_user_serials_receive_serials ) %]
224
                          <a href="/cgi-bin/koha/serials/serials-edit.pl?subscriptionid=[% subscription.subscriptionid %]&amp;serstatus=1,3,7">Serial receive</a>
253
                          <a href="/cgi-bin/koha/serials/serials-edit.pl?subscriptionid=[% subscription.subscriptionid %]&amp;serstatus=1,3,7">Serial receive</a>
Lines 238-243 Link Here
238
            <div id="closed">
267
            <div id="closed">
239
              [% IF closedsubscriptions %]
268
              [% IF closedsubscriptions %]
240
                <table id="csrlt">
269
                <table id="csrlt">
270
                <!-- FIXME add additional_fields for closed subs -->
241
                  <thead>
271
                  <thead>
242
                    <tr>
272
                    <tr>
243
                        <th>ISSN</th>
273
                        <th>ISSN</th>
Lines 246-251 Link Here
246
                        <th>Library</th>
276
                        <th>Library</th>
247
                        <th>Location</th>
277
                        <th>Location</th>
248
                        <th>Call number</th>
278
                        <th>Call number</th>
279
                        [% FOR field IN additional_fields_for_subscription %]
280
                          <th>[% field.name %]</th>
281
                        [% END %]
249
                        <th>&nbsp;</th>
282
                        <th>&nbsp;</th>
250
                        <th>&nbsp;</th>
283
                        <th>&nbsp;</th>
251
                    </tr>
284
                    </tr>
Lines 258-263 Link Here
258
                      <td><input type="text" class="filter" data-column_num="3" placeholder="Search library" /></td>
291
                      <td><input type="text" class="filter" data-column_num="3" placeholder="Search library" /></td>
259
                      <td><input type="text" class="filter" data-column_num="4" placeholder="Search location" /></td>
292
                      <td><input type="text" class="filter" data-column_num="4" placeholder="Search location" /></td>
260
                      <td><input type="text" class="filter" data-column_num="5" placeholder="Search callnumber" /></td>
293
                      <td><input type="text" class="filter" data-column_num="5" placeholder="Search callnumber" /></td>
294
                      [% FOR field IN additional_fields_for_subscription %]
295
                        <td><input type="text" class="filter" data-column_num="[% loop.count + 5 %]" placeholder="Search [% field.name %]" /></td>
296
                      [% END %]
261
                      <td></td>
297
                      <td></td>
262
                      <td></td>
298
                      <td></td>
263
                    </tr>
299
                    </tr>
Lines 287-292 Link Here
287
                        <td>
323
                        <td>
288
                          [% IF ( subscription.callnumber ) %][% subscription.callnumber %][% END %]
324
                          [% IF ( subscription.callnumber ) %][% subscription.callnumber %][% END %]
289
                        </td>
325
                        </td>
326
                        [% FOR field IN additional_fields_for_subscription %]
327
                          [% IF field.authorised_value_category %]
328
                            <td>[% KohaAuthorisedValues.GetByCode( field.authorised_value_category, subscription.additional_fields.${field.name} ) %]</td>
329
                          [% ELSE %]
330
                            <td>[% subscription.additional_fields.${field.name} %]</td>
331
                          [% END %]
332
                        [% END %]
290
                        <td>
333
                        <td>
291
                          [% UNLESS subscription.cannotedit %]
334
                          [% UNLESS subscription.cannotedit %]
292
                            <a href="/cgi-bin/koha/serials/serials-search.pl?subscriptionid=[% subscription.subscriptionid %]&amp;op=reopen&amp;routing=[% subscription.routing %]&amp;searched=1&amp;title_filter=[% title_filter %]&amp;ISSN_filter=[% ISSN_filter %]&amp;EAN_filter=[% EAN_filter %]&amp;published_filter=[% publisher_filter %]&amp;bookseller_filter=[% bookseller_filter %]&amp;branch_filter=[% branch_filter %]" id="reopensub">Reopen</a>
335
                            <a href="/cgi-bin/koha/serials/serials-search.pl?subscriptionid=[% subscription.subscriptionid %]&amp;op=reopen&amp;routing=[% subscription.routing %]&amp;searched=1&amp;title_filter=[% title_filter %]&amp;ISSN_filter=[% ISSN_filter %]&amp;EAN_filter=[% EAN_filter %]&amp;published_filter=[% publisher_filter %]&amp;bookseller_filter=[% bookseller_filter %]&amp;branch_filter=[% branch_filter %]" id="reopensub">Reopen</a>
Lines 385-390 Link Here
385
                  <input type="text" id="to" name="expiration_date_filter" value="[% expiration_date_filter | $KohaDates %]" size="10" maxlength="10" class="datepickerto" />
428
                  <input type="text" id="to" name="expiration_date_filter" value="[% expiration_date_filter | $KohaDates %]" size="10" maxlength="10" class="datepickerto" />
386
                </li>
429
                </li>
387
430
431
                [% FOR field IN additional_fields_for_subscription %]
432
                  <li>
433
                    <label for="additional_field_[% field.id %]ID"> [% field.name %]: </label>
434
                    [% IF field.authorised_value_choices %]
435
                      <select id="additional_field_[% field.id %]" name="additional_field_[% field.id %]_filter">
436
                        <option value="">All</option>
437
                        [% FOREACH av IN field.authorised_value_choices %]
438
                          [% IF av.authorised_value == additional_field_filters.${field.name} %]
439
                            <option value="[% av.authorised_value %]" selected="selected">[% av.lib %]</option>
440
                          [% ELSE %]
441
                            <option value="[% av.authorised_value %]">[% av.lib %]</option>
442
                          [% END %]
443
                        [% END %]
444
                      </select>
445
                    [% ELSE %]
446
                      <input id="additional_field_[% field.id %]" type="text" value="[% additional_field_filters.${field.name} %]" name="additional_field_[% field.id %]_filter" />
447
                    [% END %]
448
                  </li>
449
                [% END %]
388
              </ol>
450
              </ol>
389
              <input type="hidden" name="searched" value="1" />
451
              <input type="hidden" name="searched" value="1" />
390
              <fieldset class="action">
452
              <fieldset class="action">
(-)a/serials/serials-search.pl (-1 / +17 lines)
Lines 33-40 use CGI qw ( -utf8 ); 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
use Koha::DateUtils;
41
use Koha::DateUtils;
40
42
Lines 75-80 if ( $op and $op eq "close" ) { Link Here
75
    }
77
    }
76
}
78
}
77
79
80
81
my $additional_fields = Koha::AdditionalField->all( { table => 'subscription', searchable => 1 } );
82
my $additional_field_filters;
83
for my $field ( @$additional_fields ) {
84
    if ( my $filter_value = $query->param('additional_field_' . $field->{name} . '_filter') ) {
85
        $additional_field_filters->{ $field->{name} } = $filter_value;
86
    }
87
    if ( $field->{authorised_value_category} ) {
88
        $field->{authorised_value_choices} = GetAuthorisedValues( $field->{authorised_value_category} );
89
    }
90
}
91
78
my $expiration_date_dt = $expiration_date ? dt_from_string( $expiration_date ) : undef;
92
my $expiration_date_dt = $expiration_date ? dt_from_string( $expiration_date ) : undef;
79
my @subscriptions;
93
my @subscriptions;
80
if ($searched){
94
if ($searched){
Lines 88-93 if ($searched){ Link Here
88
            publisher    => $publisher,
102
            publisher    => $publisher,
89
            bookseller   => $bookseller,
103
            bookseller   => $bookseller,
90
            branch       => $branch,
104
            branch       => $branch,
105
            additional_fields => [ map{ { name => $_, value => $additional_field_filters->{$_}} } keys %$additional_field_filters ],
91
            location     => $location,
106
            location     => $location,
92
            expiration_date => $expiration_date_dt,
107
            expiration_date => $expiration_date_dt,
93
        }
108
        }
Lines 141-146 $template->param( Link Here
141
    branches_loop => \@branches_loop,
156
    branches_loop => \@branches_loop,
142
    done_searched => $searched,
157
    done_searched => $searched,
143
    routing       => $routing,
158
    routing       => $routing,
159
    additional_field_filters => $additional_field_filters,
160
    additional_fields_for_subscription => $additional_fields,
144
    marcflavour   => (uc(C4::Context->preference("marcflavour")))
161
    marcflavour   => (uc(C4::Context->preference("marcflavour")))
145
);
162
);
146
163
147
- 

Return to bug 10855