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 1352-1362 sub GetCancelledOrders { Link Here
1352
1355
1353
    my $dbh   = C4::Context->dbh;
1356
    my $dbh   = C4::Context->dbh;
1354
    my $query = "
1357
    my $query = "
1355
        SELECT biblio.*, biblioitems.*, aqorders.*, aqbudgets.*
1358
        SELECT
1359
            biblio.*,
1360
            biblioitems.*,
1361
            aqorders.*,
1362
            aqbudgets.*,
1363
            aqorders_transfers.ordernumber_to AS transferred_to,
1364
            aqorders_transfers.timestamp AS tranferred_to_timestamp
1356
        FROM aqorders
1365
        FROM aqorders
1357
          LEFT JOIN aqbudgets   ON aqbudgets.budget_id = aqorders.budget_id
1366
          LEFT JOIN aqbudgets   ON aqbudgets.budget_id = aqorders.budget_id
1358
          LEFT JOIN biblio      ON biblio.biblionumber = aqorders.biblionumber
1367
          LEFT JOIN biblio      ON biblio.biblionumber = aqorders.biblionumber
1359
          LEFT JOIN biblioitems ON biblioitems.biblionumber = biblio.biblionumber
1368
          LEFT JOIN biblioitems ON biblioitems.biblionumber = biblio.biblionumber
1369
          LEFT JOIN aqorders_transfers ON aqorders_transfers.ordernumber_from = aqorders.ordernumber
1360
        WHERE basketno = ?
1370
        WHERE basketno = ?
1361
          AND (datecancellationprinted IS NOT NULL
1371
          AND (datecancellationprinted IS NOT NULL
1362
               AND datecancellationprinted <> '0000-00-00')
1372
               AND datecancellationprinted <> '0000-00-00')
Lines 1704-1745 sub TransferOrder { Link Here
1704
1714
1705
    my $order = GetOrder( $ordernumber );
1715
    my $order = GetOrder( $ordernumber );
1706
    return if $order->{datereceived};
1716
    return if $order->{datereceived};
1717
    my $basket = GetBasket($basketno);
1718
    return unless $basket;
1707
1719
1708
    my $today = C4::Dates->new()->output("iso");
1709
    my $query = qq{
1710
        SELECT aqbooksellers.name
1711
        FROM aqorders
1712
            LEFT JOIN aqbasket ON aqorders.basketno = aqbasket.basketno
1713
            LEFT JOIN aqbooksellers ON aqbasket.booksellerid = aqbooksellers.id
1714
        WHERE aqorders.ordernumber = ?
1715
    };
1716
    my $dbh = C4::Context->dbh;
1720
    my $dbh = C4::Context->dbh;
1717
    my $sth = $dbh->prepare($query);
1721
    my ($query, $sth, $rv);
1718
    $sth->execute($ordernumber);
1719
    my ($booksellerfromname) = $sth->fetchrow_array;
1720
1721
    $query = qq{
1722
        SELECT aqbooksellers.name
1723
        FROM aqbasket
1724
            LEFT JOIN aqbooksellers ON aqbasket.booksellerid = aqbooksellers.id
1725
        WHERE aqbasket.basketno = ?
1726
    };
1727
    $sth = $dbh->prepare($query);
1728
    $sth->execute($basketno);
1729
    my ($booksellertoname) = $sth->fetchrow_array;
1730
1722
1731
    $query = qq{
1723
    $query = qq{
1732
        UPDATE aqorders
1724
        UPDATE aqorders
1733
        SET datecancellationprinted = CAST(NOW() AS date),
1725
        SET datecancellationprinted = CAST(NOW() AS date)
1734
            internalnotes = ?
1735
        WHERE ordernumber = ?
1726
        WHERE ordernumber = ?
1736
    };
1727
    };
1737
    $sth = $dbh->prepare($query);
1728
    $sth = $dbh->prepare($query);
1738
    $sth->execute("Cancelled and transfered to $booksellertoname on $today", $ordernumber);
1729
    $rv = $sth->execute($ordernumber);
1739
1730
1740
    delete $order->{'ordernumber'};
1731
    delete $order->{'ordernumber'};
1741
    $order->{'basketno'} = $basketno;
1732
    $order->{'basketno'} = $basketno;
1742
    $order->{'internalnotes'} = "Transfered from $booksellerfromname on $today";
1743
    my $newordernumber;
1733
    my $newordernumber;
1744
    (undef, $newordernumber) = NewOrder($order);
1734
    (undef, $newordernumber) = NewOrder($order);
1745
1735
Lines 1751-1756 sub TransferOrder { Link Here
1751
    $sth = $dbh->prepare($query);
1741
    $sth = $dbh->prepare($query);
1752
    $sth->execute($newordernumber, $ordernumber);
1742
    $sth->execute($newordernumber, $ordernumber);
1753
1743
1744
    $query = q{
1745
        INSERT INTO aqorders_transfers (ordernumber_from, ordernumber_to)
1746
        VALUES (?, ?)
1747
    };
1748
    $sth = $dbh->prepare($query);
1749
    $sth->execute($ordernumber, $newordernumber);
1750
1754
    return $newordernumber;
1751
    return $newordernumber;
1755
}
1752
}
1756
1753
(-)a/acqui/basket.pl (-6 / +15 lines)
Lines 308-318 if ( $op eq 'delete_confirm' ) { Link Here
308
        last;
308
        last;
309
    }
309
    }
310
310
311
    my @cancelledorders = GetCancelledOrders($basketno);
312
    foreach (@cancelledorders) {
313
        $_->{'line_total'} = sprintf("%.2f", $_->{'ecost'} * $_->{'quantity'});
314
    }
315
316
    $template->param(
311
    $template->param(
317
        basketno             => $basketno,
312
        basketno             => $basketno,
318
        basketname           => $basket->{'basketname'},
313
        basketname           => $basket->{'basketname'},
Lines 332-338 if ( $op eq 'delete_confirm' ) { Link Here
332
        name                 => $bookseller->{'name'},
327
        name                 => $bookseller->{'name'},
333
        books_loop           => \@books_loop,
328
        books_loop           => \@books_loop,
334
        book_foot_loop       => \@book_foot_loop,
329
        book_foot_loop       => \@book_foot_loop,
335
        cancelledorders_loop => \@cancelledorders,
330
        cancelledorders_loop => \@cancelledorders_loop,
336
        total_quantity       => $total_quantity,
331
        total_quantity       => $total_quantity,
337
        total_gste           => sprintf( "%.2f", $total_gste ),
332
        total_gste           => sprintf( "%.2f", $total_gste ),
338
        total_gsti           => sprintf( "%.2f", $total_gsti ),
333
        total_gsti           => sprintf( "%.2f", $total_gsti ),
Lines 428-433 sub get_order_infos { Link Here
428
    $line{surnamesuggestedby}   = $$suggestion{surnamesuggestedby};
423
    $line{surnamesuggestedby}   = $$suggestion{surnamesuggestedby};
429
    $line{firstnamesuggestedby} = $$suggestion{firstnamesuggestedby};
424
    $line{firstnamesuggestedby} = $$suggestion{firstnamesuggestedby};
430
425
426
    foreach my $key (qw(transferred_from transferred_to)) {
427
        if ($line{$key}) {
428
            my $order = GetOrder($line{$key});
429
            my $basket = GetBasket($order->{basketno});
430
            my $bookseller = GetBookSellerFromId($basket->{booksellerid});
431
            $line{$key} = {
432
                order => $order,
433
                basket => $basket,
434
                bookseller => $bookseller,
435
                timestamp => $line{$key . '_timestamp'},
436
            };
437
        }
438
    }
439
431
    return \%line;
440
    return \%line;
432
}
441
}
433
442
(-)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 2960-2965 CREATE TABLE `aqorders_items` ( -- information on items entered in the acquisiti Link Here
2960
2959
2961
2960
2962
--
2961
--
2962
-- Table structure for table aqorders_transfers
2963
--
2964
2965
DROP TABLE IF EXISTS aqorders_transfers;
2966
CREATE TABLE aqorders_transfers (
2967
  ordernumber_from int(11) NULL,
2968
  ordernumber_to int(11) NULL,
2969
  timestamp timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP,
2970
  UNIQUE KEY ordernumber_from (ordernumber_from),
2971
  UNIQUE KEY ordernumber_to (ordernumber_to),
2972
  CONSTRAINT aqorders_transfers_ordernumber_from FOREIGN KEY (ordernumber_from) REFERENCES aqorders (ordernumber) ON DELETE SET NULL ON UPDATE CASCADE,
2973
  CONSTRAINT aqorders_transfers_ordernumber_to FOREIGN KEY (ordernumber_to) REFERENCES aqorders (ordernumber) ON DELETE SET NULL ON UPDATE CASCADE
2974
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
2975
2976
--
2963
-- Table structure for table aqinvoices
2977
-- Table structure for table aqinvoices
2964
--
2978
--
2965
2979
(-)a/installer/data/mysql/updatedatabase.pl (-3 / +11 lines)
Lines 7012-7022 CREATE TABLE IF NOT EXISTS borrower_files ( Link Here
7012
7012
7013
$DBversion = "XXX";
7013
$DBversion = "XXX";
7014
if ( C4::Context->preference("Version") < TransformToNum($DBversion) ) {
7014
if ( C4::Context->preference("Version") < TransformToNum($DBversion) ) {
7015
    $dbh->do(qq{DROP TABLE IF EXISTS aqorders_transfers;});
7015
    $dbh->do(qq{
7016
    $dbh->do(qq{
7016
        ALTER TABLE aqorders
7017
        CREATE TABLE aqorders_transfers (
7017
        ADD COLUMN internalnotes MEDIUMTEXT DEFAULT NULL AFTER notes
7018
          ordernumber_from int(11) NULL,
7019
          ordernumber_to int(11) NULL,
7020
          timestamp timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP,
7021
          UNIQUE KEY ordernumber_from (ordernumber_from),
7022
          UNIQUE KEY ordernumber_to (ordernumber_to),
7023
          CONSTRAINT aqorders_transfers_ordernumber_from FOREIGN KEY (ordernumber_from) REFERENCES aqorders (ordernumber) ON DELETE SET NULL ON UPDATE CASCADE,
7024
          CONSTRAINT aqorders_transfers_ordernumber_to FOREIGN KEY (ordernumber_to) REFERENCES aqorders (ordernumber) ON DELETE SET NULL ON UPDATE CASCADE
7025
        ) ENGINE=InnoDB DEFAULT CHARSET=utf8;
7018
    });
7026
    });
7019
    print "Upgrade to $DBversion done (Add internalnotes field in aqorders table)\n";
7027
    print "Upgrade to $DBversion done (Add aqorders_transfers table)\n";
7020
    SetVersion($DBversion);
7028
    SetVersion($DBversion);
7021
}
7029
}
7022
7030
(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/acqui/basket.tt (-3 / +28 lines)
Lines 343-349 Link Here
343
                                [% ELSE %]
343
                                [% ELSE %]
344
                                    <p>[<a href="/cgi-bin/koha/acqui/modordernotes.pl?ordernumber=[% books_loo.ordernumber %]">Add note</a>]</p>
344
                                    <p>[<a href="/cgi-bin/koha/acqui/modordernotes.pl?ordernumber=[% books_loo.ordernumber %]">Add note</a>]</p>
345
                                [% END %]
345
                                [% END %]
346
                            <p>[% books_loo.internalnotes %]</p>
346
                            [% IF (books_loo.transferred_from) %]
347
                              [% USE date %]
348
                              [% USE KohaDates %]
349
                              [% basket = books_loo.transferred_from.basket %]
350
                              [% bookseller = books_loo.transferred_from.bookseller %]
351
                              [% timestamp = books_loo.transferred_from.timestamp %]
352
                              <p>Transferred from
353
                                <a href="/cgi-bin/koha/acqui/basket.pl?basketno=[% basket.basketno %]">basket: [% basket.basketname %]</a>
354
                                (<a href="/cgi-bin/koha/acqui/supplier.pl?booksellerid=[% bookseller.id %]">[% bookseller.name %]</a>)
355
                                on <span title="[% date.format(timestamp, '%F') | $KohaDates %] [% date.format(timestamp, '%X') %]">
356
                                  [% date.format(timestamp, '%F') | $KohaDates %]
357
                                </span>
358
                              </p>
359
                            [% END %]
347
                        </td>
360
                        </td>
348
                        <td class="number gste [% IF books_loo.rrpgste.search('^0') %]error[% END %]">[% books_loo.rrpgste %]</td>
361
                        <td class="number gste [% IF books_loo.rrpgste.search('^0') %]error[% END %]">[% books_loo.rrpgste %]</td>
349
                        <td class="number gste [% IF books_loo.ecostgste.search('^0') %]error[% END %]">[% books_loo.ecostgste %]</td>
362
                        <td class="number gste [% IF books_loo.ecostgste.search('^0') %]error[% END %]">[% books_loo.ecostgste %]</td>
Lines 435-441 Link Here
435
                        [% IF ( order.publicationyear ) %], [% order.publicationyear %][% END %]
448
                        [% IF ( order.publicationyear ) %], [% order.publicationyear %][% END %]
436
                        [% IF ( books_loo.editionstatement ) %], [% books_loo.editionstatement %][% END %]
449
                        [% IF ( books_loo.editionstatement ) %], [% books_loo.editionstatement %][% END %]
437
                      </p>
450
                      </p>
438
                      <p>[% order.internalnotes %]</p>
451
                      [% IF order.transferred_to %]
452
                        [% USE date %]
453
                        [% USE KohaDates %]
454
                        [% basket = order.transferred_to.basket %]
455
                        [% bookseller = order.transferred_to.bookseller %]
456
                        [% timestamp = order.transferred_to.timestamp %]
457
                        <p>Transferred to
458
                          <a href="/cgi-bin/koha/acqui/basket.pl?basketno=[% basket.basketno %]">basket: [% basket.basketname %]</a>
459
                          (<a href="/cgi-bin/koha/acqui/supplier.pl?booksellerid=[% bookseller.id %]">[% bookseller.name %]</a>)
460
                          on <span title="[% date.format(timestamp, '%F') | $KohaDates %] [% date.format(timestamp, '%X') %]">
461
                            [% date.format(timestamp, '%F') | $KohaDates %]
462
                          </span>
463
                        </p>
464
                      [% END %]
439
                    </td>
465
                    </td>
440
                    <td class="number gste">[% order.rrpgste %]</td>
466
                    <td class="number gste">[% order.rrpgste %]</td>
441
                    <td class="number gste">[% order.ecostgste %]</td>
467
                    <td class="number gste">[% order.ecostgste %]</td>
442
- 

Return to bug 5349