# end of main
sub add { &{"add_$form->{type}"} }
-sub edit { &{"edit_$form->{type}"} }
-sub save { &{"save_$form->{type}"} }
sub delete { &{"delete_$form->{type}"} }
+sub display {
+ if ($form->{display_nextsub}) {
+ &{ $form->{display_nextsub} }();
+ } else {
+ &{ $form->{nextsub} }();
+ }
+}
+
+sub save {
+ if ($form->{save_nextsub}) {
+ &{ $form->{save_nextsub} }();
+ } else {
+ &{ $form->{nextsub} }();
+ }
+}
+
+sub edit {
+ if ($form->{edit_nextsub}) {
+ &{ $form->{edit_nextsub} }();
+ } else {
+ &{ "edit_$form->{type}" }();
+ }
+}
+
sub add_account {
$lxdebug->enter_sub();
$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} .=
- "<option value=$item->{tax} selected>$item->{taxdescription}\n";
+ "<option value=$item->{tax} selected>$item->{taxdescription} ($item->{rate})\n";
} else {
$form->{selecttaxkey} .=
- "<option value=$item->{tax}>$item->{taxdescription}\n";
+ "<option value=$item->{tax}>$item->{taxdescription} ($item->{rate})\n";
}
}
<tr>
<th align=right>| . $locale->text('Steuersatz') . qq|</th>
<td><select name=tax>$form->{selecttaxkey}</select></td>
- <th align=right>| . $locale->text('Gültig ab') . qq|</th>
+ <th align=right>| . $locale->text('Gültig ab') . qq|</th>
<td><input name=startdate value="$form->{startdate}"></td>
</tr>|;
<tr>
<th align=right>| . $locale->text('Folgekonto') . qq|</th>
<td><select name=new_chart_id>$form->{selectnewaccount}</select></td>
- <th align=right>| . $locale->text('Gültig ab') . qq|</th>
+ <th align=right>| . $locale->text('Gültig ab') . qq|</th>
<td><input name=valid_from value="$form->{valid_from}"></td>
</tr>
</table>
</tr>|;
$form->{selecteur} = "<option>\n";
- %eur = (1 => "Umsatzerlöse",
- 2 => "sonstige Erlöse",
+ %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",
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",
$form->{selectbwa} = "<option>\n";
- %bwapos = (1 => 'Umsatzerlöse',
+ %bwapos = (1 => 'Umsatzerlöse',
2 => 'Best.Verdg.FE/UE',
3 => 'Aktiv.Eigenleistung',
4 => 'Mat./Wareneinkauf',
- 5 => 'So.betr.Erlöse',
+ 5 => 'So.betr.Erlöse',
10 => 'Personalkosten',
11 => 'Raumkosten',
12 => 'Betriebl.Steuern',
- 13 => 'Vers./Beiträge',
+ 13 => 'Vers./Beiträge',
14 => 'Kfz.Kosten o.St.',
15 => 'Werbe-Reisek.',
16 => 'Kosten Warenabgabe',
17 => 'Abschreibungen',
18 => 'Rep./instandhlt.',
- 19 => 'Übrige Steuern',
+ 19 => 'Übrige Steuern',
20 => 'Sonst.Kosten',
30 => 'Zinsauwand',
31 => 'Sonst.neutr.Aufw.',
- 32 => 'Zinserträge',
+ 32 => 'Zinserträge',
33 => 'Sonst.neutr.Ertrag',
34 => 'Verr.kalk.Kosten',
35 => 'Steuern Eink.u.Ertr.');
$discount =
$form->format_amount(\%myconfig, $ref->{discount} * 100);
$description =
- ($ref->{salesman})
- ? "<b>$ref->{description}</b>"
- : "$ref->{description}";
+ $ref->{description};
$column_data{description} =
qq|<td><a href=$form->{script}?action=edit_business&id=$ref->{id}&path=$form->{path}&login=$form->{login}&password=$form->{password}&callback=$callback>$description</td>|;
$column_data{discount} = qq|<td align=right>$discount</td>|;
$lxdebug->enter_sub();
$form->{title} = $locale->text("$form->{title} Business");
- $form->{salesman} = "checked" if $form->{salesman};
# $locale->text('Add Business')
# $locale->text('Edit Business')
<th align=right>| . $locale->text('Customernumberinit') . qq|</th>
<td><input name=customernumberinit size=10 value=$form->{customernumberinit}></td>
</tr>
- <tr>
- <td align=right>| . $locale->text('Salesman') . qq|</td>
- <td><input name=salesman class=checkbox type=checkbox value=1 $form->{salesman}></td>
- </tr>
<td colspan=2><hr size=3 noshade></td>
</tr>
</table>
. qq|</th>|;
$column_header{income_accno_0} =
qq|<th class=listheading>|
- . $locale->text('Erlöse Inland')
+ . $locale->text('Erlöse Inland')
. qq|</th>|;
$column_header{expense_accno_0} =
qq|<th class=listheading>|
. qq|</th>|;
$column_header{income_accno_1} =
qq|<th class=listheading>|
- . $locale->text('Erlöse EU m. UStId')
+ . $locale->text('Erlöse EU m. UStId')
. qq|</th>|;
$column_header{expense_accno_1} =
qq|<th class=listheading>|
. qq|</th>|;
$column_header{income_accno_2} =
qq|<th class=listheading>|
- . $locale->text('Erlöse EU o. UStId')
+ . $locale->text('Erlöse EU o. UStId')
. qq|</th>|;
$column_header{expense_accno_2} =
qq|<th class=listheading>|
. qq|</th>|;
$column_header{income_accno_3} =
qq|<th class=listheading>|
- . $locale->text('Erlöse Ausland')
+ . $locale->text('Erlöse Ausland')
. qq|</th>|;
$column_header{expense_accno_3} =
qq|<th class=listheading>|
$column_data{up} =
qq|<td align="center" valign="center" width="16">| .
qq|<a href="${swap_link}id1=$ref->{id}&id2=$pref->{id}">| .
- qq|<img src="image/up.png" alt="| . $locale->text("up") . qq|">| .
+ qq|<img border="0" src="image/up.png" alt="| . $locale->text("up") . qq|">| .
qq|</a></td>|;
} else {
$column_data{up} = qq|<td width="16"> </td>|;
$column_data{down} =
qq|<td align="center" valign="center" width="16">| .
qq|<a href="${swap_link}id1=$ref->{id}&id2=$nref->{id}">| .
- qq|<img src="image/down.png" alt="| . $locale->text("down") . qq|">| .
+ qq|<img border="0" src="image/down.png" alt="| . $locale->text("down") . qq|">| .
qq|</a></td>|;
}
$form->{title} = $locale->text("$form->{title} Buchungsgruppe");
- # $locale->text('Buchungsgruppe hinzufügen')
+ # $locale->text('Buchungsgruppe hinzufügen')
# $locale->text('Buchungsgruppe bearbeiten')
my ($acc_inventory, $acc_income, $acc_expense) = ({}, {}, {});
$linkaccounts .= qq|
<tr>
- <th align=right>| . $locale->text('Erlöse Inland') . qq|</th>
+ <th align=right>| . $locale->text('Erlöse Inland') . qq|</th>
<td><select name=income_accno_id_0>$form->{selectIC_income}</select></td>
</tr>
<tr>
$form->{selectIC_expense} =~ s/ value=$form->{expense_accno_id_1}/ value=$form->{expense_accno_id_1} selected/;
}
$linkaccounts .= qq| <tr>
- <th align=right>| . $locale->text('Erlöse EU m. UStId') . qq|</th>
+ <th align=right>| . $locale->text('Erlöse EU m. UStId') . qq|</th>
<td><select name=income_accno_id_1>$form->{selectIC_income}</select></td>
</tr>
<tr>
}
$linkaccounts .= qq| <tr>
- <th align=right>| . $locale->text('Erlöse EU o. UStId') . qq|</th>
+ <th align=right>| . $locale->text('Erlöse EU o. UStId') . qq|</th>
<td><select name=income_accno_id_2>$form->{selectIC_income}</select></td>
</tr>
<tr>
}
$linkaccounts .= qq| <tr>
- <th align=right>| . $locale->text('Erlöse Ausland') . qq|</th>
+ <th align=right>| . $locale->text('Erlöse Ausland') . qq|</th>
<td><select name=income_accno_id_3>$form->{selectIC_income}</select></td>
</tr>
<tr>
$lxdebug->enter_sub();
AM->delete_buchungsgruppe(\%myconfig, \%$form);
- $form->redirect($locale->text('Buchungsgruppe gelöscht!'));
+ $form->redirect($locale->text('Buchungsgruppe gelöscht!'));
$lxdebug->leave_sub();
}
$column_data{up} =
qq|<td align="center" valign="center" width="16">| .
qq|<a href="${swap_link}&id1=$ref->{id}&id2=$pref->{id}">| .
- qq|<img src="image/up.png" alt="| . $locale->text("up") . qq|">| .
+ qq|<img border="0" src="image/up.png" alt="| . $locale->text("up") . qq|">| .
qq|</a></td>|;
} else {
$column_data{up} = qq|<td width="16"> </td>|;
$column_data{down} =
qq|<td align="center" valign="center" width="16">| .
qq|<a href="${swap_link}&id1=$ref->{id}&id2=$nref->{id}">| .
- qq|<img src="image/down.png" alt="| . $locale->text("down") . qq|">| .
+ qq|<img border="0" src="image/down.png" alt="| . $locale->text("down") . qq|">| .
qq|</a></td>|;
}
$lxdebug->leave_sub();
}
-sub display_stylesheet {
+sub display_template {
$lxdebug->enter_sub();
- $form->{file} = "css/$myconfig{stylesheet}";
- &display_form;
+ $form->{edit} = 0;
+ display_template_form();
$lxdebug->leave_sub();
}
-sub display_form {
+sub edit_template {
$lxdebug->enter_sub();
- $form->{file} =~ s/^(.:)*?\/|\.\.\///g;
- $form->{file} =~ s/^\/*//g;
- $form->{file} =~ s/$userspath//;
+ $form->{edit} = 1;
+ display_template_form();
- $form->error("$!: $form->{file}") unless -f $form->{file};
+ $lxdebug->leave_sub();
+}
- AM->load_template(\%$form);
+sub save_template {
+ $lxdebug->enter_sub();
- $form->{title} = $form->{file};
+ $form->isblank("formname", $locale->text("You're not editing a file.")) unless ($form->{type} eq "stylesheet");
- # if it is anything but html
- if ($form->{file} !~ /\.html$/) {
- $form->{body} = "<pre>\n$form->{body}\n</pre>";
+ my ($filename) = AM->prepare_template_filename(\%myconfig, $form);
+ if (my $error = AM->save_template($filename, $form->{content})) {
+ $form->error(sprintf($locale->text("Saving the file '%s' failed. OS error message: %s"), $filename, $error));
}
- $form->header;
+ $form->{edit} = 0;
+ display_template_form();
- print qq|
-<body>
+ $lxdebug->leave_sub();
+}
-$form->{body}
+sub display_template_form {
+ $lxdebug->enter_sub();
-<form method=post action=$form->{script}>
+ $form->{formname} =~ s|.*/||;
+ my $format = $form->{format} eq "html" ? "html" : "tex";
-<input name=file type=hidden value=$form->{file}>
-<input name=type type=hidden value=template>
+ my $title = $form->{type} eq "stylesheet" ? $locale->text("Edit the stylesheet") : $locale->text("Edit templates");
+ $form->{title} = $title;
-<input type=hidden name=path value=$form->{path}>
-<input type=hidden name=login value=$form->{login}>
-<input type=hidden name=password value=$form->{password}>
+ my $edit_options;
-<input name=action type=submit class=submit value="|
- . $locale->text('Edit') . qq|">
+ my @hidden = qw(login path password type format);
- </form>
+ if (($form->{type} ne "stylesheet") && !$form->{edit}) {
+ $edit_options = "<p>";
-</body>
-</html>
+ my %formname_setup =
+ (
+ "balance_sheet" => { "translation" => $locale->text('Balance Sheet'), "html" => 1 },
+ "bin_list" => $locale->text('Bin List'),
+ "bwa" => { "translation" => $locale->text('BWA'), "html" => 1 },
+ "check" => { "translation" => $locale->text('Check'), "html" => 1 },
+ "credit_note" => $locale->text('Credit Note'),
+ "income_statement" => { "translation" => $locale->text('Income Statement'), "html" => 1 },
+ "invoice" => $locale->text('Invoice'),
+ "packing_list" => $locale->text('Packing List'),
+ "pick_list" => $locale->text('Pick List'),
+ "proforma" => $locale->text('Proforma Invoice'),
+ "purchase_order" => $locale->text('Purchase Order'),
+ "receipt" => { "translation" => $locale->text('Receipt'), "tex" => 1 },
+ "request_quotation" => $locale->text('RFQ'),
+ "sales_order" => $locale->text('Confirmation'),
+ "sales_quotation" => $locale->text('Quotation'),
+ "statement" => $locale->text('Statement'),
+ "storno_invoice" => $locale->text('Storno Invoice'),
+ "storno_packing_list" => $locale->text('Storno Packing List'),
+ "ustva-2004" => { "translation" => $locale->text("USTVA 2004"), "tex" => 1 },
+ "ustva-2005" => { "translation" => $locale->text("USTVA 2005"), "tex" => 1 },
+ "ustva-2006" => { "translation" => $locale->text("USTVA 2006"), "tex" => 1 },
+ "ustva-2007" => { "translation" => $locale->text("USTVA 2007"), "tex" => 1 },
+ "ustva" => $locale->text("USTVA"),
+ "zahlungserinnerung" => $locale->text('Payment Reminder'),
+ );
+
+ my (@values, %labels, $file, $setup);
+
+ while (($file, $setup) = each(%formname_setup)) {
+ next unless (!ref($setup) || $setup->{$format});
+
+ push(@values, $file);
+ $labels{$file} = ref($setup) ? $setup->{translation} : $setup;
+ }
+ @values = sort({ $labels{$a} cmp $labels{$b} } @values);
+
+ $edit_options .=
+ $locale->text("Template") . " " .
+ NTI($cgi->popup_menu("-name" => "formname", "-default" => $form->{formname},
+ "-values" => \@values, "-labels" => \%labels));
+
+ $form->get_lists("printers" => "ALL_PRINTERS",
+ "languages" => "ALL_LANGUAGES");
+
+ @values = ("");
+ %labels = ();
+
+ foreach my $item (@{ $form->{ALL_LANGUAGES} }) {
+ next unless ($item->{template_code});
+ my $key = "$item->{id}--$item->{template_code}";
+ push(@values, $key);
+ $labels{$key} = $item->{description};
+ }
+
+ if (1 != scalar(@values)) {
+ $edit_options .=
+ " " . $locale->text("Language") . " " .
+ NTI($cgi->popup_menu("-name" => "language", "-default" => $form->{language},
+ "-values" => \@values, "-labels" => \%labels));
+ }
+
+ @values = ("");
+ %labels = ();
+
+ foreach my $item (@{ $form->{ALL_PRINTERS} }) {
+ next unless ($item->{template_code});
+ my $key = "$item->{id}--$item->{template_code}";
+ push(@values, $key);
+ $labels{$key} = $item->{printer_description};
+ }
+
+ if (1 != scalar(@values)) {
+ $edit_options .=
+ " " . $locale->text("Printer") . " " .
+ NTI($cgi->popup_menu("-name" => "printer", "-default" => $form->{printer},
+ "-values" => \@values, "-labels" => \%labels));
+ }
+
+ $edit_options .= qq|
+
+ <input type="hidden" name="display_nextsub" value="display_template">
+
+ <input name="action" type="submit" class="submit" value="|
+ . $locale->text('Display') . qq|">
+
+ </p>
+
+ <hr>
|;
- $lxdebug->leave_sub();
-}
+ } else {
+ push(@hidden, qw(formname language printer));
+ }
-sub edit_template {
- $lxdebug->enter_sub();
+ if ($form->{formname} || ($form->{type} eq "stylesheet")) {
+ my ($filename, $display_filename) = AM->prepare_template_filename(\%myconfig, $form);
+ my ($content, $lines) = AM->load_template($filename);
+
+ $body = qq|
+|;
+
+ if ($form->{edit}) {
+ $form->{fokus} = "Form.content";
+ $body = qq|\n<p><div class="listtop">| . $locale->text('Edit file') . " '" . H($display_filename) . qq|'</div></p>\n<p>|
+ . NTI($cgi->textarea("-name" => "content",
+ "-id" => "content",
+ "-default" => $content,
+ "-columns" => 100,
+ "-rows" => 25))
+ . qq|</p>
+
+ <p>
+ <input type="hidden" name="save_nextsub" value="save_template">
+
+ <input type="submit" name="action" value="| . $locale->text('Save') . qq|">
+ </p>
+|;
+
+ } else {
+ $content = "\n\n" unless ($content);
+
+ $body = qq|
+ <p><div class="listtop">| . $locale->text('Display file') . " '" . H($display_filename) . qq|'</div></p>
+
+ <input type="hidden" name="edit_nextsub" value="edit_template">
- AM->load_template(\%$form);
+ <p><input name="action" type="submit" class="submit" value="| . $locale->text('Edit') . qq|"></p>
- $form->{title} = $locale->text('Edit Template');
+ <p>
+ <pre class="filecontent">| . H($content) . qq|</pre>
+ </p>
+|;
- # convert   to &nbsp;
- $form->{body} =~ s/ /&nbsp;/gi;
+ if ($lines > 25) {
+ $body .= qq|
+ <input name="action" type="submit" class="submit" value="|
+ . $locale->text('Edit') . qq|">
+|;
+ }
+ }
+ }
$form->header;
print qq|
<body>
-<form method=post action=$form->{script}>
-
-<input name=file type=hidden value=$form->{file}>
-<input name=type type=hidden value=template>
-
-<input type=hidden name=path value=$form->{path}>
-<input type=hidden name=login value=$form->{login}>
-<input type=hidden name=password value=$form->{password}>
+<div class="listheading">$title</div>
-<input name=callback type=hidden value="$form->{script}?action=display_form&file=$form->{file}&path=$form->{path}&login=$form->{login}&password=$form->{password}">
+<form method="post" name="Form" action="am.pl">
-<textarea name=body rows=25 cols=70>
-$form->{body}
-</textarea>
+|;
+ $form->hide_form(@hidden);
-<br>
-<input type=submit class=submit name=action value="|
- . $locale->text('Save') . qq|">
+ print qq|
+$edit_options
- </form>
+$body
+</form>
</body>
</html>
$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();
edit_units();
$lxdebug->leave_sub();
-}
\ No newline at end of file
+}