# Selima Website Content Management System # AcctRec.pm: The accounting record 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 # First written: 2007-09-23 package Selima::Form::AcctRec; use 5.008; use strict; use warnings; use base qw(Selima::Form); use Selima::Accounting; use Selima::FormFunc; 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"} = "acctrecs" if !exists $$args{"table"}; $$args{"deltext"} = C_("Delete this accounting record") if !exists $$args{"deltext"}; 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 record."); # 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 record."); # 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 record."); } } if (!exists $$args{"cols"}) { # A form to create a new item if ($$args{"type"} eq "new") { $$args{"cols"} = [qw(trx type ord subj summary amount)]; # 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 trx type ord subj summary amount created createdby updated updatedby)]; } } if (!exists $$args{"title"}) { # A form to create a new item if ($$args{"type"} eq "new") { $$args{"title"} = C_("Add a New Accounting Record"); # A form to edit a current item } elsif ($$args{"type"} eq "cur") { $$args{"title"} = C_("Edit a Current Accounting Record"); # A form to delete a current item } elsif ($$args{"type"} eq "del") { $$args{"title"} = C_("Delete an Accounting Record"); } } $self = $class->SUPER::new($status, $args); return $self; } # _html_col_trx: The accounting transaction sub _html_col_trx : method { $_[0]->_html_coltmpl_call("trx", h_abbr(C_("Accounting transaction:")), \&accttrx_id); } # _html_col_type: The type sub _html_col_type : method { local ($_, %_); my ($self, @opts); $self = $_[0]; @opts = ( { "val" => "debit", "title" => C_("Debit"), }, { "val" => "credit", "title" => C_("Credit"), }, ); return $self->_html_coltmpl_radio("type", h_abbr(C_("Type:")), \@opts, undef, 1); } # _html_col_subj: The accounting subject sub _html_col_subj : method { local ($_, %_); my ($self, $form, $current, $label, $choose, $mark, $colspan); my ($cur, $orig, $new); $self = $_[0]; $form = $self->{"form"}; $current = $self->{"cur"}; $label = h_abbr(C_("Accounting subject:")); $choose = h_abbr(C_("Choose")); $mark = $self->_mark("subj"); $colspan = $self->_colspan; # A form to create a new item if ($self->{"type"} eq "new") { print << "EOT"; EOT # A form to edit a current item } elsif ($self->{"type"} eq "cur") { $cur = h(acctsubj_title $current->param("subj")); $orig = h_abbr(C_("Original:")); $new = h_abbr(C_("New:")); print << "EOT"; $orig $cur EOT # A form to delete a current item } elsif ($self->{"type"} eq "del") { $cur = h(acctsubj_title $current->param("subj")); print << "EOT"; $mark$label $cur EOT } return; } # _html_col_summary: The summary sub _html_col_summary : method { $_[0]->_html_coltmpl_text("summary", h_abbr(C_("Summary:"))); } # _html_col_amount: The amount sub _html_col_amount : method { $_[0]->_html_coltmpl_text("amount", h_abbr(C_("Amount:"))); } return 1;