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

(-)a/acqui/basket.pl (-1 / +2 lines)
Lines 501-512 sub get_order_infos { Link Here
501
        $line{order_object}         = $order;
501
        $line{order_object}         = $order;
502
    }
502
    }
503
503
504
505
    my $suggestion   = GetSuggestionInfoFromBiblionumber($line{biblionumber});
504
    my $suggestion   = GetSuggestionInfoFromBiblionumber($line{biblionumber});
506
    $line{suggestionid}         = $$suggestion{suggestionid};
505
    $line{suggestionid}         = $$suggestion{suggestionid};
507
    $line{surnamesuggestedby}   = $$suggestion{surnamesuggestedby};
506
    $line{surnamesuggestedby}   = $$suggestion{surnamesuggestedby};
508
    $line{firstnamesuggestedby} = $$suggestion{firstnamesuggestedby};
507
    $line{firstnamesuggestedby} = $$suggestion{firstnamesuggestedby};
509
508
509
    $line{estimated_delivery_date} = $order->{estimated_delivery_date} || '2020-12-12';
510
510
    foreach my $key (qw(transferred_from transferred_to)) {
511
    foreach my $key (qw(transferred_from transferred_to)) {
511
        if ($line{$key}) {
512
        if ($line{$key}) {
512
            my $order = GetOrder($line{$key});
513
            my $order = GetOrder($line{$key});
(-)a/installer/data/mysql/atomicupdate/bug_15348-add_aqorders.estimated_delivery_date.perl (+29 lines)
Line 0 Link Here
1
use Date::Calc qw( Add_Delta_Days );
2
$DBversion = 'XXX';
3
if( CheckVersion( $DBversion ) ) {
4
    unless( column_exists( 'aqorders', 'estimated_delivery_date' ) ) {
5
        $dbh->do(q{ ALTER TABLE aqorders ADD estimated_delivery_date date default null AFTER suppliers_report });
6
        my $orders = $dbh->selectall_arrayref("SELECT ordernumber, orderstatus, basketno FROM aqorders", { Slice => {} });
7
        foreach my $order ( @$orders ) {
8
            my $bookseller = $dbh->selectrow_hashref("SELECT deliverytime FROM aqbooksellers WHERE id =
9
                (SELECT booksellerid FROM aqbasket WHERE basketno =
10
                    (SELECT basketno FROM aqorders WHERE ordernumber = $order->{ordernumber})
11
                )
12
            ");
13
            my $deliverytime = $bookseller->{deliverytime} || 0;
14
            if ( $order->{orderstatus} eq 'ordered' or $order->{orderstatus} eq 'complete' ) {
15
                # the basket has been closed and will have a closedate
16
                my $basket = $dbh->selectrow_hashref("SELECT closedate FROM aqbasket WHERE basketno = $order->{basketno}");
17
                my ($year, $month, $day) = ( $basket->{closedate} =~ /(\d+)-(\d+)-(\d+)/ );
18
                ($year, $month, $day) = Add_Delta_Days($year, $month, $day, $deliverytime);
19
                my $estimated_delivery_date = sprintf( "%04d-%02d-%02d", $year, $month, $day );
20
                $dbh->do(qq{ UPDATE aqorders SET estimated_delivery_date = $estimated_delivery_date WHERE ordernumber = $order->{ordernumber} });
21
            } else {
22
                # we have no closedate to use in calculation, so use today's date
23
                $dbh->do(qq{ UPDATE aqorders SET estimated_delivery_date = DATE_ADD(NOW(), INTERVAL $deliverytime DAYS) WHERE ordernumber = $order->{ordernumber} });
24
            }
25
        }
26
27
        NewVersion( $DBversion, 15348, "Add new column aqorders.estimated_delivery_date and pre-fill with calculated dates" );
28
    }
29
}
(-)a/installer/data/mysql/kohastructure.sql (+1 lines)
Lines 3319-3324 CREATE TABLE `aqorders` ( -- information related to the basket line items Link Here
3319
  suppliers_reference_number varchar(35) default NULL, -- Suppliers unique edifact quote ref
3319
  suppliers_reference_number varchar(35) default NULL, -- Suppliers unique edifact quote ref
3320
  suppliers_reference_qualifier varchar(3) default NULL, -- Type of number above usually 'QLI'
3320
  suppliers_reference_qualifier varchar(3) default NULL, -- Type of number above usually 'QLI'
3321
  `suppliers_report` MEDIUMTEXT COLLATE utf8mb4_unicode_ci, -- reports received from suppliers
3321
  `suppliers_report` MEDIUMTEXT COLLATE utf8mb4_unicode_ci, -- reports received from suppliers
3322
  `estimated_delivery_date` date default null,
3322
  PRIMARY KEY  (`ordernumber`),
3323
  PRIMARY KEY  (`ordernumber`),
3323
  KEY `basketno` (`basketno`),
3324
  KEY `basketno` (`basketno`),
3324
  KEY `biblionumber` (`biblionumber`),
3325
  KEY `biblionumber` (`biblionumber`),
(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/acqui/basket.tt (-1 / +4 lines)
Lines 412-417 Link Here
412
                        <th>GST</th>
412
                        <th>GST</th>
413
                        <th>Fund</th>
413
                        <th>Fund</th>
414
                        <th>Supplier report</th>
414
                        <th>Supplier report</th>
415
                        <th>Estimated delivery date</th>
415
                        [% IF ( active ) %]
416
                        [% IF ( active ) %]
416
                            [% UNLESS ( closedate ) %]
417
                            [% UNLESS ( closedate ) %]
417
                                <th class="NoSort">Modify</th>
418
                                <th class="NoSort">Modify</th>
Lines 439-444 Link Here
439
                        <th>[% foot_loo.tax_value | $Price %]</th>
440
                        <th>[% foot_loo.tax_value | $Price %]</th>
440
                        <th>&nbsp;</th>
441
                        <th>&nbsp;</th>
441
                        <th>&nbsp;</th>
442
                        <th>&nbsp;</th>
443
                        <th>[% foot_loo.estimated_delivery_date | $KohaDates | html %]</th>
442
                        [% IF ( active ) %]
444
                        [% IF ( active ) %]
443
                            [% UNLESS ( closedate ) %]
445
                            [% UNLESS ( closedate ) %]
444
                                <th>&nbsp;</th>
446
                                <th>&nbsp;</th>
Lines 464-469 Link Here
464
                    <th>[% total_tax_value | $Price %]</th>
466
                    <th>[% total_tax_value | $Price %]</th>
465
                    <th>&nbsp;</th>
467
                    <th>&nbsp;</th>
466
                    <th>&nbsp;</th>
468
                    <th>&nbsp;</th>
469
                    <th>[% estimated_delivery_date | $KohaDates | html %]</th>
467
                    [% IF ( active ) %]
470
                    [% IF ( active ) %]
468
                        [% UNLESS ( closedate ) %]
471
                        [% UNLESS ( closedate ) %]
469
                            <th>&nbsp;</th>
472
                            <th>&nbsp;</th>
Lines 548-553 Link Here
548
                        <td class="number [% IF books_loo.tax_value.search(zero_regex) %]error[% END %]">[% books_loo.tax_value | $Price %]</td>
551
                        <td class="number [% IF books_loo.tax_value.search(zero_regex) %]error[% END %]">[% books_loo.tax_value | $Price %]</td>
549
                        <td>[% books_loo.budget_name | html %]</td>
552
                        <td>[% books_loo.budget_name | html %]</td>
550
                        <td>[% books_loo.suppliers_report | html %]</td>
553
                        <td>[% books_loo.suppliers_report | html %]</td>
554
                        <td>[% books_loo.estimated_delivery_date | $KohaDates | html %]</td>
551
                        [% IF ( active ) %]
555
                        [% IF ( active ) %]
552
                            [% UNLESS ( closedate ) %]
556
                            [% UNLESS ( closedate ) %]
553
                            <td>
557
                            <td>
554
- 

Return to bug 15348