diff options
| -rw-r--r-- | FS/FS/Schema.pm | 2 | ||||
| -rw-r--r-- | FS/FS/cgp_rule_condition.pm | 8 | ||||
| -rwxr-xr-x | FS/bin/freeside-upgrade | 31 | ||||
| -rw-r--r-- | httemplate/browse/cgp_rule.html | 2 | ||||
| -rw-r--r-- | httemplate/edit/cgp_rule.html | 4 | ||||
| -rw-r--r-- | httemplate/edit/process/cgp_rule.html | 2 | ||||
| -rw-r--r-- | httemplate/elements/select-cgp_rule_condition.html | 12 | 
7 files changed, 44 insertions, 17 deletions
diff --git a/FS/FS/Schema.pm b/FS/FS/Schema.pm index 0b54282ef..859224fb0 100644 --- a/FS/FS/Schema.pm +++ b/FS/FS/Schema.pm @@ -1803,7 +1803,7 @@ sub tables_hashref {      'cgp_rule_condition' => {        'columns' => [          'ruleconditionnum',  'serial',     '',      '', '', '', -        'condition',        'varchar',     '', $char_d, '', '', +        'conditionname',    'varchar',     '', $char_d, '', '',          'op',               'varchar', 'NULL', $char_d, '', '',          'params',           'varchar', 'NULL',     255, '', '',          'rulenum',              'int',     '',      '', '', '', diff --git a/FS/FS/cgp_rule_condition.pm b/FS/FS/cgp_rule_condition.pm index 02ea1729d..772e1899e 100644 --- a/FS/FS/cgp_rule_condition.pm +++ b/FS/FS/cgp_rule_condition.pm @@ -36,7 +36,7 @@ currently supported:  primary key -=item condition +=item conditionname  condition @@ -113,7 +113,7 @@ sub check {    my $error =       $self->ut_numbern('ruleconditionnum') -    || $self->ut_text('condition') +    || $self->ut_text('conditionname')      || $self->ut_textn('op')      || $self->ut_textn('params')      || $self->ut_foreign_key('rulenum', 'cgp_rule', 'rulenum') @@ -125,13 +125,13 @@ sub check {  =item arrayref -Returns an array reference of the condition, op and params fields. +Returns an array reference of the conditionname, op and params fields.  =cut  sub arrayref {    my $self = shift; -  [ map $self->$_, qw( condition op params ) ]; +  [ map $self->$_, qw( conditionname op params ) ];  }  =back diff --git a/FS/bin/freeside-upgrade b/FS/bin/freeside-upgrade index a0a5fe68c..4a6fac293 100755 --- a/FS/bin/freeside-upgrade +++ b/FS/bin/freeside-upgrade @@ -61,6 +61,33 @@ if (dbdef->table('cust_main')->column('agent_custid') && ! $opt_s) {        if (dbdef->table('h_cust_main'));   } +if ( dbdef->table('cgp_rule_condition') && +     dbdef->table('cgp_rule_condition')->column('condition')  +   ) +{ +  push @bugfix, +   "ALTER TABLE ${_}cgp_rule_condition RENAME COLUMN condition TO conditionname" +      for '', 'h_'; + +} + +if ( $DRY_RUN ) { +  print +    join(";\n", @bugfix ). ";\n"; +} elsif ( @bugfix ) { + +  foreach my $statement ( @bugfix ) { +    warn "$statement\n"; +    $dbh->do( $statement ) +      or die "Error: ". $dbh->errstr. "\n executing: $statement"; +  } + +  dbdef_create($dbh, $dbdef_file); +  delete $FS::Schema::dbdef_cache{$dbdef_file}; #force an actual reload +  reload_dbdef($dbdef_file); + +} +  #you should have run fs-migrate-part_svc ages ago, when you upgraded  #from 1.3 to 1.4... if not, it needs to be hooked into -upgrade here or  #you'll lose all the part_svc settings it migrates to part_svc_column @@ -83,10 +110,10 @@ unless ( driver_name =~ /^mysql/i ) {  if ( $DRY_RUN ) {    print -    join(";\n", @bugfix, @statements ). ";\n"; +    join(";\n", @statements ). ";\n";    exit;  } else { -  foreach my $statement ( @bugfix, @statements ) { +  foreach my $statement ( @statements ) {      warn "$statement\n";      $dbh->do( $statement )        or die "Error: ". $dbh->errstr. "\n executing: $statement"; diff --git a/httemplate/browse/cgp_rule.html b/httemplate/browse/cgp_rule.html index 6f7b3e087..5be6bb4aa 100644 --- a/httemplate/browse/cgp_rule.html +++ b/httemplate/browse/cgp_rule.html @@ -55,7 +55,7 @@ my $condition_sub = sub {    [ map {            [ -            { data  => $_->condition, +            { data  => $_->conditionname,                #align =>              },              { data  => $_->op, diff --git a/httemplate/edit/cgp_rule.html b/httemplate/edit/cgp_rule.html index d9c19a150..41275aba7 100644 --- a/httemplate/edit/cgp_rule.html +++ b/httemplate/edit/cgp_rule.html @@ -51,7 +51,7 @@ my %opt = @_;  my $m2_error_callback_cond = sub {    my($cgi, $object) = @_; -  my @fields = qw( condition op params ); +  my @fields = qw( conditionname op params );    my @gfields = ( '', map "_$_", @fields );    map { @@ -83,7 +83,7 @@ my $m2_error_callback_action = sub {          if ( /^ruleactionnum(\d+)$/ ) {            my $num = $1;            if ( grep $cgi->param("ruleactionnum$num$_"), @gfields ) { -            my $x = new FS::cgp_rule_condition { +            my $x = new FS::cgp_rule_action {                'ruleactionnum' => $cgi->param("ruleactionnum$num"),                map { $_ => scalar($cgi->param("ruleactionnum${num}_$_")) } @fields,              }; diff --git a/httemplate/edit/process/cgp_rule.html b/httemplate/edit/process/cgp_rule.html index f427b6ccf..965341384 100644 --- a/httemplate/edit/process/cgp_rule.html +++ b/httemplate/edit/process/cgp_rule.html @@ -4,7 +4,7 @@                'process_o2m' => [                  {                    'table' => 'cgp_rule_condition', -                  'fields' => [qw( condition op params )], +                  'fields' => [qw( conditionname op params )],                  },                  {                    'table' => 'cgp_rule_action', diff --git a/httemplate/elements/select-cgp_rule_condition.html b/httemplate/elements/select-cgp_rule_condition.html index 622cbe86d..bc96ab487 100644 --- a/httemplate/elements/select-cgp_rule_condition.html +++ b/httemplate/elements/select-cgp_rule_condition.html @@ -3,10 +3,10 @@    <INPUT TYPE="hidden" NAME="<%$name%>" ID="<%$id%>" VALUE="<% $curr_value %>">    <% include( 'select.html', -                'field'      => $name.'_condition', -                'id'         => $id.'_condition', +                'field'      => $name.'_conditionname', +                'id'         => $id.'_conditionname',                  'options'    => \@conditions, -                'curr_value' => $condition, +                'curr_value' => $conditionname,                  'labels'     => { '' => 'Select Condition' },                  'onchange'   => $name.'_changed',              ) @@ -189,10 +189,10 @@ if ( $curr_value ) {    $cgp_rule_condition = new FS::cgp_rule_condition {};  } -my $condition = scalar($cgi->param($name.'_condition')) -                || $cgp_rule_condition->condition; +my $conditionname = scalar($cgi->param($name.'_conditionname')) +                    || $cgp_rule_condition->conditionname; -my @op = &$cond2op($condition); +my @op = &$cond2op($conditionname);  my $disabled = scalar(@op) ? '' : 1;  my $style = $disabled ? 'visibility:hidden' : '';  | 
