summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authoreinhverfr <einhverfr@4979c152-3d1c-0410-bac9-87ea11338e46>2008-11-13 01:15:47 +0000
committereinhverfr <einhverfr@4979c152-3d1c-0410-bac9-87ea11338e46>2008-11-13 01:15:47 +0000
commit1aaa9fe478fc2e9ea0fa744edb704ccacf46d07b (patch)
tree948069945fd10e396cb2c3876269fba31add977d
parentf7ae08a1336c4667e2fb4028d034a52fda7f492b (diff)
Correcting issues with draft editing.
Moving AA::post_transaction to use strict. git-svn-id: https://ledger-smb.svn.sourceforge.net/svnroot/ledger-smb/trunk@2392 4979c152-3d1c-0410-bac9-87ea11338e46
-rw-r--r--LedgerSMB/AA.pm8
-rw-r--r--LedgerSMB/DBObject.pm4
-rw-r--r--LedgerSMB/Form.pm12
-rw-r--r--LedgerSMB/GL.pm2
-rw-r--r--bin/aa.pl24
-rw-r--r--bin/gl.pl49
-rw-r--r--scripts/drafts.pl2
-rw-r--r--scripts/vendor.pl2
-rw-r--r--sql/modules/Roles.sql2
9 files changed, 96 insertions, 9 deletions
diff --git a/LedgerSMB/AA.pm b/LedgerSMB/AA.pm
index 9d922bb0..295b89a6 100644
--- a/LedgerSMB/AA.pm
+++ b/LedgerSMB/AA.pm
@@ -59,8 +59,15 @@ Post transaction uses the following variables in the $form variable:
=cut
sub post_transaction {
+ use strict;
my ( $self, $myconfig, $form ) = @_;
+
+ my $exchangerate;
+ my $batch_class;
+ my %paid;
+ my $paidamount;
+ my @queries;
if ($form->{separate_duties}){
$form->{approved} = '0';
}
@@ -404,7 +411,6 @@ sub post_transaction {
# add individual transactions
foreach $ref ( @{ $form->{acc_trans}{lineitems} } ) {
-
# insert detail records in acc_trans
if ( $ref->{amount} ) {
$query = qq|
diff --git a/LedgerSMB/DBObject.pm b/LedgerSMB/DBObject.pm
index 57f5ac6f..dade3ab8 100644
--- a/LedgerSMB/DBObject.pm
+++ b/LedgerSMB/DBObject.pm
@@ -121,7 +121,7 @@ sub exec_method {
$ref = $sth->fetchrow_hashref('NAME_lc');
- my $args = $ref->{proargnames};
+ my $pargs = $ref->{proargnames};
my @proc_args;
if ( !$ref->{proname} ) { # no such function
@@ -132,7 +132,7 @@ sub exec_method {
$ref->{pronargs} = 0 unless defined $ref->{pronargs};
# If the user provided args..
if (!defined $args{args}) {
- @proc_args = $self->_parse_array($args);
+ @proc_args = $self->_parse_array($pargs);
if (@proc_args) {
for my $arg (@proc_args) {
if ( $arg =~ s/^in_// ) {
diff --git a/LedgerSMB/Form.pm b/LedgerSMB/Form.pm
index f9ae6ad5..dec0813d 100644
--- a/LedgerSMB/Form.pm
+++ b/LedgerSMB/Form.pm
@@ -536,7 +536,7 @@ sub redirect {
my ( $self, $msg ) = @_;
if ( $self->{callback} || !$msg ) {
-
+ print STDERR "Full redirect\n";
main::redirect();
exit;
}
@@ -1189,6 +1189,16 @@ sub db_init {
push @{ $self->{custom_db_fields}{ $ref->{extends} } },
$ref->{field_def};
}
+ # Roles tracking
+ $self->{_roles} = [];
+ $query = "select rolname from pg_roles
+ where pg_has_role(SESSION_USER, 'USAGE')";
+ $sth = $dbh->prepare($query);
+ $sth->execute();
+ while (my @roles = $sth->fetchrow_array){
+ push @{$self->{_roles}}, $roles[0];
+ }
+ $sth->finish();
}
=item $form->run_custom_queries($tablename, $query_type[, $linenum]);
diff --git a/LedgerSMB/GL.pm b/LedgerSMB/GL.pm
index 22976c2d..7ee7ba89 100644
--- a/LedgerSMB/GL.pm
+++ b/LedgerSMB/GL.pm
@@ -166,7 +166,6 @@ sub post_transaction {
# extract accno
($accno) = split( /--/, $form->{"accno_$i"} );
-
if ($credit) {
$amount = $credit;
$posted = 0;
@@ -564,6 +563,7 @@ sub transaction {
my $results = $sth->fetchall_hashref('setting_key');
$form->{closedto} = $results->{'closedto'}->{'value'};
$form->{revtrans} = $results->{'revtrans'}->{'value'};
+ #$form->{separate_duties} = $results->{'separate_duties'}->{'value'};
$sth->finish;
$query = qq|SELECT g.*, d.description AS department
diff --git a/bin/aa.pl b/bin/aa.pl
index 858ac849..e3b869dd 100644
--- a/bin/aa.pl
+++ b/bin/aa.pl
@@ -883,7 +883,16 @@ sub form_footer {
{ ndx => 8, key => 'D', value => $locale->text('Delete') },
);
if (!$form->{approved} && !$form->{batch_id}){
- $button{approve} = { ndx => 3, key => 'O', value => $locale->text('Post') };
+ $button{approve} = {
+ ndx => 3,
+ key => 'O',
+ value => $locale->text('Post as Saved') };
+ if (grep /^lsmb_$form->{company}__draft_modify$/, @{$form->{_roles}}){
+ $button{edit_and_approve} = {
+ ndx => 4,
+ key => 'O',
+ value => $locale->text('Post as Shown') };
+ }
delete $button{post_as_new};
delete $button{print_and_post_as_new};
delete $button{post};
@@ -942,6 +951,18 @@ sub form_footer {
}
+sub edit_and_approve {
+ use LedgerSMB::DBObject::Draft;
+ use LedgerSMB;
+ my $lsmb = LedgerSMB->new();
+ $lsmb->merge($form);
+ my $draft = LedgerSMB::DBObject::Draft->new({base => $lsmb});
+ $draft->delete();
+ delete $form->{id};
+ AA->post_transaction( \%myconfig, \%$form );
+ approve();
+}
+
sub approve {
use LedgerSMB::DBObject::Draft;
use LedgerSMB;
@@ -1150,6 +1171,7 @@ sub post {
if ( $form->{printandpost} ) {
&{"print_$form->{formname}"}( $old_form, 1 );
}
+ print STDERR "Redirecting\n";
$form->redirect( $locale->text('Transaction posted!') );
}
else {
diff --git a/bin/gl.pl b/bin/gl.pl
index 5581259c..ef33a0b7 100644
--- a/bin/gl.pl
+++ b/bin/gl.pl
@@ -92,6 +92,39 @@ sub pos_adjust {
$form->{accno_3} = $pos_config{'coa_prefix'};
}
+sub edit_and_approve {
+ use LedgerSMB::DBObject::Draft;
+ use LedgerSMB;
+ my $lsmb = LedgerSMB->new();
+ $lsmb->merge($form);
+ my $draft = LedgerSMB::DBObject::Draft->new({base => $lsmb});
+ $draft->delete();
+ GL->post_transaction( \%myconfig, \%$form );
+ approve();
+}
+
+sub approve {
+ use LedgerSMB::DBObject::Draft;
+ use LedgerSMB;
+ my $lsmb = LedgerSMB->new();
+ $lsmb->merge($form);
+
+ my $draft = LedgerSMB::DBObject::Draft->new({base => $lsmb});
+
+ $draft->approve();
+ if ($form->{callback}){
+ print "Location: $form->{callback}\n";
+ print "Status: 302 Found\n\n";
+ print "<html><body>";
+ my $url = $form->{callback};
+ print qq|If you are not redirected automatically, click <a href="$url">|
+ . qq|here</a>.</body></html>|;
+
+ } else {
+ $form->info($locale->text('Draft Posted'));
+ }
+}
+
sub add_pos_adjust {
$form->{pos_adjust} = 1;
$form->{reference} =
@@ -1283,6 +1316,22 @@ sub form_footer {
for ( "update", "post", "schedule" ) { $a{$_} = 1 }
}
}
+ if (!$form->{approved} && !$form->{batch_id}){
+ $button{approve} = {
+ ndx => 3,
+ key => 'S',
+ value => $locale->text('Post as Saved') };
+ $a{approve} = 1;
+ $a{edit_and_approve} = 1;
+ if (grep /^lsmb_$form->{company}__draft_modify$/, @{$form->{_roles}}){
+ $button{edit_and_approve} = {
+ ndx => 4,
+ key => 'O',
+ value => $locale->text('Post as Shown') };
+ }
+ delete $button{post_as_new};
+ delete $button{post};
+ }
for ( keys %button ) { delete $button{$_} if !$a{$_} }
for ( sort { $button{$a}->{ndx} <=> $button{$b}->{ndx} } keys %button )
diff --git a/scripts/drafts.pl b/scripts/drafts.pl
index f7771f30..7d6008ec 100644
--- a/scripts/drafts.pl
+++ b/scripts/drafts.pl
@@ -11,7 +11,7 @@ sub search {
$request->{class_types} = [
{text => $request->{_locale}->text('AR'), value => 'ar'},
{text => $request->{_locale}->text('AP'), value => 'ap'},
- {text => $request->{_locale}->text('GL'), value => 'GL'},
+ {text => $request->{_locale}->text('GL'), value => 'gl'},
];
my $template = LedgerSMB::Template->new(
user =>$request->{_user},
diff --git a/scripts/vendor.pl b/scripts/vendor.pl
index 0f86c553..45a46cb6 100644
--- a/scripts/vendor.pl
+++ b/scripts/vendor.pl
@@ -23,7 +23,7 @@ package LedgerSMB::Scripts::vendor;
use LedgerSMB::DBObject::Vendor;
use base qw(LedgerSMB::ScriptLib::Company);
-require 'lsmb-request.pl';
+# require 'lsmb-request.pl';
sub set_entity_class {
my ($null, $request) = @_;
diff --git a/sql/modules/Roles.sql b/sql/modules/Roles.sql
index 9ef3d4c7..0603d92f 100644
--- a/sql/modules/Roles.sql
+++ b/sql/modules/Roles.sql
@@ -1185,7 +1185,7 @@ values (148, 'allow', 'lsmb_<?lsmb dbname ?>__create_business_type');
CREATE ROLE "lsmb_<?lsmb dbname ?>__edit_business_type"
WITH INHERIT NOLOGIN;
-GRANT UPDATE ON business TO "lsmb_<?lsmb dbname ?>__edit_business_type";
+GRANT UPDATE, DELETE ON business TO "lsmb_<?lsmb dbname ?>__edit_business_type";
INSERT INTO menu_acl (node_id, acl_type, role_name)
values (128, 'allow', 'lsmb_<?lsmb dbname ?>__edit_business_type');