summaryrefslogtreecommitdiff
path: root/scripts
diff options
context:
space:
mode:
authoreinhverfr <einhverfr@4979c152-3d1c-0410-bac9-87ea11338e46>2007-10-10 17:46:32 +0000
committereinhverfr <einhverfr@4979c152-3d1c-0410-bac9-87ea11338e46>2007-10-10 17:46:32 +0000
commit03f3758f6e1f7b613de1161b9cbe984edc02abfb (patch)
tree7695e6b562a88ed0634b1071f46362da8865c64b /scripts
parent8066acc76d4098199b1bb60830dd881bd65f3900 (diff)
Adding David Mora's workflow script. It still needs POD.
git-svn-id: https://ledger-smb.svn.sourceforge.net/svnroot/ledger-smb/trunk@1736 4979c152-3d1c-0410-bac9-87ea11338e46
Diffstat (limited to 'scripts')
-rw-r--r--scripts/payment.pl152
1 files changed, 152 insertions, 0 deletions
diff --git a/scripts/payment.pl b/scripts/payment.pl
new file mode 100644
index 00000000..466d49d0
--- /dev/null
+++ b/scripts/payment.pl
@@ -0,0 +1,152 @@
+
+#=====================================================================
+# PLAXIS
+# Copyright (c) 2007
+#
+# Author: David Mora R
+# Christian Ceballos B
+#
+#
+#
+#
+#
+# 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., 675 Mass Ave, Cambridge, MA 02139, USA.
+#======================================================================
+#
+# NEW PAYMENTS AND CHECK MODULE
+#
+#
+#======================================================================
+
+
+package LedgerSMB::Scripts::payment;
+use LedgerSMB::Template;
+use LedgerSMB::DBObject::Payment;
+use LedgerSMB::DBObject::Date;
+use strict;
+=pod
+
+=item payment
+
+This method is used to set the filter screen and prints it, using the
+TT2 system. (hopefully it will... )
+
+=back
+
+=cut
+
+sub payment {
+ my ($request) = @_;
+ my $locale = $request->{_locale};
+ my $templateData;
+ my $dbPayment = LedgerSMB::DBObject::Payment->new({'base' => $request});
+# Lets get the project data...
+ my @projectOptions;
+ my @arrayOptions = $dbPayment->list_open_projects();
+ push @projectOptions, {}; #A blank field on the select box
+ for my $ref (0 .. $#arrayOptions) {
+ push @projectOptions, { value => $arrayOptions[$ref]->{id},
+ text => $arrayOptions[$ref]->{projectnumber}."--".$arrayOptions[$ref]->{description}};
+ }
+# Lets get the departments data...
+ my @departmentOptions;
+ my $role = $request->{type} eq 'receipt' ? 'P' : 'C';
+ @arrayOptions = $dbPayment->list_departments($role);
+ push @departmentOptions, {}; # A blank field on the select box
+ for my $ref (0 .. $#arrayOptions) {
+ push @departmentOptions, { value => $arrayOptions[$ref]->{id},
+ text => $arrayOptions[$ref]->{description}};
+ }
+# Lets get the customer or vendor :)
+ my @vcOptions;
+ $dbPayment->{account_class} = $request->{type} eq 'receipt' ? 2 : 1;
+ @arrayOptions = $dbPayment->get_open_accounts();
+ for my $ref (0 .. $#arrayOptions) {
+ push @vcOptions, { value => $arrayOptions[$ref]->{id},
+ text => $arrayOptions[$ref]->{description}};
+ }
+# Lets get the open currencies (this uses the $dbPayment->{account_class} property)
+ my @currOptions;
+ @arrayOptions = $dbPayment->get_open_currencies();
+ for my $ref (0 .. $#arrayOptions) {
+ push @arrayOptions, { value => $arrayOptions[$ref]->{id},
+ text => $arrayOptions[$ref]->{description}};
+ }
+# Lets build filter by period
+my $date = LedgerSMB::DBObject::Date->new({base => $request});
+ $date->build_filter_by_period($locale);
+# Lets set the data in a hash for the template system. :)
+my $select = {
+ stylesheet => $request->{_user}->{stylesheet},
+ projects => {
+ name => 'projects',
+ options => \@projectOptions
+ },
+ department => {
+ name => 'department',
+ options => \@departmentOptions
+ },
+ customer => {
+ name => 'customer',
+ options => \@vcOptions
+ },
+ curr => {
+ name => 'curr',
+ options => \@currOptions
+ },
+ month => {
+ name => 'month',
+ options => $date->{monthsOptions}
+ },
+ year => {
+ name => 'year',
+ options => $date->{yearsOptions}
+ },
+ interval_radios => $date->{radioOptions},
+ amountfrom => {
+ type => 'text',
+ name => 'amountfrom',
+ size => '10',
+ maxlength => '10'
+ },
+ amountto => {
+ type => 'text',
+ name => 'amountto',
+ size => '10',
+ maxlength => '10'
+ },
+ sort => {
+ type => 'hidden',
+ value => 'sort_value'
+ },
+ action => {
+ name => 'action',
+ value => 'continue',
+ text => $locale->text("Continue"),
+ },
+
+};
+# Lets call upon the template system
+my $template;
+
+ $template = LedgerSMB::Template->new(
+ user => $request->{_user},
+ locale => $request->{_locale},
+ path => 'UI',
+ template => 'payment1',
+ format => 'HTML', );
+$template->render($select);# And finally, Lets print the screen :)
+}
+
+1;