use SL::Form;
use SL::User;
use SL::USTVA;
+use SL::Iconv;
use CGI::Ajax;
use CGI;
if ($item eq ''){
$form->{ACCOUNT_TAXKEYS}[$i]{select_tax} .= qq|<option value="" selected="selected">-\n|;
}
- elsif ( $item == $taxkey_used->{pos_ustva} ) {
+ elsif ( $item eq $taxkey_used->{pos_ustva} ) {
$form->{ACCOUNT_TAXKEYS}[$i]{select_tax} .= qq|<option value="$item" selected="selected">$item\n|;
}
else {
30 => "Ausserordentlicher Aufwand",
31 => "Betriebliche Steuern");
foreach $item (sort({ $a <=> $b } keys(%eur))) {
+ my $text = H(SL::Iconv::convert("ISO-8859-15", $dbcharset, $eur{$item}));
if ($item == $form->{pos_eur}) {
- $select_eur .= qq|<option value=$item selected>|. sprintf("%.2d", $item) .qq|. $eur{$item}</option>\n|;
+ $select_eur .= qq|<option value=$item selected>|. sprintf("%.2d", $item) .qq|. $text</option>\n|;
} else {
- $select_eur .= qq|<option value=$item>|. sprintf("%.2d", $item) .qq|. $eur{$item}</option>\n|;
+ $select_eur .= qq|<option value=$item>|. sprintf("%.2d", $item) .qq|. $text</option>\n|;
}
}
34 => 'Verr.kalk.Kosten',
35 => 'Steuern Eink.u.Ertr.');
foreach $item (sort({ $a <=> $b } keys %bwapos)) {
+ my $text = H(SL::Iconv::convert("ISO-8859-15", $dbcharset, $bwapos{$item}));
if ($item == $form->{pos_bwa}) {
- $select_bwa .= qq|<option value="$item" selected>|. sprintf("%.2d", $item) .qq|. $bwapos{$item}\n|;
+ $select_bwa .= qq|<option value="$item" selected>|. sprintf("%.2d", $item) .qq|. $text\n|;
} else {
- $select_bwa .= qq|<option value="$item">|. sprintf("%.2d", $item) .qq|. $bwapos{$item}\n|;
+ $select_bwa .= qq|<option value="$item">|. sprintf("%.2d", $item) .qq|. $text\n|;
}
}
foreach $ca (@{ $form->{CA} }) {
- $ca->{debit} = " ";
- $ca->{credit} = " ";
+ $ca->{debit} = "";
+ $ca->{credit} = "";
if ($ca->{amount} > 0) {
- $ca->{credit} =
- $form->format_amount(\%myconfig, $ca->{amount}, 2, " ");
+ $ca->{credit} = $form->format_amount(\%myconfig, $ca->{amount}, 2);
}
if ($ca->{amount} < 0) {
- $ca->{debit} =
- $form->format_amount(\%myconfig, -1 * $ca->{amount}, 2, " ");
+ $ca->{debit} = $form->format_amount(\%myconfig, -1 * $ca->{amount}, 2);
}
$ca->{heading} = ( $ca->{charttype} eq 'H' ) ? 1:'';
$ca->{link_edit_account} =
qq|$form->{script}?action=edit_account&id=$ca->{id}|
- .qq|&path=$form->{path}&login=$form->{login}|
+ .qq|&login=$form->{login}|
.qq|&password=$form->{password}&callback=$callback|;
}
# Ajax
my $list_account_details_url =
- "$form->{script}?login=$form->{login}&path=$form->{path}"
+ "$form->{script}?login=$form->{login}"
."&password=$form->{password}&action=list_account_details&";
- my $pjx = new CGI::Ajax(
- 'list_account_details' => $list_account_details_url
- );
+ my $pjx = new CGI::Ajax('list_account_details' => $list_account_details_url);
# Eneable AJAX debuging
#$pjx->DEBUG(1);
#$pjx->JSDEBUG(1);
push(@ { $form->{AJAX} }, $pjx);
-
+
+ $form->{stylesheets} = "list_accounts.css";
+
$form->header;
};
# Ausgabe des Templates
- print($form->parse_html_template('am/list_accounts', $parameters_ref));
+ print($form->parse_html_template2('am/list_accounts', $parameters_ref));
$lxdebug->leave_sub();
# construct callback
$callback =
- "$form->{script}?action=list_account&path=$form->{path}&login=$form->{login}&password=$form->{password}";
+ "$form->{script}?action=list_account&login=$form->{login}&password=$form->{password}";
$form->header;
<li>| . $locale->text("<%skonto_amount%> -- The deductible amount")
. qq|</li>
<li>| . $locale->text("<%total%> -- Amount payable")
+. qq|</li>
+ <li>| . $locale->text("<%total_wo_skonto%> -- Amount payable less discount")
. qq|</li>
<li>| . $locale->text("<%invtotal%> -- Invoice total")
+. qq|</li>
+ <li>| . $locale->text("<%invtotal_wo_skonto%> -- Invoice total less discount")
. qq|</li>
<li>| . $locale->text("<%currency%> -- The selected currency")
. qq|</li>
$restriction .= " OR addition = '" . $_ . "'";
}
}
-
$restriction .= (($form->{transdate} ne "" && $form->{reqdate} ne "")
? qq| AND st.itime::date >= '| . $form->{transdate} . qq|' AND st.itime::date <= '| . $form->{reqdate} . qq|'|
: (($form->{transdate} ne "" && $form->{reqdate} eq "")
: ""
)
);
-
+ $restriction .= ($form->{mitarbeiter} eq "" ? ""
+ : ($form->{mitarbeiter} =~ /^[0-9]*$/
+ ? " AND employee_id = " . $form->{mitarbeiter}
+ : " AND employee_id = " . &get_employee_id($form->{mitarbeiter}, $dbh)));
+
my $dbh = $form->dbconnect(\%myconfig);
- my $searchSNumber = $searchNo{$form->{'what2search'}} . qq|_| . $form->{'searchid'};
- $restriction .= ($form->{mitarbeiter} eq "" ? ""
- : ($form->{mitarbeiter} =~ /^[0-9]*$/
- ? " AND employee_id = " . $form->{mitarbeiter}
- : " AND employee_id = " . &get_employee_id($form->{mitarbeiter}, $dbh)));
- my $query = qq|SELECT trans_id AS id FROM history_erp WHERE sNumbers = '$searchSNumber' |;
+ my $query = qq|SELECT trans_id AS id FROM history_erp | .
+ ($form->{'searchid'} ?
+ qq| WHERE snumbers = '| . $searchNo{$form->{'what2search'}} . qq|_| . $form->{'searchid'} . qq|'| :
+ qq| WHERE snumbers ~ '^| . $searchNo{$form->{'what2search'}} . qq|'|);
my $sth = $dbh->prepare($query);
$sth->execute() || $form->dberror($query);
-
- if($sth->fetch() <= 0) {
- $sth->finish();
- my $query = qq|SELECT id FROM $search{$form->{what2search}}
- WHERE $searchNo{$form->{'what2search'}} ILIKE '$form->{"searchid"}'
- |;
- }
- $sth->execute() || $form->dberror($query);
- $form->{title} = $locale->text("History Search");
+
+ $form->{title} = $locale->text("History Search");
$form->header();
- my $daten = "";
- while(my $hash_ref = $sth->fetchrow_hashref()){
- $daten = $form->get_history($dbh,$hash_ref->{id},$restriction);
+
+ my $i = 1;
+ my $daten = qq||;
+ while(my $hash_ref = $sth->fetchrow_hashref()){
+ if($i) {
+ $daten .= $hash_ref->{id};
+ $i = 0;
+ }
+ else {
+ $daten .= " OR trans_id = " . $hash_ref->{id};
+ }
}
- $dbh->disconnect();
+
+ my ($sort, $sortby) = split(/\-\-/, $form->{order});
+ $sort =~ s/.*\.(.*)$/$1/;
+
print $form->parse_html_template("/common/show_history",
- {"DATEN" => $daten,
- "SUCCESS" => ($daten != 0 ? 1 : 0),
- "NONEWWINDOW" => 1
+ {"DATEN" => $form->get_history($dbh, $daten, $restriction, $form->{order}),
+ "SUCCESS" => ($form->get_history($dbh, $daten, $restriction, $form->{order}) ne "0"),
+ "NONEWWINDOW" => 1,
+ uc($sort) => 1,
+ uc($sort)."BY" => $sortby
});
- $lxdebug->leave_sub();
+ $dbh->disconnect();
+ $lxdebug->leave_sub();
}
sub get_employee_id {
$lxdebug->leave_sub();
}
+
+sub add_tax {
+ $lxdebug->enter_sub();
+
+ $form->{title} = $locale->text('Add');
+
+ $form->{callback} =
+ "$form->{script}?action=add_tax&login=$form->{login}&password=$form->{password}"
+ unless $form->{callback};
+
+ _get_taxaccount_selection();
+
+ $form->header();
+
+ my $parameters_ref = {
+# ChartTypeIsAccount => $ChartTypeIsAccount,
+ };
+
+ # Ausgabe des Templates
+ print($form->parse_html_template2('am/edit_tax', $parameters_ref));
+
+ $lxdebug->leave_sub();
+}
+
+sub edit_tax {
+ $lxdebug->enter_sub();
+
+ $form->{title} = $locale->text('Edit');
+
+ AM->get_tax(\%myconfig, \%$form);
+ _get_taxaccount_selection();
+
+ $form->{rate} = $form->format_amount(\%myconfig, $form->{rate}, 2);
+
+ $form->header();
+
+ my $parameters_ref = {
+ };
+
+ # Ausgabe des Templates
+ print($form->parse_html_template2('am/edit_tax', $parameters_ref));
+
+ $lxdebug->leave_sub();
+}
+
+sub list_tax {
+ $lxdebug->enter_sub();
+
+ AM->taxes(\%myconfig, \%$form);
+
+ map { $_->{rate} = $form->format_amount(\%myconfig, $_->{rate}, 2) } @{ $form->{TAX} };
+
+ $form->{callback} = build_std_url('action=list_tax');
+
+ $form->{title} = $locale->text('Tax-O-Matic');
+
+ $form->header();
+
+ # Ausgabe des Templates
+ print($form->parse_html_template2('am/list_tax', $parameters_ref));
+
+ $lxdebug->leave_sub();
+}
+
+sub _get_taxaccount_selection{
+ $lxdebug->enter_sub();
+
+ AM->get_tax_accounts(\%myconfig, \%$form);
+
+ map { $_->{selected} = $form->{chart_id} == $_->{id} } @{ $form->{ACCOUNTS} };
+
+ $lxdebug->leave_sub();
+}
+
+sub save_tax {
+ $lxdebug->enter_sub();
+
+ $form->isblank("rate", $locale->text('Taxrate missing!'));
+ $form->isblank("taxdescription", $locale->text('Taxdescription missing!'));
+ $form->isblank("taxkey", $locale->text('Taxkey missing!'));
+
+ $form->{rate} = $form->parse_amount(\%myconfig, $form->{rate});
+
+ if ( $form->{rate} < 0 || $form->{rate} >= 100 ) {
+ $form->error($locale->text('Tax Percent is a number between 0 and 100'));
+ }
+
+ if ( $form->{rate} <= 0.99 && $form->{rate} > 0 ) {
+ $form->error($locale->text('Tax Percent is a number between 0 and 100'));
+ }
+
+ AM->save_tax(\%myconfig, \%$form);
+ $form->redirect($locale->text('Tax saved!'));
+
+ $lxdebug->leave_sub();
+}
+
+sub delete_tax {
+ $lxdebug->enter_sub();
+
+ AM->delete_tax(\%myconfig, \%$form);
+ $form->redirect($locale->text('Tax deleted!'));
+
+ $lxdebug->leave_sub();
+}
+
+sub add_price_factor {
+ $lxdebug->enter_sub();
+
+ $form->{title} = $locale->text('Add Price Factor');
+ $form->{callback} ||= build_std_url('action=add_price_factor');
+ $form->{fokus} = 'description';
+
+ $form->header();
+ print $form->parse_html_template2('am/edit_price_factor');
+
+ $lxdebug->leave_sub();
+}
+
+sub edit_price_factor {
+ $lxdebug->enter_sub();
+
+ $form->{title} = $locale->text('Edit Price Factor');
+ $form->{callback} ||= build_std_url('action=add_price_factor');
+ $form->{fokus} = 'description';
+
+ AM->get_price_factor(\%myconfig, $form);
+
+ $form->{factor} = $form->format_amount(\%myconfig, $form->{factor} * 1);
+
+ $form->header();
+ print $form->parse_html_template2('am/edit_price_factor');
+
+ $lxdebug->leave_sub();
+}
+
+sub list_price_factors {
+ $lxdebug->enter_sub();
+
+ AM->get_all_price_factors(\%myconfig, \%$form);
+
+ my $previous;
+ foreach my $current (@{ $form->{PRICE_FACTORS} }) {
+ if ($previous) {
+ $previous->{next_id} = $current->{id};
+ $current->{previous_id} = $previous->{id};
+ }
+
+ $current->{factor} = $form->format_amount(\%myconfig, $current->{factor} * 1);
+
+ $previous = $current;
+ }
+
+ $form->{callback} = build_std_url('action=list_price_factors');
+ $form->{title} = $locale->text('Price Factors');
+ $form->{url_base} = build_std_url('callback');
+
+ $form->header();
+ print $form->parse_html_template2('am/list_price_factors');
+
+ $lxdebug->leave_sub();
+}
+
+sub save_price_factor {
+ $lxdebug->enter_sub();
+
+ $form->isblank("description", $locale->text('Description missing!'));
+ $form->isblank("factor", $locale->text('Factor missing!'));
+
+ $form->{factor} = $form->parse_amount(\%myconfig, $form->{factor});
+
+ AM->save_price_factor(\%myconfig, $form);
+
+ $form->{callback} .= '&MESSAGE=' . $form->escape($locale->text('Price factor saved!')) if ($form->{callback});
+
+ $form->redirect($locale->text('Price factor saved!'));
+
+ $lxdebug->leave_sub();
+}
+
+sub delete_price_factor {
+ $lxdebug->enter_sub();
+
+ AM->delete_price_factor(\%myconfig, \%$form);
+
+ $form->{callback} .= '&MESSAGE=' . $form->escape($locale->text('Price factor deleted!')) if ($form->{callback});
+
+ $form->redirect($locale->text('Price factor deleted!'));
+
+ $lxdebug->leave_sub();
+}
+
+sub swap_price_factors {
+ $lxdebug->enter_sub();
+
+ AM->swap_sortkeys(\%myconfig, $form, 'price_factors');
+ list_price_factors();
+
+ $lxdebug->leave_sub();
+}
+