$column_data{dunning_description} = qq|<td><input type=hidden name=inv_id_$i size=2 value="$ref->{id}"><input type=hidden name=customer_id_$i size=2 value="$ref->{customer_id}">$ref->{dunning_level}: $dunning</td>|;
- my $active = "checked";
+ my $active = ($ref->{active}) ? "checked" : "";
$column_data{active} =
qq|<td><input type=checkbox name=active_$i value=1 $active></td>|;
- my $email = "checked";
+ my $email = ($ref->{email}) ? "checked" : "";
$column_data{email} =
qq|<td><input type=checkbox name=email_$i value=1 $email></td>|;
$column_data{next_duedate} = qq|<td><input type=hidden name=next_duedate_$i size=6 value="$ref->{next_duedate}">$ref->{next_duedate}</td>|;
}
DN->save_config(\%myconfig, \%$form);
+ # saving the history
+ if(!exists $form->{addition} && $form->{id} ne "") {
+ $form->{addition} = "SAVED FOR DUNNING";
+ $form->save_history($form->dbconnect(\%myconfig));
+ }
+ # /saving the history
$form->redirect($locale->text('Dunning Process Config saved!'));
$lxdebug->leave_sub();
if($form->{DUNNING_PDFS}) {
DN->melt_pdfs(\%myconfig, \%$form,$spool);
}
-
+ # saving the history
+ if(!exists $form->{addition} && $form->{id} ne "") {
+ $form->{addition} = "DUNNING STARTED";
+ $form->save_history($form->dbconnect(\%myconfig));
+ }
+ # /saving the history
$form->redirect($locale->text('Dunning Process started for selected invoices!'));
$lxdebug->leave_sub();
$dunning = qq|<select name=next_dunning_id_$i>$form->{selectdunning}</select>|;
-
-
- $column_data{dunning_description} = qq|<td>$ref->{dunning_description}</td>|;
+ my $script = "";
+ if ($ref->{invoice}) {
+ $script = "is.pl";
+ } else {
+ $script = "ar.pl";
+ }
+ $column_data{dunning_description} = qq|<td><a href=dn.pl?action=print_dunning&dunning_id=$ref->{dunning_id}&format=pdf&media=screen&path=$form->{path}&login=$form->{login}&password=$form->{password}&callback=$form->{callback}>$ref->{dunning_description}</a></td>|;
my $active = "checked";
$column_data{dunning_date} = qq|<td>$ref->{dunning_date}</td>|;
$column_data{next_duedate} = qq|<td>$ref->{dunning_duedate}</td>|;
$column_data{inv_duedate} = qq|<td>$ref->{duedate}</td>|;
$column_data{invdate} = qq|<td>$ref->{transdate}</td>|;
- $column_data{invnumber} = qq|<td><a href=ar.pl?action=edit&id=$ref->{id}&path=$form->{path}&login=$form->{login}&password=$form->{password}&callback=$form->{callback}>$ref->{invnumber}</a></td>|;
+ $column_data{invnumber} = qq|<td><a href=$script?action=edit&id=$ref->{id}&path=$form->{path}&login=$form->{login}&password=$form->{password}&callback=$form->{callback}>$ref->{invnumber}</a></td>|;
$column_data{customername} = qq|<td>$ref->{customername}</td>|;
$column_data{invamount} = qq|<td>$ref->{amount}</td>|;
$column_data{fee} = qq|<td>$ref->{fee}</td>|;
$lxdebug->leave_sub();
}
+
+sub print_dunning {
+ $lxdebug->enter_sub();
+
+ DN->print_dunning(\%myconfig, \%$form, $form->{dunning_id}, $userspath,$spool, $sendmail);
+
+ if($form->{DUNNING_PDFS}) {
+ DN->melt_pdfs(\%myconfig, \%$form,$spool);
+ } else {
+ $form->redirect($locale->text('Could not create dunning copy!'));
+ }
+
+ $lxdebug->leave_sub();
+
+}
+
# end of main