summaryrefslogtreecommitdiff
path: root/httemplate/edit/process/elements
diff options
context:
space:
mode:
authorivan <ivan>2006-08-23 22:25:39 +0000
committerivan <ivan>2006-08-23 22:25:39 +0000
commit3ce7691203a7737406bf2d4442f7fd84b81f847e (patch)
tree90658b097da96772224f04771888ac6ca1a940aa /httemplate/edit/process/elements
parent15e561850b61b10a92a46d8f3e316d53d4970087 (diff)
Will things ever be the same again?
It's the final masonize
Diffstat (limited to 'httemplate/edit/process/elements')
-rw-r--r--httemplate/edit/process/elements/process.html181
-rw-r--r--httemplate/edit/process/elements/svc_Common.html17
2 files changed, 100 insertions, 98 deletions
diff --git a/httemplate/edit/process/elements/process.html b/httemplate/edit/process/elements/process.html
index 7cae78bfc..96d568754 100644
--- a/httemplate/edit/process/elements/process.html
+++ b/httemplate/edit/process/elements/process.html
@@ -1,91 +1,92 @@
-<%
+%
+%
+% # options example...
+% #
+% ###
+% ##req
+% ##
+% #
+% # 'table' =>
+% #
+% # #? 'primary_key' => #required when the dbdef doesn't know...???
+% # #? 'fields' => []
+% #
+% ###
+% ##opt
+% ###
+% #
+% # 'viewall_dir' => '', #'search' or 'browse', defaults to 'search'
+% # OR
+% # 'redirect' => 'view/table.cgi?', # value of primary key is appended
+% #
+% # 'edit_ext' => 'html', #defaults to 'html', you might want 'cgi' while the
+% # #naming is still inconsistent
+% #
+% # 'process_m2m' => { 'link_table' => 'link_table_name',
+% # 'target_table' => 'target_table_name',
+% # },
+% # 'process_m2name' => { 'link_table' => 'link_table_name',
+% # 'link_static' => { 'column' => 'value' },
+% # 'num_col' => 'column', #if column name is different in
+% # #link_table than source_table
+% # 'name_col' => 'name_column',
+% # 'names_list' => [ 'list', 'names' ],
+% # },
+%
+% my(%opt) = @_;
+%
+% #false laziness w/edit.html
+% my $table = $opt{'table'};
+% my $class = "FS::$table";
+% my $pkey = dbdef->table($table)->primary_key; #? $opt{'primary_key'} ||
+% my $fields = $opt{'fields'}
+% #|| [ grep { $_ ne $pkey } dbdef->table($table)->columns ];
+% || [ fields($table) ];
+%
+% my $pkeyvalue = $cgi->param($pkey);
+%
+% my $old = qsearchs( $table, { $pkey => $pkeyvalue } ) if $pkeyvalue;
+%
+% my $new = $class->new( {
+% map {
+% $_, scalar($cgi->param($_));
+% } @$fields
+% } );
+%
+% my $error;
+% if ( $pkeyvalue ) {
+% $error = $new->replace($old);
+% } else {
+% $error = $new->insert;
+% $pkeyvalue = $new->getfield($pkey);
+% }
+%
+% if ( !$error && $opt{'process_m2m'} ) {
+% $error = $new->process_m2m( %{ $opt{'process_m2m'} },
+% 'params' => scalar($cgi->Vars),
+% );
+% }
+%
+% if ( !$error && $opt{'process_m2name'} ) {
+% $error = $new->process_m2name( %{ $opt{'process_m2name'} },
+% 'params' => scalar($cgi->Vars),
+% );
+% }
+%
+% # XXX print?!?!
+%
+% if ( $error ) {
+% $cgi->param('error', $error);
+% my $edit_ext = $opt{'edit_ext'} || 'html';
+% print $cgi->redirect(popurl(2). "$table.$edit_ext?". $cgi->query_string );
+% } elsif ( $opt{'redirect'} ) {
+% print $cgi->redirect( $opt{'redirect'}. $pkeyvalue );
+% } else {
+% print $cgi->redirect( popurl(3).
+% ( $opt{'viewall_dir'} || 'search' ).
+% "/$table.html"
+% );
+% }
+%
+%
- # options example...
- #
- ###
- ##req
- ##
- #
- # 'table' =>
- #
- # #? 'primary_key' => #required when the dbdef doesn't know...???
- # #? 'fields' => []
- #
- ###
- ##opt
- ###
- #
- # 'viewall_dir' => '', #'search' or 'browse', defaults to 'search'
- # OR
- # 'redirect' => 'view/table.cgi?', # value of primary key is appended
- #
- # 'edit_ext' => 'html', #defaults to 'html', you might want 'cgi' while the
- # #naming is still inconsistent
- #
- # 'process_m2m' => { 'link_table' => 'link_table_name',
- # 'target_table' => 'target_table_name',
- # },
- # 'process_m2name' => { 'link_table' => 'link_table_name',
- # 'link_static' => { 'column' => 'value' },
- # 'num_col' => 'column', #if column name is different in
- # #link_table than source_table
- # 'name_col' => 'name_column',
- # 'names_list' => [ 'list', 'names' ],
- # },
-
- my(%opt) = @_;
-
- #false laziness w/edit.html
- my $table = $opt{'table'};
- my $class = "FS::$table";
- my $pkey = dbdef->table($table)->primary_key; #? $opt{'primary_key'} ||
- my $fields = $opt{'fields'}
- #|| [ grep { $_ ne $pkey } dbdef->table($table)->columns ];
- || [ fields($table) ];
-
- my $pkeyvalue = $cgi->param($pkey);
-
- my $old = qsearchs( $table, { $pkey => $pkeyvalue } ) if $pkeyvalue;
-
- my $new = $class->new( {
- map {
- $_, scalar($cgi->param($_));
- } @$fields
- } );
-
- my $error;
- if ( $pkeyvalue ) {
- $error = $new->replace($old);
- } else {
- $error = $new->insert;
- $pkeyvalue = $new->getfield($pkey);
- }
-
- if ( !$error && $opt{'process_m2m'} ) {
- $error = $new->process_m2m( %{ $opt{'process_m2m'} },
- 'params' => scalar($cgi->Vars),
- );
- }
-
- if ( !$error && $opt{'process_m2name'} ) {
- $error = $new->process_m2name( %{ $opt{'process_m2name'} },
- 'params' => scalar($cgi->Vars),
- );
- }
-
- # XXX print?!?!
-
- if ( $error ) {
- $cgi->param('error', $error);
- my $edit_ext = $opt{'edit_ext'} || 'html';
- print $cgi->redirect(popurl(2). "$table.$edit_ext?". $cgi->query_string );
- } elsif ( $opt{'redirect'} ) {
- print $cgi->redirect( $opt{'redirect'}. $pkeyvalue );
- } else {
- print $cgi->redirect( popurl(3).
- ( $opt{'viewall_dir'} || 'search' ).
- "/$table.html"
- );
- }
-
-%>
diff --git a/httemplate/edit/process/elements/svc_Common.html b/httemplate/edit/process/elements/svc_Common.html
index 1f8f8315e..8e8c99a42 100644
--- a/httemplate/edit/process/elements/svc_Common.html
+++ b/httemplate/edit/process/elements/svc_Common.html
@@ -1,11 +1,12 @@
-<%
-
- my %opt = @_;
- my $table = $opt{'table'};
- $opt{'fields'} ||= [ fields($table) ];
- push @{ $opt{'fields'} }, qw( pkgnum svcpart );
-
-%><%= include( 'process.html',
+%
+%
+% my %opt = @_;
+% my $table = $opt{'table'};
+% $opt{'fields'} ||= [ fields($table) ];
+% push @{ $opt{'fields'} }, qw( pkgnum svcpart );
+%
+%
+<% include( 'process.html',
'edit_ext' => 'cgi',
'redirect' => popurl(3)."view/$table.cgi?",
%opt,