[freeside-commits] freeside/httemplate/edit/process/elements
process.html, NONE, 1.1
Ivan,,,
ivan at wavetail.420.am
Wed Mar 8 02:05:03 PST 2006
Update of /home/cvs/cvsroot/freeside/httemplate/edit/process/elements
In directory wavetail:/tmp/cvs-serv10076/httemplate/edit/process/elements
Added Files:
process.html
Log Message:
Add a new table for inventory with for DIDs/serials/etc., and an additional
new table for inventory category (i.e. to distinguish DIDs, serials, MACs,
etc.)
--- NEW FILE: process.html ---
<%
# options example...
#
# 'table' =>
# #? 'primary_key' => #required when the dbdef doesn't know...???
# #? 'fields' => []
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 {
warn $new;
$error = $new->insert;
warn $error;
$pkeyvalue = $new->getfield($pkey);
}
if ( $error ) {
$cgi->param('error', $error);
print $cgi->redirect(popurl(2). "$table.html?". $cgi->query_string );
} else {
print $cgi->redirect(popurl(3). "search/$table.html");
}
%>
More information about the freeside-commits
mailing list