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

(-)a/C4/Serials.pm (-78 / +1 lines)
Lines 52-58 BEGIN { Link Here
52
      &getroutinglist     &delroutingmember   &addroutingmember
52
      &getroutinglist     &delroutingmember   &addroutingmember
53
      &reorder_members
53
      &reorder_members
54
      &check_routing &updateClaim &removeMissingIssue
54
      &check_routing &updateClaim &removeMissingIssue
55
      &CountIssues &SearchSubscriptions
55
      &CountIssues
56
      &subscriptionCurrentlyOnOrder
56
      &subscriptionCurrentlyOnOrder
57
      HasItems
57
      HasItems
58
      &GetSubscriptionsFromBorrower
58
      &GetSubscriptionsFromBorrower
Lines 153-235 sub GetLateIssues { Link Here
153
    return @issuelist;
153
    return @issuelist;
154
}
154
}
155
155
156
=head2 SearchSubscriptions
157
158
@results = SearchSubscriptions($biblionumber, $title, $issn, $ean, $publisher, $supplier, $branch, $minold, $maxold);
159
160
this function gets all subscriptions which have biblionumber eq $biblionumber, title like $title, ISSN like $issn, EAN like $ean, publisher like $publisher, supplier like $supplier AND branchcode eq $branch.
161
$minold and $maxold are values in days. It allows to get active and inactive subscription apart.
162
163
return:
164
a table of hashref. Each hash containt the subscription.
165
166
=cut
167
168
sub SearchSubscriptions {
169
    my ($biblionumber, $title, $issn, $ean, $publisher, $supplier, $branch, $minold, $maxold) = @_;
170
171
    my $query = qq{
172
        SELECT subscription.*, subscriptionhistory.*, biblio.*, biblioitems.issn,
173
            subscription.notes AS notes
174
        FROM subscription
175
            LEFT JOIN subscriptionhistory USING(subscriptionid)
176
            LEFT JOIN biblio ON biblio.biblionumber = subscription.biblionumber
177
            LEFT JOIN biblioitems ON biblioitems.biblionumber = subscription.biblionumber
178
            LEFT JOIN aqbooksellers ON subscription.aqbooksellerid = aqbooksellers.id
179
    };
180
    my @where_strs;
181
    my @where_args;
182
    if($biblionumber){
183
        push @where_strs, "subscription.biblionumber = ?";
184
        push @where_args, "$biblionumber";
185
    }
186
    if($title){
187
        push @where_strs, "biblio.title LIKE ?";
188
        push @where_args, "%$title%";
189
    }
190
    if($issn){
191
        push @where_strs, "biblioitems.issn LIKE ?";
192
        push @where_args, "%$issn%";
193
    }
194
    if($ean){
195
        push @where_strs, "biblioitems.ean LIKE ?";
196
        push @where_args, "%$ean%";
197
    }
198
    if($publisher){
199
        push @where_strs, "biblioitems.publishercode LIKE ?";
200
        push @where_args, "%$publisher%";
201
    }
202
    if($supplier){
203
        push @where_strs, "aqbooksellers.name LIKE ?";
204
        push @where_args, "%$supplier%";
205
    }
206
    if($branch){
207
        push @where_strs, "subscription.branchcode = ?";
208
        push @where_args, "$branch";
209
    }
210
    if ($minold) {
211
        push @where_strs, "TO_DAYS(NOW()) - TO_DAYS(subscription.enddate) > ?" if ($minold);
212
        push @where_args, "$minold" if ($minold);
213
    }
214
    if ($maxold) {
215
        push @where_strs, "(TO_DAYS(NOW()) - TO_DAYS(subscription.enddate) <= ? OR subscription.enddate IS NULL OR subscription.enddate = '0000-00-00')";
216
        push @where_args, "$maxold";
217
    }
218
219
    if(@where_strs){
220
        $query .= " WHERE " . join(" AND ", @where_strs);
221
    }
222
    warn $query;
223
    warn join(",", @where_args) if @where_args;
224
    my $dbh = C4::Context->dbh;
225
    my $sth = $dbh->prepare($query);
226
    $sth->execute(@where_args);
227
    my $results = $sth->fetchall_arrayref( {} );
228
    $sth->finish;
229
230
    return @$results;
231
}
232
233
=head2
156
=head2
234
    $bool = subscriptionCurrentlyOnOrder( $subscriptionid );
157
    $bool = subscriptionCurrentlyOnOrder( $subscriptionid );
235
    Return 1 if subscription is already on order
158
    Return 1 if subscription is already on order
(-)a/acqui/newordersubscription.pl (-1 / +12 lines)
Lines 59-65 my ($bookseller) = C4::Bookseller::GetBookSellerFromId( $booksellerid); Link Here
59
my @subscriptions;
59
my @subscriptions;
60
my $sub;
60
my $sub;
61
if ($searched) {
61
if ($searched) {
62
    @subscriptions = SearchSubscriptions($biblionumber, $title, $ISSN, $EAN, $publisher, $supplier, $branch);
62
    @subscriptions = SearchSubscriptions(
63
        {
64
            biblionumber    => $biblionumber, 
65
            title           => $title, 
66
            issn            => $ISSN, 
67
            ean             => $EAN, 
68
            publisher       => $publisher, 
69
            bookseller      => $supplier, 
70
            branch          => $branch
71
        }
72
    );
63
}
73
}
64
74
65
75
Lines 104-108 $template->param( Link Here
104
    basketname       => $basket->{'basketname'},
114
    basketname       => $basket->{'basketname'},
105
    booksellername   => $bookseller->{'name'},
115
    booksellername   => $bookseller->{'name'},
106
    unfolded_search  => 1,
116
    unfolded_search  => 1,
117
    marcflavour      => uc(C4::Context->preference("marcflavour")),
107
);
118
);
108
output_html_with_http_headers $query, $cookie, $template->output;
119
output_html_with_http_headers $query, $cookie, $template->output;
(-)a/installer/data/mysql/kohastructure.sql (-1 / +1 lines)
Lines 2780-2786 CREATE TABLE `aqorders` ( -- information related to the basket line items Link Here
2780
  `uncertainprice` tinyint(1), -- was this price uncertain (1 for yes, 0 for no)
2780
  `uncertainprice` tinyint(1), -- was this price uncertain (1 for yes, 0 for no)
2781
  `claims_count` int(11) default 0, -- count of claim letters generated
2781
  `claims_count` int(11) default 0, -- count of claim letters generated
2782
  `claimed_date` date default NULL, -- last date a claim was generated
2782
  `claimed_date` date default NULL, -- last date a claim was generated
2783
  `subscriptionid` int(11) default NULL,
2783
  `subscriptionid` int(11) default NULL, -- links this order to a subscription in the serials module
2784
  parent_ordernumber int(11) default NULL, -- ordernumber of parent order line, or same as ordernumber if no parent
2784
  parent_ordernumber int(11) default NULL, -- ordernumber of parent order line, or same as ordernumber if no parent
2785
  PRIMARY KEY  (`ordernumber`),
2785
  PRIMARY KEY  (`ordernumber`),
2786
  KEY `basketno` (`basketno`),
2786
  KEY `basketno` (`basketno`),
(-)a/installer/data/mysql/updatedatabase.pl (-2 / +2 lines)
Lines 5862-5869 if (C4::Context->preference("Version") < TransformToNum($DBversion)) { Link Here
5862
5862
5863
$DBversion = "3.09.00.XXX";
5863
$DBversion = "3.09.00.XXX";
5864
if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
5864
if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
5865
    $dbh->do("ALTER TABLE `aqorders` ADD `subscriptionid` int(11) default NULL");
5865
    $dbh->do("ALTER TABLE `aqorders` ADD `subscriptionid` int(11) default NULL AFTER `claimed_date`");
5866
    print "Upgrade to $DBversion done (Alter table aqorders done)\n";
5866
    print "Upgrade to $DBversion done (Add subscriptionid to table aqorders)\n";
5867
    SetVersion ($DBversion);
5867
    SetVersion ($DBversion);
5868
}
5868
}
5869
5869
(-)a/koha-tmpl/intranet-tmpl/prog/en/includes/acquisitions-add-to-basket.inc (-1 / +1 lines)
Lines 6-12 Link Here
6
        <input type="hidden" name="basketno" value="[% basketno %]" />
6
        <input type="hidden" name="basketno" value="[% basketno %]" />
7
        <ul><li><label for="q">From an existing record: </label><input id="q" type="text"  size="25" name="q" />
7
        <ul><li><label for="q">From an existing record: </label><input id="q" type="text"  size="25" name="q" />
8
        <input type="submit" class="submit" value="Search" /></li>
8
        <input type="submit" class="submit" value="Search" /></li>
9
        <li><a href="/cgi-bin/koha/acqui/newordersubscription.pl?booksellerid=[% booksellerid %]&amp;basketno=[% basketno %]">From a Subscription</a></li>
9
        <li><a href="/cgi-bin/koha/acqui/newordersubscription.pl?booksellerid=[% booksellerid %]&amp;basketno=[% basketno %]">From a subscription</a></li>
10
        <li><a href="/cgi-bin/koha/acqui/newordersuggestion.pl?booksellerid=[% booksellerid %]&amp;basketno=[% basketno %]">From a suggestion</a></li>
10
        <li><a href="/cgi-bin/koha/acqui/newordersuggestion.pl?booksellerid=[% booksellerid %]&amp;basketno=[% basketno %]">From a suggestion</a></li>
11
        <li><a href="/cgi-bin/koha/acqui/neworderempty.pl?booksellerid=[% booksellerid %]&amp;basketno=[% basketno %]">From a new (empty) record</a></li>
11
        <li><a href="/cgi-bin/koha/acqui/neworderempty.pl?booksellerid=[% booksellerid %]&amp;basketno=[% basketno %]">From a new (empty) record</a></li>
12
        <li><a href="/cgi-bin/koha/acqui/z3950_search.pl?booksellerid=[% booksellerid %]&amp;basketno=[% basketno %]">From an external source</a></li>
12
        <li><a href="/cgi-bin/koha/acqui/z3950_search.pl?booksellerid=[% booksellerid %]&amp;basketno=[% basketno %]">From an external source</a></li>
(-)a/koha-tmpl/intranet-tmpl/prog/en/includes/subscriptions-search.inc (-1 / +3 lines)
Lines 17-26 Link Here
17
                <label for="title">Title:</label>
17
                <label for="title">Title:</label>
18
                <input type="text" id="title" name="title_filter" value="[% title_filter %]" />
18
                <input type="text" id="title" name="title_filter" value="[% title_filter %]" />
19
              </li>
19
              </li>
20
              [% IF ( marcflavour == "UNIMARC" ) %]
20
              <li>
21
              <li>
21
                <label for="ean">EAN:</label>
22
                <label for="ean">EAN:</label>
22
                <input type="text" id="ean" name="EAN_filter" value="[% EAN_filter %]" />
23
                <input type="text" id="ean" name="EAN_filter" value="[% EAN_filter %]" />
23
              </li>
24
              </li>
25
              [% END %]
24
              <li>
26
              <li>
25
                <label for="publisher">Publisher:</label>
27
                <label for="publisher">Publisher:</label>
26
                <input type="text" id="publisher" name="publisher_filter" value="[% publisher_filter %]" />
28
                <input type="text" id="publisher" name="publisher_filter" value="[% publisher_filter %]" />
Lines 30-36 Link Here
30
                <input type="text" id="supplier" name="supplier_filter" value="[% supplier_filter %]" />
32
                <input type="text" id="supplier" name="supplier_filter" value="[% supplier_filter %]" />
31
              </li>
33
              </li>
32
              <li>
34
              <li>
33
                <label for="branch">Branch:</label>
35
                <label for="branch">Library:</label>
34
                <select id="branch" name="branch_filter">
36
                <select id="branch" name="branch_filter">
35
                  <option value="">All</option>
37
                  <option value="">All</option>
36
                  [% FOREACH branches_loo IN branches_loop %]
38
                  [% FOREACH branches_loo IN branches_loop %]
(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/acqui/newordersubscription.tt (-3 / +2 lines)
Lines 43-49 Link Here
43
        <div class="yui-b">
43
        <div class="yui-b">
44
            <h2>Serials subscriptions</h2>
44
            <h2>Serials subscriptions</h2>
45
            [% IF ( routing ) %]
45
            [% IF ( routing ) %]
46
                <h3>Search for Serial Routing List</h3>
46
                <h3>Search for serial subscriptions</h3>
47
            [% END %]
47
            [% END %]
48
            [% IF ( done_searched ) %]
48
            [% IF ( done_searched ) %]
49
                <label for="show_only_renewed">
49
                <label for="show_only_renewed">
Lines 57-63 Link Here
57
                                <th>Id</th>
57
                                <th>Id</th>
58
                                <th>ISSN</th>
58
                                <th>ISSN</th>
59
                                <th>Title</th>
59
                                <th>Title</th>
60
                                <th> Notes </th>
60
                                <th>Notes</th>
61
                                <th>Library</th>
61
                                <th>Library</th>
62
                                <th>Call number</th>
62
                                <th>Call number</th>
63
                                <th>Expiration date</th>
63
                                <th>Expiration date</th>
64
- 

Return to bug 8415