Revision 80d3ef8f
Von Cem Aydin vor mehr als 1 Jahr hinzugefügt
SL/Controller/CustomerVendor.pm | ||
---|---|---|
$self->report_generator_list_objects(report => $report, objects => $prices, layout => 0, header => 0);
|
||
}
|
||
|
||
# open the dialog for customer/vendor details
|
||
# called from SL::Presenter::customer_vendor
|
||
sub action_show_customer_vendor_details_dialog {
|
||
my ($self) = @_;
|
||
|
||
my $is_customer = 'customer' eq $::form->{cv};
|
||
my $cv;
|
||
if ($is_customer) {
|
||
$cv = SL::DB::Customer->new(id => $::form->{cv_id})->load;
|
||
} else {
|
||
$cv = SL::DB::Vendor->new(id => $::form->{cv_id})->load;
|
||
}
|
||
|
||
my %details = map { $_ => $cv->$_ } @{$cv->meta->columns};
|
||
$details{discount_as_percent} = $cv->discount_as_percent;
|
||
$details{creditlimt} = $cv->creditlimit_as_number;
|
||
$details{business} = $cv->business->description if $cv->business;
|
||
$details{language} = $cv->language_obj->description if $cv->language_obj;
|
||
$details{delivery_terms} = $cv->delivery_term->description if $cv->delivery_term;
|
||
$details{payment_terms} = $cv->payment->description if $cv->payment;
|
||
$details{pricegroup} = $cv->pricegroup->pricegroup if $is_customer && $cv->pricegroup;
|
||
|
||
if ($is_customer) {
|
||
foreach my $entry (@{ $cv->additional_billing_addresses }) {
|
||
push @{ $details{ADDITIONAL_BILLING_ADDRESSES} }, { map { $_ => $entry->$_ } @{$entry->meta->columns} };
|
||
}
|
||
}
|
||
foreach my $entry (@{ $cv->shipto }) {
|
||
push @{ $details{SHIPTO} }, { map { $_ => $entry->$_ } @{$entry->meta->columns} };
|
||
}
|
||
foreach my $entry (@{ $cv->contacts }) {
|
||
push @{ $details{CONTACTS} }, { map { $_ => $entry->$_ } @{$entry->meta->columns} };
|
||
}
|
||
|
||
$_[0]->render('common/show_vc_details', { layout => 0 },
|
||
is_customer => $is_customer,
|
||
%details);
|
||
|
||
}
|
||
|
||
sub is_vendor {
|
||
return $::form->{db} eq 'vendor';
|
||
}
|
SL/Presenter/CustomerVendor.pm | ||
---|---|---|
use strict;
|
||
|
||
use SL::Presenter::EscapedText qw(escape is_escaped);
|
||
use SL::Presenter::Tag qw(input_tag html_tag name_to_id select_tag link_tag);
|
||
use SL::Presenter::Tag qw(input_tag html_tag name_to_id select_tag link_tag img_tag);
|
||
|
||
use Exporter qw(import);
|
||
our @EXPORT_OK = qw(customer_vendor customer vendor customer_vendor_picker customer_picker vendor_picker);
|
||
... | ... | |
# do not use reserved html attribute 'type' for cv type
|
||
$params{cv_type} = delete $params{type};
|
||
|
||
my $show_details = delete $params{show_details} // 0;
|
||
|
||
my $ret =
|
||
input_tag($name, (ref $value && $value->can('id') ? $value->id : ''), class => "@classes", type => 'hidden', id => $id,
|
||
'data-customer-vendor-picker-data' => JSON::to_json(\%params),
|
||
) .
|
||
input_tag("", ref $value ? $value->displayable_name : '', id => "${id}_name", %params);
|
||
|
||
if ($show_details) {
|
||
$ret .= img_tag(src => 'image/detail.png', alt => $::locale->text('Show details'),
|
||
title => $::locale->text('Show details'), class => "button-image info",
|
||
onclick => "kivi.CustomerVendor.show_cv_details_dialog('#${id}', '$params{cv_type}')" );
|
||
|
||
$ret .= link_tag('javascript:;', $::locale->text('Edit'),
|
||
title => $::locale->text('Open in new window'),
|
||
onclick => "kivi.CustomerVendor.open_customervendor_tab('#${id}', '$params{cv_type}')" );
|
||
}
|
||
|
||
$::request->layout->add_javascripts('kivi.CustomerVendor.js');
|
||
$::request->presenter->need_reinit_widgets($id);
|
||
|
js/kivi.CustomerVendor.js | ||
---|---|---|
});
|
||
}
|
||
|
||
this.check_cv = function(cv_id, input_element_id, cv_type) {
|
||
if (cv_id === '' || $(input_element_id).val() === '') {
|
||
if (cv_type === 'customer') {
|
||
alert(kivi.t8('Please select a customer.'));
|
||
} else {
|
||
alert(kivi.t8('Please select a vendor.'));
|
||
}
|
||
return false;
|
||
}
|
||
return true;
|
||
};
|
||
|
||
this.show_cv_details_dialog = function(id_selector, cv_type) {
|
||
|
||
const input_element_id = `${id_selector}_name`;
|
||
const cv_id = $(id_selector).val();
|
||
|
||
if (!this.check_cv(cv_id, input_element_id, cv_type)) return;
|
||
|
||
kivi.popup_dialog({
|
||
url: 'controller.pl',
|
||
data: { action: 'CustomerVendor/show_customer_vendor_details_dialog',
|
||
type : $('#type').val(),
|
||
cv : cv_type,
|
||
cv_id : cv_id
|
||
},
|
||
id: 'jq_customer_vendor_details_dialog',
|
||
dialog: {
|
||
title: cv_type === 'customer' ? kivi.t8('Customer details') : kivi.t8('Vendor details'),
|
||
width: 800,
|
||
height: 650
|
||
}
|
||
});
|
||
return true;
|
||
};
|
||
|
||
this.open_customervendor_tab = function(id_selector, cv_type) {
|
||
const input_element_id = `${id_selector}_name`;
|
||
const cv_id = $(id_selector).val();
|
||
|
||
if (!this.check_cv(cv_id, input_element_id, cv_type)) return;
|
||
|
||
window.open("controller.pl?action=CustomerVendor/edit&db=" + encodeURIComponent(cv_type) + "&id=" + encodeURIComponent(cv_id), '_blank');
|
||
};
|
||
|
||
$(function(){
|
||
ns.init();
|
||
ns.price_list_init();
|
Auch abrufbar als: Unified diff
Kunden/Lieferanten Presenter: Details als Option zum picker hinzugefügt
- Option show_details zeigt Info Popup sowie Link zum bearbeiten an
- möglicher Einsatz bei Angebot, Aufträgen, Rechnungen ect., sowie Debitoren-/Kreditorenbuchung