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

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



Revision: 4799
          http://ledger-smb.svn.sourceforge.net/ledger-smb/?rev=4799&view=rev
Author:   einhverfr
Date:     2012-05-29 09:32:38 +0000 (Tue, 29 May 2012)
Log Message:
-----------
Basic contact info management now works on new modular codebase

Modified Paths:
--------------
    trunk/LedgerSMB/Scripts/contact.pm
    trunk/UI/Contact/divs/address.html
    trunk/UI/Contact/divs/contact_info.html
    trunk/UI/Contact/divs/credit.html
    trunk/sql/modules/Company.sql

Modified: trunk/LedgerSMB/Scripts/contact.pm
===================================================================
--- trunk/LedgerSMB/Scripts/contact.pm	2012-05-29 02:38:05 UTC (rev 4798)
+++ trunk/LedgerSMB/Scripts/contact.pm	2012-05-29 09:32:38 UTC (rev 4799)
@@ -52,6 +52,7 @@
     $request->{entity_class} ||= $request->{account_class};
     $request->{legal_name} ||= 'test';
     $request->{country_id} = 0;
+    $request->{target_div} = 'credit_div';
     my $company = LedgerSMB::DBObject::Entity::Company->new(%$request);
     $company = $company->get_by_cc($request->{control_code});
     _main_screen($request, $company);
@@ -241,6 +242,7 @@
                 entity_id => $entity_id,
              entity_class => $entity_class,
       location_class_list => ..hidden..,
+       contact_class_list => ..hidden..,
     });
 }
 
@@ -257,7 +259,7 @@
                              args     => ['entity_control']
                            );
     ($request->{control_code}) = values %$ref;
-    $request->{dbh}->commit;
+    $request->{target_div} = 'company_div';
     _main_screen($request, $request);
 }
 
@@ -408,6 +410,7 @@
     my $company = LedgerSMB::DBObject::Entity::Company->new(%$request);
     use Data::Dumper;
     $Data::Dumper::Sortkeys => 1;
+    $request->{target_div} = 'credit_div';
     $company = $company->save;
     _main_screen($request, $company);
 }
@@ -421,6 +424,7 @@
 sub save_credit {
     
     my ($request) = @_;
+    $request->{target_div} = 'credit_div';
     my $company;
     my @taxes;
 
@@ -502,6 +506,12 @@
     get (@_);
 }
 
+=item delete_location
+
+Deletes the specified location
+
+=cut
+
 sub delete_location {
     my ($request) = @_;
     my $location = LedgerSMB::DBObject::Entity::Location->new(%$request);
@@ -510,7 +520,42 @@
        $location->credit_id(undef);
     }
     $location->delete;
+    $request->{target_div} = 'address_div';
     get($request);
 }
 
+=item save_contact
+
+Saves the specified contact info
+
+=cut
+
+sub save_contact {
+    my ($request) = @_;
+    my $contact = LedgerSMB::DBObject::Entity::Contact->new(%$request);
+    if ($request->{attach_to} == 1){
+       $contact->credit_id(undef);
+    }
+    $contact->save;
+    $request->{target_div} = 'address_div';
+    $request->{target_div} = 'contact_info_div';
+    get($request);
+} 
+
+=item selete_contact
+
+Deletes the specified contact info.  Note that for_credit is used to pass the 
+credit id over in this case.
+
+=cut
+
+sub delete_contact {
+    my ($request) = @_;
+    my $contact = LedgerSMB::DBObject::Entity::Contact->new(%$request);
+    $contact->credit_id($request->{for_credit});
+    $contact->delete;
+    $request->{target_div} = 'contact_info_div';
+    get($request);
+}
+
 1;

Modified: trunk/UI/Contact/divs/address.html
===================================================================
--- trunk/UI/Contact/divs/address.html	2012-05-29 02:38:05 UTC (rev 4798)
+++ trunk/UI/Contact/divs/address.html	2012-05-29 09:32:38 UTC (rev 4799)
@@ -83,7 +83,9 @@
                           options         = attach_level_options
                           label           = text('Attach To') #'
                        };
-                     END; ?>
+                     ELSE ?>
+             <label><?lsmb text('Attach to') ?></label><?lsmb text('Entity');
+                    END; ?>
 	<div> 
                 <?lsmb INCLUDE select element_data = {
                        name           = "location_class"
@@ -180,3 +182,4 @@
 	</div>
     </form>
 </div>
+</div>

Modified: trunk/UI/Contact/divs/contact_info.html
===================================================================
--- trunk/UI/Contact/divs/contact_info.html	2012-05-29 02:38:05 UTC (rev 4798)
+++ trunk/UI/Contact/divs/contact_info.html	2012-05-29 09:32:38 UTC (rev 4799)
@@ -2,27 +2,31 @@
 <div class="listtop"><?lsmb text('Contact Information') ?></div>
 <?lsmb 
 
-FOREACH row IN contacts;
-    row.edit = '[' _ text('Edit') _ ']';
-    row.delete = '[' _ text('Delete') _ ']';
-    row.edit_href_suffix = 
+FOREACH ROW IN contacts;
+    ROW.edit = '[' _ text('Edit') _ ']';
+    ROW.delete = '[' _ text('Delete') _ ']';
+    ROW.edit_href_suffix = 
                tt_url(script) _ '?entity_id=' _ entity_id _ '&contact=' _
-               tt_url(row.contact) _ '&contact_class=' _ row.contact _
-               '&contact_class=' _ row.class_id _ '&description=' _
-               tt_url(row.description) _ '&credit_id=' _ credit_id _
-               '&action=edit&target_div=contact_div';
-    row.delete_href_suffix = 
+               tt_url(ROW.contact) _ '&class_id=' _ ROW.class_id _
+               '&description=' _ tt_url(ROW.description) _ '&credit_id=' _ 
+               credit_act.id _ '&action=edit&target_div=contact_div&for_credit='
+               _ ROW.credit_id;
+    ROW.delete_href_suffix = 
                tt_url(script) _ '?entity_id=' _ entity_id _ '&contact=' _
-               tt_url(row.contact) _ '&contact_class=' _ row.contact _
-               '&contact_class=' _ row.class_id _ '&description=' _
-               tt_url(row.description) _ '&credit_id=' _ credit_id _
-               '&action=delete_contact&target_div=contact_div';
+               tt_url(ROW.contact) _ '&class_id=' _ ROW.class_id _ 
+               '&description=' _ tt_url(ROW.description) _ '&credit_id=' _ 
+               credit_act.id _ '&action=delete_contact&' _
+               'target_div=contact_div&for_credit=' _ ROW.credit_id;
+    IF ROW.credit_id;
+         ROW.for_credit = 'X';
+    END;
 END;
 PROCESS dynatable 
         attributes = {id = 'contact-list' }
         tbody = {rows = contacts}
         columns = [
-         {col_id='class_name', type='text' name=text('Type') },
+         {col_id='for_credit', type='text', name=text('This Account') }, #' 
+         {col_id='class', type='text', name=text('Type') },
          {col_id='description', type='text', name=text('Description') },
          {col_id='contact', type='text', name=text('Contact Info') } #'
          {col_id='edit', type='href', href_base='', name='' }
@@ -34,11 +38,6 @@
 		name = "form_id"
 		value = form_id
 	} ?>
-<?lsmb PROCESS input element_data = {
-		type = "hidden"
-		name = "target_div"
-		value = 'contact_div'
-	} ?>
 	<?lsmb PROCESS input element_data = {
 		type="hidden" 
 		name="entity_id" 
@@ -47,30 +46,42 @@
 	<?lsmb PROCESS input element_data = {
 		type="hidden" 
 		name="credit_id" 
-		value=credit_id
+		value=credit_act.id
 	} ?>
 	<?lsmb PROCESS input element_data = {
 		type="hidden" 
 		name="old_contact_class" 
-		value=contact_class
+		value=request.contact_class
 	} ?>
 	<?lsmb PROCESS input element_data = {
 		type="hidden" 
 		name="old_contact" 
-		value=contact
+		value=request.contact
 	} ?>
 	<?lsmb PROCESS input element_data = {
 		type="hidden" 
 		name="contact_id" 
-		value=contact_id
+		value=request.contact_id
 	} ?>
+        <div>
+           
+             <?lsmb IF credit_act.id;
+                       INCLUDE select element_data = {
+                          name            = "attach_to"
+                          default_options = ['3']
+                          options         = attach_level_options
+                          label           = text('Attach To') #'
+                       };
+                     ELSE ?>
+             <label><?lsmb text('Attach to') ?></label><?lsmb text('Entity');
+                    END; ?>
 	<div>
 		<?lsmb PROCESS select element_data = {
 			name = "class_id"
 			label = "Type"
 			text_attr = "class"
 			value_attr = "id"
-			default_values = [contact_class]		
+			default_values = [request.class_id]		
 			options = contact_class_list
 		} ?>
 	</div>
@@ -78,7 +89,7 @@
 		<?lsmb PROCESS input element_data = {
 			label = text('Description'),
 			name = "description"
-			value = description
+			value = request.description
 			type = "text"
 			size = "20"
 		} #' ?>
@@ -87,7 +98,7 @@
 		<?lsmb PROCESS input element_data = {
 			label = text('Contact Info'),
 			name = "contact"
-			value = contact
+			value = request.contact
 			type = "text"
 			size = "20"
 		} #' ?>

Modified: trunk/UI/Contact/divs/credit.html
===================================================================
--- trunk/UI/Contact/divs/credit.html	2012-05-29 02:38:05 UTC (rev 4798)
+++ trunk/UI/Contact/divs/credit.html	2012-05-29 09:32:38 UTC (rev 4799)
@@ -9,7 +9,8 @@
         account_class_label = text('Customer');
    END;
    cl.meta_number_href_suffix = 'account_class=' _ cl.entity_class _ 
-      '&entity_id=' _ cl.entity_id _ '&meta_number=' _ cl.meta_number;
+      '&entity_id=' _ cl.entity_id _ '&meta_number=' _ cl.meta_number _
+      '&target_div=credit_div';
 END;
 
 PROCESS dynatable 

Modified: trunk/sql/modules/Company.sql
===================================================================
--- trunk/sql/modules/Company.sql	2012-05-29 02:38:05 UTC (rev 4798)
+++ trunk/sql/modules/Company.sql	2012-05-29 09:32:38 UTC (rev 4799)
@@ -1017,14 +1017,14 @@
 in_bank_account_id int) IS
 $$ Saves bank account to the credit account.$$;
 
-CREATE OR REPLACE FUNCTION company__delete_contact
-(in_company_id int, in_contact_class_id int, in_contact text)
+CREATE OR REPLACE FUNCTION entity__delete_contact
+(in_entity_id int, in_class_id int, in_contact text)
 returns bool as $$
 BEGIN
 
 DELETE FROM entity_to_contact
- WHERE entity_id = (select entity_id from company where id = in_companu_id) 
-       and contact_class_id = in_contact_class_id
+ WHERE entity_id = in_entity_id
+       and contact_class_id = in_class_id
        and contact= in_contact;
 RETURN FOUND;
 
@@ -1038,12 +1038,12 @@
 affected.$$;
 
 CREATE OR REPLACE FUNCTION eca__delete_contact
-(in_credit_id int, in_contact_class_id int, in_contact text)
+(in_credit_id int, in_class_id int, in_contact text)
 returns bool as $$
 BEGIN
 
 DELETE FROM eca_to_contact
- WHERE credit_id = in_credit_id and contact_class_id = in_contact_class_id
+ WHERE credit_id = in_credit_id and contact_class_id = in_class_id
        and contact= in_contact;
 RETURN FOUND;
 
@@ -1351,7 +1351,7 @@
 $$ Returns a list of contact info attached to the entity credit account.$$;
 
 CREATE OR REPLACE FUNCTION eca__save_contact
-(in_credit_id int, in_contact_class int, in_description text, in_contact text,
+(in_credit_id int, in_class_id int, in_description text, in_contact text,
 in_old_contact text, in_old_contact_class int)
 RETURNS INT AS
 $$
@@ -1368,14 +1368,14 @@
         UPDATE eca_to_contact
            SET contact = in_contact,
                description = in_description,
-               contact_class_id = in_contact_class
+               contact_class_id = in_class_id
          WHERE credit_id = in_credit_id
            AND contact_class_id = in_old_contact_class
            AND contact = in_old_contact;
     ELSE
         INSERT INTO eca_to_contact(credit_id, contact_class_id, 
                 description, contact)
-        VALUES (in_credit_id, in_contact_class, in_description, in_contact);
+        VALUES (in_credit_id, in_class_id, in_description, in_contact);
         
     END IF;
 

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