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

(-)a/C4/Acquisition.pm (+5 lines)
Lines 1221-1226 sub DelOrder { Link Here
1221
    my $sth = $dbh->prepare($query);
1221
    my $sth = $dbh->prepare($query);
1222
    $sth->execute( $bibnum, $ordernumber );
1222
    $sth->execute( $bibnum, $ordernumber );
1223
    $sth->finish;
1223
    $sth->finish;
1224
    my @itemnumbers = GetItemnumbersFromOrder( $ordernumber );
1225
    foreach my $itemnumber (@itemnumbers){
1226
    	C4::Items::DelItem( $dbh, $bibnum, $itemnumber );
1227
    }
1228
    
1224
}
1229
}
1225
1230
1226
=head2 FUNCTIONS ABOUT PARCELS
1231
=head2 FUNCTIONS ABOUT PARCELS
(-)a/C4/Biblio.pm (-1 / +73 lines)
Lines 90-97 BEGIN { Link Here
90
      &GetMarcFromKohaField
90
      &GetMarcFromKohaField
91
      &GetFrameworkCode
91
      &GetFrameworkCode
92
      &TransformKohaToMarc
92
      &TransformKohaToMarc
93
94
      &CountItemsIssued
93
      &CountItemsIssued
94
      &CountBiblioInOrders
95
      &GetSubscriptionsId
96
      &GetHolds
95
    );
97
    );
96
98
97
    # To modify something
99
    # To modify something
Lines 3681-3686 sub get_biblio_authorised_values { Link Here
3681
    return $authorised_values;
3683
    return $authorised_values;
3682
}
3684
}
3683
3685
3686
=head2 CountBiblioInOrders
3687
3688
=over 4
3689
$count = &CountBiblioInOrders( $biblionumber);
3690
3691
=back
3692
3693
This function return count of biblios in orders with $biblionumber 
3694
3695
=cut
3696
3697
sub CountBiblioInOrders {
3698
 my ($biblionumber) = @_;
3699
    my $dbh            = C4::Context->dbh;
3700
    my $query          = "SELECT count(*)
3701
          FROM  aqorders 
3702
          WHERE biblionumber=? AND (datecancellationprinted IS NULL OR datecancellationprinted='0000-00-00')";
3703
    my $sth = $dbh->prepare($query);
3704
    $sth->execute($biblionumber);
3705
    my $count = $sth->fetchrow;
3706
    return ($count);
3707
}
3708
3709
=head2 GetSubscriptionsId
3710
3711
=over 4
3712
$subscriptions = &GetSubscriptionsId($biblionumber);
3713
3714
=back
3715
3716
This function return an array of subscriptionid with $biblionumber
3717
3718
=cut
3719
3720
sub GetSubscriptionsId {
3721
 my ($biblionumber) = @_;
3722
    my $dbh            = C4::Context->dbh;
3723
    my $query          = "SELECT subscriptionid
3724
          FROM  subscription
3725
          WHERE biblionumber=?";
3726
    my $sth = $dbh->prepare($query);
3727
    $sth->execute($biblionumber);
3728
    my @subscriptions = $sth->fetchrow_array;
3729
    return (@subscriptions);
3730
}
3731
3732
=head2 GetHolds
3733
3734
=over 4
3735
$holds = &GetHolds($biblionumber);
3736
3737
=back
3738
3739
This function return the count of holds with $biblionumber
3740
3741
=cut
3742
3743
sub GetHolds {
3744
 my ($biblionumber) = @_;
3745
    my $dbh            = C4::Context->dbh;
3746
    my $query          = "SELECT count(*)
3747
          FROM  reserves
3748
          WHERE biblionumber=?";
3749
    my $sth = $dbh->prepare($query);
3750
    $sth->execute($biblionumber);
3751
    my $holds = $sth->fetchrow;
3752
    return ($holds);
3753
}
3754
3755
3684
1;
3756
1;
3685
3757
3686
__END__
3758
__END__
(-)a/C4/Items.pm (-3 / +26 lines)
Lines 68-83 BEGIN { Link Here
68
        GetItemInfosOf
68
        GetItemInfosOf
69
        GetItemsByBiblioitemnumber
69
        GetItemsByBiblioitemnumber
70
        GetItemsInfo
70
        GetItemsInfo
71
	GetItemsLocationInfo
71
        GetItemsLocationInfo
72
        get_itemnumbers_of
72
        get_itemnumbers_of
73
        GetItemnumberFromBarcode
73
        GetItemnumberFromBarcode
74
        GetBarcodeFromItemnumber
74
        GetBarcodeFromItemnumber
75
      GetHiddenItemnumbers
75
        GetHiddenItemnumbers
76
77
		DelItemCheck
76
		DelItemCheck
78
		MoveItemFromBiblio 
77
		MoveItemFromBiblio 
79
		GetLatestAcquisitions
78
		GetLatestAcquisitions
80
        CartToShelf
79
        CartToShelf
80
        GetItemHolds
81
    );
81
    );
82
}
82
}
83
83
Lines 2339-2342 sub _parse_unlinked_item_subfields_from_xml { Link Here
2339
    return $unlinked_subfields;
2339
    return $unlinked_subfields;
2340
}
2340
}
2341
2341
2342
=head2 GetItemHolds
2343
2344
=over 4
2345
$holds = &GetItemHolds($biblionumber, $itemnumber);
2346
2347
=back
2348
2349
This function return the count of holds with $biblionumber and $itemnumber
2350
2351
=cut
2352
2353
sub GetItemHolds {
2354
    my ($biblionumber, $itemnumber) = @_;
2355
    my $holds;
2356
    my $dbh            = C4::Context->dbh;
2357
    my $query          = "SELECT count(*)
2358
        FROM  reserves
2359
        WHERE biblionumber=? AND itemnumber=?";
2360
    my $sth = $dbh->prepare($query);
2361
    $sth->execute($biblionumber, $itemnumber);
2362
    $holds = $sth->fetchrow;
2363
    return $holds;
2364
}
2342
1;
2365
1;
(-)a/acqui/addorder.pl (+4 lines)
Lines 190-195 my $user = $input->remote_user; Link Here
190
# create if $quantity>=0 and $existing='no'
190
# create if $quantity>=0 and $existing='no'
191
# modify if $quantity>=0 and $existing='yes'
191
# modify if $quantity>=0 and $existing='yes'
192
# delete if $quantity has been set to 0 by the librarian
192
# delete if $quantity has been set to 0 by the librarian
193
# delete biblio if delbiblio has been set to 1 by the librarian
193
my $bibitemnum;
194
my $bibitemnum;
194
if ( $orderinfo->{quantity} ne '0' ) {
195
if ( $orderinfo->{quantity} ne '0' ) {
195
    #TODO:check to see if biblio exists
196
    #TODO:check to see if biblio exists
Lines 271-276 if ( $orderinfo->{quantity} ne '0' ) { Link Here
271
else { # qty=0, delete the line
272
else { # qty=0, delete the line
272
    my $biblionumber = $input->param('biblionumber');
273
    my $biblionumber = $input->param('biblionumber');
273
    DelOrder( $biblionumber, $$orderinfo{ordernumber} );
274
    DelOrder( $biblionumber, $$orderinfo{ordernumber} );
275
    if ($orderinfo->{delbiblio} == 1){
276
     DelBiblio($biblionumber);
277
    }
274
}
278
}
275
my $basketno=$$orderinfo{basketno};
279
my $basketno=$$orderinfo{basketno};
276
my $booksellerid=$$orderinfo{booksellerid};
280
my $booksellerid=$$orderinfo{booksellerid};
(-)a/acqui/basket.pl (-9 / +34 lines)
Lines 28-39 use C4::Output; Link Here
28
use CGI;
28
use CGI;
29
use C4::Acquisition;
29
use C4::Acquisition;
30
use C4::Budgets;
30
use C4::Budgets;
31
32
use C4::Bookseller qw( GetBookSellerFromId);
31
use C4::Bookseller qw( GetBookSellerFromId);
33
use C4::Dates qw/format_date/;
32
use C4::Dates qw/format_date/;
34
use C4::Debug;
33
use C4::Debug;
35
34
use C4::Biblio;
36
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;
37
=head1 NAME
37
=head1 NAME
38
38
39
basket.pl
39
basket.pl
Lines 259-271 if ( $op eq 'delete_confirm' ) { Link Here
259
		# FIXME: what about the "actual cost" field?
259
		# FIXME: what about the "actual cost" field?
260
        $qty_total += $qty;
260
        $qty_total += $qty;
261
        my %line = %{ $order };
261
        my %line = %{ $order };
262
262
        my $biblionumber = $order->{'biblionumber'};
263
        $line{order_received} = ( $qty == $order->{'quantityreceived'} );
263
        my $countbiblio = CountBiblioInOrders($biblionumber);
264
        $line{basketno}       = $basketno;
264
        my $ordernumber = $order->{'ordernumber'};
265
        $line{budget_name}    = $budget->{budget_name};
265
        my @subscriptions = GetSubscriptionsId ($biblionumber);
266
        $line{rrp}            = sprintf( "%.2f", $line{'rrp'} );
266
        my $itemcount = GetItemsCount($biblionumber);
267
        $line{ecost}          = sprintf( "%.2f", $line{'ecost'} );
267
        my $holds  = GetHolds ($biblionumber);
268
        $line{line_total}     = sprintf( "%.2f", $line_total );
268
        my @items = GetItemnumbersFromOrder( $ordernumber );
269
        my $itemholds;
270
        foreach my $item (@items){
271
            my $nb = GetItemHolds($biblionumber, $item);
272
            if ($nb){
273
                $itemholds += $nb;
274
            }
275
        }
276
        # 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
277
        $line{can_del_bib}          = 1 if $countbiblio <= 1 && $itemcount == scalar @items && !(@subscriptions) && !($holds);
278
        $line{items}                = ($itemcount) - (scalar @items);
279
        $line{left_item}            = 1 if $line{items} >= 1;
280
        $line{left_biblio}          = 1 if $countbiblio > 1;
281
        $line{biblios}              = $countbiblio - 1;
282
        $line{left_subscription}    = 1 if scalar @subscriptions >= 1;
283
        $line{subscriptions}        = scalar @subscriptions;
284
        $line{left_holds}           = 1 if $holds >= 1;
285
        $line{left_holds_on_order}  = 1 if $line{left_holds}==1 && ($line{items} == 0 || $itemholds );
286
        $line{holds}                = $holds;
287
        $line{holds_on_order}       = $itemholds?$itemholds:$holds if $line{left_holds_on_order};
288
        $line{order_received}       = ( $qty == $order->{'quantityreceived'} );
289
        $line{basketno}             = $basketno;
290
        $line{budget_name}          = $budget->{budget_name};
291
        $line{rrp}                  = sprintf( "%.2f", $line{'rrp'} );
292
        $line{ecost}                = sprintf( "%.2f", $line{'ecost'} );
293
        $line{line_total}           = sprintf( "%.2f", $line_total );
269
        if ($line{uncertainprice}) {
294
        if ($line{uncertainprice}) {
270
            $template->param( uncertainprices => 1 );
295
            $template->param( uncertainprices => 1 );
271
            $line{rrp} .= ' (Uncertain)';
296
            $line{rrp} .= ' (Uncertain)';
(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/acqui/basket.tt (-5 / +29 lines)
Lines 39-44 Link Here
39
                    window.location = "addorder.pl?ordernumber="+ordernumber+"&basketno=[% basketno %]&quantity=0&biblionumber="+biblionumber;
39
                    window.location = "addorder.pl?ordernumber="+ordernumber+"&basketno=[% basketno %]&quantity=0&biblionumber="+biblionumber;
40
                }
40
                }
41
            }
41
            }
42
            
43
            function confirm_delete_biblio(ordernumber, biblionumber) {
44
                var is_confirmed = confirm(_('Are you sure you want to delete this catalog record and order ?'));
45
                if (is_confirmed) {
46
                    window.location = "addorder.pl?ordernumber="+ordernumber+"&basketno=[% basketno %]&quantity=0&biblionumber="+biblionumber+"&delbiblio=1";
47
                    }
48
            }
42
49
43
//]]>
50
//]]>
44
</script>
51
</script>
Lines 277-283 Link Here
277
                                <a href="neworderempty.pl?ordernumber=[% books_loo.ordernumber %]&amp;booksellerid=[% booksellerid %]&amp;basketno=[% basketno %]">Modify</a>
284
                                <a href="neworderempty.pl?ordernumber=[% books_loo.ordernumber %]&amp;booksellerid=[% booksellerid %]&amp;basketno=[% basketno %]">Modify</a>
278
                            </td>
285
                            </td>
279
                            <td>
286
                            <td>
280
                            <a href="javascript:confirm_delete_item([% books_loo.ordernumber %],[% books_loo.biblionumber %])" class="button">Delete</a>
287
                            [% IF ( books_loo.left_holds_on_order ) %]
288
                            <a href="#" class="button" title="Can't delete order, ([% books_loo.holds_on_order %]) holds are linked with this order cancel holds first">Can't delete order</a><br>
289
                            [% ELSE %]
290
                            <a href="javascript:confirm_delete_item([% books_loo.ordernumber %],[% books_loo.biblionumber %])" class="button">Delete order</a><br>
291
                            [% END %]
292
                            [% IF ( books_loo.can_del_bib ) %]
293
                            <a href="javascript:confirm_delete_biblio([% books_loo.ordernumber %],[% books_loo.biblionumber %])" class="button">Delete order and Catalog record</a><br>
294
                            [% ELSE %]
295
                            <a href="#" class="button" title="Can't delete catalog record, see constraints below">Can't delete order and Catalog record</a><br>
296
                            [% END %]
297
                            [% IF ( books_loo.left_item ) %]
298
                            <b title="Can't delete catalog record, ([% books_loo.items %]) items are linked delete items first" >**Left ([% books_loo.items %]) Items**</b><br>
299
                            [% END %]
300
                            [% IF ( books_loo.left_biblio ) %]
301
                            <b title="Can't delete catalog record, it is needed in other orders delete ([% books_loo.biblios %]) orders first">**Left ([% books_loo.biblios %]) orders**</b><br>
302
                            [% END %]
303
                            [% IF ( books_loo.left_subscription ) %]
304
                            <b title="Can't delete catalog record, ([% books_loo.subscriptions %]) subscriptions are linked delete subscriptions first">**Left ([% books_loo.subscriptions %]) subscriptions**</b><br>
305
                            [% END %]
306
                            [% IF ( books_loo.left_holds ) %]
307
                            <b title="Can't delete catalog record nor order, ([% books_loo.holds %]) holds are linked cancel holds first">**Left ([% books_loo.holds %]) holds**</b>
308
                            [% END %]
281
                            </td>
309
                            </td>
282
                            [% END %]
310
                            [% END %]
283
                        [% END %]
311
                        [% END %]
Lines 320-328 Link Here
320
        </form>
348
        </form>
321
        </div>
349
        </div>
322
    [% END %]
350
    [% END %]
323
324
325
326
</div>
351
</div>
327
</div>
352
</div>
328
<div class="yui-b">
353
<div class="yui-b">
329
- 

Return to bug 5680