Merge branch 'master' of git.freeside.biz:/home/git/freeside
[freeside.git] / httemplate / edit / part_pkg.cgi
index 23de7c1..65eca6c 100755 (executable)
@@ -48,6 +48,7 @@
                    'recur_cost'       => 'Recur cost',
                    'pay_weight'       => 'Payment weight',
                    'credit_weight'    => 'Credit weight',
+                   'agent_pkgpartid'  => 'External ID',
                    'agentnum'         => 'Agent',
                    'setup_fee'        => 'Setup fee',
                    'setup_show_zero'  => 'Show zero setup',
                      { type  => 'tablebreak-tr-title',
                        value => 'Cost tracking', #better name?
                      },
-                     { field=>'setup_cost', type=>'money', },
-                     { field=>'recur_cost', type=>'money', },
+
+                     ( $curuser->access_right('Edit package definition costs')
+                       ? ( { field=>'setup_cost', type=>'money', },
+                           { field=>'recur_cost', type=>'money', },
+                         )
+                       : ( { field=>'setup_cost', type=>'fixed', },
+                           { field=>'recur_cost', type=>'fixed', },
+                         )
+                     ),
 
                      ( $conf->exists('part_pkg-delay_start')
                        ? ( { type  => 'tablebreak-tr-title',
                        },
                      },
 
+                     ($fcc_opts ? (
+                       { type  => 'tablebreak-tr-title',
+                         value => 'FCC Form 477 information',
+                       },
+                       { field => 'fcc_options_string',
+                         type  => 'input-fcc_options',
+                         curr_value_callback => sub {
+                           my ($cgi, $part_pkg, $fref) = @_;
+                           if ( $cgi->param('fcc_options_string') ) {
+                             # error redirect
+                             return $cgi->param('fcc_options_string');
+                           }
+                           my %hash;
+                           %hash = $part_pkg->fcc_options 
+                             if ($part_pkg->pkgpart);
+                           return encode_json(\%hash);
+                         },
+                       },
+                       ) : ()
+                     ),
+
+                     { type  => 'tablebreak-tr-title',
+                       value => 'External Links', #better name?
+                     },
+                     { field=>'agent_pkgpartid', type=>'text', size=>21 },
+
                      { type  => 'tablebreak-tr-title',
                        value => 'Line-item revenue recogition', #better name?
                      },
                      { field=>'pay_weight',    type=>'text', size=>6 },
                      { field=>'credit_weight', type=>'text', size=>6 },
 
-                     ( $conf->exists('cust_pkg-show_fcc_voice_grade_equivalent')
-                       ? ( 
-                           { type  => 'tablebreak-tr-title',
-                             value => 'FCC Form 477 information',
-                           },
-                           { field=>'fcc_voip_class',
-                             type=>'select-voip_class',
-                           },
-                           { field=>'fcc_ds0s', type=>'text', size=>6 },
-                         )
-                        : ()
-                     ),
-
-
                    { type => 'columnend' },
 
                    { type     => 'tablebreak-tr-title',
                                             ? "AND pkgpart != $pkgpart"
                                             : ''
                                          },
+                     'label_callback' => sub { shift->pkg_comment_only },
                      'm2_label'   => 'Include line item(s) from package',
                      'm2m_method' => 'bill_part_pkg_link',
                      'm2m_dstcol' => 'dst_pkgpart',
                                             ? "AND pkgpart != $pkgpart"
                                             : ''
                                          },
+                     'label_callback' => sub { shift->pkg_comment_only },
                      'm2_label'   => 'Include services of package: ',
                      'm2m_method' => 'svc_part_pkg_link',
                      'm2m_dstcol' => 'dst_pkgpart',
                    },
                    { 'field'       => 'supp_dst_pkgpart',
                      'type'        => 'select-part_pkg',
+                     'label_callback' => sub { shift->pkg_comment_only },
                      'm2_label'    => 'When ordering package, also order',
                      'm2m_method'  => 'supp_part_pkg_link',
                      'm2m_dstcol'  => 'dst_pkgpart',
@@ -385,6 +408,8 @@ my $agent_clone_extra_sql =
 my $conf = new FS::Conf;
 my $taxproducts = $conf->exists('enable_taxproducts');
 
+my $fcc_opts = $conf->exists('part_pkg-show_fcc_options');
+
 my @locales = grep { ! /^en_/i } $conf->config('available-locales'); #should filter from the default locale lang instead of en_
 my %locale_labels =  map {
   ( $_ => 'Package -- '. FS::Locales->description($_) )
@@ -806,13 +831,15 @@ my $javascript = <<'END';
 
       var plan = what.options[what.selectedIndex].value;
 
-      var term_table = document.getElementById('TableNumber7') // XXX NOT ROBUST
+      var term_table = document.getElementById('TableNumber8') // XXX NOT ROBUST
       if ( plan == 'flat' || plan == 'prorate' || plan == 'subscription' ) {
         //term_table.disabled = false;
-        term_table.style.visibility = '';
+        //term_table.style.visibility = '';
+        term_table.style.display = '';
       } else {
         //term_table.disabled = true;
-        term_table.style.visibility = 'hidden';
+        //term_table.style.visibility = 'hidden';
+        term_table.style.display = 'none';
       }
 
       var currency_regex = /^(setup|recur)_fee_[A-Z]{3}$/;
@@ -955,7 +982,17 @@ my $html_bottom = sub {
                    ? ' CHECKED'
                    : ''
                  ). '>';
-  
+
+      } elsif ( $href->{$field}{'type'} eq 'select-rate' ) {
+
+        $html .= include('/elements/select-rate.html',
+                           'field'      => $layer.'__'.$field,
+                           'curr_value' => $options{$field},
+                           map { $_ => $href->{$field}{$_} }
+                             grep { $_ !~ /^(name|type)$/ }
+                               keys %{ $href->{$field} }
+                        );
+
       } elsif ( $href->{$field}{'type'} =~ /^select/ ) {
   
         $html .= '<SELECT';