Projekt

Allgemein

Profil

« Zurück | Weiter » 

Revision 1363c4e5

Von Bernd Bleßmann vor fast 2 Jahren hinzugefügt

  • ID 1363c4e5722f0929aa91ae79cbe882d8589764f5
  • Vorgänger b37ac95d
  • Nachfolger 67743ce3

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

Unterschiede anzeigen:

SL/Controller/RecordLinks.pm
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
templates/webpages/record_links/add_filter.html
26 26
   <td>[% L.input_tag('number', '', style=style) %]</td>
27 27
  </tr>
28 28

  
29
  <tr>
29
  <tr class="record_links_add_filter_cv_row">
30 30
   <td>[%- LxERP.t8("Customer/Vendor Number") %]:</td>
31 31
   <td>[% L.input_tag('vc_number', is_sales ? SELF.object.customer.customernumber : SELF.object.vendor.vendornumber, style=style) %]</td>
32 32
  </tr>
33 33

  
34
  <tr>
34
  <tr class="record_links_add_filter_cv_row">
35 35
   <td>[%- LxERP.t8("Customer/Vendor Name") %]:</td>
36 36
   <td>[% L.input_tag('vc_name', is_sales ? SELF.object.customer.name : SELF.object.vendor.name, style=style) %]</td>
37 37
  </tr>
......
101 101
            : type == 'letter'           ? kivi.t8('Subject')
102 102
            :                              kivi.t8('Transaction description');
103 103

  
104
  if (type == 'letter') {
104
  if (type == 'letter' || type == 'email_journal' || type == 'gl_transaction') {
105 105
    $('#record_links_add_filter_project_row').hide();
106 106

  
107 107
  } else {
108 108
    $('#record_links_add_filter_project_row').show();
109 109
  }
110 110

  
111
  if (type == 'email_journal' || type == 'gl_transaction') {
112
    $('.record_links_add_filter_cv_row').hide();
113

  
114
  } else {
115
    $('.record_links_add_filter_cv_row').show();
116
  }
117

  
111 118
  $('#record_links_add_filter_title').html(title);
112 119
}
113 120
-->
templates/webpages/record_links/add_list.html
5 5
<table width="100%">
6 6
 <tr class="listheading">
7 7
  <th>[% L.checkbox_tag('record_links_check_all') %]</th>
8
  [% IF vc %]
8 9
  <th>[% IF vc == 'customer' %][%- LxERP.t8("Customer") %][%- ELSE %][%- LxERP.t8("Vendor") %][%- END %]</th>
10
  [% END %]
9 11
  <th>[%- LxERP.t8("Number") %]</th>
10 12
  [% IF date_column %]
11 13
   <th>[%- LxERP.t8("Date") %]</th>
......
19 21
 [%- FOREACH object = OBJECTS %]
20 22
 <tr class="listrow[% loop.count % 2 %]">
21 23
  <td>[% L.checkbox_tag('link_id[]', value=object.id) %]</td>
24
  [% IF vc %]
22 25
  <td>[%- HTML.escape(object.$vc.name) %]</td>
26
  [% END %]
23 27
  <td>[%- HTML.escape(object.$number_column) %]</td>
24 28
  [% IF date_column %]
25 29
   <td>[%- HTML.escape(object.$date_column.to_kivitendo) %]</td>

Auch abrufbar als: Unified diff