Initial commit.
This commit is contained in:
145
htdocs/wov/magicat/archive/cgi-bin/guestbook.cgi
Executable file
145
htdocs/wov/magicat/archive/cgi-bin/guestbook.cgi
Executable file
@@ -0,0 +1,145 @@
|
||||
#! /usr/bin/perl -w
|
||||
# Woman's Voice
|
||||
# 1-guestbook.cgi: The guestbook.
|
||||
|
||||
# Copyright (c) 2003-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: 2003-04-06
|
||||
|
||||
use 5.008;
|
||||
use utf8;
|
||||
use strict;
|
||||
use warnings;
|
||||
use lib $ENV{"DOCUMENT_ROOT"} . qw(/magicat/lib/perl5);
|
||||
use Selima::wov;
|
||||
local $SIG{"__DIE__"} = \&http_500;
|
||||
my $d = new Selima::Destroy;
|
||||
# Prototype declaration
|
||||
sub main();
|
||||
sub check_get();
|
||||
sub check_post();
|
||||
sub html_page($);
|
||||
sub html_foreword();
|
||||
|
||||
initenv(-session => 0,
|
||||
-this_table => "guestbook",
|
||||
-dbi_lock => {"guestbook" => LOCK_EX},
|
||||
-lastmod => 1,
|
||||
-page_param => {"keywords" => N_("your voice"),
|
||||
"class" => "guestbook",
|
||||
"javascripts" => [qw(/scripts/guestbook.js)]});
|
||||
|
||||
main;
|
||||
exit 0;
|
||||
|
||||
sub main() {
|
||||
local ($_, %_);
|
||||
my ($error, $processor);
|
||||
|
||||
# If the request is a GET query
|
||||
if ($ENV{"REQUEST_METHOD"} ne "POST") {
|
||||
$error = check_get;
|
||||
# If an error occurs
|
||||
if (defined $error) {
|
||||
html_page $error;
|
||||
|
||||
# Display the page
|
||||
} else {
|
||||
html_page retrieve_status;
|
||||
}
|
||||
|
||||
# If a form was POSTed from the client
|
||||
} else {
|
||||
$error = check_post;
|
||||
# If an error occurs
|
||||
if (defined $error) {
|
||||
error_redirect $error;
|
||||
|
||||
# Else, save the data
|
||||
} else {
|
||||
$processor = new Selima::wov::Processor::Guestbook::Public($POST);
|
||||
$processor->process;
|
||||
http_303 $REQUEST_FILE;
|
||||
}
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
# check_get: Check the GET arguments
|
||||
sub check_get() {
|
||||
local ($_, %_);
|
||||
# Old styled page number
|
||||
http_301 $REQUEST_FILE if defined $GET->param("no");
|
||||
# List handler handles its own error
|
||||
return;
|
||||
}
|
||||
|
||||
# check_post: Check the POSTed form
|
||||
sub check_post() {
|
||||
local ($_, %_);
|
||||
my ($checker, $error);
|
||||
# Run the checker
|
||||
$checker = new Selima::wov::Checker::Guestbook::Public(curform);
|
||||
$error = $checker->check(qw(message name identity location
|
||||
email url flood dup spam));
|
||||
return $error if defined $error;
|
||||
# OK
|
||||
return;
|
||||
}
|
||||
|
||||
# html_page: Display the page
|
||||
sub html_page($) {
|
||||
local ($_, %_);
|
||||
my ($status, $LIST, $FORM, $args);
|
||||
$status = $_[0];
|
||||
$FORM = new Selima::wov::Form::Guestbook::Public($status);
|
||||
$LIST = new Selima::wov::List::Guestbook::Public;
|
||||
$args = $LIST->page_param;
|
||||
html_header "妳的女聲", "Your Voice", $args;
|
||||
html_foreword;
|
||||
html_errmsg $status;
|
||||
$FORM->html;
|
||||
$LIST->html;
|
||||
html_footer $args;
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
##################################
|
||||
# Subroutines to manage the data #
|
||||
##################################
|
||||
# html_foreword: Print the HTML foreword
|
||||
sub html_foreword() {
|
||||
local ($_, %_);
|
||||
print << "EOT";
|
||||
<div class="intro">
|
||||
<p>發聲就是政治,是權力,是對主體性的要求。</p>
|
||||
|
||||
<p>女聲就是女人的聲音。聲音有的好聽,有的不好聽,有的悅耳,有的嘈雜。
|
||||
也許\是學者、是政要、是學生、是女兒、是媽媽、是女同性戀、是雙性戀、是
|
||||
女工、是菲傭、是公娼、是私娼、是雛妓、是打工辣妹、是家庭主婦、是心理
|
||||
女性。可能都是,也可能都不是。這些都是女人,她們的聲音都同等重要,在
|
||||
差異中尋求最適合自己的生存策略。</p>
|
||||
|
||||
<p>更重要的是,身為女人,是政治行動,不只是天生的命運。</p>
|
||||
|
||||
</div>
|
||||
|
||||
EOT
|
||||
return;
|
||||
}
|
||||
|
||||
no utf8;
|
||||
121
htdocs/wov/magicat/archive/cgi-bin/subs_counter.cgi
Executable file
121
htdocs/wov/magicat/archive/cgi-bin/subs_counter.cgi
Executable file
@@ -0,0 +1,121 @@
|
||||
#! /usr/bin/perl -w
|
||||
# Woman's Voice
|
||||
# 1-subs_counter.cgi: The subscriber counter.
|
||||
|
||||
# Copyright (c) 2003-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: 2003-05-17
|
||||
|
||||
use 5.008;
|
||||
use strict;
|
||||
use warnings;
|
||||
use lib $ENV{"DOCUMENT_ROOT"} . qw(/magicat/lib/perl5);
|
||||
use Selima::wov;
|
||||
local $SIG{"__DIE__"} = \&http_500;
|
||||
my $d = new Selima::Destroy;
|
||||
# Prototype declaration
|
||||
sub main();
|
||||
sub get_counter();
|
||||
sub html_image($);
|
||||
|
||||
use Fcntl qw(:flock :seek);
|
||||
use GD;
|
||||
use IO::NestedCapture qw(CAPTURE_STDOUT);
|
||||
|
||||
use constant DATA_FILE => "/var/lib/mailman/lists/wov/config.pck";
|
||||
use constant COUNTER_PROG => "/usr/libexec/total_members";
|
||||
use constant LISTNAME => "wov";
|
||||
use vars qw(@FGCOLOR @BGCOLOR $FONT);
|
||||
@FGCOLOR = (0, 0, 0); # #000000 Black
|
||||
@BGCOLOR = (255, 255, 255); # #FFFFFF White
|
||||
$FONT = gdLargeFont;
|
||||
use constant TRANSPARENT => 1;
|
||||
initenv( -allowed => [qw(GET HEAD)],
|
||||
-session => 0,
|
||||
-dbi => DBI_NONE,
|
||||
-lastmod => 1,
|
||||
-lmfiles => [DATA_FILE],
|
||||
-multilang => 0);
|
||||
|
||||
use vars qw($COUNTER $MTIME);
|
||||
|
||||
main;
|
||||
exit 0;
|
||||
|
||||
sub main() {
|
||||
local ($_, %_);
|
||||
|
||||
get_counter();
|
||||
html_image($COUNTER);
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
# get_counter: Get the subscriber counter
|
||||
sub get_counter() {
|
||||
local ($_, %_);
|
||||
my $OUT;
|
||||
|
||||
# Obtain the mtime of the subscriber database file
|
||||
$_ = (stat DATA_FILE)[9];
|
||||
# We should update the counter
|
||||
if (!defined $MTIME || $MTIME != $_) {
|
||||
# Update the timestamp
|
||||
$MTIME = $_;
|
||||
@_ = (COUNTER_PROG, LISTNAME);
|
||||
open $OUT, "-|", @_ or http_500 COUNTER_PROG . ": $!";
|
||||
defined($COUNTER = <$OUT>) or http_500 COUNTER_PROG . ": $!";
|
||||
close $OUT or http_500 COUNTER_PROG . ": $!";
|
||||
chomp $COUNTER;
|
||||
}
|
||||
|
||||
return $COUNTER;
|
||||
}
|
||||
|
||||
# html_image: Make the image from the counter value
|
||||
sub html_image($) {
|
||||
local $_;
|
||||
my ($counter, $image, $width, $height, $fgcolor, $bgcolor);
|
||||
$counter = $_[0];
|
||||
|
||||
# Group the counter with commas at thousand digits.
|
||||
$counter = fmtno($counter);
|
||||
|
||||
# Initialize the image object
|
||||
# Get the width and height
|
||||
$width = $FONT->width * (length $counter);
|
||||
$height = $FONT->height;
|
||||
# Create an image object
|
||||
$image = GD::Image->new($width, $height);
|
||||
# Create the forground/background color objects
|
||||
$fgcolor = $image->colorAllocate(@FGCOLOR);
|
||||
$bgcolor = $image->colorAllocate(@BGCOLOR);
|
||||
|
||||
# Draw the image
|
||||
# Set the transparent background
|
||||
$image->transparent($bgcolor) if TRANSPARENT;
|
||||
# Paint the background
|
||||
$image->filledRectangle(0, 0, $width, $height, $bgcolor);
|
||||
# Write the text
|
||||
$image->string($FONT, 0, 0, $counter, $fgcolor);
|
||||
|
||||
# Output
|
||||
$CONTENT_TYPE = "image/png";
|
||||
binmode IO::NestedCapture->instance->{"STDOUT_current"}[-1], ":raw";
|
||||
print $image->png;
|
||||
|
||||
return;
|
||||
}
|
||||
242
htdocs/wov/magicat/archive/magicat/cgi-bin/acctrecs.cgi
Executable file
242
htdocs/wov/magicat/archive/magicat/cgi-bin/acctrecs.cgi
Executable file
@@ -0,0 +1,242 @@
|
||||
#! /usr/bin/perl -w
|
||||
# Woman's Voice
|
||||
# acctrecs.cgi: The accounting record administration.
|
||||
|
||||
# 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::wov;
|
||||
local $SIG{"__DIE__"} = \&http_500;
|
||||
my $d = new Selima::Destroy;
|
||||
# Prototype declaration
|
||||
sub main();
|
||||
sub check_get();
|
||||
sub check_post();
|
||||
sub html_page($);
|
||||
sub fetch_curitem();
|
||||
sub import_seltrx($);
|
||||
sub import_selsubj($);
|
||||
|
||||
initenv(-restricted => 1,
|
||||
-this_table => "acctrecs",
|
||||
-dbi_lock => {"acctrecs" => LOCK_EX,
|
||||
"accttrx" => LOCK_SH,
|
||||
"acctsubj" => LOCK_SH},
|
||||
-lastmod => 1,
|
||||
-page_param => {"keywords" => N_("accounting")});
|
||||
|
||||
main;
|
||||
exit 0;
|
||||
|
||||
sub main() {
|
||||
local ($_, %_);
|
||||
my ($error, $success, $processor);
|
||||
|
||||
# If the request is a GET query
|
||||
if ($ENV{"REQUEST_METHOD"} ne "POST") {
|
||||
$error = check_get;
|
||||
# If an error occurs
|
||||
if (defined $error) {
|
||||
html_page $error;
|
||||
|
||||
# Display the page
|
||||
} else {
|
||||
html_page retrieve_status;
|
||||
}
|
||||
|
||||
# If a form was POSTed from the client
|
||||
} else {
|
||||
$error = check_post;
|
||||
# If an error occurs
|
||||
if (defined $error) {
|
||||
error_redirect $error;
|
||||
|
||||
# Else, save the data
|
||||
} else {
|
||||
$processor = new Selima::Processor::AcctRec($POST);
|
||||
$success = $processor->process;
|
||||
success_redirect $success;
|
||||
}
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
# check_get: Check the GET arguments
|
||||
sub check_get() {
|
||||
local ($_, %_);
|
||||
my $error;
|
||||
# Only allowing to run on HTTPS
|
||||
http_403 if !is_https;
|
||||
|
||||
# A form is requested
|
||||
if (is_form) {
|
||||
$_ = form_type;
|
||||
# A form to create a new item
|
||||
if ($_ eq "new") {
|
||||
# Nothing to check on a new form
|
||||
|
||||
# A form to edit a current item
|
||||
} elsif ($_ eq "cur") {
|
||||
# Check at fetch_curitem()
|
||||
$error = fetch_curitem;
|
||||
return $error if defined $error;
|
||||
|
||||
# A form to delete a current item
|
||||
} elsif ($_ eq "del") {
|
||||
# Check at fetch_curitem()
|
||||
$error = fetch_curitem;
|
||||
return $error if defined $error;
|
||||
|
||||
# Not a valid form
|
||||
} else {
|
||||
return {"msg"=>N_("Incorrect form: [_1]."),
|
||||
"margs"=>[$_],
|
||||
"isform"=>0};
|
||||
}
|
||||
}
|
||||
# List handler handles its own error
|
||||
# OK
|
||||
return;
|
||||
}
|
||||
|
||||
# check_post: Check the POSTed form
|
||||
sub check_post() {
|
||||
local ($_, %_);
|
||||
my ($checker, $error);
|
||||
# Only allowing to run on HTTPS
|
||||
http_403 if !is_https;
|
||||
$_ = form_type;
|
||||
# A form to create a new item
|
||||
if ($_ eq "new") {
|
||||
# Run the checker
|
||||
$checker = new Selima::Checker::AcctRec(curform);
|
||||
$checker->redir(qw(seltrx deltrx selsubj delsubj));
|
||||
$error = $checker->check(qw(trx type ord subj summary amount));
|
||||
return $error if defined $error;
|
||||
|
||||
# A form to edit a current item
|
||||
} elsif ($_ eq "cur") {
|
||||
# Check at fetch_curitem()
|
||||
$error = fetch_curitem;
|
||||
return $error if defined $error;
|
||||
# Run the checker
|
||||
$checker = new Selima::Checker::AcctRec(curform);
|
||||
$checker->redir(qw(del seltrx deltrx selsubj delsubj));
|
||||
$error = $checker->check(qw(trx type ord subj summary amount));
|
||||
return $error if defined $error;
|
||||
|
||||
# A form to delete a current item
|
||||
} elsif ($_ eq "del") {
|
||||
# Check at fetch_curitem()
|
||||
$error = fetch_curitem;
|
||||
return $error if defined $error;;
|
||||
# Run the checker
|
||||
$checker = new Selima::Checker::AcctRec(curform);
|
||||
$checker->redir(qw(cancel));
|
||||
|
||||
# Not a valid form
|
||||
} else {
|
||||
return {"msg"=>N_("Incorrect form: [_1]."),
|
||||
"margs"=>[$_],
|
||||
"isform"=>0};
|
||||
}
|
||||
# OK
|
||||
return;
|
||||
}
|
||||
|
||||
# html_page: Display the page
|
||||
sub html_page($) {
|
||||
local ($_, %_);
|
||||
my ($status, $LIST, $FORM);
|
||||
$status = $_[0];
|
||||
# A form is requested
|
||||
if (is_form $status) {
|
||||
$FORM = new Selima::Form::AcctRec($status);
|
||||
html_header $FORM->{"title"};
|
||||
html_errmsg $status;
|
||||
$FORM->html;
|
||||
html_footer;
|
||||
|
||||
# List the available items
|
||||
} else {
|
||||
$LIST = new Selima::List::Accounting::Records;
|
||||
html_header $LIST->{"title"}, undef, $LIST->page_param;
|
||||
html_errmsg $status;
|
||||
$LIST->html;
|
||||
html_footer;
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
##################################
|
||||
# Subroutines to manage the data #
|
||||
##################################
|
||||
# fetch_curitem: Fetch the current item
|
||||
sub fetch_curitem() {
|
||||
local ($_, %_);
|
||||
my ($sn, $FORM, $sth, $sql);
|
||||
|
||||
# Return if fetched before
|
||||
return if scalar(keys %CURRENT) > 0;
|
||||
|
||||
# Obtain the current form
|
||||
$FORM = curform;
|
||||
# No item specified
|
||||
return {"msg"=>N_("Please select the accounting record."),
|
||||
"isform"=>0}
|
||||
if !defined $FORM->param("sn");
|
||||
$sn = $FORM->param("sn");
|
||||
|
||||
# Find the record
|
||||
%CURRENT = fetchrec $sn, $THIS_TABLE;
|
||||
# If this record exist
|
||||
return {"msg"=>N_("This accounting record does not exist anymore. Please select another one."),
|
||||
"isform"=>0}
|
||||
if scalar(keys %CURRENT) == 0;
|
||||
|
||||
$CURRENT{"type"} = $CURRENT{"credit"}? "credit": "debit";
|
||||
|
||||
# OK
|
||||
return;
|
||||
}
|
||||
|
||||
# import_seltrx: Import the selected accounting transaction into the retrieved form
|
||||
sub import_seltrx($) {
|
||||
local ($_, %_);
|
||||
my $FORM;
|
||||
$FORM = $_[0];
|
||||
$FORM->param("trx", $GET->param("selsn"))
|
||||
if defined $GET->param("selsn")
|
||||
&& check_sn_in ${$GET->param_fetch("selsn")}[0], "accttrx";
|
||||
return;
|
||||
}
|
||||
|
||||
# import_selsubj: Import the selected accounting subject into the retrieved form
|
||||
sub import_selsubj($) {
|
||||
local ($_, %_);
|
||||
my $FORM;
|
||||
$FORM = $_[0];
|
||||
$FORM->param("subj", $GET->param("selsn"))
|
||||
if defined $GET->param("selsn")
|
||||
&& check_sn_in ${$GET->param_fetch("selsn")}[0], "acctsubj";
|
||||
return;
|
||||
}
|
||||
107
htdocs/wov/magicat/archive/magicat/cgi-bin/acctreps.cgi
Executable file
107
htdocs/wov/magicat/archive/magicat/cgi-bin/acctreps.cgi
Executable file
@@ -0,0 +1,107 @@
|
||||
#! /usr/bin/perl -w
|
||||
# Woman's Voice
|
||||
# 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::wov;
|
||||
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"}, undef, $LIST->page_param;
|
||||
html_errmsg $status;
|
||||
$LIST->html;
|
||||
html_footer;
|
||||
return;
|
||||
}
|
||||
292
htdocs/wov/magicat/archive/magicat/cgi-bin/acctsubj.cgi
Executable file
292
htdocs/wov/magicat/archive/magicat/cgi-bin/acctsubj.cgi
Executable file
@@ -0,0 +1,292 @@
|
||||
#! /usr/bin/perl -w
|
||||
# Woman's Voice
|
||||
# acctsubj.cgi: The accounting subject administraion.
|
||||
|
||||
# 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::wov;
|
||||
local $SIG{"__DIE__"} = \&http_500;
|
||||
my $d = new Selima::Destroy;
|
||||
# Prototype declaration
|
||||
sub main();
|
||||
sub check_get();
|
||||
sub check_post();
|
||||
sub html_page($);
|
||||
sub fetch_curitem();
|
||||
sub import_selparent($);
|
||||
|
||||
initenv(-restricted => 1,
|
||||
-this_table => "acctsubj",
|
||||
-dbi_lock => {"acctsubj" => LOCK_EX,
|
||||
"acctrecs" => LOCK_SH},
|
||||
-lastmod => 1,
|
||||
-page_param => {"keywords" => N_("accounting")});
|
||||
|
||||
main;
|
||||
exit 0;
|
||||
|
||||
sub main() {
|
||||
local ($_, %_);
|
||||
my ($error, $success, $processor);
|
||||
|
||||
# If the request is a GET query
|
||||
if ($ENV{"REQUEST_METHOD"} ne "POST") {
|
||||
$error = check_get;
|
||||
# If an error occurs
|
||||
if (defined $error) {
|
||||
html_page $error;
|
||||
|
||||
# Display the page
|
||||
} else {
|
||||
html_page retrieve_status;
|
||||
}
|
||||
|
||||
# If a form was POSTed from the client
|
||||
} else {
|
||||
$error = check_post;
|
||||
# If an error occurs
|
||||
if (defined $error) {
|
||||
error_redirect $error;
|
||||
|
||||
# Else, save the data
|
||||
} else {
|
||||
$processor = new Selima::Processor::AcctSubj($POST);
|
||||
$success = $processor->process;
|
||||
success_redirect $success;
|
||||
}
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
# check_get: Check the GET arguments
|
||||
sub check_get() {
|
||||
local ($_, %_);
|
||||
my $error;
|
||||
# Only allowing to run on HTTPS
|
||||
http_403 if !is_https;
|
||||
|
||||
# A form is requested
|
||||
if (is_form) {
|
||||
$_ = form_type;
|
||||
# A form to create a new item
|
||||
if ($_ eq "new") {
|
||||
# Start from the default language
|
||||
return {"msg"=>N_("Please add a new accounting subject from [_1]."),
|
||||
"margs"=>["_DEFAULT_LANG"],
|
||||
"isform"=>0}
|
||||
if getlang ne $DEFAULT_LANG;
|
||||
|
||||
# A form to edit a current item
|
||||
} elsif ($_ eq "cur") {
|
||||
# Check at fetch_curitem()
|
||||
$error = fetch_curitem;
|
||||
return $error if defined $error;
|
||||
|
||||
# A form to delete a current item
|
||||
} elsif ($_ eq "del") {
|
||||
# Check at fetch_curitem()
|
||||
$error = fetch_curitem;
|
||||
return $error if defined $error;
|
||||
return {"msg"=>N_("This accounting subject has [numerate,_1,an accounting sub-subject,accounting sub-subjects]. It cannot be deleted. To delete the subject, [numerate,_1,its accounting sub-subject,all of its accounting sub-subjects] must first be deleted."),
|
||||
"margs"=>[$CURRENT{"ssubcount"}],
|
||||
"isform"=>0}
|
||||
if $CURRENT{"ssubcount"} > 0;
|
||||
return {"msg"=>N_("This accounting subject has [numerate,_1,an accounting record,accounting records]. It cannot be deleted. To delete the subject, [numerate,_1,its accounting record,all of its accounting records] must first be deleted."),
|
||||
"margs"=>[$CURRENT{"reccount"}],
|
||||
"isform"=>0}
|
||||
if $CURRENT{"reccount"} > 0;
|
||||
|
||||
# Not a valid form
|
||||
} else {
|
||||
return {"msg"=>N_("Incorrect form: [_1]."),
|
||||
"margs"=>[$_],
|
||||
"isform"=>0};
|
||||
}
|
||||
}
|
||||
# List handler handles its own error
|
||||
# OK
|
||||
return;
|
||||
}
|
||||
|
||||
# check_post: Check the POSTed form
|
||||
sub check_post() {
|
||||
local ($_, %_);
|
||||
my ($checker, $error);
|
||||
# Only allowing to run on HTTPS
|
||||
http_403 if !is_https;
|
||||
$_ = form_type;
|
||||
# A form to create a new item
|
||||
if ($_ eq "new") {
|
||||
# Start from the default language
|
||||
return {"msg"=>N_("Please add a new accounting subject from [_1]."),
|
||||
"margs"=>["_DEFAULT_LANG"],
|
||||
"isform"=>0}
|
||||
if getlang ne $DEFAULT_LANG;
|
||||
# Run the checker
|
||||
$checker = new Selima::Checker::AcctSubj(curform);
|
||||
$checker->redir(qw(selparent delparent));
|
||||
$error = $checker->check(qw(parent code title));
|
||||
return $error if defined $error;
|
||||
|
||||
# A form to edit a current item
|
||||
} elsif ($_ eq "cur") {
|
||||
# Check at fetch_curitem()
|
||||
$error = fetch_curitem;
|
||||
return $error if defined $error;
|
||||
# Run the checker
|
||||
$checker = new Selima::Checker::AcctSubj(curform);
|
||||
$checker->redir(qw(del zhsync selparent delparent));
|
||||
$error = $checker->check(qw(parent code title));
|
||||
return $error if defined $error;
|
||||
|
||||
# A form to delete a current item
|
||||
} elsif ($_ eq "del") {
|
||||
# Check at fetch_curitem()
|
||||
$error = fetch_curitem;
|
||||
return $error if defined $error;;
|
||||
# Run the checker
|
||||
$checker = new Selima::Checker::AcctSubj(curform);
|
||||
$checker->redir(qw(cancel));
|
||||
return {"msg"=>N_("This accounting subject has [numerate,_1,an accounting sub-subject,accounting sub-subjects]. It cannot be deleted. To delete the subject, [numerate,_1,its accounting sub-subject,all of its accounting sub-subjects] must first be deleted."),
|
||||
"margs"=>[$CURRENT{"ssubcount"}],
|
||||
"isform"=>0}
|
||||
if $CURRENT{"ssubcount"} > 0;
|
||||
return {"msg"=>N_("This accounting subject has [numerate,_1,an accounting record,accounting records]. It cannot be deleted. To delete the subject, [numerate,_1,its accounting record,all of its accounting records] must first be deleted."),
|
||||
"margs"=>[$CURRENT{"reccount"}],
|
||||
"isform"=>0}
|
||||
if $CURRENT{"reccount"} > 0;
|
||||
|
||||
# Not a valid form
|
||||
} else {
|
||||
return {"msg"=>N_("Incorrect form: [_1]."),
|
||||
"margs"=>[$_],
|
||||
"isform"=>0};
|
||||
}
|
||||
# OK
|
||||
return;
|
||||
}
|
||||
|
||||
# html_page: Display the page
|
||||
sub html_page($) {
|
||||
local ($_, %_);
|
||||
my ($status, $LIST, $FORM);
|
||||
$status = $_[0];
|
||||
# A form is requested
|
||||
if (is_form $status) {
|
||||
$FORM = new Selima::Form::AcctSubj($status);
|
||||
html_header $FORM->{"title"};
|
||||
html_errmsg $status;
|
||||
$FORM->html;
|
||||
html_footer;
|
||||
|
||||
# List the available items
|
||||
} else {
|
||||
if (list_type eq "lastlv") {
|
||||
$LIST = new Selima::List::Accounting::Subjects::LastLv;
|
||||
} else {
|
||||
$LIST = new Selima::List::Accounting::Subjects;
|
||||
}
|
||||
html_header $LIST->{"title"}, undef, $LIST->page_param;
|
||||
html_errmsg $status;
|
||||
$LIST->html;
|
||||
html_footer;
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
##################################
|
||||
# Subroutines to manage the data #
|
||||
##################################
|
||||
# fetch_curitem: Fetch the current item
|
||||
sub fetch_curitem() {
|
||||
local ($_, %_);
|
||||
my ($sn, $FORM, $sth, $sql, $row);
|
||||
my ($lang, $lndb, $lndbdef, $title);
|
||||
|
||||
# Return if fetched before
|
||||
return if scalar(keys %CURRENT) > 0;
|
||||
|
||||
# Obtain the current form
|
||||
$FORM = curform;
|
||||
# No item specified
|
||||
return {"msg"=>N_("Please select the accounting subject."),
|
||||
"isform"=>0}
|
||||
if !defined $FORM->param("sn");
|
||||
$sn = $FORM->param("sn");
|
||||
|
||||
# Find the record
|
||||
%CURRENT = fetchrec $sn, $THIS_TABLE;
|
||||
# If this record exist
|
||||
return {"msg"=>N_("This accounting subject does not exist anymore. Please select another one."),
|
||||
"isform"=>0}
|
||||
if scalar(keys %CURRENT) == 0;
|
||||
|
||||
$lang = getlang;
|
||||
$lndb = getlang LN_DATABASE;
|
||||
$lndbdef = ln $DEFAULT_LANG, LN_DATABASE;
|
||||
|
||||
# Obtain the belonging subjects list
|
||||
@_ = qw();
|
||||
push @_, "sn AS sn";
|
||||
if (@ALL_LINGUAS > 1) {
|
||||
$title = $lang eq $DEFAULT_LANG? "title_$lndb":
|
||||
"COALESCE(title_$lndb, title_$lndbdef)";
|
||||
} else {;
|
||||
$title = "title";
|
||||
}
|
||||
push @_, $DBH->strcat("code", "' '", $title) . " AS title";
|
||||
$sql = "SELECT " . join(", ", @_) . " FROM acctsubj"
|
||||
. " WHERE parent=$sn"
|
||||
. " ORDER BY code;\n";
|
||||
$sth = $DBH->prepare($sql);
|
||||
$sth->execute;
|
||||
$CURRENT{"ssubcount"} = $sth->rows;
|
||||
for ($_ = 0; $_ < $CURRENT{"ssubcount"}; $_++) {
|
||||
$row = $sth->fetchrow_hashref;
|
||||
$CURRENT{"ssub$_" . "sn"} = $$row{"sn"};
|
||||
$CURRENT{"ssub$_" . "title"} = $$row{"title"};
|
||||
}
|
||||
|
||||
# Obtain the belonging records list
|
||||
$sql = "SELECT sn FROM acctrecs"
|
||||
. " WHERE subj=$sn;\n";
|
||||
$sth = $DBH->prepare($sql);
|
||||
$sth->execute;
|
||||
$CURRENT{"reccount"} = $sth->rows;
|
||||
|
||||
# OK
|
||||
return;
|
||||
}
|
||||
|
||||
# import_selparent: Import the selected parent into the retrieved form
|
||||
sub import_selparent($) {
|
||||
local ($_, %_);
|
||||
my $FORM;
|
||||
$FORM = $_[0];
|
||||
if ( defined $GET->param("selsn")
|
||||
&& check_sn_in ${$GET->param_fetch("selsn")}[0], "acctsubj") {
|
||||
$FORM->param("parent", $GET->param("selsn"));
|
||||
$FORM->param("topmost", "false");
|
||||
}
|
||||
return;
|
||||
}
|
||||
278
htdocs/wov/magicat/archive/magicat/cgi-bin/accttrx.cgi
Executable file
278
htdocs/wov/magicat/archive/magicat/cgi-bin/accttrx.cgi
Executable file
@@ -0,0 +1,278 @@
|
||||
#! /usr/bin/perl -w
|
||||
# Woman's Voice
|
||||
# accttrx.cgi: The accounting transaction administraion.
|
||||
|
||||
# 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::wov;
|
||||
local $SIG{"__DIE__"} = \&http_500;
|
||||
my $d = new Selima::Destroy;
|
||||
# Prototype declaration
|
||||
sub main();
|
||||
sub check_get();
|
||||
sub check_post();
|
||||
sub html_page($);
|
||||
sub fetch_curitem();
|
||||
sub import_selsubj($);
|
||||
|
||||
initenv(-restricted => 1,
|
||||
-this_table => "accttrx",
|
||||
-dbi_lock => {"accttrx" => LOCK_EX,
|
||||
"acctrecs" => LOCK_EX,
|
||||
"acctsubj" => LOCK_SH},
|
||||
-lastmod => 1,
|
||||
-page_param => {"keywords" => N_("accounting"),
|
||||
"javascripts" => [qw(/scripts/accounting.js)]});
|
||||
|
||||
main;
|
||||
exit 0;
|
||||
|
||||
sub main() {
|
||||
local ($_, %_);
|
||||
my ($error, $success, $processor);
|
||||
|
||||
# If the request is a GET query
|
||||
if ($ENV{"REQUEST_METHOD"} ne "POST") {
|
||||
$error = check_get;
|
||||
# If an error occurs
|
||||
if (defined $error) {
|
||||
html_page $error;
|
||||
|
||||
# Display the page
|
||||
} else {
|
||||
html_page retrieve_status;
|
||||
}
|
||||
|
||||
# If a form was POSTed from the client
|
||||
} else {
|
||||
$error = check_post;
|
||||
# If an error occurs
|
||||
if (defined $error) {
|
||||
error_redirect $error;
|
||||
|
||||
# Else, save the data
|
||||
} else {
|
||||
$processor = new Selima::Processor::AcctTrx($POST);
|
||||
$success = $processor->process;
|
||||
success_redirect $success;
|
||||
}
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
# check_get: Check the GET arguments
|
||||
sub check_get() {
|
||||
local ($_, %_);
|
||||
my $error;
|
||||
# Only allowing to run on HTTPS
|
||||
http_403 if !is_https;
|
||||
|
||||
# A form is requested
|
||||
if (is_form) {
|
||||
$_ = form_type;
|
||||
# A form to create a new item
|
||||
if ($_ eq "new") {
|
||||
# Nothing to check on a new form
|
||||
|
||||
# A form to edit a current item
|
||||
} elsif ($_ eq "cur") {
|
||||
# Check at fetch_curitem()
|
||||
$error = fetch_curitem;
|
||||
return $error if defined $error;
|
||||
|
||||
# A form to delete a current item
|
||||
} elsif ($_ eq "del") {
|
||||
# Check at fetch_curitem()
|
||||
$error = fetch_curitem;
|
||||
return $error if defined $error;
|
||||
|
||||
# Not a valid form
|
||||
} else {
|
||||
return {"msg"=>N_("Incorrect form: [_1]."),
|
||||
"margs"=>[$_],
|
||||
"isform"=>0};
|
||||
}
|
||||
}
|
||||
# List handler handles its own error
|
||||
# OK
|
||||
return;
|
||||
}
|
||||
|
||||
# check_post: Check the POSTed form
|
||||
sub check_post() {
|
||||
local ($_, %_);
|
||||
my ($checker, $error);
|
||||
# Only allowing to run on HTTPS
|
||||
http_403 if !is_https;
|
||||
$_ = form_type;
|
||||
# A form to create a new item
|
||||
if ($_ eq "new") {
|
||||
# Run the checker
|
||||
$checker = new Selima::Checker::AcctTrx(curform);
|
||||
$checker->redir(qw(cnvttrans selsubj));
|
||||
$error = $checker->check(qw(date ord note recs));
|
||||
return $error if defined $error;
|
||||
|
||||
# A form to edit a current item
|
||||
} elsif ($_ eq "cur") {
|
||||
# Check at fetch_curitem()
|
||||
$error = fetch_curitem;
|
||||
return $error if defined $error;
|
||||
# Run the checker
|
||||
$checker = new Selima::Checker::AcctTrx(curform);
|
||||
$checker->redir(qw(del cnvttrans selsubj));
|
||||
$error = $checker->check(qw(date ord note recs));
|
||||
return $error if defined $error;
|
||||
|
||||
# A form to delete a current item
|
||||
} elsif ($_ eq "del") {
|
||||
# Check at fetch_curitem()
|
||||
$error = fetch_curitem;
|
||||
return $error if defined $error;;
|
||||
# Run the checker
|
||||
$checker = new Selima::Checker::AcctTrx(curform);
|
||||
$checker->redir(qw(cancel));
|
||||
|
||||
# Not a valid form
|
||||
} else {
|
||||
return {"msg"=>N_("Incorrect form: [_1]."),
|
||||
"margs"=>[$_],
|
||||
"isform"=>0};
|
||||
}
|
||||
# OK
|
||||
return;
|
||||
}
|
||||
|
||||
# html_page: Display the page
|
||||
sub html_page($) {
|
||||
local ($_, %_);
|
||||
my ($status, $LIST, $FORM);
|
||||
$status = $_[0];
|
||||
# A form is requested
|
||||
if (is_form $status) {
|
||||
$FORM = new Selima::Form::AcctTrx($status);
|
||||
html_header $FORM->{"title"};
|
||||
html_errmsg $status;
|
||||
$FORM->html;
|
||||
html_footer;
|
||||
|
||||
# List the available items
|
||||
} else {
|
||||
$LIST = new Selima::List::Accounting::Transacts;
|
||||
html_header $LIST->{"title"}, undef, $LIST->page_param;
|
||||
html_errmsg $status;
|
||||
$LIST->html;
|
||||
html_footer;
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
##################################
|
||||
# Subroutines to manage the data #
|
||||
##################################
|
||||
# fetch_curitem: Fetch the current item
|
||||
sub fetch_curitem() {
|
||||
local ($_, %_);
|
||||
my ($sn, $FORM, $sth, $sql, $row);
|
||||
|
||||
# Return if fetched before
|
||||
return if scalar(keys %CURRENT) > 0;
|
||||
|
||||
# Obtain the current form
|
||||
$FORM = curform;
|
||||
# No item specified
|
||||
return {"msg"=>N_("Please select the accounting transaction."),
|
||||
"isform"=>0}
|
||||
if !defined $FORM->param("sn");
|
||||
$sn = $FORM->param("sn");
|
||||
|
||||
# Find the record
|
||||
%CURRENT = fetchrec $sn, $THIS_TABLE;
|
||||
# If this record exist
|
||||
return {"msg"=>N_("This accounting transaction does not exist anymore. Please select another one."),
|
||||
"isform"=>0}
|
||||
if scalar(keys %CURRENT) == 0;
|
||||
|
||||
# Obtain the belonging debit records list
|
||||
$sql = "SELECT * FROM acctrecs"
|
||||
. " WHERE trx=$sn"
|
||||
. " AND NOT credit"
|
||||
. " ORDER BY ord;\n";
|
||||
$sth = $DBH->prepare($sql);
|
||||
$sth->execute;
|
||||
$CURRENT{"debtcount"} = $sth->rows;
|
||||
for ($_ = 0; $_ < $CURRENT{"debtcount"}; $_++) {
|
||||
$row = $sth->fetchrow_hashref;
|
||||
$CURRENT{"debt$_" . "sn"} = $$row{"sn"};
|
||||
$CURRENT{"debt$_" . "ord"} = $$row{"ord"};
|
||||
$CURRENT{"debt$_" . "subj"} = $$row{"subj"};
|
||||
$CURRENT{"debt$_" . "summary"} = $$row{"summary"};
|
||||
$CURRENT{"debt$_" . "amount"} = $$row{"amount"};
|
||||
}
|
||||
|
||||
# Obtain the belonging credit records list
|
||||
$sql = "SELECT * FROM acctrecs"
|
||||
. " WHERE trx=$sn"
|
||||
. " AND credit"
|
||||
. " ORDER BY ord;\n";
|
||||
$sth = $DBH->prepare($sql);
|
||||
$sth->execute;
|
||||
$CURRENT{"crdtcount"} = $sth->rows;
|
||||
for ($_ = 0; $_ < $CURRENT{"crdtcount"}; $_++) {
|
||||
$row = $sth->fetchrow_hashref;
|
||||
$CURRENT{"crdt$_" . "sn"} = $$row{"sn"};
|
||||
$CURRENT{"crdt$_" . "ord"} = $$row{"ord"};
|
||||
$CURRENT{"crdt$_" . "subj"} = $$row{"subj"};
|
||||
$CURRENT{"crdt$_" . "summary"} = $$row{"summary"};
|
||||
$CURRENT{"crdt$_" . "amount"} = $$row{"amount"};
|
||||
}
|
||||
|
||||
# Determine the subform type
|
||||
if ( $CURRENT{"debtcount"} == 1
|
||||
&& acctsubj_code($CURRENT{"debt0subj"}) eq ACCTSUBJ_CASH
|
||||
&& !defined $CURRENT{"debt0summary"}) {
|
||||
$CURRENT{"formsub"} = "income";
|
||||
} elsif ( $CURRENT{"crdtcount"} == 1
|
||||
&& acctsubj_code($CURRENT{"crdt0subj"}) eq ACCTSUBJ_CASH
|
||||
&& !defined $CURRENT{"crdt0summary"}) {
|
||||
$CURRENT{"formsub"} = "expense";
|
||||
} else {
|
||||
$CURRENT{"formsub"} = "trans";
|
||||
}
|
||||
|
||||
# OK
|
||||
return;
|
||||
}
|
||||
|
||||
# import_selsubj: Import the selected subject into the retrieved form
|
||||
sub import_selsubj($) {
|
||||
my $FORM;
|
||||
$FORM = $_[0];
|
||||
# Sanity checks
|
||||
return $FORM
|
||||
if !defined $GET->param("selsn")
|
||||
|| !check_sn_in ${$GET->param_fetch("selsn")}[0], "acctsubj"
|
||||
|| !defined $FORM->param("caller_index");
|
||||
$FORM->param($FORM->param("caller_index") . "subj", $GET->param("selsn"));
|
||||
return $FORM;
|
||||
}
|
||||
Reference in New Issue
Block a user