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

SF.net SVN: ledger-smb:[4639] addons/1.3



Revision: 4639
          http://ledger-smb.svn.sourceforge.net/ledger-smb/?rev=4639&view=rev
Author:   einhverfr
Date:     2012-04-09 06:35:51 +0000 (Mon, 09 Apr 2012)
Log Message:
-----------
Extension for storing person info along with business info

Added Paths:
-----------
    addons/1.3/company_person/
    addons/1.3/company_person/trunk/
    addons/1.3/company_person/trunk/LedgerSMB/
    addons/1.3/company_person/trunk/LedgerSMB/ScriptLib/
    addons/1.3/company_person/trunk/LedgerSMB/ScriptLib/Company_Person.pm
    addons/1.3/company_person/trunk/UI/
    addons/1.3/company_person/trunk/UI/Contact/
    addons/1.3/company_person/trunk/UI/Contact/divs/
    addons/1.3/company_person/trunk/UI/Contact/person.html
    addons/1.3/company_person/trunk/patches/
    addons/1.3/company_person/trunk/patches/customer_person.diff
    addons/1.3/company_person/trunk/sql/
    addons/1.3/company_person/trunk/sql/modules/
    addons/1.3/company_person/trunk/sql/modules/person_customer.sql

Added: addons/1.3/company_person/trunk/LedgerSMB/ScriptLib/Company_Person.pm
===================================================================
--- addons/1.3/company_person/trunk/LedgerSMB/ScriptLib/Company_Person.pm	                        (rev 0)
+++ addons/1.3/company_person/trunk/LedgerSMB/ScriptLib/Company_Person.pm	2012-04-09 06:35:51 UTC (rev 4639)
@@ -0,0 +1,69 @@
+package LedgerSMB::ScriptLib::Company;
+use base qw(LedgerSMB::ScriptLib::Company);
+use LedgerSMB::Template;
+use LedgerSMB::DBObject::Customer;
+use LedgerSMB::DBObject::Vendor;
+use LedgerSMB::DBObject;
+use LedgerSMB::Log;
+
+my $logger = Log::Log4perl->get_logger("LedgerSMB::ScriptLib::Company");
+
+use Data::Dumper;
+
+my $ec_labels = {
+      1 => 'Vendor',
+      2 => 'Customer',
+};
+
+=pod
+
+=head1 NAME
+
+LedgerSMB::ScriptLib::Company - LedgerSMB class defining the Controller
+functions, template instantiation and rendering for vendor and customer editing 
+and display.  This would also form the basis for other forms of company
+contacts.
+
+=head1 SYOPSIS
+
+This module is the UI controller for the vendor DB access; it provides the 
+View interface, as well as defines the Save vendor. 
+Save vendor/customer will update or create as needed.
+
+
+=head1 METHODS
+
+=over
+
+=item save_person
+
+=cut
+
+sub save_person {
+    my ($request) = @_;
+    my $dbhandle = LedgerSMB::DBObject->new({base => $request});
+    my ($ref) = $dbhandle->exec_method({funcname => 'person__save'});
+    $dbhandle->merge($ref);
+    $dbhahdle->exec_method({funcname => 'company__save_person'});
+    get($request);
+}
+
+sub get {
+    my ($request) = @_;
+    my $dbhandle = LedgerSMB::DBObject->new({base => $request});
+    my @{$request->{persons}} =  
+                 $dbhahdle->exec_method({funcname => 'entity__get_persons'});
+    LedgerSMB::ScriptLib::Company->get($request);
+}
+
+=back
+
+=head1 COPYRIGHT
+
+Copyright (c) 2009, the LedgerSMB Core Team.  This is licensed under the GNU 
+General Public License, version 2, or at your option any later version.  Please 
+see the accompanying License.txt for more information.
+
+=cut
+
+1;

Added: addons/1.3/company_person/trunk/UI/Contact/person.html
===================================================================
--- addons/1.3/company_person/trunk/UI/Contact/person.html	                        (rev 0)
+++ addons/1.3/company_person/trunk/UI/Contact/person.html	2012-04-09 06:35:51 UTC (rev 4639)
@@ -0,0 +1,74 @@
+<div id="person_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 = "target_div"
+		value = 'person_div'
+	} ?>
+<?lsmb PROCESS input element_data = {
+		type = "hidden"
+		name = "form_id"
+		value = form_id
+	} ?>
+<?lsmb PROCESS input element_data = {
+                type = "hidden"
+                name = "entity_id"
+               value = entity_id
+} ?>	
+<div class="input_line" id="person_name_div"><?lsmb #text('Name:')?>&nbsp;
+<div class="input_group">
+<!-- TODO:  Add Saluatation -->
+<?lsmb PROCESS input element_data = {
+	label = text('First Name') #'
+	name = "first_name"
+	value = first_name
+	type = "text"
+	size = 20
+} ?>
+</div>
+<div class="input_group">
+<?lsmb PROCESS input element_data = {
+	label = text('Middle Name') #'
+	name = "middle_name"
+	value = middle_name
+	type = "text"
+	size = 20
+} ?>
+</div>
+</div>
+<div class="input_line" id='person_name2_div'>
+<div class="input_group">
+<?lsmb PROCESS input element_data = {
+	label = text('Last Name') #'
+	name = "last_name"
+	value = last_name
+	type = "text"
+	size = 20
+} ?>
+</div>
+</div>
+<div class="input_line" id="person-country-div">
+<div class="input_group">
+       <?lsmb country_list.unshift({}) ?>
+		<?lsmb INCLUDE select element_data = {
+			text_attr = "name"
+			value_attr = "id"
+			default_values = [country_id]
+			options = country_list
+			name = "country_id"
+			label = text('Country') 
+	} ?> 
+</div>
+</div>
+<div>
+<?lsmb PROCESS button element_data = {
+	text = text('Save')
+	class = "submit"
+	type = "submit"
+        name = 'action'
+	value = "save"
+} ?>
+</div>
+</form>
+</div>

Added: addons/1.3/company_person/trunk/patches/customer_person.diff
===================================================================
--- addons/1.3/company_person/trunk/patches/customer_person.diff	                        (rev 0)
+++ addons/1.3/company_person/trunk/patches/customer_person.diff	2012-04-09 06:35:51 UTC (rev 4639)
@@ -0,0 +1,15 @@
+Index: UI/Contact/contact.html
+===================================================================
+--- UI/Contact/contact.html	(revision 4631)
++++ UI/Contact/contact.html	(working copy)
+@@ -386,6 +386,10 @@
+ <?lsmb END ?>
+ </div>
+ <?lsmb IF entity_id ?>
++<?lsmb IF account_class == 1 or account_class == 2;
++            PROCESS "divs/person.html";
++       END;
++?>
+ <div id="credit_div" class="container">
+ <div class="listtop"><strong>Accounts</strong></div>
+     <table width="100%">

Added: addons/1.3/company_person/trunk/sql/modules/person_customer.sql
===================================================================
--- addons/1.3/company_person/trunk/sql/modules/person_customer.sql	                        (rev 0)
+++ addons/1.3/company_person/trunk/sql/modules/person_customer.sql	2012-04-09 06:35:51 UTC (rev 4639)
@@ -0,0 +1,55 @@
+BEGIN;
+
+CREATE OR REPLACE FUNCTION company__save_person
+(in_entity_id int, in_person_id int, in_location_id int)
+RETURNS person_to_company AS 
+$$
+DECLARE t_location_id int;
+        retval person_to_company;
+BEGIN;
+
+IF in_location_id IS NULL THEN
+   SELECT location_id INTO t_location_id 
+     FROM company_to_location 
+    WHERE entity_id = in_entity_id
+   ORDER BY location_class LIMIT 1;
+ELSE 
+   t_location_id := in_location_id;
+END IF;
+
+IF t_location_id IS NULL
+    SELECT location_id INTO t_location_id 
+      FROM eca_to_location e2l
+      JOIN entity_credit_account eca ON e2l.credit_id = eca.id
+     WHERE eca.entity_id = in_entity_id
+  ORDER BY location_class, credit_id LIMIT 1;
+END IF;
+
+UPDATE person_to_company
+   SET location_id = t_location_id
+ WHERE company_id = in_entity_id
+       AND person_id = in_person_id;
+
+IF NOT FOUND THEN
+    INSERT INTO person_to_company(company_id, person_id, location_id)
+    VALUES (in_entity_id, in_person_id, t_location_id);
+END IF;
+
+SELECT * INTO retval 
+  FROM company_to_person
+ WHERE company_id = in_entity_id
+       AND person_id = in_person_id;
+
+RETURN retval;
+
+END;
+$$ LANGUAGE PLPGSQL;
+
+CREATE OR REPLACE FUNCTION entity__get_persons (in_entity_id int)
+RETURNS SETOF person AS
+$$
+SELECT * FROM person 
+ WHERE id IN (select * from company_to_person WHERE company_id = $1)
+$$ LANGUAGE SQL;
+
+COMMIT; 

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