[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

SF.net SVN: ledger-smb:[3297] trunk



Revision: 3297
          http://ledger-smb.svn.sourceforge.net/ledger-smb/?rev=3297&view=rev
Author:   einhverfr
Date:     2011-06-20 09:25:20 +0000 (Mon, 20 Jun 2011)

Log Message:
-----------
Employee notes/contact info/bank info/notes now save without errors.  Not displaying yet though.

Modified Paths:
--------------
    trunk/LedgerSMB/DBObject/Employee.pm
    trunk/scripts/employee.pl
    trunk/sql/modules/Employee.sql

Modified: trunk/LedgerSMB/DBObject/Employee.pm
===================================================================
--- trunk/LedgerSMB/DBObject/Employee.pm	2011-06-20 07:38:55 UTC (rev 3296)
+++ trunk/LedgerSMB/DBObject/Employee.pm	2011-06-20 09:25:20 UTC (rev 3297)
@@ -33,6 +33,7 @@
 
 sub save_contact {
     my ($self) = @_;
+    $self->{contact_new} = $self->{contact};
     $self->exec_method(funcname => 'person__save_contact');
     $self->{dbh}->commit;
 }
@@ -87,4 +88,17 @@
     $self->{default_country} = $country_setting->{value};
 }
 
+sub get {
+    my $self = shift @_;
+    my ($ref) = $self->exec_method(funcname => 'employee__get');
+    $self->merge($ref);
+     
+}    
+
+sub save_notes {
+    my $self = shift @_;
+    $self->exec_method(funcname => 'entity__save_notes');
+    $self->{dbh}->commit;
+}
+
 1;

Modified: trunk/scripts/employee.pl
===================================================================
--- trunk/scripts/employee.pl	2011-06-20 07:38:55 UTC (rev 3296)
+++ trunk/scripts/employee.pl	2011-06-20 09:25:20 UTC (rev 3297)
@@ -173,7 +173,7 @@
 sub _render_main_screen{
     my $employee = shift @_;
     $employee->get_metadata();
-
+    $employee->{entity_class} = 3;
     $employee->{creditlimit} = "$employee->{creditlimit}"; 
     $employee->{discount} = "$employee->{discount}"; 
     $employee->{script} = "employee.pl";

Modified: trunk/sql/modules/Employee.sql
===================================================================
--- trunk/sql/modules/Employee.sql	2011-06-20 07:38:55 UTC (rev 3296)
+++ trunk/sql/modules/Employee.sql	2011-06-20 09:25:20 UTC (rev 3297)
@@ -46,24 +46,40 @@
     LEFT JOIN salutation s ON (p.salutation_id = s.id);
 
 GRANT select ON employees TO public;
-    
 
+CREATE TYPE employee_result AS (
+    entity_id int,
+    person_id int,
+    salutation text,
+    first_name text,
+    middle_name text,
+    last_name text,
+    startdate date,
+    enddate date,
+    role varchar(20),
+    ssn text,
+    sales bool,
+    manager_id int,
+    manager_first_name text,
+    manager_last_name text,
+    employeenumber varchar(32),
+    dob date
+);
+
 CREATE OR REPLACE FUNCTION employee__get
-(in_id integer)
-returns employees as
+(in_entity_id integer)
+returns employee_result as
 $$
-DECLARE
-	emp employees%ROWTYPE;
-BEGIN
-	SELECT 
-	    ee.* 
-	INTO emp 
-    FROM employees ee 
-    WHERE ee.entity_id = in_id;
-    
-	RETURN emp;
-END;
-$$ language plpgsql;
+   SELECT p.entity_id, p.id, s.salutation, 
+          p.first_name, p.middle_name, p.last_name,
+          ee.startdate, ee.enddate, ee.role, ee.ssn, ee.sales, ee.manager_id,
+          mp.first_name, mp.last_name, ee.employeenumber, ee.dob
+     FROM person p
+     JOIN entity_employee ee on (ee.entity_id = p.entity_id)
+LEFT JOIN salutation s on (p.salutation_id = s.id)
+LEFT JOIN person mp ON ee.manager_id = p.entity_id
+    WHERE p.entity_id = $1;
+$$ language sql;
 
 CREATE OR REPLACE FUNCTION employee__list_managers
 (in_id integer)


This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.