# GNU General Public License for more details.
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
-# Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
+# MA 02110-1335, USA.
#======================================================================
#
# Dunning process module
use POSIX qw(strftime);
use SL::IS;
-use SL::PE;
use SL::DN;
+use SL::DB::Department;
use SL::DB::Dunning;
-use SL::Helper::Flash;
+use SL::Helper::Flash qw(flash);
use SL::Locale::String qw(t8);
use SL::ReportGenerator;
$form->{title} = $locale->text('Edit Dunning Process Config');
$form->{callback} ||= build_std_url("action=edit_config");
+ setup_dn_edit_config_action_bar();
+
$form->header();
print $form->parse_html_template("dunning/edit_config");
$main::auth->assert('dunning_edit');
- # setup customer selection
- $form->all_vc(\%myconfig, "customer", "AR");
-
DN->get_config(\%myconfig, \%$form);
- $form->{SHOW_CUSTOMER_SELECTION} = $form->{all_customer} && scalar @{ $form->{all_customer} };
+ $form->get_lists("departments" => "ALL_DEPARTMENTS");
+
$form->{SHOW_DUNNING_LEVEL_SELECTION} = $form->{DUNNING} && scalar @{ $form->{DUNNING} };
- $form->{SHOW_DEPARTMENT_SELECTION} = $form->{all_departments} && scalar @{ $form->{all_departments} || [] };
+ $form->{SHOW_DEPARTMENT_SELECTION} = $form->{ALL_DEPARTMENTS} && scalar @{ $form->{ALL_DEPARTMENTS} || [] };
$form->{title} = $locale->text('Start Dunning Process');
+
+ setup_dn_add_action_bar();
$form->header();
print $form->parse_html_template("dunning/add");
if ($row->{next_dunning_config_id}) {
map { $_->{SELECTED} = $_->{id} == $row->{next_dunning_config_id} } @{ $row->{DUNNING_CONFIG } };
}
- map { $row->{$_} = $form->format_amount(\%myconfig, $row->{$_} * 1, -2) } qw(amount open_amount fee interest);
+ map { $row->{$_} = $form->format_amount(\%myconfig, $row->{$_} * 1, 2) } qw(amount open_amount fee interest);
if ($row->{'language_id'}) {
$row->{language} = SL::DB::Manager::Language->find_by_or_create('id' => $row->{'language_id'})->{'description'};
'no_html' => 1,
'no_opendocument' => 1,);
+ setup_dn_show_invoices_action_bar();
$form->header();
print $form->parse_html_template("dunning/show_invoices");
my $saved_language_id = $form->{language_id};
- if ($form->{groupinvoices}) {
+ if ($form->{groupinvoices} || $form->{l_include_credit_notes}) {
my %dunnings_for;
for my $i (1 .. $form->{rowcount}) {
push @{ $level }, { "row" => $i,
"invoice_id" => $form->{"inv_id_$i"},
+ "credit_note" => $form->{"credit_note_$i"},
"customer_id" => $form->{"customer_id_$i"},
"language_id" => $form->{"language_id_$i"},
"next_dunning_config_id" => $form->{"next_dunning_config_id_$i"},
+ "print_invoice" => $form->{"include_invoice_$i"},
"email" => $form->{"email_$i"}, };
}
"customer_id" => $form->{"customer_id_$i"},
"language_id" => $form->{"language_id_$i"},
"next_dunning_config_id" => $form->{"next_dunning_config_id_$i"},
+ "print_invoice" => $form->{"include_invoice_$i"},
"email" => $form->{"email_$i"}, } ];
if (!$form->{force_lang}) {
$form->{language_id} = @{$level}[0]->{language_id};
DN->get_config(\%myconfig, \%$form);
- $form->{SHOW_CUSTOMER_DDBOX} = scalar @{ $form->{ALL_CUSTOMERS} } <= $myconfig{vclimit};
- $form->{SHOW_DEPARTMENT_DDBOX} = scalar @{ $form->{ALL_CUSTOMERS} };
$form->{SHOW_DUNNING_LEVELS} = scalar @{ $form->{DUNNING} };
$form->{title} = $locale->text('Dunnings');
+ setup_dn_search_action_bar();
$form->header();
print $form->parse_html_template("dunning/search");
'checkbox' => { 'text' => '', 'visible' => 'HTML' },
'dunning_description' => { 'text' => $locale->text('Dunning Level') },
'customername' => { 'text' => $locale->text('Customername') },
+ 'departmentname' => { 'text' => $locale->text('Department') },
'language' => { 'text' => $locale->text('Language') },
'invnumber' => { 'text' => $locale->text('Invnumber') },
'transdate' => { 'text' => $locale->text('Invdate') },
$report->set_options_from_form();
+ setup_dn_show_dunning_action_bar();
$report->generate_with_headers();
$main::lxdebug->leave_sub();
$::form->error($::locale->text('No action defined.'));
}
+
+sub setup_dn_add_action_bar {
+ my %params = @_;
+
+ for my $bar ($::request->layout->get('actionbar')) {
+ $bar->add(
+ action => [
+ t8('Search'),
+ submit => [ '#form', { action => "show_invoices" } ],
+ accesskey => 'enter',
+ ],
+ );
+ }
+}
+
+sub setup_dn_show_invoices_action_bar {
+ my %params = @_;
+
+ for my $bar ($::request->layout->get('actionbar')) {
+ $bar->add(
+ action => [
+ t8('Create'),
+ submit => [ '#form', { action => "save_dunning" } ],
+ checks => [ [ 'kivi.check_if_entries_selected', '[name^=active_]' ] ],
+ accesskey => 'enter',
+ only_once => 1,
+ ],
+ );
+ }
+}
+
+sub setup_dn_search_action_bar {
+ my %params = @_;
+
+ for my $bar ($::request->layout->get('actionbar')) {
+ $bar->add(
+ action => [
+ t8('Search'),
+ submit => [ '#form', { action => "show_dunning" } ],
+ accesskey => 'enter',
+ ],
+ );
+ }
+}
+
+sub setup_dn_show_dunning_action_bar {
+ my %params = @_;
+
+ for my $bar ($::request->layout->get('actionbar')) {
+ $bar->add(
+ action => [
+ t8('Print'),
+ submit => [ '#form', { action => "print_multiple" } ],
+ checks => [ [ 'kivi.check_if_entries_selected', '[name^=selected_]' ] ],
+ accesskey => 'enter',
+ ],
+
+ action => [
+ t8('Delete'),
+ submit => [ '#form', { action => "delete" } ],
+ checks => [ [ 'kivi.check_if_entries_selected', '[name^=selected_]' ] ],
+ confirm => $::locale->text('This resets the dunning process for the selected invoices. Posted dunning invoices will not be changed!'),
+ ],
+ );
+ }
+}
+
+sub setup_dn_edit_config_action_bar {
+ my %params = @_;
+
+ for my $bar ($::request->layout->get('actionbar')) {
+ $bar->add(
+ action => [
+ t8('Save'),
+ submit => [ '#form', { action => "save" } ],
+ accesskey => 'enter',
+ ],
+ );
+ }
+}
+
# end of main