-#my $conf = new FS::Conf;
-
-#return contexts and fill-in values
-# If you add anything, be sure to add a description in
-# httemplate/edit/msg_template.html.
-sub substitutions {
- { 'cust_main' => [qw(
- display_custnum agentnum agent_name
-
- last first company
- name name_short contact contact_firstlast
- address1 address2 city county state zip
- country
- daytime night mobile fax
-
- has_ship_address
- ship_name ship_name_short ship_contact ship_contact_firstlast
- ship_address1 ship_address2 ship_city ship_county ship_state ship_zip
- ship_country
-
- paymask payname paytype payip
- num_cancelled_pkgs num_ncancelled_pkgs num_pkgs
- classname categoryname
- balance
- credit_limit
- invoicing_list_emailonly
- cust_status ucfirst_cust_status cust_statuscolor cust_status_label
-
- signupdate dundate
- packages recurdates
- ),
- [ invoicing_email => sub { shift->invoicing_list_emailonly_scalar } ],
- #compatibility: obsolete ship_ fields - use the non-ship versions
- map (
- { my $field = $_;
- [ "ship_$field" => sub { shift->$field } ]
- }
- qw( last first company daytime night fax )
- ),
- # ship_name, ship_name_short, ship_contact, ship_contact_firstlast
- # still work, though
- [ expdate => sub { shift->paydate_epoch } ], #compatibility
- [ signupdate_ymd => sub { $ymd->(shift->signupdate) } ],
- [ dundate_ymd => sub { $ymd->(shift->dundate) } ],
- [ paydate_my => sub { sprintf('%02d/%04d', shift->paydate_monthyear) } ],
- [ otaker_first => sub { shift->access_user->first } ],
- [ otaker_last => sub { shift->access_user->last } ],
- [ payby => sub { FS::payby->shortname(shift->payby) } ],
- [ company_name => sub {
- $conf->config('company_name', shift->agentnum)
- } ],
- [ company_address => sub {
- $conf->config('company_address', shift->agentnum)
- } ],
- [ company_phonenum => sub {
- $conf->config('company_phonenum', shift->agentnum)
- } ],
- [ selfservice_server_base_url => sub {
- $conf->config('selfservice_server-base_url') #, shift->agentnum)
- } ],
- ],
- # next_bill_date
- 'cust_pkg' => [qw(
- pkgnum pkg_label pkg_label_long
- location_label
- status statuscolor
-
- start_date setup bill last_bill
- adjourn susp expire
- labels_short
- ),
- [ pkg => sub { shift->part_pkg->pkg } ],
- [ pkg_category => sub { shift->part_pkg->categoryname } ],
- [ pkg_class => sub { shift->part_pkg->classname } ],
- [ cancel => sub { shift->getfield('cancel') } ], # grrr...
- [ start_ymd => sub { $ymd->(shift->getfield('start_date')) } ],
- [ setup_ymd => sub { $ymd->(shift->getfield('setup')) } ],
- [ next_bill_ymd => sub { $ymd->(shift->getfield('bill')) } ],
- [ last_bill_ymd => sub { $ymd->(shift->getfield('last_bill')) } ],
- [ adjourn_ymd => sub { $ymd->(shift->getfield('adjourn')) } ],
- [ susp_ymd => sub { $ymd->(shift->getfield('susp')) } ],
- [ expire_ymd => sub { $ymd->(shift->getfield('expire')) } ],
- [ cancel_ymd => sub { $ymd->(shift->getfield('cancel')) } ],
-
- # not necessarily correct for non-flat packages
- [ setup_fee => sub { shift->part_pkg->option('setup_fee') } ],
- [ recur_fee => sub { shift->part_pkg->option('recur_fee') } ],
-
- [ freq_pretty => sub { shift->part_pkg->freq_pretty } ],
-
- ],
- 'cust_bill' => [qw(
- invnum
- _date
- _date_pretty
- due_date
- ),
- [ due_date2str => sub { shift->due_date2str('short') } ],
- ],
- #XXX not really thinking about cust_bill substitutions quite yet
-
- # for welcome and limit warning messages
- 'svc_acct' => [qw(
- svcnum
- username
- domain
- ),
- [ password => sub { shift->getfield('_password') } ],
- [ column => sub { &$usage_warning(shift)->[0] } ],
- [ amount => sub { &$usage_warning(shift)->[1] } ],
- [ threshold => sub { &$usage_warning(shift)->[2] } ],
- ],
- 'svc_domain' => [qw(
- svcnum
- domain
- ),
- [ registrar => sub {
- my $registrar = qsearchs('registrar',
- { registrarnum => shift->registrarnum} );
- $registrar ? $registrar->registrarname : ''
- }
- ],
- [ catchall => sub {
- my $svc_acct = qsearchs('svc_acct', { svcnum => shift->catchall });
- $svc_acct ? $svc_acct->email : ''
- }
- ],
- ],
- 'svc_phone' => [qw(
- svcnum
- phonenum
- countrycode
- domain
- )
- ],
- 'svc_broadband' => [qw(
- svcnum
- speed_up
- speed_down
- ip_addr
- mac_addr
- )
- ],
- # for payment receipts
- 'cust_pay' => [qw(
- paynum
- _date
- ),
- [ paid => sub { sprintf("%.2f", shift->paid) } ],
- # overrides the one in cust_main in cases where a cust_pay is passed
- [ payby => sub { FS::payby->shortname(shift->payby) } ],
- [ date => sub { time2str("%a %B %o, %Y", shift->_date) } ],
- [ payinfo => sub {
- my $cust_pay = shift;
- ($cust_pay->payby eq 'CARD' || $cust_pay->payby eq 'CHEK') ?
- $cust_pay->paymask : $cust_pay->decrypt($cust_pay->payinfo)
- } ],
- ],
- # for payment decline messages
- # try to support all cust_pay fields
- # 'error' is a special case, it contains the raw error from the gateway
- 'cust_pay_pending' => [qw(
- _date
- error
- ),
- [ paid => sub { sprintf("%.2f", shift->paid) } ],
- [ payby => sub { FS::payby->shortname(shift->payby) } ],
- [ date => sub { time2str("%a %B %o, %Y", shift->_date) } ],
- [ payinfo => sub {
- my $pending = shift;
- ($pending->payby eq 'CARD' || $pending->payby eq 'CHEK') ?
- $pending->paymask : $pending->decrypt($pending->payinfo)
- } ],
- ],
- };
-}
-