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

(-)a/acqui/parcel.pl (-38 / +31 lines)
Lines 140-183 my ($template, $loggedinuser, $cookie) Link Here
140
                 debug => 1,
140
                 debug => 1,
141
});
141
});
142
142
143
my $action = $input->param('action');
144
my $ordernumber = $input->param('ordernumber');
145
my $biblionumber = $input->param('biblionumber');
146
147
# If canceling an order
148
if ($action eq "cancelorder") {
149
150
    my $error_delitem;
151
    my $error_delbiblio;
152
153
    # We delete the order
154
    DelOrder($biblionumber, $ordernumber);
155
156
    # We delete all the items related to this order
157
    my @itemnumbers = GetItemnumbersFromOrder($ordernumber);
158
    foreach (@itemnumbers) {
159
	my $delcheck = DelItemCheck(C4::Context->dbh, $biblionumber, $_);
160
	# (should always success, as no issue should exist on item on order)
161
	if ($delcheck != 1) { $error_delitem = 1; }
162
    }
163
164
    # We get the number of remaining items
165
    my $itemcount = GetItemsCount($biblionumber);
166
    
167
    # If there are no items left,
168
    if ($itemcount eq 0) {
169
	# We delete the record
170
	$error_delbiblio = DelBiblio($biblionumber);	
171
    }
172
173
    if ($error_delitem || $error_delbiblio) {
174
	if ($error_delitem)   { $template->param(error_delitem => 1); }
175
	if ($error_delbiblio) { $template->param(error_delbiblio => 1); }
176
    } else {
177
	$template->param(success_delorder => 1);
178
    }
179
}
180
181
# If receiving error, report the error (coming from finishrecieve.pl(sic)).
143
# If receiving error, report the error (coming from finishrecieve.pl(sic)).
182
if( scalar(@rcv_err) ) {
144
if( scalar(@rcv_err) ) {
183
	my $cnt=0;
145
	my $cnt=0;
Lines 237-242 my @loop_orders = (); Link Here
237
for (my $i = 0 ; $i < $countpendings ; $i++) {
199
for (my $i = 0 ; $i < $countpendings ; $i++) {
238
    my %line;
200
    my %line;
239
    %line = %{$pendingorders->[$i]};
201
    %line = %{$pendingorders->[$i]};
202
   
240
    $line{quantity}+=0;
203
    $line{quantity}+=0;
241
    $line{quantityreceived}+=0;
204
    $line{quantityreceived}+=0;
242
    $line{unitprice}+=0;
205
    $line{unitprice}+=0;
Lines 252-257 for (my $i = 0 ; $i < $countpendings ; $i++) { Link Here
252
    $line{total} = $total;
215
    $line{total} = $total;
253
    $line{supplierid} = $supplierid;
216
    $line{supplierid} = $supplierid;
254
    $ordergrandtotal += $line{ecost} * $line{quantity};
217
    $ordergrandtotal += $line{ecost} * $line{quantity};
218
    
219
    my $biblionumber = $line{'biblionumber'};
220
    my $countbiblio = CountBiblioInOrders($biblionumber);
221
    my $ordernumber = $line{'ordernumber'};
222
    my @subscriptions = GetSubscriptionsId ($biblionumber);
223
    my $itemcount = GetItemsCount($biblionumber);
224
    my $holds  = GetHolds ($biblionumber);
225
    my @items = GetItemnumbersFromOrder( $ordernumber );
226
    my $itemholds;
227
    foreach my $item (@items){
228
        my $nb = GetItemHolds($biblionumber, $item);
229
        if ($nb){
230
            $itemholds += $nb;
231
        }
232
    }
233
    
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
235
    $line{can_del_bib}          = 1 if $countbiblio <= 1 && $itemcount == scalar @items && !(@subscriptions) && !($holds);
236
    $line{items}                = ($itemcount) - (scalar @items);
237
    $line{left_item}            = 1 if $line{items} >= 1;
238
    $line{left_biblio}          = 1 if $countbiblio > 1;
239
    $line{biblios}              = $countbiblio - 1;
240
    $line{left_subscription}    = 1 if scalar @subscriptions >= 1;
241
    $line{subscriptions}        = scalar @subscriptions;
242
    $line{left_holds}           = 1 if $holds >= 1;
243
    $line{left_holds_on_order}  = 1 if $line{left_holds}==1 && ($line{items} == 0 || $itemholds );
244
    $line{holds}                = $holds;
245
    $line{holds_on_order}       = $itemholds?$itemholds:$holds if $line{left_holds_on_order};
246
    
247
    
255
    push @loop_orders, \%line if ($i >= $startfrom and $i < $startfrom + $resultsperpage);
248
    push @loop_orders, \%line if ($i >= $startfrom and $i < $startfrom + $resultsperpage);
256
}
249
}
257
$freight = $totalfreight unless $freight;
250
$freight = $totalfreight unless $freight;
(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/acqui/parcel.tt (-3 / +46 lines)
Lines 133-138 Link Here
133
133
134
//]]>
134
//]]>
135
</script>
135
</script>
136
<script type="text/javascript">
137
//<![CDATA[
138
            function confirm_delete_item(ordernumber, biblionumber) {
139
                var is_confirmed = confirm(_('Are you sure you want to delete this order ?'));
140
                if (is_confirmed) {
141
                    window.location = "addorder.pl?ordernumber="+ordernumber+"&basketno=[% basketno %]&quantity=0&biblionumber="+biblionumber;
142
                }
143
            }
144
            
145
            function confirm_delete_biblio(ordernumber, biblionumber) {
146
                var is_confirmed = confirm(_('Are you sure you want to delete this catalog record and order ?'));
147
                if (is_confirmed) {
148
                    window.location = "addorder.pl?ordernumber="+ordernumber+"&basketno=[% basketno %]&quantity=0&biblionumber="+biblionumber+"&delbiblio=1";
149
                    }
150
            }
151
152
//]]>
153
</script>
136
154
137
</head>
155
</head>
138
<body>
156
<body>
Lines 197-202 Link Here
197
            <th>Unit cost</th>
215
            <th>Unit cost</th>
198
            <th>Order cost</th>
216
            <th>Order cost</th>
199
            <th>&nbsp;</th>
217
            <th>&nbsp;</th>
218
            <th>&nbsp;</th>
200
        </tr>
219
        </tr>
201
    </thead>
220
    </thead>
202
		<tfoot>
221
		<tfoot>
Lines 205-210 Link Here
205
				<td>&nbsp;</td>
224
				<td>&nbsp;</td>
206
                <td>[% ordergrandtotal %]</td>
225
                <td>[% ordergrandtotal %]</td>
207
				<td>&nbsp;</td>
226
				<td>&nbsp;</td>
227
				<td>&nbsp;</td>
208
            </tr>
228
            </tr>
209
		</tfoot>
229
		</tfoot>
210
    <tbody class="filterclass">
230
    <tbody class="filterclass">
Lines 227-234 Link Here
227
                <td>[% loop_order.ecost %]</td>
247
                <td>[% loop_order.ecost %]</td>
228
                <td>[% loop_order.ordertotal %]</td>
248
                <td>[% loop_order.ordertotal %]</td>
229
				<td>
249
				<td>
230
				    <a href="orderreceive.pl?ordernumber=[% loop_order.ordernumber %]&amp;datereceived=[% loop_order.invoicedatereceived %]&amp;invoice=[% loop_order.invoice %]&amp;gst=[% loop_order.gst %]&amp;freight=[% loop_order.freight %]&amp;supplierid=[% loop_order.supplierid %]">Receive</a> /
250
				    <a href="orderreceive.pl?ordernumber=[% loop_order.ordernumber %]&amp;datereceived=[% loop_order.invoicedatereceived %]&amp;invoice=[% loop_order.invoice %]&amp;gst=[% loop_order.gst %]&amp;freight=[% loop_order.freight %]&amp;supplierid=[% loop_order.supplierid %]">Receive</a>
231
				    <a href="parcel.pl?type=intra&amp;ordernumber=[% loop_order.ordernumber %]&amp;biblionumber=[% loop_order.biblionumber %]&amp;action=cancelorder&amp;supplierid=[% loop_order.supplierid %]&amp;datereceived=[% loop_order.invoicedatereceived %]&amp;invoice=[% loop_order.invoice %]" onclick="return confirm(_('Are you sure you want to cancel this order?'));">Cancel</a>
251
				    
252
				</td>
253
				<td>
254
				    [% IF ( loop_order.left_holds_on_order ) %]
255
                    <span class="button" title="Can't delete order, ([% loop_order.holds_on_order %]) holds are linked with this order cancel holds first">Can't delete order</span><br>
256
                    [% ELSE %]
257
                    <a href="javascript:confirm_delete_item([% loop_order.ordernumber %],[% loop_order.biblionumber %])" class="button">Delete order</a><br>
258
                    [% END %]
259
                    [% IF ( loop_order.can_del_bib ) %]
260
                    <a href="javascript:confirm_delete_biblio([% loop_order.ordernumber %],[% loop_order.biblionumber %])" class="button">Delete order and catalog record</a><br>
261
                    [% ELSE %]
262
                    <span class="button" title="Can't delete catalog record, see constraints below">Can't delete order and catalog record</span><br>
263
                    [% END %]
264
                    [% IF ( loop_order.left_item ) %]
265
                    <b title="Can't delete catalog record, because of [% loop_order.items %] existing hold(s)" >[% loop_order.items %] item(s) left</b><br>
266
                    [% END %]
267
                    [% IF ( loop_order.left_biblio ) %]
268
                    <b title="Can't delete catalog record, delete other orders linked to it first">[% loop_order.biblios %] order(s) left</b><br>
269
                    [% END %]
270
                    [% IF ( loop_order.left_subscription ) %]
271
                    <b title="Can't delete catalog record, delete subscriptions first">[% loop_order.subscriptions %] subscription(s) left</b><br>
272
                    [% END %]
273
                    [% IF ( loop_order.left_holds ) %]
274
                    <b title="Can't delete catalog record or order, cancel holds first">[% loop_order.holds %] hold(s) left</b>
275
                    [% END %]
232
				</td>
276
				</td>
233
            </tr>
277
            </tr>
234
        [% END %]
278
        [% END %]
235
- 

Return to bug 5680