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

(-)a/C4/Acquisition.pm (-1 / +72 lines)
Lines 55-61 BEGIN { Link Here
55
        &GetOrderNumber &GetLateOrders &GetOrderFromItemnumber
55
        &GetOrderNumber &GetLateOrders &GetOrderFromItemnumber
56
        &SearchOrder &GetHistory &GetRecentAcqui
56
        &SearchOrder &GetHistory &GetRecentAcqui
57
        &ModReceiveOrder &ModOrderBiblioitemNumber
57
        &ModReceiveOrder &ModOrderBiblioitemNumber
58
        &GetCancelledOrders
58
        &GetCancelledOrders &TransferOrder
59
59
60
        &NewOrderItem &ModOrderItem
60
        &NewOrderItem &ModOrderItem
61
61
Lines 1295-1300 sub DelOrder { Link Here
1295
    
1295
    
1296
}
1296
}
1297
1297
1298
=head3 TransferOrder
1299
1300
    my $newordernumber = TransferOrder($ordernumber, $basketno);
1301
1302
Transfer an order line to a basket.
1303
Mark $ordernumber as cancelled with an internal note 'Cancelled and transfered
1304
to BOOKSELLER on DATE' and create new order with internal note
1305
'Transfered from BOOKSELLER on DATE'.
1306
Move all attached items to the new order.
1307
Received orders cannot be transfered.
1308
Return the ordernumber of created order.
1309
1310
=cut
1311
1312
sub TransferOrder {
1313
    my ($ordernumber, $basketno) = @_;
1314
1315
    return unless $ordernumber or $basketno;
1316
1317
    my $order = GetOrder( $ordernumber );
1318
    return if $order->{datereceived};
1319
1320
    my $today = C4::Dates->new()->output("iso");
1321
    my $query = qq{
1322
        SELECT aqbooksellers.name
1323
        FROM aqorders
1324
            LEFT JOIN aqbasket ON aqorders.basketno = aqbasket.basketno
1325
            LEFT JOIN aqbooksellers ON aqbasket.booksellerid = aqbooksellers.id
1326
        WHERE aqorders.ordernumber = ?
1327
    };
1328
    my $dbh = C4::Context->dbh;
1329
    my $sth = $dbh->prepare($query);
1330
    $sth->execute($ordernumber);
1331
    my ($booksellerfromname) = $sth->fetchrow_array;
1332
1333
    $query = qq{
1334
        SELECT aqbooksellers.name
1335
        FROM aqbasket
1336
            LEFT JOIN aqbooksellers ON aqbasket.booksellerid = aqbooksellers.id
1337
        WHERE aqbasket.basketno = ?
1338
    };
1339
    $sth = $dbh->prepare($query);
1340
    $sth->execute($basketno);
1341
    my ($booksellertoname) = $sth->fetchrow_array;
1342
1343
    $query = qq{
1344
        UPDATE aqorders
1345
        SET datecancellationprinted = CAST(NOW() AS date),
1346
            internalnotes = ?
1347
        WHERE ordernumber = ?
1348
    };
1349
    $sth = $dbh->prepare($query);
1350
    $sth->execute("Cancelled and transfered to $booksellertoname on $today", $ordernumber);
1351
1352
    delete $order->{'ordernumber'};
1353
    $order->{'basketno'} = $basketno;
1354
    $order->{'internalnotes'} = "Transfered from $booksellerfromname on $today";
1355
    my $newordernumber;
1356
    (undef, $newordernumber) = NewOrder($order);
1357
1358
    $query = qq{
1359
        UPDATE aqorders_items
1360
        SET ordernumber = ?
1361
        WHERE ordernumber = ?
1362
    };
1363
    $sth = $dbh->prepare($query);
1364
    $sth->execute($newordernumber, $ordernumber);
1365
1366
    return $newordernumber;
1367
}
1368
1298
=head2 FUNCTIONS ABOUT PARCELS
1369
=head2 FUNCTIONS ABOUT PARCELS
1299
1370
1300
=cut
1371
=cut
(-)a/installer/data/mysql/kohastructure.sql (+1 lines)
Lines 2722-2727 CREATE TABLE `aqorders` ( Link Here
2722
  `cancelledby` varchar(10) default NULL,
2722
  `cancelledby` varchar(10) default NULL,
2723
  `datecancellationprinted` date default NULL,
2723
  `datecancellationprinted` date default NULL,
2724
  `notes` mediumtext,
2724
  `notes` mediumtext,
2725
  internalnotes mediumtext DEFAULT NULL,
2725
  `supplierreference` mediumtext,
2726
  `supplierreference` mediumtext,
2726
  `purchaseordernumber` mediumtext,
2727
  `purchaseordernumber` mediumtext,
2727
  `subscription` tinyint(1) default NULL,
2728
  `subscription` tinyint(1) default NULL,
(-)a/installer/data/mysql/updatedatabase.pl (+10 lines)
Lines 5146-5151 if ( C4::Context->preference("Version") < TransformToNum($DBversion) ) { Link Here
5146
    SetVersion($DBversion);
5146
    SetVersion($DBversion);
5147
}
5147
}
5148
5148
5149
$DBversion = "XXX";
5150
if ( C4::Context->preference("Version") < TransformToNum($DBversion) ) {
5151
    $dbh->do(qq{
5152
        ALTER TABLE aqorders
5153
        ADD COLUMN internalnotes MEDIUMTEXT DEFAULT NULL AFTER notes
5154
    });
5155
    print "Upgrade to $DBversion done (Add internalnotes field in aqorders table)\n";
5156
    SetVersion($DBversion);
5157
}
5158
5149
=head1 FUNCTIONS
5159
=head1 FUNCTIONS
5150
5160
5151
=head2 DropAllForeignKeys($table)
5161
=head2 DropAllForeignKeys($table)
(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/acqui/basket.tt (+6 lines)
Lines 297-302 Link Here
297
                                    [<a href="/cgi-bin/koha/acqui/modordernotes.pl?ordernumber=[% books_loo.ordernumber %]">Add note</a>]
297
                                    [<a href="/cgi-bin/koha/acqui/modordernotes.pl?ordernumber=[% books_loo.ordernumber %]">Add note</a>]
298
                                [% END %]
298
                                [% END %]
299
                            </p>
299
                            </p>
300
                            <p>[% books_loo.internalnotes %]</p>
300
                        </td>
301
                        </td>
301
                        <td class="number">[% books_loo.rrp %]</td>
302
                        <td class="number">[% books_loo.rrp %]</td>
302
                        <td class="number">[% books_loo.ecost %]</td>
303
                        <td class="number">[% books_loo.ecost %]</td>
Lines 307-312 Link Here
307
                            [% UNLESS ( closedate ) %]
308
                            [% UNLESS ( closedate ) %]
308
                            <td>
309
                            <td>
309
                                <a href="neworderempty.pl?ordernumber=[% books_loo.ordernumber %]&amp;booksellerid=[% booksellerid %]&amp;basketno=[% basketno %]">Modify</a>
310
                                <a href="neworderempty.pl?ordernumber=[% books_loo.ordernumber %]&amp;booksellerid=[% booksellerid %]&amp;basketno=[% basketno %]">Modify</a>
311
                                [% UNLESS (books_loo.order_received) %]
312
                                    <br />
313
                                    <a href="/cgi-bin/koha/acqui/transferorder.pl?ordernumber=[% books_loo.ordernumber %]&referrer=[% "/cgi-bin/koha/acqui/basket.pl?basketno=$basketno" | uri %]">Transfer</a>
314
                                [% END %]
310
                            </td>
315
                            </td>
311
                            <td>
316
                            <td>
312
                            [% IF ( books_loo.left_holds_on_order ) %]
317
                            [% IF ( books_loo.left_holds_on_order ) %]
Lines 378-383 Link Here
378
                        [% IF ( order.publicationyear ) %], [% order.publicationyear %][% END %]
383
                        [% IF ( order.publicationyear ) %], [% order.publicationyear %][% END %]
379
                        [% IF ( books_loo.editionstatement ) %], [% books_loo.editionstatement %][% END %]
384
                        [% IF ( books_loo.editionstatement ) %], [% books_loo.editionstatement %][% END %]
380
                      </p>
385
                      </p>
386
                      <p>[% order.internalnotes %]</p>
381
                    </td>
387
                    </td>
382
                    <td><p>[% order.rrp %]</p></td>
388
                    <td><p>[% order.rrp %]</p></td>
383
                    <td><p>[% order.ecost %]</p></td>
389
                    <td><p>[% order.ecost %]</p></td>
(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/acqui/parcel.tt (-4 / +6 lines)
Lines 106-114 Link Here
106
                       + '<td>' + order.ecost + '</td>'
106
                       + '<td>' + order.ecost + '</td>'
107
                       + '<td>' + order.ordertotal + '</td>'
107
                       + '<td>' + order.ordertotal + '</td>'
108
                       + '<td>'
108
                       + '<td>'
109
                       + '<a href="orderreceive.pl?ordernumber=' + order.ordernumber + '&amp;datereceived=[% invoicedatereceived %]&amp;invoice=[% invoice %]&amp;gst=' + gst + '&amp;freight=' + order.freight + '&amp;booksellerid=[% booksellerid %]">Receive</a> /'
109
                       + '<a href="orderreceive.pl?ordernumber=' + order.ordernumber + '&amp;datereceived=[% invoicedatereceived %]&amp;invoice=[% invoice %]&amp;gst=' + gst + '&amp;freight=' + order.freight + '&amp;booksellerid=[% booksellerid %]">Receive</a>'
110
                       + '<a href="parcel.pl?type=intra&amp;ordernumber=' + order.ordernumber + '&amp;biblionumber=' + order.biblionumber + '&amp;action=cancelorder&amp;booksellerid=[% booksellerid %]&amp;datereceived=[% invoicedatereceived %]&amp;invoice=[% invoice %]" onclick="return confirm(\'' + _('Are you sure you want to cancel this order?') + '\');">Cancel</a>'
110
                       + '<br />'
111
                       + '</td></tr>').appendTo("table#pendingt");
111
                       + '<a href="/cgi-bin/koha/acqui/transferorder.pl?ordernumber=[% loop_order.ordernumber %]&amp;referrer=[% "/cgi-bin/koha/acqui/parcel.pl?booksellerid=$booksellerid&datereceived=$invoicedatereceived&invoice=$invoice" | uri %]">Transfer</a>'
112
                       + '</td><td></td></tr>').appendTo("table#pendingt");
112
				}
113
				}
113
114
114
				// If nothing has been found, we tell the user so
115
				// If nothing has been found, we tell the user so
Lines 259-264 Link Here
259
                <td>[% loop_order.ordertotal %]</td>
260
                <td>[% loop_order.ordertotal %]</td>
260
				<td>
261
				<td>
261
				    <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;booksellerid=[% loop_order.booksellerid %]">Receive</a>
262
				    <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;booksellerid=[% loop_order.booksellerid %]">Receive</a>
263
                    <br />
264
                    <a href="/cgi-bin/koha/acqui/transferorder.pl?ordernumber=[% loop_order.ordernumber %]&amp;referrer=[% "/cgi-bin/koha/acqui/parcel.pl?booksellerid=$booksellerid&datereceived=$invoicedatereceived&invoice=$invoice" | uri %]">Transfer</a>
262
				    
265
				    
263
				</td>
266
				</td>
264
				<td>
267
				<td>
265
- 

Return to bug 5349