Added billing plan sql_external for billing services in an external sql database.
authorkhoff <khoff>
Wed, 7 Jan 2004 06:10:01 +0000 (06:10 +0000)
committerkhoff <khoff>
Wed, 7 Jan 2004 06:10:01 +0000 (06:10 +0000)
httemplate/edit/part_pkg.cgi

index b697a76..f2f99b7 100755 (executable)
@@ -474,6 +474,36 @@ tie my %plans, 'Tie::IxHash',
     #'recur' => '\'my $dbh = DBI->connect("\' + what.datasrc.value + \'", "\' + what.db_username.value + \'", "\' what.db_password.value + \'" ) or die $DBI::errstr; my $sth = $dbh->prepare("\' + what.query.value + \'") or die $dbh->errstr; my $units = 0; foreach my $cust_svc ( grep { $_->part_svc->svcdb eq "svc_domain" } $cust_pkg->cust_svc ) { my $domain = $cust_svc->svc_x->domain; $sth->execute($domain) or die $sth->errstr; $units += $sth->fetchrow_arrayref->[0]; } $units -= \' + what.recur_included.value + \'; $units = 0 if $units < 0; \' + what.recur_flat.value + \' + $units * \' + what.recur_unit_charge + \';\'',
   },
 
     #'recur' => '\'my $dbh = DBI->connect("\' + what.datasrc.value + \'", "\' + what.db_username.value + \'", "\' what.db_password.value + \'" ) or die $DBI::errstr; my $sth = $dbh->prepare("\' + what.query.value + \'") or die $dbh->errstr; my $units = 0; foreach my $cust_svc ( grep { $_->part_svc->svcdb eq "svc_domain" } $cust_pkg->cust_svc ) { my $domain = $cust_svc->svc_x->domain; $sth->execute($domain) or die $sth->errstr; $units += $sth->fetchrow_arrayref->[0]; } $units -= \' + what.recur_included.value + \'; $units = 0 if $units < 0; \' + what.recur_flat.value + \' + $units * \' + what.recur_unit_charge + \';\'',
   },
 
+
+
+  'sql_external' => {
+    'name' => 'Base charge plus additional fees for external services from a configurable SQL query',
+    'fields' => {
+      'setup_fee' => { 'name' => 'Setup fee for this package',
+                       'default' => 0,
+                     },
+      'recur_flat' => { 'name' => 'Base monthly charge for this package',
+                        'default' => 0,
+                      },
+      'datasrc' => { 'name' => 'DBI data source',
+                     'default' => '',
+                   },
+      'db_username' => { 'name' => 'Database username',
+                         'default' => '',
+                       },
+      'db_password' => { 'name' => 'Database password',
+                         'default' => '',
+                       },
+      'query' => { 'name' => 'SQL query',
+                   'default' => '',
+                 },
+    },
+    'fieldorder' => [qw( setup_fee recur_flat datasrc db_username db_password query )],
+    'setup' => 'what.setup_fee.value',
+    'recur' => q!'my $dbh = DBI->connect("' + what.datasrc.value + '", "' + what.db_username.value + '", "' + what.db_password.value + '" ) or die $DBI::errstr; my $sth = $dbh->prepare("' + what.query.value + '") or die $dbh->errstr; my $price = ' + what.recur_flat.value + '; foreach my $cust_svc ( grep { $_->part_svc->svcdb eq "svc_external" } $cust_pkg->cust_svc ){ my $id = $cust_svc->svc_x->id; $sth->execute($id) or die $sth->errstr; $price += $sth->fetchrow_arrayref->[0]; } $price;'!,
+
+  },
+
 ;
 
 my %plandata = map { /^(\w+)=(.*)$/; ( $1 => $2 ); }
 ;
 
 my %plandata = map { /^(\w+)=(.*)$/; ( $1 => $2 ); }