use Rose::Object::MakeMethods::Generic
(
scalar => [ qw(item_ids_to_delete) ],
- 'scalar --get_set_init' => [ qw(order valid_types type cv p multi_items_models all_price_factors) ],
+ 'scalar --get_set_init' => [ qw(order valid_types type cv p multi_items_models all_price_factors search_cvpartnumber) ],
);
->focus( '#order_' . $self->cv . '_id');
$self->js_redisplay_amounts_and_taxes;
+ $self->js_redisplay_cvpartnumbers;
$self->js->render();
}
$self->recalc();
+ $self->get_item_cvpartnumber($item);
+
my $item_id = join('_', 'new', Time::HiRes::gettimeofday(), int rand 1000000000000);
my $row_as_html = $self->p->render('order/tabs/_row',
- ITEM => $item,
- ID => $item_id,
- TYPE => $self->type,
- ALL_PRICE_FACTORS => $self->all_price_factors
+ ITEM => $item,
+ ID => $item_id,
+ TYPE => $self->type,
+ ALL_PRICE_FACTORS => $self->all_price_factors,
+ SEARCH_CVPARTNUMBER => $self->search_cvpartnumber,
);
$self->js
$self->order->add_items( $item );
$self->recalc();
+ $self->get_item_cvpartnumber($item);
my $item_id = join('_', 'new', Time::HiRes::gettimeofday(), int rand 1000000000000);
my $row_as_html = $self->p->render('order/tabs/_row',
- ITEM => $item,
- ID => $item_id,
- TYPE => $self->type,
- ALL_PRICE_FACTORS => $self->all_price_factors
+ ITEM => $item,
+ ID => $item_id,
+ TYPE => $self->type,
+ ALL_PRICE_FACTORS => $self->all_price_factors,
+ SEARCH_CVPARTNUMBER => $self->search_cvpartnumber,
);
$self->js
->append('#row_table_id', $row_as_html);
$self->recalc();
foreach my $item (@items) {
+ $self->get_item_cvpartnumber($item);
my $item_id = join('_', 'new', Time::HiRes::gettimeofday(), int rand 1000000000000);
my $row_as_html = $self->p->render('order/tabs/_row',
- ITEM => $item,
- ID => $item_id,
- TYPE => $self->type,
- ALL_PRICE_FACTORS => $self->all_price_factors
+ ITEM => $item,
+ ID => $item_id,
+ TYPE => $self->type,
+ ALL_PRICE_FACTORS => $self->all_price_factors,
+ SEARCH_CVPARTNUMBER => $self->search_cvpartnumber,
);
$self->js->append('#row_table_id', $row_as_html);
my ($self) = @_;
my %sort_keys = (
- partnumber => sub { $_[0]->part->partnumber },
- description => sub { $_[0]->description },
- qty => sub { $_[0]->qty },
- sellprice => sub { $_[0]->sellprice },
- discount => sub { $_[0]->discount },
+ partnumber => sub { $_[0]->part->partnumber },
+ description => sub { $_[0]->description },
+ qty => sub { $_[0]->qty },
+ sellprice => sub { $_[0]->sellprice },
+ discount => sub { $_[0]->discount },
+ cvpartnumber => sub { $_[0]->{cvpartnumber} },
);
+ $self->get_item_cvpartnumber($_) for @{$self->order->items_sorted};
+
my $method = $sort_keys{$::form->{order_by}};
my @to_sort = map { { old_pos => $_->position, order_by => $method->($_) } } @{ $self->order->items_sorted };
if ($::form->{sort_dir}) {
->insertBefore($self->build_tax_rows, '#amount_row_id');
}
+sub js_redisplay_cvpartnumbers {
+ my ($self) = @_;
+
+ $self->get_item_cvpartnumber($_) for @{$self->order->items_sorted};
+
+ my @data = map {[$_->{cvpartnumber}]} @{ $self->order->items_sorted };
+
+ $self->js
+ ->run('kivi.Order.redisplay_cvpartnumbers', \@data);
+}
+
sub js_reset_order_and_item_ids_after_save {
my ($self) = @_;
return $cv;
}
+sub init_search_cvpartnumber {
+ my ($self) = @_;
+
+ my $user_prefs = SL::Helper::UserPreferences::PartPickerSearch->new();
+ my $search_cvpartnumber;
+ $search_cvpartnumber = !!$user_prefs->get_sales_search_customer_partnumber() if $self->cv eq 'customer';
+ $search_cvpartnumber = !!$user_prefs->get_purchase_search_makemodel() if $self->cv eq 'vendor';
+
+ return $search_cvpartnumber;
+}
+
sub init_p {
SL::Presenter->get;
}
$self->{order_probabilities} = [ map { { title => ($_ * 10) . '%', id => $_ * 10 } } (0..10) ];
$self->{positions_scrollbar_height} = SL::Helper::UserPreferences::PositionsScrollbar->new()->get_height();
- my $user_prefs = SL::Helper::UserPreferences::PartPickerSearch->new();
- $self->{search_cvpartnumber} = !!$user_prefs->get_sales_search_customer_partnumber() if $self->cv eq 'customer';
- $self->{search_cvpartnumber} = !!$user_prefs->get_purchase_search_makemodel() if $self->cv eq 'vendor';
-
my $print_form = Form->new('');
$print_form->{type} = $self->type;
$print_form->{printers} = SL::DB::Manager::Printer->get_all_sorted;
} } @all_objects;
}
+ $self->get_item_cvpartnumber($_) for @{$self->order->items_sorted};
+
$::request->{layout}->use_javascript("${_}.js") for qw(kivi.SalesPurchase kivi.Order kivi.File ckeditor/ckeditor ckeditor/adapters/jquery edit_periodic_invoices_config calculate_qty);
$self->setup_edit_action_bar;
}
: '';
}
+sub get_item_cvpartnumber {
+ my ($self, $item) = @_;
+
+ if ($self->cv eq 'vendor') {
+ my @mms = grep { $_->make eq $self->order->customervendor->id } @{$item->part->makemodels};
+ $item->{cvpartnumber} = $mms[0]->model if scalar @mms;
+ } elsif ($self->cv eq 'customer') {
+ my @cps = grep { $_->customer_id eq $self->order->customervendor->id } @{$item->part->customerprices};
+ $item->{cvpartnumber} = $cps[0]->customer_partnumber if scalar @cps;
+ }
+}
+
sub sales_order_type {
'sales_order';
}
<th class="listheading" nowrap width="3" >[%- 'position' | $T8 %] </th>
<th class="listheading" style='text-align:center' nowrap width="1"><img src="image/updown.png" alt="[%- LxERP.t8('reorder item') %]"></th>
<th class="listheading" style='text-align:center' nowrap width="1"><img src="image/close.png" alt="[%- LxERP.t8('delete item') %]"></th>
- <th id="partnumber_header_id" class="listheading" nowrap width="15"><a href='#' onClick='javascript:kivi.Order.reorder_items("partnumber")'> [%- 'Partnumber' | $T8 %]</a></th>
- <th id="partclass_header_id" class="listheading" nowrap width="2">[%- 'Type' | $T8 %]</th>
- <th id="description_header_id" class="listheading" nowrap ><a href='#' onClick='javascript:kivi.Order.reorder_items("description")'>[%- 'Description' | $T8 %]</a></th>
+ <th id="partnumber_header_id" class="listheading" nowrap width="15"><a href='#' onClick='javascript:kivi.Order.reorder_items("partnumber")'> [%- 'Partnumber' | $T8 %]</a></th>
+ [%- IF SELF.search_cvpartnumber -%]
+ <th id="cvpartnumber_header_id" class="listheading" nowrap width="15"><a href='#' onClick='javascript:kivi.Order.reorder_items("cvpartnumber")' > [%- SELF.cv == "customer" ? LxERP.t8('Customer Part Number') : LxERP.t8('Model') %]</a></th>
+ [%- END -%]
+ <th id="partclass_header_id" class="listheading" nowrap width="2">[%- 'Type' | $T8 %]</th>
+ <th id="description_header_id" class="listheading" nowrap ><a href='#' onClick='javascript:kivi.Order.reorder_items("description")'>[%- 'Description' | $T8 %]</a></th>
[%- IF (SELF.type == "sales_order" || SELF.type == "purchase_order") -%]
- <th id="shipped_qty_header_id" class="listheading" nowrap width="5" ><a href='#' onClick='javascript:kivi.Order.reorder_items("shipped_qty")'>[%- 'Delivered' | $T8 %]</a></th>
+ <th id="shipped_qty_header_id" class="listheading" nowrap width="5" ><a href='#' onClick='javascript:kivi.Order.reorder_items("shipped_qty")'>[%- 'Delivered' | $T8 %]</a></th>
[%- END -%]
- <th id="qty_header_id" class="listheading" nowrap width="5" ><a href='#' onClick='javascript:kivi.Order.reorder_items("qty")'> [%- 'Qty' | $T8 %]</a></th>
+ <th id="qty_header_id" class="listheading" nowrap width="5" ><a href='#' onClick='javascript:kivi.Order.reorder_items("qty")'> [%- 'Qty' | $T8 %]</a></th>
<th class="listheading" nowrap width="5" >[%- 'Price Factor' | $T8 %] </th>
<th class="listheading" nowrap width="5" >[%- 'Unit' | $T8 %] </th>
<th class="listheading" nowrap width="5" >[%- 'Price Source' | $T8 %] </th>
</thead>
[%- FOREACH item = SELF.order.items_sorted %]
- [%- PROCESS order/tabs/_row.html ITEM=item ID=(item.id||item.new_fake_id) TYPE=SELF.type ALL_PRICE_FACTORS=SELF.all_price_factors %]
+ [%- PROCESS order/tabs/_row.html ITEM=item ID=(item.id||item.new_fake_id) TYPE=SELF.type ALL_PRICE_FACTORS=SELF.all_price_factors SEARCH_CVPARTNUMBER=SELF.search_cvpartnumber %]
[%- END %]
</table>