Projekt

Allgemein

Profil

« Zurück | Weiter » 

Revision 6615e407

Von Tamino Steinert vor 6 Monaten hinzugefügt

  • ID 6615e407727d9a058ed0bb737b796a4cfdaecc9e
  • Vorgänger 524027f4
  • Nachfolger d3ebfa65

EmailJournal: suche auch über Email-Domain nach Kunde/Lieferant

Unterschiede anzeigen:

SL/Controller/EmailJournal.pm
582 582
      ],
583 583
      with_objects => [ 'shipto' ],
584 584
    );
585
    if ($manager eq 'SL::DB::Manager::Customer') {
586
      $customer_vendor ||= $manager->get_first(
587
        where => [
588
          or => [
589
            'additional_billing_addresses.email' => $email_address,
590
          ],
591
        ],
592
        with_objects => [ 'additional_billing_addresses' ],
593
      );
594
    }
595
  }
596

  
597
  # if no exact match is found search for domain and match only on one hit
598
  unless ($customer_vendor) {
599
    my $email_domain = $email_address;
600
    $email_domain =~ s/.*@(.*)/$1/;
601
    my @domain_hits_cusotmer_vendor = ();
602
    foreach my $manager (qw(SL::DB::Manager::Customer SL::DB::Manager::Vendor)) {
603
      my @domain_hits = ();
604
      push @domain_hits, @{$manager->get_all(
605
        where => [
606
          or => [
607
            email => {ilike => "%$email_domain"},
608
            cc    => {ilike => "%$email_domain"},
609
            bcc   => {ilike => "%$email_domain"},
610
          ],
611
        ],
612
      )};
613
      push @domain_hits, @{$manager->get_all(
614
        where => [
615
          or => [
616
            'contacts.cp_email'       => {ilike => "%$email_domain"},
617
            'contacts.cp_privatemail' => {ilike => "%$email_domain"},
618
          ],
619
        ],
620
        with_objects => [ 'contacts'],
621
      )};
622
      push @domain_hits, @{$manager->get_all(
623
        where => [
624
          or => [
625
            'shipto.shiptoemail' => {ilike => "%$email_domain"},
626
          ],
627
        ],
628
        with_objects => [ 'shipto' ],
629
      )};
630
      push @domain_hits, @{$manager->get_all(
631
        where => [
632
          or => [
633
            'shipto.shiptoemail' => {ilike => "%$email_domain"},
634
          ],
635
        ],
636
        with_objects => [ 'shipto' ],
637
      )};
638
      if ($manager eq 'SL::DB::Manager::Customer') {
639
        push @domain_hits, @{$manager->get_all(
640
          where => [
641
            or => [
642
              'additional_billing_addresses.email' => {ilike => "%$email_domain"},
643
            ],
644
          ],
645
          with_objects => [ 'additional_billing_addresses' ],
646
        )};
647
      }
648
      # get every customer_vendor only once
649
      my %id_to_customer_vendor = ();
650
      $id_to_customer_vendor{$_->id} = $_ for @domain_hits;
651
      push @domain_hits_cusotmer_vendor, $id_to_customer_vendor{$_} for keys %id_to_customer_vendor;
652
    }
653

  
654
    if (scalar @domain_hits_cusotmer_vendor == 1) {
655
      $customer_vendor = $domain_hits_cusotmer_vendor[0];
656
    }
585 657
  }
586 658

  
587 659
  return $customer_vendor;

Auch abrufbar als: Unified diff