X-Git-Url: http://wagnertech.de/git?a=blobdiff_plain;ds=inline;f=bin%2Fmozilla%2Fam.pl;h=137243877fcc6116fde8c2ea67963011a5412d11;hb=6ebad56e58db857141565f397c555524cba43109;hp=044bfee8da7e655b48650e4109a702888e70de23;hpb=770515d92619f11ebeb359b871d93d40c0d1af56;p=kivitendo-erp.git diff --git a/bin/mozilla/am.pl b/bin/mozilla/am.pl index 044bfee8d..137243877 100644 --- a/bin/mozilla/am.pl +++ b/bin/mozilla/am.pl @@ -36,6 +36,7 @@ use SL::CA; use SL::Form; use SL::User; use SL::USTVA; +use SL::Iconv; use CGI::Ajax; use CGI; @@ -160,7 +161,7 @@ sub account_header { if ($item eq ''){ $form->{ACCOUNT_TAXKEYS}[$i]{select_tax} .= qq|-\n|; } - elsif ( $item == $taxkey_used->{pos_ustva} ) { + elsif ( $item eq $taxkey_used->{pos_ustva} ) { $form->{ACCOUNT_TAXKEYS}[$i]{select_tax} .= qq|$item\n|; } else { @@ -223,10 +224,11 @@ sub account_header { 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||. sprintf("%.2d", $item) .qq|. $eur{$item}\n|; + $select_eur .= qq||. sprintf("%.2d", $item) .qq|. $text\n|; } else { - $select_eur .= qq||. sprintf("%.2d", $item) .qq|. $eur{$item}\n|; + $select_eur .= qq||. sprintf("%.2d", $item) .qq|. $text\n|; } } @@ -256,10 +258,11 @@ sub account_header { 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||. sprintf("%.2d", $item) .qq|. $bwapos{$item}\n|; + $select_bwa .= qq||. sprintf("%.2d", $item) .qq|. $text\n|; } else { - $select_bwa .= qq||. sprintf("%.2d", $item) .qq|. $bwapos{$item}\n|; + $select_bwa .= qq||. sprintf("%.2d", $item) .qq|. $text\n|; } } @@ -410,40 +413,38 @@ sub list_account { 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; @@ -452,7 +453,7 @@ sub list_account { }; # 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(); @@ -471,7 +472,7 @@ sub list_account_details { # 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; @@ -1509,35 +1510,35 @@ sub list_buchungsgruppe { . qq||; $column_header{income_accno_0} = qq|| - . $locale->text('Erlöse Inland') + . $locale->text('National Revenues') . qq||; $column_header{expense_accno_0} = qq|| - . $locale->text('Aufwand Inland') + . $locale->text('National Expenses') . qq||; $column_header{income_accno_1} = qq|| - . $locale->text('Erlöse EU m. UStId') + . $locale->text('Revenues EU with UStId') . qq||; $column_header{expense_accno_1} = qq|| - . $locale->text('Aufwand EU m. UStId') + . $locale->text('Expenses EU with UStId') . qq||; $column_header{income_accno_2} = qq|| - . $locale->text('Erlöse EU o. UStId') + . $locale->text('Revenues EU without UStId') . qq||; $column_header{expense_accno_2} = qq|| - . $locale->text('Aufwand EU o. UStId') + . $locale->text('Expenses EU without UStId') . qq||; $column_header{income_accno_3} = qq|| - . $locale->text('Erlöse Ausland') + . $locale->text('Foreign Revenues') . qq||; $column_header{expense_accno_3} = qq|| - . $locale->text('Aufwand Ausland') + . $locale->text('Foreign Expenses') . qq||; $form->header; @@ -1658,8 +1659,8 @@ sub buchungsgruppe_header { $form->{title} = $locale->text("$form->{title} Buchungsgruppe"); - # $locale->text('Buchungsgruppe hinzufügen') - # $locale->text('Buchungsgruppe bearbeiten') + # $locale->text('Add Accounting Group') + # $locale->text('Edit Accounting Group') my ($acc_inventory, $acc_income, $acc_expense) = ({}, {}, {}); my %acc_type_map = ( @@ -1709,11 +1710,11 @@ sub buchungsgruppe_header { $linkaccounts .= qq| - | . $locale->text('Erlöse Inland') . qq| + | . $locale->text('National Revenues') . qq| $form->{selectIC_income} - | . $locale->text('Aufwand Inland') . qq| + | . $locale->text('National Expenses') . qq| $form->{selectIC_expense} |; if ($form->{id}) { @@ -1723,11 +1724,11 @@ sub buchungsgruppe_header { $form->{selectIC_expense} =~ s/ value=$form->{expense_accno_id_1}/ value=$form->{expense_accno_id_1} selected/; } $linkaccounts .= qq| - | . $locale->text('Erlöse EU m. UStId') . qq| + | . $locale->text('Revenues EU with UStId') . qq| $form->{selectIC_income} - | . $locale->text('Aufwand EU m UStId') . qq| + | . $locale->text('Expenses EU with UStId') . qq| $form->{selectIC_expense} |; @@ -1739,11 +1740,11 @@ sub buchungsgruppe_header { } $linkaccounts .= qq| - | . $locale->text('Erlöse EU o. UStId') . qq| + | . $locale->text('Revenues EU without UStId') . qq| $form->{selectIC_income} - | . $locale->text('Aufwand EU o. UStId') . qq| + | . $locale->text('Expenses EU without UStId') . qq| $form->{selectIC_expense} |; @@ -1755,11 +1756,11 @@ sub buchungsgruppe_header { } $linkaccounts .= qq| - | . $locale->text('Erlöse Ausland') . qq| + | . $locale->text('Foreign Revenues') . qq| $form->{selectIC_income} - | . $locale->text('Aufwand Ausland') . qq| + | . $locale->text('Foreign Expenses') . qq| $form->{selectIC_expense} |; @@ -1799,7 +1800,7 @@ sub save_buchungsgruppe { $form->isblank("description", $locale->text('Description missing!')); AM->save_buchungsgruppe(\%myconfig, \%$form); - $form->redirect($locale->text('Buchungsgruppe gespeichert!')); + $form->redirect($locale->text('Accounting Group saved!')); $lxdebug->leave_sub(); } @@ -1808,7 +1809,7 @@ sub delete_buchungsgruppe { $lxdebug->enter_sub(); AM->delete_buchungsgruppe(\%myconfig, \%$form); - $form->redirect($locale->text('Buchungsgruppe gelöscht!')); + $form->redirect($locale->text('Accounting Group deleted!')); $lxdebug->leave_sub(); } @@ -2298,8 +2299,12 @@ sub payment_header { | . $locale->text("<%skonto_amount%> -- The deductible amount") . qq| | . $locale->text("<%total%> -- Amount payable") +. qq| + | . $locale->text("<%total_wo_skonto%> -- Amount payable less discount") . qq| | . $locale->text("<%invtotal%> -- Invoice total") +. qq| + | . $locale->text("<%invtotal_wo_skonto%> -- Invoice total less discount") . qq| | . $locale->text("<%currency%> -- The selected currency") . qq| @@ -3058,7 +3063,6 @@ sub show_am_history { $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 "") @@ -3068,39 +3072,48 @@ sub show_am_history { : "" ) ); - + $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 { @@ -3126,3 +3139,204 @@ sub swap_units { $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(); +} +