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

(-)a/C4/Acquisition.pm (-27 / +24 lines)
Lines 939-949 sub GetOrders { Link Here
939
        SELECT biblio.*,biblioitems.*,
939
        SELECT biblio.*,biblioitems.*,
940
                aqorders.*,
940
                aqorders.*,
941
                aqbudgets.*,
941
                aqbudgets.*,
942
                biblio.title
942
                biblio.title,
943
                aqorders_transfers.ordernumber_from AS transferred_from,
944
                aqorders_transfers.timestamp AS transferred_from_timestamp
943
        FROM    aqorders
945
        FROM    aqorders
944
            LEFT JOIN aqbudgets        ON aqbudgets.budget_id = aqorders.budget_id
946
            LEFT JOIN aqbudgets        ON aqbudgets.budget_id = aqorders.budget_id
945
            LEFT JOIN biblio           ON biblio.biblionumber = aqorders.biblionumber
947
            LEFT JOIN biblio           ON biblio.biblionumber = aqorders.biblionumber
946
            LEFT JOIN biblioitems      ON biblioitems.biblionumber =biblio.biblionumber
948
            LEFT JOIN biblioitems      ON biblioitems.biblionumber =biblio.biblionumber
949
            LEFT JOIN aqorders_transfers ON aqorders_transfers.ordernumber_to = aqorders.ordernumber
947
        WHERE   basketno=?
950
        WHERE   basketno=?
948
            AND (datecancellationprinted IS NULL OR datecancellationprinted='0000-00-00')
951
            AND (datecancellationprinted IS NULL OR datecancellationprinted='0000-00-00')
949
    ";
952
    ";
Lines 1265-1275 sub GetCancelledOrders { Link Here
1265
1268
1266
    my $dbh   = C4::Context->dbh;
1269
    my $dbh   = C4::Context->dbh;
1267
    my $query = "
1270
    my $query = "
1268
        SELECT biblio.*, biblioitems.*, aqorders.*, aqbudgets.*
1271
        SELECT
1272
            biblio.*,
1273
            biblioitems.*,
1274
            aqorders.*,
1275
            aqbudgets.*,
1276
            aqorders_transfers.ordernumber_to AS transferred_to,
1277
            aqorders_transfers.timestamp AS transferred_to_timestamp
1269
        FROM aqorders
1278
        FROM aqorders
1270
          LEFT JOIN aqbudgets   ON aqbudgets.budget_id = aqorders.budget_id
1279
          LEFT JOIN aqbudgets   ON aqbudgets.budget_id = aqorders.budget_id
1271
          LEFT JOIN biblio      ON biblio.biblionumber = aqorders.biblionumber
1280
          LEFT JOIN biblio      ON biblio.biblionumber = aqorders.biblionumber
1272
          LEFT JOIN biblioitems ON biblioitems.biblionumber = biblio.biblionumber
1281
          LEFT JOIN biblioitems ON biblioitems.biblionumber = biblio.biblionumber
1282
          LEFT JOIN aqorders_transfers ON aqorders_transfers.ordernumber_from = aqorders.ordernumber
1273
        WHERE basketno = ?
1283
        WHERE basketno = ?
1274
          AND (datecancellationprinted IS NOT NULL
1284
          AND (datecancellationprinted IS NOT NULL
1275
               AND datecancellationprinted <> '0000-00-00')
1285
               AND datecancellationprinted <> '0000-00-00')
Lines 1616-1657 sub TransferOrder { Link Here
1616
1626
1617
    my $order = GetOrder( $ordernumber );
1627
    my $order = GetOrder( $ordernumber );
1618
    return if $order->{datereceived};
1628
    return if $order->{datereceived};
1629
    my $basket = GetBasket($basketno);
1630
    return unless $basket;
1619
1631
1620
    my $today = C4::Dates->new()->output("iso");
1621
    my $query = qq{
1622
        SELECT aqbooksellers.name
1623
        FROM aqorders
1624
            LEFT JOIN aqbasket ON aqorders.basketno = aqbasket.basketno
1625
            LEFT JOIN aqbooksellers ON aqbasket.booksellerid = aqbooksellers.id
1626
        WHERE aqorders.ordernumber = ?
1627
    };
1628
    my $dbh = C4::Context->dbh;
1632
    my $dbh = C4::Context->dbh;
1629
    my $sth = $dbh->prepare($query);
1633
    my ($query, $sth, $rv);
1630
    $sth->execute($ordernumber);
1631
    my ($booksellerfromname) = $sth->fetchrow_array;
1632
1633
    $query = qq{
1634
        SELECT aqbooksellers.name
1635
        FROM aqbasket
1636
            LEFT JOIN aqbooksellers ON aqbasket.booksellerid = aqbooksellers.id
1637
        WHERE aqbasket.basketno = ?
1638
    };
1639
    $sth = $dbh->prepare($query);
1640
    $sth->execute($basketno);
1641
    my ($booksellertoname) = $sth->fetchrow_array;
1642
1634
1643
    $query = qq{
1635
    $query = qq{
1644
        UPDATE aqorders
1636
        UPDATE aqorders
1645
        SET datecancellationprinted = CAST(NOW() AS date),
1637
        SET datecancellationprinted = CAST(NOW() AS date)
1646
            internalnotes = ?
1647
        WHERE ordernumber = ?
1638
        WHERE ordernumber = ?
1648
    };
1639
    };
1649
    $sth = $dbh->prepare($query);
1640
    $sth = $dbh->prepare($query);
1650
    $sth->execute("Cancelled and transfered to $booksellertoname on $today", $ordernumber);
1641
    $rv = $sth->execute($ordernumber);
1651
1642
1652
    delete $order->{'ordernumber'};
1643
    delete $order->{'ordernumber'};
1653
    $order->{'basketno'} = $basketno;
1644
    $order->{'basketno'} = $basketno;
1654
    $order->{'internalnotes'} = "Transfered from $booksellerfromname on $today";
1655
    my $newordernumber;
1645
    my $newordernumber;
1656
    (undef, $newordernumber) = NewOrder($order);
1646
    (undef, $newordernumber) = NewOrder($order);
1657
1647
Lines 1663-1668 sub TransferOrder { Link Here
1663
    $sth = $dbh->prepare($query);
1653
    $sth = $dbh->prepare($query);
1664
    $sth->execute($newordernumber, $ordernumber);
1654
    $sth->execute($newordernumber, $ordernumber);
1665
1655
1656
    $query = q{
1657
        INSERT INTO aqorders_transfers (ordernumber_from, ordernumber_to)
1658
        VALUES (?, ?)
1659
    };
1660
    $sth = $dbh->prepare($query);
1661
    $sth->execute($ordernumber, $newordernumber);
1662
1666
    return $newordernumber;
1663
    return $newordernumber;
1667
}
1664
}
1668
1665
(-)a/acqui/basket.pl (-6 / +15 lines)
Lines 304-314 if ( $op eq 'delete_confirm' ) { Link Here
304
        last;
304
        last;
305
    }
305
    }
306
306
307
    my @cancelledorders = GetCancelledOrders($basketno);
308
    foreach (@cancelledorders) {
309
        $_->{'line_total'} = sprintf("%.2f", $_->{'ecost'} * $_->{'quantity'});
310
    }
311
312
    $template->param(
307
    $template->param(
313
        basketno             => $basketno,
308
        basketno             => $basketno,
314
        basketname           => $basket->{'basketname'},
309
        basketname           => $basket->{'basketname'},
Lines 328-334 if ( $op eq 'delete_confirm' ) { Link Here
328
        name                 => $bookseller->{'name'},
323
        name                 => $bookseller->{'name'},
329
        books_loop           => \@books_loop,
324
        books_loop           => \@books_loop,
330
        book_foot_loop       => \@book_foot_loop,
325
        book_foot_loop       => \@book_foot_loop,
331
        cancelledorders_loop => \@cancelledorders,
326
        cancelledorders_loop => \@cancelledorders_loop,
332
        total_quantity       => $total_quantity,
327
        total_quantity       => $total_quantity,
333
        total_gste           => sprintf( "%.2f", $total_gste ),
328
        total_gste           => sprintf( "%.2f", $total_gste ),
334
        total_gsti           => sprintf( "%.2f", $total_gsti ),
329
        total_gsti           => sprintf( "%.2f", $total_gsti ),
Lines 424-429 sub get_order_infos { Link Here
424
    $line{surnamesuggestedby}   = $$suggestion{surnamesuggestedby};
419
    $line{surnamesuggestedby}   = $$suggestion{surnamesuggestedby};
425
    $line{firstnamesuggestedby} = $$suggestion{firstnamesuggestedby};
420
    $line{firstnamesuggestedby} = $$suggestion{firstnamesuggestedby};
426
421
422
    foreach my $key (qw(transferred_from transferred_to)) {
423
        if ($line{$key}) {
424
            my $order = GetOrder($line{$key});
425
            my $basket = GetBasket($order->{basketno});
426
            my $bookseller = GetBookSellerFromId($basket->{booksellerid});
427
            $line{$key} = {
428
                order => $order,
429
                basket => $basket,
430
                bookseller => $bookseller,
431
                timestamp => $line{$key . '_timestamp'},
432
            };
433
        }
434
    }
435
427
    return \%line;
436
    return \%line;
428
}
437
}
429
438
(-)a/installer/data/mysql/kohastructure.sql (-1 / +15 lines)
Lines 2911-2917 CREATE TABLE `aqorders` ( -- information related to the basket line items Link Here
2911
  `cancelledby` varchar(10) default NULL, -- not used? always NULL
2911
  `cancelledby` varchar(10) default NULL, -- not used? always NULL
2912
  `datecancellationprinted` date default NULL, -- the date the line item was deleted
2912
  `datecancellationprinted` date default NULL, -- the date the line item was deleted
2913
  `notes` mediumtext, -- notes related to this order line
2913
  `notes` mediumtext, -- notes related to this order line
2914
  internalnotes mediumtext DEFAULT NULL, -- used by Koha to store some informations, not editable by librarians
2915
  `supplierreference` mediumtext, -- not used? always NULL
2914
  `supplierreference` mediumtext, -- not used? always NULL
2916
  `purchaseordernumber` mediumtext, -- not used? always NULL
2915
  `purchaseordernumber` mediumtext, -- not used? always NULL
2917
  `basketno` int(11) default NULL, -- links this order line to a specific basket (aqbasket.basketno)
2916
  `basketno` int(11) default NULL, -- links this order line to a specific basket (aqbasket.basketno)
Lines 2959-2964 CREATE TABLE `aqorders_items` ( -- information on items entered in the acquisiti Link Here
2959
2958
2960
2959
2961
--
2960
--
2961
-- Table structure for table aqorders_transfers
2962
--
2963
2964
DROP TABLE IF EXISTS aqorders_transfers;
2965
CREATE TABLE aqorders_transfers (
2966
  ordernumber_from int(11) NULL,
2967
  ordernumber_to int(11) NULL,
2968
  timestamp timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP,
2969
  UNIQUE KEY ordernumber_from (ordernumber_from),
2970
  UNIQUE KEY ordernumber_to (ordernumber_to),
2971
  CONSTRAINT aqorders_transfers_ordernumber_from FOREIGN KEY (ordernumber_from) REFERENCES aqorders (ordernumber) ON DELETE SET NULL ON UPDATE CASCADE,
2972
  CONSTRAINT aqorders_transfers_ordernumber_to FOREIGN KEY (ordernumber_to) REFERENCES aqorders (ordernumber) ON DELETE SET NULL ON UPDATE CASCADE
2973
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
2974
2975
--
2962
-- Table structure for table aqinvoices
2976
-- Table structure for table aqinvoices
2963
--
2977
--
2964
2978
(-)a/installer/data/mysql/updatedatabase.pl (-3 / +11 lines)
Lines 7060-7070 if ( CheckVersion($DBversion) ) { Link Here
7060
7060
7061
$DBversion = "XXX";
7061
$DBversion = "XXX";
7062
if ( C4::Context->preference("Version") < TransformToNum($DBversion) ) {
7062
if ( C4::Context->preference("Version") < TransformToNum($DBversion) ) {
7063
    $dbh->do(qq{DROP TABLE IF EXISTS aqorders_transfers;});
7063
    $dbh->do(qq{
7064
    $dbh->do(qq{
7064
        ALTER TABLE aqorders
7065
        CREATE TABLE aqorders_transfers (
7065
        ADD COLUMN internalnotes MEDIUMTEXT DEFAULT NULL AFTER notes
7066
          ordernumber_from int(11) NULL,
7067
          ordernumber_to int(11) NULL,
7068
          timestamp timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP,
7069
          UNIQUE KEY ordernumber_from (ordernumber_from),
7070
          UNIQUE KEY ordernumber_to (ordernumber_to),
7071
          CONSTRAINT aqorders_transfers_ordernumber_from FOREIGN KEY (ordernumber_from) REFERENCES aqorders (ordernumber) ON DELETE SET NULL ON UPDATE CASCADE,
7072
          CONSTRAINT aqorders_transfers_ordernumber_to FOREIGN KEY (ordernumber_to) REFERENCES aqorders (ordernumber) ON DELETE SET NULL ON UPDATE CASCADE
7073
        ) ENGINE=InnoDB DEFAULT CHARSET=utf8;
7066
    });
7074
    });
7067
    print "Upgrade to $DBversion done (Add internalnotes field in aqorders table)\n";
7075
    print "Upgrade to $DBversion done (Add aqorders_transfers table)\n";
7068
    SetVersion($DBversion);
7076
    SetVersion($DBversion);
7069
}
7077
}
7070
7078
(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/acqui/basket.tt (-3 / +24 lines)
Lines 351-357 Link Here
351
                                [% ELSE %]
351
                                [% ELSE %]
352
                                    <p>[<a href="/cgi-bin/koha/acqui/modordernotes.pl?ordernumber=[% books_loo.ordernumber %]">Add note</a>]</p>
352
                                    <p>[<a href="/cgi-bin/koha/acqui/modordernotes.pl?ordernumber=[% books_loo.ordernumber %]">Add note</a>]</p>
353
                                [% END %]
353
                                [% END %]
354
                            <p>[% books_loo.internalnotes %]</p>
354
                            [% IF (books_loo.transferred_from) %]
355
                              [% basket = books_loo.transferred_from.basket %]
356
                              [% bookseller = books_loo.transferred_from.bookseller %]
357
                              [% timestamp = books_loo.transferred_from.timestamp %]
358
                              <p>Transferred from
359
                                <a href="/cgi-bin/koha/acqui/basket.pl?basketno=[% basket.basketno %]">basket: [% basket.basketname %]</a>
360
                                (<a href="/cgi-bin/koha/acqui/supplier.pl?booksellerid=[% bookseller.id %]">[% bookseller.name %]</a>)
361
                                on <span title="[% timestamp | $KohaDates with_hours = 1 %]">
362
                                  [% timestamp | $KohaDates %]
363
                                </span>
364
                              </p>
365
                            [% END %]
355
                        </td>
366
                        </td>
356
                        <td class="number gste [% IF books_loo.rrpgste.search('^0') %]error[% END %]">[% books_loo.rrpgste %]</td>
367
                        <td class="number gste [% IF books_loo.rrpgste.search('^0') %]error[% END %]">[% books_loo.rrpgste %]</td>
357
                        <td class="number gste [% IF books_loo.ecostgste.search('^0') %]error[% END %]">[% books_loo.ecostgste %]</td>
368
                        <td class="number gste [% IF books_loo.ecostgste.search('^0') %]error[% END %]">[% books_loo.ecostgste %]</td>
Lines 443-449 Link Here
443
                        [% IF ( order.publicationyear ) %], [% order.publicationyear %][% END %]
454
                        [% IF ( order.publicationyear ) %], [% order.publicationyear %][% END %]
444
                        [% IF ( books_loo.editionstatement ) %], [% books_loo.editionstatement %][% END %]
455
                        [% IF ( books_loo.editionstatement ) %], [% books_loo.editionstatement %][% END %]
445
                      </p>
456
                      </p>
446
                      <p>[% order.internalnotes %]</p>
457
                      [% IF order.transferred_to %]
458
                        [% basket = order.transferred_to.basket %]
459
                        [% bookseller = order.transferred_to.bookseller %]
460
                        [% timestamp = order.transferred_to.timestamp %]
461
                        <p>Transferred to
462
                          <a href="/cgi-bin/koha/acqui/basket.pl?basketno=[% basket.basketno %]">basket: [% basket.basketname %]</a>
463
                          (<a href="/cgi-bin/koha/acqui/supplier.pl?booksellerid=[% bookseller.id %]">[% bookseller.name %]</a>)
464
                          on <span title="[% timestamp | $KohaDates with_hours = 1%]">
465
                            [% timestamp | $KohaDates %]
466
                          </span>
467
                        </p>
468
                      [% END %]
447
                    </td>
469
                    </td>
448
                    <td class="number gste">[% order.rrpgste %]</td>
470
                    <td class="number gste">[% order.rrpgste %]</td>
449
                    <td class="number gste">[% order.ecostgste %]</td>
471
                    <td class="number gste">[% order.ecostgste %]</td>
450
- 

Return to bug 5349