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 1617-1658 sub TransferOrder { Link Here
1617
1627
1618
    my $order = GetOrder( $ordernumber );
1628
    my $order = GetOrder( $ordernumber );
1619
    return if $order->{datereceived};
1629
    return if $order->{datereceived};
1630
    my $basket = GetBasket($basketno);
1631
    return unless $basket;
1620
1632
1621
    my $today = C4::Dates->new()->output("iso");
1622
    my $query = qq{
1623
        SELECT aqbooksellers.name
1624
        FROM aqorders
1625
            LEFT JOIN aqbasket ON aqorders.basketno = aqbasket.basketno
1626
            LEFT JOIN aqbooksellers ON aqbasket.booksellerid = aqbooksellers.id
1627
        WHERE aqorders.ordernumber = ?
1628
    };
1629
    my $dbh = C4::Context->dbh;
1633
    my $dbh = C4::Context->dbh;
1630
    my $sth = $dbh->prepare($query);
1634
    my ($query, $sth, $rv);
1631
    $sth->execute($ordernumber);
1632
    my ($booksellerfromname) = $sth->fetchrow_array;
1633
1634
    $query = qq{
1635
        SELECT aqbooksellers.name
1636
        FROM aqbasket
1637
            LEFT JOIN aqbooksellers ON aqbasket.booksellerid = aqbooksellers.id
1638
        WHERE aqbasket.basketno = ?
1639
    };
1640
    $sth = $dbh->prepare($query);
1641
    $sth->execute($basketno);
1642
    my ($booksellertoname) = $sth->fetchrow_array;
1643
1635
1644
    $query = qq{
1636
    $query = qq{
1645
        UPDATE aqorders
1637
        UPDATE aqorders
1646
        SET datecancellationprinted = CAST(NOW() AS date),
1638
        SET datecancellationprinted = CAST(NOW() AS date)
1647
            internalnotes = ?
1648
        WHERE ordernumber = ?
1639
        WHERE ordernumber = ?
1649
    };
1640
    };
1650
    $sth = $dbh->prepare($query);
1641
    $sth = $dbh->prepare($query);
1651
    $sth->execute("Cancelled and transfered to $booksellertoname on $today", $ordernumber);
1642
    $rv = $sth->execute($ordernumber);
1652
1643
1653
    delete $order->{'ordernumber'};
1644
    delete $order->{'ordernumber'};
1654
    $order->{'basketno'} = $basketno;
1645
    $order->{'basketno'} = $basketno;
1655
    $order->{'internalnotes'} = "Transfered from $booksellerfromname on $today";
1656
    my $newordernumber;
1646
    my $newordernumber;
1657
    (undef, $newordernumber) = NewOrder($order);
1647
    (undef, $newordernumber) = NewOrder($order);
1658
1648
Lines 1664-1669 sub TransferOrder { Link Here
1664
    $sth = $dbh->prepare($query);
1654
    $sth = $dbh->prepare($query);
1665
    $sth->execute($newordernumber, $ordernumber);
1655
    $sth->execute($newordernumber, $ordernumber);
1666
1656
1657
    $query = q{
1658
        INSERT INTO aqorders_transfers (ordernumber_from, ordernumber_to)
1659
        VALUES (?, ?)
1660
    };
1661
    $sth = $dbh->prepare($query);
1662
    $sth->execute($ordernumber, $newordernumber);
1663
1667
    return $newordernumber;
1664
    return $newordernumber;
1668
}
1665
}
1669
1666
(-)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 7069-7079 if ( CheckVersion($DBversion) ) { Link Here
7069
7069
7070
$DBversion = "XXX";
7070
$DBversion = "XXX";
7071
if ( C4::Context->preference("Version") < TransformToNum($DBversion) ) {
7071
if ( C4::Context->preference("Version") < TransformToNum($DBversion) ) {
7072
    $dbh->do(qq{DROP TABLE IF EXISTS aqorders_transfers;});
7072
    $dbh->do(qq{
7073
    $dbh->do(qq{
7073
        ALTER TABLE aqorders
7074
        CREATE TABLE aqorders_transfers (
7074
        ADD COLUMN internalnotes MEDIUMTEXT DEFAULT NULL AFTER notes
7075
          ordernumber_from int(11) NULL,
7076
          ordernumber_to int(11) NULL,
7077
          timestamp timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP,
7078
          UNIQUE KEY ordernumber_from (ordernumber_from),
7079
          UNIQUE KEY ordernumber_to (ordernumber_to),
7080
          CONSTRAINT aqorders_transfers_ordernumber_from FOREIGN KEY (ordernumber_from) REFERENCES aqorders (ordernumber) ON DELETE SET NULL ON UPDATE CASCADE,
7081
          CONSTRAINT aqorders_transfers_ordernumber_to FOREIGN KEY (ordernumber_to) REFERENCES aqorders (ordernumber) ON DELETE SET NULL ON UPDATE CASCADE
7082
        ) ENGINE=InnoDB DEFAULT CHARSET=utf8;
7075
    });
7083
    });
7076
    print "Upgrade to $DBversion done (Add internalnotes field in aqorders table)\n";
7084
    print "Upgrade to $DBversion done (Add aqorders_transfers table)\n";
7077
    SetVersion($DBversion);
7085
    SetVersion($DBversion);
7078
}
7086
}
7079
7087
(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/acqui/basket.tt (-3 / +24 lines)
Lines 357-363 Link Here
357
                                [% ELSE %]
357
                                [% ELSE %]
358
                                    <p>[<a href="/cgi-bin/koha/acqui/modordernotes.pl?ordernumber=[% books_loo.ordernumber %]">Add note</a>]</p>
358
                                    <p>[<a href="/cgi-bin/koha/acqui/modordernotes.pl?ordernumber=[% books_loo.ordernumber %]">Add note</a>]</p>
359
                                [% END %]
359
                                [% END %]
360
                            <p>[% books_loo.internalnotes %]</p>
360
                            [% IF (books_loo.transferred_from) %]
361
                              [% basket = books_loo.transferred_from.basket %]
362
                              [% bookseller = books_loo.transferred_from.bookseller %]
363
                              [% timestamp = books_loo.transferred_from.timestamp %]
364
                              <p>Transferred from
365
                                <a href="/cgi-bin/koha/acqui/basket.pl?basketno=[% basket.basketno %]">basket: [% basket.basketname %]</a>
366
                                (<a href="/cgi-bin/koha/acqui/supplier.pl?booksellerid=[% bookseller.id %]">[% bookseller.name %]</a>)
367
                                on <span title="[% timestamp | $KohaDates with_hours = 1 %]">
368
                                  [% timestamp | $KohaDates %]
369
                                </span>
370
                              </p>
371
                            [% END %]
361
                        </td>
372
                        </td>
362
                        <td class="number gste [% IF books_loo.rrpgste.search('^0') %]error[% END %]">[% books_loo.rrpgste %]</td>
373
                        <td class="number gste [% IF books_loo.rrpgste.search('^0') %]error[% END %]">[% books_loo.rrpgste %]</td>
363
                        <td class="number gste [% IF books_loo.ecostgste.search('^0') %]error[% END %]">[% books_loo.ecostgste %]</td>
374
                        <td class="number gste [% IF books_loo.ecostgste.search('^0') %]error[% END %]">[% books_loo.ecostgste %]</td>
Lines 449-455 Link Here
449
                        [% IF ( order.publicationyear ) %], [% order.publicationyear %][% END %]
460
                        [% IF ( order.publicationyear ) %], [% order.publicationyear %][% END %]
450
                        [% IF ( books_loo.editionstatement ) %], [% books_loo.editionstatement %][% END %]
461
                        [% IF ( books_loo.editionstatement ) %], [% books_loo.editionstatement %][% END %]
451
                      </p>
462
                      </p>
452
                      <p>[% order.internalnotes %]</p>
463
                      [% IF order.transferred_to %]
464
                        [% basket = order.transferred_to.basket %]
465
                        [% bookseller = order.transferred_to.bookseller %]
466
                        [% timestamp = order.transferred_to.timestamp %]
467
                        <p>Transferred to
468
                          <a href="/cgi-bin/koha/acqui/basket.pl?basketno=[% basket.basketno %]">basket: [% basket.basketname %]</a>
469
                          (<a href="/cgi-bin/koha/acqui/supplier.pl?booksellerid=[% bookseller.id %]">[% bookseller.name %]</a>)
470
                          on <span title="[% timestamp | $KohaDates with_hours = 1%]">
471
                            [% timestamp | $KohaDates %]
472
                          </span>
473
                        </p>
474
                      [% END %]
453
                    </td>
475
                    </td>
454
                    <td class="number gste">[% order.rrpgste %]</td>
476
                    <td class="number gste">[% order.rrpgste %]</td>
455
                    <td class="number gste">[% order.ecostgste %]</td>
477
                    <td class="number gste">[% order.ecostgste %]</td>
456
- 

Return to bug 5349