Revision 4943ad12
Von Cem Aydin vor etwa 1 Jahr hinzugefügt
SL/Controller/CustomerVendor.pm | ||
---|---|---|
851 | 851 |
$self->report_generator_list_objects(report => $report, objects => $prices, layout => 0, header => 0); |
852 | 852 |
} |
853 | 853 |
|
854 |
# open the dialog for customer/vendor details |
|
855 |
# called from SL::Presenter::customer_vendor |
|
856 |
sub action_show_customer_vendor_details_dialog { |
|
857 |
my ($self) = @_; |
|
858 |
|
|
859 |
my $is_customer = 'customer' eq $::form->{cv}; |
|
860 |
my $cv; |
|
861 |
if ($is_customer) { |
|
862 |
$cv = SL::DB::Customer->new(id => $::form->{cv_id})->load; |
|
863 |
} else { |
|
864 |
$cv = SL::DB::Vendor->new(id => $::form->{cv_id})->load; |
|
865 |
} |
|
866 |
|
|
867 |
my %details = map { $_ => $cv->$_ } @{$cv->meta->columns}; |
|
868 |
$details{discount_as_percent} = $cv->discount_as_percent; |
|
869 |
$details{creditlimt} = $cv->creditlimit_as_number; |
|
870 |
$details{business} = $cv->business->description if $cv->business; |
|
871 |
$details{language} = $cv->language_obj->description if $cv->language_obj; |
|
872 |
$details{delivery_terms} = $cv->delivery_term->description if $cv->delivery_term; |
|
873 |
$details{payment_terms} = $cv->payment->description if $cv->payment; |
|
874 |
$details{pricegroup} = $cv->pricegroup->pricegroup if $is_customer && $cv->pricegroup; |
|
875 |
|
|
876 |
if ($is_customer) { |
|
877 |
foreach my $entry (@{ $cv->additional_billing_addresses }) { |
|
878 |
push @{ $details{ADDITIONAL_BILLING_ADDRESSES} }, { map { $_ => $entry->$_ } @{$entry->meta->columns} }; |
|
879 |
} |
|
880 |
} |
|
881 |
foreach my $entry (@{ $cv->shipto }) { |
|
882 |
push @{ $details{SHIPTO} }, { map { $_ => $entry->$_ } @{$entry->meta->columns} }; |
|
883 |
} |
|
884 |
foreach my $entry (@{ $cv->contacts }) { |
|
885 |
push @{ $details{CONTACTS} }, { map { $_ => $entry->$_ } @{$entry->meta->columns} }; |
|
886 |
} |
|
887 |
|
|
888 |
$_[0]->render('common/show_vc_details', { layout => 0 }, |
|
889 |
is_customer => $is_customer, |
|
890 |
%details); |
|
891 |
|
|
892 |
} |
|
893 |
|
|
854 | 894 |
sub is_vendor { |
855 | 895 |
return $::form->{db} eq 'vendor'; |
856 | 896 |
} |
SL/Presenter/CustomerVendor.pm | ||
---|---|---|
3 | 3 |
use strict; |
4 | 4 |
|
5 | 5 |
use SL::Presenter::EscapedText qw(escape is_escaped); |
6 |
use SL::Presenter::Tag qw(input_tag html_tag name_to_id select_tag link_tag); |
|
6 |
use SL::Presenter::Tag qw(input_tag html_tag name_to_id select_tag link_tag img_tag);
|
|
7 | 7 |
|
8 | 8 |
use Exporter qw(import); |
9 | 9 |
our @EXPORT_OK = qw(customer_vendor customer vendor customer_vendor_picker customer_picker vendor_picker); |
... | ... | |
64 | 64 |
# do not use reserved html attribute 'type' for cv type |
65 | 65 |
$params{cv_type} = delete $params{type}; |
66 | 66 |
|
67 |
my $show_details = delete $params{show_details} // 0; |
|
68 |
|
|
67 | 69 |
my $ret = |
68 | 70 |
input_tag($name, (ref $value && $value->can('id') ? $value->id : ''), class => "@classes", type => 'hidden', id => $id, |
69 | 71 |
'data-customer-vendor-picker-data' => JSON::to_json(\%params), |
70 | 72 |
) . |
71 | 73 |
input_tag("", ref $value ? $value->displayable_name : '', id => "${id}_name", %params); |
72 | 74 |
|
75 |
if ($show_details) { |
|
76 |
$ret .= img_tag(src => 'image/detail.png', alt => $::locale->text('Show details'), |
|
77 |
title => $::locale->text('Show details'), class => "button-image info", |
|
78 |
onclick => "kivi.CustomerVendor.show_cv_details_dialog('#${id}', '$params{cv_type}')" ); |
|
79 |
|
|
80 |
$ret .= link_tag('javascript:;', $::locale->text('Edit'), |
|
81 |
title => $::locale->text('Open in new window'), |
|
82 |
onclick => "kivi.CustomerVendor.open_customervendor_tab('#${id}', '$params{cv_type}')" ); |
|
83 |
} |
|
84 |
|
|
73 | 85 |
$::request->layout->add_javascripts('kivi.CustomerVendor.js'); |
74 | 86 |
$::request->presenter->need_reinit_widgets($id); |
75 | 87 |
|
js/kivi.CustomerVendor.js | ||
---|---|---|
508 | 508 |
}); |
509 | 509 |
} |
510 | 510 |
|
511 |
this.check_cv = function(cv_id, input_element_id, cv_type) { |
|
512 |
if (cv_id === '' || $(input_element_id).val() === '') { |
|
513 |
if (cv_type === 'customer') { |
|
514 |
alert(kivi.t8('Please select a customer.')); |
|
515 |
} else { |
|
516 |
alert(kivi.t8('Please select a vendor.')); |
|
517 |
} |
|
518 |
return false; |
|
519 |
} |
|
520 |
return true; |
|
521 |
}; |
|
522 |
|
|
523 |
this.show_cv_details_dialog = function(id_selector, cv_type) { |
|
524 |
|
|
525 |
const input_element_id = `${id_selector}_name`; |
|
526 |
const cv_id = $(id_selector).val(); |
|
527 |
|
|
528 |
if (!this.check_cv(cv_id, input_element_id, cv_type)) return; |
|
529 |
|
|
530 |
kivi.popup_dialog({ |
|
531 |
url: 'controller.pl', |
|
532 |
data: { action: 'CustomerVendor/show_customer_vendor_details_dialog', |
|
533 |
type : $('#type').val(), |
|
534 |
cv : cv_type, |
|
535 |
cv_id : cv_id |
|
536 |
}, |
|
537 |
id: 'jq_customer_vendor_details_dialog', |
|
538 |
dialog: { |
|
539 |
title: cv_type === 'customer' ? kivi.t8('Customer details') : kivi.t8('Vendor details'), |
|
540 |
width: 800, |
|
541 |
height: 650 |
|
542 |
} |
|
543 |
}); |
|
544 |
return true; |
|
545 |
}; |
|
546 |
|
|
547 |
this.open_customervendor_tab = function(id_selector, cv_type) { |
|
548 |
const input_element_id = `${id_selector}_name`; |
|
549 |
const cv_id = $(id_selector).val(); |
|
550 |
|
|
551 |
if (!this.check_cv(cv_id, input_element_id, cv_type)) return; |
|
552 |
|
|
553 |
window.open("controller.pl?action=CustomerVendor/edit&db=" + encodeURIComponent(cv_type) + "&id=" + encodeURIComponent(cv_id), '_blank'); |
|
554 |
}; |
|
555 |
|
|
511 | 556 |
$(function(){ |
512 | 557 |
ns.init(); |
513 | 558 |
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