X-Git-Url: http://wagnertech.de/git?a=blobdiff_plain;f=bin%2Fmozilla%2Fam.pl;h=38eedb0c259cd50630bf510ddf9f29a70eaaf248;hb=8cef58b276ce4005c0e2ada350fecd5d7a103e89;hp=09d2007a23cd5608f9da1994edd286eaf5646a95;hpb=ef5a164cac92ef3398b328893163958eb6720e10;p=kivitendo-erp.git diff --git a/bin/mozilla/am.pl b/bin/mozilla/am.pl index 09d2007a2..38eedb0c2 100644 --- a/bin/mozilla/am.pl +++ b/bin/mozilla/am.pl @@ -40,16 +40,15 @@ use Data::Dumper; 1; - - require "$form->{path}/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(); @@ -96,13 +95,16 @@ sub account_header { $form->{description} =~ s/\"/"/g; if (@{ $form->{TAXKEY} }) { - foreach $item (@{ $form->{TAXKEY} }) { + foreach my $item (@{ $form->{TAXKEY} }) { + + $item->{rate} = $item->{rate} * 100 . '%'; + if ($item->{tax} == $form->{tax}) { $form->{selecttaxkey} .= - ""; + } - $form->{orphaned} = 1; - &form_footer; + if (!$myconfig{"default_media"}) { + $myconfig{"default_media"} = "screen"; + } + my %selected = ($myconfig{"default_media"} => "selected"); + my $default_media = qq| + + + +|; - $lxdebug->leave_sub(); -} - -sub list_sic { - $lxdebug->enter_sub(); - - AM->sic(\%myconfig, \%$form); - - $form->{callback} = - "$form->{script}?action=list_sic&path=$form->{path}&login=$form->{login}&password=$form->{password}"; - - $callback = $form->escape($form->{callback}); - - $form->{title} = $locale->text('Standard Industrial Codes'); - - @column_index = qw(code description); - - $column_header{code} = - qq|| . $locale->text('Code') . qq||; - $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; - - if ($ref->{sictype} eq 'H') { - print qq| - -|; - $column_data{code} = - qq||; - $column_data{description} = qq||; - - } else { - print qq| - -|; - - $column_data{code} = - qq||; - $column_data{description} = qq||; - - } - - map { print "$column_data{$_}\n" } @column_index; - - print qq| - -|; - } - - print qq| -
{script}?action=edit_sic&code=$ref->{code}&path=$form->{path}&login=$form->{login}&password=$form->{password}&callback=$callback>$ref->{code}$ref->{description}
{script}?action=edit_sic&code=$ref->{code}&path=$form->{path}&login=$form->{login}&password=$form->{password}&callback=$callback>$ref->{code}$ref->{description}
-

- -
-
{script}> - - - - - -{path}> -{login}> -{password}> - - - -
- - - -|; - - $lxdebug->leave_sub(); -} - -sub sic_header { - $lxdebug->enter_sub(); - - $form->{title} = $locale->text("$form->{title} SIC"); - - # $locale->text('Add SIC') - # $locale->text('Edit SIC') - - $form->{code} =~ s/\"/"/g; - $form->{description} =~ s/\"/"/g; - - $checked = ($form->{sictype} eq 'H') ? "checked" : ""; - - $form->header; - - print qq| - - -
{script}> - - -{code}> - - - - - - - - - - - - - - - - - - - - -
$form->{title}
| . $locale->text('Code') . qq|{code}>
| - . $locale->text('Heading') . qq|
| . $locale->text('Description') . qq|

-|; - - $lxdebug->leave_sub(); -} - -sub save_sic { - $lxdebug->enter_sub(); - - $form->isblank("code", $locale->text('Code missing!')); - $form->isblank("description", $locale->text('Description missing!')); - AM->save_sic(\%myconfig, \%$form); - $form->redirect($locale->text('SIC saved!')); - - $lxdebug->leave_sub(); -} - -sub delete_sic { - $lxdebug->enter_sub(); - - AM->delete_sic(\%myconfig, \%$form); - $form->redirect($locale->text('SIC deleted!')); - - $lxdebug->leave_sub(); -} - -sub display_stylesheet { - $lxdebug->enter_sub(); - - $form->{file} = "css/$myconfig{stylesheet}"; - &display_form; - - $lxdebug->leave_sub(); -} - -sub display_form { - $lxdebug->enter_sub(); - - $form->{file} =~ s/^(.:)*?\/|\.\.\///g; - $form->{file} =~ s/^\/*//g; - $form->{file} =~ s/$userspath//; - - $form->error("$!: $form->{file}") unless -f $form->{file}; - - AM->load_template(\%$form); - - $form->{title} = $form->{file}; - - # if it is anything but html - if ($form->{file} !~ /\.html$/) { - $form->{body} = "
\n$form->{body}\n
"; - } - - $form->header; - - print qq| - - -$form->{body} - -{script}> - -{file}> - - -{path}> -{login}> -{password}> - - - -
- - - -|; - - $lxdebug->leave_sub(); -} - -sub edit_template { - $lxdebug->enter_sub(); - - AM->load_template(\%$form); - - $form->{title} = $locale->text('Edit Template'); - - # convert   to   - $form->{body} =~ s/ / /gi; - - $form->header; - - print qq| - - -
{script}> - -{file}> - - -{path}> -{login}> -{password}> - - - - - -
- - -
- - - - -|; - - $lxdebug->leave_sub(); -} - -sub save_template { - $lxdebug->enter_sub(); - - AM->save_template(\%$form); - $form->redirect($locale->text('Template saved!')); - - $lxdebug->leave_sub(); -} - -sub config { - $lxdebug->enter_sub(); - - # get defaults for account numbers and last numbers - AM->defaultaccounts(\%myconfig, \%$form); - - foreach $item (qw(mm-dd-yy mm/dd/yy dd-mm-yy dd/mm/yy dd.mm.yy yyyy-mm-dd)) { - $dateformat .= - ($item eq $myconfig{dateformat}) - ? ""; - } - - 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 = ''; @@ -3053,9 +2512,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}) { @@ -3357,26 +2820,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(); @@ -3463,199 +2906,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(); @@ -3665,15 +2915,11 @@ sub edit_units { @languages = AM->language(\%myconfig, $form, 1); - @unit_list = (); - foreach $name (sort({ lc($a) cmp lc($b) } grep({ !$units->{$_}->{"base_unit"} } keys(%{$units})))) { - map({ push(@unit_list, $units->{$_}); } - sort({ ($units->{$a}->{"resolved_factor"} * 1) <=> ($units->{$b}->{"resolved_factor"} * 1) } - grep({ $units->{$_}->{"resolved_base_unit"} eq $name } keys(%{$units})))); - } + @unit_list = sort({ $a->{"sortkey"} <=> $b->{"sortkey"} } values(%{$units})); + my $i = 1; foreach (@unit_list) { - $_->{"factor"} = $form->format_amount(\%myconfig, $_->{"factor"}, 5) if ($_->{"factor"}); + $_->{"factor"} = $form->format_amount(\%myconfig, $_->{"factor"} * 1) if ($_->{"factor"}); $_->{"UNITLANGUAGES"} = []; foreach my $lang (@languages) { push(@{ $_->{"UNITLANGUAGES"} }, @@ -3690,12 +2936,15 @@ sub edit_units { $units = AM->retrieve_units(\%myconfig, $form, $form->{"unit_type"}); $ddbox = AM->unit_select_data($units, undef, 1); + my $updownlink = build_std_url("action=swap_units", "unit_type"); + $form->{"title"} = sprintf($locale->text("Add and edit %s"), $form->{"unit_type"} eq "dimension" ? $locale->text("dimension units") : $locale->text("service units")); $form->header(); print($form->parse_html_template("am/edit_units", { "UNITS" => \@unit_list, "NEW_BASE_UNIT_DDBOX" => $ddbox, - "LANGUAGES" => \@languages })); + "LANGUAGES" => \@languages, + "updownlink" => $updownlink })); $lxdebug->leave_sub(); } @@ -3831,3 +3080,113 @@ 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" + ); + my %searchNo = ( "Artikelnummer" => "partnumber", + "Kundennummer" => "customernumber", + "Lieferantennummer" => "vendornumber", + "Projektnummer" => "projectnummer", + "Buchungsnummer" => "ordnumber", + "Eingangsrechnungnummer" => "invnumber", + "Ausgangsrechnungnummer" => "invnumber" + ); + + 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(); + + my $dir = $form->{"dir"} eq "down" ? "down" : "up"; + my $unit_type = $form->{"unit_type"} eq "dimension" ? + "dimension" : "service"; + AM->swap_units(\%myconfig, $form, $dir, $form->{"name"}, $unit_type); + + edit_units(); + + $lxdebug->leave_sub(); +}