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

(-)a/C4/Acquisition.pm (-5 / +8 lines)
Lines 2039-2049 sub GetLateOrders { Link Here
2039
    #BEWARE, order of parenthesis and LEFT JOIN is important for speed
2039
    #BEWARE, order of parenthesis and LEFT JOIN is important for speed
2040
    my $dbdriver = C4::Context->config("db_scheme") || "mysql";
2040
    my $dbdriver = C4::Context->config("db_scheme") || "mysql";
2041
2041
2042
    my $lateOrderSort = C4::Context->preference("AcqLateOrderUseCreationDate");
2043
    my $aqbasketSortField = ( $lateOrderSort eq 'creation' ? 'creationdate' : 'closedate' );
2044
2042
    my @query_params = ();
2045
    my @query_params = ();
2043
    my $select = "
2046
    my $select = "
2044
    SELECT aqbasket.basketno,
2047
    SELECT aqbasket.basketno,
2045
        aqorders.ordernumber,
2048
        aqorders.ordernumber,
2046
        DATE(aqbasket.closedate)  AS orderdate,
2049
        DATE(aqbasket.${aqbasketSortField})  AS orderdate,
2047
        aqbasket.basketname       AS basketname,
2050
        aqbasket.basketname       AS basketname,
2048
        aqbasket.basketgroupid    AS basketgroupid,
2051
        aqbasket.basketgroupid    AS basketgroupid,
2049
        aqbasketgroups.name       AS basketgroupname,
2052
        aqbasketgroups.name       AS basketgroupname,
Lines 2081-2090 sub GetLateOrders { Link Here
2081
        $select .= "
2084
        $select .= "
2082
        aqorders.quantity - COALESCE(aqorders.quantityreceived,0)                 AS quantity,
2085
        aqorders.quantity - COALESCE(aqorders.quantityreceived,0)                 AS quantity,
2083
        (aqorders.quantity - COALESCE(aqorders.quantityreceived,0)) * aqorders.rrp AS subtotal,
2086
        (aqorders.quantity - COALESCE(aqorders.quantityreceived,0)) * aqorders.rrp AS subtotal,
2084
        DATEDIFF(CAST(now() AS date),closedate) AS latesince
2087
        DATEDIFF(CAST(now() AS date),${aqbasketSortField}) AS latesince
2085
        ";
2088
        ";
2086
        if ( defined $delay ) {
2089
        if ( defined $delay ) {
2087
            $from .= " AND (closedate <= DATE_SUB(CAST(now() AS date),INTERVAL ? DAY)) " ;
2090
            $from .= " AND (${aqbasketSortField} <= DATE_SUB(CAST(now() AS date),INTERVAL ? DAY)) " ;
2088
            push @query_params, $delay;
2091
            push @query_params, $delay;
2089
        }
2092
        }
2090
        $having = "
2093
        $having = "
Lines 2097-2106 sub GetLateOrders { Link Here
2097
        $select .= "
2100
        $select .= "
2098
                aqorders.quantity                AS quantity,
2101
                aqorders.quantity                AS quantity,
2099
                aqorders.quantity * aqorders.rrp AS subtotal,
2102
                aqorders.quantity * aqorders.rrp AS subtotal,
2100
                (CAST(now() AS date) - closedate)            AS latesince
2103
                (CAST(now() AS date) - ${aqbasketSortField})            AS latesince
2101
        ";
2104
        ";
2102
        if ( defined $delay ) {
2105
        if ( defined $delay ) {
2103
            $from .= " AND (closedate <= (CAST(now() AS date) -(INTERVAL ? DAY)) ";
2106
            $from .= " AND (${aqbasketSortField} <= (CAST(now() AS date) -(INTERVAL ? DAY)) ";
2104
            push @query_params, $delay;
2107
            push @query_params, $delay;
2105
        }
2108
        }
2106
    }
2109
    }
(-)a/acqui/lateorders.pl (+1 lines)
Lines 173-177 $template->param( Link Here
173
    estimateddeliverydateto   => $estimateddeliverydateto,
173
    estimateddeliverydateto   => $estimateddeliverydateto,
174
	total => $total,
174
	total => $total,
175
	intranetcolorstylesheet => C4::Context->preference("intranetcolorstylesheet"),
175
	intranetcolorstylesheet => C4::Context->preference("intranetcolorstylesheet"),
176
    lateOrderSort => C4::Context->preference("AcqLateOrderUseCreationDate"),
176
);
177
);
177
output_html_with_http_headers $input, $cookie, $template->output;
178
output_html_with_http_headers $input, $cookie, $template->output;
(-)a/installer/data/mysql/sysprefs.sql (+1 lines)
Lines 3-8 INSERT INTO systempreferences ( `variable`, `value`, `options`, `explanation`, ` Link Here
3
('AcqEnableFiles','0',NULL,'If enabled, allows librarians to upload and attach arbitrary files to invoice records.','YesNo'),
3
('AcqEnableFiles','0',NULL,'If enabled, allows librarians to upload and attach arbitrary files to invoice records.','YesNo'),
4
('AcqItemSetSubfieldsWhenReceiptIsCancelled','', '','Upon cancelling a receipt, update the items subfields if they were created when placing an order (e.g. o=5|a="bar foo")', 'Free'),
4
('AcqItemSetSubfieldsWhenReceiptIsCancelled','', '','Upon cancelling a receipt, update the items subfields if they were created when placing an order (e.g. o=5|a="bar foo")', 'Free'),
5
('AcqItemSetSubfieldsWhenReceived','','','Upon receiving items, update their subfields if they were created when placing an order (e.g. o=5|a="foo bar")','Free'),
5
('AcqItemSetSubfieldsWhenReceived','','','Upon receiving items, update their subfields if they were created when placing an order (e.g. o=5|a="foo bar")','Free'),
6
('AcqLateOrderUseCreationDate',  'closing',  'creation|closing',  'Change late order default sort.',  'Choice');
6
('AcquisitionDetails', '1', '', 'Hide/Show acquisition details on the biblio detail page.', 'YesNo'),
7
('AcquisitionDetails', '1', '', 'Hide/Show acquisition details on the biblio detail page.', 'YesNo'),
7
('AcqViewBaskets','user','user|branch|all','Define which baskets a user is allowed to view: his own only, any within his branch or all','Choice'),
8
('AcqViewBaskets','user','user|branch|all','Define which baskets a user is allowed to view: his own only, any within his branch or all','Choice'),
8
('AcqWarnOnDuplicateInvoice','0','','Warn librarians when they try to create a duplicate invoice','YesNo'),
9
('AcqWarnOnDuplicateInvoice','0','','Warn librarians when they try to create a duplicate invoice','YesNo'),
(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/acqui/lateorders.tt (-1 / +1 lines)
Lines 116-122 $(document).ready(function() { Link Here
116
            [% ELSE %]
116
            [% ELSE %]
117
                <th></th>
117
                <th></th>
118
            [% END %]
118
            [% END %]
119
            <th class="title-string">Order date</th>
119
            <th class="title-string">Order [% lateOrderSort %] date</th>
120
            <th class="title-string">Estimated delivery date</th>
120
            <th class="title-string">Estimated delivery date</th>
121
            <th>Vendor</th>
121
            <th>Vendor</th>
122
            <th class="anti-the">Information</th>
122
            <th class="anti-the">Information</th>
(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/preferences/acquisitions.pref (-1 / +6 lines)
Lines 20-25 Acquisitions: Link Here
20
                  1: always ask for confirmation.
20
                  1: always ask for confirmation.
21
                  2: do not ask for confirmation.
21
                  2: do not ask for confirmation.
22
        -
22
        -
23
            - pref: AcqLateOrderUseCreationDate
24
              choices:
25
                  creation: Do
26
                  closing: Don't
27
            - Use the creation date of the basket to sort late order.
28
        -
23
            - Show baskets
29
            - Show baskets
24
            - pref: AcqViewBaskets
30
            - pref: AcqViewBaskets
25
              choices:
31
              choices:
26
- 

Return to bug 12732