Revision 92331b8e
Von Moritz Bunkus vor fast 14 Jahren hinzugefügt
bin/mozilla/oe.pl | ||
---|---|---|
41 | 41 |
use SL::MoreCommon qw(ary_diff); |
42 | 42 |
use SL::PE; |
43 | 43 |
use SL::ReportGenerator; |
44 |
use List::MoreUtils qw(any none); |
|
44 | 45 |
use List::Util qw(max reduce sum); |
45 | 46 |
use Data::Dumper; |
46 | 47 |
|
... | ... | |
396 | 397 |
$onload .= qq|;setupPoints('|. $myconfig{numberformat} .qq|', '|. $locale->text("wrongformat") .qq|')|; |
397 | 398 |
$TMPL_VAR{onload} = $onload; |
398 | 399 |
|
400 |
if ($form->{type} eq 'sales_order') { |
|
401 |
if (!$form->{periodic_invoices_config}) { |
|
402 |
$form->{periodic_invoices_status} = $locale->text('not configured'); |
|
403 |
|
|
404 |
} else { |
|
405 |
my $config = YAML::Load($form->{periodic_invoices_config}); |
|
406 |
$form->{periodic_invoices_status} = $config->{active} ? $locale->text('active') : $locale->text('inactive'); |
|
407 |
} |
|
408 |
} |
|
409 |
|
|
399 | 410 |
$form->{javascript} .= qq|<script type="text/javascript" src="js/show_form_details.js"></script>|; |
400 | 411 |
$form->{javascript} .= qq|<script type="text/javascript" src="js/show_history.js"></script>|; |
401 | 412 |
$form->{javascript} .= qq|<script type="text/javascript" src="js/show_vc_details.js"></script>|; |
... | ... | |
747 | 758 |
"salesman", |
748 | 759 |
"shipvia", "globalprojectnumber", |
749 | 760 |
"transaction_description", "open", |
750 |
"delivered", "marge_total", "marge_percent", |
|
761 |
"delivered", "periodic_invoices", |
|
762 |
"marge_total", "marge_percent", |
|
751 | 763 |
"vcnumber", "ustid", |
752 | 764 |
"country", |
753 | 765 |
); |
... | ... | |
758 | 770 |
unshift @columns, "ids"; |
759 | 771 |
} |
760 | 772 |
|
761 |
$form->{l_open} = $form->{l_closed} = "Y" if ($form->{open} && $form->{closed}); |
|
762 |
$form->{l_delivered} = "Y" if ($form->{delivered} && $form->{notdelivered}); |
|
773 |
$form->{l_open} = $form->{l_closed} = "Y" if ($form->{open} && $form->{closed}); |
|
774 |
$form->{l_delivered} = "Y" if ($form->{delivered} && $form->{notdelivered}); |
|
775 |
$form->{l_periodic_invoices} = "Y" if ($form->{periodic_invoices_active} && $form->{periodic_invoices_inactive}); |
|
763 | 776 |
|
764 | 777 |
my $attachment_basename; |
765 | 778 |
if ($form->{vc} eq 'vendor') { |
... | ... | |
786 | 799 |
my @hidden_variables = map { "l_${_}" } @columns; |
787 | 800 |
push @hidden_variables, "l_subtotal", $form->{vc}, qw(l_closed l_notdelivered open closed delivered notdelivered ordnumber quonumber |
788 | 801 |
transaction_description transdatefrom transdateto type vc employee_id salesman_id |
789 |
reqdatefrom reqdateto projectnumber project_id); |
|
802 |
reqdatefrom reqdateto projectnumber project_id periodic_invoices_active periodic_invoices_inactive);
|
|
790 | 803 |
|
791 | 804 |
my $href = build_std_url('action=orders', grep { $form->{$_} } @hidden_variables); |
792 | 805 |
|
... | ... | |
814 | 827 |
'vcnumber' => { 'text' => $form->{vc} eq 'customer' ? $locale->text('Customer Number') : $locale->text('Vendor Number'), }, |
815 | 828 |
'country' => { 'text' => $locale->text('Country'), }, |
816 | 829 |
'ustid' => { 'text' => $locale->text('USt-IdNr.'), }, |
830 |
'periodic_invoices' => { 'text' => $locale->text('Per. Inv.'), }, |
|
817 | 831 |
); |
818 | 832 |
|
819 | 833 |
foreach my $name (qw(id transdate reqdate quonumber ordnumber name employee salesman shipvia transaction_description)) { |
... | ... | |
855 | 869 |
push @options, $locale->text('Closed') if $form->{closed}; |
856 | 870 |
push @options, $locale->text('Delivered') if $form->{delivered}; |
857 | 871 |
push @options, $locale->text('Not delivered') if $form->{notdelivered}; |
872 |
push @options, $locale->text('Periodic invoices active') if $form->{periodic_invoices_actibe}; |
|
858 | 873 |
|
859 | 874 |
$report->set_options('top_info_text' => join("\n", @options), |
860 | 875 |
'raw_top_info_text' => $form->parse_html_template('oe/orders_top'), |
... | ... | |
884 | 899 |
foreach my $oe (@{ $form->{OE} }) { |
885 | 900 |
map { $oe->{$_} *= $oe->{exchangerate} } @subtotal_columns; |
886 | 901 |
|
887 |
$oe->{tax} = $oe->{amount} - $oe->{netamount}; |
|
888 |
$oe->{open} = $oe->{closed} ? $locale->text('No') : $locale->text('Yes'); |
|
889 |
$oe->{delivered} = $oe->{delivered} ? $locale->text('Yes') : $locale->text('No'); |
|
902 |
$oe->{tax} = $oe->{amount} - $oe->{netamount}; |
|
903 |
$oe->{open} = $oe->{closed} ? $locale->text('No') : $locale->text('Yes'); |
|
904 |
$oe->{delivered} = $oe->{delivered} ? $locale->text('Yes') : $locale->text('No'); |
|
905 |
$oe->{periodic_invoices} = $oe->{periodic_invoices} ? $locale->text('On') : $locale->text('Off'); |
|
890 | 906 |
|
891 | 907 |
map { $subtotals{$_} += $oe->{$_}; |
892 | 908 |
$totals{$_} += $oe->{$_} } @subtotal_columns; |
... | ... | |
1936 | 1952 |
return $content; |
1937 | 1953 |
} |
1938 | 1954 |
|
1955 |
sub edit_periodic_invoices_config { |
|
1956 |
$::lxdebug->enter_sub(); |
|
1957 |
|
|
1958 |
$::form->{type} = 'sales_order'; |
|
1959 |
|
|
1960 |
check_oe_access(); |
|
1961 |
|
|
1962 |
my $config; |
|
1963 |
$config = YAML::Load($::form->{periodic_invoices_config}) if $::form->{periodic_invoices_config}; |
|
1964 |
|
|
1965 |
if ('HASH' ne ref $config) { |
|
1966 |
$config = { |
|
1967 |
periodicity => 'm', |
|
1968 |
start_date => $::form->{transdate}, |
|
1969 |
active => 1, |
|
1970 |
}; |
|
1971 |
} |
|
1972 |
|
|
1973 |
$config->{periodicity} = 'm' if none { $_ eq $config->{periodicity} } qw(m q y); |
|
1974 |
|
|
1975 |
$::form->get_lists(printers => "ALL_PRINTERS", |
|
1976 |
charts => { key => 'ALL_CHARTS', |
|
1977 |
transdate => 'current_date' }); |
|
1978 |
|
|
1979 |
$::form->{AR} = [ grep { $_->{link} =~ m/(?:^|:)AR(?::|$)/ } @{ $::form->{ALL_CHARTS} } ]; |
|
1980 |
$::form->{title} = $::locale->text('Edit the configuration for periodic invoices'); |
|
1981 |
|
|
1982 |
$::form->header(); |
|
1983 |
print $::form->parse_html_template('oe/edit_periodic_invoices_config', $config); |
|
1984 |
|
|
1985 |
$::lxdebug->leave_sub(); |
|
1986 |
} |
|
1987 |
|
|
1988 |
sub save_periodic_invoices_config { |
|
1989 |
$::lxdebug->enter_sub(); |
|
1990 |
|
|
1991 |
$::form->{type} = 'sales_order'; |
|
1992 |
|
|
1993 |
check_oe_access(); |
|
1994 |
|
|
1995 |
$::form->isblank('start_date', $::locale->text('The start date is missing.')); |
|
1996 |
|
|
1997 |
my $config = { active => $::form->{active} ? 1 : 0, |
|
1998 |
periodicity => (any { $_ eq $::form->{periodicity} } qw(m q y)) ? $::form->{periodicity} : 'm', |
|
1999 |
start_date => $::form->{start_date}, |
|
2000 |
print => $::form->{print} ? 1 : 0, |
|
2001 |
printer_id => $::form->{print} ? $::form->{printer_id} * 1 : undef, |
|
2002 |
copies => $::form->{copies} * 1 ? $::form->{copies} : 1, |
|
2003 |
ar_chart_id => $::form->{ar_chart_id} * 1, |
|
2004 |
}; |
|
2005 |
|
|
2006 |
$::form->{periodic_invoices_config} = YAML::Dump($config); |
|
2007 |
|
|
2008 |
$::form->{title} = $::locale->text('Edit the configuration for periodic invoices'); |
|
2009 |
$::form->header; |
|
2010 |
print $::form->parse_html_template('oe/save_periodic_invoices_config', $config); |
|
2011 |
|
|
2012 |
$::lxdebug->leave_sub(); |
|
2013 |
} |
|
2014 |
|
|
1939 | 2015 |
sub dispatcher { |
1940 | 2016 |
my $form = $main::form; |
1941 | 2017 |
my $locale = $main::locale; |
Auch abrufbar als: Unified diff
Bearbeiten der Konfiguration für wiederkehrende Rechnungen implementiert
Zzgl. der Suchfunktionserweiterung bei Aufträgen