use SL::AM;
use SL::CA;
use SL::Form;
+use SL::Helper::Flash;
use SL::User;
use SL::USTVA;
use SL::Iconv;
$main::lxdebug->leave_sub();
}
+sub add_unit {
+ $::auth->assert('config');
+
+ # my $units = AM->retrieve_units(\%::myconfig, $::form, "resolved_");
+ # # AM->units_in_use(\%::myconfig, $::form, $units);
+
+ # $units->{$_}->{BASE_UNIT_DDBOX} = AM->unit_select_data($units, $units->{$_}->{base_unit}, 1) for keys %{$units};
+
+ my @languages = @{ SL::DB::Manager::Language->get_all_sorted };
+
+ my $units = AM->retrieve_units(\%::myconfig, $::form);
+ my $ddbox = AM->unit_select_data($units, undef, 1);
+
+ setup_am_add_unit_action_bar();
+
+ $::form->{title} = $::locale->text("Add unit");
+ $::form->header();
+ print($::form->parse_html_template("am/add_unit", {
+ NEW_BASE_UNIT_DDBOX => $ddbox,
+ LANGUAGES => \@languages,
+ }));
+}
+
sub edit_units {
$main::lxdebug->enter_sub();
$units = AM->retrieve_units(\%myconfig, $form);
my $ddbox = AM->unit_select_data($units, undef, 1);
- $form->{"title"} = $locale->text("Add and edit units");
+ setup_am_edit_units_action_bar();
+
+ $form->{"title"} = $locale->text("Edit units");
$form->header();
print($form->parse_html_template("am/edit_units",
{ "UNITS" => \@unit_list,
$main::lxdebug->leave_sub();
}
-sub add_unit {
+sub create_unit {
$main::lxdebug->enter_sub();
my $form = $main::form;
AM->add_unit(\%myconfig, $form, $form->{"new_name"}, $base_unit, $factor, \@languages);
- $form->{"saved_message"} = $locale->text("The unit has been saved.");
+ flash_later('info', $locale->text("The unit has been added."));
- edit_units();
+ print $form->redirect_header('am.pl?action=edit_units');
$main::lxdebug->leave_sub();
}
AM->save_units(\%myconfig, $form, $new_units, \@delete_units);
- $form->{"saved_message"} = $locale->text("The units have been saved.");
+ flash_later('info', $locale->text("The units have been saved."));
- edit_units();
+ print $form->redirect_header('am.pl?action=edit_units');
$main::lxdebug->leave_sub();
}
);
}
}
+
+sub setup_am_add_unit_action_bar {
+ my %params = @_;
+
+ for my $bar ($::request->layout->get('actionbar')) {
+ $bar->add(
+ action => [
+ t8('Save'),
+ submit => [ '#form', { action => "create_unit" } ],
+ accesskey => 'enter',
+ ],
+
+ 'separator',
+
+ link => [
+ t8('Back'),
+ link => 'am.pl?action=edit_units',
+ ],
+ );
+ }
+}
+
+sub setup_am_edit_units_action_bar {
+ my %params = @_;
+
+ for my $bar ($::request->layout->get('actionbar')) {
+ $bar->add(
+ action => [
+ t8('Save'),
+ submit => [ '#form', { action => "save_unit" } ],
+ accesskey => 'enter',
+ ],
+
+ 'separator',
+
+ link => [
+ t8('Add'),
+ link => 'am.pl?action=add_unit',
+ ],
+ );
+ }
+}
'Add Vendor Invoice' => 'Einkaufsrechnung erfassen',
'Add Warehouse' => 'Lager erfassen',
'Add acceptance status' => 'Abnahmestatus hinzufügen',
- 'Add and edit units' => 'Einheiten erfassen und bearbeiten',
'Add bank account' => 'Bankkonto erfassen',
'Add booking group' => 'Buchungsgruppe erfassen',
'Add business' => 'Kunden-/Lieferantentyp hinzufügen',
'The transfer has been canceled by the user.' => 'Der Vorgang wurde durch den Benutzer abgebrochen.',
'The transport cost article \'#1\' is missing. Do you want to continue anyway?' => 'Der Transportkostenartikel »#1« fehlt. Wollen Sie trotzdem fortfahren?',
'The type is missing.' => 'Der Typ fehlt.',
- 'The unit has been saved.' => 'Die Einheit wurde gespeichert.',
+ 'The unit has been added.' => 'Die Einheit wurde erfasst.',
'The unit in row %d has been deleted in the meantime.' => 'Die Einheit in Zeile %d ist in der Zwischentzeit gelöscht worden.',
'The unit in row %d has been used in the meantime and cannot be changed anymore.' => 'Die Einheit in Zeile %d wurde in der Zwischenzeit benutzt und kann nicht mehr geändert werden.',
'The unit is missing.' => 'Die Einheit fehlt.',
--- /dev/null
+[%- USE HTML -%][%- USE LxERP -%][%- USE T8 -%]
+<p>
+ [% LxERP.t8('All units have either no or exactly one base unit of which they are multiples.') %]
+ [% LxERP.t8('If you select a base unit then you also have to enter a factor.') %]
+ [% LxERP.t8('You have to define a unit as a multiple of a smaller unit.') %]
+ [% LxERP.t8('Therefore the definition of "kg" with the base unit "g" and a factor of 1000 is valid while defining "g" with a base unit of "kg" and a factor of "0.001" is not.') %]
+</p>
--- /dev/null
+[%- USE HTML -%][%- USE T8 -%]
+<h1>[% 'Add unit' | $T8 %]</h1>
+
+[% PROCESS "am/_units_header_info.html" %]
+
+<hr>
+
+<form method="post" action="[% HTML.escape(script) %]" id="form">
+
+ <input type="hidden" name="type" value="unit">
+
+ <table>
+ <tr>
+ <th align="right">[% 'Unit' | $T8 %]</th>
+ <td><input name="new_name" size="20" maxlength="20"></td>
+ </tr>
+ <tr>
+ <th align="right">[% 'Base unit' | $T8 %]</th>
+ <td>
+ <select name="new_base_unit">
+ [% FOREACH row = NEW_BASE_UNIT_DDBOX %]<option [% row.selected %]>[% row.name %]</option>[% END %]
+ </select>
+ </td>
+ </tr>
+ <tr>
+ <th align="right">[% 'Factor' | $T8 %]</th>
+ <td><input name="new_factor"></td>
+ </tr>
+
+ [% FOREACH language = LANGUAGES %]
+ <tr>
+ <th align="right">[% language.description %]</th>
+ <td><input name="new_localized_[% language.id %]" size="20" maxlength="20"></td>
+ <th align="right">[% 'Plural' | $T8 %]</th>
+ <td><input name="new_localized_plural_[% language.id %]" size="20" maxlength="20"></td>
+ </tr>
+ [% END %]
+ </table>
+</form>
[% USE HTML %]
<h1>[% title %]</h1>
- [% IF saved_message %]
- <p>[% saved_message %]</p>
+[% PROCESS "common/flash.html" %]
- <hr>
- [% END %]
+[% PROCESS "am/_units_header_info.html" %]
- <form method="post" action="[% HTML.escape(script) %]">
+<hr>
- <input type="hidden" name="type" value="unit">
-
- <p>
- [% LxERP.t8('All units have either no or exactly one base unit of which they are multiples.') %]
- [% LxERP.t8('If you select a base unit then you also have to enter a factor.') %]
- [% LxERP.t8('You have to define a unit as a multiple of a smaller unit.') %]
- [% LxERP.t8('Therefore the definition of "kg" with the base unit "g" and a factor of 1000 is valid while defining "g" with a base unit of "kg" and a factor of "0.001" is not.') %]
- </p>
+<p>
+ [% 'Units that have already been used (e.g. for parts and services or in invoices or warehouse transactions) cannot be changed.' | $T8 %]
+</p>
- <hr>
+<p>
+ [% 'Units marked for deletion will be deleted upon saving.' | $T8 %]
+</p>
- <h2>[% 'Add unit' | $T8 %]</h2>
+<p>
+ [% 'You can declare different translations for singular and plural for each unit (e.g. "day" and "days).' | $T8 %]
+</p>
- <table>
- <tr>
- <th align="right">[% 'Unit' | $T8 %]</th>
- <td><input name="new_name" size="20" maxlength="20"></td>
- </tr>
- <tr>
- <th align="right">[% 'Base unit' | $T8 %]</th>
- <td>
- <select name="new_base_unit">
- [% FOREACH row = NEW_BASE_UNIT_DDBOX %]<option [% row.selected %]>[% row.name %]</option>[% END %]
- </select>
- </td>
- </tr>
- <tr>
- <th align="right">[% 'Factor' | $T8 %]</th>
- <td><input name="new_factor"></td>
- </tr>
-
- [% FOREACH language = LANGUAGES %]
- <tr>
- <th align="right">[% language.description %]</th>
- <td><input name="new_localized_[% language.id %]" size="20" maxlength="20"></td>
- <th align="right">[% 'Plural' | $T8 %]</th>
- <td><input name="new_localized_plural_[% language.id %]" size="20" maxlength="20"></td>
- </tr>
- [% END %]
- </table>
+<form method="post" action="[% HTML.escape(script) %]" id="form">
- <input type="submit" class="submit" name="action" value="[% 'Add' | $T8 %]">
-
- <hr>
-
- <h2>[% 'Edit units' | $T8 %]</h2>
-
- <p>
- [% 'Units that have already been used (e.g. for parts and services or in invoices or warehouse transactions) cannot be changed.' | $T8 %]
- </p>
-
- <p>
- [% 'Units marked for deletion will be deleted upon saving.' | $T8 %]
- </p>
-
- <p>
- [% 'You can declare different translations for singular and plural for each unit (e.g. "day" and "days).' | $T8 %]
- </p>
+ <input type="hidden" name="type" value="unit">
<table id="unit_list">
<thead>
<input type="hidden" name="rowcount" value="[% UNITS.size %]">
- <input type="submit" class="submit" name="action" value="[% 'Save' | $T8 %]">
-
</form>
[% L.sortable_element('#unit_list tbody', url => 'controller.pl?action=Unit/reorder', with => 'unit_id') %]
-