This commit was generated by cvs2svn to compensate for changes in r3921,
[freeside.git] / FS / FS / part_pkg / flat_comission_pkg.pm
1 package FS::part_pkg::flat_comission_pkg;
2
3 use strict;
4 use vars qw(@ISA %info);
5 #use FS::Record qw(qsearch qsearchs);
6 use FS::part_pkg;
7
8 @ISA = qw(FS::part_pkg::flat);
9
10 %info = (
11     'name' => 'Flat rate with recurring commission per (selected) active package',
12     'fields' => {
13       'setup_fee' => { 'name' => 'Setup fee for this package',
14                        'default' => 0,
15                      },
16       'recur_fee' => { 'name' => 'Recurring fee for this package',
17                        'default' => 0,
18                      },
19       'comission_amount' => { 'name' => 'Commission amount per month (per uncancelled package)',
20                               'default' => 0,
21                             },
22       'comission_depth'  => { 'name' => 'Number of layers',
23                               'default' => 1,
24                             },
25       'comission_pkgpart' => { 'name' => 'Applicable packages<BR><FONT SIZE="-1">(hold <b>ctrl</b> to select multiple packages)</FONT>',
26                                'type' => 'select_multiple',
27                                'select_table' => 'part_pkg',
28                                'select_hash'  => { 'disabled' => '' } ,
29                                'select_key'   => 'pkgpart',
30                                'select_label' => 'pkg',
31                              },
32     },
33     'fieldorder' => [ 'setup_fee', 'recur_fee', 'comission_depth', 'comission_amount', 'comission_pkgpart' ],
34     #'setup' => 'what.setup_fee.value',
35     #'recur' => '""; var pkgparts = ""; for ( var c=0; c < document.flat_comission_pkg.comission_pkgpart.options.length; c++ ) { if (document.flat_comission_pkg.comission_pkgpart.options[c].selected) { pkgparts = pkgparts + document.flat_comission_pkg.comission_pkgpart.options[c].value + \', \'; } } what.recur.value = \'my $error = $cust_pkg->cust_main->credit( \' + what.comission_amount.value + \' * scalar( grep { my $pkgpart = $_->pkgpart; grep { $_ == $pkgpart } ( \' + pkgparts + \'  ) } $cust_pkg->cust_main->referral_cust_pkg(\' + what.comission_depth.value+ \')), "commission" ); die $error if $error; \' + what.recur_fee.value + \';\'',
36     #'disabled' => 1,
37     'weight' => '64',
38 );
39
40 # XXX this needs to be fixed!!!
41 sub calc_recur {
42   my($self, $cust_pkg ) = @_;
43   $self->option('recur_fee');
44 }
45
46 1;