[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
SF.net SVN: ledger-smb:[4798] trunk
- Subject: SF.net SVN: ledger-smb:[4798] trunk
- From: ..hidden..
- Date: Tue, 29 May 2012 02:38:05 +0000
Revision: 4798
http://ledger-smb.svn.sourceforge.net/ledger-smb/?rev=4798&view=rev
Author: einhverfr
Date: 2012-05-29 02:38:05 +0000 (Tue, 29 May 2012)
Log Message:
-----------
Base address operations now work on new more modular framework
Modified Paths:
--------------
trunk/LedgerSMB/DBObject/Entity/Location.pm
trunk/LedgerSMB/ScriptLib/Company.pm
trunk/LedgerSMB/Scripts/contact.pm
trunk/UI/Contact/divs/address.html
trunk/sql/modules/Company.sql
Modified: trunk/LedgerSMB/DBObject/Entity/Location.pm
===================================================================
--- trunk/LedgerSMB/DBObject/Entity/Location.pm 2012-05-28 15:47:00 UTC (rev 4797)
+++ trunk/LedgerSMB/DBObject/Entity/Location.pm 2012-05-29 02:38:05 UTC (rev 4798)
@@ -42,13 +42,13 @@
has 'inactive_date' => (is => 'rw', isa => 'Maybe[LedgerSMB::PGDate]');
-=item location_id
+=item id
Internal id of the actual location entry.
=cut
-has 'location_id' => (is => 'rw', isa => 'Maybe[Int]');
+has 'id' => (is => 'rw', isa => 'Maybe[Int]');
=item entity_id
@@ -66,7 +66,7 @@
=cut
-has 'credit_id' => (is => 'ro', isa => 'Maybe[Int]');
+has 'credit_id' => (is => 'rw', isa => 'Maybe[Int]');
=item location_class
@@ -237,15 +237,21 @@
$self->exec_method({funcname => $procname});
}
-=item deactivate()
+=item delete()
-Deactivates the current location
+Deletes the current location
=cut
-sub deactivate {
+sub delete{
my ($self) = @_;
- $self->exec_method({funcname => 'location__deactivate'});
+ my $procname;
+ if ($self->credit_id){
+ $procname = 'eca__delete_location';
+ } else {
+ $procname = 'entity__delete_location';
+ }
+ $self->exec_method({funcname => $procname});
}
=back
Modified: trunk/LedgerSMB/ScriptLib/Company.pm
===================================================================
--- trunk/LedgerSMB/ScriptLib/Company.pm 2012-05-28 15:47:00 UTC (rev 4797)
+++ trunk/LedgerSMB/ScriptLib/Company.pm 2012-05-29 02:38:05 UTC (rev 4798)
@@ -118,49 +118,10 @@
=over
-=item add_location
-
-Adds a location to the company as defined in the inherited object
-
-=back
-
-=cut
-
-sub add_location {
- my ($request) = @_;
- my $location = LedgerSMB::DBObject::Entity::Location->new(%$request);
- my $company = LedgerSMB::DBObject::Entity::Company->new(%$request);
-
- $location->save();
- $company = $company->get($request->{entity_id});
-
- _render_main_screen($request, $company);
-
-}
-
=pod
=over
-=item save_new_location
-
-Adds a location to the company as defined in the inherited object, not
-overwriting existing locations.
-
-=back
-
-=cut
-
-sub save_new_location {
- my ($request) = @_;
- delete $request->{location_id};
- add_location($request);
-}
-
-=pod
-
-=over
-
=item generate_control_code
Sets $company->{control_code} equal to the next in the series of entity_control
Modified: trunk/LedgerSMB/Scripts/contact.pm
===================================================================
--- trunk/LedgerSMB/Scripts/contact.pm 2012-05-28 15:47:00 UTC (rev 4797)
+++ trunk/LedgerSMB/Scripts/contact.pm 2012-05-29 02:38:05 UTC (rev 4798)
@@ -188,9 +188,9 @@
$default_language = $default_language->{value};
my $attach_level_options = [
- {label => $locale->text('Entity'), value => 1} ];
+ {text => $locale->text('Entity'), value => 1} ];
..hidden..,
- {label => $locale->text('Credit Account'),
+ {text => $locale->text('Credit Account'),
value => 3} if $credit_act->{id};
;
@@ -240,6 +240,7 @@
attach_level_options => $attach_level_options,
entity_id => $entity_id,
entity_class => $entity_class,
+ location_class_list => ..hidden..,
});
}
@@ -458,4 +459,58 @@
save_credit($request);
}
+=item save_location
+
+Adds a location to the company as defined in the inherited object
+
+=cut
+
+sub save_location {
+ my ($request) = @_;
+
+ my $location = LedgerSMB::DBObject::Entity::Location->new(%$request);
+ if ($request->{attach_to} eq '1'){
+ $location->credit_id(undef);
+ }
+ $location->id($request->{location_id});
+ $location->save;
+ $request->{target_div} = 'address_div';
+ get($request);
+
+}
+
+=item save_new_location
+
+Adds a location to the company as defined in the inherited object, not
+overwriting existing locations.
+
+=cut
+
+sub save_new_location {
+ my ($request) = @_;
+ delete $request->{location_id};
+ save_location($request);
+}
+
+=item edit
+
+This is a synonym of get() which is preferred to use for editing operations.
+
+=cut
+
+sub edit {
+ get (@_);
+}
+
+sub delete_location {
+ my ($request) = @_;
+ my $location = LedgerSMB::DBObject::Entity::Location->new(%$request);
+ $location->id($request->{location_id});
+ if (!$request->{is_for_credit}){
+ $location->credit_id(undef);
+ }
+ $location->delete;
+ get($request);
+}
+
1;
Modified: trunk/UI/Contact/divs/address.html
===================================================================
--- trunk/UI/Contact/divs/address.html 2012-05-28 15:47:00 UTC (rev 4797)
+++ trunk/UI/Contact/divs/address.html 2012-05-29 02:38:05 UTC (rev 4798)
@@ -27,12 +27,7 @@
type="hidden"
name="credit_id"
value=credit_act.id
- } ?>
- <?lsmb PROCESS input element_data = {
- type="hidden"
- name="location_id"
- value=location_id
- }; ?><?lsmb
+ };
FOREACH LOC IN locations;
IF LOC.credit_id;
LOC.is_for_credit = 'X';
@@ -47,15 +42,18 @@
LOC.edit = '[' _ text('Edit') _ ']';
LOC.delete= '[' _ text('Delete') _ ']';
LOC.edit_href_suffix= script _ '?action=edit&entity_id=' _ entity_id _
- '&location_id=' _ loc.id _ '&credit_id=' _
- credit_act.id _ '&country_code=' _ loc.country_id _
- '&target_div=location_div&location_class=' _
- loc.location_class;
- LOC.delete_href_suffix= script _ '?action=delete&entity_id=' _ entity_id _
- '&location_id=' _ loc.id _ '&credit_id=' _
- credit_act.id _ '&country_code=' _ loc.country_id _
- '&target_div=location_div&location_class=' _
- loc.location_class;
+ '&location_id=' _ LOC.id _ '&credit_id=' _
+ credit_act.id _ '&is_for_credit=' _ LOC.is_for_credit _
+ '&target_div=address_div&location_class=' _
+ LOC.location_class;
+ LOC.delete_href_suffix= script _ '?action=delete_location&entity_id=' _
+ entity_id _ '&location_id=' _ LOC.id _ '&credit_id=' _
+ credit_act.id _ '&is_for_credit=' _ LOC.is_for_credit _
+ '&target_div=address_div&location_class=' _
+ LOC.location_class;
+ IF LOC.id == request.location_id && request.action == 'edit';
+ DISPLAY = LOC;
+ END;
END; ?><?lsmb
PROCESS dynatable
tbody = {rows = locations}
@@ -72,11 +70,24 @@
{col_id = 'edit', type='href', name=' ', href_base='' }
{col_id = 'delete', type='href', name=' ', href_base='' }
];
- ?>
+ PROCESS input element_data = {
+ type="hidden"
+ name="location_id"
+ value= DISPLAY.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') #'
+ };
+ END; ?>
<div>
<?lsmb INCLUDE select element_data = {
name = "location_class"
- default_values = [location_class]
+ default_values = [DISPLAY.location_class]
options = location_class_list
text_attr = "class"
value_attr = "id"
@@ -88,7 +99,7 @@
<?lsmb INCLUDE input element_data = {
label = text('Address'),
name = "line_one",
- value = line_one,
+ value = DISPLAY.line_one,
type = "text",
size = "20"
} ?>
@@ -98,7 +109,7 @@
label = ":"
name = "line_two"
class = "addl-address"
- value = line_two
+ value = DISPLAY.line_two
type = "text"
size = "20"
} ?>
@@ -108,7 +119,7 @@
label = ":"
name = "line_three"
class = "addl-address"
- value = line_three
+ value = DISPLAY.line_three
type = "text"
size = "20"
} ?>
@@ -117,7 +128,7 @@
<?lsmb PROCESS input element_data = {
label = text('City'),
name = "city",
- value = city,
+ value = DISPLAY.city,
type = "text",
size = "20"
} ?>
@@ -126,7 +137,7 @@
<?lsmb PROCESS input element_data = {
label = text('State/Province'),
name = "state",
- value = state,
+ value = DISPLAY.state,
type = "text",
size = "20"
} ?>
@@ -135,7 +146,7 @@
<?lsmb PROCESS input element_data = {
label = text('Zip/Post Code'),
name = "mail_code",
- value = mail_code,
+ value = DISPLAY.mail_code,
type = "text",
size = "20"
} #' ?>
@@ -145,7 +156,7 @@
<?lsmb INCLUDE select element_data = {
text_attr = "name"
value_attr = "id"
- default_values = [country_id]
+ default_values = [DISPLAY.country_id]
options = country_list
name = "country_id"
label = text('Country')
@@ -155,7 +166,7 @@
<?lsmb PROCESS button element_data = {
class = "submit"
name = "action"
- value = "add_location"
+ value = "save_location"
id = "loc_save_location"
text = text('Save Location')
} #' ?>
Modified: trunk/sql/modules/Company.sql
===================================================================
--- trunk/sql/modules/Company.sql 2012-05-28 15:47:00 UTC (rev 4797)
+++ trunk/sql/modules/Company.sql 2012-05-29 02:38:05 UTC (rev 4798)
@@ -1142,14 +1142,14 @@
$$ language 'sql';
CREATE OR REPLACE FUNCTION entity__location_save (
- in_entity_id int, in_location_id int,
+ in_entity_id int, in_id int,
in_location_class int, in_line_one text, in_line_two text,
in_city TEXT, in_state TEXT, in_mail_code text, in_country_id int,
in_created date
) returns int AS $$
BEGIN
return _entity_location_save(
- in_entity_id, in_location_id,
+ in_entity_id, in_id,
in_location_class, in_line_one, in_line_two,
'', in_city , in_state, in_mail_code, in_country_id);
END;
@@ -1157,7 +1157,7 @@
$$ language 'plpgsql';
COMMENT ON FUNCTION entity__location_save (
- in_entity_id int, in_location_id int,
+ in_entity_id int, in_id int,
in_location_class int, in_line_one text, in_line_two text,
in_city TEXT, in_state TEXT, in_mail_code text, in_country_id int,
in_created date
@@ -1208,7 +1208,7 @@
Returns the location id that was inserted or updated.$$;
create or replace function eca__location_save(
- in_credit_id int, in_location_id int,
+ in_credit_id int, in_id int,
in_location_class int, in_line_one text, in_line_two text,
in_line_three text, in_city TEXT, in_state TEXT, in_mail_code text,
in_country_id int, in_old_location_class int
@@ -1224,11 +1224,11 @@
SET location_class = in_location_class
WHERE credit_id = in_credit_id
AND location_class = in_old_location_class
- AND location_id = in_location_id;
+ AND location_id = in_id;
IF FOUND THEN
SELECT location_save(
- in_location_id,
+ in_id,
in_line_one,
in_line_two,
in_line_three,
@@ -1262,7 +1262,7 @@
$$ language 'plpgsql';
COMMENT ON function eca__location_save(
- in_credit_id int, in_location_id int,
+ in_credit_id int, in_id int,
in_location_class int, in_line_one text, in_line_two text,
in_line_three text, in_city TEXT, in_state TEXT, in_mail_code text,
in_country_code int, in_old_location_class int
@@ -1270,13 +1270,13 @@
$$ Saves a location to an entity credit account. Returns id of saved record.$$;
CREATE OR REPLACE FUNCTION eca__delete_location
-(in_credit_id int, in_location_id int, in_location_class int)
+(in_credit_id int, in_id int, in_location_class int)
RETURNS BOOL AS
$$
BEGIN
DELETE FROM eca_to_location
- WHERE credit_id = in_credit_id AND location_id = in_location_id
+ WHERE credit_id = in_credit_id AND location_id = in_id
AND location_class = in_location_class;
RETURN FOUND;
@@ -1285,18 +1285,18 @@
$$ language plpgsql;
COMMENT ON FUNCTION eca__delete_location
-(in_credit_id int, in_location_id int, in_location_class int) IS
+(in_credit_id int, in_id int, in_location_class int) IS
$$ Deletes the record identified. Returns true if successful, false if no record
found.$$;
-CREATE OR REPLACE FUNCTION company__delete_location
-(in_company_id int, in_location_id int, in_location_class int)
+CREATE OR REPLACE FUNCTION entity__delete_location
+(in_entity_id int, in_id int, in_location_class int)
RETURNS BOOL AS
$$
BEGIN
-DELETE FROM eca_to_location
- WHERE company_id = in_company_id AND location_id = in_location_id
+DELETE FROM entity_to_location
+ WHERE entity_id = in_entity_id AND location_id = in_id
AND location_class = in_location_class;
RETURN FOUND;
@@ -1304,8 +1304,8 @@
END;
$$ language plpgsql;
-COMMENT ON FUNCTION company__delete_location
-(in_company_id int, in_location_id int, in_location_class int) IS
+COMMENT ON FUNCTION entity__delete_location
+(in_entity_id int, in_id int, in_location_class int) IS
$$ Deletes the record identified. Returns true if successful, false if no record
found.$$;
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.