Projekt

Allgemein

Profil

« Zurück | Weiter » 

Revision f92238b9

Von Kivitendo Admin vor mehr als 6 Jahren hinzugefügt

  • ID f92238b98bcce39c427a903063a578f873bfd32d
  • Vorgänger 62966f4b
  • Nachfolger 4ff59605

SL::DB::ShopOrder - neue Methode check_for_existing_customers

Fuzzy Search von möglichen Kundenübereinstimmungen, die als Vorschläge
für Kundenzuweisungen genommen werden.

Unterschiede anzeigen:

SL/DB/ShopOrder.pm
107 107
   }
108 108
};
109 109

  
110
sub check_for_existing_customers {
111
  my ($self, %params) = @_;
112

  
113
  my $name     = $self->billing_lastname ne '' ? $self->billing_firstname . " " . $self->billing_lastname : '';
114
  my $lastname = $self->billing_lastname ne '' ? "%" . $self->billing_lastname . "%"                      : '';
115
  my $company  = $self->billing_company  ne '' ? "%" . $self->billing_company  . "%"                      : '';
116
  my $street   = $self->billing_street   ne '' ?  $self->billing_street                                   : '';
117

  
118
  # Fuzzysearch for street to find e.g. "Dorfstrasse - Dorfstr. - Dorfstraße"
119
  my $fs_query = <<SQL;
120
SELECT *
121
FROM customer
122
WHERE (
123
   (
124
    ( name ILIKE ? OR name ILIKE ? )
125
      AND
126
    zipcode ILIKE ?
127
   )
128
 OR
129
   ( street % ?  AND zipcode ILIKE ?)
130
 OR
131
   email ILIKE ?
132
)
133
SQL
134
  my @values = ($lastname, $company, $self->billing_zipcode, $street, $self->billing_zipcode, $self->billing_email);
135
  my $customers = SL::DB::Manager::Customer->get_objects_from_sql(
136
    sql  => $fs_query,
137
    args => \@values,
138
  );
139
  return $customers;
140
}
141

  
110 142
sub compare_to {
111 143
  my ($self, $other) = @_;
112 144

  
......
119 151
}
120 152

  
121 153
1;
154

  
155
__END__
156

  
157
=pod
158

  
159
=encoding utf-8
160

  
161
=head1 NAME
162

  
163
SL::DB::ShopOrder - Model for the 'shop_orders' table
164

  
165
=head1 SYNOPSIS
166

  
167
This is a standard Rose::DB::Object based model and can be used as one.
168

  
169
=head1 METHODS
170

  
171
=over 4
172

  
173
=item C<convert_to_sales_order>
174

  
175
=item C<check_for_existing_customers>
176

  
177
Inexact search for possible matches with existing customers in the database.
178

  
179
Returns all found customers as an arrayref of SL::DB::Customer objects.
180

  
181
=item C<compare_to>
182

  
183
=back
184

  
185
=head1 AUTHORS
186

  
187
Werner Hahn E<lt>wh@futureworldsearch.netE<gt>
188

  
189
G. Richardson E<lt>grichardson@kivitendo-premium.deE<gt>
190

  
191
=cut

Auch abrufbar als: Unified diff