use utf8;
+use List::MoreUtils qw(any);
+
use SL::Auth;
use SL::Auth::PasswordPolicy;
use SL::AM;
$form->{title} = $locale->text('Add Warehouse');
$form->{callback} ||= build_std_url('action=add_warehouse');
+ setup_am_edit_warehouse_action_bar();
+
$form->header();
print $form->parse_html_template('am/edit_warehouse');
$form->{title} = $locale->text('Edit Warehouse');
$form->{callback} ||= build_std_url('action=list_warehouses');
+ setup_am_edit_warehouse_action_bar(id => $::form->{id}, in_use => any { $_->{in_use} } @{ $::form->{BINS} });
+
$form->header();
print $form->parse_html_template('am/edit_warehouse');
$main::lxdebug->leave_sub();
}
+sub edit_bins {
+ $::auth->assert('config');
+
+ AM->get_warehouse(\%::myconfig, $::form);
+
+ $::form->{title} = $::locale->text('Edit Bins for Warehouse \'#1\'', $::form->{description});
+ $::form->{callback} ||= build_std_url('action=list_warehouses');
+
+ setup_am_edit_bins_action_bar(id => $::form->{id});
+
+ $::form->header;
+ print $::form->parse_html_template('am/edit_bins');
+}
+
sub list_warehouses {
$main::lxdebug->enter_sub();
$form->{title} = $locale->text('Warehouses');
$form->{url_base} = build_std_url('callback');
+ setup_am_list_warehouses_action_bar();
+
$form->header();
print $form->parse_html_template('am/list_warehouses');
$main::auth->assert('config');
- if (!$form->{confirmed}) {
- $form->{title} = $locale->text('Confirmation');
-
- $form->header();
- print $form->parse_html_template('am/confirm_delete_warehouse');
- $::dispatcher->end_request;
- }
-
if (AM->delete_warehouse(\%myconfig, $form)) {
$form->{callback} .= '&saved_message=' . E($locale->text('Warehouse deleted.')) if ($form->{callback});
$form->redirect($locale->text('Warehouse deleted.'));
);
}
}
+
+sub setup_am_list_warehouses_action_bar {
+ my %params = @_;
+
+ for my $bar ($::request->layout->get('actionbar')) {
+ $bar->add(
+ link => [
+ t8('Add'),
+ link => 'am.pl?action=add&type=warehouse&callback=' . E($::form->{callback}),
+ accesskey => 'enter',
+ ],
+ );
+ }
+}
+
+sub setup_am_edit_warehouse_action_bar {
+ my %params = @_;
+
+ for my $bar ($::request->layout->get('actionbar')) {
+ $bar->add(
+ action => [
+ t8('Save'),
+ submit => [ '#form', { action => 'save_warehouse' } ],
+ accesskey => 'enter',
+ ],
+
+ action => [
+ t8('Delete'),
+ submit => [ '#form', { action => 'delete_warehouse' } ],
+ disabled => !$params{id} ? t8('The object has not been saved yet.')
+ : $params{in_use} ? t8('The object is in use and cannot be deleted.')
+ : undef,
+ confirm => t8('Do you really want to delete this object?'),
+ ],
+
+ 'separator',
+
+ link => [
+ t8('Bins'),
+ link => 'am.pl?action=edit_bins&id=' . E($params{id}),
+ only_if => $params{id},
+ ],
+
+ link => [
+ t8('Abort'),
+ link => $::form->{callback} || 'am.pl?action=list_warehouses',
+ ],
+ );
+ }
+}
+
+sub setup_am_edit_bins_action_bar {
+ my %params = @_;
+
+ for my $bar ($::request->layout->get('actionbar')) {
+ $bar->add(
+ action => [
+ t8('Save'),
+ submit => [ '#form', { action => 'save_bin' } ],
+ accesskey => 'enter',
+ ],
+
+ 'separator',
+
+ link => [
+ t8('Abort'),
+ link => 'am.pl?action=edit_warehouse&id=' . E($params{id}),
+ ],
+ );
+ }
+}
'Bin List' => 'Lagerliste',
'Bin To' => 'Ziellagerplatz',
'Binding to the LDAP server as "#1" failed. Please check config/kivitendo.conf.' => 'Die Anmeldung am LDAP-Server als "#1" schlug fehl. Bitte überprüfen Sie die Angaben in config/kivitendo.conf.',
+ 'Bins' => 'Lagerplätze',
'Bins saved.' => 'Lagerplätze gespeichert.',
'Bins that have been used in the past cannot be deleted anymore. For these bins there\'s no checkbox in the "Delete" column.' => 'Lagerplätze, die bereits benutzt wurden, können nicht mehr gelöscht werden. Deswegen fehlt bei ihnen die Checkbox in der Spalte "Löschen".',
'Birthday' => 'Geburtstag',
'Do you really want to delete this draft?' => 'Wollen Sie diesen Entwurf wirklich löschen?',
'Do you really want to delete this object?' => 'Wollen Sie dieses Objekt wirklich löschen?',
'Do you really want to delete this record template?' => 'Wollen Sie diese Belegvorlage wirklich löschen?',
- 'Do you really want to delete this warehouse?' => 'Wollen Sie dieses Lager wirklich löschen?',
'Do you really want to revert to this version?' => 'Wollen Sie wirklich auf diese Version zurücksetzen?',
'Do you really want to save?' => 'Wollen Sie wirklich speichern?',
'Do you really want to unimport the selected documents?' => 'Wollen Sie wirklich diese Dateien an die Quelle zurückgeben?',
'Edit Accounts Receivables Transaction' => 'Debitorenbuchung bearbeiten',
'Edit Assembly' => 'Erzeugnis bearbeiten',
'Edit Assortment' => 'Sortiment bearbeiten',
- 'Edit Bins' => 'Lagerplätze bearbeiten',
+ 'Edit Bins for Warehouse \'#1\'' => 'Lagerplätze von Lager »#1« bearbeiten',
'Edit Client' => 'Mandanten bearbeiten',
'Edit Credit Note' => 'Gutschrift bearbeiten',
'Edit Customer' => 'Kunde editieren',
+++ /dev/null
-[%- USE T8 %]
-[%- USE HTML %]
- <h1>[% title %]</h1>
-
- <p>[% 'Do you really want to delete this warehouse?' | $T8 %]</p>
-
- <p>[% 'Warehouse' | $T8 %]: [% HTML.escape(orig_description) %]</p>
-
- <form action="am.pl" method="post">
-
- <input type="hidden" name="id" value="[% HTML.escape(id) %]">
- <input type="hidden" name="callback" value="[% HTML.escape(callback) %]">
- <input type="hidden" name="type" value="warehouse">
- <input type="hidden" name="confirmed" value="1">
-
- <button type="button" class="submit" onclick="history.back()">[% 'Back' | $T8 %]</button>
- <input type="submit" class="submit" name="action" value="[% 'Delete' | $T8 %]">
- </form>
-
-</form>
--- /dev/null
+[%- USE HTML -%][%- USE T8 -%]
+
+<h1>[% title %]</h1>
+
+[% UNLESS BINS.size %]
+ <p>[% 'No bins have been added to this warehouse yet.' | $T8 %]</p>
+
+[% ELSE %]
+
+ <p>
+ [%- 'Bins that have been used in the past cannot be deleted anymore. For these bins there\'s no checkbox in the "Delete" column.' | $T8 %]
+ </p>
+
+ <form method="post" action="am.pl" id="form">
+
+ <input type="hidden" name="warehouse_id" value="[% HTML.escape(id) %]">
+
+ <input type="hidden" name="type" value="bin">
+ <input type="hidden" name="callback" value="[% HTML.escape(callback) %]">
+
+ <table border="0">
+ <tr>
+ <th class="listheading">[% 'Delete' | $T8 %]</th><th class="listheading">[% 'Description' | $T8 %]</th>
+ <th class="listheading">[% 'Delete' | $T8 %]</th><th class="listheading">[% 'Description' | $T8 %]</th>
+ </tr>
+ [%- SET row_odd = '1' %]
+ [%- USE bin_it = Iterator(BINS) %]
+ [%- FOREACH bin = bin_it %]
+ [%- IF row_odd %]
+ <tr>
+ [%- END %]
+
+ <td>[% IF bin.in_use %] [% ELSE %]<input type="checkbox" name="delete_[% bin_it.count %]" value="1">[% END %]</td>
+ <td>
+ <input type="hidden" name="id_[% bin_it.count %]" value="[% HTML.escape(bin.id) %]">
+ <input name="description_[% bin_it.count %]" value="[% HTML.escape(bin.description) %]">
+ </td>
+
+ [%- SET end_tr = '0' %]
+ [%- UNLESS row_odd %][%- SET end_tr = '1' %][%- END %]
+ [%- IF bin_it.last %][%- SET end_tr = '1' %][%- END %]
+ [%- IF end_tr %]
+ </tr>
+ [%- END %]
+
+ [%- IF row_odd %][% SET row_odd = '0' %][% ELSE %][% SET row_odd = '1' %][% END %]
+ [%- END %]
+ </table>
+
+ <input type="hidden" name="rowcount" value="[% BINS.size %]">
+ </form>
+
+[% END %]
<p>[% saved_message %]</p>
[% END %]
- <form method="post" action="am.pl">
+ <form method="post" action="am.pl" id="form">
<input type="hidden" name="id" value="[% HTML.escape(id) %]">
<td><input name="prefix" value="[% 'Bin' | $T8 %]"></td>
</tr>
</table>
-
- <p>
- <input type="submit" class="submit" name="action" value="[% 'Save' | $T8 %]">
- [%- IF id %][%- UNLESS in_use %]
- <input type="submit" class="submit" name="action" value="[% 'Delete' | $T8 %]">
- [%- END %][%- END %]
- </p>
-
</form>
-
- [% IF id %]
-
- <hr height="3">
-
- <h2>[% 'Edit Bins' | $T8 %]</h2>
-
- [% UNLESS BINS.size %]
- <p>[% 'No bins have been added to this warehouse yet.' | $T8 %]</p>
-
- [% ELSE %]
-
- <p>
- [%- 'Bins that have been used in the past cannot be deleted anymore. For these bins there\'s no checkbox in the "Delete" column.' | $T8 %]
- </p>
-
- <form method="post" action="am.pl">
-
- <input type="hidden" name="warehouse_id" value="[% HTML.escape(id) %]">
-
- <input type="hidden" name="type" value="bin">
- <input type="hidden" name="callback" value="[% HTML.escape(callback) %]">
-
- <table border="0">
- <tr>
- <th class="listheading">[% 'Delete' | $T8 %]</th><th class="listheading">[% 'Description' | $T8 %]</th>
- <th class="listheading">[% 'Delete' | $T8 %]</th><th class="listheading">[% 'Description' | $T8 %]</th>
- </tr>
- [%- SET row_odd = '1' %]
- [%- USE bin_it = Iterator(BINS) %]
- [%- FOREACH bin = bin_it %]
- [%- IF row_odd %]
- <tr>
- [%- END %]
-
- <td>[% IF bin.in_use %] [% ELSE %]<input type="checkbox" name="delete_[% bin_it.count %]" value="1">[% END %]</td>
- <td>
- <input type="hidden" name="id_[% bin_it.count %]" value="[% HTML.escape(bin.id) %]">
- <input name="description_[% bin_it.count %]" value="[% HTML.escape(bin.description) %]">
- </td>
-
- [%- SET end_tr = '0' %]
- [%- UNLESS row_odd %][%- SET end_tr = '1' %][%- END %]
- [%- IF bin_it.last %][%- SET end_tr = '1' %][%- END %]
- [%- IF end_tr %]
- </tr>
- [%- END %]
-
- [%- IF row_odd %][% SET row_odd = '0' %][% ELSE %][% SET row_odd = '1' %][% END %]
- [%- END %]
- </table>
-
- <input type="hidden" name="rowcount" value="[% BINS.size %]">
-
- <p><input type="submit" class="submit" name="action" value="[% 'Save' | $T8 %]"></p>
- </form>
-
- [% END %]
-
- [% END %]
</table>
</p>
- <hr height="3">
-
- <p>
- <a href="am.pl?action=add&type=warehouse&callback=[% HTML.url(callback) %]">[%- 'Add' | $T8 %]</a>
- </p>
-
[% L.sortable_element('#warehouse_list tbody', url => 'controller.pl?action=Warehouse/reorder', with => 'warehouse_id') %]