Projekt

Allgemein

Profil

« Zurück | Weiter » 

Revision cb2abccd

Von Sven Schöling vor mehr als 12 Jahren hinzugefügt

Ansprechpartner löschbar machen.

Ansprechpartner können jetzt gelöscht werden. Ist der Ansprechpartner noch in
verwendung wird eine Nachricht an den User gegeben und der Ansprechpartner nur
auf ungültig gesetzt. Ungültige Ansprechpartner werden in den Belegmasken nicht
angezeigt, es sei denn der Beleg wird aus der Datenbank geholt und der
ungültige Ansprechpartner ist vorausgewählt. Beim ersten Erneuern bei dem ein
anderer Ansprechpartner ausgewählt ist, der ungültige nicht mehr zur Auswahl
gestellt.

Es gibt noch keinen Aufräummechanismus für unbenutzte Zombieansprechpartner in
der Datenbank.

Beim Testen in Bonn hatte ich massive Probleme mit einem Setup unter Ubuntu
10.04 mit Postgres 8.4.10, Perl 5.10.1, DBI 1.609, RDBO 0.785, RDB 0.758, RO
0.856. Kompilierung ist scheinbar ohne erkennbare Zusammenhänge unter CGI und
FCGI schon zur compile time abgestürzt.

Sollten diese Probleme nochmal auftauchen, bitte melden.

Unterschiede anzeigen:

SL/DB/Contact.pm
14 14
# Creates get_all, get_all_count, get_all_iterator, delete_all and update_all.
15 15
__PACKAGE__->meta->make_manager_class;
16 16

  
17
sub used {
18
  my ($self) = @_;
19

  
20
  return unless $self->cp_id;
21

  
22
  require SL::DB::Order;
23
  require SL::DB::Invoice;
24
  require SL::DB::PurchaseInvoice;
25
  require SL::DB::DeliveryOrder;
26

  
27
  return SL::DB::Manager::Order->get_all_count(query => [ cp_id => $self->cp_id ])
28
       + SL::DB::Manager::Invoice->get_all_count(query => [ cp_id => $self->cp_id ])
29
       + SL::DB::Manager::PurchaseInvoice->get_all_count(query => [ cp_id => $self->cp_id ])
30
       + SL::DB::Manager::DeliveryOrder->get_all_count(query => [ cp_id => $self->cp_id ]);
31
}
32

  
33
sub detach {
34
  $_[0]->cp_cv_id(undef);
35
  $_[0]->save;
36
}
37

  
17 38
sub full_name {
18 39
  my ($self) = @_;
19 40
  die 'not an accessor' if @_ > 1;
bin/mozilla/ct.pl
51 51
use SL::CVar;
52 52
use SL::DB::Business;
53 53
use SL::DB::Default;
54
use SL::Helper::Flash;
54 55
use SL::ReportGenerator;
55 56

  
56 57
require "bin/mozilla/common.pl";
......
730 731
}
731 732

  
732 733
sub delete_contact {
733
  $main::lxdebug->enter_sub();
734

  
735
  $main::auth->assert('customer_vendor_edit');
734
  $::lxdebug->enter_sub;
735
  $::auth->assert('customer_vendor_edit');
736 736

  
737
  my $form     = $main::form;
738
  my %myconfig = %main::myconfig;
737
  CT->get_contact(\%::myconfig, $::form);
739 738

  
740
  CT->get_contact(\%myconfig, \%$form);
739
  my $contact = SL::DB::Manager::Contact->find_by(cp_id => $::form->{cp_id});
741 740

  
742
  unless ($form->{cp_used}) {
743
    CT->delete_contact($form->{cp_id});
744
    @$form{ grep /^cp_/, keys %$form } = undef;
741
  if ($contact->used) {
742
    $contact->detach;
743
    flash('info', $::locale->text('Contact is in use and was flagged invalid.'));
744
  } else {
745
    $contact->delete;
746
    flash('info', $::locale->text('Contact deleted.'));
745 747
  }
748
  delete $::form->{$_} for grep /^cp_/, keys %$::form;
746 749

  
747 750
  edit();
748 751

  
749
  $main::lxdebug->leave_sub();
752
  $::lxdebug->leave_sub;
750 753
}
751 754

  
752 755
sub ajax_autocomplete {
bin/mozilla/do.pl
266 266
          if ($form->{"project_id_$_"}); } (1..$form->{"rowcount"}));
267 267

  
268 268
  my $vc = $form->{vc} eq "customer" ? "customers" : "vendors";
269
  $form->get_lists("contacts"       => "ALL_CONTACTS",
270
                   "shipto"         => "ALL_SHIPTO",
269
  $form->get_lists("shipto"         => "ALL_SHIPTO",
271 270
                   "projects"       => {
272 271
                     "key"          => "ALL_PROJECTS",
273 272
                     "all"          => 0,
......
280 279
                   "departments"    => "ALL_DEPARTMENTS",
281 280
                   "business_types" => "ALL_BUSINESS_TYPES",
282 281
    );
282
  $::form->{ALL_CONTACTS}          = SL::DB::Manager::Contact->get_all(query => [
283
    or => [
284
      cp_cv_id => $::form->{"$::form->{vc}_id"} * 1,
285
      and      => [
286
        cp_cv_id => undef,
287
        cp_id    => $::form->{cp_id} * 1
288
      ]
289
    ]
290
  ]);
283 291

  
284 292
  map { $_->{value} = "$_->{description}--$_->{id}" } @{ $form->{ALL_DEPARTMENTS} };
285 293
  map { $_->{value} = "$_->{name}--$_->{id}"        } @{ $form->{ALL_VC} };
bin/mozilla/ir.pl
283 283
  my @old_project_ids = ($form->{"globalproject_id"});
284 284
  map { push @old_project_ids, $form->{"project_id_$_"} if $form->{"project_id_$_"}; } 1..$form->{"rowcount"};
285 285

  
286
  $form->get_lists("contacts"      => "ALL_CONTACTS",
287
                   "shipto"        => "ALL_SHIPTO",
286
  $form->get_lists("shipto"        => "ALL_SHIPTO",
288 287
                   "projects"      => { "key"    => "ALL_PROJECTS",
289 288
                                        "all"    => 0,
290 289
                                        "old_id" => \@old_project_ids },
......
295 294
                   "departments"   => "all_departments",
296 295
                   "price_factors" => "ALL_PRICE_FACTORS");
297 296

  
297
  $TMPL_VAR{ALL_CONTACTS}          = SL::DB::Manager::Contact->get_all(query => [
298
    or => [
299
      cp_cv_id => $::form->{"$::form->{vc}_id"} * 1,
300
      and      => [
301
        cp_cv_id => undef,
302
        cp_id    => $::form->{cp_id} * 1
303
      ]
304
    ]
305
  ]);
298 306
  $TMPL_VAR{sales_employee_labels} = sub { $_[0]->{name} || $_[0]->{login} };
299 307
#  $TMPL_VAR{shipto_labels}         = sub { join "; ", grep { $_ } map { $_[0]->{"shipto${_}" } } qw(name department_1 street city) };
300
  $TMPL_VAR{contact_labels}        = sub { join(', ', $_[0]->{"cp_name"}, $_[0]->{"cp_givenname"}) . ($_[0]->{cp_abteilung} ? " ($_[0]->{cp_abteilung})" : "") };
301 308
  $TMPL_VAR{department_labels}     = sub { "$_[0]->{description}--$_[0]->{id}" };
302 309

  
303 310
  # customer
bin/mozilla/is.pl
300 300
  my @old_project_ids = ($form->{"globalproject_id"});
301 301
  map { push @old_project_ids, $form->{"project_id_$_"} if $form->{"project_id_$_"}; } 1..$form->{"rowcount"};
302 302

  
303
  $form->get_lists("contacts"      => "ALL_CONTACTS",
304
                   "shipto"        => "ALL_SHIPTO",
303
  $form->get_lists("shipto"        => "ALL_SHIPTO",
305 304
                   "projects"      => { "key"    => "ALL_PROJECTS",
306 305
                                        "all"    => 0,
307 306
                                        "old_id" => \@old_project_ids },
......
313 312
                   "departments"   => "all_departments",
314 313
                   "price_factors" => "ALL_PRICE_FACTORS");
315 314

  
315
  $TMPL_VAR{ALL_CONTACTS}          = SL::DB::Manager::Contact->get_all(query => [
316
    or => [
317
      cp_cv_id => $::form->{"$::form->{vc}_id"} * 1,
318
      and      => [
319
        cp_cv_id => undef,
320
        cp_id    => $::form->{cp_id} * 1
321
      ]
322
    ]
323
  ]);
316 324
  $TMPL_VAR{sales_employee_labels} = sub { $_[0]->{name} || $_[0]->{login} };
317 325
  $TMPL_VAR{shipto_labels}         = sub { join "; ", grep { $_ } map { $_[0]->{"shipto${_}" } } qw(name department_1 street city) };
318
  $TMPL_VAR{contact_labels}        = sub { join(', ', $_[0]->{"cp_name"}, $_[0]->{"cp_givenname"}) . ($_[0]->{cp_abteilung} ? " ($_[0]->{cp_abteilung})" : "") };
319 326
  $TMPL_VAR{department_labels}     = sub { "$_[0]->{description}--$_[0]->{id}" };
320 327

  
321 328
  # customer
bin/mozilla/oe.pl
327 327
  my @old_project_ids = ($form->{"globalproject_id"}, grep { $_ } map { $form->{"project_id_$_"} } 1..$form->{"rowcount"});
328 328

  
329 329
  my $vc = $form->{vc} eq "customer" ? "customers" : "vendors";
330
  $form->get_lists("contacts"      => "ALL_CONTACTS",
331
                   "shipto"        => "ALL_SHIPTO",
330
  $form->get_lists("shipto"        => "ALL_SHIPTO",
332 331
                   "projects"      => { "key"      => "ALL_PROJECTS",
333 332
                                        "all"      => 0,
334 333
                                        "old_id"   => \@old_project_ids },
......
343 342
                   "price_factors" => "ALL_PRICE_FACTORS");
344 343

  
345 344
  # label subs
345
  $TMPL_VAR{ALL_CONTACTS}          = SL::DB::Manager::Contact->get_all(query => [
346
    or => [
347
      cp_cv_id => $::form->{"$::form->{vc}_id"} * 1,
348
      and      => [
349
        cp_cv_id => undef,
350
        cp_id    => $::form->{cp_id} * 1
351
      ]
352
    ]
353
  ]);
346 354
  $TMPL_VAR{sales_employee_labels} = sub { $_[0]->{name} || $_[0]->{login} };
347 355
  $TMPL_VAR{shipto_labels}         = sub { join "; ", grep { $_ } map { $_[0]->{"shipto${_}" } } qw(name department_1 street city) };
348
  $TMPL_VAR{contact_labels}        = sub { join(', ', $_[0]->{"cp_name"}, $_[0]->{"cp_givenname"}) . ($_[0]->{cp_abteilung} ? " ($_[0]->{cp_abteilung})" : "") };
349 356
  $TMPL_VAR{department_labels}     = sub { "$_[0]->{description}--$_[0]->{id}" };
350 357

  
351 358
  # vendor/customer
locale/de/all
417 417
  'Confirmation'                => 'Auftragsbestätigung',
418 418
  'Contact'                     => 'Kontakt',
419 419
  'Contact Person'              => 'Ansprechpartner',
420
  'Contact deleted.'            => 'Ansprechpartner gelöscht.',
421
  'Contact is in use and was flagged invalid.' => 'Ansprechpartner ist noch in Verwendung, und wurde als ungültig markiert.',
420 422
  'Contact person (surname)'    => 'Ansprechpartner (Nachname)',
421 423
  'Contacts'                    => 'Ansprechpartner',
422 424
  'Continue'                    => 'Weiter',
templates/webpages/ct/_contact.html
1 1
[% USE L %][% USE HTML %][% USE T8 %][% USE LxERP %]
2
    <table id="contact_table">
2
    <table>
3 3
     <input type="hidden" name="cp_id" value="[% HTML.escape(cp_id) %]">
4 4
     <tr>
5 5
      <th align="left">[% 'Contacts' | $T8 %]</th>
6 6
      <td>
7 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'))") %]
8
                        onchange => "\$('#contacts').load('ct.pl?action=get_contact&id=' + \$('#cvid').attr('value') + '&db=' + \$('#db').attr('value') + '&cp_id=' + \$('#cp_id').attr('value'))") %]
9 9
      </td>
10 10
     </tr>
11 11

  
......
115 115
      <td><input name="bcc" size="40" value="[% HTML.escape(bcc) %]"></td>
116 116
     </tr>
117 117
    </table>
118

  
119
    <input type="submit" id="delete_contact" name="action" value="[% 'Delete Contact' | $T8 %]" [% IF cp_used %]'disabled'[% END %]>
120

  
121
    <br style="clear: left" />
templates/webpages/ct/form_header.html
314 314

  
315 315
   <div id="contacts" class="tabcontent">
316 316
    [% INCLUDE 'ct/_contact.html' %]
317

  
318
    <input type="submit" id="delete_contact" name="action" value="[% 'Delete Contact' | $T8 %]" disabled>
319
    <br style="clear: left" />
320 317
   </div>
321 318

  
322 319
   <div id="deliveries" class="tabcontent">
templates/webpages/do/form_header.html
137 137
          [%- HTML.escape(row.cp_name) %][%- IF row.cp_abteilung %] ([% HTML.escape(row.cp_abteilung) %])[% END -%]
138 138
          [%- END %]
139 139
          [%- ELSE %]
140
          <select name="cp_id" class="fixed_width" >
141
           <option></option>
142
           [%- FOREACH row = ALL_CONTACTS %]
143
           <option value="[% HTML.escape(row.cp_id) %]"[% IF cp_id == row.cp_id %] selected[% END %]>
144
            [%- HTML.escape(row.cp_name) %][%- IF row.cp_abteilung %] ([% HTML.escape(row.cp_abteilung) %])[% END -%]
145
           </option>
146
           [%- END %]
147
          </select>
140
            [% L.select_tag('cp_id', L.options_for_select(ALL_CONTACTS, default=cp_id, value='cp_id', title='full_name_dep', with_empty=1), style='width: 250px') %]
148 141
          [%- END %]
149 142
         </td>
150 143
        </tr>
templates/webpages/ir/form_header.html
54 54
        <tr>
55 55
          <th align="right">[% 'Contact Person' | $T8 %]</th>
56 56
          <td>
57
            [%- INCLUDE 'generic/multibox.html'
58
                 name       = 'cp_id',
59
                 style      = 'width: 250px',
60
                 DATA       = ALL_CONTACTS,
61
                 id_key     = 'cp_id',
62
                 label_sub  = 'contact_labels',
63
                 show_empty = 1 -%]
57
            [% L.select_tag('cp_id', L.options_for_select(ALL_CONTACTS, default=cp_id, value='cp_id', title='full_name_dep', with_empty=1), style='width: 250px') %]
64 58
          </td>
65 59
        </tr>
66 60
[%- END %]
templates/webpages/is/form_header.html
55 55
        <tr>
56 56
          <th align="right">[% 'Contact Person' | $T8 %]</th>
57 57
          <td>
58
            [% L.select_tag('cp_id', L.options_for_select(ALL_CONTACTS, default=cp_id, value='cp_id', title_sub=\contact_labels, with_empty=1), style='width: 250px') %]
58
            [% L.select_tag('cp_id', L.options_for_select(ALL_CONTACTS, default=cp_id, value='cp_id', title='full_name_dep', with_empty=1), style='width: 250px') %]
59 59
          </td>
60 60
        </tr>
61 61
[%- END %]
templates/webpages/oe/form_header.html
58 58
                  <tr>
59 59
                    <th align="right">[% 'Contact Person' | $T8 %]</th>
60 60
                    <td>
61
                      [% L.select_tag('cp_id', L.options_for_select(ALL_CONTACTS, default=cp_id, value='cp_id', title_sub=\contact_labels, with_empty=1), style='width: 250px') %]
61
                      [% L.select_tag('cp_id', L.options_for_select(ALL_CONTACTS, default=cp_id, value='cp_id', title='full_name_dep', with_empty=1), style='width: 250px') %]
62 62
                    </td>
63 63
                  </tr>
64 64
[%- END %]

Auch abrufbar als: Unified diff