1 package FS::part_pkg::flat_comission_pkg;
4 use vars qw(@ISA %info);
5 #use FS::Record qw(qsearch qsearchs);
6 use FS::part_pkg::flat;
8 @ISA = qw(FS::part_pkg::flat);
11 'name' => 'Flat rate with recurring commission per (selected) active package',
12 'shortname' => 'Commission per (selected) active package',
14 'setup_fee' => { 'name' => 'Setup fee for this package',
17 'recur_fee' => { 'name' => 'Recurring fee for this package',
20 'unused_credit' => { 'name' => 'Credit the customer for the unused portion'.
21 ' of service at cancellation',
24 'comission_amount' => { 'name' => 'Commission amount per month (per uncancelled package)',
27 'comission_depth' => { 'name' => 'Number of layers',
30 'comission_pkgpart' => { 'name' => 'Applicable packages<BR><FONT SIZE="-1">(hold <b>ctrl</b> to select multiple packages)</FONT>',
31 'type' => 'select_multiple',
32 'select_table' => 'part_pkg',
33 'select_hash' => { 'disabled' => '' } ,
34 'select_key' => 'pkgpart',
35 'select_label' => 'pkg',
37 'reason_type' => { 'name' => 'Reason type for commission credits',
39 'select_table' => 'reason_type',
40 'select_hash' => { 'class' => 'R' } ,
41 'select_key' => 'typenum',
42 'select_label' => 'type',
45 'fieldorder' => [ 'setup_fee', 'recur_fee', 'unused_credit', 'comission_depth', 'comission_amount', 'comission_pkgpart', 'reason_type' ],
46 #'setup' => 'what.setup_fee.value',
47 #'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 + \';\'',
52 # XXX this needs to be fixed!!!
54 my($self, $cust_pkg ) = @_;
55 $self->option('recur_fee');