diff options
Diffstat (limited to 'LedgerSMB')
-rw-r--r-- | LedgerSMB/DBObject.pm | 47 | ||||
-rw-r--r-- | LedgerSMB/Employee.pm | 19 | ||||
-rw-r--r-- | LedgerSMB/Location.pm | 4 |
3 files changed, 38 insertions, 32 deletions
diff --git a/LedgerSMB/DBObject.pm b/LedgerSMB/DBObject.pm index 071acb68..beb95fb2 100644 --- a/LedgerSMB/DBObject.pm +++ b/LedgerSMB/DBObject.pm @@ -29,14 +29,17 @@ use strict; no strict 'refs'; use warnings; -@ISA = (LedgerSMB); +our @ISA = qw(LedgerSMB); sub new { my $lsmb = shift @_; - if (! $lsmb->isa(LedgerSMB)){ - $self->error("Constructor called without LedgerSMB object arg"); my $self = {}; - for $attr (keys $lsmb){ + if (! $lsmb->isa('LedgerSMB')){ + $self->error("Constructor called without LedgerSMB object arg"); + } + + my $attr; + for $attr (keys %{$lsmb}){ $self->{$attr} = $lsmb->{$attr}; } bless $self; @@ -49,34 +52,36 @@ sub exec_method { my $query = "SELECT proname, proargnames FROM pg_proc WHERE proname = ?"; - my $sth = $self->{__dbh}->prepare($query); + my $sth = $self->{dbh}->prepare($query); $sth->execute($funcname); my $ref; - $ref = $sth->fetchrow_hashref(NAME_lc); + $ref = $sth->fetchrow_hashref('NAME_lc'); + my $args = $ref->{proargnames}; + $args =~ s/\{(.*)\}/$1/; + my @proc_args = split /,/, $args; + print "Ref: $ref\n"; + print "Args: $ref->{proargnames}\n"; if (!$ref){ # no such function - $self->error($locale->text("No such function: ") .$funcname; + $self->error("No such function: ", $funcname); die; } my $m_name = $ref->{proname}; - my $args = $ref->{proargnames}; - my @proc_args; - - if ($m_name ~= s/$name\_//){ - push @{$self->{__methods}}, $m_name; - if ($args){ - for $arg (@$args){ - if ($arg =~ s/^in_//){ - push @proc_args, $ref->{$arg}; - } + + if ($args){ + for my $arg (@proc_args){ + if ($arg =~ s/^in_//){ + print "Arg: $arg\n"; + push @proc_args, $self->{$arg}; } } - else { - @proc_args = @_; - } } + else { + @proc_args = @_; + } + print "Arg2s: @_ \n"; $self->callproc($funcname, @proc_args); } - +1; diff --git a/LedgerSMB/Employee.pm b/LedgerSMB/Employee.pm index a299ea86..9ddbbc8f 100644 --- a/LedgerSMB/Employee.pm +++ b/LedgerSMB/Employee.pm @@ -33,33 +33,34 @@ use LedgerSMB; use LedgerSMB::DBObject; our $VERSION = '1.0.0'; -@ISA = (LedgerSMB::DBObject); +our @ISA = qw(LedgerSMB::DBObject); sub AUTOLOAD { + my $self = shift; my $procname = "employee_$LedgerSMB::Employee::Autoload"; - $self->exec_method($procname); + $self->exec_method($procname, @_); } sub save { - my $hashref = shift ($self->exec_method("employee_save")); + my $self = shift; + my $hashref = shift @{$self->exec_method("employee_save")}; $self->merge($hashref, 'id'); } sub get { - my $hashref = shift ($self->exec_method("employee_get")); - $self->merge($hashref, keys $hashref); -} - -sub delete { - $self->exec_method("employee_delete"); + my $self = shift; + my $hashref = shift @{$self->exec_method("employee_get")}; + $self->merge($hashref, keys %{$hashref}); } sub list_managers { + my $self = shift; $self->{manager_list} = $self->exec_method("employee_list_managers"); } sub search { + my $self = shift; $self->{search_results} = $self->exec_method("employee_search"); } diff --git a/LedgerSMB/Location.pm b/LedgerSMB/Location.pm index 3c7eda52..95128e51 100644 --- a/LedgerSMB/Location.pm +++ b/LedgerSMB/Location.pm @@ -34,7 +34,7 @@ use LedgerSMB; use LedgerSMB::DBObject; our $VERSION = '1.0.0'; -@ISA = (LedgerSMB::DBObject); +our @ISA = qw(LedgerSMB::DBObject); sub AUTOLOAD { my $procname = "location_$LedgerSMB::Location::Autoload"; @@ -48,7 +48,7 @@ sub save { sub get { $ref = shift @{$self->exec_method('location_get')}; - $self->merge($ref, keys $ref); + $self->merge($ref, keys %{$ref}); } sub search { |