X-Git-Url: http://wagnertech.de/git?a=blobdiff_plain;f=bin%2Fmozilla%2Fdn.pl;h=844abf5b588bd10d22f980ddcc4dac9252521ccf;hb=cd3dc84b8687e1571c7012d91a5138b9444c246c;hp=e79283a6dde98b0eb41e2faaa37b28642e825665;hpb=54e4131e091831e00a861fe2c4f53e344b87ddca;p=kivitendo-erp.git diff --git a/bin/mozilla/dn.pl b/bin/mozilla/dn.pl index e79283a6d..844abf5b5 100644 --- a/bin/mozilla/dn.pl +++ b/bin/mozilla/dn.pl @@ -36,8 +36,8 @@ use SL::PE; use SL::DN; use Data::Dumper; -require "$form->{path}/io.pl"; -require "$form->{path}/arap.pl"; +require "bin/mozilla/io.pl"; +require "bin/mozilla/arap.pl"; 1; @@ -51,7 +51,7 @@ sub edit_config { $form->{title} = $locale->text('Edit Dunning Process Config'); $form->{callback} = - "$form->{script}?action=edit_config&path=$form->{path}&login=$form->{login}&password=$form->{password}" + "$form->{script}?action=edit_config&login=$form->{login}&password=$form->{password}" unless $form->{callback}; @column_index = qw(dunning_level dunning_description active auto email payment_terms terms fee interest template); @@ -105,7 +105,7 @@ sub edit_config { - + |; @@ -163,9 +163,8 @@ sub edit_config { $column_data{dunning_level} = qq||; $column_data{dunning_description} = qq||; - my $active = ""; $column_data{active} = - qq||; + qq||; my $email = ""; $column_data{email} = qq||; @@ -202,19 +201,11 @@ sub edit_config { -{path}> {login}> {password}> |; - - if ($form->{menubar}) { - require "$form->{path}/menu.pl"; - &menubar; - } - - print qq| + . $locale->text('Save') . qq|"> @@ -279,7 +270,7 @@ sub add { # with JavaScript Calendar $button1 = qq| - |; @@ -291,12 +282,16 @@ sub add { # without JavaScript Calendar $button1 = - qq||; + qq||; } $form->{fokus} = "search.customer"; + $form->{javascript} .= qq||; $form->header; + $onload = qq|focus()|; + $onload .= qq|;setupDateFormat('|. $myconfig{dateformat} .qq|', '|. $locale->text("Falsches Datumsformat!") .qq|')|; + $onload .= qq|;setupPoints('|. $myconfig{numberformat} .qq|', '|. $locale->text("wrongformat") .qq|')|; print qq| - +{script}> @@ -328,7 +323,6 @@ sub add { $button1 -
$form->{title}$form->{title}
$i + text('button') . qq|>
| . $locale->text('Payment until') . qq|
@@ -353,7 +347,6 @@ sub add { {nextsub}> -{path}> {login}> {password}> @@ -389,9 +382,12 @@ sub show_invoices { $form->{nextsub} = "save_dunning"; - + + $form->{jsscript} = 1; + $form->{javascript} .= qq||; + $form->{callback} = - "$form->{script}?action=show_invoices&path=$form->{path}&login=$form->{login}&password=$form->{password}&customer=$form->{customer}&invnumber=$form->{invnumber}&ordnumber=$form->{ordnumber}&paymentuntil=$form->{paymentuntil}&groupinvoices=$form->{groupinvoices}&minamount=$form->{minamount}&dunning_level=$form->{dunning_level}¬es=$form->{notes}" + "$form->{script}?action=show_invoices&login=$form->{login}&password=$form->{password}&customer=$form->{customer}&invnumber=$form->{invnumber}&ordnumber=$form->{ordnumber}&paymentuntil=$form->{paymentuntil}&groupinvoices=$form->{groupinvoices}&minamount=$form->{minamount}&dunning_level=$form->{dunning_level}¬es=$form->{notes}" unless $form->{callback}; @column_index = qw(dunning_description active email customername invnumber invdate inv_duedate invamount next_duedate fee interest ); @@ -402,11 +398,17 @@ sub show_invoices { . qq||; $column_header{active} = qq|| - . $locale->text('Active?') + . NTI($cgi->checkbox('-name' => 'selectall_active', + '-label' => $locale->text('Active?'), + '-checked' => 1, + '-onclick' => "checkbox_check_all('selectall_active', 'active_', 1, " . scalar(@{ $form->{DUNNINGS} }) . ")")) . qq||; $column_header{email} = qq|| - . $locale->text('eMail?') + . NTI($cgi->checkbox('-name' => 'selectall_email', + '-label' => $locale->text('eMail?'), + '-checked' => 0, + '-onclick' => "checkbox_check_all('selectall_email', 'email_', 1, " . scalar(@{ $form->{DUNNINGS} }) . ")")) . qq||; $column_header{customername} = qq|| @@ -448,12 +450,12 @@ sub show_invoices { -{script}> +{script}> - + |; @@ -473,19 +475,19 @@ sub show_invoices { |; $form->{selectdunning} =~ s/ selected//g; - if ($ref->{next_dunning_id} ne "") { - $form->{selectdunning} =~ s/value=$ref->{next_dunning_id}/value=$ref->{next_dunning_id} selected/; + if ($ref->{next_dunning_config_id} ne "") { + $form->{selectdunning} =~ s/value=$ref->{next_dunning_config_id}/value=$ref->{next_dunning_config_id} selected/; } - $dunning = qq||; + $dunning = qq||; $column_data{dunning_description} = qq||; - my $active = "checked"; + my $active = ($ref->{active}) ? "checked" : ""; $column_data{active} = qq||; - my $email = "checked"; + my $email = ($ref->{email}) ? "checked" : ""; $column_data{email} = qq||; $column_data{next_duedate} = qq||; @@ -517,8 +519,8 @@ sub show_invoices {
$form->{title}$form->{title}
$ref->{dunning_level}: $dunning$ref->{next_duedate}
|; -&print_options; -print qq| + print_options(); + print qq|
{script}> @@ -528,19 +530,11 @@ print qq| -{path}> {login}> {password}> - -|; - - if ($form->{menubar}) { - require "$form->{path}/menu.pl"; - &menubar; - } - - print qq| + + @@ -566,6 +560,13 @@ sub save { } DN->save_config(\%myconfig, \%$form); + # saving the history + if(!exists $form->{addition} && $form->{id} ne "") { + $form->{snumbers} = qq|dunning_id_| . $form->{"dunning_id"}; + $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(); @@ -580,19 +581,14 @@ sub save_dunning { if ($form->{groupinvoices}) { while ($active) { $lastcustomer = 0; - $form->{inv_ids} = ""; + $form->{inv_ids} = []; $active = 0; @rows = (); for my $i (1 .. $form->{rowcount}) { $form->{"active_$i"} *= 1; $lastcustomer = $form->{"customer_id_$i"} unless ($lastcustomer); - #print(STDERR qq|LASTCUSTOMER $lastcustomer AKTUELL $form->{"customer_id_$i"} ACTIVE? $form->{"active_$i"} active $active\n Zeile $i|); if ($form->{"active_$i"} && ($form->{"customer_id_$i"} == $lastcustomer)) { - if ($form->{inv_ids}) { - $form->{inv_ids} .= qq|,$form->{"inv_id_$i"}|; - } else { - $form->{inv_ids} = qq|($form->{"inv_id_$i"}|; - } + push(@{ $form->{inv_ids} }, $form->{"inv_id_$i"}); $form->{"active_$i"} = 0; $form->{"customer_id_$i"} = 0; push(@rows, $i); @@ -602,28 +598,30 @@ sub save_dunning { $form->{"customer_id_$i"} = 0; } } - if ($form->{inv_ids} ne "") { - $form->{inv_ids} .= ")"; - #print(STDERR "Rufe save_dunning_auf für Zeile $form->{inv_ids} von Kunde $lastcustomer\n"); - DN->save_dunning(\%myconfig, \%$form, \@rows, $userspath,$spool, $sendmail); + if (scalar(@{ $form->{inv_ids} }) != 0) { + DN->save_dunning(\%myconfig, \%$form, \@rows, $userspath, $spool, $sendmail); } } } else { for my $i (1 .. $form->{rowcount}) { if ($form->{"active_$i"}) { @rows = (); - $form->{inv_ids} = qq|($form->{"inv_id_$i"})|; + $form->{inv_ids} = [ $form->{"inv_id_$i"} ]; push(@rows, $i); - #print(STDERR "Rufe save_dunning_auf für Zeile $i\n"); - DN->save_dunning(\%myconfig, \%$form, \@rows, $userspath,$spool, $sendmail); + DN->save_dunning(\%myconfig, \%$form, \@rows, $userspath, $spool, $sendmail); } } } - #print(STDERR Dumper($form->{DUNNING_PDFS})); if($form->{DUNNING_PDFS}) { DN->melt_pdfs(\%myconfig, \%$form,$spool); } - + # saving the history + if(!exists $form->{addition} && $form->{id} ne "") { + $form->{snumbers} = qq|dunning_id_| . $form->{"dunning_id"}; + $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(); @@ -635,7 +633,7 @@ sub set_email { my $callback = "$form->{script}?action=set_email&"; map({ $callback .= "$_=" . $form->escape($form->{$_}) . "&" } - (qw(login path password name input_subject input_body input_attachment email_subject email_body email_attachment), grep({ /^[fl]_/ } keys %$form))); + (qw(login password name input_subject input_body input_attachment email_subject email_body email_attachment), grep({ /^[fl]_/ } keys %$form))); if ($form->{email_attachment}) { $form->{email_attachment} = "checked"; @@ -701,22 +699,22 @@ sub search { # with JavaScript Calendar $button1 = qq| - + text('button') . qq|> |; $button2 = qq| - + text('button') . qq|> |; $button3 = qq| - + text('button') . qq|> |; $button4 = qq| - + text('button') . qq|> |; @@ -728,19 +726,24 @@ sub search { # without JavaScript Calendar $button1 = - qq||; + qq||; $button2 = - qq||; - $button1 = - qq||; - $button1 = - qq||; + qq||; + $button3 = + qq||; + $button4 = + qq||; } $form->{fokus} = "search.customer"; + $form->{javascript} .= qq||; $form->header; + $onload = qq|focus()|; + $onload .= qq|;setupDateFormat('|. $myconfig{dateformat} .qq|', '|. $locale->text("Falsches Datumsformat!") .qq|')|; + $onload .= qq|;setupPoints('|. $myconfig{numberformat} .qq|', '|. $locale->text("wrongformat") .qq|')|; + print qq| - +
{script}> @@ -781,7 +784,6 @@ sub search { $button4 - @@ -802,7 +804,6 @@ sub search { {nextsub}> -{path}> {login}> {password}> @@ -834,7 +835,7 @@ sub show_dunning { $form->{callback} = - "$form->{script}?action=show_dunning&path=$form->{path}&login=$form->{login}&password=$form->{password}&customer=$form->{customer}&invnumber=$form->{invnumber}&ordnumber=$form->{ordnumber}&transdatefrom=$form->{transdatefrom}&transdateto=$form->{transdateto}&dunningfrom=$form->{dunningfrom}&dunningto=$form->{dunningto}¬es=$form->{notes}&showold=$form->{showold}&dunning_level=$form->{dunning_level}" + "$form->{script}?action=show_dunning&login=$form->{login}&password=$form->{password}&customer=$form->{customer}&invnumber=$form->{invnumber}&ordnumber=$form->{ordnumber}&transdatefrom=$form->{transdatefrom}&transdateto=$form->{transdateto}&dunningfrom=$form->{dunningfrom}&dunningto=$form->{dunningto}¬es=$form->{notes}&showold=$form->{showold}&dunning_level=$form->{dunning_level}" unless $form->{callback}; @column_index = qw(dunning_description customername invnumber invdate inv_duedate invamount dunning_date next_duedate fee interest ); @@ -892,7 +893,7 @@ sub show_dunning { - + |; @@ -901,11 +902,28 @@ sub show_dunning { print qq| |; + + my %columns = ( + "dunning_duedate" => "next_duedate", + "duedate" => "inv_duedate", + "transdate" => "invdate", + "amount" => "invamount", + ); + my $i = 0; + my $j = 0; + my ($previous_dunning_id, $first_row_for_dunning); foreach $ref (@{ $form->{DUNNINGS} }) { - $i++; - my $j = $i % 2; + + if ($previous_dunning_id != $ref->{dunning_id}) { + $j++; + $j = $j % 2; + $first_row_for_dunning = 1; + } else { + $first_row_for_dunning = 0; + } + $previous_dunning_id = $ref->{dunning_id}; print qq| @@ -913,23 +931,28 @@ sub show_dunning { - $dunning = qq||; - - - $column_data{dunning_description} = qq||; - my $active = "checked"; - $column_data{dunning_date} = qq||; - $column_data{next_duedate} = qq||; - - $column_data{inv_duedate} = qq||; - $column_data{invdate} = qq||; - $column_data{invnumber} = qq||; - $column_data{customername} = qq||; - $column_data{invamount} = qq||; - $column_data{fee} = qq||; - $column_data{interest} = qq||; + foreach (qw(dunning_date dunning_duedate duedate transdate customername + amount fee interest)) { + my $col = $columns{$_} ? $columns{$_} : $_; + $column_data{$col} = ""; + } + if ($first_row_for_dunning) { + $column_data{dunning_description} = + qq||; + } else { + $column_data{dunning_description} = qq||; + $column_data{customername} = qq||; + } + $column_data{invnumber} = + qq||; map { print "$column_data{$_}\n" } @column_index; @@ -957,17 +980,8 @@ sub show_dunning { -{path}> {login}> {password}> -|; - - if ($form->{menubar}) { - require "$form->{path}/menu.pl"; - &menubar; - } - - print qq| @@ -979,5 +993,21 @@ sub show_dunning { $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
$form->{title}$form->{title}
$ref->{dunning_description}$ref->{dunning_date}$ref->{dunning_duedate}$ref->{duedate}$ref->{transdate}{id}&path=$form->{path}&login=$form->{login}&password=$form->{password}&callback=$form->{callback}>$ref->{invnumber}$ref->{customername}$ref->{amount}$ref->{fee}$ref->{interest}" . H($ref->{$_}) . "| . H($ref->{dunning_description}) . qq|  {id}) . + join("", map({ "&${_}=" . E($form->{$_}) } qw(login password callback))) . + qq|">| . H($ref->{invnumber}) . qq|