-use HTML::Template;
-
-my $query = new CGI;
-my ($template, $loggedinuser, $cookie)
-= get_template_and_user({template_name => "acqui/lateorders.tmpl",
- query => $query,
- type => "intranet",
- authnotrequired => 0,
- flagsrequired => {acquisition => 1},
- debug => 1,
- });
-# my $title = $query->param('title');
-# my $ISSN = $query->param('ISSN');
-# my @subscriptions = GetSubscriptions($title,$ISSN);
-
-my $supplierid = $query->param('supplierid');
-my $delay = $query->param('delay');
-my $branch = $query->param('branch');
-
-$delay =($delay?$delay:30);
-
-my %supplierlist = getsupplierlistwithlateorders($delay,$branch);
-my @select_supplier;
-push @select_supplier,"";
-foreach my $supplierid (keys %supplierlist){
- push @select_supplier, $supplierid;
+use C4::Acquisition;
+use C4::Letters;
+use C4::Branch; # GetBranches
+
+my $input = new CGI;
+my ($template, $loggedinuser, $cookie) = get_template_and_user({
+ template_name => "acqui/lateorders.tmpl",
+ query => $input,
+ type => "intranet",
+ authnotrequired => 0,
+ flagsrequired => {acquisition => 'order_receive'},
+ debug => 1,
+});
+
+my $supplierid = $input->param('supplierid') || undef; # we don't want "" or 0
+my $delay = $input->param('delay');
+my $branch = $input->param('branch');
+my $op = $input->param('op');
+
+my @errors = ();
+$delay = 30 unless defined $delay;
+unless ($delay =~ /^\d{1,3}$/) {
+ push @errors, {delay_digits => 1, bad_delay => $delay};
+ $delay = 30; #default value for delay