Projekt

Allgemein

Profil

« Zurück | Weiter » 

Revision fece0d1b

Von Moritz Bunkus vor fast 2 Jahren hinzugefügt

  • ID fece0d1bf7faaf2335ce487638ea8217767f5053
  • Vorgänger babc3c0a
  • Nachfolger 057d4622

Lieferantenauftrag→Einkaufslieferschein: Lieferantenartikelnummer anzeigen

Unterschiede anzeigen:

SL/Controller/Order.pm
44 44

  
45 45
use List::Util qw(first sum0);
46 46
use List::UtilsBy qw(sort_by uniq_by);
47
use List::MoreUtils qw(any none pairwise first_index);
47
use List::MoreUtils qw(uniq any none pairwise first_index);
48 48
use English qw(-no_match_vars);
49 49
use File::Spec;
50 50
use Cwd;
......
1546 1546
  $self->redirect_to(@redirect_params);
1547 1547
}
1548 1548

  
1549
sub action_show_conversion_to_purchase_delivery_order_item_selection {
1550
  my ($self) = @_;
1551

  
1552
  my @items = @{ $::form->{order}->{orderitems} // [] };
1553

  
1554
  if (@items) {
1555
    my @part_ids          = uniq map { $_->{parts_id} } @items;
1556
    my %parts_by_id       = map { ($_->id => $_) } @{ SL::DB::Manager::Part->get_all(where => [ id => \@part_ids ]) };
1557
    my %make_models_by_id = map { ($_->parts_id => $_->model) } @{
1558
      SL::DB::Manager::MakeModel->get_all(
1559
        where => [
1560
          parts_id => \@part_ids,
1561
          make     => $::form->{order}->{vendor_id},
1562
        ])
1563
    };
1564

  
1565
    foreach my $item (@items) {
1566
      $item->{partnumber}        = $parts_by_id{ $item->{parts_id} }->partnumber;
1567
      $item->{vendor_partnumber} = $make_models_by_id{ $item->{parts_id} };
1568
    }
1569
  }
1570

  
1571
  $self->render(
1572
    'order/tabs/_purchase_delivery_order_item_selection',
1573
    { layout => 0 },
1574
    ITEMS => \@items,
1575
  );
1576
}
1577

  
1549 1578
sub js_load_second_row {
1550 1579
  my ($self, $item, $item_id, $do_parse) = @_;
1551 1580

  
js/kivi.Order.js
62 62
    if (back_to_caller) data.push({ name: 'back_to_caller', value: '1' });
63 63
    if (params.convert_to_purchase_delivery_order_selected_items_only) data.push({ name: 'convert_to_purchase_delivery_order_selected_items_only', value: '1' });
64 64

  
65
    if (params.data)
66
      data = $.merge(data, params.data);
67

  
65 68
    $.post("controller.pl", data, kivi.eval_json_result);
66 69
  };
67 70

  
......
956 959
  };
957 960

  
958 961
  ns.convert_to_purchase_delivery_order_select_items = function(params) {
959
    $("#purchase_delivery_order_item_selection_checkall").attr("checked", "checked");
960

  
961
    var $src  = $("#row_table_id");
962
    var $dest = $("#convert_to_purchase_delivery_order_item_selection_items");
963

  
964
    $dest.data("params", params);
965
    $dest.empty();
966

  
967
    $("#row_table_id tbody>tr:first-child").each(function(idx, tr) {
968
      const $row        = $(tr);
969
      const partnumber  = $row.find("div[name=partnumber]").text().replaceAll(" ", "");
970
      const description = $row.find("input[name='order.orderitems[].description']").val();
971
      const qty         = $row.find("input[name='order.orderitems[].qty_as_number']").val();
972
      const unit        = $row.find("select[name='order.orderitems[].unit']").val();
973
      var html          =
974
          "<tr class=\"listrow\">" +
975
          "  <td><input type=\"checkbox\" name=\"purchase_delivery_order_item_selection_indexes[+]\" class=\"purchase_delivery_order_item_selection_checkall\" value=\"" + (idx + 1) + "\" checked=\"checked\"></td>" +
976
          "  <td align=\"right\" class=\"numeric\">" + (idx + 1) + "</td>" +
977
          "  <td>" + partnumber + "</td>" +
978
          "  <td>" + description + "</td>" +
979
          "  <td align=\"right\" class=\"numeric\">" + qty + "</td>" +
980
          "  <td>" + unit + "</td>" +
981
          "</tr>";
982

  
983
      $dest.append(html);
984
    });
962
    var data = $('#order_form').serializeArray();
963
    data.push({ name: 'action', value: 'Order/show_conversion_to_purchase_delivery_order_item_selection' });
985 964

  
986 965
    kivi.popup_dialog({
987
      id: "convert_to_purchase_delivery_order_item_selection",
988
      dialog: {
989
        title: kivi.t8("Select items for delivery order"),
966
      id:     "convert_to_purchase_delivery_order_item_selection",
967
      url:    "controller.pl",
968
      data:   data,
969
      type:   "POST",
970
      dialog: { title: kivi.t8("Select items for delivery order") },
971
      load:   function() {
972
        $("body").data("convert_to_purchase_delivery_order_item_selection_params", params);
990 973
      }
991 974
    });
992 975
  };
993 976

  
994 977
  ns.convert_to_purchase_delivery_order = function() {
995
    var $dlg = $("#convert_to_purchase_delivery_order_item_selection");
996
    $dlg.dialog('close');
997

  
998
    var params = $("#convert_to_purchase_delivery_order_item_selection_items").data("params");
978
    var params = $("body").data("convert_to_purchase_delivery_order_item_selection_params");
999 979
    params.convert_to_purchase_delivery_order_selected_items_only = 1;
1000 980

  
981
    var $dlg    = $("#convert_to_purchase_delivery_order_item_selection");
982
    params.data = $dlg.find("tbody input").serializeArray();
983

  
984
    $dlg.dialog('close');
1001 985
    $dlg.remove();
1002
    $('#order_form').append($dlg);
1003 986

  
1004 987
    kivi.Order.save(params);
1005 988
  };
templates/design40_webpages/order/form.html
68 68
</div>
69 69

  
70 70
</div><!-- /.tabwidget -->
71

  
72
 [% IF SELF.order.id && (FORM.type == 'purchase_order') %]
73
  [%- PROCESS 'order/tabs/_purchase_delivery_order_item_selection.html' %]
74
 [% END %]
75 71
</form>
templates/design40_webpages/order/tabs/_purchase_delivery_order_item_selection.html
1
[%- USE LxERP -%][%- USE L -%]
2
<div id="convert_to_purchase_delivery_order_item_selection">
3
  <div class="wrapper">
4
    [% L.button_tag("kivi.Order.convert_to_purchase_delivery_order()", LxERP.t8("Create delivery order")) %]
5
  </div>
1
[%- USE LxERP -%][%- USE L -%][%- USE HTML -%]
2
<div class="wrapper">
3
  [% L.button_tag("kivi.Order.convert_to_purchase_delivery_order()", LxERP.t8("Create delivery order")) %]
4
</div>
6 5

  
7
  <div class="wrapper">
8
    <table class="tbl-list">
9
      <thead>
10
        <tr class="listheading">
11
          <th>[% L.checkbox_tag("purchase_delivery_order_item_selection_checkall", checkall="input.purchase_delivery_order_item_selection_checkall") %]</th>
12
          <th>[% LxERP.t8("Position") %]</th>
13
          <th>[% LxERP.t8("Partnumber") %]</th>
14
          <th>[% LxERP.t8("Description") %]</th>
15
          <th>[% LxERP.t8("Qty") %]</th>
16
          <th>[% LxERP.t8("Unit") %]</th>
17
        </tr>
18
      </thead>
6
<div class="wrapper">
7
  <table class="tbl-list">
8
    <thead>
9
      <tr class="listheading">
10
        <th>[% L.checkbox_tag("purchase_delivery_order_item_selection_checkall", checkall="input.purchase_delivery_order_item_selection_checkall") %]</th>
11
        <th>[% LxERP.t8("Position") %]</th>
12
        <th>[% LxERP.t8("Partnumber") %]</th>
13
        <th>[% LxERP.t8("Vendor Part Number") %]</th>
14
        <th>[% LxERP.t8("Description") %]</th>
15
        <th>[% LxERP.t8("Qty") %]</th>
16
        <th>[% LxERP.t8("Unit") %]</th>
17
      </tr>
18
    </thead>
19 19

  
20
      <tbody id="convert_to_purchase_delivery_order_item_selection_items" class="row_entry listrow">
21
      </tbody>
22
    </table>
23
  </div>
20
    <tbody id="convert_to_purchase_delivery_order_item_selection_items" class="row_entry listrow">
21
      [% FOREACH item = ITEMS %]
22
        <tr class="listrow">
23
          <td>[% L.checkbox_tag("purchase_delivery_order_item_selection_indexes[+]", class="purchase_delivery_order_item_selection_checkall", value=loop.count, checked="checked") %]</td>
24
          <td class="numeric">[% loop.count %]</td>
25
          <td>[% HTML.escape(item.partnumber) %]</td>
26
          <td>[% HTML.escape(item.vendor_partnumber) %]</td>
27
          <td>[% HTML.escape(item.description) %]</td>
28
          <td class="numeric">[% HTML.escape(item.qty_as_number) %]</td>
29
          <td>[% HTML.escape(item.unit) %]</td>
30
        </tr>
31
      [% END %]
32
    </tbody>
33
  </table>
24 34
</div>
templates/webpages/order/form.html
67 67
    </div>
68 68

  
69 69
  </div>
70

  
71
 [% IF SELF.order.id && (FORM.type == 'purchase_order') %]
72
  [%- PROCESS 'order/tabs/_purchase_delivery_order_item_selection.html' %]
73
 [% END %]
74 70
</form>
templates/webpages/order/tabs/_purchase_delivery_order_item_selection.html
1
[%- USE LxERP -%][%- USE L -%]
2
<div id="convert_to_purchase_delivery_order_item_selection">
3
  <div>
4
    [% L.button_tag("kivi.Order.convert_to_purchase_delivery_order()", LxERP.t8("Create delivery order")) %]
5
  </div>
1
[%- USE LxERP -%][%- USE L -%][%- USE HTML -%]
2
<div>
3
  [% L.button_tag("kivi.Order.convert_to_purchase_delivery_order()", LxERP.t8("Create delivery order")) %]
4
</div>
6 5

  
7
  <div>
8
    <table>
9
      <thead>
10
        <tr class="listheading">
11
          <th>[% L.checkbox_tag("purchase_delivery_order_item_selection_checkall", checkall="input.purchase_delivery_order_item_selection_checkall") %]</th>
12
          <th>[% LxERP.t8("Position") %]</th>
13
          <th>[% LxERP.t8("Partnumber") %]</th>
14
          <th>[% LxERP.t8("Description") %]</th>
15
          <th>[% LxERP.t8("Qty") %]</th>
16
          <th>[% LxERP.t8("Unit") %]</th>
17
        </tr>
18
      </thead>
6
<div>
7
  <table>
8
    <thead>
9
      <tr class="listheading">
10
        <th>[% L.checkbox_tag("purchase_delivery_order_item_selection_checkall", checkall="input.purchase_delivery_order_item_selection_checkall", checked="checked") %]</th>
11
        <th>[% LxERP.t8("Position") %]</th>
12
        <th>[% LxERP.t8("Partnumber") %]</th>
13
        <th>[% LxERP.t8("Vendor Part Number") %]</th>
14
        <th>[% LxERP.t8("Description") %]</th>
15
        <th>[% LxERP.t8("Qty") %]</th>
16
        <th>[% LxERP.t8("Unit") %]</th>
17
      </tr>
18
    </thead>
19 19

  
20
      <tbody id="convert_to_purchase_delivery_order_item_selection_items">
20
    <tbody>
21
      [% FOREACH item = ITEMS %]
21 22
        <tr class="listrow">
22
          <td>[% L.checkbox_tag("purchase_delivery_order_item_selection_indexes[+]", class="purchase_delivery_order_item_selection_checkall", value="42", checked="checked") %]</td>
23
          <td>1</td>
24
          <td align="right">4</td>
25
          <td>Moo Cow Chunky Bacon</td>
26
          <td align="right">17,5</td>
27
          <td>Kuh</td>
23
          <td>[% L.checkbox_tag("purchase_delivery_order_item_selection_indexes[+]", class="purchase_delivery_order_item_selection_checkall", value=loop.count, checked="checked") %]</td>
24
          <td align="right">[% loop.count %]</td>
25
          <td>[% HTML.escape(item.partnumber) %]</td>
26
          <td>[% HTML.escape(item.vendor_partnumber) %]</td>
27
          <td>[% HTML.escape(item.description) %]</td>
28
          <td align="right">[% HTML.escape(item.qty_as_number) %]</td>
29
          <td>[% HTML.escape(item.unit) %]</td>
28 30
        </tr>
29
      </tbody>
30
    </table>
31
  </div>
31
      [% END %]
32
    </tbody>
33
  </table>
32 34
</div>

Auch abrufbar als: Unified diff