1 <% include( 'elements/process.html',
2 'table' => 'part_virtual_field',
3 'viewall_dir' => 'browse',
4 'precheck_callback' => sub {
6 $act = 'edit' if $cgi->param('vfieldpart');
7 my @permitted_tables = qw( svc_broadband router cust_main );
8 return 'Table not in list of permitted tables'
9 unless $cgi->param('dbtable')
10 && grep { $_ eq $cgi->param('dbtable') } @permitted_tables;
13 'noerror_callback' => sub {
14 my ($cgi, $object) = @_;
15 if ( $act eq 'add' ) {
16 use FS::Schema qw( reload_dbdef );
17 warn "cf add started schema modification, time=".time;
19 my $sql = "ALTER TABLE ".$object->dbtable." ADD COLUMN cf_".$object->name." varchar(".$object->length.")";
20 $dbh->do($sql) or die $dbh->errstr;
21 $sql = "ALTER TABLE h_".$object->dbtable." ADD COLUMN cf_".$object->name." varchar(".$object->length.")";
22 $dbh->do($sql) or die $dbh->errstr;
24 # apparently nothing happens w/o commit here - but is this OK?
25 $dbh->commit or die $dbh->errstr;
28 my $dbdef_file = "/usr/local/etc/freeside/dbdef.".datasrc # XXX: fix this
29 my $dbdef = new_native DBIx::DBSchema $dbh;
30 $dbdef->save($dbdef_file);
31 delete $FS::Schema::dbdef_cache{$dbdef_file}; #force an actual reload
32 reload_dbdef($dbdef_file);
34 warn "cf add done schema modification, time=".time;
36 # XXX: edit is going to be harder: possibly add editing length and renaming column
46 unless $FS::CurrentUser::CurrentUser->access_right('Configuration');