Revision 544a7573
Von Werner Hahn vor mehr als 1 Jahr hinzugefügt
SL/Controller/DispositionManager.pm | ||
---|---|---|
8 | 8 |
use SL::DB::PurchaseBasketItem; |
9 | 9 |
use SL::PriceSource; |
10 | 10 |
use SL::Locale::String qw(t8); |
11 |
use SL::Helper::Flash qw(flash); |
|
12 |
|
|
11 | 13 |
use Data::Dumper; |
12 | 14 |
|
13 | 15 |
sub action_list_parts { |
... | ... | |
28 | 30 |
my $basket_part = SL::DB::PurchaseBasketItem->new( |
29 | 31 |
parts_id => $part->id, |
30 | 32 |
qty => $part->ordersize, # was ist wenn order_size < (rop-onhand) ist? sollte dann nicht (rop-onhand) genommen werden? |
31 |
orderer => SL::DB::Manager::Employee->current;
|
|
33 |
orderer => SL::DB::Manager::Employee->current,
|
|
32 | 34 |
)->save; |
33 | 35 |
} |
34 | 36 |
$self->action_show_basket; |
... | ... | |
38 | 40 |
sub action_show_basket { |
39 | 41 |
my ( $self ) = @_; |
40 | 42 |
|
41 |
$::request->{layout}->add_javascripts('kivi.DispositionManager.js'); |
|
43 |
$::request->{layout}->add_javascripts('kivi.DispositionManager.js', 'kivi.PartDetail.js');
|
|
42 | 44 |
my $basket_items = SL::DB::Manager::PurchaseBasketItem->get_all( query => [ cleared => 'F' ], with_objects => [ 'part', 'part.makemodels' ]); |
43 | 45 |
$self->_setup_show_basket_action_bar; |
44 | 46 |
$self->render('disposition_manager/show_purchase_basket', BASKET_ITEMS => $basket_items, title => "Purchase basket" ); |
45 | 47 |
} |
46 | 48 |
|
49 |
sub action_show_vendor_items { |
|
50 |
my ( $self ) = @_; |
|
51 |
|
|
52 |
my $makemodels_parts = SL::DB::Manager::Part->get_all( query => [ 'makemodels.make' => $::form->{v_id}, '!id' => ['5599'], ], sort_by => 'onhand', with_objects => [ 'makemodels' ]); |
|
53 |
$self->render('disposition_manager/_show_vendor_parts', { layout => 0 }, MAKEMODEL_ITEMS => $makemodels_parts); |
|
54 |
} |
|
55 |
|
|
47 | 56 |
sub action_transfer_to_purchase_order { |
48 | 57 |
|
49 | 58 |
my ( $self ) = @_; |
50 | 59 |
require SL::DB::Order; |
51 | 60 |
require SL::DB::OrderItem; |
52 |
require SL::DB::Part; |
|
53 | 61 |
require SL::DB::Vendor; |
54 | 62 |
my @error_report; |
55 | 63 |
|
64 |
unless (($::form->{ids} && scalar @{ $::form->{ids}}) || ( $::form->{vendor_part_ids} && scalar @{ $::form->{vendor_part_ids}})) { |
|
65 |
die 'There are no items selected'; |
|
66 |
} |
|
56 | 67 |
my $v_id = $::form->{vendor_ids}->[0] ; |
57 | 68 |
|
58 | 69 |
my ($vendor, $employee); |
59 | 70 |
$vendor = SL::DB::Manager::Vendor->find_by(id => $v_id) or die "Can't find vendor"; |
60 | 71 |
$employee = SL::DB::Manager::Employee->current or die "Can't find employee"; |
61 | 72 |
|
62 |
my $basket_items = SL::DB::Manager::PurchaseBasketItem->get_all( query => [ id => \@{ $::form->{ids} } ] ); |
|
73 |
|
|
74 |
my $basket_items; |
|
75 |
$basket_items = SL::DB::Manager::PurchaseBasketItem->get_all( query => [ id => \@{ $::form->{ids} } ] ) if ($::form->{ids} && scalar @{ $::form->{ids}}); |
|
76 |
|
|
77 |
my $vendor_items; |
|
78 |
$vendor_items = SL::DB::Manager::Part->get_all( query => [ id => \@{ $::form->{vendor_part_ids} } ] ) if ($::form->{vendor_part_ids} && scalar @{ $::form->{vendor_part_ids}}); |
|
63 | 79 |
|
64 | 80 |
# create order first so we have a record for PriceSource |
65 | 81 |
my $order = SL::DB::Order->new( |
... | ... | |
76 | 92 |
my $i = 0; |
77 | 93 |
my @items; |
78 | 94 |
|
79 |
foreach my $basket_item ( @{ $basket_items } ) { |
|
80 |
$i++; |
|
81 |
my $mm = SL::DB::Manager::MakeModel->get_first( query => [ make => $vendor->id, parts_id => $basket_item->parts_id] ); |
|
82 |
|
|
83 |
my $current_order_item = SL::DB::OrderItem->new( |
|
84 |
part => $basket_item->part, |
|
85 |
description => $basket_item->part->description, |
|
86 |
qty => $basket_item->qty || 1, |
|
87 |
unit => $basket_item->part->unit, |
|
88 |
position => $i, |
|
89 |
); |
|
95 |
if ($::form->{ids} && scalar @{ $::form->{ids}}) { |
|
96 |
foreach my $basket_item ( @{ $basket_items } ) { |
|
97 |
$i++; |
|
98 |
|
|
99 |
my $current_order_item = SL::DB::OrderItem->new( |
|
100 |
part => $basket_item->part, |
|
101 |
description => $basket_item->part->description, |
|
102 |
qty => $basket_item->part->min_order_qty || 1, |
|
103 |
unit => $basket_item->part->unit, |
|
104 |
position => $i, |
|
105 |
orderer_id => $basket_item->orderer->id, |
|
106 |
); |
|
107 |
|
|
108 |
my $price_source = SL::PriceSource->new(record_item => $current_order_item, record => $order); |
|
109 |
$current_order_item->sellprice($price_source->best_price->price); |
|
110 |
$current_order_item->active_price_source($price_source->best_price->source); |
|
111 |
push(@items, $current_order_item); |
|
112 |
} |
|
113 |
} |
|
90 | 114 |
|
91 |
my $price_source = SL::PriceSource->new(record_item => $current_order_item, record => $order); |
|
92 |
$current_order_item->sellprice($price_source->best_price->price); |
|
93 |
$current_order_item->active_price_source($price_source->best_price->source); |
|
94 |
push(@items, $current_order_item); |
|
115 |
if ($::form->{vendor_part_ids} && scalar @{ $::form->{vendor_part_ids}}) { |
|
116 |
foreach my $vendor_item ( @{ $vendor_items } ) { |
|
117 |
$i++; |
|
118 |
|
|
119 |
my $current_order_item = SL::DB::OrderItem->new( |
|
120 |
part => $vendor_item, |
|
121 |
description => $vendor_item->description, |
|
122 |
qty => $vendor_item->min_order_qty || 1, |
|
123 |
unit => $vendor_item->unit, |
|
124 |
position => $i, |
|
125 |
orderer_id => $employee->id, |
|
126 |
); |
|
127 |
|
|
128 |
my $price_source = SL::PriceSource->new(record_item => $current_order_item, record => $order); |
|
129 |
$current_order_item->sellprice($price_source->best_price->price); |
|
130 |
$current_order_item->active_price_source($price_source->best_price->source); |
|
131 |
push(@items, $current_order_item); |
|
132 |
} |
|
95 | 133 |
} |
96 | 134 |
|
97 | 135 |
$order->orderitems( [ @items ] ); |
136 |
|
|
98 | 137 |
$order->db->with_transaction( sub { |
99 | 138 |
$order->calculate_prices_and_taxes; |
100 | 139 |
$order->save; |
... | ... | |
112 | 151 |
$item->{custom_variables} = \@{ $item->cvars_by_config }; |
113 | 152 |
$item->save; |
114 | 153 |
} |
115 |
SL::DB::Manager::PurchaseBasketItem->delete_all( where => [ id => \@{ $::form->{ids} }]); |
|
154 |
SL::DB::Manager::PurchaseBasketItem->delete_all( where => [ id => \@{ $::form->{ids} }]) if ($::form->{ids} && scalar @{ $::form->{ids}});
|
|
116 | 155 |
return 1; |
117 | 156 |
}) || die "error: " . $order->db->error; |
118 | 157 |
$self->redirect_to(controller => "oe.pl", action => 'edit', type => 'purchase_order', vc => 'vendor', id => $order->id); |
... | ... | |
153 | 192 |
$bar->add( |
154 | 193 |
action => [ |
155 | 194 |
t8('Reload'), |
156 |
submit => [ '#purchasebasket', { action => "DispositionManager/show_basket" } ],
|
|
195 |
link => $self->url_for(controller => 'DispositionManager', action => 'show_basket'),
|
|
157 | 196 |
], |
158 | 197 |
action => [ |
159 | 198 |
t8('Action'), |
... | ... | |
218 | 257 |
|
219 | 258 |
Shows a list with parts which are in the basket. |
220 | 259 |
This list can be filtered by vendor. Then you can create a purchase order. |
260 |
When filtered by vendor, a table with the parts from the vendor of the purchase basket and |
|
261 |
a table with all parts from the vendor will be shown. From there you can mark |
|
262 |
the parts and create an order |
|
221 | 263 |
|
222 | 264 |
=item C<action_transfer_to_purchase_order> |
223 | 265 |
|
SL/DB/Part.pm | ||
---|---|---|
581 | 581 |
|
582 | 582 |
foreach my $mm ( @{$_[0]->makemodels} ){ |
583 | 583 |
my $vendor = SL::DB::Manager::Vendor->get_first( where => [ id => $mm->make ] ); |
584 |
my @tmp = ({ title => $vendor->name . " (" . $::form->format_amount(\%::myconfig, $mm->lastcost, 2) . ")", value => $vendor->{id} }); |
|
584 |
my @tmp = ({ title => $vendor->vendornumber . "--" .$vendor->name . " (" . $::form->format_amount(\%::myconfig, $mm->lastcost, 2) . ")", value => $vendor->{id} });
|
|
585 | 585 |
push @vendor_dd, @tmp; |
586 | 586 |
} |
587 | 587 |
return \@vendor_dd; |
js/kivi.DispositionManager.js | ||
---|---|---|
1 | 1 |
namespace('kivi.DispositionManager', function(ns) { |
2 | 2 |
ns.sort_vendors = function() { |
3 |
ns.display_vendor_parts($('#vendor_id2').val()); |
|
3 | 4 |
$("table tr").each(function(index) { |
4 | 5 |
if ( index !== 0 ) { |
5 | 6 |
$row = $(this); |
6 |
//alert( $row.find("select[name='vendor_ids[]']").val() + '!=' + $('#cv_id').val()); |
|
7 |
if( $row.find("select[name='vendor_ids[]']").val() != $('#cv_id').val()) { |
|
7 |
if( $row.find("select[name='vendor_ids[]']").val() != $('#vendor_id2').val()) { |
|
8 | 8 |
$row.remove(); |
9 | 9 |
} |
10 | 10 |
} |
11 | 11 |
}); |
12 | 12 |
} |
13 |
|
|
14 |
ns.display_vendor_parts = function(vendor_id) { |
|
15 |
var url = 'controller.pl?action=DispositionManager/show_vendor_items&v_id=' + vendor_id; |
|
16 |
$('#vendor_parts').load(url); |
|
17 |
} |
|
18 |
|
|
13 | 19 |
ns.create_order = function() { |
14 | 20 |
var data = $('#purchasebasket').serializeArray(); |
15 | 21 |
data.push({ name: 'action', value: 'DispositionManager/transfer_to_purchase_order' }); |
16 |
|
|
17 | 22 |
$.post("controller.pl", data, kivi.eval_json_result); |
18 | 23 |
} |
24 |
|
|
25 |
ns.show_detail_dialog = function(part_id,partnumber) { |
|
26 |
if ( part_id && partnumber ) { |
|
27 |
var title = kivi.t8('Details of article number "#1"',[partnumber]); |
|
28 |
kivi.popup_dialog({ |
|
29 |
url: 'controller.pl', |
|
30 |
data: { |
|
31 |
action: 'Part/showdetails', |
|
32 |
id : part_id, |
|
33 |
}, |
|
34 |
id: 'detail_menu', |
|
35 |
dialog: { title: title |
|
36 |
, width: 1000 |
|
37 |
, height: 450 |
|
38 |
, modal: false } |
|
39 |
}); |
|
40 |
} |
|
41 |
return true; |
|
42 |
}; |
|
19 | 43 |
}); |
sql/Pg-upgrade2/hmo_purchase_basket.sql | ||
---|---|---|
1 |
-- @tag: hmo_purchase_basket |
|
2 |
-- @description: Änderungen HMO für Dispositionsmanager. Neue Spalte Besteller in orderitems und delivery_order_items |
|
3 |
-- @depends: purchase_basket |
|
4 |
-- @ignore: 0 |
|
5 |
|
|
6 |
ALTER TABLE purchase_basket_items DROP COLUMN description; |
|
7 |
ALTER TABLE purchase_basket_items ADD COLUMN orderer_id INTEGER REFERENCES employee(id); |
|
8 |
ALTER TABLE orderitems ADD COLUMN orderer_id INTEGER REFERENCES employee(id); |
|
9 |
ALTER TABLE delivery_order_items ADD COLUMN orderer_id INTEGER REFERENCES employee(id); |
templates/webpages/disposition_manager/_show_vendor_parts.html | ||
---|---|---|
1 |
[%- USE HTML -%][%- USE LxERP -%][%- USE L -%][%- USE T8 -%][% USE P %] |
|
2 |
[% USE Dumper %] |
|
3 |
<h2>[% 'All parts of vendor odered by onhand' | $T8 %]</h2> |
|
4 |
<table width="100%"> |
|
5 |
<thead> |
|
6 |
<tr class="listheading"> |
|
7 |
<th>[% 'Purchase basket' | $T8 %] </th> |
|
8 |
<th>[% 'Partnumber' | $T8 %] </th> |
|
9 |
<th>[% 'Description' | $T8 %] </th> |
|
10 |
<th>[% 'Onhand / Ordered' | $T8 %] </th> |
|
11 |
<th>[% 'Rop' | $T8 %] </th> |
|
12 |
<th>[% 'Order quantity' | $T8 %] </th> |
|
13 |
<th>[% 'Vendor' | $T8 %] </th> |
|
14 |
</tr> |
|
15 |
</thead> |
|
16 |
<tbody> |
|
17 |
[% FOREACH makemodel_item = MAKEMODEL_ITEMS %] |
|
18 |
|
|
19 |
[% # Dumper.dump_html('TEST') %] |
|
20 |
[% # Dumper.dump_html(basket_item) %] |
|
21 |
[% SET select_size = basket_item.part.vendor_dropdown.size %] |
|
22 |
<tr class="listrow"> |
|
23 |
<td>[% L.checkbox_tag('vendor_part_ids[+]', checked = '0', value=makemodel_item.id) %]</td> |
|
24 |
<td>[% HTML.escape(makemodel_item.partnumber) %] |
|
25 |
[% IF makemodel_item.id %] |
|
26 |
<img class="odbuttons" onclick="kivi.DispositionManager.show_detail_dialog('[% makemodel_item.id %]','[% makemodel_item.partnumber %]')" src="image/icons/svg/information.svg" |
|
27 |
title="[% 'Article details' | $T8 %]"> |
|
28 |
[% END %] |
|
29 |
</td> |
|
30 |
<td>[% HTML.escape(makemodel_item.description) %]</td> |
|
31 |
<td class="numeric">[% makemodel_item.onhand_as_number %] / [% makemodel_item.get_ordered_qty %]</td> |
|
32 |
<td class="numeric">[% makemodel_item.rop_as_number %] </td> |
|
33 |
<td class="numeric">[% makemodel_item.qty_as_number %] </td> |
|
34 |
<td>[% L.select_tag('vendor_ids[]', makemodel_item.vendor_dropdown, value_key = 'value', title_key = 'title', default = makemodel_item.makemodels.item(0).make, size = select_size, style='width: 350px;' ) %]</td> |
|
35 |
</tr> |
|
36 |
[% END %] |
|
37 |
</tbody> |
|
38 |
</table> |
templates/webpages/disposition_manager/show_purchase_basket.html | ||
---|---|---|
4 | 4 |
<h1>[% title %]</h1> |
5 | 5 |
[% # Dumper.dump_html(BASKET_ITEMS) %] |
6 | 6 |
<form id="purchasebasket" style="margin:1em;"> |
7 |
[% P.customer_vendor.picker('vendor_id2', '', type='vendor', fat_set_item=1) %]<br> |
|
8 |
<div>id from change: <span id='change3'></span></div> |
|
9 |
[% L.hidden_tag('cv_id', '') %] |
|
7 |
[% P.customer_vendor.picker('vendor_id2', '', type='vendor') %]<br> |
|
8 |
<div> |
|
10 | 9 |
<table id="baskettable" width="100%"> |
11 | 10 |
<thead> |
12 | 11 |
<tr class="listheading"> |
13 |
<th>[% L.checkbox_tag('check_all') %][% 'Purchase basket' | $T8 %] </th>
|
|
12 |
<th>[% L.checkbox_tag("", id="check_all", checkall="[data-checkall=1]") %][% 'Purchase basket' | $T8 %] </th>
|
|
14 | 13 |
<th>[% 'Partnumber' | $T8 %] </th> |
15 | 14 |
<th>[% 'Description' | $T8 %] </th> |
16 | 15 |
<th>[% 'Onhand' | $T8 %] </th> |
... | ... | |
27 | 26 |
[% SET select_size = basket_item.part.vendor_dropdown.size %] |
28 | 27 |
[% # IF !basket_item.part.get_ordered_qty(part.id) %] |
29 | 28 |
<tr class="listrow"> |
30 |
<td>[% L.checkbox_tag('ids[+]', checked = '1', value=basket_item.id) %]</td> |
|
31 |
<td>[% HTML.escape(basket_item.part.partnumber) %] </td> |
|
29 |
<td>[% L.checkbox_tag('ids[+]', "data-checkall"=1, checked = '1', value=basket_item.id) %]</td> |
|
30 |
<td>[% HTML.escape(basket_item.part.partnumber) %] |
|
31 |
[% IF basket_item.part.id %] |
|
32 |
<img class="odbuttons" onclick="kivi.DispositionManager.show_detail_dialog('[% basket_item.part.id %]','[% basket_item.part.partnumber %]')" src="image/icons/svg/information.svg" |
|
33 |
title="[% 'Article details' | $T8 %]"> |
|
34 |
[% END %] |
|
35 |
</td> |
|
32 | 36 |
<td>[% HTML.escape(basket_item.part.description) %]</td> |
33 | 37 |
<td class="numeric">[% basket_item.part.onhand_as_number %] </td> |
34 | 38 |
<td class="numeric">[% basket_item.part.rop_as_number %] </td> |
... | ... | |
39 | 43 |
[% END %] |
40 | 44 |
</tbody> |
41 | 45 |
</table> |
46 |
</div> |
|
47 |
<hr> |
|
48 |
|
|
49 |
<div id="vendor_parts"></div> |
|
42 | 50 |
</form> |
43 | 51 |
<hr> |
44 | 52 |
<script type="text/javascript"> |
45 | 53 |
<!-- |
46 | 54 |
|
47 |
$('#vendor_id2').change(function() { $('#change3').html($('#vendor_id2').val()) }) |
|
48 |
$('#vendor_id2').on('set_item:CustomerVendorPicker', function(e,o) { |
|
49 |
$('#cv_id').val(o.id) |
|
55 |
$('#vendor_id2').change('set_item:CustomerVendorPicker', function(e,o) { |
|
50 | 56 |
kivi.DispositionManager.sort_vendors(); |
51 | 57 |
}) |
52 |
$(function() { |
|
53 |
$('#check_all').checkall('INPUT[name^="id"]'); |
|
54 |
}); |
|
55 | 58 |
--> |
56 | 59 |
</script> |
Auch abrufbar als: Unified diff
Dispositionsmanager Zusätzliche Artikel des Lieferanten anzeigen