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

(-)a/C4/Suggestions.pm (-3 / +57 lines)
Lines 40-45 our @EXPORT = qw< Link Here
40
    GetSuggestion
40
    GetSuggestion
41
    GetSuggestionByStatus
41
    GetSuggestionByStatus
42
    GetSuggestionFromBiblionumber
42
    GetSuggestionFromBiblionumber
43
    GetSuggestionInfoFromBiblionumber
44
    GetSuggestionInfo
43
    ModStatus
45
    ModStatus
44
    ModSuggestion
46
    ModSuggestion
45
    NewSuggestion
47
    NewSuggestion
Lines 209-221 sub GetSuggestionFromBiblionumber { Link Here
209
    my $query = q{
211
    my $query = q{
210
        SELECT suggestionid
212
        SELECT suggestionid
211
        FROM   suggestions
213
        FROM   suggestions
212
        WHERE  biblionumber=?
214
        WHERE  biblionumber=? LIMIT 1
213
    };
215
    };
214
    my $dbh=C4::Context->dbh;
216
    my $dbh=C4::Context->dbh;
215
    my $sth = $dbh->prepare($query);
217
    my $sth = $dbh->prepare($query);
216
    $sth->execute($biblionumber);
218
    $sth->execute($biblionumber);
217
    my ($ordernumber) = $sth->fetchrow;
219
    my ($suggestionid) = $sth->fetchrow;
218
    return $ordernumber;
220
    return $suggestionid;
221
}
222
223
=head2 GetSuggestionInfoFromBiblionumber
224
225
Get a suggestion and borrower's informations from it's biblionumber.
226
227
return :
228
all informations (suggestion and borrower) of the suggestion which is related to the biblionumber given.
229
230
=cut
231
232
sub GetSuggestionInfoFromBiblionumber {
233
    my ($biblionumber) = @_;
234
    my $query = qq{
235
        SELECT suggestions.*,
236
        U1.surname   AS surnamesuggestedby,
237
        U1.firstname AS firstnamesuggestedby,
238
        U1.borrowernumber AS borrnumsuggestedby
239
        FROM suggestions
240
        LEFT JOIN borrowers AS U1 ON suggestedby=U1.borrowernumber
241
        WHERE biblionumber = ? LIMIT 1
242
    };
243
    my $dbh = C4::Context->dbh;
244
    my $sth = $dbh->prepare($query);
245
    $sth->execute($biblionumber);
246
    return $sth->fetchrow_hashref;
247
}
248
249
=head2 GetSuggestionInfo
250
251
Get a suggestion and borrower's informations from it's suggestionid
252
253
return :
254
all informations (suggestion and borrower) of the suggestion which is related to the suggestionid given.
255
256
=cut
257
258
sub GetSuggestionInfo {
259
    my ($suggestionid) = @_;
260
    my $query = qq{
261
        SELECT suggestions.*,
262
        U1.surname   AS surnamesuggestedby,
263
        U1.firstname AS firstnamesuggestedby,
264
        U1.borrowernumber AS borrnumsuggestedby
265
        FROM suggestions
266
        LEFT JOIN borrowers AS U1 ON suggestedby=U1.borrowernumber
267
        WHERE suggestionid = ? LIMIT 1
268
    };
269
    my $dbh = C4::Context->dbh;
270
    my $sth = $dbh->prepare($query);
271
    $sth->execute($suggestionid);
272
    return $sth->fetchrow_hashref;
219
}
273
}
220
274
221
=head2 GetSuggestionByStatus
275
=head2 GetSuggestionByStatus
(-)a/acqui/basket.pl (+9 lines)
Lines 34-39 use C4::Debug; Link Here
34
use C4::Biblio;
34
use C4::Biblio;
35
use C4::Members qw/GetMember/;  #needed for permissions checking for changing basketgroup of a basket
35
use C4::Members qw/GetMember/;  #needed for permissions checking for changing basketgroup of a basket
36
use C4::Items;
36
use C4::Items;
37
use C4::Suggestions;
38
37
=head1 NAME
39
=head1 NAME
38
40
39
basket.pl
41
basket.pl
Lines 237-242 if ( $op eq 'delete_confirm' ) { Link Here
237
	
239
	
238
    my $qty_total;
240
    my $qty_total;
239
    my @books_loop;
241
    my @books_loop;
242
    my $suggestion;
240
243
241
    for my $order ( @results ) {
244
    for my $order ( @results ) {
242
        my $rrp = $order->{'listprice'} || 0;
245
        my $rrp = $order->{'listprice'} || 0;
Lines 303-308 if ( $op eq 'delete_confirm' ) { Link Here
303
	} else {
306
	} else {
304
	    $line{'title'} = "Deleted bibliographic notice, can't find title.";
307
	    $line{'title'} = "Deleted bibliographic notice, can't find title.";
305
	}
308
	}
309
310
        $suggestion = GetSuggestionInfoFromBiblionumber($line{biblionumber});
311
        $line{suggestionid}         = $suggestion->{suggestionid};
312
        $line{surnamesuggestedby}   = $suggestion->{surnamesuggestedby};
313
        $line{firstnamesuggestedby} = $suggestion->{firstnamesuggestedby};
314
306
        push @books_loop, \%line;
315
        push @books_loop, \%line;
307
    }
316
    }
308
317
(-)a/acqui/neworderempty.pl (-1 / +6 lines)
Lines 204-209 else { #modify order Link Here
204
    $booksellerid = $data2->{'booksellerid'};
204
    $booksellerid = $data2->{'booksellerid'};
205
}
205
}
206
206
207
my $suggestion;
208
$suggestion = GetSuggestionInfo($suggestionid) if $suggestionid;
209
207
# get currencies (for change rates calcs if needed)
210
# get currencies (for change rates calcs if needed)
208
my $active_currency = GetCurrency();
211
my $active_currency = GetCurrency();
209
my $default_currency;
212
my $default_currency;
Lines 359-365 $template->param( Link Here
359
    authorisedbyname     => $basket->{'authorisedbyname'},
362
    authorisedbyname     => $basket->{'authorisedbyname'},
360
    closedate            => C4::Dates->new($basket->{'closedate'},'iso')->output,
363
    closedate            => C4::Dates->new($basket->{'closedate'},'iso')->output,
361
    # order details
364
    # order details
362
    suggestionid     => $suggestionid,
365
    suggestionid         => $suggestion->{suggestionid},
366
    surnamesuggestedby   => $suggestion->{surnamesuggestedby},
367
    firstnamesuggestedby => $suggestion->{firstnamesuggestedby},
363
    biblionumber     => $biblionumber,
368
    biblionumber     => $biblionumber,
364
    uncertainprice   => $data->{'uncertainprice'},
369
    uncertainprice   => $data->{'uncertainprice'},
365
    authorisedbyname => $borrower->{'firstname'} . " " . $borrower->{'surname'},
370
    authorisedbyname => $borrower->{'firstname'} . " " . $borrower->{'surname'},
(-)a/acqui/orderreceive.pl (-1 / +7 lines)
Lines 75-80 use C4::Members; Link Here
75
use C4::Branch;    # GetBranches
75
use C4::Branch;    # GetBranches
76
use C4::Items;
76
use C4::Items;
77
use C4::Biblio;
77
use C4::Biblio;
78
use C4::Suggestions;
78
79
79
80
80
my $input      = new CGI;
81
my $input      = new CGI;
Lines 135-140 if ( $count == 1 ) { Link Here
135
        @$results[0]->{'unitprice'} = '';
136
        @$results[0]->{'unitprice'} = '';
136
    }
137
    }
137
138
139
    my $suggestion   = GetSuggestionInfoFromBiblionumber(@$results[0]->{'biblionumber'});
140
138
    my $authorisedby = @$results[0]->{'authorisedby'};
141
    my $authorisedby = @$results[0]->{'authorisedby'};
139
    my $member = GetMember( borrowernumber => $authorisedby );
142
    my $member = GetMember( borrowernumber => $authorisedby );
140
143
Lines 167-173 if ( $count == 1 ) { Link Here
167
        invoice               => $invoice,
170
        invoice               => $invoice,
168
        datereceived          => $datereceived->output(),
171
        datereceived          => $datereceived->output(),
169
        datereceived_iso      => $datereceived->output('iso'),
172
        datereceived_iso      => $datereceived->output('iso'),
170
        notes                 => $order->{notes}
173
        notes                 => $order->{notes},
174
        suggestionid          => $suggestion->{suggestionid},
175
        surnamesuggestedby    => $suggestion->{surnamesuggestedby},
176
        firstnamesuggestedby  => $suggestion->{firstnamesuggestedby},
171
    );
177
    );
172
}
178
}
173
else {
179
else {
(-)a/acqui/parcel.pl (-1 / +12 lines)
Lines 67-72 use C4::Items; Link Here
67
use CGI;
67
use CGI;
68
use C4::Output;
68
use C4::Output;
69
use C4::Dates qw/format_date format_date_in_iso/;
69
use C4::Dates qw/format_date format_date_in_iso/;
70
use C4::Suggestions;
70
use JSON;
71
use JSON;
71
72
72
my $input=new CGI;
73
my $input=new CGI;
Lines 178-183 for (my $i = 0 ; $i < $countlines ; $i++) { Link Here
178
    $totalprice += $parcelitems[$i]->{'unitprice'};
179
    $totalprice += $parcelitems[$i]->{'unitprice'};
179
    $line{unitprice} = sprintf($cfstr, $parcelitems[$i]->{'unitprice'});
180
    $line{unitprice} = sprintf($cfstr, $parcelitems[$i]->{'unitprice'});
180
181
182
    my $suggestion   = GetSuggestionInfoFromBiblionumber($line{biblionumber});
183
    $line{suggestionid}         = $suggestion->{suggestionid};
184
    $line{surnamesuggestedby}   = $suggestion->{surnamesuggestedby};
185
    $line{firstnamesuggestedby} = $suggestion->{firstnamesuggestedby};
186
181
    #double FIXME - totalfreight is redefined later.
187
    #double FIXME - totalfreight is redefined later.
182
188
183
# FIXME - each order in a  parcel holds the freight for the whole parcel. This means if you receive a parcel with items from multiple budgets, you'll see the freight charge in each budget..
189
# FIXME - each order in a  parcel holds the freight for the whole parcel. This means if you receive a parcel with items from multiple budgets, you'll see the freight charge in each budget..
Lines 230-236 for (my $i = 0 ; $i < $countpendings ; $i++) { Link Here
230
            $itemholds += $nb;
236
            $itemholds += $nb;
231
        }
237
        }
232
    }
238
    }
233
    
239
240
    my $suggestion   = GetSuggestionInfoFromBiblionumber($line{biblionumber});
241
    $line{suggestionid}         = $suggestion->{suggestionid};
242
    $line{surnamesuggestedby}   = $suggestion->{surnamesuggestedby};
243
    $line{firstnamesuggestedby} = $suggestion->{firstnamesuggestedby};
244
234
    # if the biblio is not in other orders and if there is no items elsewhere and no subscriptions and no holds we can then show the link "Delete order and Biblio" see bug 5680
245
    # if the biblio is not in other orders and if there is no items elsewhere and no subscriptions and no holds we can then show the link "Delete order and Biblio" see bug 5680
235
    $line{can_del_bib}          = 1 if $countbiblio <= 1 && $itemcount == scalar @items && !(@subscriptions) && !($holds);
246
    $line{can_del_bib}          = 1 if $countbiblio <= 1 && $itemcount == scalar @items && !(@subscriptions) && !($holds);
236
    $line{items}                = ($itemcount) - (scalar @items);
247
    $line{items}                = ($itemcount) - (scalar @items);
(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/acqui/basket.tt (+6 lines)
Lines 283-288 Link Here
283
                                    [% IF ( books_loo.issn ) %] - [% books_loo.issn %][% END %]
283
                                    [% IF ( books_loo.issn ) %] - [% books_loo.issn %][% END %]
284
                                    [% IF ( books_loo.publishercode ) %], [% books_loo.publishercode %][% END %]
284
                                    [% IF ( books_loo.publishercode ) %], [% books_loo.publishercode %][% END %]
285
                                    [% IF ( books_loo.publicationyear ) %], [% books_loo.publicationyear %][% END %]
285
                                    [% IF ( books_loo.publicationyear ) %], [% books_loo.publicationyear %][% END %]
286
                                    [% IF ( books_loo.suggestionid ) %]
287
                                        <br/>
288
                                        Suggested by [% books_loo.surnamesuggestedby %]
289
                                        [% IF ( books_loo.firstnamesuggestedby ) %], [% books_loo.firstnamesuggestedby %] [% END %]
290
                                        (from <a href="/cgi-bin/koha/suggestion/suggestion.pl?suggestionid=[% books_loo.suggestionid %]">suggestion #[% books_loo.suggestionid %]</a>)
291
                                    [% END %]
286
                            </p>
292
                            </p>
287
                            </td>
293
                            </td>
288
                        <td class="number">[% books_loo.rrp %]</td>
294
                        <td class="number">[% books_loo.rrp %]</td>
(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/acqui/neworderempty.tt (-1 / +13 lines)
Lines 166-172 $(document).ready(function() Link Here
166
    [% ELSE %]
166
    [% ELSE %]
167
        New order
167
        New order
168
    [% END %]
168
    [% END %]
169
        [% IF ( suggestionid ) %](defined from suggestion #[% suggestionid %])[% END %]
170
</h2>
169
</h2>
171
170
172
[% IF ( basketno ) %]
171
[% IF ( basketno ) %]
Lines 310-315 $(document).ready(function() Link Here
310
            [% END %]
309
            [% END %]
311
        </ol>
310
        </ol>
312
    </fieldset>
311
    </fieldset>
312
313
    [% IF ( suggestionid ) %]
314
        <fieldset class="rows">
315
        <legend>Suggestion</legend>
316
        <ol>
317
          <li>
318
            <span class="label">Suggested by </span>
319
            [% surnamesuggestedby %][% IF ( firstnamesuggestedby ) %], [% firstnamesuggestedby %][% END %] (from <a href="/cgi-bin/koha/suggestion/suggestion.pl?suggestionid=[% suggestionid %]">suggestion #[% suggestionid %]</a>)
320
          </li>
321
        </ol>
322
        </fieldset>
323
    [% END %]
324
313
    [% IF ( items ) %]
325
    [% IF ( items ) %]
314
    <fieldset class="rows">
326
    <fieldset class="rows">
315
        <legend>Item</legend>
327
        <legend>Item</legend>
(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/acqui/orderreceive.tt (+13 lines)
Lines 35-40 Link Here
35
        [% seriestitle %]</li>
35
        [% seriestitle %]</li>
36
    </ol>
36
    </ol>
37
	</fieldset>
37
	</fieldset>
38
39
    [% IF ( suggestionid ) %]
40
        <fieldset class="rows">
41
        <legend>Suggestion</legend>
42
        <ol>
43
          <li>
44
            <span class="label">Suggested by </span>
45
            [% surnamesuggestedby %][% IF ( firstnamesuggestedby ) %], [% firstnamesuggestedby %][% END %] (from <a href="/cgi-bin/koha/suggestion/suggestion.pl?suggestionid=[% suggestionid %]">suggestion #[% suggestionid %]</a>)
46
          </li>
47
        </ol>
48
        </fieldset>
49
    [% END %]
50
38
    [% IF ( items ) %]
51
    [% IF ( items ) %]
39
    <fieldset class="rows">
52
    <fieldset class="rows">
40
        <legend>Item</legend>
53
        <legend>Item</legend>
(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/acqui/parcel.tt (+12 lines)
Lines 241-246 Link Here
241
                [% IF ( loop_order.author ) %] by [% loop_order.author %][% END %]
241
                [% IF ( loop_order.author ) %] by [% loop_order.author %][% END %]
242
                [% IF ( loop_order.isbn ) %] &ndash; [% loop_order.isbn %][% END %]
242
                [% IF ( loop_order.isbn ) %] &ndash; [% loop_order.isbn %][% END %]
243
                [% IF ( loop_order.publishercode ) %]<br />Publisher :[% loop_order.publishercode %][% END %]
243
                [% IF ( loop_order.publishercode ) %]<br />Publisher :[% loop_order.publishercode %][% END %]
244
                [% IF ( loop_order.suggestionid ) %]
245
                    <br/>
246
                    Suggested by [% loop_order.surnamesuggestedby %]
247
                    [% IF ( loop_order.firstnamesuggestedby ) %], [% loop_order.firstnamesuggestedby %] [% END %]
248
                    (from <a href="/cgi-bin/koha/suggestion/suggestion.pl?suggestionid=[% loop_order.suggestionid %]">suggestion #[% loop_order.suggestionid %]</a>)
249
                [% END %]
244
                </td>
250
                </td>
245
                <td><a href="/cgi-bin/koha/catalogue/showmarc.pl?id=[% loop_order.biblionumber %]" title="MARC" rel="gb_page_center[600,500]">MARC</a> | <a href="/cgi-bin/koha/catalogue/showmarc.pl?viewas=card&amp;id=[% loop_order.biblionumber %]" title="MARC" rel="gb_page_center[600,500]">Card</a></td>
251
                <td><a href="/cgi-bin/koha/catalogue/showmarc.pl?id=[% loop_order.biblionumber %]" title="MARC" rel="gb_page_center[600,500]">MARC</a> | <a href="/cgi-bin/koha/catalogue/showmarc.pl?viewas=card&amp;id=[% loop_order.biblionumber %]" title="MARC" rel="gb_page_center[600,500]">Card</a></td>
246
                <td>[% loop_order.quantity %]</td>
252
                <td>[% loop_order.quantity %]</td>
Lines 361-366 Link Here
361
                [% IF ( loop_receive.author ) %] / [% loop_receive.author %][% END %]
367
                [% IF ( loop_receive.author ) %] / [% loop_receive.author %][% END %]
362
                [% IF ( loop_receive.isbn ) %] - [% loop_receive.isbn %][% END %]
368
                [% IF ( loop_receive.isbn ) %] - [% loop_receive.isbn %][% END %]
363
                [% IF ( loop_receive.publishercode ) %]<br />Publisher :[% loop_receive.publishercode %][% END %]
369
                [% IF ( loop_receive.publishercode ) %]<br />Publisher :[% loop_receive.publishercode %][% END %]
370
                [% IF ( loop_receive.suggestionid ) %]
371
                    <br/>
372
                    Suggested by [% loop_receive.surnamesuggestedby %]
373
                    [% IF ( loop_receive.firstnamesuggestedby ) %], [% loop_receive.firstnamesuggestedby %] [% END %]
374
                    (from <a href="/cgi-bin/koha/suggestion/suggestion.pl?suggestionid=[% loop_receive.suggestionid %]">suggestion #[% loop_receive.suggestionid %]</a>
375
                [% END %]
364
                </td>
376
                </td>
365
                <td><a href="/cgi-bin/koha/catalogue/showmarc.pl?id=[% loop_receive.biblionumber %]" title="MARC" rel="gb_page_center[600,500]">MARC</a> | <a href="/cgi-bin/koha/catalogue/showmarc.pl?viewas=card&amp;id=[% loop_receive.biblionumber %]" title="MARC" rel="gb_page_center[600,500]">Card</a></td>
377
                <td><a href="/cgi-bin/koha/catalogue/showmarc.pl?id=[% loop_receive.biblionumber %]" title="MARC" rel="gb_page_center[600,500]">MARC</a> | <a href="/cgi-bin/koha/catalogue/showmarc.pl?viewas=card&amp;id=[% loop_receive.biblionumber %]" title="MARC" rel="gb_page_center[600,500]">Card</a></td>
366
                <td>[% loop_receive.quantityreceived %]</td>
378
                <td>[% loop_receive.quantityreceived %]</td>
(-)a/t/db_dependent/Suggestions.t (-3 / +6 lines)
Lines 9-24 use Data::Dumper; Link Here
9
9
10
use C4::Suggestions;
10
use C4::Suggestions;
11
11
12
use Test::More tests =>6; 
12
use Test::More tests =>9;
13
13
14
BEGIN {
14
BEGIN {
15
    use_ok('C4::Suggestions');
15
    use_ok('C4::Suggestions');
16
}
16
}
17
17
18
my ($suggestionid, $suggestion, $status);
18
my ($suggestionid, $suggestion, $status, $biblionumber);
19
$biblionumber = 1;
19
ok($suggestionid= NewSuggestion( {title=>'Petit traité de philosohpie',author=>'Hubert de Chardassé',publishercode=>'Albin Michel'} ), "NewSuggestion OK");
20
ok($suggestionid= NewSuggestion( {title=>'Petit traité de philosohpie',author=>'Hubert de Chardassé',publishercode=>'Albin Michel'} ), "NewSuggestion OK");
20
ok($suggestion= GetSuggestion( $suggestionid), "GetSuggestion OK");
21
ok($suggestion= GetSuggestion( $suggestionid), "GetSuggestion OK");
21
ok($status= ModSuggestion( {title=>'test Modif Simple', suggestionid=>$suggestionid} ), "ModSuggestion Simple OK");
22
ok($status= ModSuggestion( {title=>'test Modif Simple', suggestionid=>$suggestionid} ), "ModSuggestion Simple OK");
22
ok($status= ModSuggestion( {STATUS=>'STALLED', suggestionid=>$suggestionid} ), "ModSuggestion Status OK");
23
ok($status= ModSuggestion( {STATUS=>'STALLED', suggestionid=>$suggestionid} ), "ModSuggestion Status OK");
24
ok($status= ModSuggestion( {suggestionid => $suggestionid, biblionumber => $biblionumber } ), "ModSuggestion, set biblionumber OK" );
25
ok($suggestion= GetSuggestionFromBiblionumber( $biblionumber ), "GetSuggestionFromBiblionumber OK");
26
ok($suggestion= GetSuggestionInfoFromBiblionumber( $biblionumber ), "GetSuggestionInfoFromBiblionumber OK");
23
ok(@{SearchSuggestion( {STATUS=>'STALLED'} )}>0, "SearchSuggestion Status OK");
27
ok(@{SearchSuggestion( {STATUS=>'STALLED'} )}>0, "SearchSuggestion Status OK");
24
28
25
- 

Return to bug 5346