[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
SF.net SVN: ledger-smb:[4393] trunk
- Subject: SF.net SVN: ledger-smb:[4393] trunk
- From: ..hidden..
- Date: Wed, 07 Mar 2012 03:14:10 +0000
Revision: 4393
http://ledger-smb.svn.sourceforge.net/ledger-smb/?rev=4393&view=rev
Author: einhverfr
Date: 2012-03-07 03:14:09 +0000 (Wed, 07 Mar 2012)
Log Message:
-----------
More tuning to business reporting unit framework
Modified Paths:
--------------
trunk/LedgerSMB/DBObject/Business_Unit_Class.pm
trunk/sql/modules/Business_Unit.sql
Modified: trunk/LedgerSMB/DBObject/Business_Unit_Class.pm
===================================================================
--- trunk/LedgerSMB/DBObject/Business_Unit_Class.pm 2012-03-07 02:06:29 UTC (rev 4392)
+++ trunk/LedgerSMB/DBObject/Business_Unit_Class.pm 2012-03-07 03:14:09 UTC (rev 4393)
@@ -49,14 +49,14 @@
# Hmm should we move this to per-module restrictions? --CT
-=item non_accounting bool
+=item modules bool
If true, indicates that this will not show up on accounting transaction screens.
this is indivated for CRM and other applications.
=cut
-has 'non_accounting' => (is => 'rw', isa => 'Bool');
+has 'modules' => (is => 'rw', isa => 'ArrayRef[LedgerSMB::DBObject::App_Module]');
=item ordering
@@ -99,11 +99,31 @@
sub save {
my ($self) = @_;
my ($ref) = $self->exec_method({funcname => 'business_unit_class__save'});
+ $self->save_modules();
$self->prepare_dbhash($ref);
$self = $self->new(%$ref);
$self->dbh->commit;
}
+=item save_modules
+
+This saves only the module permissions. This takes the list of modules and prepares an array for the saving and then saves the modules. This is broken off as a public
+interface because it makes it possible to activate/deactive regarding modules after the
+fact without changing anything else.
+
+=cut
+
+sub save_modules {
+ my ($self) = @_;
+ my $mod_ids = [];
+ for my $mod (@{$self->modules}){
+ push @$mod_ids, $mod->id;
+ }
+ $self->call_procedure(procname => 'business_unit_class__save_modules',
+ args => [$self->id, $mod_ids]
+ );
+}
+
=item list
Returns a list of all business unit classes.
Modified: trunk/sql/modules/Business_Unit.sql
===================================================================
--- trunk/sql/modules/Business_Unit.sql 2012-03-07 02:06:29 UTC (rev 4392)
+++ trunk/sql/modules/Business_Unit.sql 2012-03-07 03:14:09 UTC (rev 4393)
@@ -82,6 +82,26 @@
$$ This function returns tree-related records with the root of the tree being
the business unit of in_id. $$;
+CREATE OR REPLACE FUNCTION business_unit_class__save_modules
+(in_id int, in_mod_ids int[])
+RETURNS BOOL AS
+$$
+DELETE FROM bu_class_to_module WHERE bu_class_id = $1;
+
+INSERT INTO bu_class_to_module (bu_class_id, module_id)
+SELECT $1, unnest
+ FROM unnest($2);
+
+SELECT true;
+$$ LANGUAGE SQL;
+
+CREATE FUNCTION business_unit_class__get_modules(in_id int)
+RETURNS SETOF lsmb_module AS
+$$ SELECT * FROM lsmb_module
+ WHERE id IN (select module_id from bu_class_to_module where bu_class_id = $1);
+ ORDER BY id;
+$$;
+
CREATE OR REPLACE FUNCTION business_unit_class__save
(in_id int, in_label text, in_active bool, in_non_accounting bool, in_ordering int)
RETURNS business_unit_class AS
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.