summaryrefslogtreecommitdiff
path: root/httemplate/edit/process/elements/process.html
diff options
context:
space:
mode:
Diffstat (limited to 'httemplate/edit/process/elements/process.html')
-rw-r--r--httemplate/edit/process/elements/process.html96
1 files changed, 54 insertions, 42 deletions
diff --git a/httemplate/edit/process/elements/process.html b/httemplate/edit/process/elements/process.html
index 636bae0ce..12b3bd94b 100644
--- a/httemplate/edit/process/elements/process.html
+++ b/httemplate/edit/process/elements/process.html
@@ -62,6 +62,10 @@ Example:
'fields' => [qw( fieldname fieldname2 )],
},
+ 'skip_process' => 0, #boolean, if set true, will skip the main table
+ #add/edit processing and only run any linked table
+ #process_ items
+
#checks CGI params and whatever else before much else runs
#return an error string or empty for no error
'precheck_callback' => sub { my( $cgi ) = @_; },
@@ -204,62 +208,71 @@ my $new;
my $new_pkey = '';
foreach my $value ( @values ) {
- $new = $class->new( \%hash );
+ if ($opt{'skip_process'}) {
+
+ $new = $old;
+ $new_pkey = $old_pkey;
+
+ } else {
+
+ $new = $class->new( \%hash );
- $new->$bfield($value) if $bfield;
+ $new->$bfield($value) if $bfield;
- if ($old && exists($opt{'copy_on_empty'})) {
- foreach my $field (@{$opt{'copy_on_empty'}}) {
- $new->set($field, $old->get($field))
- unless scalar($cgi->param($field));
+ if ($old && exists($opt{'copy_on_empty'})) {
+ foreach my $field (@{$opt{'copy_on_empty'}}) {
+ $new->set($field, $old->get($field))
+ unless scalar($cgi->param($field));
+ }
}
- }
- if ( $opt{'agent_virt'} ) {
+ if ( $opt{'agent_virt'} ) {
- if ( ! $new->agentnum
- && ( ! $opt{'agent_null_right'}
- || ! $curuser->access_right($opt{'agent_null_right'})
- )
- )
- {
+ if ( ! $new->agentnum
+ && ( ! $opt{'agent_null_right'}
+ || ! $curuser->access_right($opt{'agent_null_right'})
+ )
+ )
+ {
- $error ||= 'Select an agent';
+ $error ||= 'Select an agent';
- } else {
+ } else {
- die "illegal agentnum"
- unless $curuser->agentnums_href->{$new->agentnum}
- or $curuser->access_right('View customers of all agents')
- or $opt{'agent_null_right'}
- && ! $new->agentnum
- && $curuser->access_right($opt{'agent_null_right'});
+ die "illegal agentnum"
+ unless $curuser->agentnums_href->{$new->agentnum}
+ or $curuser->access_right('View customers of all agents')
+ or $opt{'agent_null_right'}
+ && ! $new->agentnum
+ && $curuser->access_right($opt{'agent_null_right'});
- }
+ }
- }
+ }
- $error ||= $new->check;
+ $error ||= $new->check;
- my @args = ();
- if ( !$error && $opt{'args_callback'} ) {
- @args = &{ $opt{'args_callback'} }( $cgi, $new );
- }
+ my @args = ();
+ if ( !$error && $opt{'args_callback'} ) {
+ @args = &{ $opt{'args_callback'} }( $cgi, $new );
+ }
- if ( !$error && $opt{'debug'} ) {
- warn "$me updating record in $table table using $class class\n";
- warn Dumper(\%hash);
- warn "with args: \n". Dumper(\@args) if @args;
- }
+ if ( !$error && $opt{'debug'} ) {
+ warn "$me updating record in $table table using $class class\n";
+ warn Dumper(\%hash);
+ warn "with args: \n". Dumper(\@args) if @args;
+ }
- if ( !$error ) {
- if ( $old_pkey ) {
- $error = $new->replace($old, @args);
- } else {
- $error = $new->insert(@args);
+ if ( !$error ) {
+ if ( $old_pkey ) {
+ $error = $new->replace($old, @args);
+ } else {
+ $error = $new->insert(@args);
+ }
+ $new_pkey = $new->getfield($pkey);
}
- $new_pkey = $new->getfield($pkey);
- }
+
+ } #unless $opt{'skip_process'}
if ( !$error && $opt{'process_m2m'} ) {
@@ -344,5 +357,4 @@ foreach my $value ( @values ) {
last if $error;
}
-
</%init>