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

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



Revision: 1910
          http://ledger-smb.svn.sourceforge.net/ledger-smb/?rev=1910&view=rev
Author:   einhverfr
Date:     2007-11-27 00:08:19 -0800 (Tue, 27 Nov 2007)

Log Message:
-----------
Employee screen QA round 1.

Modified Paths:
--------------
    trunk/LedgerSMB/DBObject/Employee.pm
    trunk/UI/Contact/contact.css
    trunk/UI/Contact/contact.html
    trunk/sql/modules/Person.sql

Modified: trunk/LedgerSMB/DBObject/Employee.pm
===================================================================
--- trunk/LedgerSMB/DBObject/Employee.pm	2007-11-27 02:27:48 UTC (rev 1909)
+++ trunk/LedgerSMB/DBObject/Employee.pm	2007-11-27 08:08:19 UTC (rev 1910)
@@ -1,6 +1,6 @@
 package LedgerSMB::DBObject::Employee;
 
-use base qw(LedgerSMB::DBObject::Company);
+use base qw(LedgerSMB::DBObject);
 use strict;
 
 my $ENTITY_CLASS = 3;
@@ -9,5 +9,25 @@
     my $self = shift @_;
     $self->{entity_class} = $ENTITY_CLASS;
 }
+
+sub save {
+   my ($self) = @_;
+   $self->set_entity_class();
+   $self->{entity_id} = $self->exec_method(funcname => 'person_save');
+   $self->exec_method(funcname => 'employee__save');
+   $self->{dbh}->commit;
+}
+
+sub save_location {
+}
+
+sub save_contact {
+}
+
+sub save_bank_account {
+}
+
+sub save_note {
+}
     
 1;

Modified: trunk/UI/Contact/contact.css
===================================================================
--- trunk/UI/Contact/contact.css	2007-11-27 02:27:48 UTC (rev 1909)
+++ trunk/UI/Contact/contact.css	2007-11-27 08:08:19 UTC (rev 1910)
@@ -18,3 +18,7 @@
 	margin-left: 1em;
 	margin-bottom: 0em;
 }
+
+div label {
+	margin-left: 1em;
+}

Modified: trunk/UI/Contact/contact.html
===================================================================
--- trunk/UI/Contact/contact.html	2007-11-27 02:27:48 UTC (rev 1909)
+++ trunk/UI/Contact/contact.html	2007-11-27 08:08:19 UTC (rev 1910)
@@ -35,13 +35,109 @@
 </ul>
 </div>
 <?lsmb IF entity_class == 3 ?>
+<div id="hr_div" class="container">
+	<div class="listtop"><strong><?lsmb text("$operation Employee") ?></strong></div>
+<form name="hr" action="<?lsmb script ?>" method="post">
+<?lsmb PROCESS input element_data = {
+		type = "hidden"
+		name = "entity_id"
+		value = entity_id
+	} ?>
+<div class="input" id="person_name_div"><?lsmb text('Name:')?>&nbsp;
+<!-- TODO:  Add Saluatation -->
+<?lsmb PROCESS input element_data = {
+	label = text('First')
+	name = "first_name"
+	value = first_name
+	type = "text"
+	size = 20
+} ?>
+<?lsmb PROCESS input element_data = {
+	label = text('Middle')
+	name = "middle_name"
+	value = middle_name
+	type = "text"
+	size = 20
+} ?>
+<?lsmb PROCESS input element_data = {
+	label = text('Last')
+	name = "last_name"
+	value = last_name
+	type = "text"
+	size = 20
+} ?>
+</div>
+<div id="job_title_div">
+<!-- Note that the strange # ' constructs are only necessary to help VIM avoid
+problems with multi-word single-quoted constructs in PI tags. -CT  -->
+<?lsmb PROCESS input element_data = {
+	label = text('Job Title:')
+	name = "role"
+	value = role
+	type = "text"
+	size = 20
+} # ' ?>
+<?lsmb PROCESS input element_data = {
+	label = text('Sales:')
+	value = 1
+	type = "checkbox"
+	checked = sales
+	name = "sales"
+} ?>
+<?lsmb PROCESS input element_data = {
+	label = text('Employee Number')
+	value = employee_number
+	name = "employee_number"
+	type = "text"
+	size = 20
+} # ' ?>
+<label for="manager_select"><?lsmb text('Manager:') ?></label>
+<select id="manager_select" name="manager_id">
+<?lsmb FOREACH e = employee ?>
+<option value = e.entity_id <?lsmb (manager_id == e.entity_id) ? "SELECTED" : ""?><?lsmb e.name ?></option>
+<?lsmb END ?>
+</select>
+<div>
+<?lsmb PROCESS input element_data = {
+	label = text('DOB:')
+	name = "dob"
+	value = dob
+	type = "text"
+	class = "date"
+	size = 10
+}  ?>
+<?lsmb PROCESS input element_data = {
+	label = text('Start Date:')
+	name = "start_date"
+	value = start_date
+	type = "text"
+	class = "date"
+	size = 10
+} # '  ?>
+<?lsmb PROCESS input element_data = {
+	label = text('End Date:')
+	name = "end_date"
+	value = end_date
+	class = "text"
+	type = "text"
+	size = 10
+} # ' ?>
+<div>
+<?lsmb PROCESS button element_data = {
+	text = text('Save')
+	class = "submit"
+	type = "submit"
+	value = "save_employee"
+} ?>
+</div>
+</form>
 <?lsmb ELSE ?>
 <div class="container" id="customer_div">
 <?lsmb SWITCH entity_class
 	?><?lsmb CASE 1 ?><?lsmb entity_classname = "Vendor" 
 	?><?lsmb CASE 2 ?><?lsmb entity_classname = "Customer" 
-?><?lsmb END ?>
-<div class="listtop"><strong><?lsmb text("$operation $entity_classname") ?></strong></div>
+	?><?lsmb END ?>
+	<div class="listtop"><strong><?lsmb text("$operation $entity_classname") ?></strong></div>
 <?lsmb FOREACH n = notes ?>
 <div class="entity_note"><?lsmb n.note ?></div>
 <?lsmb END ?>
@@ -64,7 +160,7 @@
 		name = "meta_number",
 		value = meta_number,
 		size = "20"
-	} ?><br/>
+	}  # ' ?><br/>
         <table>
         <tr>
             <td>
@@ -76,7 +172,7 @@
 			type = "text",
 			size = "12",
 			maxlength = "10"
-		} ?>
+		} #' ?>
             </td>
             <td>
 		<?lsmb PROCESS input element_data = {
@@ -87,7 +183,7 @@
 			type = "text",
 			size = "12",
 			maxlength = "10"
-		} ?>
+		} #' ?>
             </td>
         </tr>
         <tr>
@@ -98,7 +194,7 @@
 			value = creditlimit,
 			type = "text",
 			size = "20"
-		} ?>
+		} #' ?>
             </td>
             <td>
 		<?lsmb PROCESS input element_data = {
@@ -119,7 +215,7 @@
 			value = taxnumber,
 			type = "text",
 			size = "19"
-		} ?>
+		} #' ?>
             </td>
             <td>
 		<?lsmb PROCESS input element_data = {
@@ -128,7 +224,7 @@
 			value = gifi_accno,
 			type = "text",
 			size = "19"
-		} ?>
+		} #' ?>
             </td>
         </tr>
 	<tr>
@@ -332,7 +428,7 @@
 			value = mail_code,
 			type = "text",
 			size = "20"
-		} ?>
+		} #' ?>
 	</div>
 	<div> <!-- TODO:  Move to elements.html -CT -->
 		<label for="country"><?lsmb text('Country:') ?></label>
@@ -348,7 +444,7 @@
 		value = "add_location" 
 		id = "loc_save_location"
 		text = text('Save Location') 
-	} ?>
+	} #' ?>
 	</div>
     </form>
 </div>
@@ -403,14 +499,14 @@
 			value = contact
 			type = "text"
 			size = "20"
-		} ?>
+		} #' ?>
 	</div>
 	<div><?lsmb PROCESS button element_data = {
 		name = "action",
 		value = "save_contact",
 		text =  text('Save Contact'),
 		class = "submit"
-		} ?>
+		} #' ?>
 	</div>
 </form>
 	
@@ -456,7 +552,7 @@
 		name="bic" 
 		value=bic
 		size=20
-	} ?>
+	} #' ?>
 	</div>
 	<div><label for="iban">
 	<?lsmb PROCESS input element_data = {
@@ -465,7 +561,7 @@
 		name="iban" 
 		value=iban
 		size=20
-	} ?>
+	} #' ?>
 	</div>
 	<div><?lsmb PROCESS button element_data = {
 		name="action" 

Modified: trunk/sql/modules/Person.sql
===================================================================
--- trunk/sql/modules/Person.sql	2007-11-27 02:27:48 UTC (rev 1909)
+++ trunk/sql/modules/Person.sql	2007-11-27 08:08:19 UTC (rev 1910)
@@ -1,9 +1,8 @@
 begin;
 
 CREATE OR REPLACE FUNCTION person_save
-
-(in_id integer, in_salutation int, 
-in_first_name text, in_last_name text    
+(in_entity_id integer, in_salutation_id int, 
+in_first_name text, in_middle_name text, in_last_name text    
 )
 RETURNS INT AS $$
 
@@ -12,41 +11,72 @@
         e entity;
         loc location;
         l_id int;
-        per person;
         p_id int;
     BEGIN
     
-    select * into e from entity where id = in_id and entity_class = 3;
+    select * into e from entity where id = in_entity_id and entity_class = 3;
+    e_id := in_entity_id; 
     
     IF NOT FOUND THEN
-        RAISE EXCEPTION 'No entity found for ID %', in_id;
+        INSERT INTO entity (name, entity_class) 
+	values (in_first_name || ' ' || in_last_name, 3);
+	e_id := currval('entity_id_seq');
+       
     END IF;
     
-    select * into per FROM person WHERE entity_id = in_id;
-    
+      
+    UPDATE person SET
+            salutation_id = in_salutation_id,
+            first_name = in_first_name,
+            last_name = in_last_name,
+            middle_name = in_middle_name
+    WHERE
+            entity_id = in_entity_id;
     IF FOUND THEN
-    
-        -- do an update
-        
-        UPDATE person SET
-            salutation = in_salutation,
-            first_name = in_first_name,
-            last_name = in_last_name
-        WHERE
-            entity_id = in_id
-        AND
-            id = per.id;
-    
-    ELSE
-    
+	RETURN in_entity_id;
+    ELSE 
         -- Do an insert
         
-        INSERT INTO person (salutation, first_name, last_name) VALUES 
-            (in_salutation, in_first_name, in_last_name);
-                
+        INSERT INTO person (salutation_id, first_name, last_name, entity_id)
+	VALUES (in_salutation_id, in_first_name, in_last_name, e_id);
+        RETURN e_id;
     
     END IF;
 END;
 $$ language plpgsql;
 
+CREATE OR REPLACE FUNCTION employee__save 
+(in_entity_id int, in_start_date date, in_end_date date, in_dob date, 
+	in_role text, in_ssn text, in_sales bool, in_manager_id int, in_employee_number text)
+RETURNS int AS $$
+DECLARE out_id INT;
+BEGIN
+	UPDATE entity_employee 
+	SET startdate = in_start_date,
+		enddate = in_end_date,
+		dob = in_dob,
+		role = in_role,
+		ssn = in_ssn,
+		manager_id = in_manager_id,
+		employeenumber = in_employee_number,
+		person_id = (select id FROM person 
+			WHERE entity_id = in_entity_id)
+	WHERE entity_id = in_entity_id;
+
+	out_id = in_entity_id;
+
+	IF NOT FOUND THEN
+		INSERT INTO entity_employee 
+			(startdate, enddate, dob, role, ssn, manager_id, 
+				employeenumber, entity_id, person_id)
+		VALUES
+			(in_start_date, in_end_date, in_dob, in_role, in_ssn,
+				in_manager_id, in_employee_number, in_entity_id,
+				(SELECT id FROM person 
+				WHERE entity_id = in_entity_id));
+		RETURN in_entity_id;
+	END IF;
+END;
+$$ LANGUAGE PLPGSQL;
+
 commit;


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