X-Git-Url: http://wagnertech.de/git?a=blobdiff_plain;ds=sidebyside;f=bin%2Fmozilla%2Fis.pl;h=e94bb386e11dc1f8fd65baf04aeb870b6910a8ab;hb=599030d5e26bcef0f9850ddbbedba106ded70ebb;hp=501d885ddbee6ba04c3c2b64a4a699308739d28c;hpb=e4cc127ad5e8b572a747de9be85ebccd4a73a953;p=kivitendo-erp.git
diff --git a/bin/mozilla/is.pl b/bin/mozilla/is.pl
index 501d885dd..e94bb386e 100644
--- a/bin/mozilla/is.pl
+++ b/bin/mozilla/is.pl
@@ -35,8 +35,9 @@ use SL::IS;
use SL::PE;
use Data::Dumper;
-require "$form->{path}/io.pl";
-require "$form->{path}/arap.pl";
+require "bin/mozilla/io.pl";
+require "bin/mozilla/arap.pl";
+require "bin/mozilla/drafts.pl";
1;
@@ -44,7 +45,9 @@ require "$form->{path}/arap.pl";
sub add {
$lxdebug->enter_sub();
-
+
+ return $lxdebug->leave_sub() if (load_draft_maybe());
+
if ($form->{type} eq "credit_note") {
$form->{title} = $locale->text('Add Credit Note');
@@ -58,7 +61,7 @@ sub add {
$form->{callback} =
- "$form->{script}?action=add&type=$form->{type}&login=$form->{login}&path=$form->{path}&password=$form->{password}"
+ "$form->{script}?action=add&type=$form->{type}&login=$form->{login}&password=$form->{password}"
unless $form->{callback};
$form{jsscript} = "date";
@@ -69,8 +72,6 @@ sub add {
}
&invoice_links;
&prepare_invoice;
- $form->{format} = "pdf";
-
&display_form;
$lxdebug->leave_sub();
@@ -79,7 +80,10 @@ sub add {
sub edit {
$lxdebug->enter_sub();
-
+ # show history button
+ $form->{javascript} = qq||;
+ #/show hhistory button
+
if ($myconfig{acs} =~ "AR--Add Sales Invoice" || $myconfig{acs} =~ "AR--AR")
{
$form->error("Access Denied");
@@ -117,6 +121,7 @@ sub invoice_links {
if ($form->{all_customer}) {
unless ($form->{customer_id}) {
$form->{customer_id} = $form->{all_customer}->[0]->{id};
+ $form->{salesman_id} = $form->{all_customer}->[0]->{salesman_id};
}
}
@@ -138,6 +143,7 @@ sub invoice_links {
$cp_id = $form->{cp_id};
IS->get_customer(\%myconfig, \%$form);
+
#quote all_customer Bug 133
foreach $ref (@{ $form->{all_customer} }) {
$ref->{name} = $form->quote($ref->{name});
@@ -161,19 +167,11 @@ sub invoice_links {
$form->{shipto_id} = $shipto_id;
}
- # currencies
- @curr = split(/:/, $form->{currencies});
- chomp $curr[0];
- $form->{defaultcurrency} = $curr[0];
-
- map { $form->{selectcurrency} .= "\n"
} (@{ $form->{all_departments} });
}
$form->{employee} = "$form->{employee}--$form->{employee_id}";
- # sales staff
- if ($form->{all_employees}) {
- $form->{selectemployee} = "";
- map { $form->{selectemployee} .= "\n";
}
if ($key eq "AR_paid") {
@@ -245,11 +237,9 @@ sub prepare_invoice {
if ($form->{type} eq "credit_note") {
$form->{type} = "credit_note";
$form->{formname} = "credit_note";
- $form->{media} = "screen";
} else {
$form->{type} = "invoice";
$form->{formname} = "invoice";
- $form->{media} = "screen";
}
if ($form->{id}) {
@@ -260,10 +250,11 @@ sub prepare_invoice {
# # get pricegroups for parts
# IS->get_pricegroups_for_parts(\%myconfig, \%$form);
+ my $i = 0;
+
foreach $ref (@{ $form->{invoice_details} }) {
$i++;
-
map { $form->{"${_}_$i"} = $ref->{$_} } keys %{$ref};
$form->{"discount_$i"} =
$form->format_amount(\%myconfig, $form->{"discount_$i"} * 100);
@@ -310,6 +301,9 @@ sub form_header {
}
}
+ $form->{radier} =
+ ($form->current_date(\%myconfig) eq $form->{gldate}) ? 1 : 0;
+
$payment = qq||;
foreach $item (@{ $form->{payment_terms} }) {
if ($form->{payment_id} eq $item->{id}) {
@@ -319,65 +313,158 @@ sub form_header {
}
}
+ my $set_duedate_url =
+ "$form->{script}?login=$form->{login}&password=$form->{password}&action=set_duedate";
+
+ my $pjx = new CGI::Ajax( 'set_duedate' => $set_duedate_url );
+ push(@ { $form->{AJAX} }, $pjx);
+
+ my @old_project_ids = ($form->{"globalproject_id"});
+ map({ push(@old_project_ids, $form->{"project_id_$_"})
+ if ($form->{"project_id_$_"}); } (1..$form->{"rowcount"}));
+
+ $form->get_lists("contacts" => "ALL_CONTACTS",
+ "shipto" => "ALL_SHIPTO",
+ "projects" => { "key" => "ALL_PROJECTS",
+ "all" => 0,
+ "old_id" => \@old_project_ids },
+ "employees" => "ALL_SALESMEN",
+ "taxzones" => "ALL_TAXZONES",
+ "currencies" => "ALL_CURRENCIES",
+ "customers" => "ALL_CUSTOMERS");
+
+ my %labels;
+ my @values = (undef);
+ foreach my $item (@{ $form->{"ALL_CONTACTS"} }) {
+ push(@values, $item->{"cp_id"});
+ $labels{$item->{"cp_id"}} = $item->{"cp_name"} .
+ ($item->{"cp_abteilung"} ? " ($item->{cp_abteilung})" : "");
+ }
+ my $contact =
+ NTI($cgi->popup_menu('-name' => 'cp_id', '-values' => \@values,
+ '-labels' => \%labels, '-default' => $form->{"cp_id"}));
+
+ %labels = ();
+ @values = ();
+ foreach my $item (@{ $form->{"ALL_SALESMEN"} }) {
+ push(@values, $item->{"id"});
+ $labels{$item->{"id"}} = $item->{"name"};
+ }
- if (@{ $form->{TAXZONE} }) {
- $form->{selecttaxzone} = "";
- foreach $item (@{ $form->{TAXZONE} }) {
- if ($item->{id} == $form->{taxzone_id}) {
- $form->{selecttaxzone} .=
- "";
- } else {
- $form->{selecttaxzone} .=
- "";
- }
+ my $employees = qq|
+
+ | . $locale->text('Employee') . qq| |
+ | .
+ NTI($cgi->popup_menu('-name' => 'employee', '-default' => $form->{"employee_id"},
+ '-values' => \@values, '-labels' => \%labels)) . qq|
+ |
+
|;
+
+
+ %labels = ();
+ @values = ();
+ foreach my $item (@{ $form->{"ALL_CUSTOMERS"} }) {
+ push(@values, $item->{name}.qq|--|.$item->{"id"});
+ $labels{$item->{"id"}} = $item->{name}.qq|--|.$item->{"id"};
+ }
- }
- } else {
- $form->{selecttaxzone} =~ s/ selected//g;
- if ($form->{taxzone_id} ne "") {
- $form->{selecttaxzone} =~ s/value=$form->{taxzone_id}/value=$form->{taxzone_id} selected/;
- }
+ my $customers = qq|
+ | . $locale->text('Customer') . qq| |
+ | .
+ (($myconfig{vclimit} == 1 )
+ ? qq||
+ : (NTI($cgi->popup_menu('-name' => 'customer', '-default' => $form->{oldcustomer},
+ '-onChange' => 'document.getElementById(\'update_button\').click();',
+ '-values' => \@values, '-labels' => \%labels)))) . qq|
+ | |;
+
+ %labels = ();
+ @values = ("");
+ foreach my $item (@{ $form->{"ALL_SHIPTO"} }) {
+ push(@values, $item->{"shipto_id"});
+ $labels{$item->{"shipto_id"}} =
+ $item->{"shiptoname"} . " " . $item->{"shiptodepartment_1"};
}
- if ($form->{rowcount} >0) {
- $form->{selecttaxzone} =~ /";
- foreach $item (@{ $form->{SHIPTO} }) {
- if ($item->{id} == $form->{shipto_id}) {
- $form->{selectshipto} .=
- "";
- } else {
- $form->{selectshipto} .=
- "";
- }
+ if (!$form->{"id"}) {
+ $taxzone = qq|
+
+ | . $locale->text('Steuersatz') . qq| |
+ | .
+ NTI($cgi->popup_menu('-name' => 'taxzone_id', '-default' => $form->{"taxzone_id"},
+ '-values' => \@values, '-labels' => \%labels)) . qq|
+ |
+
|;
- }
} else {
- $form->{selectshipto} =~ s/ selected//g;
- if ($form->{shipto_id} ne "") {
- $form->{selectshipto} =~ s/value=$form->{shipto_id}/value=$form->{shipto_id} selected/;
- }
+ $taxzone = qq|
+
+ | . $locale->text('Steuersatz') . qq| |
+
+
+ | . H($labels{$form->{"taxzone_id"}}) . qq|
+ |
+
|;
}
- $shipto = qq|
- | . $locale->text('Shipping Address') . qq| |
- |
- |;
-
-
-
# set option selected
foreach $item (qw(AR customer currency department employee)) {
$form->{"select$item"} =~ s/ selected//;
@@ -387,36 +474,16 @@ sub form_header {
#quote customer Bug 133
$form->{selectcustomer} = $form->quote($form->{selectcustomer});
-
- #build contacts
- if ($form->{all_contacts}) {
-
- $form->{selectcontact} = "";
- foreach $item (@{ $form->{all_contacts} }) {
- my $department = ($item->{cp_abteilung}) ? "--$item->{cp_abteilung}" : "";
- if ($form->{cp_id} == $item->{cp_id}) {
- $form->{selectcontact} .=
- "";
- } else {
- $form->{selectcontact} .= "";
- }
- }
- } else {
- $form->{selectcontact} =~ s/ selected//g;
- if ($form->{cp_id} ne "") {
- $form->{selectcontact} =~ s/value=$form->{cp_id}/value=$form->{cp_id} selected/;
- }
- }
-
+ #substitute \n and \r to \s (bug 543)
+ $form->{selectcustomer} =~ s/[\n\r]/ /g;
+
if (($form->{creditlimit} != 0) && ($form->{creditremaining} < 0) && !$form->{update}) {
$creditwarning = 1;
} else {
$creditwarning = 0;
}
- #else {$form->{all_contacts} = 0;}
-
$form->{exchangerate} =
$form->format_amount(\%myconfig, $form->{exchangerate});
@@ -429,36 +496,25 @@ sub form_header {
if ($form->{currency} ne $form->{defaultcurrency}) {
if ($form->{forex}) {
$exchangerate .=
- qq||
+ qq| | |
. $locale->text('Exchangerate')
- . qq| | $form->{exchangerate}{exchangerate}> | |;
+ . qq|$form->{exchangerate} | |;
} else {
$exchangerate .=
- qq||
+ qq| | |
. $locale->text('Exchangerate')
- . qq| | {exchangerate}> | |;
+ . qq| | |;
}
}
$exchangerate .= qq|
-{forex}>
+
|;
- $customer =
- ($form->{selectcustomer})
- ? qq|\n|
- : qq||;
-
- #sk
- $contact =
- ($form->{selectcontact})
- ? qq|\n|
- : qq||;
-
$department = qq|
| . $locale->text('Department') . qq| |
-
-
+ |
+
|
| if $form->{selectdepartment};
@@ -468,9 +524,9 @@ sub form_header {
if ($form->{business}) {
$business = qq|
- | . $locale->text('Business') . qq| |
+ | . $locale->text('Business') . qq| |
$form->{business} |
- | . $locale->text('Trade Discount') . qq| |
+ | . $locale->text('Trade Discount') . qq| |
|
. $form->format_amount(\%myconfig, $form->{tradediscount} * 100)
. qq| % |
@@ -481,12 +537,12 @@ sub form_header {
if ($form->{max_dunning_level}) {
$dunning = qq|
-
+ |
- | . $locale->text('Max. Dunning Level') . qq|: |
+ | . $locale->text('Max. Dunning Level') . qq|: |
$form->{max_dunning_level} |
- | . $locale->text('Dunning Amount') . qq|: |
+ | . $locale->text('Dunning Amount') . qq|: |
|
. $form->format_amount(\%myconfig, $form->{dunning_amount},2)
. qq| |
@@ -507,11 +563,10 @@ sub form_header {
# with JavaScript Calendar
$button1 = qq|
- {invdate}> |
- text('button') . qq|> |
- |;
-
+ |
+ | |;
+
#write Trigger
$jsscript =
Form->write_trigger(\%myconfig, "1",
@@ -521,28 +576,28 @@ sub form_header {
# without JavaScript Calendar
$button1 =
- qq|{invdate}> | |;
+ qq| | |;
$button2 =
- qq|{duedate}> | |;
+ qq| | |;
}
} else {
if ($form->{jsscript}) {
# with JavaScript Calendar
$button1 = qq|
- {invdate}> |
- text('button') . qq|> |
+ |
+ |
|;
$button2 = qq|
- {duedate}> |
- text('button') . qq|> |
+ |
+ |
|;
$button3 = qq|
- {deliverydate}> |
- text('button') . qq|> |
+ |
+ |
|;
#write Trigger
@@ -557,9 +612,9 @@ sub form_header {
# without JavaScript Calendar
$button1 =
- qq|{invdate}> | |;
+ qq| | |;
$button2 =
- qq|{duedate}> | |;
+ qq|{duedate} onBlur=\"check_right_date_format(this)\"> | |;
}
}
if ($form->{resubmit} && ($form->{format} eq "html")) {
@@ -568,14 +623,24 @@ sub form_header {
} elsif ($form->{resubmit}) {
$onload = qq|document.invoice.submit()|;
} else {
- $onload = "fokus()";
+ $onload = "focus()";
}
-
+ $onload .= qq|;setupDateFormat('|. $myconfig{dateformat} .qq|', '|. $locale->text("Falsches Datumsformat!") .qq|')|;
+ $onload .= qq|;setupPoints('|. $myconfig{numberformat} .qq|', '|. $locale->text("wrongformat") .qq|')|;
$credittext = $locale->text('Credit Limit exceeded!!!');
if ($creditwarning) {
$onload = qq|alert('$credittext')|;
}
+ $form->{"javascript"} .= qq||;
+
+ $jsscript .=
+ $form->write_trigger(\%myconfig, 2,
+ "orddate", "BL", "trigger_orddate",
+ "quodate", "BL", "trigger_quodate");
+ # show history button js
+ $form->{javascript} .= qq||;
+ #/show history button js
$form->header;
print qq|
@@ -585,69 +650,45 @@ sub form_header {
- |
-
|;
@@ -1551,10 +1646,38 @@ sub credit_note {
sub yes {
$lxdebug->enter_sub();
-
- $form->redirect($locale->text('Invoice deleted!'))
- if (IS->delete_invoice(\%myconfig, \%$form, $spool));
+ if (IS->delete_invoice(\%myconfig, \%$form, $spool)) {
+ # saving the history
+ if(!exists $form->{addition}) {
+ $form->{snumbers} = qq|invnumber_| . $form->{invnumber};
+ $form->{addition} = "DELETED";
+ $form->save_history($form->dbconnect(\%myconfig));
+ }
+ # /saving the history
+ $form->redirect($locale->text('Invoice deleted!'));
+ }
$form->error($locale->text('Cannot delete invoice!'));
$lxdebug->leave_sub();
}
+
+sub e_mail {
+ $lxdebug->enter_sub();
+
+ if (!$form->{id}) {
+ $print_post = 1;
+
+ my $saved_form = save_form();
+
+ post();
+
+ my %saved_vars;
+ map({ $saved_vars{$_} = $form->{$_}; } qw(id invnumber));
+ restore_form($saved_form);
+ map({ $form->{$_} = $saved_vars{$_}; } qw(id invnumber));
+ }
+
+ edit_e_mail();
+
+ $lxdebug->leave_sub();
+}