1 package SL::Controller::LiquidityProjection;
 
   5 use parent qw(SL::Controller::Base);
 
   7 use SL::Locale::String;
 
   8 use SL::LiquidityProjection;
 
   9 use SL::Util qw(_hashify);
 
  11 __PACKAGE__->run_before('check_auth');
 
  13 use Rose::Object::MakeMethods::Generic (
 
  14   scalar                  => [ qw(liquidity) ],
 
  15   'scalar --get_set_init' => [ qw(oe_report_columns_str) ],
 
  26   $self->liquidity(SL::LiquidityProjection->new(%{ $::form->{params} })->create) if $::form->{params};
 
  28   $::form->{params} ||= {
 
  35   $self->render('liquidity_projection/show', title => t8('Liquidity projection'));
 
  42 sub check_auth                 { $::auth->assert('report') }
 
  43 sub init_oe_report_columns_str { join '&', map { "$_=Y" } qw(open delivered notdelivered l_ordnumber l_transdate l_reqdate l_name l_employee l_salesman l_netamount l_amount l_transaction_description) }
 
  49 sub link_to_old_orders {
 
  51   my %params  = _hashify(0, @_);
 
  53   my $reqdate = $params{reqdate};
 
  54   my $months  = $params{months} * 1;
 
  58   if ($reqdate eq 'old') {
 
  59     $fields .= '&reqdate_unset_or_old=Y';
 
  61   } elsif ($reqdate eq 'future') {
 
  63     $fields .= '&reqdatefrom=' . $self->iso_to_display(SL::LiquidityProjection::_the_date($now[5] + 1900, $now[4] + 1 + $months) . '-01');
 
  66     $reqdate =~ m/(\d+)-(\d+)/;
 
  67     $fields .=  '&reqdatefrom=' . $self->iso_to_display($reqdate . '-01');
 
  68     $fields .=  '&reqdateto='   . $self->iso_to_display($reqdate . sprintf('-%02d', DateTime->last_day_of_month(year => $1, month => $2)->day));
 
  72   return "oe.pl?action=orders&type=sales_order&vc=customer&" . $self->oe_report_columns_str . $fields;
 
  76   my ($self, $date) = @_;
 
  78   $::locale->reformat_date({ dateformat => 'yyyy-mm-dd' }, $date, $::myconfig{dateformat});