[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
SF.net SVN: ledger-smb:[4350] trunk
- Subject: SF.net SVN: ledger-smb:[4350] trunk
- From: ..hidden..
- Date: Thu, 23 Feb 2012 09:29:17 +0000
Revision: 4350
http://ledger-smb.svn.sourceforge.net/ledger-smb/?rev=4350&view=rev
Author: einhverfr
Date: 2012-02-23 09:29:16 +0000 (Thu, 23 Feb 2012)
Log Message:
-----------
More business reporting unit code
Modified Paths:
--------------
trunk/LedgerSMB/DBObject/Business_Unit.pm
trunk/LedgerSMB/DBObject_Moose.pm
trunk/LedgerSMB/PGDate.pm
trunk/LedgerSMB/Scripts/business_unit.pm
trunk/LedgerSMB/Template/HTML.pm
trunk/LedgerSMB/User.pm
trunk/sql/modules/Business_Unit.sql
Modified: trunk/LedgerSMB/DBObject/Business_Unit.pm
===================================================================
--- trunk/LedgerSMB/DBObject/Business_Unit.pm 2012-02-23 02:50:35 UTC (rev 4349)
+++ trunk/LedgerSMB/DBObject/Business_Unit.pm 2012-02-23 09:29:16 UTC (rev 4350)
@@ -52,7 +52,7 @@
=cut
-has 'description' => (is => 'rw', isa => 'Str');
+has 'description' => (is => 'rw', isa => 'Maybe[Str]');
=item start_date
@@ -78,7 +78,7 @@
=cut
-has 'parent_id' => (is => 'rw', isa => 'Int');
+has 'parent_id' => (is => 'rw', isa => 'Maybe[Int]');
=item parent
@@ -86,7 +86,7 @@
=cut
-has 'parent' => (is => 'rw', isa => 'LedgerSMB::DBObject::Business_Unit');
+has 'parent' => (is => 'rw', isa => 'Maybe[LedgerSMB::DBObject::Business_Unit]');
=item credit_id
@@ -95,7 +95,7 @@
=cut
-has 'credit_id' => (is => 'rw', isa => 'Int');
+has 'credit_id' => (is => 'rw', isa => 'Maybe[Int]');
=item children
@@ -107,7 +107,7 @@
=cut
-has 'children' => (is => 'rw', isa => 'ArrayRef[LedgerSMB::DBObject::Business_Unit]');
+has 'children' => (is => 'rw', isa => 'Maybe[ArrayRef[LedgerSMB::DBObject::Business_Unit]]');
=head1 METHODS
Modified: trunk/LedgerSMB/DBObject_Moose.pm
===================================================================
--- trunk/LedgerSMB/DBObject_Moose.pm 2012-02-23 02:50:35 UTC (rev 4349)
+++ trunk/LedgerSMB/DBObject_Moose.pm 2012-02-23 09:29:16 UTC (rev 4350)
@@ -52,7 +52,7 @@
has 'dbh' => (is => 'ro', isa => 'DBI::db', required => '1');
has '_roles' => (is => 'ro', isa => 'ArrayRef[Str]', required => '1');
-has '_user' => (is => 'ro', isa => 'HashRef[Any]', required => '1');
+has '_user' => (is => 'ro', isa => 'LedgerSMB::User', required => '1');
has '_locale' => (is => 'ro', isa => 'LedgerSMB::Locale', required => '1');
has '_request' => (is => 'ro', isa => 'CGI::Simple', required => '1');
Modified: trunk/LedgerSMB/PGDate.pm
===================================================================
--- trunk/LedgerSMB/PGDate.pm 2012-02-23 02:50:35 UTC (rev 4349)
+++ trunk/LedgerSMB/PGDate.pm 2012-02-23 09:29:16 UTC (rev 4350)
@@ -164,10 +164,17 @@
used. If $format is not supplied, the dateformat of the user is used.
=cut
+
sub to_output {
my ($self) = @_;
return undef if !defined $self->date;
- my $fmt = $formats->{$LedgerSMB::App_State::User->dateformat}->[0];
+ my $fmt;
+ if (defined $LedgerSMB::App_State::User->{dateformat}){
+ $fmt = $formats->{uc($LedgerSMB::App_State::User->{dateformat})}->[0];
+ } else {
+ $fmt = '%F';
+ }
+
my $formatter = new DateTime::Format::Strptime(
pattern => $fmt,
locale => $LedgerSMB::App_State::Locale->{datetime},
Modified: trunk/LedgerSMB/Scripts/business_unit.pm
===================================================================
--- trunk/LedgerSMB/Scripts/business_unit.pm 2012-02-23 02:50:35 UTC (rev 4349)
+++ trunk/LedgerSMB/Scripts/business_unit.pm 2012-02-23 09:29:16 UTC (rev 4350)
@@ -52,16 +52,7 @@
$request->{class_id} = $request->{id};
}
$request->{id} = undef;
- my $template = LedgerSMB::Template->new(
- user =>$request->{_user},
- locale => $request->{_locale},
- path => 'UI/business_units',
- template => 'edit',
- format => 'HTML'
- );
- $template->render($request);
-
-
+ _display($request);
}
=item edit
@@ -72,8 +63,26 @@
sub edit {
my ($request) = @_;
+ $request->{control_code} = '';
+ $request->{class_id} = 0 unless $request->{class_id} = 0;
+ my $b_unit = LedgerSMB::DBObject::Business_Unit->new(%$request);
+ $b_unit->get;
+ _display($b_unit);
}
+sub _display {
+ my ($request) = @_;
+ my $template = LedgerSMB::Template->new(
+ user =>$request->{_user},
+ locale => $request->{_locale},
+ path => 'UI/business_units',
+ template => 'edit',
+ format => 'HTML'
+ );
+ $template->render($request);
+
+}
+
=item list
Lists business units. The following properties of $request may be set:
@@ -104,6 +113,38 @@
sub list {
my ($request) = @_;
+ $request->{control_code} = '';
+ $request->{class_id} = 0 unless $request->{class_id} = 0;
+ my $b_unit = LedgerSMB::DBObject::Business_Unit->new(%$request);
+ my $template = LedgerSMB::Template->new(
+ user =>$request->{_user},
+ locale => $request->{_locale},
+ path => 'UI',
+ template => 'form-dynatable',
+ format => 'HTML'
+ );
+ my $cols;
+ @$cols = qw(id control_code description start_date end_date);
+ my $heading = {
+ id => $request->{_locale}->text('ID'),
+ control_code => $request->{_locale}->text('Control Code'),
+ description => $request->{_locale}->text('Description'),
+ start_date => $request->{_locale}->text('Start Date'),
+ end_date => $request->{_locale}->text('End Date'),
+ };
+ my $rows;
+ @$rows = $b_unit->list;
+ my $base_href= "business_unit.pl?action=edit";
+ for $row(@$rows){
+ $row->{control_code} = {text => $row->{control_code},
+ href => "$base_href&id=$row->{id}"};
+ }
+ $template->render({
+ form => $request,
+ heading => $heading,
+ rows => $rows,
+ columns => $cols,
+ });
}
=item delete
@@ -117,7 +158,7 @@
sub delete {
my ($request) = @_;
- my $unit = LedgerSMB::DBObject::Business_Unit->new($request);
+ my $unit = LedgerSMB::DBObject::Business_Unit->new(%$request);
$unit->delete;
list($request);
}
@@ -151,7 +192,6 @@
$request->{end_date} = LedgerSMB::PGDate->from_input($request->{end_date}, 0)
if defined $request->{end_date};
my $unit = LedgerSMB::DBObject::Business_Unit->new(%$request);
- my $unit = LedgerSMB::DBObject::Business_Unit->new(%$request);
$unit->save;
edit($request);
}
Modified: trunk/LedgerSMB/Template/HTML.pm
===================================================================
--- trunk/LedgerSMB/Template/HTML.pm 2012-02-23 02:50:35 UTC (rev 4349)
+++ trunk/LedgerSMB/Template/HTML.pm 2012-02-23 09:29:16 UTC (rev 4350)
@@ -63,6 +63,9 @@
sub preprocess {
my $rawvars = shift;
my $vars;
+ if (eval {$rawvars->can('to_output')}){
+ $rawvars = $rawvars->to_output;
+ }
my $type = ref $rawvars;
return $rawvars if $type =~ /^LedgerSMB::Locale/;
Modified: trunk/LedgerSMB/User.pm
===================================================================
--- trunk/LedgerSMB/User.pm 2012-02-23 02:50:35 UTC (rev 4349)
+++ trunk/LedgerSMB/User.pm 2012-02-23 09:29:16 UTC (rev 4350)
@@ -62,6 +62,11 @@
my $logger = Log::Log4perl->get_logger('LedgerSMB::User');
+sub dateformat {
+ my ($self) = @_;
+ return $self->{language};
+}
+
=item LedgerSMB::User->new($login);
Create a LedgerSMB::User object. If the user $login exists, set the fields
@@ -190,6 +195,7 @@
$sth->execute();
($templates) = $sth->fetchrow_array() || 'demo';
$myconfig->{templates} = "$LedgerSMB::Sysconfig::templates/$templates";
+ bless $myconfig, __PACKAGE__;
return $myconfig;
}
Modified: trunk/sql/modules/Business_Unit.sql
===================================================================
--- trunk/sql/modules/Business_Unit.sql 2012-02-23 02:50:35 UTC (rev 4349)
+++ trunk/sql/modules/Business_Unit.sql 2012-02-23 09:29:16 UTC (rev 4350)
@@ -137,17 +137,22 @@
IF FOUND THEN
- t_id = in_id;
+ t_id := in_id;
ELSE
INSERT INTO business_unit
(class_id, control_code, description, start_date, end_date, parent_id,
credit_id)
VALUES (in_class_id, in_control_code, in_description, in_start_date,
in_end_date, in_parent_id, in_credit_id);
+ t_id := currval('business_unit_id_seq');
END IF;
-SELECT * INTO retval FROM business_unit WHERE id = in_id;
+RAISE NOTICE 'ID: %', t_id;
+SELECT * INTO retval FROM business_unit WHERE id = t_id;
+
+RAISE NOTICE 'ID: %', retval.id;
+
RETURN retval;
END;
$$ LANGUAGE PLPGSQL;
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.