Projekt

Allgemein

Profil

« Zurück | Weiter » 

Revision 3a8be1b7

Von Tamino Steinert vor etwa 1 Jahr hinzugefügt

  • ID 3a8be1b7fa19297314bfdf99f9b898986d1df9f1
  • Vorgänger 9734325f
  • Nachfolger 39aa38b2

EmailJournal: Templates überarbeitet und Verknüpfte Belege hinzugefügt

Unterschiede anzeigen:

SL/Controller/EmailJournal.pm
8 8
use SL::DB::Employee;
9 9
use SL::DB::EmailJournal;
10 10
use SL::DB::EmailJournalAttachment;
11
use SL::DB::Order;
12 11
use SL::Helper::Flash;
13
use SL::Locale::String;
12
use SL::Locale::String qw(t8);
14 13
use SL::System::TaskServer;
15 14
use SL::Presenter::EmailJournal;
16 15

  
16
use SL::DB::Order;
17
use SL::DB::Order::TypeData;
18
use SL::DB::DeliveryOrder;
19
use SL::DB::DeliveryOrder::TypeData;
20
use SL::DB::Reclamation;
21
use SL::DB::Reclamation::TypeData;
22
use SL::DB::Invoice;
23
use SL::DB::PurchaseInvoice;
24

  
25
use SL::DB::Manager::Customer;
26
use SL::DB::Manager::Vendor;
27

  
17 28
use Rose::Object::MakeMethods::Generic
18 29
(
19 30
  scalar                  => [ qw(entry) ],
......
24 35
__PACKAGE__->run_before('add_js');
25 36

  
26 37
my %RECORD_TYPES_INFO = (
27
  # Order
28 38
  Order => {
29 39
    controller => 'Order',
30 40
    model      => 'SL::DB::Order',
41
    types => SL::DB::Order::TypeData->valid_types(),
42
  },
43
  DeliveryOrder => {
44
    controller => 'DeliveryOrder',
45
    model      => 'SL::DB::DeliveryOrder',
46
    types => SL::DB::DeliveryOrder::TypeData->valid_types(),
47
  },
48
  Reclamation => {
49
    controller => 'Reclamation',
50
    model      => 'SL::DB::Reclamation',
51
    types => SL::DB::Reclamation::TypeData->valid_types(),
52
  },
53
  Invoice => {
54
    controller => 'ar.pl',
55
    model      => 'SL::DB::Invoice',
56
    types => [
57
      'ar_transaction',
58
      'invoice',
59
      'invoice_for_advance_payment',
60
      'invoice_for_advance_payment_storno',
61
      'final_invoice',
62
      'invoice_storno',
63
      'credit_note',
64
      'credit_note_storno',
65
    ],
66
  },
67
  PurchaseInvoice => {
68
    controller => 'ap.pl',
69
    model      => 'SL::DB::PurchaseInvoice',
31 70
    types => [
32
      'purchase_order',
33
      'purchase_quotation_intake',
34
      'request_quotation',
35
      'sales_order',
36
      'sales_order_intake',
37
      'sales_quotation',
71
      'ap_transaction',
72
      'purchase_invoice',
73
      'purchase_credit_note',
38 74
    ],
39 75
  },
40 76
);
......
81 117
    $::form->error(t8('You do not have permission to access this entry.'));
82 118
  }
83 119

  
120
  my @record_types_with_info = ();
121
  for my $record_class ('SL::DB::Order', 'SL::DB::DeliveryOrder', 'SL::DB::Reclamation') {
122
    my $valid_types = "${record_class}::TypeData"->valid_types();
123
    for my $type (@$valid_types) {
124

  
125
      my $type_data = SL::DB::Helper::TypeDataProxy->new($record_class, $type);
126
      push @record_types_with_info, {
127
        record_type    => $type,
128
        customervendor => $type_data->properties('customervendor'),
129
        text           => $type_data->text('type'),
130
      };
131
    }
132
  }
133
  push @record_types_with_info, (
134
    # invoice
135
    { record_type => 'ar_transaction'                    ,  customervendor => 'customer',  text => t8('AR Transaction')},
136
    { record_type => 'invoice'                           ,  customervendor => 'customer',  text => t8('Invoice') },
137
    { record_type => 'invoice_for_advance_payment'       ,  customervendor => 'customer',  text => t8('Invoice for Advance Payment')},
138
    { record_type => 'invoice_for_advance_payment_storno',  customervendor => 'customer',  text => t8('Storno Invoice for Advance Payment')},
139
    { record_type => 'final_invoice'                     ,  customervendor => 'customer',  text => t8('Final Invoice')},
140
    { record_type => 'invoice_storno'                    ,  customervendor => 'customer',  text => t8('Storno Invoice')},
141
    { record_type => 'credit_note'                       ,  customervendor => 'customer',  text => t8('Credit Note')},
142
    { record_type => 'credit_note_storno'                ,  customervendor => 'customer',  text => t8('Storno Credit Note')},
143
    # purchase invoice
144
    { record_type => 'ap_transaction'      ,  customervendor => 'vendor',  text => t8('AP Transaction')},
145
    { record_type => 'purchase_invoice'    ,  customervendor => 'vendor',  text => t8('Purchase Invoice')},
146
    { record_type => 'purchase_credit_note',  customervendor => 'vendor',  text => t8('Purchase Credit Note')},
147
  );
148

  
149
  my $customer_vendor = $self->find_customer_vendor_from_email($self->entry);
150

  
84 151
  $self->setup_show_action_bar;
85
  $self->render('email_journal/show',
86
                title   => $::locale->text('View email'),
87
                back_to => $back_to);
152
  $self->render(
153
    'email_journal/show',
154
    title    => $::locale->text('View email'),
155
    CUSTOMER_VENDOR => , $customer_vendor,
156
    CV_TYPE_FOUND => $customer_vendor && $customer_vendor->is_vendor ? 'vendor' : 'customer',
157
    RECORD_TYPES_WITH_INFO => \@record_types_with_info,
158
    back_to  => $back_to
159
  );
88 160
}
89 161

  
90 162
sub action_show_attachment {
......
123 195

  
124 196
sub action_apply_record_action {
125 197
  my ($self) = @_;
126
  my $email_journal_id = $::form->{email_journal_id};
127
  my $attachment_id = $::form->{attachment_id};
128
  my $record_action = $::form->{record_action};
129
  my $vendor_id = $::form->{vendor_id};
130
  my $customer_id = $::form->{customer_id};
131

  
132
  if ( $record_action =~ s/^link_// ) { # remove prefix
133

  
134
    # Load record
135
    my $record_type = $record_action;
136
    my $record_id = $::form->{$record_type . "_id"};
137
    my $record_type_model = $RECORD_TYPE_TO_MODEL{$record_type};
138
    my $record = $record_type_model->new(id => $record_id)->load;
139
    my $email_journal = SL::DB::EmailJournal->new(id => $email_journal_id)->load;
140

  
141
    if ($attachment_id) {
142
      my $attachment = SL::DB::EmailJournalAttachment->new(id => $attachment_id)->load;
143
      $attachment->add_file_to_record($record);
144
    }
145

  
146
    $email_journal->link_to_record($record);
147

  
148
    return $self->js->flash('info',  $::locale->text('Linked to e-mail ') . $record->displayable_name)->render();
198
  my $email_journal_id   = $::form->{email_journal_id};
199
  my $attachment_id      = $::form->{attachment_id};
200
  my $customer_vendor    = $::form->{customer_vendor_selection};
201
  my $customer_vendor_id = $::form->{"${customer_vendor}_id"};
202
  my $action             = $::form->{action_selection};
203
  my $record_type        = $::form->{"${customer_vendor}_record_type_selection"};
204
  my $record_id          = $::form->{"${record_type}_id"};
205

  
206
  if ($action eq 'linking') {
207
    return $self->link_and_add_attachment_to_record({
208
        email_journal_id    => $email_journal_id,
209
        attachment_id       => $attachment_id,
210
        record_type         => $record_type,
211
        record_id           => $record_id,
212
      });
149 213
  }
150 214

  
151 215
  my %additional_params = ();
152
  if ( $record_action =~ s/^customer_// ) {  # remove prefix
153
    $additional_params{customer_id} = $customer_id;
154
  } elsif ( $record_action =~ s/^vendor_// ) { # remove prefix
155
    $additional_params{vendor_id} = $vendor_id;
216
  if ($action eq 'create_new') {
217
    $additional_params{action} = 'add_from_email_journal';
218
    $additional_params{"${customer_vendor}_id"} = $customer_vendor_id;
219
  } else {
220
    $additional_params{action} = 'edit_from_email_journal';
221
    $additional_params{id} = $record_id;
156 222
  }
157
  $additional_params{type} = $record_action;
158
  $additional_params{controller} = $RECORD_TYPE_TO_CONTROLLER{$record_action};
159 223

  
160 224
  $self->redirect_to(
161
    action              => 'add_from_email_journal',
225
    controller          => $RECORD_TYPE_TO_CONTROLLER{$record_type},
226
    type                => $record_type,
162 227
    from_id             => $email_journal_id,
163 228
    from_type           => 'email_journal',
164 229
    email_attachment_id => $attachment_id,
......
198 263
# helpers
199 264
#
200 265

  
201
sub find_cv_from_email {
202
  my ($self, $cv_type, $email_journal) = @_;
266
sub link_and_add_attachment_to_record {
267
 my ($self, $params) = @_;
268

  
269
  my $email_journal_id   = $params->{email_journal_id};
270
  my $attachment_id      = $params->{attachment_id};
271
  my $record_type        = $params->{record_type};
272
  my $record_id          = $params->{record_id};
273

  
274
  my $record_type_model = $RECORD_TYPE_TO_MODEL{$record_type};
275
  my $record = $record_type_model->new(id => $record_id)->load;
276
  my $email_journal = SL::DB::EmailJournal->new(id => $email_journal_id)->load;
277

  
278
  if ($attachment_id) {
279
    my $attachment = SL::DB::EmailJournalAttachment->new(id => $attachment_id)->load;
280
    $attachment->add_file_to_record($record);
281
  }
282

  
283
  $email_journal->link_to_record($record);
284

  
285
  return $self->js->flash('info',  $::locale->text('Linked e-mail and attachment to ') . $record->displayable_name)->render();
286
}
287

  
288
sub find_customer_vendor_from_email {
289
  my ($self, $email_journal, $cv_type) = @_;
203 290
  my $email_address = $email_journal->from;
291
  $email_address =~ s/.*<(.*)>/$1/; # address can look like "name surname <email_address>"
204 292

  
205
  # search for customer or vendor or both
206
  my $customer;
207
  my $vendor;
208
  if ($cv_type ne 'vendor') {
209
    $customer = SL::DB::Manager::Customer->get_first(
293
  # Separate query otherwise cv without contacts and shipto is not found
294
  my $customer_vendor;
295
  foreach my $manager (qw(SL::DB::Manager::Customer SL::DB::Manager::Vendor)) {
296
    $customer_vendor ||= $manager->get_first(
210 297
      where => [
211 298
        or => [
212 299
          email => $email_address,
213 300
          cc    => $email_address,
214 301
          bcc   => $email_address,
215
          'contacts.cp_email' => $email_address,
216
          'contacts.cp_privatemail' => $email_address,
217
          'shipto.shiptoemail' => $email_address,
218 302
        ],
219 303
      ],
220
      with_objects => [ 'contacts', 'shipto' ],
221 304
    );
222
  } elsif ($cv_type ne 'customer') {
223
    $vendor = SL::DB::Manager::Vendor->get_first(
305
    $customer_vendor ||= $manager->get_first(
224 306
      where => [
225 307
        or => [
226
          email => $email_address,
227
          cc    => $email_address,
228
          bcc   => $email_address,
229 308
          'contacts.cp_email' => $email_address,
230 309
          'contacts.cp_privatemail' => $email_address,
310
        ],
311
      ],
312
      with_objects => [ 'contacts'],
313
    );
314
    $customer_vendor ||= $manager->get_first(
315
      where => [
316
        or => [
231 317
          'shipto.shiptoemail' => $email_address,
232 318
        ],
233 319
      ],
234
      with_objects => [ 'contacts', 'shipto' ],
320
      with_objects => [ 'shipto' ],
235 321
    );
236 322
  }
237 323

  
238
  return $customer || $vendor;
324
  return $customer_vendor;
239 325
}
240 326

  
241 327
sub find_customer_from_email {
js/kivi.EmailJournal.js
11 11
    $.post("controller.pl", data, kivi.eval_json_result);
12 12
  }
13 13

  
14
  ns.update_extra_div_selection = function() {
15
    let record_action = $('#record_action').val();
16
    if (record_action == undefined) { return; }
14
  ns.update_customer_vendor_selection = function() {
15
    let customer_vendor = $('#customer_vendor_selection').val();
17 16

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

  
21
    $('#link_sales_quotation_div').hide();
22
    $('#link_sales_order_intake_div').hide();
23
    $('#link_sales_order_div').hide();
24
    $('#link_request_quotation_div').hide();
25
    $('#link_purchase_quotation_intake_div').hide();
26
    $('#link_purchase_order_div').hide();
27

  
28
    $('#placeholder_div').hide();
29

  
30
    // customer vendor
31
    if (record_action.match(/^customer/)) {
22
    if (customer_vendor == 'customer') {
32 23
      $('#customer_div').show();
33
    } else if (record_action.match(/^vendor/)) {
24
      $('#customer_record_types_div').show();
25
    } else { // if (customer_vendor == 'vendor')
34 26
      $('#vendor_div').show();
35
    // link
36
    } else if (record_action.match(/^link_/)) {
37
      $('#'+record_action+'_div').show();
38
    // placeholder
27
      $('#vendor_record_types_div').show();
28
    }
29
    kivi.EmailJournal.update_record_type_selection(customer_vendor);
30
  }
31

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

  
35
    $('#record_type_div').hide();
36
    $('#no_record_type_div').hide();
37

  
38
    if (record_action == 'create_new') {
39
      $('#no_record_type_div').show();
39 40
    } else {
40
      $('#placeholder_div').show();
41
      $('#record_type_div').show();
41 42
    }
42 43
  }
43 44

  
44
  ns.apply_record_action = function() {
45
    let record_action = $('#record_action').val();
46
    if (record_action == '') {
47
      alert(kivi.t8('Please select an action.'));
48
      return;
45
  ns.update_record_type_selection = function(customer_vendor) {
46
    let record_type = $('#' + customer_vendor + '_record_type_selection').val();
47

  
48
    $('.record_type').hide();
49
    if (record_type != '') {
50
      $('#' + record_type + '_div').show();
51
    } else {
52
      $('#record_type_placeholder_div').show();
49 53
    }
54
  }
50 55

  
56
  ns.apply_action_with_attachment = function() {
51 57
    let data = $('#record_action_form').serializeArray();
52 58
    data.push({ name: 'action', value: 'EmailJournal/apply_record_action' });
53 59

  
......
57 63

  
58 64
$(function() {
59 65
  kivi.EmailJournal.update_attachment_preview();
60
  kivi.EmailJournal.update_extra_div_selection();
61 66
});
templates/design40_webpages/email_journal/show.html
4 4
[% USE P %]
5 5
[% USE T8 %]
6 6

  
7
[% BLOCK filter_toggle_panel # can't change name %]
8
<table id="email_journal_details" class="tbl-horizontal">
9
  <tbody>
10
    <tr>
11
      <th>[% 'From' | $T8 %]</th>
12
      <td>[% L.input_tag('from',  SELF.entry.from, style="color:black", class="wi-verywide", disabled=1) %]</td>
13
    </tr>
14
    <tr>
15
      <th>[% 'Recipients' | $T8 %]</th>
16
      <td>[% L.input_tag('recipients', SELF.entry.recipients, style="color:black", class="wi-verywide", disabled=1) %]</td>
17
    </tr>
18
    <tr>
19
      <th>[% 'Subject' | $T8 %]</th>
20
      <td>[% L.input_tag('subject', SELF.entry.subject, style="color:black", class="wi-verywide", disabled=1) %]</td>
21
    </tr>
22
    <tr>
23
      <th>[% 'Sent on' | $T8 %]</th>
24
      <td>[% L.input_tag('sent_on', SELF.entry.sent_on.to_lxoffice("precision" => "second"), style="color:black", class="wi-verywide", disabled=1) %]</td>
25
    </tr>
26
    <tr>
27
      <th>[% 'Status' | $T8 %]</th>
28
      <td>[% L.input_tag('status', P.email_journal.entry_status(SELF.entry), style="color:black", class="wi-verywide", disabled=1) %]</td>
29
    </tr>
30
    <tr>
31
      <th>[% 'Extended status' | $T8 %]</th>
32
      <td>
33
        [% L.textarea_tag('extended_status', SELF.entry.extended_status, wrap="soft", style="color:black; height:25px", class="wi-verywide", disabled=1) %]
34
      </td>
35
    </tr>
36
    <tr>
37
      <th>[% 'Headers' | $T8 %]</th>
38
      <td>
39
        [% L.textarea_tag('headers', HTML.escape(SELF.entry.headers), wrap="soft", style="color:black; height:25px", class="wi-verywide", disabled=1) %]
40
      </td>
41
    </tr>
42
    <tr>
43
      <th>[% 'Body' | $T8 %]</th>
44
      <td>
45
        [% IF SELF.entry.headers.match('(?i)content-type:.*text/html') %]
46
          <div style="border:1px solid black;">
47
          [% P.restricted_html(SELF.entry.body) %]
48
          </div>
49
        [% ELSE %]
50
          [% L.textarea_tag('body', SELF.entry.body, wrap="soft", style="color:black; height:200px", class="wi-verywide", disabled=1) %]
51
        [% END %]
52
      </td>
53
    </tr>
54
  </tbody>
55
</table>
56
[% END %]
57

  
58

  
59

  
60 7
<h1>[% FORM.title %]</h1>
61 8

  
62 9
[% INCLUDE 'common/flash.html' %]
63 10

  
64
<div class="wrapper" id="wrapper-0">
11
<form>
12
<div class="tabwidget" id="email_tabs">
13
  <ul>
14
    <li><a href="#ui-tabs-basic-data">[% 'Basic Data' | $T8 %]</a></li>
15
    <li><a href="controller.pl?action=RecordLinks/ajax_list&object_model=EmailJournal&object_id=[% HTML.url(SELF.entry.id) %]">[% 'Linked Records' | $T8 %]</a></li>
16
  </ul>
65 17

  
66
<div class="wrapper">
67
  [%
68
    display_status = 'open';
69
    button_closed  = LxERP.t8('Show Email');
70
    button_open    = LxERP.t8('Hide Email');
71
    INCLUDE 'common/toggle_panel.html';
72
  %]
73
</div><!-- /.wrapper -->
18
[% PROCESS "email_journal/tabs/basic_data.html" %]
19
</div> <!-- /.tabwidget -->
20
</form>
74 21

  
22
<div class="wrapper" id="wrapper-0">
75 23

  
76 24
[% SET attachments = SELF.entry.attachments_sorted %]
77 25

  
......
116 64
      %]
117 65
    </div>
118 66

  
119
    <div class="col">
120
    [% L.select_tag('record_action',
121
       # id has to start with customer_ or vendor_ for picker selection
67
    <div id="customer_vendor_div" class="col">
68
    [% L.select_tag('customer_vendor_selection',
122 69
       [
123
         [ LxERP.t8("Linking"), [
124
           {id => "link_sales_quotation",           name => LxERP.t8("Link to sales quotation")},
125
           {id => "link_sales_order_intake",        name => LxERP.t8("Link to sales order intake")},
126
           {id => "link_sales_order",               name => LxERP.t8("Link to sales order")},
127
           {id => "link_request_quotation",         name => LxERP.t8("Link to request quotation")},
128
           {id => "link_purchase_quotation_intake", name => LxERP.t8("Link to purchase quotation intake")},
129
           {id => "link_purchase_order",            name => LxERP.t8("Link to purchase order")},
130

  
131
         ] ],
132
         [ LxERP.t8("Sales"), [
133
             {id => "customer_sales_order",  name => LxERP.t8("Create sales order")},
134
             {id => "customer_sales_order_intake",  name => LxERP.t8("Create sales order intake")},
135
             {id => "customer_sales_quotation",  name => LxERP.t8("Create sales quotation")},
136
         ] ],
137
         [ LxERP.t8("Purchase"), [
138
             {id => "vendor_purchase_order", name => LxERP.t8("Create purchase order")},
139
             {id => "vendor_purchase_quotation_intake", name => LxERP.t8("Create purchase quotation intake")},
140
             {id => "vendor_request_quotation", name => LxERP.t8("Create request quotation")},
141

  
142
         ] ],
70
         {value => "customer", name => LxERP.t8("Sales")},
71
         {value => "vendor",   name => LxERP.t8("Purchase")},
143 72
       ],
144
       value_key='id', title_key='name',
145
       with_empty=1, empty_value='', empty_title=LxERP.t8("No action"),
146
       with_optgroups=1,
147
       class="wi-normal",
148
       onchange='kivi.EmailJournal.update_extra_div_selection();'
73
       default = CV_TYPE_FOUND,
74
       value_key='value', title_key='name',
75
       class="wi-verysmall",
76
       onchange='kivi.EmailJournal.update_customer_vendor_selection();'
149 77
       ) %]
150 78
    </div>
151

  
152
    [% FOREACH cv_type_name = [['customer', 'Customer'], ['vendor', 'Vendor']] %]
153
    [% SET cv_type = cv_type_name.0 %]
154
    [% SET cv_name = cv_type_name.1 %]
155
    <div id="[% cv_type _ "_div" %]" class="col" style="display:none">
79
    [% FOREACH cv_option = [
80
         ['customer', 'Customer', 1],
81
         ['vendor',   'Vendor',   0],
82
         ] %]
83
    [% SET cv_type        = cv_option.0 %]
84
    [% SET cv_name        = cv_option.1 %]
85
    [% SET cv_is_cusotmer = cv_option.2 %]
86
    <div
87
      id="[% cv_type _ "_div" %]" class="col"
88
      style=[% IF cv_type == CV_TYPE_FOUND %] "display:block" [% ELSE %] "display:none" [% END %]
89
      >
156 90
      [% P.customer_vendor.picker(
157
           cv_type _ "_id", SELF.find_cv_from_email(cv_type, SELF.entry),
91
           cv_type _ "_id",
92
           CUSTOMER_VENDOR.is_customer == cv_is_cusotmer ? CUSTOMER_VENDOR : undef,
158 93
           type=cv_type, class="wi-normal", placeholder=LxERP.t8(cv_name)
159 94
           ) %]
160 95
    </div>
161 96
    [% END %]
162
    [% FOREACH record_type  = [
163
         'sales_quotation', 'sales_order_intake', 'sales_order',
164
         'request_quotation', 'purchase_quotation_intake', 'purchase_order'
165
         ] %]
166
    <div id="[% "link_" _ record_type _ "_div" %]" class="col" style="display:none">
167
      [% L.input_tag(record_type _ "_id", '',
168
           style="color:black", class="wi-normal",
169
           placeholder=record_type _ " id") %]
97

  
98
    <div id="action_div" class="col">
99
    [% L.select_tag('action_selection',
100
       [
101
         {value => "workflow",   name => LxERP.t8("Create from Workflow")},
102
         {value => "linking",    name => LxERP.t8("Linking to Record")},
103
         {value => "create_new", name => LxERP.t8("Create new")},
104
       ],
105
       value_key='value', title_key='name',
106
       class="wi-normal",
107
       onchange='kivi.EmailJournal.update_action_selection();'
108
       ) %]
109
    </div>
110

  
111
    [% FOREACH customer_vendor = ['customer', 'vendor'] %]
112
    <div id="[% customer_vendor _ "_record_types_div" %]" class="col"
113
      style=[% IF customer_vendor == CV_TYPE_FOUND %] "display:block" [% ELSE %] "display:none" [% END %]
114
      >
115

  
116
      [%
117
        SET options = [];
118
        FOREACH record_info = RECORD_TYPES_WITH_INFO;
119
          IF (record_info.customervendor == customer_vendor);
120
            options.push({value => record_info.record_type, name => record_info.text});
121
          END;
122
        END;
123
      %]
124
    [% L.select_tag(customer_vendor _ '_record_type_selection',
125
       options,
126
       value_key='value', title_key='name',
127
       with_empty=1, empty_value='', empty_title=LxERP.t8("Select record type"),
128
       class="wi-normal",
129
       onchange='kivi.EmailJournal.update_record_type_selection("' _ customer_vendor _ '");'
130
       ) %]
170 131
    </div>
171 132
    [% END %]
172
    <div id="placeholder_div" class="col" style="display:block">
133

  
134
    <div id="record_type_div" class="col" style="display:block">
135
      [% FOREACH record_info = RECORD_TYPES_WITH_INFO %]
136
      <div id="[% record_info.record_type _ "_div" %]" class="col record_type" style="display:none">
137
        [% L.input_tag(record_info.record_type _ "_id", '',
138
             style="color:black", class="wi-normal",
139
             placeholder=record_info.record_type _ " id") %]
140
      </div>
141
      [% END %]
142
      <div id="record_type_placeholder_div" class="col record_type" style="display:block">
143
        [% L.input_tag('cv_placeholder', '',
144
             style="color:black", class="wi-normal", disabled=1,
145
             placeholder=LxERP.t8("Select record type first"),
146
             ) %]
147
      </div>
148
    </div>
149
    <div id="no_record_type_div" class="col" style="display:none">
173 150
      [% L.input_tag('cv_placeholder', '',
174 151
           style="color:black", class="wi-normal", disabled=1,
175
           placeholder=LxERP.t8("Select action first"),
152
           placeholder=LxERP.t8("No record needed"),
176 153
           ) %]
177 154
    </div>
178 155

  
179 156
    <div class="col">
180
      [% L.button_tag('kivi.EmailJournal.apply_record_action();', LxERP.t8('Apply with Attachment')) %]
157
      [% L.button_tag('kivi.EmailJournal.apply_action_with_attachment();', LxERP.t8('Apply with Attachment')) %]
181 158
    </div>
182 159
  </div> <!-- action_div -->
183 160
</form>
......
185 162
<!-- kivi.EmailJournal.update_attachment_preview -->
186 163
<div id="attachment_preview"></div>
187 164
[% END %]
188

  
189 165
</div> <!-- wrapper-2 -->
190 166

  
191 167
</div> <!-- wrapper-0 -->
templates/design40_webpages/email_journal/tabs/basic_data.html
1
[% USE T8 %]
2
[% USE HTML %]
3
[% USE LxERP %]
4
[% USE L %]
5
[% USE P %]
6

  
7
<div id="ui-tabs-basic-data">
8

  
9
<div class="wrapper">
10
[% INCLUDE 'generic/toggle_wrapper.html' %]
11

  
12
<table id="email_journal_details" class="tbl-horizontal">
13
  <caption>[% 'E-Mail Details' | $T8 %]</caption>
14
  <tbody>
15
    <tr>
16
      <th>[% 'From' | $T8 %]</th>
17
      <td>[% L.input_tag('from',  SELF.entry.from, style="color:black", class="wi-verywide", disabled=1) %]</td>
18
    </tr>
19
    <tr>
20
      <th>[% 'Recipients' | $T8 %]</th>
21
      <td>[% L.input_tag('recipients', SELF.entry.recipients, style="color:black", class="wi-verywide", disabled=1) %]</td>
22
    </tr>
23
    <tr>
24
      <th>[% 'Subject' | $T8 %]</th>
25
      <td>[% L.input_tag('subject', SELF.entry.subject, style="color:black", class="wi-verywide", disabled=1) %]</td>
26
    </tr>
27
    <tr>
28
      <th>[% 'Sent on' | $T8 %]</th>
29
      <td>[% L.input_tag('sent_on', SELF.entry.sent_on.to_lxoffice("precision" => "second"), style="color:black", class="wi-verywide", disabled=1) %]</td>
30
    </tr>
31
    <tr>
32
      <th>[% 'Status' | $T8 %]</th>
33
      <td>[% L.input_tag('status', P.email_journal.entry_status(SELF.entry), style="color:black", class="wi-verywide", disabled=1) %]</td>
34
    </tr>
35
    <tr>
36
      <th>[% 'Extended status' | $T8 %]</th>
37
      <td>
38
        [% L.textarea_tag('extended_status', SELF.entry.extended_status, wrap="soft", style="color:black; height:25px", class="wi-verywide", disabled=1) %]
39
      </td>
40
    </tr>
41
    <tr>
42
      <th>[% 'Headers' | $T8 %]</th>
43
      <td>
44
        [% L.textarea_tag('headers', HTML.escape(SELF.entry.headers), wrap="soft", style="color:black; height:25px", class="wi-verywide", disabled=1) %]
45
      </td>
46
    </tr>
47
    <tr>
48
      <th>[% 'Body' | $T8 %]</th>
49
      <td>
50
        [% IF SELF.entry.headers.match('(?i)content-type:.*text/html') %]
51
          <div style="border:1px solid black;">
52
          [% P.restricted_html(SELF.entry.body) %]
53
          </div>
54
        [% ELSE %]
55
          [% L.textarea_tag('body', SELF.entry.body, wrap="soft", style="color:black; height:200px", class="wi-verywide", disabled=1) %]
56
        [% END %]
57
      </td>
58
    </tr>
59
  </tbody>
60
</table>
61
</div><!-- /.wrapper -->
62

  
63
</div><!-- /#ui-tabs-basic-data -->
templates/webpages/email_journal/show.html
1
[% USE HTML %][% USE L %][% USE LxERP %][%- USE P -%]
1
[% USE HTML %][% USE L %][% USE LxERP %][%- USE P -%] [% USE T8 %]
2 2

  
3 3
 <h1>[% FORM.title %]</h1>
4 4

  
5 5
[%- INCLUDE 'common/flash.html' %]
6 6

  
7
 <table id="email_journal_details" class="email_journal_details">
8
  <tbody>
9
   <tr class="listrow">
10
    <th>[%- LxERP.t8("From") %]</th>
11
    <td>[%- HTML.escape(SELF.entry.from) %]</td>
12
   </tr>
13

  
14
   <tr class="listrow">
15
    <th>[%- LxERP.t8("Recipients") %]</th>
16
    <td>[%- HTML.escape(SELF.entry.recipients) %]</td>
17
   </tr>
18

  
19
   <tr class="listrow">
20
    <th>[%- LxERP.t8("Subject") %]</th>
21
    <td>[%- HTML.escape(SELF.entry.subject) %]</td>
22
   </tr>
23

  
24
   <tr class="listrow">
25
    <th>[%- LxERP.t8("Sent on") %]</th>
26
    <td>[%- HTML.escape(SELF.entry.sent_on.to_lxoffice("precision" => "second")) %]</td>
27
   </tr>
28

  
29
   <tr class="listrow">
30
    <th>[%- LxERP.t8("Status") %]</th>
31
    <td>
32
        [% P.email_journal.entry_status(SELF.entry) %]
33
    </td>
34
   </tr>
7
<div class="tabwidget" id="email_tabs">
8
  <ul>
9
    <li><a href="#ui-tabs-basic-data">[% 'Basic Data' | $T8 %]</a></li>
10
    <li><a href="controller.pl?action=RecordLinks/ajax_list&object_model=EmailJournal&object_id=[% HTML.url(SELF.entry.id) %]">[% 'Linked Records' | $T8 %]</a></li>
11
  </ul>
35 12

  
36
   <tr class="listrow">
37
    <th>[%- LxERP.t8("Extended status") %]</th>
38
    <td><pre>[%- HTML.escape(SELF.entry.extended_status) %]</pre></td>
39
   </tr>
40

  
41
   <tr class="listrow">
42
    <th>[%- LxERP.t8("Headers") %]</th>
43
    <td><pre>[% HTML.escape(SELF.entry.headers) %]</pre></td>
44
   </tr>
45

  
46
   <tr class="listrow">
47
    <th>[%- LxERP.t8("Body") %]</th>
48
    <td>
49
     [%- IF SELF.entry.headers.match('(?i)content-type:.*text/html') %]
50
      [% P.restricted_html(SELF.entry.body) %]
51
     [%- ELSE %]
52
      <pre>[% HTML.escape(SELF.entry.body) %]</pre>
53
     [%- END %]
54
    </td>
55
   </tr>
56
 </table>
13
[% PROCESS "email_journal/tabs/basic_data.html" %]
14
</div> <!-- /.tabwidget -->
57 15

  
58 16
 [% SET attachments = SELF.entry.attachments_sorted %]
59 17
  <h2>[% LxERP.t8("Attachments") %]</h2>
......
97 55
    </td>
98 56

  
99 57
    <td>
100
      [% L.select_tag('record_action',
101
         # id has to start with customer_ or vendor_ for picker selection
58
      [% L.select_tag('customer_vendor_selection',
102 59
         [
103
           [ LxERP.t8("Linking"), [
104
             {id => "link_sales_quotation",           name => LxERP.t8("Link to sales quotation")},
105
             {id => "link_sales_order_intake",        name => LxERP.t8("Link to sales order intake")},
106
             {id => "link_sales_order",               name => LxERP.t8("Link to sales order")},
107
             {id => "link_request_quotation",         name => LxERP.t8("Link to request quotation")},
108
             {id => "link_purchase_quotation_intake", name => LxERP.t8("Link to purchase quotation intake")},
109
             {id => "link_purchase_order",            name => LxERP.t8("Link to purchase order")},
110

  
111
           ] ],
112
           [ LxERP.t8("Sales"), [
113
               {id => "customer_sales_order",  name => LxERP.t8("Create sales order")},
114
               {id => "customer_sales_order_intake",  name => LxERP.t8("Create sales order intake")},
115
               {id => "customer_sales_quotation",  name => LxERP.t8("Create sales quotation")},
116
           ] ],
117
           [ LxERP.t8("Purchase"), [
118
               {id => "vendor_purchase_order", name => LxERP.t8("Create purchase order")},
119
               {id => "vendor_purchase_quotation_intake", name => LxERP.t8("Create purchase quotation intake")},
120
               {id => "vendor_request_quotation", name => LxERP.t8("Create request quotation")},
121

  
122
           ] ],
60
           {value => "customer", name => LxERP.t8("Sales")},
61
           {value => "vendor",   name => LxERP.t8("Purchase")},
123 62
         ],
124
         value_key='id', title_key='name',
125
         with_empty=1, empty_value='', empty_title=LxERP.t8("No action"),
126
         with_optgroups=1,
127
         class="wi-normal",
128
         onchange='kivi.EmailJournal.update_extra_div_selection();'
63
         default = CV_TYPE_FOUND,
64
         value_key='value', title_key='name',
65
         class="wi-verysmall",
66
         onchange='kivi.EmailJournal.update_customer_vendor_selection();'
129 67
         ) %]
130 68
    </td>
131 69

  
132 70
    <td>
133
      [% FOREACH cv_type_name = [['customer', 'Customer'], ['vendor', 'Vendor']] %]
134
      [% SET cv_type = cv_type_name.0 %]
135
      [% SET cv_name = cv_type_name.1 %]
136
      <div id="[% cv_type _ "_div" %]" style="display:none">
71
      [% FOREACH cv_option = [
72
           ['customer', 'Customer', 1],
73
           ['vendor',   'Vendor',   0],
74
           ] %]
75
      [% SET cv_type        = cv_option.0 %]
76
      [% SET cv_name        = cv_option.1 %]
77
      [% SET cv_is_cusotmer = cv_option.2 %]
78
      <div
79
        id="[% cv_type _ "_div" %]" class="col"
80
        style=[% IF cv_type == CV_TYPE_FOUND %] "display:block" [% ELSE %] "display:none" [% END %]
81
        >
137 82
        [% P.customer_vendor.picker(
138
             cv_type _ "_id", SELF.find_cv_from_email(cv_type, SELF.entry),
83
             cv_type _ "_id",
84
             CUSTOMER_VENDOR.is_customer == cv_is_cusotmer ? CUSTOMER_VENDOR : undef,
139 85
             type=cv_type, class="wi-normal", placeholder=LxERP.t8(cv_name)
140 86
             ) %]
141 87
      </div>
142
      [% END %]
143
      [% FOREACH record_type  = [
144
           'sales_quotation', 'sales_order_intake', 'sales_order',
145
           'request_quotation', 'purchase_quotation_intake', 'purchase_order'
146
           ] %]
147
      <div id="[% "link_" _ record_type _ "_div" %]" style="display:none">
148
        [% L.input_tag(record_type _ "_id", '',
149
             style="color:black", class="wi-normal",
150
             placeholder=record_type _ " id") %]
88
    [% END %]
89
    </td>
90

  
91
    <td>
92
      [% L.select_tag('action_selection',
93
         [
94
           {value => "workflow",   name => LxERP.t8("Create from Workflow")},
95
           {value => "linking",    name => LxERP.t8("Linking to Record")},
96
           {value => "create_new", name => LxERP.t8("Create new")},
97
         ],
98
         value_key='value', title_key='name',
99
         class="wi-normal",
100
         onchange='kivi.EmailJournal.update_action_selection();'
101
         ) %]
102
    </td>
103

  
104
    <td>
105
      [% FOREACH customer_vendor = ['customer', 'vendor'] %]
106
      <div id="[% customer_vendor _ "_record_types_div" %]" class="col"
107
        style=[% IF customer_vendor == CV_TYPE_FOUND %] "display:block" [% ELSE %] "display:none" [% END %]
108
        >
109

  
110
        [%
111
          SET options = [];
112
          FOREACH record_info = RECORD_TYPES_WITH_INFO;
113
            IF (record_info.customervendor == customer_vendor);
114
              options.push({value => record_info.record_type, name => record_info.text});
115
            END;
116
          END;
117
        %]
118
      [% L.select_tag(customer_vendor _ '_record_type_selection',
119
         options,
120
         value_key='value', title_key='name',
121
         with_empty=1, empty_value='', empty_title=LxERP.t8("Select record type"),
122
         class="wi-normal",
123
         onchange='kivi.EmailJournal.update_record_type_selection("' _ customer_vendor _ '");'
124
         ) %]
151 125
      </div>
152 126
      [% END %]
153
      <div id="placeholder_div" style="display:block">
127
    </td>
128

  
129
    <td>
130
      <div id="record_type_div" class="col" style="display:block">
131
        [% FOREACH record_info = RECORD_TYPES_WITH_INFO %]
132
        <div id="[% record_info.record_type _ "_div" %]" class="col record_type" style="display:none">
133
          [% L.input_tag(record_info.record_type _ "_id", '',
134
               style="color:black", class="wi-normal",
135
               placeholder=record_info.record_type _ " id") %]
136
        </div>
137
        [% END %]
138
        <div id="record_type_placeholder_div" class="col record_type" style="display:block">
139
          [% L.input_tag('cv_placeholder', '',
140
               style="color:black", class="wi-normal", disabled=1,
141
               placeholder=LxERP.t8("Select record type first"),
142
               ) %]
143
        </div>
144
      </div>
145
      <div id="no_record_type_div" class="col" style="display:none">
154 146
        [% L.input_tag('cv_placeholder', '',
155 147
             style="color:black", class="wi-normal", disabled=1,
156
             placeholder=LxERP.t8("Select action first"),
148
             placeholder=LxERP.t8("No record needed"),
157 149
             ) %]
158 150
      </div>
159 151
    </td>
160 152

  
161 153
    <td>
162
      [% L.button_tag('kivi.EmailJournal.apply_record_action();', LxERP.t8('Apply with Attachment')) %]
154
      [% L.button_tag('kivi.EmailJournal.apply_action_with_attachment();', LxERP.t8('Apply with Attachment')) %]
163 155
    </td>
164 156
  </tr> </table>
165 157
</form>
templates/webpages/email_journal/tabs/basic_data.html
1
[% USE HTML %][% USE L %][% USE LxERP %][%- USE P -%]
2

  
3
<div id="ui-tabs-basic-data">
4

  
5
<table id="email_journal_details" class="email_journal_details">
6
 <tbody>
7
  <tr class="listrow">
8
   <th>[%- LxERP.t8("From") %]</th>
9
   <td>[%- HTML.escape(SELF.entry.from) %]</td>
10
  </tr>
11

  
12
  <tr class="listrow">
13
   <th>[%- LxERP.t8("Recipients") %]</th>
14
   <td>[%- HTML.escape(SELF.entry.recipients) %]</td>
15
  </tr>
16

  
17
  <tr class="listrow">
18
   <th>[%- LxERP.t8("Subject") %]</th>
19
   <td>[%- HTML.escape(SELF.entry.subject) %]</td>
20
  </tr>
21

  
22
  <tr class="listrow">
23
   <th>[%- LxERP.t8("Sent on") %]</th>
24
   <td>[%- HTML.escape(SELF.entry.sent_on.to_lxoffice("precision" => "second")) %]</td>
25
  </tr>
26

  
27
  <tr class="listrow">
28
   <th>[%- LxERP.t8("Status") %]</th>
29
   <td>
30
       [% P.email_journal.entry_status(SELF.entry) %]
31
   </td>
32
  </tr>
33

  
34
  <tr class="listrow">
35
   <th>[%- LxERP.t8("Extended status") %]</th>
36
   <td><pre>[%- HTML.escape(SELF.entry.extended_status) %]</pre></td>
37
  </tr>
38

  
39
  <tr class="listrow">
40
   <th>[%- LxERP.t8("Headers") %]</th>
41
   <td><pre>[% HTML.escape(SELF.entry.headers) %]</pre></td>
42
  </tr>
43

  
44
  <tr class="listrow">
45
   <th>[%- LxERP.t8("Body") %]</th>
46
   <td>
47
    [%- IF SELF.entry.headers.match('(?i)content-type:.*text/html') %]
48
     [% P.restricted_html(SELF.entry.body) %]
49
    [%- ELSE %]
50
     <pre>[% HTML.escape(SELF.entry.body) %]</pre>
51
    [%- END %]
52
   </td>
53
  </tr>
54
</table>
55

  
56
</div><!-- /#ui-tabs-basic-data -->

Auch abrufbar als: Unified diff