X-Git-Url: http://wagnertech.de/gitweb/gitweb.cgi/mfinanz.git/blobdiff_plain/c2ba1d2cda11661f0cb2aebda7d8bd3ff934ab41..dec270d227e4e9c199001064f32cef1ef37c4296:/bin/mozilla/ar.pl
diff --git a/bin/mozilla/ar.pl b/bin/mozilla/ar.pl
index 1b59d789e..7456cd5f9 100644
--- a/bin/mozilla/ar.pl
+++ b/bin/mozilla/ar.pl
@@ -24,7 +24,8 @@
# GNU General Public License for more details.
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
-# Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
+# MA 02110-1335, USA.
#======================================================================
#
# Accounts Receivables
@@ -38,7 +39,6 @@ use List::UtilsBy qw(sort_by);
use SL::AR;
use SL::FU;
use SL::IS;
-use SL::PE;
use SL::DB::Default;
use SL::DB::Invoice;
use SL::ReportGenerator;
@@ -81,7 +81,7 @@ use strict;
sub add {
$main::lxdebug->enter_sub();
- $main::auth->assert('general_ledger');
+ $main::auth->assert('ar_transactions');
my $form = $main::form;
my %myconfig = %main::myconfig;
@@ -108,7 +108,7 @@ sub add {
sub edit {
$main::lxdebug->enter_sub();
- $main::auth->assert('general_ledger');
+ $main::auth->assert('ar_transactions');
my $form = $main::form;
@@ -127,7 +127,7 @@ sub edit {
sub display_form {
$main::lxdebug->enter_sub();
- $main::auth->assert('general_ledger');
+ $main::auth->assert('ar_transactions');
my $form = $main::form;
@@ -146,7 +146,7 @@ sub _retrieve_invoice_object {
sub create_links {
$main::lxdebug->enter_sub();
- $main::auth->assert('general_ledger');
+ $main::auth->assert('ar_transactions');
my %params = @_;
my $form = $main::form;
@@ -181,16 +181,7 @@ sub create_links {
(@{ $form->{all_customer} });
}
- # departments
- if (@{ $form->{all_departments} || [] }) {
- $form->{selectdepartment} = "\n";
- $form->{department} = "$form->{department}--$form->{department_id}";
-
- map {
- $form->{selectdepartment} .=
- " $_->{description}--$_->{id}\n"
- } (@{ $form->{all_departments} || [] });
- }
+ $form->{ALL_DEPARTMENTS} = SL::DB::Manager::Department->get_all;
$form->{employee} = "$form->{employee}--$form->{employee_id}";
@@ -216,7 +207,7 @@ sub create_links {
sub form_header {
$main::lxdebug->enter_sub();
- $main::auth->assert('general_ledger');
+ $main::auth->assert('ar_transactions');
my $form = $main::form;
my %myconfig = %main::myconfig;
@@ -226,7 +217,7 @@ sub form_header {
$form->{invoice_obj} = _retrieve_invoice_object();
my ($title, $readonly, $exchangerate, $rows);
- my ($notes, $department, $customer, $employee, $amount, $project);
+ my ($notes, $customer, $employee, $amount, $project);
my ($ARselected);
@@ -265,7 +256,7 @@ sub form_header {
$readonly = ($form->{radier}) ? "" : $readonly;
# set option selected
- foreach my $item (qw(customer currency department employee)) {
+ foreach my $item (qw(customer currency employee)) {
$form->{"select$item"} =~ s/ selected//;
$form->{"select$item"} =~ s/option>\Q$form->{$item}\E/option selected>$form->{$item}/;
}
@@ -288,6 +279,8 @@ sub form_header {
"taxcharts" => { "key" => "ALL_TAXCHARTS",
"module" => "AR" },);
+ $form->{ALL_DEPARTMENTS} = SL::DB::Manager::Department->get_all;
+
$_->{link_split} = { map { $_ => 1 } split/:/, $_->{link} } for @{ $form->{ALL_CHARTS} };
my %project_labels = map { $_->{id} => $_->{projectnumber} } @{ $form->{"ALL_PROJECTS"} };
@@ -476,7 +469,7 @@ sub form_header {
sub form_footer {
$main::lxdebug->enter_sub();
- $main::auth->assert('general_ledger');
+ $main::auth->assert('ar_transactions');
my $form = $main::form;
my %myconfig = %main::myconfig;
@@ -513,7 +506,7 @@ sub form_footer {
sub mark_as_paid {
$main::lxdebug->enter_sub();
- $main::auth->assert('general_ledger');
+ $main::auth->assert('ar_transactions');
my $form = $main::form;
my %myconfig = %main::myconfig;
@@ -523,10 +516,16 @@ sub mark_as_paid {
$main::lxdebug->leave_sub();
}
+sub show_draft {
+ $::form->{transdate} = DateTime->today_local->to_kivitendo if !$::form->{transdate};
+ $::form->{gldate} = $::form->{transdate} if !$::form->{gldate};
+ update();
+}
+
sub update {
$main::lxdebug->enter_sub();
- $main::auth->assert('general_ledger');
+ $main::auth->assert('ar_transactions');
my $form = $main::form;
my %myconfig = %main::myconfig;
@@ -616,7 +615,7 @@ sub update {
sub post_payment {
$main::lxdebug->enter_sub();
- $main::auth->assert('general_ledger');
+ $main::auth->assert('ar_transactions');
my $form = $main::form;
my %myconfig = %main::myconfig;
@@ -666,7 +665,7 @@ sub post_payment {
sub _post {
- $main::auth->assert('general_ledger');
+ $main::auth->assert('ar_transactions');
my $form = $main::form;
@@ -677,7 +676,7 @@ sub _post {
sub post {
$main::lxdebug->enter_sub();
- $main::auth->assert('general_ledger');
+ $main::auth->assert('ar_transactions');
my $form = $main::form;
my %myconfig = %main::myconfig;
@@ -694,7 +693,7 @@ sub post {
$form->isblank("duedate", $locale->text('Due Date missing!'));
$form->isblank("customer", $locale->text('Customer missing!'));
- if ($myconfig{mandatory_departments} && !$form->{department}) {
+ if ($myconfig{mandatory_departments} && !$form->{department_id}) {
$form->{saved_message} = $::locale->text('You have to specify a department.');
update();
exit;
@@ -767,7 +766,7 @@ sub post {
sub post_as_new {
$main::lxdebug->enter_sub();
- $main::auth->assert('general_ledger');
+ $main::auth->assert('ar_transactions');
my $form = $main::form;
my %myconfig = %main::myconfig;
@@ -789,7 +788,7 @@ sub post_as_new {
sub use_as_new {
$main::lxdebug->enter_sub();
- $main::auth->assert('general_ledger');
+ $main::auth->assert('ar_transactions');
my $form = $main::form;
my %myconfig = %main::myconfig;
@@ -806,7 +805,7 @@ sub use_as_new {
sub delete {
$main::lxdebug->enter_sub();
- $main::auth->assert('general_ledger');
+ $main::auth->assert('ar_transactions');
my $form = $main::form;
my $locale = $main::locale;
@@ -845,7 +844,7 @@ sub delete {
sub yes {
$main::lxdebug->enter_sub();
- $main::auth->assert('general_ledger');
+ $main::auth->assert('ar_transactions');
my $form = $main::form;
my %myconfig = %main::myconfig;
@@ -884,10 +883,10 @@ sub search {
# Auch in Rechnungsübersicht nach Kundentyp filtern - jan
$form->get_lists("projects" => { "key" => "ALL_PROJECTS", "all" => 1 },
- "departments" => "ALL_DEPARTMENTS",
"customers" => "ALL_VC",
"business_types" => "ALL_BUSINESS_TYPES");
$form->{ALL_EMPLOYEES} = SL::DB::Manager::Employee->get_all_sorted(query => [ deleted => 0 ]);
+ $form->{ALL_DEPARTMENTS} = SL::DB::Manager::Department->get_all;
$form->{SHOW_BUSINESS_TYPES} = scalar @{ $form->{ALL_BUSINESS_TYPES} } > 0;
$form->{CT_CUSTOM_VARIABLES} = CVar->get_configs('module' => 'CT');
@@ -1038,21 +1037,9 @@ sub ar_transactions {
push @options, $locale->text('Contact Person') . " : $form->{cp_name}";
}
- # $form->{department} seems to never be filled, and showing the department_id
- # at the top of the report doesn't make much sense.
- # So determine the department name from the id whenever we have a filter for
- # department
- if ($form->{department}) {
- my ($department) = split /--/, $form->{department};
- push @options, $locale->text('Department') . " : $department";
- }
if ($form->{department_id}) {
- # push @options, $locale->text('Department Id') . " : $form->{department_id}";
- unless ($form->{department}) {
- require SL::DB::Department;
- my $department = SL::DB::Manager::Department->find_by(id => $::form->{department_id});
- push @options, $locale->text('Department') . " : " . $department->description if $department;
- }
+ my $department = SL::DB::Manager::Department->find_by( id => $form->{department_id} );
+ push @options, $locale->text('Department') . " : " . $department->description;
}
if ($form->{invnumber}) {
push @options, $locale->text('Invoice Number') . " : $form->{invnumber}";
@@ -1187,7 +1174,7 @@ sub ar_transactions {
sub storno {
$main::lxdebug->enter_sub();
- $main::auth->assert('general_ledger');
+ $main::auth->assert('ar_transactions');
my $form = $main::form;
my %myconfig = %main::myconfig;