Initial commit.
This commit is contained in:
107
htdocs/emandy/magicat/cgi-bin/acctreps.cgi
Executable file
107
htdocs/emandy/magicat/cgi-bin/acctreps.cgi
Executable file
@@ -0,0 +1,107 @@
|
||||
#! /usr/bin/perl -w
|
||||
# Mandy Wu's Website
|
||||
# acctreps.cgi: The accounting report viewer.
|
||||
|
||||
# Copyright (c) 2007-2021 imacat.
|
||||
#
|
||||
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||
# you may not use this file except in compliance with the License.
|
||||
# You may obtain a copy of the License at
|
||||
#
|
||||
# http://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing, software
|
||||
# distributed under the License is distributed on an "AS IS" BASIS,
|
||||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
# See the License for the specific language governing permissions and
|
||||
# limitations under the License.
|
||||
|
||||
# Author: imacat <imacat@mail.imacat.idv.tw>
|
||||
# First written: 2007-09-24
|
||||
|
||||
use 5.008;
|
||||
use strict;
|
||||
use warnings;
|
||||
use lib $ENV{"DOCUMENT_ROOT"} . qw(/magicat/lib/perl5);
|
||||
use Selima::emandy;
|
||||
local $SIG{"__DIE__"} = \&http_500;
|
||||
my $d = new Selima::Destroy;
|
||||
# Prototype declaration
|
||||
sub main();
|
||||
sub check_get();
|
||||
sub html_page($);
|
||||
|
||||
initenv(-restricted => 1,
|
||||
-dbi_lock => {"acctsubj" => LOCK_SH,
|
||||
"accttrx" => LOCK_SH,
|
||||
"acctrecs" => LOCK_SH},
|
||||
-lastmod => 1,
|
||||
-page_param => {"keywords" => N_("accounting"),
|
||||
"javascripts" => [qw(/scripts/accounting.js)]});
|
||||
|
||||
main;
|
||||
exit 0;
|
||||
|
||||
sub main() {
|
||||
local ($_, %_);
|
||||
my $error;
|
||||
# Only allowing requests with GET method
|
||||
# Check it here, since we still want list preference handlers to work
|
||||
http_405 qw(GET) if $ENV{"REQUEST_METHOD"} ne "GET";
|
||||
$error = check_get;
|
||||
# If an error occurs
|
||||
if (defined $error) {
|
||||
html_page $error;
|
||||
|
||||
# Display the page
|
||||
} else {
|
||||
html_page retrieve_status;
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
# check_get: Check the GET arguments
|
||||
sub check_get() {
|
||||
local ($_, %_);
|
||||
# Only allowing to run on HTTPS
|
||||
http_403 if !is_https;
|
||||
# List handler handles its own error
|
||||
# OK
|
||||
return;
|
||||
}
|
||||
|
||||
# html_page: Display the page
|
||||
sub html_page($) {
|
||||
local ($_, %_);
|
||||
my ($status, $LIST, $page_param);
|
||||
$status = $_[0];
|
||||
# List the available items
|
||||
$_ = list_type;
|
||||
if ($_ eq "cashsum") {
|
||||
$LIST = new Selima::List::Accounting::Reports::Cash::Summary;
|
||||
} elsif ($_ eq "ldgr") {
|
||||
$LIST = new Selima::List::Accounting::Reports::Ledger;
|
||||
} elsif ($_ eq "ldgrsum") {
|
||||
$LIST = new Selima::List::Accounting::Reports::Ledger::Summary;
|
||||
} elsif ($_ eq "journal") {
|
||||
$LIST = new Selima::List::Accounting::Reports::Journal;
|
||||
} elsif ($_ eq "tb") {
|
||||
$LIST = new Selima::List::Accounting::Reports::TriBlnc;
|
||||
} elsif ($_ eq "incmstat") {
|
||||
$LIST = new Selima::List::Accounting::Reports::IncmStat;
|
||||
} elsif ($_ eq "blncshet") {
|
||||
$LIST = new Selima::List::Accounting::Reports::BlncShet;
|
||||
} elsif ($_ eq "search") {
|
||||
$LIST = new Selima::List::Accounting::Reports::Search;
|
||||
} else {
|
||||
$LIST = new Selima::List::Accounting::Reports::Cash;
|
||||
}
|
||||
# Return the data as a CSV file
|
||||
return $LIST->html if $LIST->{"iscsv"};
|
||||
# Ordinary list
|
||||
html_header $LIST->{"title"}, $LIST->page_param;
|
||||
html_errmsg $status;
|
||||
$LIST->html;
|
||||
html_footer;
|
||||
return;
|
||||
}
|
||||
Reference in New Issue
Block a user