X-Git-Url: http://wagnertech.de/git?a=blobdiff_plain;f=bin%2Fmozilla%2Fam.pl;h=77d8878ffdb1e7390b41a6e548830a8468eabded;hb=991315859c7b0f25da49baad4822492510b6b3bb;hp=d25eb7e308977f6f49a232dfe6d1d4a4949a39af;hpb=9a795b8553bd43a379646bc6244c618e570556e9;p=kivitendo-erp.git diff --git a/bin/mozilla/am.pl b/bin/mozilla/am.pl index d25eb7e30..77d8878ff 100644 --- a/bin/mozilla/am.pl +++ b/bin/mozilla/am.pl @@ -35,21 +35,24 @@ use SL::AM; use SL::CA; use SL::Form; use SL::User; +use SL::USTVA; +use SL::Iconv; +use CGI::Ajax; +use CGI; use Data::Dumper; 1; - - -require "$form->{path}/common.pl"; +require "bin/mozilla/common.pl"; # end of main -sub add { &{"add_$form->{type}"} } -sub edit { &{"edit_$form->{type}"} } -sub save { &{"save_$form->{type}"} } -sub delete { &{"delete_$form->{type}"} } +sub add { call_sub("add_$form->{type}"); } +sub delete { call_sub("delete_$form->{type}"); } +sub save { call_sub("save_$form->{type}"); } +sub edit { call_sub("edit_$form->{type}"); } +sub continue { call_sub($form->{"nextsub"}); } sub add_account { $lxdebug->enter_sub(); @@ -59,7 +62,7 @@ sub add_account { AM->get_account(\%myconfig, \%$form); $form->{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}" unless $form->{callback}; &account_header; @@ -87,131 +90,108 @@ sub edit_account { sub account_header { $lxdebug->enter_sub(); + if ( $form->{action} eq 'edit_account') { + $form->{account_exists} = '1'; + } + $form->{title} = $locale->text("$form->{title} Account"); - $checked{ $form->{charttype} } = "checked"; - $checked{"$form->{category}_"} = "checked"; - $checked{CT_tax} = ($form->{CT_tax}) ? "" : "checked"; + $form->{"$form->{charttype}_checked"} = "checked"; + $form->{"$form->{category}_checked"} = "checked"; - $form->{description} =~ s/\"/"/g; + $form->{select_tax} = ""; + + my @tax_report_pos = USTVA->report_variables({ + myconfig => \%myconfig, + form => $form, + type => '', + attribute => 'position', + calc => '', + }); if (@{ $form->{TAXKEY} }) { - foreach $item (@{ $form->{TAXKEY} }) { - if ($item->{tax} == $form->{tax}) { - $form->{selecttaxkey} .= - ""; + $form->{selectnewaccount} = qq||; } foreach $item (@{ $form->{NEWACCOUNT} }) { if ($item->{id} == $form->{new_chart_id}) { $form->{selectnewaccount} .= - ""; + qq||; } elsif (!$form->{new_chart_valid}) { $form->{selectnewaccount} .= - ""; + qq||; } } } - $newaccount = qq| - - - - - - - - - -
| . $locale->text('Folgekonto') . qq|| . $locale->text('Gültig ab') . qq|
- - |; - - $form->{selectustva} = "\n|; %eur = (1 => "Umsatzerlöse", 2 => "sonstige Erlöse", 3 => "Privatanteile", @@ -244,22 +224,16 @@ 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}) { - $form->{selecteur} .= "\n|; } else { - $form->{selecteur} .= "\n|; } } - $eur = qq| - - | . $locale->text('EUER') . qq| - - - |; - - $form->{selectbwa} = "\n|; %bwapos = (1 => 'Umsatzerlöse', 2 => 'Best.Verdg.FE/UE', @@ -284,194 +258,89 @@ 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}) { - $form->{selectbwa} .= "\n|; + foreach $item ((1, 2, 3, 4)) { + if ($item == $form->{pos_bilanz}) { + $select_bilanz .= qq|"; - } - - if (!$myconfig{"default_media"}) { - $myconfig{"default_media"} = "screen"; - } - my %selected = ($myconfig{"default_media"} => "selected"); - my $default_media = qq| - - - -|; - - %selected = (); - $selected{$myconfig{"default_printer_id"}} = "selected" - if ($myconfig{"default_printer_id"}); - my $default_printer = qq||; - AM->printer(\%myconfig, $form); - foreach my $printer (@{$form->{"ALL"}}) { - $default_printer .= qq||; - } + %selected = (); + $selected{$myconfig{"default_printer_id"}} = "selected" + if ($myconfig{"default_printer_id"}); + my $default_printer = qq||; + AM->printer(\%myconfig, $form); + foreach my $printer (@{$form->{"ALL"}}) { + $default_printer .= qq||; + } %countrycodes = User->country_codes; $countrycodes = ''; @@ -2828,9 +2451,13 @@ sub config { } } - opendir CSS, "css/."; - @all = grep /.*\.css$/, readdir CSS; - closedir CSS; +# opendir CSS, "css/."; +# @all = grep /.*\.css$/, readdir CSS; +# closedir CSS; + +# css dir has styles that are not intended as general layouts. +# reverting to hardcoded list + @all = qw(lx-office-erp.css Win2000.css); foreach $item (@all) { if ($item eq $myconfig{stylesheet}) { @@ -3101,7 +2728,6 @@ print qq| -{path}> {login}> {password}> @@ -3132,26 +2758,6 @@ sub save_preferences { $lxdebug->leave_sub(); } -sub backup { - $lxdebug->enter_sub(); - - if ($form->{media} eq 'email') { - $form->error($locale->text('No email address for') . " $myconfig{name}") - unless ($myconfig{email}); - - $form->{OUT} = "$sendmail"; - - } - - AM->backup(\%myconfig, \%$form, $userspath); - - if ($form->{media} eq 'email') { - $form->redirect($locale->text('Backup sent to') . qq| $myconfig{email}|); - } - - $lxdebug->leave_sub(); -} - sub audit_control { $lxdebug->enter_sub(); @@ -3172,7 +2778,6 @@ sub audit_control {
{script}> -{path}> {login}> {password}> @@ -3238,199 +2843,6 @@ sub doclose { $lxdebug->leave_sub(); } -sub add_warehouse { - $lxdebug->enter_sub(); - - $form->{title} = "Add"; - - $form->{callback} = - "$form->{script}?action=add_warehouse&path=$form->{path}&login=$form->{login}&password=$form->{password}" - unless $form->{callback}; - - &warehouse_header; - &form_footer; - - $lxdebug->leave_sub(); -} - -sub edit_warehouse { - $lxdebug->enter_sub(); - - $form->{title} = "Edit"; - - AM->get_warehouse(\%myconfig, \%$form); - - &warehouse_header; - &form_footer; - - $lxdebug->leave_sub(); -} - -sub list_warehouse { - $lxdebug->enter_sub(); - - AM->warehouses(\%myconfig, \%$form); - - $form->{callback} = - "$form->{script}?action=list_warehouse&path=$form->{path}&login=$form->{login}&password=$form->{password}"; - - $callback = $form->escape($form->{callback}); - - $form->{title} = $locale->text('Warehouses'); - - @column_index = qw(description); - - $column_header{description} = - qq|| - . $locale->text('Description') - . qq||; - - $form->header; - - print qq| - - - - - - - - - - - - - -
$form->{title}
- - -|; - - map { print "$column_header{$_}\n" } @column_index; - - print qq| - -|; - - foreach $ref (@{ $form->{ALL} }) { - - $i++; - $i %= 2; - - print qq| - -|; - - $column_data{description} = - qq||; - - map { print "$column_data{$_}\n" } @column_index; - - print qq| - -|; - } - - print qq| -
{script}?action=edit_warehouse&id=$ref->{id}&path=$form->{path}&login=$form->{login}&password=$form->{password}&callback=$callback>$ref->{description}
-

- -
-{script}> - - - - - -{path}> -{login}> -{password}> - - - -
- - - -|; - - $lxdebug->leave_sub(); -} - -sub warehouse_header { - $lxdebug->enter_sub(); - - $form->{title} = $locale->text("$form->{title} Warehouse"); - - # $locale->text('Add Warehouse') - # $locale->text('Edit Warehouse') - - $form->{description} =~ s/\"/"/g; - - if (($rows = $form->numtextrows($form->{description}, 60)) > 1) { - $description = - qq||; - } else { - $description = - qq||; - } - - $form->header; - - print qq| - - -
{script}> - -{id}> - - - - - - - - - - - - - - -
$form->{title}
| . $locale->text('Description') . qq|$description

-|; - - $lxdebug->leave_sub(); -} - -sub save_warehouse { - $lxdebug->enter_sub(); - - $form->isblank("description", $locale->text('Description missing!')); - AM->save_warehouse(\%myconfig, \%$form); - $form->redirect($locale->text('Warehouse saved!')); - - $lxdebug->leave_sub(); -} - -sub delete_warehouse { - $lxdebug->enter_sub(); - - AM->delete_warehouse(\%myconfig, \%$form); - $form->redirect($locale->text('Warehouse deleted!')); - - $lxdebug->leave_sub(); -} - -sub continue { - $lxdebug->enter_sub(); - - &{ $form->{nextsub} }; - - $lxdebug->leave_sub(); -} - sub edit_units { $lxdebug->enter_sub(); @@ -3606,6 +3018,105 @@ sub save_unit { $lxdebug->leave_sub(); } +sub show_history_search { + $lxdebug->enter_sub(); + + $form->{title} = $locale->text("History Search"); + $form->header(); + + print $form->parse_html_template("/common/search_history"); + + $lxdebug->leave_sub(); +} + +sub show_am_history { + $lxdebug->enter_sub(); + my %search = ( "Artikelnummer" => "parts", + "Kundennummer" => "customer", + "Lieferantennummer" => "vendor", + "Projektnummer" => "project", + "Buchungsnummer" => "oe", + "Eingangsrechnungnummer" => "ap", + "Ausgangsrechnungnummer" => "ar", + "Mahnungsnummer" => "dunning" + ); + my %searchNo = ( "Artikelnummer" => "partnumber", + "Kundennummer" => "customernumber", + "Lieferantennummer" => "vendornumber", + "Projektnummer" => "projectnummer", + "Buchungsnummer" => "ordnumber", + "Eingangsrechnungnummer" => "invnumber", + "Ausgangsrechnungnummer" => "invnumber", + "Mahnungsnummer" => "dunning_id" + ); + + my $restriction; + my $tempNo = 0; + foreach(split(/\,/, $form->{einschraenkungen})) { + if($tempNo == 0) { + $restriction .= " AND addition = '" . $_ . "'"; + $tempNo = 1; + } + else { + $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 "") + ? qq| AND st.itime::date >= '| . $form->{transdate} . qq|'| + : ($form->{transdate} eq "" && $form->{reqdate} ne "") + ? qq| AND st.itime::date <= '| . $form->{reqdate} . qq|'| + : "" + ) + ); + + 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 $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->header(); + my $daten = ""; + while(my $hash_ref = $sth->fetchrow_hashref()){ + $daten = $form->get_history($dbh,$hash_ref->{id},$restriction); + } + $dbh->disconnect(); + print $form->parse_html_template("/common/show_history", + {"DATEN" => $daten, + "SUCCESS" => ($daten != 0 ? 1 : 0), + "NONEWWINDOW" => 1 + }); + $lxdebug->leave_sub(); +} + +sub get_employee_id { + $lxdebug->enter_sub(); + my $query = qq|SELECT id FROM employee WHERE name = '| . $_[0] . qq|'|; + my $sth = $_[1]->prepare($query); + $sth->execute() || $form->dberror($query); + my $return = $sth->fetch(); + $sth->finish(); + return ${$return}[0]; + $lxdebug->leave_sub(); +} + sub swap_units { $lxdebug->enter_sub();