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 (+73 lines)
Lines 94-99 BEGIN { Link Here
94
      &PrepHostMarcField
94
      &PrepHostMarcField
95
95
96
      &CountItemsIssued
96
      &CountItemsIssued
97
      &CountBiblioInOrders
98
      &GetSubscriptionsId
99
      &GetHolds
97
    );
100
    );
98
101
99
    # To modify something
102
    # To modify something
Lines 3806-3811 sub get_biblio_authorised_values { Link Here
3806
    return $authorised_values;
3809
    return $authorised_values;
3807
}
3810
}
3808
3811
3812
=head2 CountBiblioInOrders
3813
3814
=over 4
3815
$count = &CountBiblioInOrders( $biblionumber);
3816
3817
=back
3818
3819
This function return count of biblios in orders with $biblionumber 
3820
3821
=cut
3822
3823
sub CountBiblioInOrders {
3824
 my ($biblionumber) = @_;
3825
    my $dbh            = C4::Context->dbh;
3826
    my $query          = "SELECT count(*)
3827
          FROM  aqorders 
3828
          WHERE biblionumber=? AND (datecancellationprinted IS NULL OR datecancellationprinted='0000-00-00')";
3829
    my $sth = $dbh->prepare($query);
3830
    $sth->execute($biblionumber);
3831
    my $count = $sth->fetchrow;
3832
    return ($count);
3833
}
3834
3835
=head2 GetSubscriptionsId
3836
3837
=over 4
3838
$subscriptions = &GetSubscriptionsId($biblionumber);
3839
3840
=back
3841
3842
This function return an array of subscriptionid with $biblionumber
3843
3844
=cut
3845
3846
sub GetSubscriptionsId {
3847
 my ($biblionumber) = @_;
3848
    my $dbh            = C4::Context->dbh;
3849
    my $query          = "SELECT subscriptionid
3850
          FROM  subscription
3851
          WHERE biblionumber=?";
3852
    my $sth = $dbh->prepare($query);
3853
    $sth->execute($biblionumber);
3854
    my @subscriptions = $sth->fetchrow_array;
3855
    return (@subscriptions);
3856
}
3857
3858
=head2 GetHolds
3859
3860
=over 4
3861
$holds = &GetHolds($biblionumber);
3862
3863
=back
3864
3865
This function return the count of holds with $biblionumber
3866
3867
=cut
3868
3869
sub GetHolds {
3870
 my ($biblionumber) = @_;
3871
    my $dbh            = C4::Context->dbh;
3872
    my $query          = "SELECT count(*)
3873
          FROM  reserves
3874
          WHERE biblionumber=?";
3875
    my $sth = $dbh->prepare($query);
3876
    $sth->execute($biblionumber);
3877
    my $holds = $sth->fetchrow;
3878
    return ($holds);
3879
}
3880
3881
3809
1;
3882
1;
3810
3883
3811
__END__
3884
__END__
(-)a/C4/Items.pm (-2 / +25 lines)
Lines 74-87 BEGIN { Link Here
74
	get_hostitemnumbers_of
74
	get_hostitemnumbers_of
75
        GetItemnumberFromBarcode
75
        GetItemnumberFromBarcode
76
        GetBarcodeFromItemnumber
76
        GetBarcodeFromItemnumber
77
      GetHiddenItemnumbers
77
        GetHiddenItemnumbers
78
79
		DelItemCheck
78
		DelItemCheck
80
		MoveItemFromBiblio 
79
		MoveItemFromBiblio 
81
		GetLatestAcquisitions
80
		GetLatestAcquisitions
82
        CartToShelf
81
        CartToShelf
83
82
84
	GetAnalyticsCount
83
	GetAnalyticsCount
84
        GetItemHolds
85
    );
85
    );
86
}
86
}
87
87
Lines 2464-2467 sub GetAnalyticsCount { Link Here
2464
    }
2464
    }
2465
}
2465
}
2466
2466
2467
=head2 GetItemHolds
2468
2469
=over 4
2470
$holds = &GetItemHolds($biblionumber, $itemnumber);
2471
2472
=back
2473
2474
This function return the count of holds with $biblionumber and $itemnumber
2475
2476
=cut
2477
2478
sub GetItemHolds {
2479
    my ($biblionumber, $itemnumber) = @_;
2480
    my $holds;
2481
    my $dbh            = C4::Context->dbh;
2482
    my $query          = "SELECT count(*)
2483
        FROM  reserves
2484
        WHERE biblionumber=? AND itemnumber=?";
2485
    my $sth = $dbh->prepare($query);
2486
    $sth->execute($biblionumber, $itemnumber);
2487
    $holds = $sth->fetchrow;
2488
    return $holds;
2489
}
2467
1;
2490
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
                            <span 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</span><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
                            <span class="button" title="Can't delete catalog record, see constraints below">Can't delete order and catalog record</span><br>
296
                            [% END %]
297
                            [% IF ( books_loo.left_item ) %]
298
                            <b title="Can't delete catalog record, because of [% books_loo.items %] existing hold(s)" >[% books_loo.items %] item(s) left</b><br>
299
                            [% END %]
300
                            [% IF ( books_loo.left_biblio ) %]
301
                            <b title="Can't delete catalog record, delete other orders linked to it first">[% books_loo.biblios %] order(s) left</b><br>
302
                            [% END %]
303
                            [% IF ( books_loo.left_subscription ) %]
304
                            <b title="Can't delete catalog record, delete subscriptions first">[% books_loo.subscriptions %] subscription(s) left</b><br>
305
                            [% END %]
306
                            [% IF ( books_loo.left_holds ) %]
307
                            <b title="Can't delete catalog record or order, cancel holds first">[% books_loo.holds %] hold(s) left</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