1 package SL::Controller::RecordTemplate;
5 use base qw(SL::Controller::Base);
7 use SL::Helper::Flash qw(flash);
8 use SL::Locale::String qw(t8);
9 use SL::DB::RecordTemplate;
11 use Rose::Object::MakeMethods::Generic (
12 'scalar --get_set_init' => [ qw(template_type template templates data) ],
15 __PACKAGE__->run_before('check_auth');
19 controller => 'ar.pl',
20 load_action => 'load_record_template',
21 save_action => 'save_record_template',
22 form_selector => '#form',
26 controller => 'ap.pl',
27 load_action => 'load_record_template',
28 save_action => 'save_record_template',
29 form_selector => '#form',
33 controller => 'gl.pl',
34 load_action => 'load_record_template',
35 save_action => 'save_record_template',
36 form_selector => '#form',
44 sub action_show_dialog {
49 html => $self->dialog_html,
50 id => 'record_template_dialog',
52 title => t8('Record templates'),
55 ->focus("#record_template_dialog_new_template_name")
62 $self->template_type($self->template->template_type);
63 $self->template->update_attributes(template_name => $::form->{template_name});
67 ->html('#record_template_dialog', $self->dialog_html)
68 ->focus("#record_template_dialog_new_template_name")
76 $self->template_type($self->template->template_type);
77 $self->template->delete;
81 ->html('#record_template_dialog', $self->dialog_html)
82 ->focus("#record_template_dialog_new_template_name")
92 $::auth->assert('ap_transactions | ar_transactions | gl_transactions');
95 sub init_template_type { $::form->{template_type} or die 'need template_type' }
96 sub init_data { $modules{ $_[0]->template_type } }
97 sub init_template { SL::DB::RecordTemplate->new(id => $::form->{id})->load }
102 return scalar SL::DB::Manager::RecordTemplate->get_all_sorted(
103 where => [ template_type => $self->template_type ],
110 return $self->render('record_template/dialog', { layout => 0, output => 0 });