Projekt

Allgemein

Profil

« Zurück | Weiter » 

Revision 4cb3a908

Von Thomas Heck vor mehr als 11 Jahren hinzugefügt

  • ID 4cb3a9081f02797bedd522b0f01539a0d9c0b3b3
  • Vorgänger a9d8dd12
  • Nachfolger 8aeebba7

ct.pl als Controller

Unterschiede anzeigen:

SL/Controller/CustomerVendor.pm
1
package SL::Controller::CustomerVendor;
2

  
3
use strict;
4
use parent qw(SL::Controller::Base);
5

  
6
use SL::JSON;
7
use SL::DBUtils;
8
use SL::Helper::Flash;
9

  
10
use SL::DB::Customer;
11
use SL::DB::Vendor;
12
use SL::DB::Business;
13
use SL::DB::Employee;
14
use SL::DB::Language;
15
use SL::DB::TaxZone;
16
use SL::DB::Note;
17
use SL::DB::PaymentTerm;
18
use SL::DB::Pricegroup;
19
use SL::DB::Contact;
20
use SL::DB::FollowUp;
21

  
22
# safety
23
__PACKAGE__->run_before(
24
  sub {
25
    $::auth->assert('customer_vendor_edit');
26
  }
27
);
28

  
29
__PACKAGE__->run_before(
30
  '_instantiate_args',
31
  only => [
32
    'save',
33
    'save_and_ap_transaction',
34
    'save_and_ar_transaction',
35
    'save_and_close',
36
    'save_and_invoice',
37
    'save_and_order',
38
    'save_and_quotation',
39
    'save_and_rfq',
40
    'delete_contact',
41
    'delete_shipto',
42
  ]
43
);
44

  
45
__PACKAGE__->run_before(
46
  '_load_customer_vendor',
47
  only => [
48
    'edit',
49
    'update',
50
    'ajaj_get_shipto',
51
    'ajaj_get_contact',
52
  ]
53
);
54
__PACKAGE__->run_before(
55
  '_create_customer_vendor',
56
  only => [
57
    'new',
58
  ]
59
);
60

  
61
sub action_new {
62
  my ($self) = @_;
63

  
64
  $self->_pre_render();
65
  $self->render(
66
    'customer_vendor/form',
67
    title => ($self->is_vendor() ? $::locale->text('Add Vendor') : $::locale->text('Add Customer')),
68
    %{$self->{template_args}}
69
  );
70
}
71

  
72
sub action_edit {
73
  my ($self) = @_;
74

  
75
  $self->_pre_render();
76
  $self->render(
77
    'customer_vendor/form',
78
    title => ($self->is_vendor() ? $::locale->text('Edit Vendor') : $::locale->text('Edit Customer')),
79
    %{$self->{template_args}}
80
  );
81
}
82

  
83
sub _save {
84
  my ($self) = @_;
85

  
86
  my $cvs_by_nr;
87
  if ( $self->is_vendor() ) {
88
    if ( $self->{cv}->vendornumber ) {
89
      $cvs_by_nr = SL::DB::Manager::Vendor->get_all(query => [vendornumber => $self->{cv}->vendornumber]);
90
    }
91
  }
92
  else {
93
    if ( $self->{cv}->customernumber ) {
94
      $cvs_by_nr = SL::DB::Manager::Customer->get_all(query => [customernumber => $self->{cv}->customernumber]);
95
    }
96
  }
97

  
98
  foreach my $entry (@{$cvs_by_nr}) {
99
    if( $entry->id != $self->{cv}->id ) {
100
      my $msg =
101
        $self->is_vendor() ? $::locale->text('This vendor number is already in use.') : $::locale->text('This customer number is already in use.');
102

  
103
      $::form->error($msg);
104
    }
105
  }
106

  
107
  $self->{cv}->save(cascade => 1);
108

  
109
  $self->{contact}->cp_cv_id($self->{cv}->id);
110
  if( $self->{contact}->cp_name ne '' || $self->{contact}->cp_givenname ne '' ) {
111
    $self->{contact}->save();
112
  }
113

  
114
  if( $self->{note}->subject ne '' && $self->{note}->body ne '' ) {
115
    $self->{note}->trans_id($self->{cv}->id);
116
    $self->{note}->save();
117
    $self->{note_followup}->save();
118

  
119
    $self->{note} = SL::DB::Note->new();
120
    $self->{note_followup} = SL::DB::FollowUp->new();
121
  }
122

  
123
  $self->{shipto}->trans_id($self->{cv}->id);
124
  if( $self->{shipto}->shiptoname ne '' ) {
125
    $self->{shipto}->save();
126
  }
127

  
128
  #TODO: history
129
}
130

  
131
sub action_save {
132
  my ($self) = @_;
133

  
134
  $self->_save();
135

  
136
  $self->action_edit();
137
}
138

  
139
sub action_save_and_close {
140
  my ($self) = @_;
141

  
142
  $self->_save();
143

  
144
  my $msg = $self->is_vendor() ? $::locale->text('Vendor saved') : $::locale->text('Customer saved');
145
  $::form->redirect($msg);
146
}
147

  
148
sub _transaction {
149
  my ($self, $script) = @_;
150

  
151
  $::auth->assert('general_ledger         | invoice_edit         | vendor_invoice_edit | ' .
152
                 ' request_quotation_edit | sales_quotation_edit | sales_order_edit    | purchase_order_edit');
153

  
154
  $self->_save();
155

  
156
  my $callback = $::form->escape($::form->{callback}, 1);
157
  my $name = $::form->escape($self->{cv}->name, 1);
158
  my $db = $self->is_vendor() ? 'vendor' : 'customer';
159

  
160
  my $url =
161
    $script .'?'.
162
    'action=add&'.
163
    'vc='. $db .'&'.
164
    $db .'_id=' . $self->{cv}->id .'&'.
165
    $db .'='. $name .'&'.
166
    'type='. $::form->{type} .'&'.
167
    'callback='. $callback;
168

  
169
  print $::form->redirect_header($url);
170
}
171

  
172
sub action_save_and_ar_transaction {
173
  my ($self) = @_;
174

  
175
  $main::auth->assert('general_ledger');
176

  
177
  $self->_transaction('ar.pl');
178
}
179

  
180
sub action_save_and_ap_transaction {
181
  my ($self) = @_;
182

  
183
  $main::auth->assert('general_ledger');
184

  
185
  $self->_transaction('ap.pl');
186
}
187

  
188
sub action_save_and_invoice {
189
  my ($self) = @_;
190

  
191
  if ( $self->is_vendor() ) {
192
    $::auth->assert('vendor_invoice_edit');
193
  } else {
194
    $::auth->assert('invoice_edit');
195
  }
196

  
197
  $::form->{type} = 'invoice';
198
  $self->_transaction($self->is_vendor() ? 'ir.pl' : 'is.pl');
199
}
200

  
201
sub action_save_and_order {
202
  my ($self) = @_;
203

  
204
  if ( $self->is_vendor() ) {
205
    $::auth->assert('purchase_order_edit');
206
  } else {
207
    $::auth->assert('sales_order_edit');
208
  }
209

  
210
  $::form->{type} = $self->is_vendor() ? 'purchase_order' : 'sales_order';
211
  $self->_transaction('oe.pl');
212
}
213

  
214
sub action_save_and_rfq {
215
  my ($self) = @_;
216

  
217
  $::auth->assert('request_quotation_edit');
218

  
219
  $::form->{type} = 'request_quotation';
220
  $self->_transaction('oe.pl');
221
}
222

  
223
sub action_save_and_quotation {
224
  my ($self) = @_;
225

  
226
  $::auth->assert('sales_quotation_edit');
227

  
228
  $::form->{type} = 'sales_quotation';
229
  $self->_transaction('oe.pl');
230
}
231

  
232
sub action_delete {
233
  my ($self) = @_;
234

  
235
  if( !$self->is_orphaned() ) {
236
    SL::Helper::Flash::flash('error', $::locale->text('blaabla'));
237

  
238
    $self->action_edit();
239
  }
240
  else {
241
    $self->{cv}->delete();
242

  
243
    #TODO: history
244

  
245
    my $msg = $self->is_vendor() ? $::locale->text('Vendor deleted!') : $::locale->text('Customer deleted!');
246
    $::form->redirect($msg);
247
  }
248

  
249
}
250

  
251

  
252
sub action_delete_contact {
253
  my ($self) = @_;
254

  
255
  if ( !$self->{contact}->cp_id ) {
256
    SL::Helper::Flash::flash('error', $::locale->text('No contact selected to delete'));
257
  } else {
258
    if ( $self->{contact}->used ) {
259
      $self->{contact}->detach();
260
      $self->{contact}->save();
261
      SL::Helper::Flash::flash('info', $::locale->text('Contact is in use and was flagged invalid.'));
262
    } else {
263
      $self->{contact}->delete();
264
      SL::Helper::Flash::flash('info', $::locale->text('Contact deleted.'));
265
    }
266

  
267
    $self->{contact} = SL::DB::Contact->new();
268
  }
269

  
270
  $self->action_edit();
271
}
272

  
273
sub action_delete_shipto {
274
  my ($self) = @_;
275

  
276
  if ( !$self->{shipto}->shipto_id ) {
277
    SL::Helper::Flash::flash('error', $::locale->text('No shipto selected to delete'));
278
  } else {
279
    if ( $self->{shipto}->used ) {
280
      $self->{shipto}->detach();
281
      $self->{shipto}->save();
282
      SL::Helper::Flash::flash('info', $::locale->text('Shipto is in use and was flagged invalid.'));
283
    } else {
284
      $self->{shipto}->delete();
285
      SL::Helper::Flash::flash('info', $::locale->text('Shipto deleted.'));
286
    }
287

  
288
    $self->{shipto} = SL::DB::Shipto->new();
289
  }
290

  
291
  $self->action_edit();
292
}
293

  
294
sub action_get_delivery {
295
  my ($self) = @_;
296

  
297
  my $dbh = $::form->get_standard_dbh();
298

  
299
  my ($arap, $db, $qty_sign);
300
  if ( $self->is_vendor() ) {
301
    $arap = 'ap';
302
    $db = 'vendor';
303
    $qty_sign = ' * -1 AS qty';
304
  }
305
  else {
306
    $arap = 'ar';
307
    $db = 'customer';
308
    $qty_sign = '';
309
  }
310

  
311
  my $where = ' WHERE 1=1 ';
312
  my @values;
313

  
314
  if ( !$self->is_vendor() && $::form->{shipto_id} && $::form->{shipto_id} ne 'all' ) {
315
    $where .= "AND ${arap}.shipto_id = ?";
316
    push(@values, $::form->{shipto_id});
317
  }
318

  
319
  if ( $::form->{delivery_from} ) {
320
    $where .= "AND ${arap}.transdate >= ?";
321
    push(@values, conv_date($::form->{delivery_from}));
322
  }
323

  
324
  if ( $::form->{delivery_to} ) {
325
    $where .= "AND ${arap}.transdate <= ?";
326
    push(@values, conv_date($::form->{delivery_to}));
327
  }
328

  
329
  my $query =
330
    "SELECT
331
       s.shiptoname,
332
       i.qty ${qty_sign},
333
       ${arap}.id,
334
       ${arap}.transdate,
335
       ${arap}.invnumber,
336
       ${arap}.ordnumber,
337
       i.description,
338
       i.unit,
339
       i.sellprice,
340
       oe.id AS oe_id,
341
       invoice
342
     FROM ${arap}
343

  
344
     LEFT JOIN shipto s
345
      ON ". ($arap eq 'ar' ? '(ar.shipto_id = s.shipto_id) ' : '(ap.id = s.trans_id) ') ."
346

  
347
     LEFT JOIN invoice i
348
       ON ${arap}.id = i.trans_id
349

  
350
     LEFT JOIN parts p
351
       ON p.id = i.parts_id
352

  
353
     LEFT JOIN oe
354
       ON (oe.ordnumber = ${arap}.ordnumber AND NOT ${arap}.ordnumber = '')
355

  
356
     ${where}
357
     ORDER BY ${arap}.transdate DESC LIMIT 15";
358

  
359
  $self->{delivery} = selectall_hashref_query($::form, $dbh, $query, @values);
360

  
361
  $self->render('customer_vendor/get_delivery', { layout => 0 });
362
}
363

  
364
sub action_ajaj_get_shipto {
365
  my ($self) = @_;
366

  
367
  my $data = {
368
    map(
369
      {
370
        my $name = 'shipto'. $_;
371
        $name => $self->{shipto}->$name;
372
      }
373
      qw(_id name department_1 department_2 street zipcode city country contact phone fax email)
374
    )
375
  };
376

  
377
  $self->render(\SL::JSON::to_json($data), { type => 'json', process => 0 });
378
}
379

  
380
sub action_ajaj_get_contact {
381
  my ($self) = @_;
382

  
383
  my $data;
384

  
385
  $data->{contact} = {
386
    map(
387
      {
388
        my $name = 'cp_'. $_;
389

  
390
        if ( $_ eq 'birthday' && $self->{contact}->$name ) {
391
          $name => $self->{contact}->$name->to_lxoffice;
392
        }
393
        else {
394
          $name => $self->{contact}->$name;
395
        }
396
      }
397
      qw(
398
        id gender abteilung title position givenname name email phone1 phone2 fax mobile1 mobile2
399
        satphone satfax project street zipcode city privatphone privatemail birthday
400
      )
401
    )
402
  };
403

  
404
  $data->{contact_cvars} = {
405
    map(
406
      {
407
        if ( $_->config->type eq 'number' ) {
408
          $_->config->name => $::form->format_amount(\%::myconfig, $_->value, -2);
409
        }
410
        else {
411
          $_->config->name => $_->value;
412
        }
413
      }
414
      grep(
415
        { $_->is_valid; }
416
        @{$self->{contact}->cvars_by_config}
417
      )
418
    )
419
  };
420

  
421
  $self->render(\SL::JSON::to_json($data), { type => 'json', process => 0 });
422
}
423

  
424
sub action_ajaj_customer_autocomplete {
425
  my ($self, %params) = @_;
426

  
427
  my $limit = $::form->{limit} || 20;
428
  my $type  = $::form->{type}  || {};
429
  my $query = { ilike => '%'. $::form->{term} .'%' };
430

  
431
  my @filter;
432
  push(
433
    @filter,
434
    $::form->{column} ? ($::form->{column} => $query) : (or => [ customernumber => $query, name => $query ])
435
  );
436

  
437
  my $customers = SL::DB::Manager::Customer->get_all(query => [ @filter ], limit => $limit);
438
  my $value_col = $::form->{column} || 'name';
439

  
440
  my $data = [
441
    map(
442
      {
443
        {
444
          value => $_->can($value_col)->($_),
445
          label => $_->displayable_name,
446
          id    => $_->id,
447
          customernumber => $_->customernumber,
448
          name  => $_->name,
449
        }
450
      }
451
      @{$customers}
452
    )
453
  ];
454

  
455
  $self->render(\SL::JSON::to_json($data), { layout => 0, type => 'json' });
456
}
457

  
458
sub is_vendor {
459
  return $::form->{db} eq 'vendor';
460
}
461

  
462
sub is_customer {
463
  return $::form->{db} eq 'customer';
464
}
465

  
466
sub is_orphaned {
467
  my ($self) = @_;
468

  
469
  if ( defined($self->{_is_orphaned}) ) {
470
    return $self->{_is_orphaned};
471
  }
472

  
473
  my $arap      = $self->is_vendor ? 'ap' : 'ar';
474
  my $num_args  = 2;
475

  
476
  my $cv = $self->is_vendor ? 'vendor' : 'customer';
477

  
478
  my $query =
479
   'SELECT a.id
480
    FROM '. $arap .' AS a
481
    JOIN '. $cv .' ct ON (a.'. $cv .'_id = ct.id)
482
    WHERE ct.id = ?
483

  
484
    UNION
485

  
486
    SELECT a.id
487
    FROM oe a
488
    JOIN '. $cv .' ct ON (a.'. $cv .'_id = ct.id)
489
    WHERE ct.id = ?';
490

  
491

  
492
  if ( $self->is_vendor ) {
493
    $query .=
494
     ' UNION
495
      SELECT 1 FROM makemodel mm WHERE mm.make = ?';
496
    $num_args++;
497
  }
498

  
499
  my ($dummy) = selectrow_query($::form, $::form->get_standard_dbh(), $query, (conv_i($self->{cv}->id)) x $num_args);
500

  
501
  return $self->{_is_orphaned} = !$dummy;
502
}
503

  
504
sub _instantiate_args {
505
  my ($self) = @_;
506

  
507
  my $curr_employee = SL::DB::Manager::Employee->current;
508

  
509
  foreach ( 'cv.creditlimit', 'cv.discount' ) {
510
    my ($namespace, $varname) = split('.', $_, 2);
511
    $::form->{$namespace}->{$varname} = $::form->parse_amount(\%::myconfig, $::form->{$namespace}->{$varname});
512
  }
513
  $::form->{cv}->{discount} /= 100;
514

  
515
  if ( $::form->{cv}->{id} ) {
516
    if ( $self->is_vendor() ) {
517
      $self->{cv} = SL::DB::Vendor->new(id => $::form->{cv}->{id})->load();
518
    }
519
    else {
520
      $self->{cv} = SL::DB::Customer->new(id => $::form->{cv}->{id})->load();
521
    }
522
  }
523
  else {
524
    if ( $self->is_vendor() ) {
525
      $self->{cv} = SL::DB::Vendor->new();
526
    }
527
    else {
528
      $self->{cv} = SL::DB::Customer->new();
529
    }
530
  }
531
  $self->{cv}->assign_attributes(%{$::form->{cv}});
532

  
533
  foreach my $cvar (@{$self->{cv}->cvars_by_config()}) {
534
    my $value = $::form->{cv_cvars}->{$cvar->config->name};
535

  
536
    if ( $cvar->config->type eq 'number' ) {
537
      $value = $::form->parse_amount(\%::myconfig, $value);
538
    }
539

  
540
    $cvar->value($value);
541
  }
542

  
543
#  foreach my $cvar_key (keys(%{$::form->{cv_cvars}})) {
544
#    my $cvar_value = $::form->{cv_cvars}->{$cvar_key};
545
#    my $cvar = $self->{cv}->cvar_by_name($cvar_key);
546
#    $cvar->value($cvar_value);
547
#  }
548

  
549
  if ( $::form->{note}->{id} ) {
550
    $self->{note} = SL::DB::Note->new(id => $::form->{note}->{id})->load();
551
  }
552
  else {
553
    $self->{note} = SL::DB::Note->new();
554
  }
555
  $self->{note}->assign_attributes(%{$::form->{note}});
556
  $self->{note}->created_by($curr_employee->id);
557
  $self->{note}->trans_module('ct');
558
  #  if ( $self->{note}->trans_id != $self->{cv}->id ) {
559
  #    die($::locale->text('Error'));
560
  #  }
561

  
562

  
563
  $self->{note_followup} = SL::DB::FollowUp->new();
564
  $self->{note_followup}->assign_attributes(%{$::form->{note_followup}});
565
  $self->{note_followup}->note($self->{note});
566
  $self->{note_followup}->created_by($curr_employee->id);
567

  
568
  if ( $::form->{shipto}->{shipto_id} ) {
569
    $self->{shipto} = SL::DB::Shipto->new(shipto_id => $::form->{shipto}->{shipto_id})->load();
570
  }
571
  else {
572
    $self->{shipto} = SL::DB::Shipto->new();
573
  }
574
  $self->{shipto}->assign_attributes(%{$::form->{shipto}});
575
  $self->{shipto}->module('CT');
576
#  if ( $self->{shipto}->trans_id != $self->{cv}->id ) {
577
#    die($::locale->text('Error'));
578
#  }
579

  
580
  if ( $::form->{contact}->{cp_id} ) {
581
    $self->{contact} = SL::DB::Contact->new(cp_id => $::form->{contact}->{cp_id})->load();
582
  }
583
  else {
584
    $self->{contact} = SL::DB::Contact->new();
585
  }
586
  $self->{contact}->assign_attributes(%{$::form->{contact}});
587
#  if ( $self->{contact}->cp_cv_id != $self->{cv}->id ) {
588
#    die($::locale->text('Error'));
589
#  }
590

  
591
  foreach my $cvar (@{$self->{contact}->cvars_by_config()}) {
592
    my $value = $::form->{contact_cvars}->{$cvar->config->name};
593

  
594
    if ( $cvar->config->type eq 'number' ) {
595
      $value = $::form->parse_amount(\%::myconfig, $value);
596
    }
597

  
598
    $cvar->value($value);
599
  }
600
}
601

  
602
sub _load_customer_vendor {
603
  my ($self) = @_;
604

  
605
  if ( $self->is_vendor() ) {
606
    $self->{cv} = SL::DB::Vendor->new(id => $::form->{id})->load();
607
  }
608
  else {
609
    $self->{cv} = SL::DB::Customer->new(id => $::form->{id})->load();
610
  }
611

  
612
  $self->{note} = SL::DB::Note->new();
613
  $self->{note_followup} = SL::DB::FollowUp->new();
614

  
615
  if ( $::form->{shipto_id} ) {
616
    $self->{shipto} = SL::DB::Shipto->new(shipto_id => $::form->{shipto_id})->load();
617

  
618
    if ( $self->{shipto}->trans_id != $self->{cv}->id ) {
619
      die($::locale->text('Error'));
620
    }
621
  }
622
  else {
623
    $self->{shipto} = SL::DB::Shipto->new();
624
  }
625

  
626
  if ( $::form->{contact_id} ) {
627
    $self->{contact} = SL::DB::Contact->new(cp_id => $::form->{contact_id})->load();
628

  
629
    if ( $self->{contact}->cp_cv_id != $self->{cv}->id ) {
630
      die($::locale->text('Error'));
631
    }
632
  }
633
  else {
634
    $self->{contact} = SL::DB::Contact->new();
635
  }
636
}
637

  
638
sub _create_customer_vendor {
639
  my ($self) = @_;
640

  
641
  if ( $self->is_vendor() ) {
642
    $self->{cv} = SL::DB::Vendor->new();
643
  }
644
  else {
645
    $self->{cv} = SL::DB::Customer->new();
646
  }
647

  
648
  $self->{note} = SL::DB::Note->new();
649

  
650
  $self->{note_followup} = SL::DB::FollowUp->new();
651

  
652
  $self->{shipto} = SL::DB::Shipto->new();
653

  
654
  $self->{contact} = SL::DB::Contact->new();
655
}
656

  
657
sub _pre_render {
658
  my ($self) = @_;
659

  
660
  my $dbh = $::form->get_standard_dbh();
661

  
662
  my $query;
663

  
664
  $self->{all_business} = SL::DB::Manager::Business->get_all();
665

  
666
  $self->{all_employees} = SL::DB::Manager::Employee->get_all();
667

  
668
  $query =
669
    'SELECT DISTINCT(greeting)
670
     FROM customer
671
     WHERE greeting IS NOT NULL AND greeting != \'\'
672
     UNION
673
       SELECT DISTINCT(greeting)
674
       FROM vendor
675
       WHERE greeting IS NOT NULL AND greeting != \'\'
676
     ORDER BY greeting';
677
  $self->{all_greetings} = [
678
    map(
679
      { $_->{greeting}; }
680
      selectall_hashref_query($::form, $dbh, $query)
681
    )
682
  ];
683

  
684
  $query =
685
    'SELECT DISTINCT(cp_title) AS title
686
     FROM contacts
687
     WHERE cp_title IS NOT NULL AND cp_title != \'\'
688
     ORDER BY cp_title';
689
  $self->{all_titles} = [
690
    map(
691
      { $_->{title}; }
692
      selectall_hashref_query($::form, $dbh, $query)
693
    )
694
  ];
695

  
696
  $query =
697
    'SELECT curr
698
     FROM defaults';
699
  my $curr = selectall_hashref_query($::form, $dbh, $query)->[0]->{curr};
700
  my @currencies = grep(
701
    { $_; }
702
    map(
703
      { s/\s//g; $_; }
704
      split(m/:/, $curr)
705
    )
706
  );
707
  $self->{all_currencies} = \@currencies;
708

  
709
  $self->{all_languages} = SL::DB::Manager::Language->get_all();
710

  
711
  $self->{all_taxzones} = SL::DB::Manager::TaxZone->get_all();
712

  
713
  #Employee:
714
  #TODO: ALL_SALESMAN
715
  #TODO: ALL_SALESMAN_CUSTOMERS
716

  
717
  $self->{all_payment_terms} = SL::DB::Manager::PaymentTerm->get_all();
718

  
719
  $self->{all_pricegroups} = SL::DB::Manager::Pricegroup->get_all();
720

  
721
  $query =
722
    'SELECT DISTINCT(cp_abteilung) AS department
723
     FROM contacts
724
     WHERE cp_abteilung IS NOT NULL AND cp_abteilung != \'\'
725
     ORDER BY cp_abteilung';
726
  $self->{all_departments} = [
727
    map(
728
      { $_->{department}; }
729
      selectall_hashref_query($::form, $dbh, $query)
730
    )
731
  ];
732

  
733
  $self->{contacts} = $self->{cv}->contacts;
734
  $self->{contacts} ||= [];
735

  
736
  $self->{shiptos} = $self->{cv}->shipto;
737
  $self->{shiptos} ||= [];
738

  
739
  $self->{template_args} = {};
740

  
741
  $self->{cv}->discount($self->{cv}->discount * 100);
742

  
743

  
744
  $::request->{layout}->add_javascripts('autocomplete_customer.js');
745
}
746

  
747
1;
js/kivi.CustomerVendor.js
1
namespace('kivi.CustomerVendor', function() {
2

  
3
  this.selectShipto = function() {
4
    var shiptoId = $('#shipto_shipto_id').val();
5

  
6
    if( shiptoId ) {
7
      var url = 'controller.pl?action=CustomerVendor/ajaj_get_shipto&id='+ $('#cv_id').val() +'&db='+ $('#db').val() +'&shipto_id='+ shiptoId;
8

  
9
      $.getJSON(url, function(data) {
10
        for(var key in data)
11
          $(document.getElementById('shipto_'+ key)).val(data[key]);
12

  
13
        $('#action_delete_shipto').show();
14
      });
15
    }
16
    else {
17
      $('#shipto :input').not(':button, :submit, :reset, :hidden').val('');
18

  
19
      $('#action_delete_shipto').hide();
20
    }
21
  };
22

  
23
  this.selectDelivery = function(fromDate, toDate) {
24
    var deliveryId = $('#delivery_id').val();
25

  
26
    if( !deliveryId )
27
      $("#delivery").empty();
28
    else {
29
      var url = 'controller.pl?action=CustomerVendor/get_delivery&id='+ $('#cv_id').val() +'&db='+ $('#db').val() +'&shipto_id='+ $('#delivery_id').val();
30

  
31
      if( fromDate && toDate )
32
        url += '&delivery_from='+ fromDate +'&delivery_to='+ toDate;
33

  
34
      $('#delivery').load(url);
35
    }
36
  };
37

  
38
  this.selectContact = function() {
39
    var contactId = $('#contact_cp_id').val();
40

  
41
    if( contactId ) {
42
      var url = 'controller.pl?action=CustomerVendor/ajaj_get_contact&id='+ $('#cv_id').val() +'&db='+ $('#db').val() +'&contact_id='+ contactId;
43

  
44
      $.getJSON(url, function(data) {
45
        var contact = data.contact;
46
        for(var key in contact)
47
          $(document.getElementById('contact_'+ key)).val(contact[key]);
48

  
49
        var cvars = data.contact_cvars;
50
        for(var key in cvars)
51
          $(document.getElementById('contact_cvar_'+ key)).val(cvars[key]);
52

  
53
        $('#action_delete_contact').show();
54
      });
55
    }
56
    else {
57
      $('#contacts :input').not(':button, :submit, :reset, :hidden').val('').removeAttr('checked').removeAttr('selected');
58

  
59
      $('#action_delete_contact').hide();
60
    }
61

  
62
    $('#contact_cp_title_select, #contact_cp_abteilung_select').val('');
63
  };
64

  
65

  
66
  this.showMap = function(prefix) {
67
    var searchStmts = [
68
      '#street',
69
      ', ',
70
      '#zipcode',
71
      ' ',
72
      '#city',
73
      ', ',
74
      '#country'
75
    ];
76

  
77
    var searchString = "";
78

  
79
    for(var i in searchStmts) {
80
      var stmt = searchStmts[i];
81
      if( stmt.charAt(0) == '#' ) {
82
        var val = $('#'+ prefix + stmt.substring(1)).val();
83
        if( val )
84
          searchString += val;
85
      }
86
      else
87
        searchString += stmt;
88
    }
89

  
90
    var url = 'https://maps.google.com/maps?q='+ encodeURIComponent(searchString);
91

  
92
    window.open(url, '_blank');
93
    window.focus();
94
  };
95

  
96
  this.showHistoryWindow = function(id) {
97
    var xPos = (screen.width - 800) / 2;
98
    var yPos = (screen.height - 500) / 2;
99
    var parm = "left="+ xPos +",top="+ yPos +",width=800,height=500,status=yes,scrollbars=yes";
100
    var url = "common.pl?INPUT_ENCODING=UTF-8&action=show_history&longdescription=&input_name="+ encodeURIComponent(id);
101
    window.open(url, "_new_generic", parm);
102
  };
103
});
templates/webpages/ct/ajax_autocomplete2.json
1
[%- USE HTML %][% USE JSON %][
2
[%- FOREACH customer = SELF.customers %]
3
 {
4
   "value": [% customer.${SELF.value}.json %],
5
   "label": [% customer.displayable_name.json %],
6
   "id": [% customer.id.json %],
7
   "customernumber": [% customer.customernumber.json %],
8
   "name": [% customer.name.json %]
9
  }[% ',' UNLESS loop.last %]
10
[%- END %]
11
]
templates/webpages/customer_vendor/form.html
1
[%- USE T8 %]
2
[%- USE HTML %]
3
[%- USE LxERP %]
4
[%- USE L %]
5

  
6
[% cv_cvars = SELF.cv.cvars_by_config %]
7

  
8
<form method="post" action="controller.pl">
9
  <div class="listtop">[% FORM.title %]</div>
10

  
11
  [% L.hidden_tag('db', FORM.db) %]
12
  [% L.hidden_tag('callback', FORM.callback) %]
13
  [% L.hidden_tag('cv.id', SELF.cv.id) %]
14

  
15
  [%- INCLUDE 'common/flash.html' %]
16

  
17
  <div class="tabwidget">
18
    <ul>
19
      <li><a href="#billing">[% 'Billing Address' | $T8 %]</a></li>
20
      <li><a href="#shipto">[% 'Shipping Address' | $T8 %]</a></li>
21
      <li><a href="#contacts">[% 'Contacts' | $T8 %]</a></li>
22
      [% IF ( SELF.cv.id ) %]
23
        <li><a href="#deliveries">[% 'Supplies' | $T8 %]</a></li>
24
      [% END %]
25
      <li><a href="#vcnotes">[% 'Notes' | $T8 %]</a></li>
26

  
27
      [% IF ( cv_cvars.size ) %]
28
        <li><a href="#custom_variables">[% 'Custom Variables' | $T8 %]</a></li>
29
      [% END %]
30
    </ul>
31

  
32
    <div id="billing">
33
      <table width="100%">
34

  
35
        <tr height="5"></tr>
36

  
37
        [% IF ( conf_vertreter ) %]<!-- == $::lx_office_conf{features}->{vertreter}; -->
38
          <tr>
39
            <th align="right">
40
              [% IF SELF.is_vendor() %]
41
                [% 'Type of Vendor' | $T8 %]
42
              [% ELSE %]
43
                [% 'Type of Customer' | $T8 %]
44
              [% END %]
45
            </th>
46

  
47
            <td>
48
              [% L.select_tag('cv.business_id', SELF.all_business, value_key = 'id', title_key = 'description', default = SELF.cv.business_id, with_empty = 1) %]
49
            </td>
50
          </tr>
51

  
52
          <tr>
53
            <th align="right">
54
              [% 'Representative' | $T8 %]
55
            </th>
56

  
57
            <td>
58
              <!-- TODO: ALL_SALESMAN_CUSTOMERS -->
59
              [% L.select_tag('cv.salesman_id', SELF.all_employees, value_key = 'id', title_key = 'safe_name', with_empty = 1) %]
60
            </td>
61
          </tr>
62

  
63
        [%- END %]
64

  
65
        <tr>
66
          [% IF SELF.is_vendor() %]
67
            <th align="right" nowrap>[% 'Vendor Number' | $T8 %]</th>
68
            <td>
69
              [% L.input_tag('cv.vendornumber', SELF.cv.vendornumber) %]
70
            </td>
71
          [%- ELSE %]
72
            <th align="right" nowrap>[% 'Customer Number' | $T8 %]</th>
73
            <td>
74
              [% L.input_tag('cv.customernumber', SELF.cv.customernumber) %]
75
            </td>
76
          [%- END %]
77
        </tr>
78

  
79
        <tr>
80
          <th align="right" nowrap>[% 'Greeting' | $T8 %]</th>
81

  
82
          <td>
83
            [% L.input_tag('cv.greeting', SELF.cv.greeting) %]
84
            [% L.select_tag('cv_greeting_select', SELF.all_greetings, default = SELF.cv.greeting, with_empty = 1, onchange = '$("#cv_greeting").val(this.value);') %]
85
          </td>
86
        </tr>
87

  
88
        <tr>
89
          <th align="right" nowrap>
90
            [% IF SELF.is_vendor() %]
91
              [% 'Vendor Name' | $T8 %]
92
            [%- ELSE %]
93
              [% 'Customer Name' | $T8 %]
94
            [%- END %]
95
          </th>
96

  
97
          <td>
98
            [% L.input_tag('cv.name', SELF.cv.name) %]
99
          </td>
100
        </tr>
101

  
102
        <tr>
103
          <th align="right" nowrap>[% 'Department' | $T8 %]</th>
104

  
105
          <td>
106
            [% L.input_tag('cv.department_1', SELF.cv.department_1, size = 16, maxlength = 75) %]
107
            [% L.input_tag('cv.department_2', SELF.cv.department_2, size = 16, maxlength = 75) %]
108
          </td>
109
        </tr>
110

  
111
        <tr>
112
          <th align="right" nowrap>[% 'Street' | $T8 %]</th>
113

  
114
          <td>
115
            [% L.input_tag('cv.street', SELF.cv.street) %]
116
            <a href="#" onclick="namespace('kivi.CustomerVendor').showMap('cv_');" title="[% 'Map' | $T8 %]">
117
              <img src="image/map.png" alt="[% 'Map' | $T8 %]" />
118
            </a>
119
          </td>
120
        </tr>
121

  
122
        <tr>
123
          <th align="right" nowrap>[% 'Zipcode' | $T8 %]/[% 'City' | $T8 %]</th>
124

  
125
          <td>
126
            [% L.input_tag('cv.zipcode', SELF.cv.zipcode, size = 5 maxlength = 10) %]
127
            [% L.input_tag('cv.city', SELF.cv.city, size = 30 maxlength = 75) %]
128
          </td>
129
        </tr>
130

  
131
        <tr>
132
          <th align="right" nowrap>[% 'Country' | $T8 %]</th>
133

  
134
          <td>
135
            [% L.input_tag('cv.country', SELF.cv.country, size = 30 maxlength = 75) %]
136
          </td>
137
        </tr>
138

  
139
        <tr>
140
          <th align="right" nowrap>[% 'Contact' | $T8 %]</th>
141

  
142
          <td>
143
            [% L.input_tag('cv.contact', SELF.cv.contact, size = 28 maxlength = 75) %]
144
          </td>
145
        </tr>
146

  
147
        <tr>
148
          <th align="right" nowrap>[% 'Phone' | $T8 %]</th>
149

  
150
          <td>
151
            [% L.input_tag('cv.phone', SELF.cv.phone, size = 30) %]
152
          </td>
153
        </tr>
154

  
155
        <tr>
156
          <th align="right" nowrap>[% 'Fax' | $T8 %]</th>
157

  
158
          <td>
159
            [% L.input_tag('cv.fax', SELF.cv.fax, size = 30 maxlength = 30) %]
160
          </td>
161
        </tr>
162

  
163
        <tr>
164
          <th align="right" nowrap>[% 'E-mail' | $T8 %]</th>
165

  
166
          <td>
167
            [% L.input_tag('cv.email', SELF.cv.email, size = 45) %]
168
          </td>
169
        </tr>
170

  
171
        <tr>
172
          <th align="right" nowrap>
173
            [% IF homepage %]
174
              <a href="[% HTML.escape(SELF.cv.homepage) %]" title="[% 'Open this Website' | $T8 %]" target="_blank">[% 'Homepage' | $T8 %]</a>
175
            [% ELSE %]
176
              [% 'Homepage' | $T8 %]
177
            [% END %]
178
          </th>
179

  
180
          <td>
181
            [% L.input_tag('cv.homepage', SELF.cv.homepage, size = 45, title = LxERP.t8('Example: http://kivitendo.de')) %]
182
          </td>
183
        </tr>
184

  
185
        <tr>
186
          <th align="right" nowrap>[% 'Username' | $T8 %]</th>
187

  
188
          <td>
189
            [% L.input_tag('cv.username', SELF.cv.username, size = 45) %]
190
          </td>
191
        </tr>
192

  
193
        <tr>
194
          <th align="right" nowrap>[% 'Password' | $T8 %]</th>
195

  
196
          <td>
197
            [% L.input_tag('cv.user_password', SELF.cv.user_password, size = 45) %]
198
          </td>
199
        </tr>
200
      </table>
201

  
202

  
203
      <table>
204

  
205
        <tr>
206
          <th align="right">[% 'Credit Limit' | $T8 %]</th>
207

  
208
          <td>
209
            [% L.input_tag('cv.creditlimit', LxERP.format_amount(SELF.cv.creditlimit, 0), size = 9) %]
210
          </td>
211

  
212

  
213
          <th align="right">[% 'Payment Terms' | $T8 %]</th>
214

  
215
          <td>
216
            [% L.select_tag('cv.payment_id', SELF.all_payment_terms, value_key = 'id', title_key = 'description', default = SELF.cv.payment_id, with_empty = 1) %]
217
          </td>
218

  
219

  
220
          <th align="right">[% 'Discount' | $T8 %]</th>
221

  
222
          <td>
223
            [% L.input_tag('cv.discount', SELF.cv.discount, size = 4) %]
224
          </td>
225
        </tr>
226

  
227
        <tr>
228
          <th align="right">[% 'Tax Number / SSN' | $T8 %]</th>
229

  
230
          <td>
231
            [% L.input_tag('cv.taxnumber', SELF.cv.taxnumber, size = 20) %]
232
          </td>
233

  
234

  
235
          <!-- Anm.: R&B 15.11.2008     VAT Reg No ist Ust-ID in GB, aber generell sollte es laut Richardson die sales tax id sein -->
236
          <th align="right">[% 'sales tax identification number' | $T8 %]</th>
237

  
238
          <td>
239
            [% L.input_tag('cv.ustid', SELF.cv.ustid, maxlength = 14 size = 20 ) %]
240
          </td>
241

  
242

  
243
          [%- IF ( SELF.is_vendor() ) %]
244
            <th align="right">[% 'Customer Number' | $T8 %]</th>
245
            <td>
246
              [% L.input_tag('cv.v_customer_id', SELF.cv.v_customer_id, size = 10) %]
247
            </td>
248
          [%- ELSE %]
249
            <th align="right">[% 'our vendor number at customer' | $T8 %]</th>
250
            <td>
251
              [% L.input_tag('cv.c_vendor_id', SELF.cv.c_vendor_id, size = 10) %]
252
            </td>
253
          [%- END %]
254
        </tr>
255

  
256
        <tr>
257
          <th align="right">[% 'Account Number' | $T8 %]</th>
258

  
259
          <td>
260
            [% L.input_tag('cv.account_number', SELF.cv.account_number, size = 10, maxlength = 100) %]
261
          </td>
262

  
263

  
264
          <th align="right">[% 'Bank Code Number' | $T8 %]</th>
265

  
266
          <td>
267
            [% L.input_tag('cv.bank_code', SELF.cv.bank_code, size = 10, maxlength = 100) %]
268
          </td>
269

  
270

  
271
          <th align="right">[% 'Bank' | $T8 %]</th>
272

  
273
          <td>
274
            [% L.input_tag('cv.bank', SELF.cv.bank, size = 20) %]
275
          </td>
276
        </tr>
277

  
278
        <tr>
279
          <th align="right">[% 'IBAN' | $T8 %]</th>
280

  
281
          <td>
282
            [% L.input_tag('cv.iban', SELF.cv.iban, size = 10, maxlength = 100) %]
283
          </td>
284

  
285

  
286
          <th align="right">[% 'BIC' | $T8 %]</th>
287
          <td>
288
            [% L.input_tag('cv.bic', SELF.cv.bic, size = 10, maxlength = 100) %]
289
          </td>
290

  
291

  
292
          [% IF ( SELF.all_currencies.size ) %]
293
            <th align="right">[% 'Currency' | $T8 %]</th>
294

  
295
            <td>
296
              [% L.select_tag('cv.curr', SELF.all_currencies, default = SELF.cv.curr, with_empty = 1) %]
297
            </td>
298
          [% END %]
299
        </tr>
300

  
301
        <tr>
302
          [% IF ( !conf_vertreter ) %]
303
            <th align="right">
304
              [% IF ( SELF.is_vendor() ) %]
305
                [% 'Type of Vendor' | $T8 %]
306
              [% ELSE %]
307
                [% 'Type of Customer' | $T8 %]
308
              [% END %]
309
            </th>
310

  
311
            <td>
312
              [% L.select_tag('cv.business_id', SELF.all_business, default = SELF.cv.business_id, value_key = 'id', title_key = 'description', with_empty = 1) %]
313
            </td>
314
          [% END %]
315

  
316

  
317
          <th align="right">[% 'Language' | $T8 %]</th>
318

  
319
          <td>
320
            [% L.select_tag('cv.language_id', SELF.all_languages, default = SELF.cv.language_id, value_key = 'id', title_key = 'description', with_empty = 1) %]
321
          </td>
322

  
323

  
324
          <th align="right">[% 'Bcc' | $T8 %]</th>
325

  
326
          <td>
327
            [% L.input_tag('cv.bcc', SELF.cv.bcc, size = 40) %]
328
          </td>
329

  
330

  
331
          [% IF ( SELF.is_customer() ) %]
332
            <th align="right">[% 'Preisklasse' | $T8 %]</th>
333

  
334
            <td>
335
              [% L.select_tag('cv.klass', SELF.all_pricegroups, default = SELF.cv.klass, value_key = 'id', title_key = 'pricegroup', with_empty = 1) %]
336
            </td>
337
          [% END  %]
338
        </tr>
339

  
340
        <tr>
341
          <td align="right">
342
            <label for="cv_obsolete">[% 'Obsolete' | $T8 %]</label>
343
          </td>
344

  
345
          <td>
346
            [% L.checkbox_tag('cv.obsolete', checked = SELF.cv.obsolete) %]
347
          </td>
348

  
349

  
350
          <td align="right">
351
            <label for="cv_direct_debit">[% 'direct debit' | $T8 %]</label>
352
          </td>
353

  
354
          <td>
355
            [% L.checkbox_tag('cv.direct_debit', checked = SELF.cv.direct_debit) %]
356
          </td>
357
        </tr>
358

  
359
        <tr>
360
          <th align="right">[% 'Steuersatz' | $T8 %]</th>
361

  
362
          <td>
363
            [% L.select_tag('cv.taxzone_id', SELF.all_taxzones, default = SELF.cv.taxzone_id, value_key = 'id', title_key = 'description') %]
364
          </td>
365

  
366

  
367
          [% IF ( SELF.is_customer() && !conf_vertreter ) %]
368
            <th align="right">[% 'Salesman' | $T8 %]</th>
369

  
370
            <td>
371
              <!-- TODO: ALL_SALESMAN -->
372
              [% L.select_tag('cv.salesman_id', SELF.all_employees, default = salesman_id, value_key = 'id', title_key = 'safe_name', with_empty = 1) %]
373
            </td>
374

  
375
            <td>[% 'taxincluded checked' | $T8 %]</td>
376

  
377
            <td>
378
              [% L.select_tag('cv.taxincluded_checked', [[undef, LxERP.t8('use user config')], ['1', LxERP.t8('Yes')], ['0', LxERP.t8('No')]], default = SELF.cv.taxincluded_checked) %]
379
            </td>
380
          [%- END %]
381
        </tr>
382
      </table>
383

  
384
      <table>
385
        <tr>
386
          <th align="left" nowrap>[% 'Internal Notes' | $T8 %]</th>
387
        </tr>
388

  
389
        <tr>
390
          <td>
391
            [% L.textarea_tag('cv.notes', SELF.cv.notes, rows = 3 cols = 60 wrap = soft) %]
392
          </td>
393
        </tr>
394
      </table>
395
    </div>
396

  
397
    <div id="shipto">
398
      <table width="100%" id="shipto_table">
399
        <tr>
400
          <th align="right">[% 'Shipping Address' | $T8 %]</th>
401

  
402
          <td>
403
            [% L.select_tag(
404
                 'shipto.shipto_id',
405
                 SELF.shiptos,
406
                 default = SELF.shipto.shipto_id,
407
                 value_key = 'shipto_id',
408
                 title_key = 'displayable_id',
409
                 with_empty = 1,
410
                 empty_title = LxERP.t8('New shipto'),
411
                 onchange = "namespace('kivi.CustomerVendor').selectShipto();"
412
               )
413
            %]
414
          </td>
415
        </tr>
416

  
417
        <tr>
418
          <th align="right" nowrap>[% 'Name' | $T8 %]</th>
419

  
420
          <td>
421
            [% L.input_tag('shipto.shiptoname', SELF.shipto.shiptoname,  size = 35, maxlength = 75) %]
422
          </td>
423
        </tr>
424

  
425
        <tr>
426
          <th align="right" nowrap>[% 'Abteilung' | $T8 %]</th>
427

  
428
          <td>
429
            [% L.input_tag('shipto.shiptodepartment_1', SELF.shipto.shiptodepartment_1,  size = 16, maxlength = 75) %]
430
            [% L.input_tag('shipto.shiptodepartment_2', SELF.shipto.shiptodepartment_2,  size = 16, maxlength = 75) %]
431
          </td>
432
        </tr>
433

  
434
        <tr>
435
          <th align="right" nowrap>[% 'Street' | $T8 %]</th>
436

  
437
          <td>
438
            [% L.input_tag('shipto.shiptostreet', SELF.shipto.shiptostreet,  size = 35, maxlength = 75) %]
439

  
440
            <a href="#" onclick="namespace('kivi.CustomerVendor').showMap('shipto_shipto');" title="[% 'Map' | $T8 %]">
441
              <img src="image/map.png" alt="[% 'Map' | $T8 %]" />
442
            </a>
443
          </td>
444
        </tr>
445

  
446
        <tr>
447
          <th align="right" nowrap>[% 'Zipcode' | $T8 %]/[% 'City' | $T8 %]</th>
448

  
449
          <td>
450
            [% L.input_tag('shipto.shiptozipcode', SELF.shipto.shiptostreet,  size = 5, maxlength = 75) %]
451
            [% L.input_tag('shipto.shiptocity', SELF.shipto.shiptocity,  size = 30, maxlength = 75) %]
452
          </td>
453
        </tr>
454

  
455
        <tr>
456
          <th align="right" nowrap>[% 'Country' | $T8 %]</th>
457

  
458
          <td>
459
            [% L.input_tag('shipto.shiptocountry', SELF.shipto.shiptocountry,  size = 35, maxlength = 75) %]
460
          </td>
461
        </tr>
462

  
463
        <tr>
464
          <th align="right" nowrap>[% 'Contact' | $T8 %]</th>
465

  
466
          <td>
467
            [% L.input_tag('shipto.shiptocontact', SELF.shipto.shiptocontact,  size = 30, maxlength = 75) %]
468
          </td>
469
        </tr>
470

  
471
        <tr>
472
          <th align="right" nowrap>[% 'Phone' | $T8 %]</th>
473

  
474
          <td>
475
            [% L.input_tag('shipto.shiptophone', SELF.shipto.shiptophone,  size = 30, maxlength = 30) %]
476
          </td>
477
        </tr>
478

  
479
        <tr>
480
          <th align="right" nowrap>[% 'Fax' | $T8 %]</th>
481

  
482
          <td>
483
            [% L.input_tag('shipto.shiptofax', SELF.shipto.shiptofax,  size = 30, maxlength = 30) %]
484
          </td>
485
        </tr>
486

  
487
        <tr>
488
          <th align="right" nowrap>[% 'E-mail' | $T8 %]</th>
489

  
490
          <td>
491
            [% L.input_tag('shipto.shiptoemail', SELF.shipto.shiptoemail,  size = 45) %]
492
          </td>
493
        </tr>
494
      </table>
495

  
496
      [% L.button_tag('submitInputButton(this);', LxERP.t8('Delete Shipto'), name = 'action_delete_shipto', class = 'submit') %]
497
      [% IF ( !SELF.shipto.shipto_id ) %]
498
        <script type="text/javascript">
499
          $('#action_delete_shipto').hide();
500
        </script>
501
      [% END %]
502
    </div>
503

  
504
    <div id="contacts">
505
      <table>
506
        <tr>
507
          <th align="left">[% 'Contacts' | $T8 %]</th>
508

  
509
          <td>
510
            [%
511
              L.select_tag(
512
                'contact.cp_id',
513
                SELF.contacts,
514
                default = SELF.contact.cp_id,
515
                with_empty = 1,
516
                empty_title = LxERP.t8('New contact'),
517
                value_key = 'cp_id',
518
                title_key = 'full_name',
519
                onchange = "namespace('kivi.CustomerVendor').selectContact();")
520
            %]
521
          </td>
522
        </tr>
523

  
524
        <tr>
525
          <th align="left" nowrap>[% 'Gender' | $T8 %]</th>
526

  
527
          <td>
528
            [%
529
              L.select_tag(
530
                'contact.cp_gender',
531
                [['m', LxERP.t8('male')], ['f', LxERP.t8('female')]],
532
                default = SELF.contact.cp_gender
533
              )
534
            %]
535
          </td>
536
        </tr>
537

  
538
        <tr>
539
          <th align="left" nowrap>[% 'Title' | $T8 %]</th>
540

  
541
          <td>
542
            [% L.input_tag('contact.cp_title', SELF.contact.cp_title, size = 40 maxlength = 75) %]
543
            [% L.select_tag('contact_cp_title_select', SELF.all_titles, with_empty = 1, onchange = '$("#contact_cp_title").val(this.value);') %]
544
          </td>
545
        </tr>
546

  
547
        <tr>
548
          <th align="left" nowrap>[% 'Department' | $T8 %]</th>
549

  
550
          <td>
551
            [% L.input_tag('contact.cp_abteilung', SELF.contact.cp_abteilung, size = 40) %]
552
            [% L.select_tag('contact_cp_abteilung_select', SELF.all_departments, default = SELF.contact.cp_abteilung,  with_empty = 1, onchange = '$("#contact_cp_abteilung").val(this.value);') %]
553
          </td>
554
        </tr>
555

  
556
        <tr>
557
          <th align="left" nowrap>[% 'Function/position' | $T8 %]</th>
558

  
559
          <td>
560
            [% L.input_tag('contact.cp_position', SELF.contact.cp_position, size = 40, maxlength = 75) %]
561
          </td>
562
        </tr>
563

  
564
        <tr>
565
          <th align="left" nowrap>[% 'Given Name' | $T8 %]</th>
566

  
567
          <td>
568
            [% L.input_tag('contact.cp_givenname', SELF.contact.cp_givenname, size = 40, maxlength = 75) %]
569
          </td>
570
        </tr>
571

  
572
        <tr>
573
          <th align="left" nowrap>[% 'Name' | $T8 %]</th>
574

  
575
          <td>
576
            [% L.input_tag('contact.cp_name', SELF.contact.cp_name, size = 40, maxlength = 75) %]
577
          </td>
578
        </tr>
579

  
580
        <tr>
581
          <th align="left" nowrap>[% 'E-mail' | $T8 %]</th>
582

  
583
          <td>
584
            [% L.input_tag('contact.cp_email', SELF.contact.cp_email, size = 40) %]
585
          </td>
586
        </tr>
587

  
588
        <tr>
589
          <th align="left" nowrap>[% 'Phone1' | $T8 %]</th>
590

  
591
          <td>
592
            [% L.input_tag('contact.cp_phone1', SELF.contact.cp_phone1, size = 40, maxlength = 75) %]
593
          </td>
594
        </tr>
595

  
596
        <tr>
597
          <th align="left" nowrap>[% 'Phone2' | $T8 %]</th>
598

  
599
          <td>
600
            [% L.input_tag('contact.cp_phone2', SELF.contact.cp_phone2, size = 40, maxlength = 75) %]
601
          </td>
602
        </tr>
603

  
604
        <tr>
605
          <th align="left" nowrap>[% 'Fax' | $T8 %]</th>
606

  
607
          <td>
608
            [% L.input_tag('contact.cp_fax', SELF.contact.cp_fax, size = 40) %]
609
          </td>
610
        </tr>
... Dieser Diff wurde abgeschnitten, weil er die maximale Anzahl anzuzeigender Zeilen überschreitet.

Auch abrufbar als: Unified diff