820 lines
34 KiB
Perl
820 lines
34 KiB
Perl
# Selima Website Content Management System
|
|
# AcctTrx.pm: The accounting transaction form.
|
|
|
|
# Copyright (c) 2007-2018 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-20
|
|
|
|
package Selima::Form::AcctTrx;
|
|
use 5.008;
|
|
use strict;
|
|
use warnings;
|
|
use base qw(Selima::Form);
|
|
|
|
use Selima::Accounting;
|
|
use Selima::AddGet;
|
|
use Selima::CommText;
|
|
use Selima::DataVars qw($DBH :requri :scptconf);
|
|
use Selima::FormFunc;
|
|
use Selima::Format;
|
|
use Selima::HTTP;
|
|
use Selima::MarkAbbr;
|
|
use Selima::ShortCut;
|
|
|
|
# new: Initialize the HTML form table displayer
|
|
sub new : method {
|
|
local ($_, %_);
|
|
my ($class, $status, $args, $self);
|
|
($class, $status, $args) = @_;
|
|
$args = {} if !defined $args;
|
|
|
|
# $args must be a hash reference
|
|
http_500 "type of argument 2 must be a hash reference"
|
|
if ref($args) ne "HASH";
|
|
$$args{"type"} = form_type
|
|
if !exists $$args{"type"};
|
|
$$args{"table"} = "accttrx"
|
|
if !exists $$args{"table"};
|
|
$$args{"deltext"} = C_("Delete this accounting transaction")
|
|
if !exists $$args{"deltext"};
|
|
# The hidden columns
|
|
if (!exists $$args{"summary"}) {
|
|
# A form to create a new item
|
|
if ($$args{"type"} eq "new") {
|
|
$$args{"summary"} = C_("This table provides you a form to add a new accounting transaction.");
|
|
# A form to edit a current item
|
|
} elsif ($$args{"type"} eq "cur") {
|
|
$$args{"summary"} = C_("This table provides you a form to edit a current accounting transaction.");
|
|
# A form to delete a current item
|
|
} elsif ($$args{"type"} eq "del") {
|
|
$$args{"summary"} = C_("This table provides you a form to delete an accounting transaction.");
|
|
}
|
|
}
|
|
if (!exists $$args{"cols"}) {
|
|
# A form to create a new item
|
|
if ($$args{"type"} eq "new") {
|
|
$$args{"cols"} = [qw(date ord recs note)];
|
|
# A form to edit a current item
|
|
# A form to delete a current item
|
|
} elsif ($$args{"type"} eq "cur" || $$args{"type"} eq "del") {
|
|
$$args{"cols"} = [qw(sn date ord recs note
|
|
created createdby updated updatedby)];
|
|
}
|
|
}
|
|
$self = $class->SUPER::new($status, $args);
|
|
${$self->{"maxlens"}}{"ord"} = 2;
|
|
# Set the subform type
|
|
if ($$args{"type"} eq "new") {
|
|
$_ = curform;
|
|
$self->{"subtype"} = $_->param("formsub");
|
|
} elsif ($$args{"type"} eq "cur") {
|
|
$self->{"subtype"} = $self->{"form"}->param("formsub");
|
|
} elsif ($$args{"type"} eq "del") {
|
|
$self->{"subtype"} = $self->{"cur"}->param("formsub");
|
|
}
|
|
# Only expense, income or trans are allowed
|
|
http_500 "invalid form sub-type: " . $self->{"type"}
|
|
if $self->{"subtype"} !~ /^(?:expense|income|trans)$/;
|
|
if ($self->{"subtype"} eq "expense" || $self->{"subtype"} eq "income") {
|
|
$self->{"colspan"} = 3;
|
|
} else {
|
|
$self->{"colspan"} = 6;
|
|
}
|
|
$self->{"hidcols"} = [] if !exists $self->{"hidcols"};
|
|
push @{$self->{"hidcols"}}, {
|
|
"name" => "formsub",
|
|
"value" => $self->{"subtype"},
|
|
};
|
|
if ($self->{"type"} eq "cur" && $self->{"subtype"} ne "trans") {
|
|
$self->{"header_buttons"} = [
|
|
{ "name" => undef, "value" => h(C_("Submit")) },
|
|
{ "name" => "confirm", "value" => h(C_("Save")) },
|
|
{ "name" => "del", "value" => h($self->{"deltext"}) },
|
|
{ "name" => "cnvttrans", "value" => h(C_("Convert to a transfer transaction")) }, ];
|
|
$self->{"footer_buttons"} = [
|
|
{ "name" => undef, "value" => h(C_("Submit")) },
|
|
{ "name" => "confirm", "value" => h(C_("Save")) },
|
|
{ "name" => "del", "value" => h($self->{"deltext"}) },
|
|
{ "name" => "cnvttrans", "value" => h(C_("Convert to a transfer transaction")) }, ];
|
|
}
|
|
# A form to create a new item
|
|
if ($self->{"type"} eq "new") {
|
|
if ($self->{"subtype"} eq "expense") {
|
|
$self->{"title"} = C_("Add a New Cache Expense Transaction");
|
|
} elsif ($self->{"subtype"} eq "income") {
|
|
$self->{"title"} = C_("Add a New Cache Income Transaction");
|
|
} elsif ($self->{"subtype"} eq "trans") {
|
|
$self->{"title"} = C_("Add a New Transfer Transaction");
|
|
}
|
|
# A form to edit a current item
|
|
} elsif ($self->{"type"} eq "cur") {
|
|
if ($self->{"subtype"} eq "expense") {
|
|
$self->{"title"} = C_("Edit a Current Cache Expense Transaction");
|
|
} elsif ($self->{"subtype"} eq "income") {
|
|
$self->{"title"} = C_("Edit a Current Cache Income Transaction");
|
|
} elsif ($self->{"subtype"} eq "trans") {
|
|
$self->{"title"} = C_("Edit a Current Transfer Transaction");
|
|
}
|
|
# A form to delete a current item
|
|
} elsif ($self->{"type"} eq "del") {
|
|
if ($self->{"subtype"} eq "expense") {
|
|
$self->{"title"} = C_("Delete a Cache Expense Transaction");
|
|
} elsif ($self->{"subtype"} eq "income") {
|
|
$self->{"title"} = C_("Delete a Cache Income Transaction");
|
|
} elsif ($self->{"subtype"} eq "trans") {
|
|
$self->{"title"} = C_("Delete a Transfer Transaction");
|
|
}
|
|
}
|
|
%_ = $DBH->col_lens("acctrec");
|
|
${$self->{"maxlens"}}{"recsubj"} = $_{"subj"};
|
|
${$self->{"maxlens"}}{"recsummary"} = $_{"summary"};
|
|
${$self->{"maxlens"}}{"recamount"} = $_{"amount"};
|
|
return $self;
|
|
}
|
|
|
|
# _html_coltmpl_ro_loop_rec: Display a read-only record row column
|
|
sub _html_coltmpl_ro_loop_rec : method {
|
|
local ($_, %_);
|
|
local ($_, %_);
|
|
my ($self, $i, $current, $rowhdrs);
|
|
my ($curlsubj, $curlsummary, $curlamount);
|
|
my ($curbsubj, $curbsummary, $curbamount);
|
|
($self, $i) = @_;
|
|
$current = $self->{"cur"};
|
|
$rowhdrs = "threcs";
|
|
$rowhdrs .= " thold" if $self->{"type"} eq "cur";
|
|
|
|
# A form to fill in a cash expense transaction
|
|
if ($self->{"subtype"} eq "expense") {
|
|
$curlsubj = defined($_ = $current->param("debt$i" . "subj"))?
|
|
h_abbr(acctsubj_title $_): "";
|
|
$curlsummary = defined($_ = $current->param("debt$i" . "summary"))?
|
|
h_abbr($_): "";
|
|
$curlamount = defined($_ = $current->param("debt$i" . "amount"))?
|
|
h_abbr(fmtntamount $_): "";
|
|
print << "EOT";
|
|
<tr>
|
|
<td headers="$rowhdrs thcdsubj">$curlsubj</td>
|
|
<td headers="$rowhdrs thcdsummary">$curlsummary</td>
|
|
<td class="amount" headers="$rowhdrs thcdamount">$curlamount</td>
|
|
</tr>
|
|
EOT
|
|
|
|
# A form to fill in a cash income transaction
|
|
} elsif ($self->{"subtype"} eq "income") {
|
|
$curbsubj = defined($_ = $current->param("crdt$i" . "subj"))?
|
|
h_abbr(acctsubj_title $_): "";
|
|
$curbsummary = defined($_ = $current->param("crdt$i" . "summary"))?
|
|
h_abbr($_): "";
|
|
$curbamount = defined($_ = $current->param("crdt$i" . "amount"))?
|
|
h_abbr(fmtntamount $_): "";
|
|
print << "EOT";
|
|
<tr>
|
|
<td headers="$rowhdrs thccsubj">$curbsubj</td>
|
|
<td headers="$rowhdrs thccsummary">$curbsummary</td>
|
|
<td class="amount" headers="$rowhdrs thccamount">$curbamount</td>
|
|
</tr>
|
|
EOT
|
|
|
|
# A form to fill in a transfer transaction
|
|
} elsif ($self->{"subtype"} eq "trans") {
|
|
$curlsubj = defined($_ = $current->param("debt$i" . "subj"))?
|
|
h_abbr(acctsubj_title $_): "";
|
|
$curlsummary = defined($_ = $current->param("debt$i" . "summary"))?
|
|
h_abbr($_): "";
|
|
$curlamount = defined($_ = $current->param("debt$i" . "amount"))?
|
|
h_abbr(fmtntamount $_): "";
|
|
$curbsubj = defined($_ = $current->param("crdt$i" . "subj"))?
|
|
h_abbr(acctsubj_title $_): "";
|
|
$curbsummary = defined($_ = $current->param("crdt$i" . "summary"))?
|
|
h_abbr($_): "";
|
|
$curbamount = defined($_ = $current->param("crdt$i" . "amount"))?
|
|
h_abbr(fmtntamount $_): "";
|
|
print << "EOT";
|
|
<tr>
|
|
<td headers="$rowhdrs thcdsubj">$curlsubj</td>
|
|
<td headers="$rowhdrs thcdsummary">$curlsummary</td>
|
|
<td class="amount" headers="$rowhdrs thcdamount">$curlamount</td>
|
|
<td headers="$rowhdrs thccsubj">$curbsubj</td>
|
|
<td headers="$rowhdrs thccsummary">$curbsummary</td>
|
|
<td class="amount" headers="$rowhdrs thccamount">$curbamount</td>
|
|
</tr>
|
|
EOT
|
|
}
|
|
return;
|
|
}
|
|
|
|
# _html_coltmpl_loop_rec: Display a record row column
|
|
sub _html_coltmpl_loop_rec : method {
|
|
local ($_, %_);
|
|
my ($self, $i, $form, $choose, $rowhdrs);
|
|
my ($coldsubj, $coldsummary, $valdsummary, $coldamount, $valdamount);
|
|
my ($colcsubj, $colcsummary, $valcsummary, $colcamount, $valcamount);
|
|
($self, $i) = @_;
|
|
$form = $self->{"form"};
|
|
$choose = h_abbr(C_("Choose"));
|
|
$rowhdrs = "threcs";
|
|
$rowhdrs .= " thnew" if $self->{"type"} eq "cur";
|
|
|
|
# A form to fill in a cash expense transaction
|
|
if ($self->{"subtype"} eq "expense") {
|
|
$coldsubj = "debt$i" . "subj";
|
|
$coldsubj = h($coldsubj);
|
|
$coldsummary = "debt$i" . "summary";
|
|
$valdsummary = $self->_val_text($coldsummary, "recsummary");
|
|
$coldsummary = h($coldsummary);
|
|
$coldamount = "debt$i" . "amount";
|
|
$valdamount = $self->_val_text($coldamount, "recamount");
|
|
$coldamount = h($coldamount);
|
|
print << "EOT";
|
|
<tr>
|
|
<td headers="$rowhdrs thdsubj"><select id="$coldsubj" name="$coldsubj" onchange="setAutoSummary(this);">
|
|
EOT
|
|
print acctsubj_recent_options $form->param($coldsubj);
|
|
print << "EOT";
|
|
</select>
|
|
<input id="sel$coldsubj" type="submit" name="sel$coldsubj" value="$choose" />
|
|
</td>
|
|
<td headers="$rowhdrs thdsummary"><input id="$coldsummary" type="text" name="$coldsummary" size="15"$valdsummary /></td>
|
|
<td headers="$rowhdrs thdamount"><input id="$coldamount" class="amount" type="text" name="$coldamount" size="10"$valdamount onchange="calcTotal(this);" /></td>
|
|
</tr>
|
|
EOT
|
|
|
|
# A form to fill in a cash income transaction
|
|
} elsif ($self->{"subtype"} eq "income") {
|
|
$colcsubj = "crdt$i" . "subj";
|
|
$colcsubj = h($colcsubj);
|
|
$colcsummary = "crdt$i" . "summary";
|
|
$valcsummary = $self->_val_text($colcsummary, "recsummary");
|
|
$colcsummary = h($colcsummary);
|
|
$colcamount = "crdt$i" . "amount";
|
|
$valcamount = $self->_val_text($colcamount, "recamount");
|
|
$colcamount = h($colcamount);
|
|
print << "EOT";
|
|
<tr>
|
|
<td headers="$rowhdrs thcsubj"><select id="$colcsubj" name="$colcsubj" onchange="setAutoSummary(this);">
|
|
EOT
|
|
print acctsubj_recent_options $form->param($colcsubj);
|
|
print << "EOT";
|
|
</select>
|
|
<input id="sel$colcsubj" type="submit" name="sel$colcsubj" value="$choose" />
|
|
</td>
|
|
<td headers="$rowhdrs thcsummary"><input id="$colcsummary" type="text" name="$colcsummary" size="15"$valcsummary /></td>
|
|
<td headers="$rowhdrs thcamount"><input id="$colcamount" class="amount" type="text" name="$colcamount" size="10"$valcamount onchange="calcTotal(this);" /></td>
|
|
</tr>
|
|
EOT
|
|
|
|
# A form to fill in a transfer transaction
|
|
} elsif ($self->{"subtype"} eq "trans") {
|
|
$coldsubj = "debt$i" . "subj";
|
|
$coldsubj = h($coldsubj);
|
|
$coldsummary = "debt$i" . "summary";
|
|
$valdsummary = $self->_val_text($coldsummary, "recsummary");
|
|
$coldsummary = h($coldsummary);
|
|
$coldamount = "debt$i" . "amount";
|
|
$valdamount = $self->_val_text($coldamount, "recamount");
|
|
$coldamount = h($coldamount);
|
|
$colcsubj = "crdt$i" . "subj";
|
|
$colcsubj = h($colcsubj);
|
|
$colcsummary = "crdt$i" . "summary";
|
|
$valcsummary = $self->_val_text($colcsummary, "recsummary");
|
|
$colcsummary = h($colcsummary);
|
|
$colcamount = "crdt$i" . "amount";
|
|
$valcamount = $self->_val_text($colcamount, "recamount");
|
|
$colcamount = h($colcamount);
|
|
print << "EOT";
|
|
<tr>
|
|
<td headers="$rowhdrs thdebit thdsubj"><select id="$coldsubj" name="$coldsubj" onchange="setAutoSummary(this);">
|
|
EOT
|
|
print acctsubj_recent_options $form->param($coldsubj);
|
|
print << "EOT";
|
|
</select>
|
|
<input id="sel$coldsubj" type="submit" name="sel$coldsubj" value="$choose" />
|
|
</td>
|
|
<td headers="$rowhdrs thdebit thdsummary"><input id="$coldsummary" type="text" name="$coldsummary" size="15"$valdsummary /></td>
|
|
<td headers="$rowhdrs thdebit thdamount"><input id="$coldamount" class="amount" type="text" name="$coldamount" size="10"$valdamount onchange="calcTotal(this);" /></td>
|
|
<td headers="$rowhdrs thcredit thcsubj"><select id="$colcsubj" name="$colcsubj" onchange="setAutoSummary(this);">
|
|
EOT
|
|
print acctsubj_recent_options $form->param($colcsubj);
|
|
print << "EOT";
|
|
</select>
|
|
<input id="sel$colcsubj" type="submit" name="sel$colcsubj" value="$choose" />
|
|
</td>
|
|
<td headers="$rowhdrs thcredit thcsummary"><input id="$colcsummary" type="text" name="$colcsummary" size="15"$valcsummary /></td>
|
|
<td headers="$rowhdrs thcredit thcamount"><input id="$colcamount" class="amount" type="text" name="$colcamount" size="10"$valcamount onchange="calcTotal(this);" /></td>
|
|
</tr>
|
|
EOT
|
|
}
|
|
return;
|
|
}
|
|
|
|
# _html_col_ord: The order
|
|
sub _html_col_ord : method {
|
|
local ($_, %_);
|
|
my ($self, $form);
|
|
$self = $_[0];
|
|
$form = $self->{"form"};
|
|
# Set the default order to maximum
|
|
$form->param("ord", 99)
|
|
if $self->{"is_first_form"} && $self->{"type"} eq "new";
|
|
$self->_html_coltmpl_text("ord", h_abbr(C_("Order:")), undef,
|
|
${$self->{"maxlens"}}{"ord"});
|
|
}
|
|
|
|
# _html_col_recs: The accounting records
|
|
sub _html_col_recs : method {
|
|
local ($_, %_);
|
|
my ($self, $form, $current, $label, $mark, $orig, $new);
|
|
my ($labeldebit, $labelcredit, $labelsubj, $labelsummary, $labelamount);
|
|
my ($labelsum, $sumdebit, $sumcredit);
|
|
my ($count_new, $rows_new, $count_cur, $rows_cur, $rowspan);
|
|
$self = $_[0];
|
|
$form = $self->{"form"};
|
|
$current = $self->{"cur"};
|
|
$mark = $self->_mark("recs");
|
|
$labeldebit = h_abbr(C_("Debit"));
|
|
$labelcredit = h_abbr(C_("Credit"));
|
|
$labelsubj = h_abbr(C_("Accounting subject"));
|
|
$labelsummary = h_abbr(C_("Summary"));
|
|
$labelamount = h_abbr(C_("Amount"));
|
|
$labelsum = h_abbr(C_("Total"));
|
|
|
|
# A form to create a new item
|
|
if ($self->{"type"} eq "new") {
|
|
# Find the total number of records
|
|
$count_new = 0;
|
|
# Find the last-used debit record
|
|
for ( $_ = 0;
|
|
defined $form->param("debt$_" . "subj")
|
|
|| defined $form->param("debt$_" . "summary")
|
|
|| defined $form->param("debt$_" . "amount"); $_++) {};
|
|
if ($_ > 0) {
|
|
for ( $_--;
|
|
$_ >= 0
|
|
&& $form->param("debt$_" . "subj") eq ""
|
|
&& $form->param("debt$_" . "summary") eq ""
|
|
&& $form->param("debt$_" . "amount") eq ""; $_--) {};
|
|
$_++;
|
|
}
|
|
$count_new = $_ if $count_new < $_;
|
|
# Find the last-used credit record
|
|
for ( $_ = 0;
|
|
defined $form->param("crdt$_" . "subj")
|
|
|| defined $form->param("crdt$_" . "summary")
|
|
|| defined $form->param("crdt$_" . "amount"); $_++) {};
|
|
if ($_ > 0) {
|
|
for ( $_--;
|
|
$_ >= 0
|
|
&& $form->param("crdt$_" . "subj") eq ""
|
|
&& $form->param("crdt$_" . "summary") eq ""
|
|
&& $form->param("crdt$_" . "amount") eq ""; $_--) {};
|
|
$_++;
|
|
}
|
|
$count_new = $_ if $count_new < $_;
|
|
# We need at least 5 blank records
|
|
$count_new += 5;
|
|
$_ = $count_new + 2;
|
|
$_++ if $self->{"subtype"} eq "trans";
|
|
$rows_new = " rowspan=\"" . h($_) . "\"";
|
|
$rows_new = "" if $_ == 1;
|
|
$label = h_abbr(C_("[numerate,_1,Content]:", 0));
|
|
# A form to fill in a cash expense transaction
|
|
if ($self->{"subtype"} eq "expense") {
|
|
print << "EOT";
|
|
<tr>
|
|
<th id="threcs" class="th"$rows_new scope="row"><label for="debt0subj">$mark$label</label></th>
|
|
<th id="thdsubj"><label for="debt0subj">$labelsubj</label></th>
|
|
<th id="thdsummary"><label for="debt0summary">$labelsummary</label></th>
|
|
<th id="thdamount"><label for="debt0amount">$labelamount</label></th>
|
|
</tr>
|
|
EOT
|
|
# A form to fill in a cash income transaction
|
|
} elsif ($self->{"subtype"} eq "income") {
|
|
print << "EOT";
|
|
<tr>
|
|
<th id="threcs" class="th"$rows_new scope="row"><label for="crdt0subj">$mark$label</label></th>
|
|
<th id="thcsubj"><label for="crdt0subj">$labelsubj</label></th>
|
|
<th id="thcsummary"><label for="crdt0summary">$labelsummary</label></th>
|
|
<th id="thcamount"><label for="crdt0amount">$labelamount</label></th>
|
|
</tr>
|
|
EOT
|
|
# A form to fill in a transfer transaction
|
|
} elsif ($self->{"subtype"} eq "trans") {
|
|
print << "EOT";
|
|
<tr>
|
|
<th id="threcs" class="th"$rows_new scope="row"><label for="debt0subj">$mark$label</label></th>
|
|
<th id="thdebit" colspan="3"><label for="debt0subj">$labeldebit</label></th>
|
|
<th id="thcredit" colspan="3"><label for="crdt0subj">$labelcredit</label></th>
|
|
</tr>
|
|
<tr>
|
|
<th id="thdsubj"><label for="debt0subj">$labelsubj</label></th>
|
|
<th id="thdsummary"><label for="debt0summary">$labelsummary</label></th>
|
|
<th id="thdamount"><label for="debt0amount">$labelamount</label></th>
|
|
<th id="thcsubj"><label for="crdt0subj">$labelsubj</label></th>
|
|
<th id="thcsummary"><label for="crdt0summary">$labelsummary</label></th>
|
|
<th id="thcamount"><label for="crdt0amount">$labelamount</label></th>
|
|
</tr>
|
|
EOT
|
|
}
|
|
for ($_ = 0, @_ = qw(); $_ < $count_new; $_++) {
|
|
$self->_html_coltmpl_loop_rec($_);
|
|
}
|
|
# A form to fill in a cash expense transaction
|
|
if ($self->{"subtype"} eq "expense") {
|
|
for (my $i = 0, $sumdebit = 0; $i < $count_new; $i++) {
|
|
$sumdebit += $_
|
|
if defined($_ = $form->param("debt$i" . "amount"))
|
|
&& /^\d+$/;
|
|
}
|
|
print << "EOT";
|
|
<tr>
|
|
<th id="thdsum" colspan="2"><label for="debttotal">$labelsum</label></th>
|
|
<td headers="threcs thdsum"><input id="debttotal" class="amount" type="text" name="debttotal" size="10" value="$sumdebit" disabled="disabled" /></td>
|
|
</tr>
|
|
EOT
|
|
# A form to fill in a cash income transaction
|
|
} elsif ($self->{"subtype"} eq "income") {
|
|
for (my $i = 0, $sumcredit = 0; $i < $count_new; $i++) {
|
|
$sumcredit += $_
|
|
if defined($_ = $current->param("crdt$i" . "amount"))
|
|
&& /^\d+$/;
|
|
}
|
|
print << "EOT";
|
|
<tr>
|
|
<th id="thcsum" colspan="2"><label for="crdttotal">$labelsum</label></th>
|
|
<td headers="threcs thcsum"><input id="crdttotal" class="amount" type="text" name="crdttotal" size="10" value="$sumcredit" disabled="disabled" /></td>
|
|
</tr>
|
|
EOT
|
|
# A form to fill in a transfer transaction
|
|
} elsif ($self->{"subtype"} eq "trans") {
|
|
for (my $i = 0, $sumdebit = 0, $sumcredit = 0; $i < $count_new; $i++) {
|
|
$sumdebit += $_
|
|
if defined($_ = $current->param("debt$i" . "amount"))
|
|
&& /^\d+$/;
|
|
$sumcredit += $_
|
|
if defined($_ = $current->param("crdt$i" . "amount"))
|
|
&& /^\d+$/;
|
|
}
|
|
print << "EOT";
|
|
<tr>
|
|
<th id="thdsum" colspan="2"><label for="debttotal">$labelsum</label></th>
|
|
<td headers="threcs thdebit thdsum"><input id="debttotal" class="amount" type="text" name="debttotal" size="10" value="$sumdebit" disabled="disabled" /></td>
|
|
<th id="thcsum" colspan="2"><label for="crdttotal">$labelsum</label></th>
|
|
<td headers="threcs thcredit thcsum"><input id="crdttotal" class="amount" type="text" name="crdttotal" size="10" value="$sumcredit" disabled="disabled" /></td>
|
|
</tr>
|
|
EOT
|
|
}
|
|
|
|
# A form to edit a current item
|
|
} elsif ($self->{"type"} eq "cur") {
|
|
$count_cur = 0;
|
|
$count_cur = $current->param("debtcount")
|
|
if $count_cur < $current->param("debtcount");
|
|
$count_cur = $current->param("crdtcount")
|
|
if $count_cur < $current->param("crdtcount");
|
|
$_ = $count_cur + 2;
|
|
$_++ if $self->{"subtype"} eq "trans";
|
|
$rows_cur = " rowspan=\"" . h($_) . "\"";
|
|
$rows_cur = "" if $_ == 1;
|
|
# Find the total number of records
|
|
$count_new = 0;
|
|
# Find the last-used debit record
|
|
for ( $_ = 0;
|
|
defined $form->param("debt$_" . "subj")
|
|
|| defined $form->param("debt$_" . "summary")
|
|
|| defined $form->param("debt$_" . "amount"); $_++) {};
|
|
if ($_ > 0) {
|
|
for ( $_--;
|
|
$_ > 0
|
|
&& $form->param("debt$_" . "subj") eq ""
|
|
&& $form->param("debt$_" . "summary") eq ""
|
|
&& $form->param("debt$_" . "amount") eq ""; $_--) {};
|
|
}
|
|
$_++;
|
|
$count_new = $_ if $count_new < $_;
|
|
# Find the last-used credit record
|
|
for ( $_ = 0;
|
|
defined $form->param("crdt$_" . "subj")
|
|
|| defined $form->param("crdt$_" . "summary")
|
|
|| defined $form->param("crdt$_" . "amount"); $_++) {};
|
|
if ($_ > 0) {
|
|
for ( $_--;
|
|
$_ > 0
|
|
&& $form->param("crdt$_" . "subj") eq ""
|
|
&& $form->param("crdt$_" . "summary") eq ""
|
|
&& $form->param("crdt$_" . "amount") eq ""; $_--) {};
|
|
}
|
|
$_++;
|
|
$count_new = $_ if $count_new < $_;
|
|
# We need at least 5 blank records
|
|
$count_new += 5;
|
|
$_ = $count_new + 2;
|
|
$_++ if $self->{"subtype"} eq "trans";
|
|
$rows_new = " rowspan=\"" . h($_) . "\"";
|
|
$rows_new = "" if $_ == 1;
|
|
$_ = $count_cur + $count_new + 4;
|
|
$_ += 2 if $self->{"subtype"} eq "trans";
|
|
$rowspan = " rowspan=\"" . h($_) . "\"";
|
|
$rowspan = "" if $_ == 1;
|
|
$label = h_abbr(C_("[numerate,_1,Content]:", 0));
|
|
$orig = h_abbr(C_("Original:"));
|
|
$new = h_abbr(C_("New:"));
|
|
# A form to fill in a cash expense transaction
|
|
if ($self->{"subtype"} eq "expense") {
|
|
print << "EOT";
|
|
<tr>
|
|
<th id="threcs" class="th"$rowspan scope="row">$mark$label</th>
|
|
<th id="thold" class="oldnew"$rows_cur>$orig</th>
|
|
<th id="thcdsubj">$labelsubj</th>
|
|
<th id="thcdsummary">$labelsummary</th>
|
|
<th id="thcdamount">$labelamount</th>
|
|
</tr>
|
|
EOT
|
|
# A form to fill in a cash income transaction
|
|
} elsif ($self->{"subtype"} eq "income") {
|
|
print << "EOT";
|
|
<tr>
|
|
<th id="threcs" class="th"$rowspan scope="row">$mark$label</th>
|
|
<th id="thold" class="oldnew"$rows_cur>$orig</th>
|
|
<th id="thccsubj">$labelsubj</th>
|
|
<th id="thccsummary">$labelsummary</th>
|
|
<th id="thccamount">$labelamount</th>
|
|
</tr>
|
|
EOT
|
|
# A form to fill in a transfer transaction
|
|
} elsif ($self->{"subtype"} eq "trans") {
|
|
print << "EOT";
|
|
<tr>
|
|
<th id="threcs" class="th"$rowspan scope="row">$mark$label</th>
|
|
<th id="thold" class="oldnew"$rows_cur>$orig</th>
|
|
<th id="thcdebit" colspan="3">$labeldebit</th>
|
|
<th id="thccredit" colspan="3">$labelcredit</th>
|
|
</tr>
|
|
<tr>
|
|
<th id="thcdsubj">$labelsubj</th>
|
|
<th id="thcdsummary">$labelsummary</th>
|
|
<th id="thcdamount">$labelamount</th>
|
|
<th id="thccsubj">$labelsubj</th>
|
|
<th id="thccsummary">$labelsummary</th>
|
|
<th id="thccamount">$labelamount</th>
|
|
</tr>
|
|
EOT
|
|
}
|
|
for ($_ = 0, @_ = qw(); $_ < $count_cur; $_++) {
|
|
$self->_html_coltmpl_ro_loop_rec($_);
|
|
}
|
|
# A form to fill in a cash expense transaction
|
|
if ($self->{"subtype"} eq "expense") {
|
|
for (my $i = 0, $sumdebit = 0; $i < $count_cur; $i++) {
|
|
$sumdebit += $_
|
|
if defined($_ = $current->param("debt$i" . "amount"));
|
|
}
|
|
$sumdebit = h_abbr(fmtntamount $sumdebit);
|
|
print << "EOT";
|
|
<tr>
|
|
<th id="thcdsum" colspan="2">$labelsum</th>
|
|
<td class="amount" headers="threcs thold thcdsum">$sumdebit</td>
|
|
</tr>
|
|
EOT
|
|
# A form to fill in a cash income transaction
|
|
} elsif ($self->{"subtype"} eq "income") {
|
|
for (my $i = 0, $sumcredit = 0; $i < $count_cur; $i++) {
|
|
$sumcredit += $_
|
|
if defined($_ = $current->param("crdt$i" . "amount"));
|
|
}
|
|
$sumcredit = h_abbr(fmtntamount $sumcredit);
|
|
print << "EOT";
|
|
<tr>
|
|
<th id="thccsum" colspan="2">$labelsum</th>
|
|
<td class="amount" headers="threcs thold thccsum">$sumcredit</td>
|
|
</tr>
|
|
EOT
|
|
# A form to fill in a transfer transaction
|
|
} elsif ($self->{"subtype"} eq "trans") {
|
|
for (my $i = 0, $sumdebit = 0, $sumcredit = 0; $i < $count_cur; $i++) {
|
|
$sumdebit += $_
|
|
if defined($_ = $current->param("debt$i" . "amount"));
|
|
$sumcredit += $_
|
|
if defined($_ = $current->param("crdt$i" . "amount"));
|
|
}
|
|
$sumdebit = h_abbr(fmtntamount $sumdebit);
|
|
$sumcredit = h_abbr(fmtntamount $sumcredit);
|
|
print << "EOT";
|
|
<tr>
|
|
<th id="thcdsum" colspan="2">$labelsum</th>
|
|
<td class="amount" headers="threcs thold thcdebit thcdsum">$sumdebit</td>
|
|
<th id="thccsum" colspan="2">$labelsum</th>
|
|
<td class="amount" headers="threcs thold thccredit thccsum">$sumcredit</td>
|
|
</tr>
|
|
EOT
|
|
}
|
|
# A form to fill in a cash expense transaction
|
|
if ($self->{"subtype"} eq "expense") {
|
|
print << "EOT";
|
|
<tr>
|
|
<th id="thnew" class="oldnew"$rows_new>$new</th>
|
|
<th id="thdsubj"><label for="debt0subj">$labelsubj</label></th>
|
|
<th id="thdsummary"><label for="debt0summary">$labelsummary</label></th>
|
|
<th id="thdamount"><label for="debt0amount">$labelamount</label></th>
|
|
</tr>
|
|
EOT
|
|
# A form to fill in a cash income transaction
|
|
} elsif ($self->{"subtype"} eq "income") {
|
|
print << "EOT";
|
|
<tr>
|
|
<th id="thnew" class="oldnew"$rows_new>$new</th>
|
|
<th id="thcsubj"><label for="crdt0subj">$labelsubj</label></th>
|
|
<th id="thcsummary"><label for="crdt0summary">$labelsummary</label></th>
|
|
<th id="thcamount"><label for="crdt0amount">$labelamount</label></th>
|
|
</tr>
|
|
EOT
|
|
# A form to fill in a transfer transaction
|
|
} elsif ($self->{"subtype"} eq "trans") {
|
|
print << "EOT";
|
|
<tr>
|
|
<th id="thnew" class="oldnew"$rows_new>$new</th>
|
|
<th id="thdebit" colspan="3"><label for="debt0subj">$labeldebit</label></th>
|
|
<th id="thcredit" colspan="3"><label for="crdt0subj">$labelcredit</label></th>
|
|
</tr>
|
|
<tr>
|
|
<th id="thdsubj"><label for="debt0subj">$labelsubj</label></th>
|
|
<th id="thdsummary"><label for="debt0summary">$labelsummary</label></th>
|
|
<th id="thdamount"><label for="debt0amount">$labelamount</label></th>
|
|
<th id="thcsubj"><label for="crdt0subj">$labelsubj</label></th>
|
|
<th id="thcsummary"><label for="crdt0summary">$labelsummary</label></th>
|
|
<th id="thcamount"><label for="crdt0amount">$labelamount</label></th>
|
|
</tr>
|
|
EOT
|
|
}
|
|
for ($_ = 0, @_ = qw(); $_ < $count_new; $_++) {
|
|
$self->_html_coltmpl_loop_rec($_);
|
|
}
|
|
# A form to fill in a cash expense transaction
|
|
if ($self->{"subtype"} eq "expense") {
|
|
for (my $i = 0, $sumdebit = 0; $i < $count_new; $i++) {
|
|
$sumdebit += $_
|
|
if defined($_ = $form->param("debt$i" . "amount"))
|
|
&& /^\d+$/;
|
|
}
|
|
print << "EOT";
|
|
<tr>
|
|
<th id="thdsum" colspan="2"><label for="debttotal">$labelsum</label></th>
|
|
<td headers="threcs thdsum"><input id="debttotal" class="amount" type="text" name="debttotal" size="10" value="$sumdebit" disabled="disabled" /></td>
|
|
</tr>
|
|
EOT
|
|
# A form to fill in a cash income transaction
|
|
} elsif ($self->{"subtype"} eq "income") {
|
|
for (my $i = 0, $sumcredit = 0; $i < $count_new; $i++) {
|
|
$sumcredit += $_
|
|
if defined($_ = $current->param("crdt$i" . "amount"))
|
|
&& /^\d+$/;
|
|
}
|
|
print << "EOT";
|
|
<tr>
|
|
<th id="thcsum" colspan="2"><label for="crdttotal">$labelsum</label></th>
|
|
<td headers="threcs thcsum"><input id="crdttotal" class="amount" type="text" name="crdttotal" size="10" value="$sumcredit" disabled="disabled" /></td>
|
|
</tr>
|
|
EOT
|
|
# A form to fill in a transfer transaction
|
|
} elsif ($self->{"subtype"} eq "trans") {
|
|
for (my $i = 0, $sumdebit = 0, $sumcredit = 0; $i < $count_new; $i++) {
|
|
$sumdebit += $_
|
|
if defined($_ = $current->param("debt$i" . "amount"))
|
|
&& /^\d+$/;
|
|
$sumcredit += $_
|
|
if defined($_ = $current->param("crdt$i" . "amount"))
|
|
&& /^\d+$/;
|
|
}
|
|
print << "EOT";
|
|
<tr>
|
|
<th id="thdsum" colspan="2"><label for="debttotal">$labelsum</label></th>
|
|
<td headers="threcs thdebit thdsum"><input id="debttotal" class="amount" type="text" name="debttotal" size="10" value="$sumdebit" disabled="disabled" /></td>
|
|
<th id="thcsum" colspan="2"><label for="crdttotal">$labelsum</label></th>
|
|
<td headers="threcs thcredit thcsum"><input id="crdttotal" class="amount" type="text" name="crdttotal" size="10" value="$sumcredit" disabled="disabled" /></td>
|
|
</tr>
|
|
EOT
|
|
}
|
|
|
|
# A form to delete a current item
|
|
} elsif ($self->{"type"} eq "del") {
|
|
$count_cur = 0;
|
|
$count_cur = $current->param("debtcount")
|
|
if $count_cur < $current->param("debtcount");
|
|
$count_cur = $current->param("crdtcount")
|
|
if $count_cur < $current->param("crdtcount");
|
|
$_ = $count_cur + 2;
|
|
$_++ if $self->{"subtype"} eq "trans";
|
|
$rows_cur = " rowspan=\"" . h($_) . "\"";
|
|
$rows_cur = "" if $_ == 1;
|
|
$label = h_abbr(C_("[numerate,_1,Content]:", $count_cur));
|
|
# A form to fill in a cash expense transaction
|
|
if ($self->{"subtype"} eq "expense") {
|
|
print << "EOT";
|
|
<tr>
|
|
<th id="threcs" class="th"$rows_cur scope="row">$mark$label</th>
|
|
<th id="thcdsubj">$labelsubj</th>
|
|
<th id="thcdsummary">$labelsummary</th>
|
|
<th id="thcdamount">$labelamount</th>
|
|
</tr>
|
|
EOT
|
|
# A form to fill in a cash income transaction
|
|
} elsif ($self->{"subtype"} eq "income") {
|
|
print << "EOT";
|
|
<tr>
|
|
<th id="threcs" class="th"$rows_cur scope="row">$mark$label</th>
|
|
<th id="thccsubj">$labelsubj</th>
|
|
<th id="thccsummary">$labelsummary</th>
|
|
<th id="thccamount">$labelamount</th>
|
|
</tr>
|
|
EOT
|
|
# A form to fill in a transfer transaction
|
|
} elsif ($self->{"subtype"} eq "trans") {
|
|
print << "EOT";
|
|
<tr>
|
|
<th id="threcs" class="th"$rows_cur scope="row">$mark$label</th>
|
|
<th id="thcdebit" colspan="3">$labeldebit</th>
|
|
<th id="thccredit" colspan="3">$labelcredit</th>
|
|
</tr>
|
|
<tr>
|
|
<th id="thcdsubj">$labelsubj</th>
|
|
<th id="thcdsummary">$labelsummary</th>
|
|
<th id="thcdamount">$labelamount</th>
|
|
<th id="thccsubj">$labelsubj</th>
|
|
<th id="thccsummary">$labelsummary</th>
|
|
<th id="thccamount">$labelamount</th>
|
|
</tr>
|
|
EOT
|
|
}
|
|
for ($_ = 0, @_ = qw(); $_ < $count_cur; $_++) {
|
|
$self->_html_coltmpl_ro_loop_rec($_);
|
|
}
|
|
# A form to fill in a cash expense transaction
|
|
if ($self->{"subtype"} eq "expense") {
|
|
for (my $i = 0, $sumdebit = 0; $i < $count_cur; $i++) {
|
|
$sumdebit += $_
|
|
if defined($_ = $current->param("debt$i" . "amount"));
|
|
}
|
|
$sumdebit = h_abbr(fmtntamount $sumdebit);
|
|
print << "EOT";
|
|
<tr>
|
|
<td id="thcdsum" colspan="2">$labelsum</td>
|
|
<td class="amount" headers="threcs thcdsum">$sumdebit</td>
|
|
</tr>
|
|
EOT
|
|
# A form to fill in a cash income transaction
|
|
} elsif ($self->{"subtype"} eq "income") {
|
|
for (my $i = 0, $sumcredit = 0; $i < $count_cur; $i++) {
|
|
$sumcredit += $_
|
|
if defined($_ = $current->param("crdt$i" . "amount"));
|
|
}
|
|
$sumcredit = h_abbr(fmtntamount $sumcredit);
|
|
print << "EOT";
|
|
<tr>
|
|
<td id="thccsum" colspan="2">$labelsum</td>
|
|
<td class="amount" headers="threcs thccsum">$sumcredit</td>
|
|
</tr>
|
|
EOT
|
|
# A form to fill in a transfer transaction
|
|
} elsif ($self->{"subtype"} eq "trans") {
|
|
for (my $i = 0, $sumdebit = 0, $sumcredit = 0; $i < $count_cur; $i++) {
|
|
$sumdebit += $_
|
|
if defined($_ = $current->param("debt$i" . "amount"));
|
|
$sumcredit += $_
|
|
if defined($_ = $current->param("crdt$i" . "amount"));
|
|
}
|
|
$sumdebit = h_abbr(fmtntamount $sumdebit);
|
|
$sumcredit = h_abbr(fmtntamount $sumcredit);
|
|
print << "EOT";
|
|
<tr>
|
|
<td id="thcdsum" colspan="2">$labelsum</td>
|
|
<td class="amount" headers="threcs thcdebit thcdsum">$sumdebit</td>
|
|
<td id="thccsum" colspan="2">$labelsum</td>
|
|
<td class="amount" headers="threcs thccredit thccsum">$sumcredit</td>
|
|
</tr>
|
|
EOT
|
|
}
|
|
}
|
|
return;
|
|
}
|
|
|
|
# _html_col_note: The note
|
|
sub _html_col_note : method {
|
|
$_[0]->_html_coltmpl_textarea("note", h_abbr(C_("Note:")),
|
|
h_abbr(C_("Fill in the note here.")), undef, 2);
|
|
}
|
|
|
|
return 1;
|