Projekt

Allgemein

Profil

« Zurück | Weiter » 

Revision 3f055eaf

Von Bernd Bleßmann vor mehr als 3 Jahren hinzugefügt

  • ID 3f055eafce38dafed88437c5d428a72cceb22b6b
  • Vorgänger 6daa0eca
  • Nachfolger 966976a7

Auftrags-Controller: neuen Artikel aus Maske heraus anlegen können

Todo: Im Moment können nur Waren angelegt werden. Es müsste ein Mini-Select
geben, wo man zwischen Waren/Dienstleistungen/Erzeugnissen/Sortimenten/...
wählen kann.

Übernahme aus anderem Kundenprojekt

Unterschiede anzeigen:

SL/Controller/Order.pm
976 976
  $self->render_price_dialog($item);
977 977
}
978 978

  
979
# save the order in a session variable and redirect to the part controller
980
sub action_create_part {
981
  my ($self) = @_;
982

  
983
  my $previousform = $::auth->save_form_in_session(non_scalars => 1);
984

  
985
  my $callback     = $self->url_for(
986
    action       => 'return_from_create_part',
987
    type         => $self->type, # type is needed for check_auth on return
988
    previousform => $previousform,
989
  );
990

  
991
  flash_later('info', t8('You are adding a new part while you are editing another document. You will be redirected to your document when saving the new part or aborting this form.'));
992

  
993
  my @redirect_params = (
994
    controller => 'Part',
995
    action     => 'add',
996
    part_type  => 'part',
997
    callback   => $callback,
998
    show_abort => 1,
999
  );
1000

  
1001
  $self->redirect_to(@redirect_params);
1002
}
1003

  
1004
sub action_return_from_create_part {
1005
  my ($self) = @_;
1006

  
1007
  $self->{created_part} = SL::DB::Part->new(id => delete $::form->{new_parts_id})->load if $::form->{new_parts_id};
1008

  
1009
  $::auth->restore_form_from_session(delete $::form->{previousform});
1010

  
1011
  # set item ids to new fake id, to identify them as new items
1012
  foreach my $item (@{$self->order->items_sorted}) {
1013
    $item->{new_fake_id} = join('_', 'new', Time::HiRes::gettimeofday(), int rand 1000000000000);
1014
  }
1015

  
1016
  $self->recalc();
1017
  $self->get_unalterable_data();
1018
  $self->pre_render();
1019

  
1020
  # trigger rendering values for second row/longdescription as hidden,
1021
  # because they are loaded only on demand. So we need to keep the values
1022
  # from the source.
1023
  $_->{render_second_row}      = 1 for @{ $self->order->items_sorted };
1024
  $_->{render_longdescription} = 1 for @{ $self->order->items_sorted };
1025

  
1026
  $self->render(
1027
    'order/form',
1028
    title => $self->get_title_for('edit'),
1029
    %{$self->{template_args}}
1030
  );
1031

  
1032
}
1033

  
979 1034
# load the second row for one or more items
980 1035
#
981 1036
# This action gets the html code for all items second rows by rendering a template for
SL/Controller/Part.pm
168 168
  $self->action_save(save_as_new=>1);
169 169
}
170 170

  
171
sub action_abort {
172
  my ($self) = @_;
173
  if ( $::form->{callback} ) {
174
    $self->redirect_to($::form->unescape($::form->{callback}));
175
  }
176
}
177

  
171 178
sub action_delete {
172 179
  my ($self) = @_;
173 180

  
......
1339 1346
        ],
1340 1347
      ], # end of combobox "Save"
1341 1348

  
1349
      action => [
1350
        t8('Abort'),
1351
        submit   => [ '#ic', { action => "Part/abort" } ],
1352
        only_if  => !!$::form->{show_abort},
1353
      ],
1354

  
1342 1355
      action => [
1343 1356
        t8('Delete'),
1344 1357
        call     => [ 'kivi.Part.delete' ],
js/kivi.Order.js
837 837
    follow_up_window();
838 838
  };
839 839

  
840
  ns.create_part = function() {
841
    var data = $('#order_form').serializeArray();
842
    data.push({ name: 'action', value: 'Order/create_part' });
843

  
844
    $.post("controller.pl", data, kivi.eval_json_result);
845
  };
846

  
840 847
});
841 848

  
842 849
$(function() {
locale/de/all
29 29
  '%'                           => '%',
30 30
  '(recommended) Insert the used currencies in the system. You can simply change the name of the currencies by editing the textfields above. Do not use a name of a currency that is already in use.' => '(empfohlen) Fügen Sie die verwaisten Währungen in Ihr System ein. Sie können den Namen der Währung einfach ändern, indem Sie die Felder oben bearbeiten. Benutzen Sie keine Namen von Währungen, die Sie bereits benutzen.',
31 31
  '*/'                          => '*/',
32
  '+'                           => '+',
32 33
  ', if set'                    => ', falls gesetzt',
33 34
  '---please select---'         => '---bitte auswählen---',
34 35
  '. Automatically generated.'  => '. Automatisch erzeugt.',
......
747 748
  'Create a new client'         => 'Einen neuen Mandanten anlegen',
748 749
  'Create a new delivery term'  => 'Neue Lieferbedingungen anlegen',
749 750
  'Create a new group'          => 'Neue Benutzergruppe erfassen',
751
  'Create a new part'           => 'Einen neuen Artikel anlegen',
750 752
  'Create a new payment term'   => 'Neue Zahlungsbedingungen anlegen',
751 753
  'Create a new price rule'     => 'Neue Preisregel anlegen',
752 754
  'Create a new printer'        => 'Einen neuen Drucker anlegen',
......
4127 4129
  'Yes'                         => 'Ja',
4128 4130
  'Yes, included by default'    => 'Ja, standardmäßig an',
4129 4131
  'Yes/No (Checkbox)'           => 'Ja/Nein (Checkbox)',
4132
  'You are adding a new part while you are editing another document. You will be redirected to your document when saving the new part or aborting this form.' => 'Sie legen einen neuen Artikel an, während Sie ein anderes Dokument bearbeiten. Sie werden zu Ihrem Dokument zurückgeleitet, wenn Sie den Artikel speichern oder die Bearbeitung dieser Maske abbrechen.',
4130 4133
  'You are logged out!'         => 'Auf Wiedersehen!',
4131 4134
  'You can also delete this transaction and re-enter it manually.' => 'Alternativ können Sie die Buchung auch mit löschen lassen und sie anschließend neu eingeben.',
4132 4135
  'You can choose account categories for taxes. Depending on these categories taxes will be displayed for transfers in the general ledger or not.' => 'Sie können Kontoarten für Steuern auswählen. Abhängig von diesen Kontoarten werden dann Steuern bei Dialogbuchungen angezeigt oder nicht.',
locale/en/all
29 29
  '%'                           => '',
30 30
  '(recommended) Insert the used currencies in the system. You can simply change the name of the currencies by editing the textfields above. Do not use a name of a currency that is already in use.' => '',
31 31
  '*/'                          => '',
32
  '+'                           => '',
32 33
  ', if set'                    => '',
33 34
  '---please select---'         => '',
34 35
  '. Automatically generated.'  => '',
......
747 748
  'Create a new client'         => '',
748 749
  'Create a new delivery term'  => '',
749 750
  'Create a new group'          => '',
751
  'Create a new part'           => '',
750 752
  'Create a new payment term'   => '',
751 753
  'Create a new price rule'     => '',
752 754
  'Create a new printer'        => '',
......
4126 4128
  'Yes'                         => '',
4127 4129
  'Yes, included by default'    => '',
4128 4130
  'Yes/No (Checkbox)'           => '',
4131
  'You are adding a new part while you are editing another document. You will be redirected to your document when saving the new part or aborting this form.' => '',
4129 4132
  'You are logged out!'         => '',
4130 4133
  'You can also delete this transaction and re-enter it manually.' => '',
4131 4134
  'You can choose account categories for taxes. Depending on these categories taxes will be displayed for transfers in the general ledger or not.' => '',
templates/webpages/order/tabs/_item_input.html
4 4
  <table id="input_row_table_id">
5 5
    <thead>
6 6
      <tr class="listheading">
7
        <th class="listheading" nowrap >[%- '+'            | $T8 %] </th>
7 8
        <th class="listheading" nowrap >[%- 'position'     | $T8 %] </th>
8 9
        <th class="listheading" nowrap >[%- 'Part'         | $T8 %] </th>
9 10
        <th class="listheading" nowrap >[%- 'Description'  | $T8 %] </th>
......
15 16
    </thead>
16 17
    <tbody>
17 18
      <tr valign="top" class="listrow">
19
        <td class="tooltipster-html" title="[%- 'Create a new part' | $T8 -%]">[% L.button_tag('kivi.Order.create_part()', LxERP.t8('+')) %]</td>
18 20
        <td>[% L.input_tag('add_item.position', '', size = 5, class="add_item_input numeric") %]</td>
19 21
        <td>
20 22
          [%- SET PARAM_KEY = SELF.cv == "customer" ? 'with_customer_partnumber' : 'with_makemodel' -%]
21 23
          [%- SET PARAM_VAL = SELF.search_cvpartnumber -%]
22
          [% P.part.picker('add_item.parts_id', '', style='width: 300px', class="add_item_input",
24
          [% P.part.picker('add_item.parts_id', SELF.created_part, style='width: 300px', class="add_item_input",
23 25
                            fat_set_item=1,
24 26
                            multiple_pos_input=1,
25 27
                            action={set_multi_items='kivi.Order.add_multi_items'},
26 28
                            classification_id=SELF.part_picker_classification_ids.as_list.join(','),
27 29
                            $PARAM_KEY=PARAM_VAL) %]</td>
28
        <td>[% L.input_tag('add_item.description', '', class="add_item_input") %]</td>
30
        <td>[% L.input_tag('add_item.description', SELF.created_part.description, class="add_item_input") %]</td>
29 31
        <td>
30 32
          [% L.input_tag('add_item.qty_as_number', '', size = 5, class="add_item_input numeric") %]
31
          [% L.hidden_tag('add_item.unit', '', class="add_item_input") %]
33
          [% L.hidden_tag('add_item.unit', SELF.created_part.unit, class="add_item_input") %]
32 34
        </td>
33
        <td>[% L.input_tag('add_item.sellprice_as_number', '', size = 10, class="add_item_input numeric") %]</td>
35
        [%- SET price = LxERP.format_amount((SELF.type == 'sales_order' ? SELF.created_part.sellprice : SELF.created_part.lastcost), -2) -%]
36
        <td>[% L.input_tag('add_item.sellprice_as_number', price, size = 10, class="add_item_input numeric") %]</td>
34 37
        <td>[% L.input_tag('add_item.discount_as_percent', '', size = 5, class="add_item_input numeric") %]</td>
35 38
        <td>[% L.button_tag('kivi.Order.add_item()', LxERP.t8('Add part')) %]</td>
36 39
      </tr>

Auch abrufbar als: Unified diff