use SL::DB::Note;
use SL::DB::PaymentTerm;
use SL::DB::Pricegroup;
+use SL::DB::Price;
use SL::DB::Contact;
use SL::DB::FollowUp;
use SL::DB::FollowUpLink;
'update',
'ajaj_get_shipto',
'ajaj_get_contact',
+ 'ajax_list_prices',
]
);
$_[0]->render('customer_vendor/test_page');
}
+sub action_ajax_list_prices {
+ my ($self, %params) = @_;
+
+ my $report = SL::ReportGenerator->new(\%::myconfig, $::form);
+ my @columns = qw(partnumber description price);
+ my @visible = qw(partnumber description price);
+ my @sortable = qw(partnumber description price);
+
+ my %column_defs = (
+ partnumber => { text => $::locale->text('Part Number'), sub => sub { $_[0]->parts->partnumber } },
+ description => { text => $::locale->text('Part Description'), sub => sub { $_[0]->parts->description } },
+ price => { text => $::locale->text('Price'), sub => sub { $::form->format_amount(\%::myconfig, $_[0]->price, 2) }, align => 'right' },
+ );
+
+ $::form->{sort_by} ||= 'partnumber';
+ $::form->{sort_dir} //= 1;
+
+ for my $col (@sortable) {
+ $column_defs{$col}{link} = $self->url_for(
+ action => 'ajax_list_prices',
+ callback => $::form->{callback},
+ db => $::form->{db},
+ id => $self->{cv}->id,
+ sort_by => $col,
+ sort_dir => ($::form->{sort_by} eq $col ? 1 - $::form->{sort_dir} : $::form->{sort_dir})
+ );
+ }
+
+ map { $column_defs{$_}{visible} = 1 } @visible;
+
+ my $pricegroup;
+ $pricegroup = $self->{cv}->pricegroup->pricegroup if $self->{cv}->pricegroup;
+
+ $report->set_columns(%column_defs);
+ $report->set_column_order(@columns);
+ $report->set_options(allow_pdf_export => 0, allow_csv_export => 0);
+ $report->set_sort_indicator($::form->{sort_by}, $::form->{sort_dir});
+ $report->set_export_options(@{ $params{report_generator_export_options} || [] });
+ $report->set_options(
+ %{ $params{report_generator_options} || {} },
+ output_format => 'HTML',
+ top_info_text => $::locale->text('Pricegroup') . ': ' . $pricegroup,
+ title => $::locale->text('Price List'),
+ );
+
+ my $sort_param = $::form->{sort_by} eq 'price' ? 'price' :
+ $::form->{sort_by} eq 'description' ? 'parts.description' :
+ 'parts.partnumber';
+ $sort_param .= ' ' . ($::form->{sort_dir} ? 'ASC' : 'DESC');
+ my $prices = SL::DB::Manager::Price->get_all(where => [ pricegroup_id => $self->{cv}->pricegroup_id ],
+ sort_by => $sort_param,
+ with_objects => 'parts');
+
+ $self->report_generator_list_objects(report => $report, objects => $prices, layout => 0, header => 0);
+}
+
sub is_vendor {
return $::form->{db} eq 'vendor';
}
ns.reinit_widgets();
}
+ ns.get_price_report = function(target, source, data) {
+ $.ajax({
+ url: source,
+ success: function (rsp) {
+ $(target).html(rsp);
+ $(target).find('a.report-generator-header-link').click(function(event){ ns.price_report_redirect_event(event, target) });
+ },
+ });
+ };
+
+ ns.price_report_redirect_event = function (event, target) {
+ event.preventDefault();
+ ns.get_price_report(target, event.target + '');
+ };
+
+ ns.price_list_init = function () {
+ $("#customer_vendor_tabs").on('tabsbeforeactivate', function(event, ui){
+ if (ui.newPanel.attr('id') == 'price_list') {
+ ns.get_price_report('#price_list', "controller.pl?action=CustomerVendor/ajax_list_prices&id=" + $('#cv_id').val() + "&db=" + $('#db').val() + "&callback=" + $('#callback').val());
+ }
+ return 1;
+ });
+
+ $("#customer_vendor_tabs").on('tabscreate', function(event, ui){
+ if (ui.panel.attr('id') == 'price_list') {
+ ns.get_price_report('#price_list', "controller.pl?action=CustomerVendor/ajax_list_prices&id=" + $('#cv_id').val() + "&db=" + $('#db').val() + "&callback=" + $('#callback').val());
+ }
+ return 1;
+ });
+ }
+
$(function(){
ns.init();
+ ns.price_list_init();
});
});
'Price #1' => 'Preis #1',
'Price Factor' => 'Preisfaktor',
'Price Factors' => 'Preisfaktoren',
+ 'Price List' => 'Preisliste',
'Price Rule' => 'Preisregel',
'Price Rules' => 'Preisregeln',
'Price Source' => 'Preisquelle',
<li><a href="#price_rules">[% 'Price Rules' | $T8 %]</a></li>
[% END %]
+ [% IF ( SELF.cv.id && SELF.cv.pricegroup_id && AUTH.assert('part_service_assembly_details', 1) ) %]
+ <li><a href="#price_list">[% 'Price List' | $T8 %]</a></li>
+ [% END %]
+
[% IF SELF.cv.id %]
[% IF ( FORM.db == 'customer' && AUTH.assert('show_extra_record_tab_customer',1) ) %]
<li><a href="[% 'controller.pl?action=CustomerVendorTurnover/list_turnover&id=' _ SELF.cv.id _ '&db=' _ FORM.db %]">[% LxERP.t8('Records') %]
[% IF SELF.cv.id %]
[% PROCESS "customer_vendor/tabs/price_rules.html" %]
[% END %]
+ [% IF ( SELF.cv.id && SELF.cv.pricegroup_id && AUTH.assert('part_service_assembly_details', 1) ) %]
+ [% PROCESS "customer_vendor/tabs/price_list.html" %]
+ [% END %]
</div>
</form>