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

(-)a/acqui/finishreceive.pl (+5 lines)
Lines 33-38 use C4::Items; Link Here
33
use C4::Search;
33
use C4::Search;
34
34
35
use Koha::Acquisition::Bookseller;
35
use Koha::Acquisition::Bookseller;
36
use Koha::DateUtils;
36
37
37
use List::MoreUtils qw/any/;
38
use List::MoreUtils qw/any/;
38
39
Lines 61-66 my $bookfund = $input->param("bookfund"); Link Here
61
my $order            = GetOrder($ordernumber);
62
my $order            = GetOrder($ordernumber);
62
my $new_ordernumber  = $ordernumber;
63
my $new_ordernumber  = $ordernumber;
63
64
65
my $datereceived_dt = eval { dt_from_string( $datereceived) };
66
$datereceived_dt = dt_from_string unless ( $datereceived_dt );
67
$datereceived = output_pref( { dt => $datereceived_dt , dateonly => 1, dateformat => 'iso' } ) ;
68
64
#need old recievedate if we update the order, parcel.pl only shows the right parcel this way FIXME
69
#need old recievedate if we update the order, parcel.pl only shows the right parcel this way FIXME
65
if ($quantityrec > $origquantityrec ) {
70
if ($quantityrec > $origquantityrec ) {
66
    my @received_items = ();
71
    my @received_items = ();
(-)a/acqui/histsearch.pl (-14 / +14 lines)
Lines 55-64 use CGI qw ( -utf8 ); Link Here
55
use C4::Auth;    # get_template_and_user
55
use C4::Auth;    # get_template_and_user
56
use C4::Output;
56
use C4::Output;
57
use C4::Acquisition;
57
use C4::Acquisition;
58
use C4::Dates;
59
use C4::Debug;
58
use C4::Debug;
60
use C4::Branch;
59
use C4::Branch;
61
use C4::Koha;
60
use C4::Koha;
61
use Koha::DateUtils;
62
62
63
my $input = new CGI;
63
my $input = new CGI;
64
my $title                   = $input->param( 'title');
64
my $title                   = $input->param( 'title');
Lines 67-77 my $isbn = $input->param('isbn'); Link Here
67
my $name                    = $input->param( 'name' );
67
my $name                    = $input->param( 'name' );
68
my $ean                     = $input->param('ean');
68
my $ean                     = $input->param('ean');
69
my $basket                  = $input->param( 'basket' );
69
my $basket                  = $input->param( 'basket' );
70
my $basketgroupname             = $input->param('basketgroupname');
70
my $basketgroupname         = $input->param('basketgroupname');
71
my $booksellerinvoicenumber = $input->param( 'booksellerinvoicenumber' );
71
my $booksellerinvoicenumber = $input->param( 'booksellerinvoicenumber' );
72
my $do_search               = $input->param('do_search') || 0;
72
my $do_search               = $input->param('do_search') || 0;
73
my $from_placed_on          = C4::Dates->new($input->param('from'));
73
my $from_placed_on          = eval { dt_from_string( $input->param('from') ) } || dt_from_string;
74
my $to_placed_on            = C4::Dates->new($input->param('to'));
74
my $to_placed_on            = eval { dt_from_string( $input->param('to') ) } || dt_from_string;
75
my $budget                  = $input->param( 'budget' );
75
my $budget                  = $input->param( 'budget' );
76
my $orderstatus             = $input->param( 'orderstatus' );
76
my $orderstatus             = $input->param( 'orderstatus' );
77
my $ordernumber             = $input->param( 'ordernumber' );
77
my $ordernumber             = $input->param( 'ordernumber' );
Lines 79-87 my $search_children_too = $input->param( 'search_children_too' ); Link Here
79
my @created_by              = $input->param('created_by');
79
my @created_by              = $input->param('created_by');
80
80
81
if ( not $input->param('from') ) {
81
if ( not $input->param('from') ) {
82
    # FIXME Dirty but we can't sent a Date::Calc to C4::Dates ?
82
    # Subtract one year if param was not defined
83
    # We would use a function like Add_Delta_YM(-1, 0, 0);
83
    $from_placed_on->subtract(years => 1);
84
    $$from_placed_on{dmy_arrayref}[5] -= 1;
85
}
84
}
86
85
87
my $dbh = C4::Context->dbh;
86
my $dbh = C4::Context->dbh;
Lines 96-107 my ( $template, $loggedinuser, $cookie ) = get_template_and_user( Link Here
96
    }
95
    }
97
);
96
);
98
97
99
my ( $from_iso, $to_iso, $d );
98
my ( $from_iso, $to_iso );
100
if ( $d = $input->param('from') ) {
99
101
    $from_iso = C4::Dates->new($d)->output('iso');
100
if ( $input->param('from') ) {
101
    $from_iso = output_pref( { dt => $from_placed_on, dateformat => 'iso',  dateonly => 1 } );
102
}
102
}
103
if ( $d = $input->param('iso') ) {
103
if ( $input->param('to') ) {
104
    $to_iso = C4::Dates->new($d)->output('iso');
104
    $to_iso = output_pref( { dt => $to_placed_on, dateformat => 'iso',  dateonly => 1 } );
105
}
105
}
106
106
107
my $order_loop;
107
my $order_loop;
Lines 126-133 if ($do_search) { Link Here
126
    );
126
    );
127
}
127
}
128
128
129
my $from_date = $from_placed_on ? $from_placed_on->output('syspref') : undef;
129
my $from_date = output_pref( { dt => $from_placed_on, dateformat => 'iso',  dateonly => 1 } );
130
my $to_date = $to_placed_on ? $to_placed_on->output('syspref') : undef;
130
my $to_date = output_pref( { dt => $to_placed_on, dateformat => 'iso',  dateonly => 1 } );
131
131
132
my $budgetperiods = C4::Budgets::GetBudgetPeriods;
132
my $budgetperiods = C4::Budgets::GetBudgetPeriods;
133
my $bp_loop = $budgetperiods;
133
my $bp_loop = $budgetperiods;
(-)a/acqui/invoice.pl (-4 / +17 lines)
Lines 37-42 use C4::Budgets; Link Here
37
37
38
use Koha::Acquisition::Bookseller;
38
use Koha::Acquisition::Bookseller;
39
use Koha::Misc::Files;
39
use Koha::Misc::Files;
40
use Koha::DateUtils;
40
41
41
my $input = new CGI;
42
my $input = new CGI;
42
my ( $template, $loggedinuser, $cookie, $flags ) = get_template_and_user(
43
my ( $template, $loggedinuser, $cookie, $flags ) = get_template_and_user(
Lines 76-89 elsif ( $op && $op eq 'reopen' ) { Link Here
76
    }
77
    }
77
}
78
}
78
elsif ( $op && $op eq 'mod' ) {
79
elsif ( $op && $op eq 'mod' ) {
79
    my $shipmentdate       = $input->param('shipmentdate');
80
80
    my $billingdate        = $input->param('billingdate');
81
    my $shipmentcost       = $input->param('shipmentcost');
81
    my $shipmentcost       = $input->param('shipmentcost');
82
    my $shipment_budget_id = $input->param('shipment_budget_id');
82
    my $shipment_budget_id = $input->param('shipment_budget_id');
83
    my $shipmentdate       = '';
84
    my $billingdate        = '';
85
86
    if ( $input->param('shipmentdate') ) {
87
        $shipmentdate = eval { dt_from_string( $input->param('shipmentdate') ) };
88
        $shipmentdate = output_pref( { dt => $shipmentdate, dateformat => 'iso',  dateonly => 1 } ) if ( $shipmentdate );
89
    }
90
91
    if ( $input->param('billingdate') ) {
92
        $billingdate = eval { dt_from_string( $input->param('billingdate') ) };
93
        $billingdate = output_pref( { dt => $billingdate, dateformat => 'iso',  dateonly => 1 } ) if ( $billingdate );
94
    }
95
83
    ModInvoice(
96
    ModInvoice(
84
        invoiceid             => $invoiceid,
97
        invoiceid             => $invoiceid,
85
        shipmentdate          => C4::Dates->new($shipmentdate)->output("iso"),
98
        shipmentdate          => $shipmentdate,
86
        billingdate           => C4::Dates->new($billingdate)->output("iso"),
99
        billingdate           => $billingdate,
87
        shipmentcost          => $shipmentcost,
100
        shipmentcost          => $shipmentcost,
88
        shipmentcost_budgetid => $shipment_budget_id
101
        shipmentcost_budgetid => $shipment_budget_id
89
    );
102
    );
(-)a/acqui/invoices.pl (-20 / +47 lines)
Lines 36-41 use C4::Output; Link Here
36
use C4::Acquisition qw/GetInvoices/;
36
use C4::Acquisition qw/GetInvoices/;
37
use C4::Branch qw/GetBranches/;
37
use C4::Branch qw/GetBranches/;
38
use C4::Budgets;
38
use C4::Budgets;
39
use Koha::DateUtils;
39
40
40
my $input = CGI->new;
41
my $input = CGI->new;
41
my ( $template, $loggedinuser, $cookie, $flags ) = get_template_and_user(
42
my ( $template, $loggedinuser, $cookie, $flags ) = get_template_and_user(
Lines 64-74 my $branch = $input->param('branch'); Link Here
64
my $op               = $input->param('op');
65
my $op               = $input->param('op');
65
66
66
my $invoices = [];
67
my $invoices = [];
68
69
my $shipmentdatefrom_iso = '';
70
my $shipmentdateto_iso = '';
71
my $billingdatefrom_iso = '';
72
my $billingdateto_iso = '';
73
74
67
if ( $op and $op eq 'do_search' ) {
75
if ( $op and $op eq 'do_search' ) {
68
    my $shipmentdatefrom_iso = C4::Dates->new($shipmentdatefrom)->output('iso');
76
69
    my $shipmentdateto_iso   = C4::Dates->new($shipmentdateto)->output('iso');
77
    if ( $shipmentdatefrom ) {
70
    my $billingdatefrom_iso  = C4::Dates->new($billingdatefrom)->output('iso');
78
        $shipmentdatefrom_iso = eval { dt_from_string( $shipmentdatefrom ) };
71
    my $billingdateto_iso    = C4::Dates->new($billingdateto)->output('iso');
79
        $shipmentdatefrom_iso = output_pref( { dt => $shipmentdatefrom_iso, dateformat => 'iso',  dateonly => 1 } ) if ( $shipmentdatefrom_iso );
80
    }
81
82
    if ( $shipmentdateto ) {
83
        $shipmentdateto_iso = eval { dt_from_string( $shipmentdateto) };
84
        $shipmentdateto_iso = output_pref( { dt => $shipmentdateto_iso, dateformat => 'iso',  dateonly => 1 } ) if ( $shipmentdateto_iso );
85
    }
86
87
    if ( $billingdatefrom ) {
88
        $billingdatefrom_iso = eval { dt_from_string( $billingdatefrom) };
89
        $billingdatefrom_iso = output_pref( { dt => $billingdatefrom_iso, dateformat => 'iso',  dateonly => 1 } ) if ( $billingdatefrom_iso );
90
    }
91
92
    if ( $billingdateto ) {
93
        $billingdateto_iso = eval { dt_from_string( $billingdateto) };
94
        $billingdateto_iso = output_pref( { dt => $billingdateto_iso, dateformat => 'iso',  dateonly => 1 } ) if ( $billingdateto_iso );
95
    }
96
72
    @{$invoices} = GetInvoices(
97
    @{$invoices} = GetInvoices(
73
        invoicenumber    => $invoicenumber,
98
        invoicenumber    => $invoicenumber,
74
        supplierid       => $supplierid,
99
        supplierid       => $supplierid,
Lines 130-151 foreach my $budget (@$budgets) { Link Here
130
$template->{'VARS'}->{'budgets_loop'} = \@budgets_loop;
155
$template->{'VARS'}->{'budgets_loop'} = \@budgets_loop;
131
156
132
$template->param(
157
$template->param(
133
    do_search => ( $op and $op eq 'do_search' ) ? 1 : 0,
158
    do_search        => ( $op and $op eq 'do_search' ) ? 1 : 0,
134
    invoices => $invoices,
159
    invoices         => $invoices,
135
    invoicenumber   => $invoicenumber,
160
    invoicenumber    => $invoicenumber,
136
    booksellerid    => $supplierid,
161
    booksellerid     => $supplierid,
137
    suppliername    => $suppliername,
162
    suppliername     => $suppliername,
138
    billingdatefrom => $billingdatefrom,
163
    shipmentdatefrom => $shipmentdatefrom_iso,
139
    billingdateto   => $billingdateto,
164
    shipmentdateto   => $shipmentdateto_iso,
140
    isbneanissn     => $isbneanissn,
165
    billingdatefrom  => $billingdatefrom_iso,
141
    title           => $title,
166
    billingdateto    => $billingdateto_iso,
142
    author          => $author,
167
    isbneanissn      => $isbneanissn,
143
    publisher       => $publisher,
168
    title            => $title,
144
    publicationyear => $publicationyear,
169
    author           => $author,
145
    branch          => $branch,
170
    publisher        => $publisher,
146
    branchname      => $branchname,
171
    publicationyear  => $publicationyear,
147
    suppliers_loop  => $suppliers_loop,
172
    branch           => $branch,
148
    branches_loop   => $branches_loop,
173
    branchname       => $branchname,
174
    suppliers_loop   => $suppliers_loop,
175
    branches_loop    => $branches_loop,
149
);
176
);
150
177
151
output_html_with_http_headers $input, $cookie, $template->output;
178
output_html_with_http_headers $input, $cookie, $template->output;
(-)a/acqui/orderreceive.pl (-3 / +6 lines)
Lines 74-81 use C4::Items; Link Here
74
use C4::Biblio;
74
use C4::Biblio;
75
use C4::Suggestions;
75
use C4::Suggestions;
76
76
77
use Koha::Acquisition::Bookseller;
77
use Koha::DateUtils;
78
use Koha::DateUtils qw( dt_from_string );
79
78
80
my $input      = new CGI;
79
my $input      = new CGI;
81
80
Lines 194-199 my $budget = GetBudget( $order->{budget_id} ); Link Here
194
193
195
my $datereceived = $order->{datereceived} ? dt_from_string( $order->{datereceived} ) : dt_from_string;
194
my $datereceived = $order->{datereceived} ? dt_from_string( $order->{datereceived} ) : dt_from_string;
196
195
196
my $orderentrydate =  eval{ dt_from_string( $order->{entrydate} ); };
197
$orderentrydate = output_pref( { dt => $orderentrydate, dateonly => 1 } ) if ( $orderentrydate );
198
197
$template->param(
199
$template->param(
198
    AcqCreateItem         => $AcqCreateItem,
200
    AcqCreateItem         => $AcqCreateItem,
199
    count                 => 1,
201
    count                 => 1,
Lines 203-208 $template->param( Link Here
203
    booksellerid          => $order->{'booksellerid'},
205
    booksellerid          => $order->{'booksellerid'},
204
    freight               => $freight,
206
    freight               => $freight,
205
    name                  => $bookseller->{'name'},
207
    name                  => $bookseller->{'name'},
208
    date                  => $orderentrydate,
206
    title                 => $order->{'title'},
209
    title                 => $order->{'title'},
207
    author                => $order->{'author'},
210
    author                => $order->{'author'},
208
    copyrightdate         => $order->{'copyrightdate'},
211
    copyrightdate         => $order->{'copyrightdate'},
Lines 218-224 $template->param( Link Here
218
    membersurname         => $member->{surname} || "",
221
    membersurname         => $member->{surname} || "",
219
    invoiceid             => $invoice->{invoiceid},
222
    invoiceid             => $invoice->{invoiceid},
220
    invoice               => $invoice->{invoicenumber},
223
    invoice               => $invoice->{invoicenumber},
221
    datereceived          => $datereceived,
224
    datereceived          => output_pref( { dt => $datereceived, dateonly => 1, dateformat => 'iso' } ),
222
    order_internalnote    => $order->{order_internalnote},
225
    order_internalnote    => $order->{order_internalnote},
223
    order_vendornote      => $order->{order_vendornote},
226
    order_vendornote      => $order->{order_vendornote},
224
    suggestionid          => $suggestion->{suggestionid},
227
    suggestionid          => $suggestion->{suggestionid},
(-)a/acqui/parcel.pl (-6 / +5 lines)
Lines 64-73 use C4::Biblio; Link Here
64
use C4::Items;
64
use C4::Items;
65
use CGI qw ( -utf8 );
65
use CGI qw ( -utf8 );
66
use C4::Output;
66
use C4::Output;
67
use C4::Dates qw/format_date format_date_in_iso/;
68
use C4::Suggestions;
67
use C4::Suggestions;
69
use C4::Reserves qw/GetReservesFromBiblionumber/;
68
use C4::Reserves qw/GetReservesFromBiblionumber/;
70
69
use Koha::DateUtils;
71
use Koha::Acquisition::Bookseller;
70
use Koha::Acquisition::Bookseller;
72
71
73
use JSON;
72
use JSON;
Lines 112-118 unless( $invoiceid and $invoice->{invoiceid} ) { Link Here
112
my $booksellerid = $invoice->{booksellerid};
111
my $booksellerid = $invoice->{booksellerid};
113
my $bookseller = Koha::Acquisition::Bookseller->fetch({ id => $booksellerid });
112
my $bookseller = Koha::Acquisition::Bookseller->fetch({ id => $booksellerid });
114
my $gst = $bookseller->{gstrate} // C4::Context->preference("gist") // 0;
113
my $gst = $bookseller->{gstrate} // C4::Context->preference("gist") // 0;
115
my $datereceived = C4::Dates->new();
114
my $datereceived = dt_from_string;
116
115
117
my @orders        = @{ $invoice->{orders} };
116
my @orders        = @{ $invoice->{orders} };
118
my $countlines    = scalar @orders;
117
my $countlines    = scalar @orders;
Lines 282-290 $template->param( Link Here
282
    invoiceid             => $invoice->{invoiceid},
281
    invoiceid             => $invoice->{invoiceid},
283
    invoice               => $invoice->{invoicenumber},
282
    invoice               => $invoice->{invoicenumber},
284
    invoiceclosedate      => $invoice->{closedate},
283
    invoiceclosedate      => $invoice->{closedate},
285
    datereceived          => $datereceived->output('iso'),
284
    datereceived          => eval { output_pref( { dt => $datereceived, dateonly => 1, dateformat =>'iso' } ) },
286
    invoicedatereceived   => $datereceived->output('iso'),
285
    invoicedatereceived   => eval { output_pref( { dt => $datereceived, dateonly => 1, dateformat =>'iso' } ) },
287
    formatteddatereceived => $datereceived->output(),
286
    formatteddatereceived => eval { output_pref( { dt => $datereceived, dateonly => 1 } ) },
288
    name                  => $bookseller->{'name'},
287
    name                  => $bookseller->{'name'},
289
    booksellerid          => $bookseller->{id},
288
    booksellerid          => $bookseller->{id},
290
    loop_received         => \@loop_received,
289
    loop_received         => \@loop_received,
(-)a/acqui/parcels.pl (-8 / +32 lines)
Lines 89-94 my $resultsperpage = $input->param('resultsperpage'); Link Here
89
my $op             = $input->param('op');
89
my $op             = $input->param('op');
90
$resultsperpage ||= 20;
90
$resultsperpage ||= 20;
91
91
92
my $datefrom_iso = '';
93
my $dateto_iso = '';
94
95
if ( $datefrom ) {
96
    $datefrom_iso = eval { dt_from_string( $datefrom ) };
97
    if ($datefrom_iso ) {
98
        $datefrom_iso = output_pref( { dt => $datefrom_iso, dateformat => 'iso',  dateonly => 1 } );
99
    }
100
    else {
101
        $datefrom = '';
102
    }
103
}
104
105
if ( $dateto ) {
106
    $dateto_iso = eval { dt_from_string( $dateto ) };
107
    if ($dateto_iso ) {
108
        $dateto_iso = output_pref( { dt => $dateto_iso, dateformat => 'iso',  dateonly => 1 } );
109
    }
110
    else {
111
        $dateto = '';
112
    }
113
}
114
92
our ( $template, $loggedinuser, $cookie, $flags ) = get_template_and_user(
115
our ( $template, $loggedinuser, $cookie, $flags ) = get_template_and_user(
93
    {   template_name   => 'acqui/parcels.tt',
116
    {   template_name   => 'acqui/parcels.tt',
94
        query           => $input,
117
        query           => $input,
Lines 103-110 my $invoicenumber = $input->param('invoice'); Link Here
103
my $shipmentdate = $input->param('shipmentdate');
126
my $shipmentdate = $input->param('shipmentdate');
104
my $shipmentcost = $input->param('shipmentcost');
127
my $shipmentcost = $input->param('shipmentcost');
105
my $shipmentcost_budgetid = $input->param('shipmentcost_budgetid');
128
my $shipmentcost_budgetid = $input->param('shipmentcost_budgetid');
106
if($shipmentdate) {
129
if ( $shipmentdate ) {
107
    $shipmentdate = C4::Dates->new($shipmentdate)->output('iso');
130
    $shipmentdate = eval { dt_from_string ( $shipmentdate ) };
131
    $shipmentdate = output_pref( { dt => $shipmentdate, dateonly => 1, dateformat => 'iso' } ) if ( $shipmentdate );
108
}
132
}
109
133
110
if ( $op and $op eq 'new' ) {
134
if ( $op and $op eq 'new' ) {
Lines 143-153 if ($op and $op eq 'confirm') { Link Here
143
167
144
my $bookseller = Koha::Acquisition::Bookseller->fetch({ id => $booksellerid });
168
my $bookseller = Koha::Acquisition::Bookseller->fetch({ id => $booksellerid });
145
my @parcels = GetInvoices(
169
my @parcels = GetInvoices(
146
    supplierid => $booksellerid,
170
    supplierid       => $booksellerid,
147
    invoicenumber => $code,
171
    invoicenumber    => $code,
148
    ( $datefrom ? ( shipmentdatefrom => output_pref({ dt => dt_from_string($datefrom), dateformat => 'iso' }) ) : () ),
172
    shipmentdatefrom => $datefrom_iso,
149
    ( $dateto   ? ( shipmentdateto   => output_pref({ dt => dt_from_string($dateto),   dateformat => 'iso' }) )    : () ),
173
    shipmentdateto   => $dateto_iso,
150
    order_by => $order
174
    order_by         => $order
151
);
175
);
152
my $count_parcels = @parcels;
176
my $count_parcels = @parcels;
153
177
Lines 206-212 $template->param( Link Here
206
    dateto                   => $dateto,
230
    dateto                   => $dateto,
207
    resultsperpage           => $resultsperpage,
231
    resultsperpage           => $resultsperpage,
208
    name                     => $bookseller->{'name'},
232
    name                     => $bookseller->{'name'},
209
    shipmentdate_today       => C4::Dates->new()->output(),
233
    shipmentdate_today       => output_pref( { dt => dt_from_string, dateonly =>1 } ),
210
    booksellerid             => $booksellerid,
234
    booksellerid             => $booksellerid,
211
    GST                      => C4::Context->preference('gist'),
235
    GST                      => C4::Context->preference('gist'),
212
    budgets                  => $budget_loop,
236
    budgets                  => $budget_loop,
(-)a/acqui/transferorder.pl (-2 lines)
Lines 27-33 use C4::Output; Link Here
27
use C4::Context;
27
use C4::Context;
28
use C4::Acquisition;
28
use C4::Acquisition;
29
use C4::Members;
29
use C4::Members;
30
use C4::Dates qw/format_date_in_iso/;
31
use Date::Calc qw/Today/;
30
use Date::Calc qw/Today/;
32
31
33
my $input = new CGI;
32
my $input = new CGI;
34
- 

Return to bug 14946