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

(-)a/C4/Acquisition.pm (-5 / +42 lines)
Lines 1208-1228 cancelled. Link Here
1208
=cut
1208
=cut
1209
1209
1210
sub DelOrder {
1210
sub DelOrder {
1211
    my ( $bibnum, $ordernumber ) = @_;
1211
    my ( $bibnum, $ordernumber, $delete_biblio, $reason ) = @_;
1212
1213
    my $error;
1212
    my $dbh = C4::Context->dbh;
1214
    my $dbh = C4::Context->dbh;
1213
    my $query = "
1215
    my $query = "
1214
        UPDATE aqorders
1216
        UPDATE aqorders
1215
        SET    datecancellationprinted=now()
1217
        SET    datecancellationprinted=now()
1216
        WHERE  biblionumber=? AND ordernumber=?
1218
    ";
1219
    if($reason) {
1220
        $query .= "
1221
            , notes = IF(notes IS NULL,
1222
                CONCAT('Cancellation reason: ', ?),
1223
                CONCAT(notes, ' - Cancellation reason: ', ?)
1224
            )
1225
        ";
1226
    }
1227
    $query .= "
1228
        WHERE biblionumber=? AND ordernumber=?
1217
    ";
1229
    ";
1218
    my $sth = $dbh->prepare($query);
1230
    my $sth = $dbh->prepare($query);
1219
    $sth->execute( $bibnum, $ordernumber );
1231
    if($reason) {
1232
        $sth->execute($reason, $reason, $bibnum, $ordernumber);
1233
    } else {
1234
        $sth->execute( $bibnum, $ordernumber );
1235
    }
1220
    $sth->finish;
1236
    $sth->finish;
1237
1221
    my @itemnumbers = GetItemnumbersFromOrder( $ordernumber );
1238
    my @itemnumbers = GetItemnumbersFromOrder( $ordernumber );
1222
    foreach my $itemnumber (@itemnumbers){
1239
    foreach my $itemnumber (@itemnumbers){
1223
    	C4::Items::DelItem( $dbh, $bibnum, $itemnumber );
1240
        my $delcheck = C4::Items::DelItemCheck( $dbh, $bibnum, $itemnumber );
1241
1242
        if($delcheck != 1) {
1243
            $error->{'delitem'} = 1;
1244
        }
1245
    }
1246
1247
    if($delete_biblio) {
1248
        # We get the number of remaining items
1249
        my $itemcount = C4::Items::GetItemsCount($bibnum);
1250
1251
        # If there are no items left,
1252
        if ( $itemcount == 0 ) {
1253
            # We delete the record
1254
            my $delcheck = DelBiblio($bibnum);
1255
1256
            if($delcheck) {
1257
                $error->{'delbiblio'} = 1;
1258
            }
1259
        }
1224
    }
1260
    }
1225
    
1261
1262
    return $error;
1226
}
1263
}
1227
1264
1228
=head2 FUNCTIONS ABOUT PARCELS
1265
=head2 FUNCTIONS ABOUT PARCELS
(-)a/acqui/addorder.pl (-45 / +3 lines)
Lines 123-129 use strict; Link Here
123
use warnings;
123
use warnings;
124
use CGI;
124
use CGI;
125
use C4::Auth;			# get_template_and_user
125
use C4::Auth;			# get_template_and_user
126
use C4::Acquisition;	# NewOrder DelOrder ModOrder
126
use C4::Acquisition;	# NewOrder ModOrder
127
use C4::Suggestions;	# ModStatus
127
use C4::Suggestions;	# ModStatus
128
use C4::Biblio;			# AddBiblio TransformKohaToMarc
128
use C4::Biblio;			# AddBiblio TransformKohaToMarc
129
use C4::Items;
129
use C4::Items;
Lines 153-196 my ( $template, $loggedinuser, $cookie ) = get_template_and_user( Link Here
153
my $orderinfo					= $input->Vars;
153
my $orderinfo					= $input->Vars;
154
$orderinfo->{'list_price'}    ||=  0;
154
$orderinfo->{'list_price'}    ||=  0;
155
$orderinfo->{'uncertainprice'} ||= 0;
155
$orderinfo->{'uncertainprice'} ||= 0;
156
#my $ordernumber        = $input->param('ordernumber');
157
#my $basketno      = $input->param('basketno');
158
#my $booksellerid  = $input->param('booksellerid');
159
#my $existing      = $input->param('existing');    # existing biblio, (not basket or order)
160
#my $title         = $input->param('title');
161
#my $author        = $input->param('author');
162
#my $publicationyear= $input->param('publicationyear');
163
#my $isbn          = $input->param('ISBN');
164
#my $itemtype      = $input->param('format');
165
#my $quantity      = $input->param('quantity');		# FIXME: else ERROR!
166
#my $branch        = $input->param('branch');
167
#my $series        = $input->param('series');
168
#my $notes         = $input->param('notes');
169
#my $budget_id     = $input->param('budget_id');
170
#my $sort1         = $input->param('sort1');
171
#my $sort2         = $input->param('sort2');
172
#my $rrp           = $input->param('rrp');
173
#my $ecost         = $input->param('ecost');
174
#my $gst           = $input->param('GST');
175
#my $budget        = $input->param('budget');
176
#my $cost          = $input->param('cost');
177
#my $sub           = $input->param('sub');
178
#my $purchaseorder = $input->param('purchaseordernumber');
179
#my $invoice       = $input->param('invoice');
180
#my $publishercode = $input->param('publishercode');
181
#my $suggestionid  = $input->param('suggestionid');
182
#my $biblionumber  = $input->param('biblionumber');
183
#my $uncertainprice = $input->param('uncertainprice');
184
#my $import_batch_id= $input->param('import_batch_id');
185
#
186
#my $createbibitem = $input->param('createbibitem');
187
#
188
my $user          = $input->remote_user;
189
# create, modify or delete biblio
156
# create, modify or delete biblio
190
# create if $quantity>=0 and $existing='no'
157
# create if $quantity>0 and $existing='no'
191
# modify if $quantity>=0 and $existing='yes'
158
# modify if $quantity>0 and $existing='yes'
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
194
my $bibitemnum;
159
my $bibitemnum;
195
if ( $orderinfo->{quantity} ne '0' ) {
160
if ( $orderinfo->{quantity} ne '0' ) {
196
    #TODO:check to see if biblio exists
161
    #TODO:check to see if biblio exists
Lines 269-281 if ( $orderinfo->{quantity} ne '0' ) { Link Here
269
234
270
}
235
}
271
236
272
else { # qty=0, delete the line
273
    my $biblionumber = $input->param('biblionumber');
274
    DelOrder( $biblionumber, $$orderinfo{ordernumber} );
275
    if ($orderinfo->{delbiblio} == 1){
276
     DelBiblio($biblionumber);
277
    }
278
}
279
my $basketno=$$orderinfo{basketno};
237
my $basketno=$$orderinfo{basketno};
280
my $booksellerid=$$orderinfo{booksellerid};
238
my $booksellerid=$$orderinfo{booksellerid};
281
if (my $import_batch_id=$$orderinfo{import_batch_id}) {
239
if (my $import_batch_id=$$orderinfo{import_batch_id}) {
(-)a/acqui/cancelorder.pl (+74 lines)
Line 0 Link Here
1
#!/usr/bin/perl
2
3
# Copyright 2011 BibLibre SARL
4
# This file is part of Koha.
5
#
6
# Koha is free software; you can redistribute it and/or modify it under the
7
# terms of the GNU General Public License as published by the Free Software
8
# Foundation; either version 2 of the License, or (at your option) any later
9
# version.
10
#
11
# Koha is distributed in the hope that it will be useful, but WITHOUT ANY
12
# WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
13
# A PARTICULAR PURPOSE.  See the GNU General Public License for more details.
14
#
15
# You should have received a copy of the GNU General Public License along
16
# with Koha; if not, write to the Free Software Foundation, Inc.,
17
# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
18
19
=head1 NAME
20
21
cancelorder.pl
22
23
=head1 DESCRIPTION
24
25
Ask confirmation for cancelling an order line
26
and add possibility to indicate a reason for cancellation
27
(saved in aqorders.notes)
28
29
=cut
30
31
use Modern::Perl;
32
33
use CGI;
34
use C4::Auth;
35
use C4::Output;
36
use C4::Acquisition;
37
38
my $input = new CGI;
39
my ($template, $loggedinuser, $cookie, $flags) = get_template_and_user( {
40
    template_name   => 'acqui/cancelorder.tt',
41
    query           => $input,
42
    type            => 'intranet',
43
    authnotrequired => 0,
44
    flagsrequired   => { 'acquisition' => 'order_manage' },
45
    debug           => 1,
46
} );
47
48
my $action = $input->param('action');
49
my $ordernumber = $input->param('ordernumber');
50
my $biblionumber = $input->param('biblionumber');
51
my $referrer = $input->param('referrer') || $input->referer;
52
my $del_biblio = $input->param('del_biblio') ? 1 : 0;
53
54
if($action and $action eq "confirmcancel") {
55
    my $reason = $input->param('reason');
56
    my $error = DelOrder($biblionumber, $ordernumber, $del_biblio, $reason);
57
58
    if($error) {
59
        $template->param(error_delitem => 1) if $error->{'delitem'};
60
        $template->param(error_delbiblio => 1) if $error->{'delbiblio'};
61
    } else {
62
        $template->param(success_cancelorder => 1);
63
    }
64
    $template->param(confirmcancel => 1);
65
}
66
67
$template->param(
68
    ordernumber => $ordernumber,
69
    biblionumber => $biblionumber,
70
    referrer => $referrer,
71
    del_biblio => $del_biblio,
72
);
73
74
output_html_with_http_headers $input, $cookie, $template->output;
(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/acqui/basket.tt (-15 / +2 lines)
Lines 25-43 Link Here
25
                    window.location = "[% script_name %]?op=delete_confirm&basketno=[% basketno %]&booksellerid=[% booksellerid %]";
25
                    window.location = "[% script_name %]?op=delete_confirm&basketno=[% basketno %]&booksellerid=[% booksellerid %]";
26
                }
26
                }
27
            }
27
            }
28
            function confirm_delete_item(ordernumber, biblionumber) {
29
                var is_confirmed = confirm(_('Are you sure you want to delete this order ?'));
30
                if (is_confirmed) {
31
                    window.location = "addorder.pl?ordernumber="+ordernumber+"&basketno=[% basketno %]&quantity=0&biblionumber="+biblionumber;
32
                }
33
            }
34
            
35
            function confirm_delete_biblio(ordernumber, biblionumber) {
36
                var is_confirmed = confirm(_('Are you sure you want to delete this catalog record and order ?'));
37
                if (is_confirmed) {
38
                    window.location = "addorder.pl?ordernumber="+ordernumber+"&basketno=[% basketno %]&quantity=0&biblionumber="+biblionumber+"&delbiblio=1";
39
                    }
40
            }
41
28
42
//]]>
29
//]]>
43
</script>
30
</script>
Lines 298-307 Link Here
298
                            [% IF ( books_loo.left_holds_on_order ) %]
285
                            [% IF ( books_loo.left_holds_on_order ) %]
299
                            <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>
286
                            <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>
300
                            [% ELSE %]
287
                            [% ELSE %]
301
                            <a href="javascript:confirm_delete_item([% books_loo.ordernumber %],[% books_loo.biblionumber %])" class="button">Delete order</a><br>
288
                            <a href="/cgi-bin/koha/acqui/cancelorder.pl?ordernumber=[% books_loo.ordernumber %]&biblionumber=[% books_loo.biblionumber %]&referrer=/cgi-bin/koha/acqui/basket.pl%3Fbasketno=[% basketno %]" class="button">Delete order</a><br>
302
                            [% END %]
289
                            [% END %]
303
                            [% IF ( books_loo.can_del_bib ) %]
290
                            [% IF ( books_loo.can_del_bib ) %]
304
                            <a href="javascript:confirm_delete_biblio([% books_loo.ordernumber %],[% books_loo.biblionumber %])" class="button">Delete order and catalog record</a><br>
291
                            <a href="/cgi-bin/koha/acqui/cancelorder.pl?ordernumber=[% books_loo.ordernumber %]&biblionumber=[% books_loo.biblionumber %]&del_biblio=1&referrer=/cgi-bin/koha/acqui/basket.pl%3Fbasketno=[% basketno %]" class="button">Delete order and catalog record</a><br>
305
                            [% ELSE %]
292
                            [% ELSE %]
306
                            <span class="button" title="Can't delete catalog record, see constraints below">Can't delete order and catalog record</span><br>
293
                            <span class="button" title="Can't delete catalog record, see constraints below">Can't delete order and catalog record</span><br>
307
                            [% END %]
294
                            [% END %]
(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/acqui/cancelorder.tt (+62 lines)
Line 0 Link Here
1
[% INCLUDE 'doc-head-open.inc' %]
2
<title>Koha &rsaquo; Acquisition &rsaquo; Cancel order</title>
3
[% INCLUDE 'doc-head-close.inc' %]
4
</head>
5
6
<body>
7
[% INCLUDE 'header.inc' %]
8
9
<div id="breadcrumbs"><a href="/cgi-bin/koha/mainpage.pl">Home</a> &rsaquo; <a href="/cgi-bin/koha/acqui/acqui-home.pl">Acquisition</a> &rsaquo; Cancel order</div>
10
11
<div id="doc3" class="yui-t2">
12
13
<div id="bd">
14
  <div id="yui-main">
15
    <div class="yui-b">
16
      [% UNLESS ( confirmcancel ) %]
17
      <form method="post" action="">
18
        <div class="dialog alert">
19
          <h3>Are you sure you want to cancel this order ([% ordernumber %])</h3>
20
          <p>
21
            [% IF (del_biblio) %]
22
              Bibliographic record will be deleted too.
23
            [% ELSE %]
24
              Bibliographic record will not be deleted.
25
            [% END %]
26
          </p>
27
          <p>
28
            <textarea name="reason" placeholder="Reason of cancellation"></textarea>
29
          </p>
30
          <input type="hidden" name="action" value="confirmcancel" />
31
          <input type="hidden" value="[% ordernumber %]" name="ordernumber" />
32
          <input type="hidden" value="[% biblionumber %]" name="biblionumber" />
33
          <input type="hidden" value="[% referrer %]" name="referrer" />
34
          [% IF (del_biblio) %]
35
            <input type="hidden" value="1" name="del_biblio" />
36
          [% END %]
37
          <input type="submit" class="approve" value="Yes, Cancel (Y)" accesskey="y" />
38
          <input type="submit" class="deny" value="No, Don't Cancel (N)" accesskey="n" onclick="window.location='[% referrer %]';return false;" />
39
        </div>
40
      </form>
41
      [% ELSE %]
42
        [% IF ( success_cancelorder ) %]
43
            <div class="dialog message">
44
                The order has been successfully canceled
45
        [% ELSE %]
46
            <div class="dialog alert">
47
                An error has occured.
48
                [% IF ( error_delitem ) %]
49
                    <p>The order has been canceled, although one or more items could not have been deleted.</p>
50
                [% END %]
51
                [% IF ( error_delbiblio ) %]
52
                <p>The order has been canceled, although the record has not been deleted.</p>
53
                [% END %]
54
        [% END %]
55
                <p>Click <a href="[% referrer %]">here</a> to return to previous page</p>
56
            </div>
57
      [% END %]
58
59
    </div>
60
  </div>
61
</div>
62
[% INCLUDE 'intranet-bottom.inc' %]
(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/acqui/parcel.tt (-3 / +2 lines)
Lines 138-151 Link Here
138
            function confirm_delete_item(ordernumber, basketno, biblionumber) {
138
            function confirm_delete_item(ordernumber, basketno, biblionumber) {
139
                var is_confirmed = confirm(_('Are you sure you want to delete this order ?'));
139
                var is_confirmed = confirm(_('Are you sure you want to delete this order ?'));
140
                if (is_confirmed) {
140
                if (is_confirmed) {
141
                    window.location = "addorder.pl?ordernumber="+ordernumber+"&basketno="+basketno+"&quantity=0&biblionumber="+biblionumber;
141
                    window.location = "/cgi-bin/koha/acqui/cancelorder.pl?ordernumber="+ordernumber+"&biblionumber="+biblionumber+"&referrer=/cgi-bin/koha/acqui/parcel.pl%3Fsupplierid=[% supplierid %]%26datereceived=[% datereceived %]%26invoice=[% invoice %]";
142
                }
142
                }
143
            }
143
            }
144
            
144
            
145
            function confirm_delete_biblio(ordernumber, biblionumber) {
145
            function confirm_delete_biblio(ordernumber, biblionumber) {
146
                var is_confirmed = confirm(_('Are you sure you want to delete this catalog record and order ?'));
146
                var is_confirmed = confirm(_('Are you sure you want to delete this catalog record and order ?'));
147
                if (is_confirmed) {
147
                if (is_confirmed) {
148
                    window.location = "addorder.pl?ordernumber="+ordernumber+"&basketno="+basketno+"&quantity=0&biblionumber="+biblionumber+"&delbiblio=1";
148
                    window.location = "/cgi-bin/koha/acqui/cancelorder.pl?ordernumber="+ordernumber+"&biblionumber="+biblionumber+"&del_biblio=1&referrer=/cgi-bin/koha/acqui/parcel.pl%3Fsupplierid=[% supplierid %]%26datereceived=[% datereceived %]%26invoice=[% invoice %]";
149
                    }
149
                    }
150
            }
150
            }
151
151
152
- 

Return to bug 7162