|
#=====================================================================
|
|
# LX-Office ERP
|
|
# Copyright (C) 2004
|
|
# Based on SQL-Ledger Version 2.1.9
|
|
# Web http://www.lx-office.org
|
|
#
|
|
#=====================================================================
|
|
# SQL-Ledger, Accounting
|
|
# Copyright (c) 1998-2002
|
|
#
|
|
# Author: Dieter Simader
|
|
# Email: dsimader@sql-ledger.org
|
|
# Web: http://www.sql-ledger.org
|
|
#
|
|
#
|
|
# This program is free software; you can redistribute it and/or modify
|
|
# it under the terms of the GNU General Public License as published by
|
|
# the Free Software Foundation; either version 2 of the License, or
|
|
# (at your option) any later version.
|
|
#
|
|
# This program is distributed in the hope that it will be useful,
|
|
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
# 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., 51 Franklin Street, Fifth Floor, Boston,
|
|
# MA 02110-1335, USA.
|
|
#======================================================================
|
|
#
|
|
# Inventory received module
|
|
#
|
|
#======================================================================
|
|
|
|
use SL::FU;
|
|
use SL::Helper::Flash qw(flash_later);
|
|
use SL::Helper::UserPreferences::DisplayPreferences;
|
|
use SL::IR;
|
|
use SL::IS;
|
|
use SL::DB::BankTransactionAccTrans;
|
|
use SL::DB::Default;
|
|
use SL::DB::Department;
|
|
use SL::DB::Project;
|
|
use SL::DB::PurchaseInvoice;
|
|
use SL::DB::ValidityToken;
|
|
use SL::DB::Vendor;
|
|
use List::MoreUtils qw(uniq);
|
|
use List::Util qw(max sum);
|
|
use List::UtilsBy qw(sort_by);
|
|
|
|
require "bin/mozilla/io.pl";
|
|
require "bin/mozilla/common.pl";
|
|
|
|
use strict;
|
|
|
|
1;
|
|
|
|
# end of main
|
|
|
|
sub _may_view_or_edit_this_invoice {
|
|
return 1 if $::auth->assert('ap_transactions', 1); # may edit all invoices
|
|
return 0 if !$::form->{id}; # creating new invoices isn't allowed without invoice_edit
|
|
return 1 if $::auth->assert('purchase_invoice_view', 1); # viewing is allowed with this right
|
|
return 0 if !$::form->{globalproject_id}; # existing records without a project ID are not allowed
|
|
return SL::DB::Project->new(id => $::form->{globalproject_id})->load->may_employee_view_project_invoices(SL::DB::Manager::Employee->current);
|
|
}
|
|
|
|
sub _assert_access {
|
|
my $cache = $::request->cache('ap.pl::_assert_access');
|
|
|
|
$cache->{_may_view_or_edit_this_invoice} = _may_view_or_edit_this_invoice() if !exists $cache->{_may_view_or_edit_this_invoice};
|
|
$::form->show_generic_error($::locale->text("You do not have the permissions to access this function.")) if ! $cache->{_may_view_or_edit_this_invoice};
|
$::lxdebug->enter_sub;
|
|
|
|
_assert_access();
|
|
|
|
relink_accounts();
|
|
|
|
my $new_rowcount = $::form->{"rowcount"} * 1 + 1;
|
|
$::form->{"project_id_${new_rowcount}"} = $::form->{"globalproject_id"};
|
|
|
|
$::form->language_payment(\%::myconfig);
|
|
|
|
Common::webdav_folder($::form);
|
|
|
|
form_header();
|
|
display_row(++$:: |