X-Git-Url: http://wagnertech.de/git?a=blobdiff_plain;f=bin%2Fmozilla%2Fam.pl;h=1aca213e0e624a962a5dd09e59a5e10edc61541a;hb=98ccfccb26e831dd0a12dcae229eabb33744ed8b;hp=48ed1cd30e16437a71cd211b71c50f8532e30b0c;hpb=c1bf4079c7a2bc8ce7883e39838c88912d58301b;p=kivitendo-erp.git diff --git a/bin/mozilla/am.pl b/bin/mozilla/am.pl index 48ed1cd30..1aca213e0 100644 --- a/bin/mozilla/am.pl +++ b/bin/mozilla/am.pl @@ -31,43 +31,62 @@ # #====================================================================== +use utf8; + +use SL::Auth; +use SL::Auth::PasswordPolicy; use SL::AM; use SL::CA; use SL::Form; use SL::User; +use SL::USTVA; +use SL::Iconv; +use SL::TODO; +use SL::Printer; +use CGI; -use Data::Dumper; +require "bin/mozilla/common.pl"; -1; +use strict; -require "$form->{path}/common.pl"; +1; # 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_$main::form->{type}"); } +sub delete { call_sub("delete_$main::form->{type}"); } +sub save { call_sub("save_$main::form->{type}"); } +sub edit { call_sub("edit_$main::form->{type}"); } +sub continue { call_sub($main::form->{"nextsub"}); } +sub save_as_new { call_sub("save_as_new_$main::form->{type}"); } sub add_account { - $lxdebug->enter_sub(); + $main::lxdebug->enter_sub(); + + my $form = $main::form; + my %myconfig = %main::myconfig; + + $main::auth->assert('config'); $form->{title} = "Add"; $form->{charttype} = "A"; AM->get_account(\%myconfig, \%$form); - $form->{callback} = - "$form->{script}?action=list_account&path=$form->{path}&login=$form->{login}&password=$form->{password}" - unless $form->{callback}; + $form->{callback} = "am.pl?action=list_account" unless $form->{callback}; &account_header; &form_footer; - $lxdebug->leave_sub(); + $main::lxdebug->leave_sub(); } sub edit_account { - $lxdebug->enter_sub(); + $main::lxdebug->enter_sub(); + + my $form = $main::form; + my %myconfig = %main::myconfig; + + $main::auth->assert('config'); $form->{title} = "Edit"; AM->get_account(\%myconfig, \%$form); @@ -79,156 +98,144 @@ sub edit_account { &account_header; &form_footer; - $lxdebug->leave_sub(); + $main::lxdebug->leave_sub(); } sub account_header { - $lxdebug->enter_sub(); + $main::lxdebug->enter_sub(); + + my $form = $main::form; + my %myconfig = %main::myconfig; + my $locale = $main::locale; + + $main::auth->assert('config'); + + 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->{select_tax} = ""; - $form->{description} =~ s/\"/"/g; + 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} }) { + foreach my $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|; + my %eur = ( + 1 => "Umsatzerlöse", + 2 => "sonstige Erlöse", 3 => "Privatanteile", - 4 => "Zinserträge", - 5 => "Ausserordentliche Erträge", + 4 => "Zinserträge", + 5 => "Ausserordentliche Erträge", 6 => "Vereinnahmte Umsatzst.", 7 => "Umsatzsteuererstattungen", - 8 => "Wareneingänge", - 9 => "Löhne und Gehälter", + 8 => "Wareneingänge", + 9 => "Löhne und Gehälter", 10 => "Gesetzl. sozialer Aufw.", 11 => "Mieten", 12 => "Gas, Strom, Wasser", 13 => "Instandhaltung", - 14 => "Steuern, Versich., Beiträge", + 14 => "Steuern, Versich., Beiträge", 15 => "Kfz-Steuern", 16 => "Kfz-Versicherungen", - 17 => "Sonst. Fahrtkosten", + 17 => "Sonst. Fahrzeugkosten", 18 => "Werbe- und Reisekosten", 19 => "Instandhaltung u. Werkzeuge", - 20 => "Fachzeitschriften, Bücher", - 21 => "Miete für Einrichtungen", + 20 => "Fachzeitschriften, Bücher", + 21 => "Miete für Einrichtungen", 22 => "Rechts- und Beratungskosten", - 23 => "Bürobedarf, Porto, Telefon", + 23 => "Bürobedarf, Porto, Telefon", 24 => "Sonstige Aufwendungen", 25 => "Abschreibungen auf Anlagever.", 26 => "Abschreibungen auf GWG", @@ -237,337 +244,261 @@ sub account_header { 29 => "Zinsaufwand", 30 => "Ausserordentlicher Aufwand", 31 => "Betriebliche Steuern"); - foreach $item (sort({ $a <=> $b } keys(%eur))) { + foreach my $item (sort({ $a <=> $b } keys(%eur))) { + my $text = H($::locale->{iconv_utf8}->convert($eur{$item})); if ($item == $form->{pos_eur}) { - $form->{selecteur} .= "\n|; } else { - $form->{selecteur} .= "\n|; } } - $eur = qq| - - | . $locale->text('EUER') . qq| - - - |; + my $select_bwa = q|\n|; - $form->{selectbwa} = "\n|; + foreach my $item ((1, 2, 3, 4)) { + if ($item == $form->{pos_bilanz}) { + $select_bilanz .= qq|\n|; + + my %category = ( + 'A' => $locale->text('Asset'), + 'L' => $locale->text('Liability'), + 'Q' => $locale->text('Equity'), + 'I' => $locale->text('Revenue'), + 'E' => $locale->text('Expense'), + 'C' => $locale->text('Costs'), + ); + foreach my $item ( sort({ $a <=> $b } keys %category) ) { + if ($item eq $form->{category}) { + $select_category .= qq||; - foreach $item (qw(1,000.00 1000.00 1.000,00 1000,00)) { - $numberformat .= - ($item eq $form->{output_numberformat}) - ? ""; - } + my $form = $main::form; + my %myconfig = %main::myconfig; + my $locale = $main::locale; - my $dateformat = - qq||; - foreach $item (qw(mm-dd-yy mm/dd/yy dd-mm-yy dd/mm/yy dd.mm.yy yyyy-mm-dd)) { - $dateformat .= - ($item eq $form->{output_dateformat}) - ? ""; - } + $main::auth->assert('config'); - print qq| - - -
{script}> - -{id}> - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
$form->{title}
| . $locale->text('Language') . qq|
| . $locale->text('Template Code') . qq|
| . $locale->text('Article Code') . qq|
| . $locale->text('Number Format') . qq|
| . $locale->text('Date Format') . qq|
| . $locale->text('Long Dates') . qq|{output_longdates} ? " checked" : "") . - qq|>| . $locale->text("Yes") . - qq|{output_longdates} ? "" : " checked") . - qq|>| . $locale->text("No") . - qq|

-|; - - $lxdebug->leave_sub(); -} + $form->{title} = $locale->text('Edit'); -sub save_language { - $lxdebug->enter_sub(); + AM->get_tax(\%myconfig, \%$form); + _get_taxaccount_selection(); - $form->isblank("description", $locale->text('Language missing!')); - $form->isblank("template_code", $locale->text('Template Code missing!')); - $form->isblank("article_code", $locale->text('Article Code missing!')); - AM->save_language(\%myconfig, \%$form); - $form->redirect($locale->text('Language saved!')); + $form->{rate} = $form->format_amount(\%myconfig, $form->{rate}, 2); - $lxdebug->leave_sub(); -} + $form->header(); -sub delete_language { - $lxdebug->enter_sub(); + my $parameters_ref = { + }; - AM->delete_language(\%myconfig, \%$form); - $form->redirect($locale->text('Language deleted!')); + # Ausgabe des Templates + print($form->parse_html_template('am/edit_tax', $parameters_ref)); - $lxdebug->leave_sub(); + $main::lxdebug->leave_sub(); } +sub list_tax { + $main::lxdebug->enter_sub(); -sub add_buchungsgruppe { - $lxdebug->enter_sub(); + my $form = $main::form; + my %myconfig = %main::myconfig; + my $locale = $main::locale; - # $locale->text("Add Buchungsgruppe") - # $locale->text("Edit Buchungsgruppe") - $form->{title} = "Add"; + $main::auth->assert('config'); - $form->{callback} = - "$form->{script}?action=add_buchungsgruppe&path=$form->{path}&login=$form->{login}&password=$form->{password}" - unless $form->{callback}; - AM->get_buchungsgruppe(\%myconfig, \%$form); - $form->{"inventory_accno_id"} = $form->{"std_inventory_accno_id"}; - for (my $i = 0; 4 > $i; $i++) { - map({ $form->{"${_}_accno_id_$i"} = $form->{"std_${_}_accno_id"}; } - qw(income expense)); - } + AM->taxes(\%myconfig, \%$form); - &buchungsgruppe_header; - &form_footer; + 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(); + + my $parameters_ref = { + }; + + # Ausgabe des Templates + print($form->parse_html_template('am/list_tax', $parameters_ref)); - $lxdebug->leave_sub(); + $main::lxdebug->leave_sub(); } -sub edit_buchungsgruppe { - $lxdebug->enter_sub(); +sub _get_taxaccount_selection{ + $main::lxdebug->enter_sub(); - $form->{title} = "Edit"; + my $form = $main::form; + my %myconfig = %main::myconfig; - AM->get_buchungsgruppe(\%myconfig, \%$form); + $main::auth->assert('config'); - &buchungsgruppe_header; + AM->get_tax_accounts(\%myconfig, \%$form); - &form_footer; + map { $_->{selected} = $form->{chart_id} == $_->{id} } @{ $form->{ACCOUNTS} }; - $lxdebug->leave_sub(); + $main::lxdebug->leave_sub(); } -sub list_buchungsgruppe { - $lxdebug->enter_sub(); - - AM->buchungsgruppe(\%myconfig, \%$form); - - $form->{callback} = - "$form->{script}?action=list_buchungsgruppe&path=$form->{path}&login=$form->{login}&password=$form->{password}"; - - $callback = $form->escape($form->{callback}); - - $form->{title} = $locale->text('Buchungsgruppen'); - - @column_index = qw(description inventory_accno income_accno_0 expense_accno_0 income_accno_1 expense_accno_1 income_accno_2 expense_accno_2 income_accno_3 expense_accno_3 ); - - $column_header{description} = - qq|| - . $locale->text('Description') - . qq||; - $column_header{inventory_accno} = - qq|| - . $locale->text('Bestandskonto') - . qq||; - $column_header{income_accno_0} = - qq|| - . $locale->text('Erlöse Inland') - . qq||; - $column_header{expense_accno_0} = - qq|| - . $locale->text('Aufwand Inland') - . qq||; - $column_header{income_accno_1} = - qq|| - . $locale->text('Erlöse EU m. UStId') - . qq||; - $column_header{expense_accno_1} = - qq|| - . $locale->text('Aufwand EU m. UStId') - . qq||; - $column_header{income_accno_2} = - qq|| - . $locale->text('Erlöse EU o. UStId') - . qq||; - $column_header{expense_accno_2} = - qq|| - . $locale->text('Aufwand EU o. UStId') - . qq||; - $column_header{income_accno_3} = - qq|| - . $locale->text('Erlöse Ausland') - . qq||; - $column_header{expense_accno_3} = - qq|| - . $locale->text('Aufwand Ausland') - . qq||; - $form->header; +sub save_tax { + $main::lxdebug->enter_sub(); - print qq| - + my $form = $main::form; + my %myconfig = %main::myconfig; + my $locale = $main::locale; - - - - - - - - - - - -
$form->{title}
- - -|; + $main::auth->assert('config'); - map { print "$column_header{$_}\n" } @column_index; + $form->isblank("rate", $locale->text('Taxrate missing!')); + $form->isblank("taxdescription", $locale->text('Taxdescription missing!')); + $form->isblank("taxkey", $locale->text('Taxkey missing!')); - print qq| - -|; + $form->{rate} = $form->parse_amount(\%myconfig, $form->{rate}); - foreach $ref (@{ $form->{ALL} }) { + if ( $form->{rate} < 0 || $form->{rate} >= 100 ) { + $form->error($locale->text('Tax Percent is a number between 0 and 100')); + } - $i++; - $i %= 2; - - print qq| - -|; - - - $column_data{description} = - qq||; - $column_data{inventory_accno} = qq||; - $column_data{income_accno_0} = - qq||; - $column_data{expense_accno_0} = qq||; - $column_data{income_accno_1} = - qq||; - $column_data{expense_accno_1} = qq||; - $column_data{income_accno_2} = - qq||; - $column_data{expense_accno_2} = qq||; - $column_data{income_accno_3} = - qq||; - $column_data{expense_accno_3} = qq||; - - map { print "$column_data{$_}\n" } @column_index; - - print qq| - -|; + if ( $form->{rate} <= 0.99 && $form->{rate} > 0 ) { + $form->error($locale->text('Tax Percent is a number between 0 and 100')); } - print qq| -
{script}?action=edit_buchungsgruppe&id=$ref->{id}&path=$form->{path}&login=$form->{login}&password=$form->{password}&callback=$callback>$ref->{description}$ref->{inventory_accno}$ref->{income_accno_0}$ref->{expense_accno_0}$ref->{income_accno_1}$ref->{expense_accno_1}$ref->{income_accno_2}$ref->{expense_accno_2}$ref->{income_accno_3}$ref->{expense_accno_3}
-

+ AM->save_tax(\%myconfig, \%$form); + $form->redirect($locale->text('Tax saved!')); -
-{script}> + $main::lxdebug->leave_sub(); +} - +sub delete_tax { + $main::lxdebug->enter_sub(); - + my $form = $main::form; + my %myconfig = %main::myconfig; + my $locale = $main::locale; -{path}> -{login}> -{password}> + $main::auth->assert('config'); -|; + AM->delete_tax(\%myconfig, \%$form); + $form->redirect($locale->text('Tax deleted!')); - if ($form->{menubar}) { - require "$form->{path}/menu.pl"; - &menubar; - } + $main::lxdebug->leave_sub(); +} - print qq| +sub add_price_factor { + $main::lxdebug->enter_sub(); -
+ my $form = $main::form; + my $locale = $main::locale; - - -|; + $main::auth->assert('config'); - $lxdebug->leave_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_template('am/edit_price_factor'); + + $main::lxdebug->leave_sub(); } -sub buchungsgruppe_header { - $lxdebug->enter_sub(); +sub edit_price_factor { + $main::lxdebug->enter_sub(); - $form->{title} = $locale->text("$form->{title} Buchungsgruppe"); + my $form = $main::form; + my %myconfig = %main::myconfig; + my $locale = $main::locale; - # $locale->text('Buchungsgruppe hinzufügen') - # $locale->text('Buchungsgruppe bearbeiten') + $main::auth->assert('config'); - my ($acc_inventory, $acc_income, $acc_expense) = ({}, {}, {}); - my %acc_type_map = ( - "IC" => $acc_inventory, - "IC_income" => $acc_income, - "IC_sale" => $acc_income, - "IC_expense" => $acc_expense, - "IC_cogs" => $acc_expense, - ); + $form->{title} = $locale->text('Edit Price Factor'); + $form->{callback} ||= build_std_url('action=add_price_factor'); + $form->{fokus} = 'description'; - foreach $key (keys(%acc_type_map)) { - foreach $ref (@{ $form->{IC_links}{$key} }) { - $acc_type_map{$key}->{$ref->{"id"}} = $ref; - } - } + AM->get_price_factor(\%myconfig, $form); - foreach my $type (qw(IC IC_income IC_expense)) { - $form->{"select$type"} = - join("", - map({ "" } - sort({ $a->{"accno"} cmp $b->{"accno"} } - values(%{$acc_type_map{$type}})))); - } + $form->{factor} = $form->format_amount(\%myconfig, $form->{factor} * 1); - if ($form->{id}) { - $form->{selectIC} =~ s/selected//g; - $form->{selectIC} =~ s/ value=$form->{inventory_accno_id}/ value=$form->{inventory_accno_id} selected/; - $form->{selectIC_income} =~ s/selected//g; - $form->{selectIC_income} =~ s/ value=$form->{income_accno_id_0}/ value=$form->{income_accno_id_0} selected/; - $form->{selectIC_expense} =~ s/selected//g; - $form->{selectIC_expense} =~ s/ value=$form->{expense_accno_id_0}/ value=$form->{expense_accno_id_0} selected/; - } + $form->header(); + print $form->parse_html_template('am/edit_price_factor'); - if (!$eur) { - $linkaccounts = qq| - - | . $locale->text('Inventory') . qq| - - - |; - } else { - $linkaccounts = qq| - {inventory_accno_id}>|; - } + $main::lxdebug->leave_sub(); +} +sub list_price_factors { + $main::lxdebug->enter_sub(); - $linkaccounts .= qq| - - | . $locale->text('Erlöse Inland') . qq| - - - - | . $locale->text('Aufwand Inland') . qq| - - |; - if ($form->{id}) { - $form->{selectIC_income} =~ s/selected//g; - $form->{selectIC_income} =~ s/ value=$form->{income_accno_id_1}/ value=$form->{income_accno_id_1} selected/; - $form->{selectIC_expense} =~ s/selected//g; - $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('Aufwand EU m UStId') . qq| - - |; - - if ($form->{id}) { - $form->{selectIC_income} =~ s/selected//g; - $form->{selectIC_income} =~ s/ value=$form->{income_accno_id_2}/ value=$form->{income_accno_id_2} selected/; - $form->{selectIC_expense} =~ s/selected//g; - $form->{selectIC_expense} =~ s/ value=$form->{expense_accno_id_2}/ value=$form->{expense_accno_id_2} selected/; - } + my $form = $main::form; + my %myconfig = %main::myconfig; + my $locale = $main::locale; - $linkaccounts .= qq| - | . $locale->text('Erlöse EU o. UStId') . qq| - - - - | . $locale->text('Aufwand EU o. UStId') . qq| - - |; - - if ($form->{id}) { - $form->{selectIC_income} =~ s/selected//g; - $form->{selectIC_income} =~ s/ value=$form->{income_accno_id_3}/ value=$form->{income_accno_id_3} selected/; - $form->{selectIC_expense} =~ s/selected//g; - $form->{selectIC_expense} =~ s/ value=$form->{expense_accno_id_3}/ value=$form->{expense_accno_id_3} selected/; - } + $main::auth->assert('config'); - $linkaccounts .= qq| - | . $locale->text('Erlöse Ausland') . qq| - - - - | . $locale->text('Aufwand Ausland') . qq| - - -|; + AM->get_all_price_factors(\%myconfig, \%$form); + foreach my $current (@{ $form->{PRICE_FACTORS} }) { + $current->{factor} = $form->format_amount(\%myconfig, $current->{factor} * 1); + } - $form->header; + $form->{callback} = build_std_url('action=list_price_factors'); + $form->{title} = $locale->text('Price Factors'); + $form->{url_base} = build_std_url('callback'); - print qq| - - -
{script}> - -{id}> - - - - - - - - - - - - $linkaccounts - - -
$form->{title}
| . $locale->text('Buchungsgruppe') . qq|

-|; - - $lxdebug->leave_sub(); + $form->header(); + print $form->parse_html_template('am/list_price_factors'); + + $main::lxdebug->leave_sub(); } -sub save_buchungsgruppe { - $lxdebug->enter_sub(); +sub save_price_factor { + $main::lxdebug->enter_sub(); + + my $form = $main::form; + my %myconfig = %main::myconfig; + my $locale = $main::locale; + + $main::auth->assert('config'); $form->isblank("description", $locale->text('Description missing!')); + $form->isblank("factor", $locale->text('Factor missing!')); - AM->save_buchungsgruppe(\%myconfig, \%$form); - $form->redirect($locale->text('Buchungsgruppe gespeichert!')); + $form->{factor} = $form->parse_amount(\%myconfig, $form->{factor}); - $lxdebug->leave_sub(); -} + AM->save_price_factor(\%myconfig, $form); -sub delete_buchungsgruppe { - $lxdebug->enter_sub(); + $form->{callback} .= '&MESSAGE=' . $form->escape($locale->text('Price factor saved!')) if ($form->{callback}); - AM->delete_buchungsgruppe(\%myconfig, \%$form); - $form->redirect($locale->text('Buchungsgruppe gelöscht!')); + $form->redirect($locale->text('Price factor saved!')); - $lxdebug->leave_sub(); + $main::lxdebug->leave_sub(); } +sub delete_price_factor { + $main::lxdebug->enter_sub(); -sub add_printer { - $lxdebug->enter_sub(); + my $form = $main::form; + my %myconfig = %main::myconfig; + my $locale = $main::locale; - $form->{title} = "Add"; + $main::auth->assert('config'); - $form->{callback} = - "$form->{script}?action=add_printer&path=$form->{path}&login=$form->{login}&password=$form->{password}" - unless $form->{callback}; + AM->delete_price_factor(\%myconfig, \%$form); - &printer_header; - &form_footer; + $form->{callback} .= '&MESSAGE=' . $form->escape($locale->text('Price factor deleted!')) if ($form->{callback}); + + $form->redirect($locale->text('Price factor deleted!')); - $lxdebug->leave_sub(); + $main::lxdebug->leave_sub(); } -sub edit_printer { - $lxdebug->enter_sub(); +sub add_warehouse { + $main::lxdebug->enter_sub(); - $form->{title} = "Edit"; + my $form = $main::form; + my $locale = $main::locale; - AM->get_printer(\%myconfig, \%$form); + $main::auth->assert('config'); - &printer_header; + $form->{title} = $locale->text('Add Warehouse'); + $form->{callback} ||= build_std_url('action=add_warehouse'); + $form->{fokus} = 'description'; - $form->{orphaned} = 1; - &form_footer; + $form->header(); + print $form->parse_html_template('am/edit_warehouse'); - $lxdebug->leave_sub(); + $main::lxdebug->leave_sub(); } -sub list_printer { - $lxdebug->enter_sub(); +sub edit_warehouse { + $main::lxdebug->enter_sub(); - AM->printer(\%myconfig, \%$form); + my $form = $main::form; + my %myconfig = %main::myconfig; + my $locale = $main::locale; - $form->{callback} = - "$form->{script}?action=list_printer&path=$form->{path}&login=$form->{login}&password=$form->{password}"; + $main::auth->assert('config'); - $callback = $form->escape($form->{callback}); + AM->get_warehouse(\%myconfig, $form); - $form->{title} = $locale->text('Printer'); + $form->get_lists('employees' => 'EMPLOYEES'); - @column_index = qw(printer_description printer_command template_code); + $form->{title} = $locale->text('Edit Warehouse'); + $form->{callback} ||= build_std_url('action=list_warehouses'); + $form->{fokus} = 'description'; - $column_header{printer_description} = - qq|| - . $locale->text('Printer Description') - . qq||; - $column_header{printer_command} = - qq|| - . $locale->text('Printer Command') - . qq||; - $column_header{template_code} = - qq|| - . $locale->text('Template Code') - . qq||; + $form->header(); + print $form->parse_html_template('am/edit_warehouse'); - $form->header; + $main::lxdebug->leave_sub(); +} - print qq| - +sub list_warehouses { + $main::lxdebug->enter_sub(); - - - - - - - - - - - -
$form->{title}
- - -|; + my $form = $main::form; + my %myconfig = %main::myconfig; + my $locale = $main::locale; - map { print "$column_header{$_}\n" } @column_index; + $main::auth->assert('config'); - print qq| - -|; + AM->get_all_warehouses(\%myconfig, $form); - foreach $ref (@{ $form->{ALL} }) { + $form->{callback} = build_std_url('action=list_warehouses'); + $form->{title} = $locale->text('Warehouses'); + $form->{url_base} = build_std_url('callback'); - $i++; - $i %= 2; + $form->header(); + print $form->parse_html_template('am/list_warehouses'); - print qq| - -|; + $main::lxdebug->leave_sub(); +} +sub save_warehouse { + $main::lxdebug->enter_sub(); - $column_data{printer_description} = - qq||; - $column_data{printer_command} = qq||; - $column_data{template_code} = - qq||; - - map { print "$column_data{$_}\n" } @column_index; - - print qq| - -|; - } - - print qq| -
{script}?action=edit_printer&id=$ref->{id}&path=$form->{path}&login=$form->{login}&password=$form->{password}&callback=$callback>$ref->{printer_description}$ref->{printer_command}$ref->{template_code}
-

- -
-{script}> - - - - - -{path}> -{login}> -{password}> - -|; - - if ($form->{menubar}) { - require "$form->{path}/menu.pl"; - &menubar; - } - - print qq| - -
- - - -|; - - $lxdebug->leave_sub(); -} - -sub printer_header { - $lxdebug->enter_sub(); - - $form->{title} = $locale->text("$form->{title} Printer"); - - # $locale->text('Add Printer') - # $locale->text('Edit Printer') - - $form->{printer_description} =~ s/\"/"/g; - $form->{template_code} =~ s/\"/"/g; - $form->{printer_command} =~ s/\"/"/g; - - - $form->header; - - print qq| - - -
{script}> - -{id}> - - - - - - - - - - - - - - - - - - - - - -
$form->{title}
| . $locale->text('Printer') . qq|
| . $locale->text('Printer Command') . qq|
| . $locale->text('Template Code') . qq|

-|; - - $lxdebug->leave_sub(); -} - -sub save_printer { - $lxdebug->enter_sub(); - - $form->isblank("printer_description", $locale->text('Description missing!')); - $form->isblank("printer_command", $locale->text('Printer Command missing!')); - AM->save_printer(\%myconfig, \%$form); - $form->redirect($locale->text('Printer saved!')); - - $lxdebug->leave_sub(); -} - -sub delete_printer { - $lxdebug->enter_sub(); - - AM->delete_printer(\%myconfig, \%$form); - $form->redirect($locale->text('Printer deleted!')); - - $lxdebug->leave_sub(); -} - - -sub add_payment { - $lxdebug->enter_sub(); - - $form->{title} = "Add"; - - $form->{callback} = - "$form->{script}?action=add_payment&path=$form->{path}&login=$form->{login}&password=$form->{password}" - unless $form->{callback}; - - $form->{terms_netto} = 0; - $form->{terms_skonto} = 0; - $form->{percent_skonto} = 0; - &payment_header; - &form_footer; - - $lxdebug->leave_sub(); -} - -sub edit_payment { - $lxdebug->enter_sub(); - - $form->{title} = "Edit"; - - AM->get_payment(\%myconfig, \%$form); - - &payment_header; - - $form->{orphaned} = 1; - &form_footer; - - $lxdebug->leave_sub(); -} - -sub list_payment { - $lxdebug->enter_sub(); - - AM->payment(\%myconfig, \%$form); - - $form->{callback} = - "$form->{script}?action=list_payment&path=$form->{path}&login=$form->{login}&password=$form->{password}"; - - $callback = $form->escape($form->{callback}); - - $form->{title} = $locale->text('Payment Terms'); - - @column_index = qw(description description_long terms_netto terms_skonto percent_skonto); - - $column_header{description} = - qq|| - . $locale->text('Description') - . qq||; - $column_header{description_long} = - qq|| - . $locale->text('Long Description') - . qq||; - $column_header{terms_netto} = - qq|| - . $locale->text('Netto Terms') - . qq||; - $column_header{terms_skonto} = - qq|| - . $locale->text('Skonto Terms') - . qq||; - $column_header{percent_skonto} = - qq|| - . $locale->text('Skonto') - . 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||; - $column_data{description_long} = qq||; - $column_data{terms_netto} = - qq||; - $column_data{terms_skonto} = - qq||; - $column_data{percent_skonto} = - qq||; - map { print "$column_data{$_}\n" } @column_index; - - print qq| - -|; - } - - print qq| -
{script}?action=edit_payment&id=$ref->{id}&path=$form->{path}&login=$form->{login}&password=$form->{password}&callback=$callback>$ref->{description}$ref->{description_long}$ref->{terms_netto}$ref->{terms_skonto}$ref->{percent_skonto} %
-

- -
-{script}> - - - - - -{path}> -{login}> -{password}> - -|; - - if ($form->{menubar}) { - require "$form->{path}/menu.pl"; - &menubar; - } - - print qq| - -
- - - -|; - - $lxdebug->leave_sub(); -} - -sub payment_header { - $lxdebug->enter_sub(); - - $form->{title} = $locale->text("$form->{title} Payment Terms"); - - # $locale->text('Add Payment Terms') - # $locale->text('Edit Payment Terms') - - $form->{description} =~ s/\"/"/g; - - - - $form->header; - - print qq| - - -
{script}> - -{id}> - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
$form->{title}
| . $locale->text('Description') . qq|
| . $locale->text('Long Description') . qq|
| . $locale->text('Netto Terms') . qq|
| . $locale->text('Skonto Terms') . qq|
| . $locale->text('Skonto') . qq| %

-|; - - $lxdebug->leave_sub(); -} - -sub save_payment { - $lxdebug->enter_sub(); - - $form->isblank("description", $locale->text('Language missing!')); - AM->save_payment(\%myconfig, \%$form); - $form->redirect($locale->text('Payment Terms saved!')); - - $lxdebug->leave_sub(); -} - -sub delete_payment { - $lxdebug->enter_sub(); - - AM->delete_payment(\%myconfig, \%$form); - $form->redirect($locale->text('Payment terms deleted!')); - - $lxdebug->leave_sub(); -} - -sub add_sic { - $lxdebug->enter_sub(); - - $form->{title} = "Add"; - - $form->{callback} = - "$form->{script}?action=add_sic&path=$form->{path}&login=$form->{login}&password=$form->{password}" - unless $form->{callback}; - - &sic_header; - &form_footer; - - $lxdebug->leave_sub(); -} - -sub edit_sic { - $lxdebug->enter_sub(); - - $form->{title} = "Edit"; - - AM->get_sic(\%myconfig, \%$form); - - &sic_header; - - $form->{orphaned} = 1; - &form_footer; - - $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}> - -|; - - if ($form->{menubar}) { - require "$form->{path}/menu.pl"; - &menubar; - } - - print qq| -
- - - -|; - - $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(); -} + my $form = $main::form; + my %myconfig = %main::myconfig; + my $locale = $main::locale; -sub save_sic { - $lxdebug->enter_sub(); + $main::auth->assert('config'); - $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}> - -|; - - if ($form->{menubar}) { - require "$form->{path}/menu.pl"; - &menubar; - } - - print qq| -
- - - -|; - - $lxdebug->leave_sub(); -} - -sub edit_template { - $lxdebug->enter_sub(); - - AM->load_template(\%$form); - - $form->{title} = $locale->text('Edit Template'); - - # convert   to &nbsp; - $form->{body} =~ s/ /&nbsp;/gi; - - $form->header; - - print qq| - - -
{script}> - -{file}> - - -{path}> -{login}> -{password}> - - - - - -
-|; - - if ($form->{menubar}) { - require "$form->{path}/menu.pl"; - &menubar; - } - - print q| -
- - - - -|; - - $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}) - ? ""; - } - - %countrycodes = User->country_codes; - $countrycodes = ''; - foreach $key (sort { $countrycodes{$a} cmp $countrycodes{$b} } - keys %countrycodes - ) { - $countrycodes .= - ($myconfig{countrycode} eq $key) - ? "