# /saving the history
$form->{title} = "Add";
- $form->{callback} = "ar.pl?action=add" unless $form->{callback};
+ $form->{callback} = "ar.pl?action=add&DONT_LOAD_DRAFT=1" unless $form->{callback};
AR->get_transdate(\%myconfig, $form);
$form->{initial_transdate} = $form->{transdate};
my $form = $main::form;
my %myconfig = %main::myconfig;
my $locale = $main::locale;
- my $cgi = $main::cgi;
+ my $cgi = $::request->{cgi};
my ($title, $readonly, $exchangerate, $rows);
my ($taxincluded, $notes, $department, $customer, $employee, $amount, $project);
$form->{exchangerate} = $form->{forex} if $form->{forex};
# format amounts
- $form->{exchangerate} =
- $form->format_amount(\%myconfig, $form->{exchangerate});
-
- if ($form->{exchangerate} == 0) {
- $form->{exchangerate} = "";
- }
-
- $form->{creditlimit} =
- $form->format_amount(\%myconfig, $form->{creditlimit}, 0, "0");
- $form->{creditremaining} =
- $form->format_amount(\%myconfig, $form->{creditremaining}, 0, "0");
+ $form->{exchangerate} = $form->{exchangerate} ? $form->format_amount(\%myconfig, $form->{exchangerate}) : '';
+ $form->{creditlimit} = $form->format_amount(\%myconfig, $form->{creditlimit}, 0, "0");
+ $form->{creditremaining} = $form->format_amount(\%myconfig, $form->{creditremaining}, 0, "0");
$exchangerate = qq|
<input type=hidden name=forex value=$form->{forex}>
qq|<script type="text/javascript" src="js/show_vc_details.js"></script>| .
qq|<script type="text/javascript" src="js/follow_up.js"></script>|;
+ my $globalprojectnumber =
+ NTI($cgi->popup_menu('-name' => "globalproject_id",
+ '-values' => \@project_values,
+ '-labels' => \%project_labels,
+ '-default' => $form->{"globalproject_id"} ));
+
$form->header;
$onload = qq|focus()|;
$onload .= qq|;setupDateFormat('|. $myconfig{dateformat} .qq|', '|. $locale->text("Falsches Datumsformat!") .qq|')|;
<th align=right nowrap>| . $locale->text('Due Date') . qq|</th>
$button2
</tr>
+ <tr>
+ <th align=right nowrap>| . $locale->text('Project Number') . qq|</th>
+ <td>$globalprojectnumber</td>
+ </tr>
</table>
</td>
</tr>
$form->{"paid_$i"} =
$form->format_amount(\%myconfig, $form->{"paid_$i"}, 2);
}
- $form->{"exchangerate_$i"} =
- $form->format_amount(\%myconfig, $form->{"exchangerate_$i"});
-
if ($form->{"exchangerate_$i"} == 0) {
$form->{"exchangerate_$i"} = "";
+ } else {
+ $form->{"exchangerate_$i"} =
+ $form->format_amount(\%myconfig, $form->{"exchangerate_$i"});
+ }
+
+ print qq|<input type=hidden name="acc_trans_id_$i" value=$form->{"acc_trans_id_$i"}>\n|;
+ print qq|<input type=hidden name="gldate_$i" value=$form->{"gldate_$i"}>\n|;
+ my $changeable = 1;
+ if ($::lx_office_conf{features}->{payments_changeable} == 0) {
+ # never
+ $changeable = ($form->{"acc_trans_id_$i"})? 0 : 1;
+ }
+ if ($::lx_office_conf{features}->{payments_changeable} == 2) {
+ # on the same day
+ $changeable = (($form->{"gldate_$i"} eq '') || $form->current_date(\%myconfig) eq $form->{"gldate_$i"});
}
$exchangerate = qq| |;
$exchangerate =
qq|<input type=hidden name="exchangerate_$i" value=$form->{"exchangerate_$i"}>$form->{"exchangerate_$i"}|;
} else {
- $exchangerate =
- qq|<input name="exchangerate_$i" size=10 value=$form->{"exchangerate_$i"}>|;
+ if ($changeable) {
+ $exchangerate =
+ qq|<input name="exchangerate_$i" size=10 value=$form->{"exchangerate_$i"}>|;
+ } else {
+ $exchangerate =
+ qq|<input type=hidden name="exchangerate_$i" value=$form->{"exchangerate_$i"}>$form->{"exchangerate_$i"}|;
+ }
}
}
<input type=hidden name="forex_$i" value=$form->{"forex_$i"}>
|;
- $column_data{paid} =
- qq|<td align=center><input name="paid_$i" size=11 value="$form->{"paid_$i"}" onBlur=\"check_right_number_format(this)\"></td>|;
- $column_data{AR_paid} =
- qq|<td align=center>${selectAR_paid}</td>|;
- $column_data{exchangerate} = qq|<td align=center>$exchangerate</td>|;
- $column_data{datepaid} =
- qq|<td align=center><input name="datepaid_$i" id="datepaid_$i" size=11 value="$form->{"datepaid_$i"}" onBlur=\"check_right_date_format(this)\">
+ my $datepaid;
+ if ($changeable) {
+ $datepaid = qq|<td align=center><input name="datepaid_$i" id="datepaid_$i" size=11 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} =
- qq|<td align=center><input name="source_$i" size=11 value="$form->{"source_$i"}"></td>|;
- $column_data{memo} =
- qq|<td align=center><input name="memo_$i" size=11 value="$form->{"memo_$i"}"></td>|;
+ } else {
+ $datepaid = qq|<td align=center>$form->{"datepaid_$i"}</td>|.
+ qq|<input type=hidden name="datepaid_$i" value=$form->{"datepaid_$i"}>|;
+ }
- $column_data{paid_project_id} =
+ my $paid;
+ if ($changeable) {
+ $paid = qq|<td align=center><input name="paid_$i" size=11 value="$form->{"paid_$i"}" onBlur=\"check_right_number_format(this)\"></td>|;
+ } else {
+ $paid = qq|<td align=center>$form->{"paid_$i"}</td>|.
+ qq|<input type=hidden name="paid_$i" value=$form->{"paid_$i"}>|;
+ }
+
+ my $source;
+ if ($changeable) {
+ $source = qq|<td align=center><input name="source_$i" size=11 value="$form->{"source_$i"}"></td>|;
+ } else {
+ $source = qq|<td align=center>$form->{"source_$i"}</td>|.
+ qq|<input type=hidden name="source_$i" value=$form->{"source_$i"}>|;
+ }
+
+ my $memo;
+ if ($changeable) {
+ $memo = qq|<td align=center><input name="memo_$i" size=11 value="$form->{"memo_$i"}"></td>|;
+ } else {
+ $memo = qq|<td align=center>$form->{"memo_$i"}</td>|.
+ qq|<input type=hidden name="memo_$i" value=$form->{"memo_$i"}>|;
+ }
+
+ my $AR_paid;
+ if ($changeable) {
+ $AR_paid = qq|<td align=center>${selectAR_paid}</td>|;
+ } else {
+ $AR_paid = qq|<td align=center>$form->{"AR_paid_$i"}</td>|.
+ qq|<input type=hidden name="AR_paid_$i" value=$form->{"AR_paid_$i"}>|;
+ }
+
+ my $paid_project_id;
+ if ($changeable) {
+ $paid_project_id =
qq|<td>|
. NTI($cgi->popup_menu('-name' => "paid_project_id_$i",
'-values' => \@project_values,
'-labels' => \%project_labels,
'-default' => $form->{"paid_project_id_$i"} ))
. qq|</td>|;
+ } else {
+ my $projectnumber = $project_labels{$form->{"paid_project_id_$i"}};
+ $paid_project_id = qq|<td>$projectnumber</td>|.
+ qq|<input type=hidden name="paid_project_id_$i" value=$form->{"paid_project_id_$i"}>|;
+ }
+
+ $column_data{paid} = $paid;
+ $column_data{AR_paid} = $AR_paid;
+ $column_data{exchangerate} = qq|<td align=center>$exchangerate</td>|;
+ $column_data{datepaid} = $datepaid;
+ $column_data{source} = $source;
+ $column_data{memo} = $memo;
+ $column_data{paid_project_id} = $paid_project_id;
map { print qq|$column_data{$_}\n| } @column_index;
print "
</tr>
";
- push(@triggers, "datepaid_$i", "BL", "trigger_datepaid_$i");
+ if ($changeable) {
+ push(@triggers, "datepaid_$i", "BL", "trigger_datepaid_$i");
+ }
}
my $paid_missing = $form->{invtotal_unformatted} - $form->{totalpaid};
my $form = $main::form;
my %myconfig = %main::myconfig;
my $locale = $main::locale;
- my $cgi = $main::cgi;
+ my $cgi = $::request->{cgi};
my ($transdate, $closedto);
$form->{invdate} = $form->{transdate};
- my %saved_variables = map +( $_ => $form->{$_} ), qw(AR AR_amount_1 taxchart_1);
+ my %saved_variables = map +( $_ => $form->{$_} ), qw(AR AR_amount_1 taxchart_1 customer_id);
&check_name("customer");
+ # check_name loads customer notes into notes, but ar only knows intnotes, so copy them
+ $form->{notes} = $form->{intnotes} if $saved_variables{customer_id} != $form->{customer_id};
+
$form->{AR} = $saved_variables{AR};
if ($saved_variables{AR_amount_1} =~ m/.--./) {
map { $form->{$_} = $saved_variables{$_} } qw(AR_amount_1 taxchart_1);
my $form = $main::form;
my %myconfig = %main::myconfig;
- map { delete $form->{$_} } qw(printed emailed queued invnumber invdate deliverydate id datepaid_1 source_1 memo_1 paid_1 exchangerate_1 AP_paid_1 storno);
+ map { delete $form->{$_} } qw(printed emailed queued invnumber invdate deliverydate id datepaid_1 gldate_1 acc_trans_id_1 source_1 memo_1 paid_1 exchangerate_1 AP_paid_1 storno);
$form->{paidaccounts} = 1;
$form->{rowcount}--;
$form->{invdate} = $form->current_date(\%myconfig);
my $form = $main::form;
my %myconfig = %main::myconfig;
my $locale = $main::locale;
- my $cgi = $main::cgi;
+ my $cgi = $::request->{cgi};
my ($customer, $department);
my ($jsscript, $button1, $button2, $onload);
$form->get_lists("projects" => { "key" => "ALL_PROJECTS", "all" => 1 },
"departments" => "ALL_DEPARTMENTS",
"customers" => "ALL_VC",
- "employees" => "ALL_EMPLOYEES",
- "salesmen" => "ALL_SALESMEN",
"business_types" => "ALL_BUSINESS_TYPES");
+ $form->{ALL_EMPLOYEES} = SL::DB::Manager::Employee->get_all(query => [ deleted => 0 ]);
$form->{SHOW_BUSINESS_TYPES} = scalar @{ $form->{ALL_BUSINESS_TYPES} } > 0;
# constants and subs for template
$form->{jsscript} = 1;
$form->{vc_keys} = sub { "$_[0]->{name}--$_[0]->{id}" };
- $form->{employee_labels} = sub { $_[0]->{"name"} || $_[0]->{"login"} };
- $form->{salesman_labels} = $form->{employee_labels};
$form->header;
print $form->parse_html_template('ar/search', { %myconfig });
my ($callback, $href, @columns);
- $form->{customer} = $form->unescape($form->{customer});
($form->{customer}, $form->{customer_id}) = split(/--/, $form->{customer});
report_generator_set_default_sort('transdate', 1);
@columns =
qw(transdate id type invnumber ordnumber name netamount tax amount paid
datepaid due duedate transaction_description notes salesman employee shippingpoint shipvia
- marge_total marge_percent globalprojectnumber customernumber country ustid taxzone payment_terms charts);
+ marge_total marge_percent globalprojectnumber customernumber country ustid taxzone payment_terms charts customertype);
my @hidden_variables = map { "l_${_}" } @columns;
- push @hidden_variables, "l_subtotal", qw(open closed customer invnumber ordnumber transaction_description notes project_id transdatefrom transdateto);
+ push @hidden_variables, "l_subtotal", qw(open closed customer invnumber ordnumber transaction_description notes project_id transdatefrom transdateto employee_id salesman_id business_id);
$href = build_std_url('action=ar_transactions', grep { $form->{$_} } @hidden_variables);
'employee' => { 'text' => $locale->text('Employee'), },
'shippingpoint' => { 'text' => $locale->text('Shipping Point'), },
'shipvia' => { 'text' => $locale->text('Ship via'), },
- 'globalprojectnumber' => { 'text' => $locale->text('Project Number'), },
+ 'globalprojectnumber' => { 'text' => $locale->text('Document Project Number'), },
'marge_total' => { 'text' => $locale->text('Ertrag'), },
'marge_percent' => { 'text' => $locale->text('Ertrag prozentual'), },
'customernumber' => { 'text' => $locale->text('Customer Number'), },
'taxzone' => { 'text' => $locale->text('Steuersatz'), },
'payment_terms' => { 'text' => $locale->text('Payment Terms'), },
'charts' => { 'text' => $locale->text('Buchungskonto'), },
+ 'customertype' => { 'text' => $locale->text('Customer type'), },
);
foreach my $name (qw(id transdate duedate invnumber ordnumber name datepaid employee shippingpoint shipvia transaction_description)) {
if ($form->{open}) {
push @options, $locale->text('Open');
}
+ if ($form->{employee_id}) {
+ my $employee = SL::DB::Employee->new(id => $form->{employee_id})->load;
+ push @options, $locale->text('Employee') . ' : ' . $employee->name;
+ }
+ if ($form->{salesman_id}) {
+ my $salesman = SL::DB::Employee->new(id => $form->{salesman_id})->load;
+ push @options, $locale->text('Salesman') . ' : ' . $salesman->name;
+ }
if ($form->{closed}) {
push @options, $locale->text('Closed');
}