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

(-)a/C4/Acquisition.pm (-5 / +8 lines)
Lines 2117-2127 sub GetLateOrders { Link Here
2117
    #BEWARE, order of parenthesis and LEFT JOIN is important for speed
2117
    #BEWARE, order of parenthesis and LEFT JOIN is important for speed
2118
    my $dbdriver = C4::Context->config("db_scheme") || "mysql";
2118
    my $dbdriver = C4::Context->config("db_scheme") || "mysql";
2119
2119
2120
    my $lateOrderSort = C4::Context->preference("AcqLateOrderUseCreationDate");
2121
    my $aqbasketSortField = ( $lateOrderSort eq 'creation' ? 'creationdate' : 'closedate' );
2122
2120
    my @query_params = ();
2123
    my @query_params = ();
2121
    my $select = "
2124
    my $select = "
2122
    SELECT aqbasket.basketno,
2125
    SELECT aqbasket.basketno,
2123
        aqorders.ordernumber,
2126
        aqorders.ordernumber,
2124
        DATE(aqbasket.closedate)  AS orderdate,
2127
        DATE(aqbasket.${aqbasketSortField})  AS orderdate,
2125
        aqbasket.basketname       AS basketname,
2128
        aqbasket.basketname       AS basketname,
2126
        aqbasket.basketgroupid    AS basketgroupid,
2129
        aqbasket.basketgroupid    AS basketgroupid,
2127
        aqbasketgroups.name       AS basketgroupname,
2130
        aqbasketgroups.name       AS basketgroupname,
Lines 2159-2168 sub GetLateOrders { Link Here
2159
        $select .= "
2162
        $select .= "
2160
        aqorders.quantity - COALESCE(aqorders.quantityreceived,0)                 AS quantity,
2163
        aqorders.quantity - COALESCE(aqorders.quantityreceived,0)                 AS quantity,
2161
        (aqorders.quantity - COALESCE(aqorders.quantityreceived,0)) * aqorders.rrp AS subtotal,
2164
        (aqorders.quantity - COALESCE(aqorders.quantityreceived,0)) * aqorders.rrp AS subtotal,
2162
        DATEDIFF(CAST(now() AS date),closedate) AS latesince
2165
        DATEDIFF(CAST(now() AS date),${aqbasketSortField}) AS latesince
2163
        ";
2166
        ";
2164
        if ( defined $delay ) {
2167
        if ( defined $delay ) {
2165
            $from .= " AND (closedate <= DATE_SUB(CAST(now() AS date),INTERVAL ? DAY)) " ;
2168
            $from .= " AND (${aqbasketSortField} <= DATE_SUB(CAST(now() AS date),INTERVAL ? DAY)) " ;
2166
            push @query_params, $delay;
2169
            push @query_params, $delay;
2167
        }
2170
        }
2168
        $having = "
2171
        $having = "
Lines 2175-2184 sub GetLateOrders { Link Here
2175
        $select .= "
2178
        $select .= "
2176
                aqorders.quantity                AS quantity,
2179
                aqorders.quantity                AS quantity,
2177
                aqorders.quantity * aqorders.rrp AS subtotal,
2180
                aqorders.quantity * aqorders.rrp AS subtotal,
2178
                (CAST(now() AS date) - closedate)            AS latesince
2181
                (CAST(now() AS date) - ${aqbasketSortField})            AS latesince
2179
        ";
2182
        ";
2180
        if ( defined $delay ) {
2183
        if ( defined $delay ) {
2181
            $from .= " AND (closedate <= (CAST(now() AS date) -(INTERVAL ? DAY)) ";
2184
            $from .= " AND (${aqbasketSortField} <= (CAST(now() AS date) -(INTERVAL ? DAY)) ";
2182
            push @query_params, $delay;
2185
            push @query_params, $delay;
2183
        }
2186
        }
2184
    }
2187
    }
(-)a/acqui/lateorders.pl (+1 lines)
Lines 172-176 $template->param( Link Here
172
    estimateddeliverydateto   => $estimateddeliverydateto,
172
    estimateddeliverydateto   => $estimateddeliverydateto,
173
	total => $total,
173
	total => $total,
174
	intranetcolorstylesheet => C4::Context->preference("intranetcolorstylesheet"),
174
	intranetcolorstylesheet => C4::Context->preference("intranetcolorstylesheet"),
175
    lateOrderSort => C4::Context->preference("AcqLateOrderUseCreationDate"),
175
);
176
);
176
output_html_with_http_headers $input, $cookie, $template->output;
177
output_html_with_http_headers $input, $cookie, $template->output;
(-)a/installer/data/mysql/sysprefs.sql (+1 lines)
Lines 2-7 INSERT INTO systempreferences ( `variable`, `value`, `options`, `explanation`, ` Link Here
2
('AcqCreateItem','ordering','ordering|receiving|cataloguing','Define when the item is created : when ordering, when receiving, or in cataloguing module','Choice'),
2
('AcqCreateItem','ordering','ordering|receiving|cataloguing','Define when the item is created : when ordering, when receiving, or in cataloguing module','Choice'),
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
('AcqItemSetSubfieldsWhenReceived','','','Upon receiving items, update their subfields if they were created when placing an order (e.g. o=5|a="foo bar")','Free'),
4
('AcqItemSetSubfieldsWhenReceived','','','Upon receiving items, update their subfields if they were created when placing an order (e.g. o=5|a="foo bar")','Free'),
5
('AcqLateOrderUseCreationDate',  'closing',  'creation|closing',  'Change late order default sort.',  'Choice');
5
('AcquisitionDetails', '1', '', 'Hide/Show acquisition details on the biblio detail page.', 'YesNo'),
6
('AcquisitionDetails', '1', '', 'Hide/Show acquisition details on the biblio detail page.', 'YesNo'),
6
('AcqViewBaskets','user','user|branch|all','Define which baskets a user is allowed to view: his own only, any within his branch or all','Choice'),
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'),
7
('AcqWarnOnDuplicateInvoice','0','','Warn librarians when they try to create a duplicate invoice','YesNo'),
8
('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 111-117 $(document).ready(function() { Link Here
111
            [% ELSE %]
111
            [% ELSE %]
112
                <th></th>
112
                <th></th>
113
            [% END %]
113
            [% END %]
114
            <th class="title-string">Order date</th>
114
            <th class="title-string">Order [% lateOrderSort %] date</th>
115
            <th class="title-string">Estimated delivery date</th>
115
            <th class="title-string">Estimated delivery date</th>
116
            <th>Vendor</th>
116
            <th>Vendor</th>
117
            <th class="anti-the">Information</th>
117
            <th class="anti-the">Information</th>
(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/preferences/acquisitions.pref (-1 / +7 lines)
Lines 57-62 Acquisitions: Link Here
57
              type: textarea
57
              type: textarea
58
            - "You can use the following fields: price, quantity, budget_code, discount, sort1, sort2"
58
            - "You can use the following fields: price, quantity, budget_code, discount, sort1, sort2"
59
            - "<br/>For example:<br/>price: 947$a|947$c<br/>quantity: 969$h<br/>budget_code: 922$a"
59
            - "<br/>For example:<br/>price: 947$a|947$c<br/>quantity: 969$h<br/>budget_code: 922$a"
60
        -
61
            - pref: AcqLateOrderUseCreationDate
62
              choices:
63
                  creation: Do
64
                  closing: Don't
65
            - Use the creation date of the basket to sort late order.
66
60
    Printing:
67
    Printing:
61
        -
68
        -
62
            - Use the
69
            - Use the
63
- 

Return to bug 12732