Projekt

Allgemein

Profil

« Zurück | Weiter » 

Revision 4d32ba10

Von Tamino Steinert vor 11 Monaten hinzugefügt

  • ID 4d32ba1005f8c76249130347f2039eb9759682f7
  • Vorgänger 9c42cae9
  • Nachfolger 45073f4d

EmailJournal: Belegvorlage zum Workflow hinzugefügt

Unterschiede anzeigen:

SL/Controller/EmailJournal.pm
87 87
      'purchase_credit_note',
88 88
    ],
89 89
  },
90
  RecordTemplate => {
91
    controller => '',
92
    class      => 'RecordTemplate',
93
    types => [
94
      'gl_transaction_template',
95
      'ar_transaction_template',
96
      'ap_transaction_template',
97
    ],
98
  }
90 99
);
91 100
my %RECORD_TYPE_TO_CONTROLLER =
92 101
  map {
......
110 119
    my $model = $RECORD_TYPE_TO_MODEL{$_};
111 120
    if (any {$model eq $_} qw(SL::DB::Invoice SL::DB::PurchaseInvoice)) {
112 121
      $_ => 'invnumber';
122
    } elsif (any {$model eq $_} qw(SL::DB::RecordTemplate)) {
123
      $_ => 'template_name';
113 124
    } else {
114 125
      my $type_data = SL::DB::Helper::TypeDataProxy->new($model, $_);
115 126
      $_ => $type_data->properties('nr_key');
......
121 132
  # TODO: what record types can be created, which are only available in workflows?
122 133
  my @record_types_with_info = ();
123 134
  for my $record_class ('SL::DB::Order', 'SL::DB::DeliveryOrder', 'SL::DB::Reclamation') {
124
    my $valid_types = "${record_class}::TypeData"->valid_types();
135
    my $type_data = "${record_class}::TypeData";
136
    my $valid_types = $type_data->valid_types();
125 137
    for my $type (@$valid_types) {
126

  
127
      my $type_data = SL::DB::Helper::TypeDataProxy->new($record_class, $type);
128 138
      push @record_types_with_info, {
129
        record_type    => $type,
130
        customervendor => $type_data->properties('customervendor'),
131
        text           => $type_data->text('type'),
139
        record_type     => $type,
140
        text            => $type_data->can('get3')->($type, 'text', 'type'),
141
        customervendor  => $type_data->can('get3')->($type, 'properties', 'customervendor'),
142
        workflow_needed => $type_data->can('get3')->($type, 'properties', 'worflow_needed'),
143
        can_workflow    => (
144
          any {
145
            $_ ne 'delete' && $type_data->can('get3')->($type, 'show_menu', $_)
146
          } keys %{$type_data->can('get')->($type, 'show_menu')}
147
        ),
132 148
      };
133 149
    }
134 150
  }
135 151
  push @record_types_with_info, (
136 152
    # invoice
137
    { record_type => 'invoice',                             customervendor => 'customer',  text => t8('Invoice') },
138
    { record_type => 'invoice_for_advance_payment',         customervendor => 'customer',  text => t8('Invoice for Advance Payment')},
139
    { record_type => 'invoice_for_advance_payment_storno',  customervendor => 'customer',  text => t8('Storno Invoice for Advance Payment')},
140
    { record_type => 'final_invoice',                       customervendor => 'customer',  text => t8('Final Invoice')},
141
    { record_type => 'invoice_storno',                      customervendor => 'customer',  text => t8('Storno Invoice')},
142
    { record_type => 'credit_note',                         customervendor => 'customer',  text => t8('Credit Note')},
143
    { record_type => 'credit_note_storno',                  customervendor => 'customer',  text => t8('Storno Credit Note')},
144
    { record_type => 'ar_transaction',                      customervendor => 'customer',  text => t8('AR Transaction')},
153
    { record_type => 'invoice',                            customervendor => 'customer', workflow_needed => 0, can_workflow => 1, text => t8('Invoice') },
154
    { record_type => 'invoice_for_advance_payment',        customervendor => 'customer', workflow_needed => 0, can_workflow => 1, text => t8('Invoice for Advance Payment')},
155
    { record_type => 'invoice_for_advance_payment_storno', customervendor => 'customer', workflow_needed => 1, can_workflow => 1, text => t8('Storno Invoice for Advance Payment')},
156
    { record_type => 'final_invoice',                      customervendor => 'customer', workflow_needed => 1, can_workflow => 1, text => t8('Final Invoice')},
157
    { record_type => 'invoice_storno',                     customervendor => 'customer', workflow_needed => 1, can_workflow => 1, text => t8('Storno Invoice')},
158
    { record_type => 'credit_note',                        customervendor => 'customer', workflow_needed => 0, can_workflow => 1, text => t8('Credit Note')},
159
    { record_type => 'credit_note_storno',                 customervendor => 'customer', workflow_needed => 1, can_workflow => 1, text => t8('Storno Credit Note')},
145 160
    # purchase invoice
146
    { record_type => 'purchase_invoice',      customervendor => 'vendor',  text => t8('Purchase Invoice')},
147
    { record_type => 'purchase_credit_note',  customervendor => 'vendor',  text => t8('Purchase Credit Note')},
148
    { record_type => 'ap_transaction',        customervendor => 'vendor',  text => t8('AP Transaction')},
161
    { record_type => 'purchase_invoice',      customervendor => 'vendor', workflow_needed => 0, can_workflow => 1, text => t8('Purchase Invoice')},
162
    { record_type => 'purchase_credit_note',  customervendor => 'vendor', workflow_needed => 0, can_workflow => 1, text => t8('Purchase Credit Note')},
163
    # transactions
164
    # TODO: create gl_transaction with email
165
    # { record_type => 'gl_transaction', customervendor => 'customer', workflow_needed => 0, can_workflow => 0, text => t8('GL Transaction')},
166
    # { record_type => 'gl_transaction', customervendor => 'vendor',   workflow_needed => 0, can_workflow => 0, text => t8('GL Transaction')},
167
    { record_type => 'ar_transaction', customervendor => 'customer', workflow_needed => 0, can_workflow => 1, text => t8('AR Transaction')},
168
    { record_type => 'ap_transaction', customervendor => 'vendor',   workflow_needed => 0, can_workflow => 1, text => t8('AP Transaction')},
169
    # templates
170
    { record_type => 'gl_transaction_template', is_template => 1, customervendor => 'customer', workflow_needed => 0, can_workflow => 0, text => t8('GL Transaction')},
171
    { record_type => 'gl_transaction_template', is_template => 1, customervendor => 'vendor',   workflow_needed => 0, can_workflow => 0, text => t8('GL Transaction')},
172
    { record_type => 'ar_transaction_template', is_template => 1, customervendor => 'customer', workflow_needed => 0, can_workflow => 0, text => t8('AR Transaction')},
173
    { record_type => 'ap_transaction_template', is_template => 1, customervendor => 'vendor',   workflow_needed => 0, can_workflow => 0, text => t8('AP Transaction')},
149 174
  );
150 175
  return @record_types_with_info;
151 176
}
152 177

  
153
sub record_types_for_customer_vendor_type {
154
  my ($self, $customer_vendor_type) = @_;
155
  return [ map { $_->{record_type} } grep { $_->{customervendor} eq $customer_vendor_type } $self->get_record_types_with_info ];
178
sub record_types_for_customer_vendor_type_and_action {
179
  my ($self, $customer_vendor_type, $action) = @_;
180
  return [
181
    map { $_->{record_type} }
182
    grep {
183
      ($_->{customervendor} eq $customer_vendor_type)
184
      && ($action eq 'workflow_record' ? $_->{can_workflow} : 1)
185
      && ($action eq 'create_new'      ? $_->{workflow_needed} : 1)
186
      && ($action eq 'linking_record'  ? $_->{record_type} !~ /_template$/ : 1)
187
      && ($action eq 'template_record' ? $_->{record_type} =~ /_template$/ : 1)
188
    }
189
    $self->get_record_types_with_info()
190
  ];
156 191
}
157 192

  
158 193
#
......
192 227
  my $customer_vendor = $self->find_customer_vendor_from_email($self->entry);
193 228
  my $cv_type = $customer_vendor && $customer_vendor->is_vendor ? 'vendor' : 'customer';
194 229

  
195
  my $record_types = $self->record_types_for_customer_vendor_type($cv_type);
230
  my $record_types = $self->record_types_for_customer_vendor_type_and_action($cv_type, 'workflow_record');
196 231
  my @records = $self->get_records_for_types(
197 232
    $record_types,
198 233
    customer_vendor_type => $cv_type,
......
227 262
    my $manager = $RECORD_TYPE_TO_MANAGER{$record_type};
228 263
    my $model = $RECORD_TYPE_TO_MODEL{$record_type};
229 264
    my %additional_where = ();
230
    if ($cv_type && $cv_id) {
265
    if ($cv_type && $cv_id && $record_type !~ /^gl_transaction/) {
231 266
      $additional_where{"${cv_type}_id"} = $cv_id;
232 267
    }
233 268
    if ($record_number) {
......
392 427
  $::auth->assert('email_journal');
393 428
  my $customer_vendor_type = $::form->{customer_vendor_selection};
394 429
  my $customer_vendor_id   = $::form->{"${customer_vendor_type}_id"};
395
  my $record_type          = $::form->{"${customer_vendor_type}_record_type_selection"};
430
  my $action               = $::form->{action_selection};
431
  my $record_type          = $::form->{"${customer_vendor_type}_${action}_type_selection"};
396 432
  my $record_number        = $::form->{record_number};
397 433
  my $with_closed          = $::form->{with_closed};
398 434

  
399
  $record_type ||= $self->record_types_for_customer_vendor_type($customer_vendor_type);
435
  $record_type ||= $self->record_types_for_customer_vendor_type_and_action($customer_vendor_type, $action);
400 436

  
401 437
  my @records = $self->get_records_for_types(
402 438
    $record_type,
......
423 459
    id => 'record_list',
424 460
  );
425 461

  
426

  
427 462
  $self->js->replaceWith('#record_list', $new_div);
428 463
  $self->js->hide('#record_toggle_closed') if scalar @records < 20;
429 464
  $self->js->show('#record_toggle_open')   if scalar @records < 20;
js/kivi.EmailJournal.js
10 10
    $.post("controller.pl", data, kivi.eval_json_result);
11 11
  }
12 12

  
13
  ns.update_customer_vendor_selection = function() {
13
  ns.update_email_workflow_options = function() {
14 14
    let customer_vendor = $('#customer_vendor_selection').val();
15

  
16
    $('#customer_div').hide();
17
    $('#customer_record_types_div').hide();
18
    $('#vendor_div').hide();
19
    $('#vendor_record_types_div').hide();
20

  
21
    if (customer_vendor == 'customer') {
22
      $('#customer_div').show();
23
      $('#customer_record_types_div').show();
24
    } else { // if (customer_vendor == 'vendor')
25
      $('#vendor_div').show();
26
      $('#vendor_record_types_div').show();
27
    }
28
    kivi.EmailJournal.update_record_list();
29
  }
30

  
31
  ns.update_action_selection = function() {
32 15
    let record_action = $('#action_selection').val();
33 16

  
17
    // Hide all div
18
    ['customer', 'vendor'].forEach(function(cv) {
19
      $(`#${cv}_div`).hide();
20
      ['workflow_record', 'template_record', 'linking_record', 'new_record'].forEach(function(action) {
21
        $(`#${cv}_${action}_types_div`).hide();
22

  
23
      });
24
    });
25
    $('#new_record_div').hide();
26
    $('#template_record_div').hide();
34 27
    $('#record_selection_div').hide();
35
    $('#create_new_div').hide();
36 28

  
37
    if (record_action == 'create_new') {
38
      $('#create_new_div').show();
39
      $('#create_new_div').css('display','inline-block')
29
    // Enable needed div
30
    $(`#${customer_vendor}_div`).show();
31
    $(`#${customer_vendor}_${record_action}_types_div`).show();
32
    if (record_action == 'new_record') {
33
      $('#new_record_div').show();
34
      $('#new_record_div').css('display','inline-block')
40 35
    } else {
41 36
      $('#record_selection_div').show();
37
      kivi.EmailJournal.update_record_list();
42 38
    }
43 39
  }
44 40

  
locale/de/all
914 914
  'Create customers and vendors. Edit all vendors. Edit only customers where salesman equals employee (login)' => 'Kunden und Lieferanten erfassen. Alle Lieferanten bearbeiten. Nur Kunden bearbeiten bei denen der Verkäufer gleich Bearbeiter (login) ist',
915 915
  'Create delivery order'       => 'Lieferschein erstellen',
916 916
  'Create first invoice on'     => 'Erste Rechnung erzeugen am',
917
  'Create from Record Template' => 'Mit Belegvorlage erstellen',
917 918
  'Create from Workflow'        => 'Workflow weiterführen von',
918 919
  'Create invoice'              => 'Buchung erstellen',
919 920
  'Create invoice?'             => 'Rechnung erstellen?',
locale/en/all
914 914
  'Create customers and vendors. Edit all vendors. Edit only customers where salesman equals employee (login)' => '',
915 915
  'Create delivery order'       => '',
916 916
  'Create first invoice on'     => '',
917
  'Create from Record Template' => '',
917 918
  'Create from Workflow'        => '',
918 919
  'Create invoice'              => '',
919 920
  'Create invoice?'             => '',
templates/design40_webpages/email_journal/show.html
70 70
      <div id="action_div" class="col">
71 71
      [% L.select_tag('action_selection',
72 72
         [
73
           {value => "workflow",   name => LxERP.t8("Create from Workflow")},
74
           {value => "linking",    name => LxERP.t8("Linking to Record")},
75
           {value => "create_new", name => LxERP.t8("Create new")},
73
           {value => "workflow_record", name => LxERP.t8("Create from Workflow")},
74
           {value => "linking_record",  name => LxERP.t8("Linking to Record")},
75
           {value => "new_record",      name => LxERP.t8("Create new")},
76
           {value => "template_record", name => LxERP.t8("Create from Record Template")},
76 77
         ],
77 78
         value_key='value', title_key='name',
78 79
         class="wi-normal",
79
         onchange='kivi.EmailJournal.update_action_selection();'
80
         onchange='kivi.EmailJournal.update_email_workflow_options();'
80 81
         ) %]
81 82
      </div>
82 83

  
......
89 90
         default = CV_TYPE_FOUND,
90 91
         value_key='value', title_key='name',
91 92
         class="wi-verysmall",
92
         onchange='kivi.EmailJournal.update_customer_vendor_selection();'
93
         onchange='kivi.EmailJournal.update_email_workflow_options();'
93 94
         ) %]
94 95
      </div>
95 96

  
96 97
      [% FOREACH customer_vendor = ['customer', 'vendor'] %]
97
      <div id="[% customer_vendor _ "_record_types_div" %]" class="col"
98
      <div id="[% customer_vendor _ "_workflow_record_types_div" %]" class="col"
98 99
        style=[% IF customer_vendor == CV_TYPE_FOUND %] "display:block" [% ELSE %] "display:none" [% END %]
99 100
        >
100 101

  
101 102
        [%
102 103
          SET options = [];
103 104
          FOREACH record_info = RECORD_TYPES_WITH_INFO;
104
            IF (record_info.customervendor == customer_vendor);
105
            IF (record_info.customervendor == customer_vendor && record_info.can_workflow && !record_info.is_template);
105 106
              options.push({value => record_info.record_type, name => record_info.text});
106 107
            END;
107 108
          END;
108 109
        %]
109
      [% L.select_tag(customer_vendor _ '_record_type_selection',
110
      [% L.select_tag(customer_vendor _ '_workflow_record_type_selection',
111
         options,
112
         value_key='value', title_key='name',
113
         with_empty=1, empty_value='', empty_title=LxERP.t8("Select record type"),
114
         onchange='kivi.EmailJournal.update_record_list();'
115
         ) %]
116
      </div>
117
      <div id="[% customer_vendor _ "_new_record_types_div" %]" class="col"
118
        style="display:none"
119
        >
120
        [%
121
          SET options = [];
122
          FOREACH record_info = RECORD_TYPES_WITH_INFO;
123
            IF (record_info.customervendor == customer_vendor && !record_info.workflow_needed && !record_info.is_template);
124
              options.push({value => record_info.record_type, name => record_info.text});
125
            END;
126
          END;
127
        %]
128
      [% L.select_tag(customer_vendor _ '_new_record_type_selection',
129
         options,
130
         value_key='value', title_key='name',
131
         with_empty=1, empty_value='', empty_title=LxERP.t8("Select record type"),
132
         onchange='kivi.EmailJournal.update_record_list();'
133
         ) %]
134
      </div>
135
      <div id="[% customer_vendor _ "_linking_record_types_div" %]" class="col"
136
        style="display:none"
137
        >
138
        [%
139
          SET options = [];
140
          FOREACH record_info = RECORD_TYPES_WITH_INFO;
141
            IF (record_info.customervendor == customer_vendor && !record_info.is_template);
142
              options.push({value => record_info.record_type, name => record_info.text});
143
            END;
144
          END;
145
        %]
146
      [% L.select_tag(customer_vendor _ '_linking_record_type_selection',
147
         options,
148
         value_key='value', title_key='name',
149
         with_empty=1, empty_value='', empty_title=LxERP.t8("Select record type"),
150
         onchange='kivi.EmailJournal.update_record_list();'
151
         ) %]
152
      </div>
153

  
154

  
155
      <div id="[% customer_vendor _ "_template_record_types_div" %]" class="col"
156
        style="display:none"
157
        >
158
        [%
159
          SET options = [];
160
          FOREACH record_info = RECORD_TYPES_WITH_INFO;
161
            IF (record_info.customervendor == customer_vendor && record_info.is_template);
162
              options.push({value => record_info.record_type, name => record_info.text});
163
            END;
164
          END;
165
        %]
166
      [% L.select_tag(customer_vendor _ '_template_record_type_selection',
110 167
         options,
111 168
         value_key='value', title_key='name',
112 169
         with_empty=1, empty_value='', empty_title=LxERP.t8("Select record type"),
......
217 274

  
218 275
<script type="text/javascript">
219 276
  $(document).ready(function() {
220
    kivi.EmailJournal.update_action_selection();
221
    kivi.EmailJournal.update_customer_vendor_selection();
277
    kivi.EmailJournal.update_email_workflow_options();
222 278
    kivi.EmailJournal.update_record_list();
223 279
    kivi.EmailJournal.update_attachment_preview();
224 280
  });

Auch abrufbar als: Unified diff