This commit was generated by cvs2svn to compensate for changes in r11022,
[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::flat;
7
8 @ISA = qw(FS::part_pkg::flat);
9
10 %info = (
11   'name' => 'Flat rate with recurring commission per (selected) active package',
12   'shortname' => 'Commission per (selected) active package',
13   'inherit_fields' => [ 'flat_comission', 'global_Mixin' ],
14   'fields' => {
15     'comission_pkgpart' => { 'name' => 'Applicable packages<BR><FONT SIZE="-1">(hold <b>ctrl</b> to select multiple packages)</FONT>',
16                              'type' => 'select_multiple',
17                              'select_table' => 'part_pkg',
18                              'select_hash'  => { 'disabled' => '' } ,
19                              'select_key'   => 'pkgpart',
20                              'select_label' => 'pkg',
21                            },
22   },
23   'fieldorder' => [ 'comission_depth', 'comission_amount', 'comission_pkgpart', 'reason_type' ],
24   #'setup' => 'what.setup_fee.value',
25   #'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 + \';\'',
26   #'disabled' => 1,
27   'weight' => '64',
28 );
29
30 # XXX this needs to be fixed!!!
31 sub calc_recur {
32   my($self, $cust_pkg ) = @_;
33   $self->option('recur_fee');
34 }
35
36 sub can_discount { 0; }
37
38 1;