54 |
54 |
{ title => t8('Purchase Reclamation'), type => 'purchase_reclamation', model => 'Reclamation', number => 'record_number',},
|
55 |
55 |
{ title => t8('Purchase Invoice'), type => 'purchase_invoice', model => 'PurchaseInvoice', number => 'invnumber', },
|
56 |
56 |
{ title => t8('Letter'), type => 'letter', model => 'Letter', number => 'letternumber', description => 'subject', description_title => t8('Subject'), date => 'date', project => undef },
|
57 |
|
{ title => t8('Email'), type => 'email_journal', model => 'EmailJournal', number => 'id', description => 'subject', description_title => t8('Subject'), },
|
|
57 |
{ title => t8('Email'), type => 'email_journal', model => 'EmailJournal', number => 'id', description => 'subject', description_title => t8('Subject'), project => undef},
|
58 |
58 |
{ title => t8('AR Transaction'), type => 'ar_transaction', model => 'Invoice', number => 'invnumber', },
|
59 |
59 |
{ title => t8('AP Transaction'), type => 'ap_transaction', model => 'PurchaseInvoice', number => 'invnumber', },
|
60 |
60 |
{ title => t8('Dunning'), type => 'dunning', model => 'Dunning', number => 'dunning_id', },
|
61 |
|
{ title => t8('GL Transaction'), type => 'gl_transaction', model => 'GLTransaction', number => 'reference', },
|
|
61 |
{ title => t8('GL Transaction'), type => 'gl_transaction', model => 'GLTransaction', number => 'reference', project => undef},
|
62 |
62 |
);
|
63 |
63 |
|
64 |
64 |
my @link_types = map { +{ %link_type_defaults, %{ $_ } } } @link_type_specifics;
|
... | ... | |
126 |
126 |
my @link_type_select = map { [ $_->{type}, $_->{title} ] } @link_types;
|
127 |
127 |
my @projects = map { [ $_->id, $_->presenter->project(display => 'inline', style => 'both', no_link => 1) ] } @{ SL::DB::Manager::Project->get_all_sorted };
|
128 |
128 |
my $is_sales = $self->object->can('customer_id') && $self->object->customer_id;
|
|
129 |
my $is_purchase = $self->object->can('vendor_id') && $self->object->vendor_id;
|
129 |
130 |
|
130 |
131 |
$self->render(
|
131 |
132 |
'record_links/add_filter',
|
132 |
133 |
{ layout => 0 },
|
133 |
134 |
is_sales => $is_sales,
|
134 |
|
DEFAULT_LINK_TYPE => $is_sales ? 'sales_quotation' : 'request_quotation',
|
|
135 |
is_purchase => $is_purchase,
|
|
136 |
DEFAULT_LINK_TYPE => $is_sales ? 'sales_quotation' : $is_purchase ? 'request_quotation' : 'email_journal',
|
135 |
137 |
LINK_TYPES => \@link_type_select,
|
136 |
138 |
PROJECTS => \@projects,
|
137 |
139 |
);
|
... | ... | |
140 |
142 |
sub action_ajax_add_list {
|
141 |
143 |
my ($self) = @_;
|
142 |
144 |
|
|
145 |
my $class = 'SL::DB::' . $self->link_type_desc->{model};
|
143 |
146 |
my $manager = 'SL::DB::Manager::' . $self->link_type_desc->{model};
|
144 |
|
my $vc = $self->link_type =~ m/shop|sales_|^invoice|requirement_spec|letter|^ar_/ ? 'customer' : 'vendor';
|
|
147 |
my $vc = !($class->can('customer_id') || $class->can('vendor_id')) ? undef
|
|
148 |
: $self->link_type =~ m/shop|sales_|^invoice|requirement_spec|letter|^ar_/ ? 'customer'
|
|
149 |
: 'vendor';
|
145 |
150 |
my $project = $self->link_type_desc->{project};
|
146 |
151 |
my $project_id = "${project}_id";
|
147 |
152 |
my $description = $self->link_type_desc->{description};
|
... | ... | |
149 |
154 |
my $number = $self->link_type_desc->{number};
|
150 |
155 |
|
151 |
156 |
my @where = $filter && $manager->can($filter) ? $manager->$filter($self->link_type) : ();
|
152 |
|
push @where, ("${vc}.${vc}number" => { ilike => like($::form->{vc_number}) }) if $::form->{vc_number};
|
153 |
|
push @where, ("${vc}.name" => { ilike => like($::form->{vc_name}) }) if $::form->{vc_name};
|
|
157 |
push @where, ("${vc}.${vc}number" => { ilike => like($::form->{vc_number}) }) if $vc && $::form->{vc_number};
|
|
158 |
push @where, ("${vc}.name" => { ilike => like($::form->{vc_name}) }) if $vc && $::form->{vc_name};
|
154 |
159 |
push @where, ($description => { ilike => like($::form->{transaction_description}) }) if $::form->{transaction_description};
|
155 |
160 |
push @where, ($project_id => $::form->{globalproject_id}) if $::form->{globalproject_id} && $manager->can($project_id);
|
156 |
161 |
|
157 |
162 |
if ($::form->{number}) {
|
158 |
|
my $class = 'SL::DB::' . $self->link_type_desc->{model};
|
159 |
163 |
my $col_type = ref $class->meta->column($number);
|
160 |
164 |
if ($col_type =~ /^Rose::DB::Object::Metadata::Column::(?:Integer|Serial)$/) {
|
161 |
165 |
push @where, ($number => $::form->{number});
|
... | ... | |
164 |
168 |
}
|
165 |
169 |
}
|
166 |
170 |
|
167 |
|
my @with_objects = ($vc);
|
|
171 |
my @with_objects = ();
|
|
172 |
push @with_objects, $vc if $vc;
|
168 |
173 |
push @with_objects, $project if $manager->can($project_id);
|
169 |
174 |
|
170 |
175 |
# show the newest records first (should be better for 80% of the cases TODO sortable click
|
Verknüpfte Belege: Verknüpfungen hinzufügen: Kein Kunde/Lieferant/Projekt …
… als Filter anbieten, wenn nicht verfügbar im zu verknüpfenden Beleg.
Betrifft Emails und Dialogbuchungen