Projekt

Allgemein

Profil

« Zurück | Weiter » 

Revision a65c8e99

Von Moritz Bunkus vor mehr als 13 Jahren hinzugefügt

  • ID a65c8e991906fc1ad47af84decc066672348ce1b
  • Vorgänger b1d38913
  • Nachfolger 59486b32

Ansprechpersonentab mit jQuery & AJAX neu laden lassen, nicht via CGI::AJAX

Unterschiede anzeigen:

bin/mozilla/ct.pl
298 298
  join('; ', grep { $_ } map { $s->{"shipto$_"} } qw(name department_1 street city)) || ' '
299 299
}
300 300

  
301
sub _contacts_label {
302
  join ", ", grep { $_ } $_[0]->{cp_name}, $_[0]->{cp_givenname};
303
}
304

  
301 305
sub form_header {
302 306
  $main::lxdebug->enter_sub();
303 307

  
......
319 323
  $form->{is_customer}    = $form->{db}     eq 'customer';
320 324
  $form->{salesman_label} = sub { $_[0]->{name} ne "" ? $_[0]->{name} : $_[0]->{login} };
321 325
  $form->{shipto_label}   = \&_shipto_label;
322
  $form->{contacts_label} = sub { join ", ", grep { $_ } $_[0]->{cp_name}, $_[0]->{cp_givenname} };
326
  $form->{contacts_label} = \&_contacts_label;
323 327
  $form->{taxzone_id}     = 0                                                               if !$form->{id};
324 328
  $form->{jsscript}       = 1;
325 329
  $form->{fokus}          = "ct.greeting";
326
  $form->{AJAX}           = [ new CGI::Ajax( map {; "get_$_" => "$form->{script}?action=get_$_" } qw(contact delivery) ) ];
330
  $form->{AJAX}           = [ new CGI::Ajax( map {; "get_$_" => "$form->{script}?action=get_$_" } qw(delivery) ) ];
327 331
  $form->{SHIPTO_ALL}     = [ +{ shipto_id => '0', shiptoname => $::locale->text('All') }, @{ $form->{SHIPTO} } ];
328 332

  
329
  unshift @{ $form->{CONTACTS} }, +{ cp_id     => '0', cp_name => $locale->text('New contact') };
330

  
331 333
  $form->{title} = $form->{title_save}
332 334
                || $locale->text("$form->{title} " . ucfirst $form->{db}) . ($form->{title} eq "Edit" ? " $form->{name}" : '');
333 335

  
334 336
  CT->query_titles_and_greetings(\%myconfig, \%$form);
335
  map { $form->{"MB_$_"} = [ map +{ id => $_, description => $_ }, @{ $form->{$_} } ] } qw(TITLES GREETINGS COMPANY_GREETINGS DEPARTMENT);
337
  map { $form->{"MB_$_"} = [ map +{ id => $_, description => $_ }, @{ $form->{$_} } ] } qw(COMPANY_GREETINGS);
336 338

  
337 339
  $form->{NOTES} ||= [ ];
338 340

  
......
651 653

  
652 654
  $main::auth->assert('customer_vendor_edit');
653 655

  
654
  my $form     = $main::form;
655
  my %myconfig = %main::myconfig;
656
  CT->populate_drop_down_boxes(\%::myconfig, $::form);
657
  CT->query_titles_and_greetings(\%::myconfig, $::form);
658
  CT->get_contact(\%::myconfig, $::form) if $::form->{cp_id};
656 659

  
657
  CT->get_contact(\%myconfig, \%$form);
658
  print $form->ajax_response_header(), join '__pjx__', map $form->{"cp_$_"},
659
    qw(name title givenname phone1 phone2 email abteilung fax mobile1 mobile2 satphone satfax project privatphone privatemail birthday used gender);
660
  $main::lxdebug->leave_sub();
660
  $::form->{contacts_label} = \&_contacts_label;
661 661

  
662
  print $::form->ajax_response_header(), $::form->parse_html_template('ct/_contact');
663

  
664
  $main::lxdebug->leave_sub();
662 665
}
663 666

  
664 667
sub get_shipto {
templates/webpages/ct/_contact.html
1
[% USE L %][% USE HTML %][% USE T8 %][% USE LxERP %]
2
    <table id="contact_table">
3
     <input type="hidden" name="cp_id" value="[% HTML.escape(cp_id) %]">
4
     <tr>
5
      <th align="left">[% 'Contacts' | $T8 %]</th>
6
      <td>
7
       [%- L.select_tag('cp_id', L.options_for_select(CONTACTS, default => cp_id, with_empty => 1, empty_title => LxERP.t8('New contact'), value => 'cp_id', title_sub => \contacts_label),
8
                        onchange => "\$('#contact_table').load('ct.pl?action=get_contact&id=' + \$('#cvid').attr('value') + '&db=' + \$('#db').attr('value') + '&cp_id=' + \$('#cp_id').attr('value'))") %]
9
      </td>
10
     </tr>
11

  
12
    <tr>
13
     <th align="left" nowrap>[% 'Gender' | $T8 %]</th>
14
     <td>
15
      <select id="cp_gender" name="cp_gender">
16
       <option value="m"[% IF cp_gender == 'm' %] selected[% END %]>[% 'male' | $T8 %]</option>
17
       <option value="f"[% IF cp_gender == 'f' %] selected[% END %]>[% 'female' | $T8 %]</option>
18
      </select>
19
     </td>
20
    </tr>
21
    <tr>
22

  
23
     <tr>
24
      <th align="left" nowrap>[% 'Title' | $T8 %]</th>
25
      <td>
26
       <input id="cp_title" name="cp_title" size="40" maxlength="75" value="[% HTML.escape(cp_title) %]">&nbsp;
27
       [% L.select_tag('selected_cp_title', L.options_for_select(TITLES, with_empty => 1)) %]
28
      </td>
29
     </tr>
30

  
31
     <tr>
32
      <th align="left" nowrap>[% 'Department' | $T8 %]</th>
33
      <td>
34
       <input id="cp_abteilung" name="cp_abteilung" size="40" value="[% HTML.escape(cp_abteilung) %]">&nbsp;
35
       [% L.select_tag('selected_cp_abteilung', L.options_for_select(DEPARTMENT, with_empty => 1)) %]
36
      </td>
37
     </tr>
38

  
39
     <tr>
40
      <th align="left" nowrap>[% 'Given Name' | $T8 %]</th>
41
      <td><input id="cp_givenname" name="cp_givenname" size="40" maxlength="75" value="[% HTML.escape(cp_givenname) %]"></td>
42
     </tr>
43

  
44
     <tr>
45
      <th align="left" nowrap>[% 'Name' | $T8 %]</th>
46
      <td><input id="cp_name" name="cp_name" size="40" maxlength="75" value="[% HTML.escape(cp_name) %]"></td>
47
     </tr>
48

  
49
     <tr>
50
      <th align="left" nowrap>[% 'Phone1' | $T8 %]</th>
51
      <td><input id="cp_phone1" name="cp_phone1" size="40" maxlength="75" value="[% HTML.escape(cp_phone1) %]"></td>
52
     </tr>
53

  
54
     <tr>
55
      <th align="left" nowrap>[% 'Phone2' | $T8 %]</th>
56
      <td><input id="cp_phone2" name="cp_phone2" size="40" maxlength="75" value="[% HTML.escape(cp_phone2) %]"></td>
57
     </tr>
58

  
59
     <tr>
60
      <th align="left" nowrap>[% 'Fax' | $T8 %]</th>
61
      <td><input id="cp_fax" name="cp_fax" size="40" value="[% HTML.escape(cp_fax) %]"></td>
62
     </tr>
63

  
64
     <tr>
65
      <th align="left" nowrap>[% 'Mobile1' | $T8 %]</th>
66
      <td><input id="cp_mobile1" name="cp_mobile1" size="40" value="[% HTML.escape(cp_mobile1) %]"></td>
67
     </tr>
68

  
69
     <tr>
70
      <th align="left" nowrap>[% 'Mobile2' | $T8 %]</th>
71
      <td><input id="cp_mobile2" name="cp_mobile2" size="40" value="[% HTML.escape(cp_mobile2) %]"></td>
72
     </tr>
73

  
74
     <tr>
75
      <th align="left" nowrap>[% 'Sat. Phone' | $T8 %]</th>
76
      <td><input id="cp_satphone" name="cp_satphone" size="40" value="[% HTML.escape(cp_satphone) %]"></td>
77
     </tr>
78

  
79
     <tr>
80
      <th align="left" nowrap>[% 'Sat. Fax' | $T8 %]</th>
81
      <td><input id="cp_satfax" name="cp_satfax" size="40" value="[% HTML.escape(cp_satfax) %]"></td>
82
     </tr>
83

  
84
     <tr>
85
      <th align="left" nowrap>[% 'Project' | $T8 %]</th>
86
      <td><input id="cp_project" name="cp_project" size="40" value="[% HTML.escape(cp_project) %]"></td>
87
     </tr>
88

  
89
     <tr>
90
      <th align="left" nowrap>[% 'E-mail' | $T8 %]</th>
91
      <td><input id="cp_email" name="cp_email" size="40" value="[% HTML.escape(cp_email) %]"></td>
92
     </tr>
93

  
94
     <tr>
95
      <th align="left" nowrap>[% 'Private Phone' | $T8 %]</th>
96
      <td><input id="cp_privatphone" name="cp_privatphone" size="40" value="[% HTML.escape(cp_privatphone) %]"></td>
97
     </tr>
98

  
99
     <tr>
100
      <th align="left" nowrap>[% 'Private E-mail' | $T8 %]</th>
101
      <td><input id="cp_privatemail" name="cp_privatemail" size="40" value="[% HTML.escape(cp_privatemail) %]"></td>
102
     </tr>
103

  
104
     <tr>
105
      <th align="left" nowrap>[% 'Birthday' | $T8 %]</th>
106
      <td><input id="cp_birthday" name="cp_birthday" size="40" value="[% HTML.escape(cp_birthday) %]"></td>
107
     </tr>
108

  
109
     <tr>
110
      <td colspan="2"><hr></td>
111
     </tr>
112

  
113
     <tr>
114
      <th align="left" nowrap>[% 'Bcc' | $T8 %]</th>
115
      <td><input name="bcc" size="40" value="[% HTML.escape(bcc) %]"></td>
116
     </tr>
117
    </table>
templates/webpages/ct/form_header.html
307 307
   </div>
308 308

  
309 309
   <div id="contacts" class="tabcontent">
310
    <table>
311
     <input type="hidden" name="cp_id" value="[% HTML.escape(cp_id) %]">
312
     <tr>
313
      <th align="left">[% 'Contacts' | $T8 %]</th>
314
      <td>
315
       [%- INCLUDE generic/multibox.html
316
             name       = 'cp_id',
317
             id         = 'cp_id',
318
             DATA       = CONTACTS,
319
             onChange   = "on_contact_changed()",
320
             id_key     = 'cp_id',
321
             label_sub  = 'contacts_label',
322
       -%]
323
      </td>
324
     </tr>
325

  
326
    <tr>
327
     <th align="left" nowrap>[% 'Gender' | $T8 %]</th>
328
     <td>
329
      <select id="cp_gender" name="cp_gender">
330
       <option value="m"[% IF cp_gender == 'm' %] selected[% END %]>[% 'male' | $T8 %]</option>
331
       <option value="f"[% IF cp_gender == 'f' %] selected[% END %]>[% 'female' | $T8 %]</option>
332
      </select>
333
     </td>
334
    </tr>
335
    <tr>
336

  
337
     <tr>
338
      <th align="left" nowrap>[% 'Title' | $T8 %]</th>
339
      <td>
340
       <input id="cp_title" name="cp_title" size="40" maxlength="75" value="[% HTML.escape(cp_title) %]">&nbsp;
341
       [%- INCLUDE generic/multibox.html
342
             name       = 'selected_cp_title',
343
             id         = 'selected_cp_title',
344
             DATA       = MB_TITLES,
345
             show_empty = 1,
346
             id_key     = 'id',
347
             label_key  = 'description',
348
       -%]
349
      </td>
350
     </tr>
351

  
352
     <tr>
353
      <th align="left" nowrap>[% 'Department' | $T8 %]</th>
354
      <td>
355
       <input id="cp_abteilung" name="cp_abteilung" size="40" value="[% HTML.escape(cp_abteilung) %]">&nbsp;
356
       [%- INCLUDE generic/multibox.html
357
             name       = 'selected_cp_abteilung',
358
             id         = 'selected_cp_abteilung',
359
             DATA       = MB_DEPARTMENT,
360
             show_empty = 1,
361
             id_key     = 'id',
362
             label_key  = 'description',
363
       -%]
364
      </td>
365
     </tr>
366

  
367
     <tr>
368
      <th align="left" nowrap>[% 'Given Name' | $T8 %]</th>
369
      <td><input id="cp_givenname" name="cp_givenname" size="40" maxlength="75" value="[% HTML.escape(cp_givenname) %]"></td>
370
     </tr>
371

  
372
     <tr>
373
      <th align="left" nowrap>[% 'Name' | $T8 %]</th>
374
      <td><input id="cp_name" name="cp_name" size="40" maxlength="75" value="[% HTML.escape(cp_name) %]"></td>
375
     </tr>
376

  
377
     <tr>
378
      <th align="left" nowrap>[% 'Phone1' | $T8 %]</th>
379
      <td><input id="cp_phone1" name="cp_phone1" size="40" maxlength="75" value="[% HTML.escape(cp_phone1) %]"></td>
380
     </tr>
381

  
382
     <tr>
383
      <th align="left" nowrap>[% 'Phone2' | $T8 %]</th>
384
      <td><input id="cp_phone2" name="cp_phone2" size="40" maxlength="75" value="[% HTML.escape(cp_phone2) %]"></td>
385
     </tr>
386

  
387
     <tr>
388
      <th align="left" nowrap>[% 'Fax' | $T8 %]</th>
389
      <td><input id="cp_fax" name="cp_fax" size="40" value="[% HTML.escape(cp_fax) %]"></td>
390
     </tr>
391

  
392
     <tr>
393
      <th align="left" nowrap>[% 'Mobile1' | $T8 %]</th>
394
      <td><input id="cp_mobile1" name="cp_mobile1" size="40" value="[% HTML.escape(cp_mobile1) %]"></td>
395
     </tr>
396

  
397
     <tr>
398
      <th align="left" nowrap>[% 'Mobile2' | $T8 %]</th>
399
      <td><input id="cp_mobile2" name="cp_mobile2" size="40" value="[% HTML.escape(cp_mobile2) %]"></td>
400
     </tr>
401

  
402
     <tr>
403
      <th align="left" nowrap>[% 'Sat. Phone' | $T8 %]</th>
404
      <td><input id="cp_satphone" name="cp_satphone" size="40" value="[% HTML.escape(cp_satphone) %]"></td>
405
     </tr>
406

  
407
     <tr>
408
      <th align="left" nowrap>[% 'Sat. Fax' | $T8 %]</th>
409
      <td><input id="cp_satfax" name="cp_satfax" size="40" value="[% HTML.escape(cp_satfax) %]"></td>
410
     </tr>
411

  
412
     <tr>
413
      <th align="left" nowrap>[% 'Project' | $T8 %]</th>
414
      <td><input id="cp_project" name="cp_project" size="40" value="[% HTML.escape(cp_project) %]"></td>
415
     </tr>
416

  
417
     <tr>
418
      <th align="left" nowrap>[% 'E-mail' | $T8 %]</th>
419
      <td><input id="cp_email" name="cp_email" size="40" value="[% HTML.escape(cp_email) %]"></td>
420
     </tr>
421

  
422
     <tr>
423
      <th align="left" nowrap>[% 'Private Phone' | $T8 %]</th>
424
      <td><input id="cp_privatphone" name="cp_privatphone" size="40" value="[% HTML.escape(cp_privatphone) %]"></td>
425
     </tr>
426

  
427
     <tr>
428
      <th align="left" nowrap>[% 'Private E-mail' | $T8 %]</th>
429
      <td><input id="cp_privatemail" name="cp_privatemail" size="40" value="[% HTML.escape(cp_privatemail) %]"></td>
430
     </tr>
431

  
432
     <tr>
433
      <th align="left" nowrap>[% 'Birthday' | $T8 %]</th>
434
      <td><input id="cp_birthday" name="cp_birthday" size="40" value="[% HTML.escape(cp_birthday) %]"></td>
435
     </tr>
436

  
437
     <tr>
438
      <td colspan="2"><hr></td>
439
     </tr>
440

  
441
     <tr>
442
      <th align="left" nowrap>[% 'Bcc' | $T8 %]</th>
443
      <td><input name="bcc" size="40" value="[% HTML.escape(bcc) %]"></td>
444
     </tr>
445
    </table>
310
    [% INCLUDE 'ct/_contact.html' %]
446 311

  
447 312
    <input type="submit" id="delete_contact" name="action" value="[% 'Delete Contact' | $T8 %]" disabled>
448 313
    <br style="clear: left" />
......
597 462
       s.selectedIndex = (gender == 'f') ? 1 : 0;
598 463
     }
599 464
   }
600

  
601
   function on_contact_changed() {
602
     get_contact(['cp_id__' + $('#cp_id').attr('value')],
603
                 ['cp_name','cp_title','cp_givenname','cp_phone1','cp_phone2','cp_email','cp_abteilung','cp_fax','cp_mobile1','cp_mobile2',
604
                  'cp_satphone','cp_satfax','cp_project','cp_privatphone','cp_privatemail','cp_birthday',enable_delete_contact,set_gender]);
605
     $('#selected_cp_title').attr('selectedIndex', 0);
606
     $('#selected_cp_abteilung').attr('selectedIndex', 0);
607
   }
608 465
  -->
609 466

  
610 467
  </script>

Auch abrufbar als: Unified diff