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;
$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";
$form->{shipto_id} = $shipto_id;
}
- # currencies
- @curr = split(/:/, $form->{currencies});
- chomp $curr[0];
- $form->{defaultcurrency} = $curr[0];
-
- map { $form->{selectcurrency} .= "<option>$_\n" } @curr;
-
$form->{oldcustomer} = "$form->{customer}--$form->{customer_id}";
if (@{ $form->{all_customer} }) {
- $form->{customer} = "$form->{customer}--$form->{customer_id}";
- map { $form->{selectcustomer} .= "<option>$_->{name}--$_->{id}\n" }
- (@{ $form->{all_customer} });
+ $form->{customer} = "$form->{customer}--$form->{customer_id}";
+ $form->{selectcustomer} = "$form->{customer}--$form->{customer_id}";
}
# departments
map {
$form->{selectdepartment} .=
- "<option>$_->{description}--$_->{id}\n"
+ "<option>$_->{description}--$_->{id}</option>\n"
} (@{ $form->{all_departments} });
}
$form->{employee} = "$form->{employee}--$form->{employee_id}";
- # sales staff
- if ($form->{all_employees}) {
- $form->{selectemployee} = "";
- map { $form->{selectemployee} .= "<option>$_->{name}--$_->{id}\n" }
- (@{ $form->{all_employees} });
- }
-
# forex
$form->{forex} = $form->{exchangerate};
$exchangerate = ($form->{exchangerate}) ? $form->{exchangerate} : 1;
foreach $key (keys %{ $form->{AR_links} }) {
foreach $ref (@{ $form->{AR_links}{$key} }) {
- $form->{"select$key"} .= "<option>$ref->{accno}--$ref->{description}\n";
+ $form->{"select$key"} .=
+"<option>$ref->{accno}--$ref->{description}</option>\n";
}
if ($key eq "AR_paid") {
}
my $set_duedate_url =
- "$form->{script}?login=$form->{login}&path=$form->{path}&password=$form->{password}&action=set_duedate";
+ "$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);
- if (@{ $form->{TAXZONE} }) {
- $form->{selecttaxzone} = "";
- foreach $item (@{ $form->{TAXZONE} }) {
- if ($item->{id} == $form->{taxzone_id}) {
- $form->{selecttaxzone} .=
- "<option value=$item->{id} selected>" . H($item->{description}) .
- "</option>";
- } else {
- $form->{selecttaxzone} .=
- "<option value=$item->{id}>" . H($item->{description}) . "</option>";
- }
-
- }
- } else {
- $form->{selecttaxzone} =~ s/ selected//g;
- if ($form->{taxzone_id} ne "") {
- $form->{selecttaxzone} =~ s/value=\"$form->{taxzone_id}\"/value=\"$form->{taxzone_id}\" selected/;
- }
- }
-
- $taxzone = qq|
- <tr>
- <th align="right">| . $locale->text('Steuersatz') . qq|</th>
- <td><select name="taxzone_id">$form->{selecttaxzone}</select></td>
- <input type="hidden" name="selecttaxzone" value="$form->{selecttaxzone}">
- </tr>|;
-
my @old_project_ids = ($form->{"globalproject_id"});
map({ push(@old_project_ids, $form->{"project_id_$_"})
if ($form->{"project_id_$_"}); } (1..$form->{"rowcount"}));
"projects" => { "key" => "ALL_PROJECTS",
"all" => 0,
"old_id" => \@old_project_ids },
- "employees" => "ALL_SALESMEN");
+ "employees" => "ALL_SALESMEN",
+ "taxzones" => "ALL_TAXZONES",
+ "currencies" => "ALL_CURRENCIES",
+ "customers" => "ALL_CUSTOMERS");
- my (%labels, @values);
+ my %labels;
+ my @values = (undef);
foreach my $item (@{ $form->{"ALL_CONTACTS"} }) {
push(@values, $item->{"cp_id"});
$labels{$item->{"cp_id"}} = $item->{"cp_name"} .
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"};
+ }
+
+ my $employees = qq|
+ <tr>
+ <th align="right">| . $locale->text('Employee') . qq|</th>
+ <td>| .
+ NTI($cgi->popup_menu('-name' => 'employee', '-default' => $form->{"employee_id"},
+ '-values' => \@values, '-labels' => \%labels)) . qq|
+ </td>
+ </tr>|;
+
+
+ %labels = ();
+ @values = ();
+ foreach my $item (@{ $form->{"ALL_CUSTOMERS"} }) {
+ push(@values, $item->{name}.qq|--|.$item->{"id"});
+ $labels{$item->{"id"}} = $item->{name}.qq|--|.$item->{"id"};
+ }
+
+ my $customers = qq|
+ <th align="right">| . $locale->text('Customer') . qq|</th>
+ <td>| .
+ (($myconfig{vclimit} <= scalar(@values))
+ ? qq|<input type="text" value="| . H($form->{"oldcustomer"}) . qq|" name="customer">|
+ : (NTI($cgi->popup_menu('-name' => 'customer', '-default' => $form->{oldcustomer},
+ '-onChange' => 'document.getElementById(\'update_button\').click();',
+ '-values' => \@values, '-labels' => \%labels)))) . qq|
+ </td>|;
+
%labels = ();
@values = ("");
foreach my $item (@{ $form->{"ALL_SHIPTO"} }) {
'-labels' => \%labels, '-default' => $form->{"shipto_id"}))
. qq|</td>|;
+ %labels = ();
+ @values = ();
+ foreach my $item (@{ $form->{"ALL_CURRENCIES"} }) {
+ push(@values, $item);
+ $labels{$item} = $item;
+ }
+
+ $form->{currency} = $form->{defaultcurrency} unless $form->{currency};
+ my $currencies = qq|
+ <tr>
+ <th align="right">| . $locale->text('Currency') . qq|</th>
+ <td>| .
+ NTI($cgi->popup_menu('-name' => 'currency', '-default' => $form->{"currency"},
+ '-values' => \@values, '-labels' => \%labels)) . qq|
+ </td>
+ </tr>|;
+
%labels = ();
@values = ("");
foreach my $item (@{ $form->{"ALL_PROJECTS"} }) {
. qq|</td>
</tr>|;
+ %labels = ();
+ @values = ();
+ foreach my $item (@{ $form->{"ALL_TAXZONES"} }) {
+ push(@values, $item->{"id"});
+ $labels{$item->{"id"}} = $item->{"description"};
+ }
+
+ if (!$form->{"id"}) {
+ $taxzone = qq|
+ <tr>
+ <th align="right">| . $locale->text('Steuersatz') . qq|</th>
+ <td>| .
+ NTI($cgi->popup_menu('-name' => 'taxzone_id', '-default' => $form->{"taxzone_id"},
+ '-values' => \@values, '-labels' => \%labels)) . qq|
+ </td>
+ </tr>|;
+
+ } else {
+ $taxzone = qq|
+ <tr>
+ <th align="right">| . $locale->text('Steuersatz') . qq|</th>
+ <td>
+ <input type="hidden" name="taxzone_id" value="| . H($form->{"taxzone_id"}) . qq|">
+ | . H($labels{$form->{"taxzone_id"}}) . qq|
+ </td>
+ </tr>|;
+ }
+
# set option selected
foreach $item (qw(AR customer currency department employee)) {
$form->{"select$item"} =~ s/ selected//;
#quote customer Bug 133
$form->{selectcustomer} = $form->quote($form->{selectcustomer});
+
+ #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;
<input type="hidden" name="forex" value="$form->{forex}">
|;
- $customer =
- ($form->{selectcustomer})
- ? qq|<select name="customer">$form->{selectcustomer}</select>\n<input type="hidden" name="selectcustomer" value="$form->{selectcustomer}">|
- : qq|<input name="customer" value="$form->{customer}" size="35">|;
-
$department = qq|
<tr>
<th align="right" nowrap>| . $locale->text('Department') . qq|</th>
# with JavaScript Calendar
$button1 = qq|
- <td><input name="invdate" id="invdate" size="11" title="$myconfig{dateformat}" value="$form->{invdate}"></td>
+ <td><input name="invdate" id="invdate" size="11" title="$myconfig{dateformat}" value="$form->{invdate}" onBlur=\"check_right_date_format(this)\"></td>
<td><input type="button" name="invdate" id="trigger1" value="|
. $locale->text('button') . qq|"></td>|;
# without JavaScript Calendar
$button1 =
- qq|<td><input name="invdate" size="11" title="$myconfig{dateformat}" value="$form->{invdate}"></td>|;
+ qq|<td><input name="invdate" size="11" title="$myconfig{dateformat}" value="$form->{invdate}" onBlur=\"check_right_date_format(this)\"></td>|;
$button2 =
qq|<td width="13"><input name="duedate" size="11" title="$myconfig{dateformat}" value="$form->{duedate}"></td>|;
}
# with JavaScript Calendar
$button1 = qq|
- <td><input name="invdate" id="invdate" size="11" title="$myconfig{dateformat}" value="$form->{invdate}"></td>
+ <td><input name="invdate" id="invdate" size="11" title="$myconfig{dateformat}" value="$form->{invdate}" onBlur=\"check_right_date_format(this)\"></td>
<td><input type="button" name="invdate" id="trigger1" value="|
. $locale->text('button') . qq|"></td>
|;
$button2 = qq|
- <td width="13"><input name="duedate" id="duedate" size="11" title="$myconfig{dateformat}" value="$form->{duedate}"></td>
+ <td width="13"><input name="duedate" id="duedate" size="11" title="$myconfig{dateformat}" value="$form->{duedate}" onBlur=\"check_right_date_format(this)\"></td>
<td width="4"><input type="button" name="duedate" id="trigger2" value="|
. $locale->text('button') . qq|"></td></td>
|;
$button3 = qq|
- <td width="13"><input name="deliverydate" id="deliverydate" size="11" title="$myconfig{dateformat}" value="$form->{deliverydate}"></td>
+ <td width="13"><input name="deliverydate" id="deliverydate" size="11" title="$myconfig{dateformat}" value="$form->{deliverydate}" onBlur=\"check_right_date_format(this)\"></td>
<td width="4"><input type="button" name="deliverydate" id="trigger3" value="|
. $locale->text('button') . qq|"></td></td>
|;
# without JavaScript Calendar
$button1 =
- qq|<td><input name="invdate" size="11" title="$myconfig{dateformat}" value="$form->{invdate}"></td>|;
+ qq|<td><input name="invdate" size="11" title="$myconfig{dateformat}" value="$form->{invdate}" onBlur=\"check_right_date_format(this)\"></td>|;
$button2 =
- qq|<td width="13"><input name=duedate size=11 title="$myconfig{dateformat}" value=$form->{duedate}></td>|;
+ qq|<td width="13"><input name=duedate size=11 title="$myconfig{dateformat}" value=$form->{duedate} onBlur=\"check_right_date_format(this)\"></td>|;
}
}
if ($form->{resubmit} && ($form->{format} eq "html")) {
} 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')|;
<td>
<table>
<tr>
- <th align="right" nowrap>| . $locale->text('Customer') . qq|</th>
- <td colspan="3">$customer</td>
+ $customers
<input type="hidden" name="customer_klass" value="$form->{customer_klass}">
<input type="hidden" name="customer_id" value="$form->{customer_id}">
- <input type="hidden" name="oldcustomer" value="$form->{oldcustomer}">
+ <input type="hidden" name="oldcustomer" value="$form->{oldcustomer}">
+ <input type="hidden" name="selectcustomer" value="1">
<th align="right" nowrap>|
. $locale->text('Contact Person') . qq|</th>
<td colspan="3">$contact</td>
$taxzone
$department
<tr>
- <th align="right" nowrap>| . $locale->text('Currency') . qq|</th>
- <td><select name="currency">$form->{selectcurrency}</select></td>
- <input type="hidden" name="selectcurrency" value="$form->{selectcurrency}">
- <input type="hidden" name="defaultcurrency" value="$form->{defaultcurrency}">
+ $currencies
<input type="hidden" name="fxgain_accno" value="$form->{fxgain_accno}">
<input type="hidden" name="fxloss_accno" value="$form->{fxloss_accno}">
$exchangerate
<tr>
<th align="right" nowrap>| . $locale->text('Ship via') . qq|</th>
<td colspan="3"><input name="shipvia" size="35" value="$form->{shipvia}"></td>
- </tr>|;
+ </tr>
+ <tr>
+ <th align="right">| . $locale->text('Transaction description') . qq|</th>
+ <td colspan="3">| . $cgi->textfield("-name" => "transaction_description", "-size" => 35, "-value" => $form->{transaction_description}) . qq|</td>
+ </tr>|;
# <tr>
# <td colspan=4>
# <table>
</td>
<td align="right">
<table>
- <tr>
- <th align="right" nowrap>| . $locale->text('Employee') . qq|</th>
- <td colspan="2"><select name="employee">$form->{selectemployee}</select></td>
- <input type="hidden" name="selectemployee" value="$form->{selectemployee}">
- <td></td>
- </tr>
+ $employees
$salesman
|;
if ($form->{type} eq "credit_note") {
</tr>
<tr>
<th align="right" nowrap>| . $locale->text('Order Date') . qq|</th>
- <td><input name="orddate" id="orddate" size="11" title="$myconfig{dateformat}" value="| . Q($form->{orddate}) . qq|"></td>
+ <td><input name="orddate" id="orddate" size="11" title="$myconfig{dateformat}" value="| . Q($form->{orddate}) . qq|" onBlur=\"check_right_date_format(this)\"></td>
<td><input type="button" name="b_orddate" id="trigger_orddate" value="?"></td>
</tr>
<tr>
</tr>
<tr>
<th align="right" nowrap>| . $locale->text('Quotation Date') . qq|</th>
- <td><input name="quodate" id="quodate" size="11" title="$myconfig{dateformat}" value="| . Q($form->{quodate}) . qq|"></td>
+ <td><input name="quodate" id="quodate" size="11" title="$myconfig{dateformat}" value="| . Q($form->{quodate}) . qq|" onBlur=\"check_right_date_format(this)\"></td>
<td><input type="button" name="b_quodate" id="trigger_quodate" value="?"></td>
</tr>
<tr>
<!-- shipto are in hidden variables -->
| ;
map({ print($cgi->hidden("-name" => $_, "-value" => $form->{$_})); }
- qw(shiptoname shiptostreet shiptozipcode shiptocity shiptocountry
- shiptocontact shiptophone shiptofax shiptoemail));
+ qw(shiptoname shiptostreet shiptozipcode shiptocity shiptocountry shiptocontact shiptophone shiptofax shiptoemail shiptodepartment_1 shiptodepartment_2));
print qq|<!-- email variables --> |;
map({ print($cgi->hidden("-name" => $_, "-value" => $form->{$_})); }
qw(message email subject cc bcc taxaccounts));
qq|<textarea name="notes" rows="$rows" cols="26" wrap="soft">$form->{notes}</textarea>|;
$intnotes =
qq|<textarea name="intnotes" rows="$rows" cols="35" wrap="soft">$form->{intnotes}</textarea>|;
-
- $form->{taxincluded} = ($form->{taxincluded}) ? "checked" : "";
+
+ $form->{taxincluded} = ($form->{taxincluded} ? "checked" : "");
$taxincluded = "";
if ($form->{taxaccounts}) {
$taxincluded = qq|
- <input name="taxincluded" class="checkbox" type="checkbox" value=$form->{taxincluded}> <b>|
+ <input name="taxincluded" class="checkbox" type="checkbox" $form->{taxincluded}> <b>|
. $locale->text('Tax Included') . qq|</b><br><br>|;
}
$exchangerate .= qq|<input type="hidden" name="forex_$i" value="$form->{"forex_$i"}">|;
$column_data{"paid_$i"} =
- qq|<td align="center"><input name="paid_$i" size="11" value="$form->{"paid_$i"}"></td>|;
+ qq|<td align="center"><input name="paid_$i" size="11" value="$form->{"paid_$i"}" onBlur=\"check_right_number_format(this)\"></td>|;
$column_data{"exchangerate_$i"} = qq|<td align="center">$exchangerate</td>|;
$column_data{"AR_paid_$i"} =
qq|<td align="center"><select name="AR_paid_$i">$form->{"selectAR_paid_$i"}</select></td>|;
$column_data{"datepaid_$i"} =
- qq|<td align="center"><input id="datepaid_$i" name="datepaid_$i" size="11" title="$myconfig{dateformat}" value=$form->{"datepaid_$i"}>
+ qq|<td align="center"><input id="datepaid_$i" name="datepaid_$i" size="11" title="$myconfig{dateformat}" value="$form->{"datepaid_$i"}" onBlur=\"check_right_date_format(this)\">
<input type="button" name="datepaid_$i" id="trigger_datepaid_$i" value="?"></td>|;
$column_data{"source_$i"} =
qq|<td align=center><input name="source_$i" size="11" value="$form->{"source_$i"}"></td>|;
<td>
|;
- &print_options;
+ print_options();
print qq|
</td>
$cgi->hidden("-name" => "callback", "-value" => $form->{callback})
. $cgi->hidden('-name' => 'draft_id', '-default' => [$form->{draft_id}])
. $cgi->hidden('-name' => 'draft_description', '-default' => [$form->{draft_description}]);
-map({ print $cgi->hidden("-name" => $_ , "-value" => $form->{$_});} qw(path login password));
+map({ print $cgi->hidden("-name" => $_ , "-value" => $form->{$_});} qw(login password));
print qq|
</form>
$form->{print_and_post} = 0;
}
+
+ if($form->{taxincluded}) {
+ $taxincluded = "checked";
+ }
$form->{update} = 1;
&check_name(customer);
+ if(!$form->{taxincluded}) {
+ $form->{taxincluded} = $taxincluded;
+ }
+
+
$form->{exchangerate} = $exchangerate
if (
$form->{forex} = (
$form->isblank("invdate", $locale->text('Invoice Date missing!'));
$form->isblank("customer", $locale->text('Customer missing!'));
+ $form->{invnumber} =~ s/^\s*//g;
+ $form->{invnumber} =~ s/\s*$//g;
+
# if oldcustomer ne customer redo form
if (&check_name(customer)) {
&update;
remove_draft() if $form->{remove_draft};
if(!exists $form->{addition}) {
+ $form->{snumbers} = qq|invnumber_| . $form->{invnumber};
$form->{addition} = $print_post ? "PRINTED AND POSTED" :
$form->{storno} ? "STORNO" :
"POSTED";
}
map({ my $key = $_; delete($form->{$key})
- unless (grep({ $key eq $_ } qw(path login password id type))); }
+ unless (grep({ $key eq $_ } qw(login password id stylesheet type))); }
keys(%{ $form }));
- &invoice_links;
- &prepare_invoice;
+ invoice_links();
+ prepare_invoice();
relink_accounts();
+ # Payments must not be recorded for the new storno invoice.
+ $form->{paidaccounts} = 0;
+ map { my $key = $_; delete $form->{$key} if grep { $key =~ /^$_/ } qw(datepaid_ source_ memo_ paid_ exchangerate_ AR_paid_) } keys %{ $form };
+
$form->{storno_id} = $form->{id};
$form->{storno} = 1;
$form->{id} = "";
$form->{invnumber} = "Storno zu " . $form->{invnumber};
+ $form->{rowcount}++;
- &post();
+ post();
$lxdebug->leave_sub();
-
}
sub preview {
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));
}
sub e_mail {
$lxdebug->enter_sub();
- $print_post = 1;
+ if (!$form->{id}) {
+ $print_post = 1;
- &post;
+ 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;
+ edit_e_mail();
$lxdebug->leave_sub();
}