X-Git-Url: http://wagnertech.de/git?a=blobdiff_plain;f=bin%2Fmozilla%2Ffu.pl;h=5cd6a0745bcb7f03aa12584f65a0d698286ea90b;hb=refs%2Fheads%2Forder_controller;hp=7c78dd7ed2fffda2b80f0980a7ee42dd772dc723;hpb=7a7f33b5c1b3531ab761adba1cf19d4ad68cffcd;p=kivitendo-erp.git diff --git a/bin/mozilla/fu.pl b/bin/mozilla/fu.pl index 7c78dd7ed..5cd6a0745 100644 --- a/bin/mozilla/fu.pl +++ b/bin/mozilla/fu.pl @@ -5,11 +5,17 @@ use SL::ReportGenerator; require "bin/mozilla/reportgenerator.pl"; +use strict; + sub _collect_links { - $lxdebug->enter_sub(); + $main::lxdebug->enter_sub(); + + $main::auth->assert('productivity'); my $dest = shift; + my $form = $main::form; + $dest->{LINKS} = []; foreach my $i (1 .. $form->{trans_rowcount}) { @@ -18,11 +24,17 @@ sub _collect_links { push @{ $dest->{LINKS} }, { map { +"trans_$_" => $form->{"trans_${_}_$i"} } qw(id type info) }; } - $lxdebug->leave_sub(); + $main::lxdebug->leave_sub(); } sub add { - $lxdebug->enter_sub(); + $main::lxdebug->enter_sub(); + + $main::auth->assert('productivity'); + + my $form = $main::form; + my %myconfig = %main::myconfig; + my $locale = $main::locale; _collect_links($form); @@ -43,11 +55,16 @@ sub add { display_form(); - $lxdebug->leave_sub(); + $main::lxdebug->leave_sub(); } sub edit { - $lxdebug->enter_sub(); + $main::lxdebug->enter_sub(); + + $main::auth->assert('productivity'); + + my $form = $main::form; + my $locale = $main::locale; my $ref = FU->retrieve('id' => $form->{id}); @@ -65,11 +82,15 @@ sub edit { display_form(); - $lxdebug->leave_sub(); + $main::lxdebug->leave_sub(); } sub display_form { - $lxdebug->enter_sub(); + $main::lxdebug->enter_sub(); + + $main::auth->assert('productivity'); + + my $form = $main::form; $form->get_lists("employees" => "EMPLOYEES"); @@ -78,22 +99,25 @@ sub display_form { $params{trans_id} = $form->{LINKS}->[0]->{trans_id} if (@{ $form->{LINKS} }); $form->{FOLLOW_UPS} = FU->follow_ups(%params); - $form->{jsscript} = 1; - - $form->header(); + $form->header(no_layout => $::form->{POPUP_MODE}); print $form->parse_html_template('fu/add_edit'); - $lxdebug->leave_sub(); + $main::lxdebug->leave_sub(); } sub save_follow_up { - $lxdebug->enter_sub(); + $main::lxdebug->enter_sub(); + + $main::auth->assert('productivity'); + + my $form = $main::form; + my $locale = $main::locale; $form->isblank('created_for_user', $locale->text('You must chose a user.')); $form->isblank('follow_up_date', $locale->text('The follow-up date is missing.')); $form->isblank('subject', $locale->text('The subject is missing.')); - my %params = (map({ $_ => $form->{$_} } qw(id subject body created_for_user follow_up_date)), 'done' => 0); + my %params = (map({ $_ => $form->{$_} } qw(id subject body note_id created_for_user follow_up_date)), 'done' => 0); _collect_links(\%params); @@ -102,7 +126,7 @@ sub save_follow_up { if ($form->{POPUP_MODE}) { $form->header(); print $form->parse_html_template('fu/close_window'); - exit 0; + ::end_of_request(); } $form->{SAVED_MESSAGE} = $locale->text('Follow-Up saved.'); @@ -117,11 +141,16 @@ sub save_follow_up { report(); - $lxdebug->leave_sub(); + $main::lxdebug->leave_sub(); } sub finish { - $lxdebug->enter_sub(); + $main::lxdebug->enter_sub(); + + $main::auth->assert('productivity'); + + my $form = $main::form; + my $locale = $main::locale; if ($form->{id}) { my $ref = FU->retrieve('id' => $form->{id}); @@ -143,18 +172,23 @@ sub finish { if ($form->{POPUP_MODE}) { $form->header(); print $form->parse_html_template('fu/close_window'); - exit 0; + ::end_of_request(); } $form->redirect() if ($form->{callback}); report(); - $lxdebug->leave_sub(); + $main::lxdebug->leave_sub(); } sub delete { - $lxdebug->enter_sub(); + $main::lxdebug->enter_sub(); + + $main::auth->assert('productivity'); + + my $form = $main::form; + my $locale = $main::locale; if ($form->{id}) { my $ref = FU->retrieve('id' => $form->{id}); @@ -176,35 +210,48 @@ sub delete { if ($form->{POPUP_MODE}) { $form->header(); print $form->parse_html_template('fu/close_window'); - exit 0; + ::end_of_request(); } $form->redirect() if ($form->{callback}); report(); - $lxdebug->leave_sub(); + $main::lxdebug->leave_sub(); } sub search { - $lxdebug->enter_sub(); + $main::lxdebug->enter_sub(); + + $main::auth->assert('productivity'); + + my $form = $main::form; + my $locale = $main::locale; $form->get_lists("employees" => "EMPLOYEES"); - $form->{jsscript} = 1; $form->{title} = $locale->text('Follow-Ups'); $form->header(); print $form->parse_html_template('fu/search'); - $lxdebug->leave_sub(); + $main::lxdebug->leave_sub(); } sub report { - $lxdebug->enter_sub(); + $main::lxdebug->enter_sub(); + + $main::auth->assert('productivity'); + + my $form = $main::form; + my %myconfig = %main::myconfig; + my $locale = $main::locale; + my $cgi = $::request->{cgi}; my @report_params = qw(created_for subject body reference follow_up_date_from follow_up_date_to itime_from itime_to due_only all_users done not_done); + report_generator_set_default_sort('follow_up_date', 1); + my $follow_ups = FU->follow_ups(map { $_ => $form->{$_} } @report_params); $form->{rowcount} = scalar @{ $follow_ups }; @@ -222,6 +269,12 @@ sub report { ); my @columns = qw(selected follow_up_date created_on subject title created_by_name created_for_user_name done); + my $href = build_std_url('action=report', grep { $form->{$_} } @report_params); + + foreach my $name (qw(follow_up_date created_on title subject)) { + my $sortdir = $form->{sort} eq $name ? 1 - $form->{sortdir} : $form->{sortdir}; + $column_defs{$name}->{link} = $href . "&sort=$name&sortdir=$sortdir"; + } my @options; @@ -251,9 +304,9 @@ sub report { $report->set_columns(%column_defs); $report->set_column_order(@columns); - $report->set_export_options('report', @report_params); + $report->set_export_options('report', @report_params, qw(sort sortdir)); - $report->set_sort_indicator('follow_up_date', 1); + $report->set_sort_indicator($form->{sort}, $form->{sortdir}); $report->set_options('raw_top_info_text' => $form->parse_html_template('fu/report_top', { 'OPTIONS' => \@options }), 'raw_bottom_info_text' => $form->parse_html_template('fu/report_bottom', { 'HIDDEN' => \@hidden_report_params }), @@ -262,6 +315,7 @@ sub report { 'attachment_basename' => $locale->text('follow_up_list') . strftime('_%Y%m%d', localtime time), ); $report->set_options_from_form(); + $locale->set_numberformat_wo_thousands_separator(\%myconfig) if lc($report->{options}->{output_format}) eq 'csv'; my $idx = 0; my $callback = build_std_url('action=report', grep { $form->{$_} } @report_params); @@ -295,18 +349,22 @@ sub report { $report->generate_with_headers(); - $lxdebug->leave_sub(); + $main::lxdebug->leave_sub(); } sub report_for_todo_list { - $lxdebug->enter_sub(); + $main::lxdebug->enter_sub(); + + $main::auth->assert('productivity'); + + my $form = $main::form; my @report_params = qw(created_for subject body reference follow_up_date_from follow_up_date_to itime_from itime_to due_only all_users done not_done); my %params = ( 'due_only' => 1, 'not_done' => 1, - 'created_for_login' => $form->{login}, + 'created_for_login' => $::myconfig{login}, ); my $follow_ups = FU->follow_ups(%params); @@ -330,17 +388,22 @@ sub report_for_todo_list { 'edit_url' => $edit_url, }); } - $lxdebug->leave_sub(); + $main::lxdebug->leave_sub(); return $content; } sub edit_access_rights { - $lxdebug->enter_sub(); + $main::lxdebug->enter_sub(); + + $main::auth->assert('productivity'); + + my $form = $main::form; + my $locale = $main::locale; my $access = FU->retrieve_access_rights(); - $form->get_lists("employees" => "EMPLOYEES"); + $form->{EMPLOYEES} = SL::DB::Manager::Employee->get_all_sorted(query => [ deleted => 0 ]); map { $_->{access} = $access->{$_->{id}} } @{ $form->{EMPLOYEES} }; @@ -349,11 +412,16 @@ sub edit_access_rights { $form->header(); print $form->parse_html_template('fu/edit_access_rights'); - $lxdebug->leave_sub(); + $main::lxdebug->leave_sub(); } sub save_access_rights { - $lxdebug->enter_sub(); + $main::lxdebug->enter_sub(); + + $main::auth->assert('productivity'); + + my $form = $main::form; + my $locale = $main::locale; my %access; @@ -368,26 +436,33 @@ sub save_access_rights { $form->{SAVED_MESSAGE} = $locale->text('The access rights have been saved.'); edit_access_rights(); - $lxdebug->leave_sub(); + $main::lxdebug->leave_sub(); } sub update { - call_sub($form->{nextsub}); + call_sub($main::form->{nextsub}); } sub continue { - call_sub($form->{nextsub}); + call_sub($main::form->{nextsub}); } sub save { - if ($form->{save_nextsub}) { - call_sub($form->{save_nextsub}); + $main::auth->assert('productivity'); + + if ($main::form->{save_nextsub}) { + call_sub($main::form->{save_nextsub}); } else { save_follow_up(); } } sub dispatcher { + $main::lxdebug->enter_sub(); + + my $form = $main::form; + my $locale = $main::locale; + foreach my $action (qw(finish save delete)) { if ($form->{"action_${action}"}) { call_sub($action);