Projekt

Allgemein

Profil

« Zurück | Weiter » 

Revision 4070dbf3

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

  • ID 4070dbf38e04b168fe43bd3a6e5a3f28f77e986d
  • Vorgänger 8545bbce
  • Nachfolger 5104dee4

Suche nach Ansprechpartnern

Merge aus zwei verschiedenen Implementierungen der gleichen Funktionalität

Features:
- behandelt Ansprechparter als direkte Suchziele wie Kunden und Lieferanten (1)
- Suche ähnlich den bekannten Suchmasken (1)
- Suche nach direktem Suchwort (2)
- Verlinkung einer Schnellsuche in der menunew header Leiste (2)

Unterschiede anzeigen:

SL/CT.pm
1207 1207
  $main::lxdebug->leave_sub();
1208 1208
}
1209 1209

  
1210
sub search_contacts {
1211
  $::lxdebug->enter_sub;
1212

  
1213
  my $self      = shift;
1214
  my %params    = @_;
1215

  
1216
  my $dbh       = $params{dbh} || $::form->get_standard_dbh;
1217
  my $vc        = $params{db} eq 'customer' ? 'customer' : 'vendor';
1218

  
1219
  my %sortspecs = (
1220
    'cp_name'   => 'cp_name, cp_givenname',
1221
    'vcname'    => 'vcname, cp_name, cp_givenname',
1222
    'vcnumber'  => 'vcnumber, cp_name, cp_givenname',
1223
    );
1224

  
1225
  my %sortcols  = map { $_ => 1 } qw(cp_name cp_givenname cp_phone1 cp_phone2 cp_mobile1 cp_email vcname vcnumber);
1226

  
1227
  my $order_by  = $sortcols{$::form->{sort}} ? $::form->{sort} : 'cp_name';
1228
  $::form->{sort} = $order_by;
1229
  $order_by     = $sortspecs{$order_by} if ($sortspecs{$order_by});
1230

  
1231
  my $sortdir   = $::form->{sortdir} ? 'ASC' : 'DESC';
1232
  $order_by     =~ s/,/ ${sortdir},/g;
1233
  $order_by    .= " $sortdir";
1234

  
1235
  my @where_tokens = ();
1236
  my @values;
1237

  
1238
  if ($params{search_term}) {
1239
    my @tokens;
1240
    push @tokens,
1241
      'cp.cp_name      ILIKE ?',
1242
      'cp.cp_givenname ILIKE ?',
1243
      'cp.cp_email     ILIKE ?';
1244
    push @values, ('%' . $params{search_term} . '%') x 3;
1245

  
1246
    if (($params{search_term} =~ m/\d/) && ($params{search_term} !~ m/[^\d \(\)+\-]/)) {
1247
      my $number =  $params{search_term};
1248
      $number    =~ s/[^\d]//g;
1249
      $number    =  join '[ /\(\)+\-]*', split(m//, $number);
1250

  
1251
      push @tokens, map { "($_ ~ '$number')" } qw(cp_phone1 cp_phone2 cp_mobile1 cp_mobile2);
1252
    }
1253

  
1254
    push @where_tokens, map { "($_)" } join ' OR ', @tokens;
1255
  }
1256

  
1257
  if (my $filter = $params{filter}) {
1258
    for (qw(name title givenname email project abteilung)) {
1259
      next unless $filter->{"cp_$_"};
1260
      add_token(\@where_tokens, \@values, col =>  "cp.cp_$_", val => $filter->{"cp_$_"}, method => 'ILIKE', esc => 'substr');
1261
    }
1262

  
1263
    push @where_tokens, 'cp.cp_cv_id IS NOT NULL' if $filter->{status} eq 'active';
1264
    push @where_tokens, 'cp.cp_cv_id IS NULL'     if $filter->{status} eq 'orphaned';
1265
  }
1266

  
1267
  my $where = @where_tokens ? 'WHERE ' . join ' AND ', @where_tokens : '';
1268

  
1269
  my $query     = qq|SELECT cp.*,
1270
                       COALESCE(c.id,             v.id)           AS vcid,
1271
                       COALESCE(c.name,           v.name)         AS vcname,
1272
                       COALESCE(c.customernumber, v.vendornumber) AS vcnumber,
1273
                       CASE WHEN c.name IS NULL THEN 'vendor' ELSE 'customer' END AS db
1274
                     FROM contacts cp
1275
                     LEFT JOIN customer c ON (cp.cp_cv_id = c.id)
1276
                     LEFT JOIN vendor v   ON (cp.cp_cv_id = v.id)
1277
                     $where
1278
                     ORDER BY $order_by|;
1279

  
1280
  my $contacts  = selectall_hashref_query($::form, $dbh, $query, @values);
1281

  
1282
  $::lxdebug->leave_sub;
1283

  
1284
  return @{ $contacts };
1285
}
1286

  
1287

  
1210 1288
1;
bin/mozilla/ct.pl
49 49

  
50 50
use SL::CT;
51 51
use SL::CVar;
52
use SL::Request qw(flatten);
52 53
use SL::DB::Business;
53 54
use SL::DB::Default;
54 55
use SL::Helper::Flash;
......
110 111
  $main::lxdebug->leave_sub();
111 112
}
112 113

  
114
sub search_contact {
115
  $::lxdebug->enter_sub;
116
  $::auth->assert('customer_vendor_edit');
117

  
118
  $::form->{fokus}    = 'Form.name';
119

  
120
  $::form->header;
121
  print $::form->parse_html_template('ct/search_contact');
122

  
123
  $::lxdebug->leave_sub;
124
}
125

  
113 126
sub list_names {
114 127
  $main::lxdebug->enter_sub();
115 128

  
......
268 281
  $main::lxdebug->leave_sub();
269 282
}
270 283

  
284
sub list_contacts {
285
  $::lxdebug->enter_sub;
286
  $::auth->assert('customer_vendor_edit');
287

  
288
  $::form->{sortdir} = 1 unless defined $::form->{sortdir};
289

  
290
  my @contacts     = CT->search_contacts(
291
    search_term => $::form->{search_term},
292
    filter      => $::form->{filter},
293
  );
294

  
295
  my @columns      = qw(
296
    cp_id vcname vcnumber cp_name cp_givenname cp_street cp_phone1 cp_phone2
297
    cp_mobile1 cp_mobile2 cp_email cp_abteilung cp_birthday cp_gender
298
  );
299

  
300
  my @visible_columns;
301
  if ($::form->{l}) {
302
    @visible_columns = grep { $::form->{l}{$_} } @columns;
303
    push @visible_columns, qw(cp_phone1 cp_phone2)   if $::form->{l}{cp_phone};
304
    push @visible_columns, qw(cp_mobile1 cp_mobile2) if $::form->{l}{cp_mobile};
305
  } else {
306
   @visible_columns = qw(vcname vcnumber cp_name cp_givenname cp_phone1 cp_phone2 cp_mobile1 cp_email);
307
  }
308

  
309
  my %column_defs  = (
310
    'cp_id'        => { 'text' => $::locale->text('ID'), },
311
    'vcname'       => { 'text' => $::locale->text('Customer/Vendor'), },
312
    'vcnumber'     => { 'text' => $::locale->text('Customer/Vendor Number'), },
313
    'cp_name'      => { 'text' => $::locale->text('Name'), },
314
    'cp_givenname' => { 'text' => $::locale->text('Given Name'), },
315
    'cp_street'    => { 'text' => $::locale->text('Street'), },
316
    'cp_phone1'    => { 'text' => $::locale->text('Phone1'), },
317
    'cp_phone2'    => { 'text' => $::locale->text('Phone2'), },
318
    'cp_mobile1'   => { 'text' => $::locale->text('Mobile 1'), },
319
    'cp_mobile2'   => { 'text' => $::locale->text('Mobile 2'), },
320
    'cp_email'     => { 'text' => $::locale->text('E-mail'), },
321
    'cp_abteilung' => { 'text' => $::locale->text('Department'), },
322
    'cp_birthday'  => { 'text' => $::locale->text('Birthday'), },
323
    'cp_gender'    => { 'text' => $::locale->text('Gender'), },
324
  );
325

  
326
  map { $column_defs{$_}->{visible} = 1 } @visible_columns;
327

  
328
  my @hidden_variables  = (qw(search_term filter l));
329
  my $hide_vars         = { map { $_ => $::form->{$_} } @hidden_variables };
330
  my @hidden_nondefault = grep({ $::form->{$_} } @hidden_variables);
331
  my $callback          = build_std_url('action=list_contacts', join '&', map { E($_->[0]) . '=' . E($_->[1]) } @{ flatten($hide_vars) });
332
  $::form->{callback}     = "$callback&sort=" . E($::form->{sort});
333

  
334
  map { $column_defs{$_}->{link} = "${callback}&sort=${_}&sortdir=" . ($::form->{sort} eq $_ ? 1 - $::form->{sortdir} : $::form->{sortdir}) } @columns;
335

  
336
  $::form->{title} = $::locale->text('Contacts');
337

  
338
  my $report     = SL::ReportGenerator->new(\%::myconfig, $::form);
339

  
340
  my @options    = $::locale->text('Search term') . ': ' . $::form->{search_term};
341

  
342
  $report->set_options('top_info_text'       => join("\n", @options),
343
                       'output_format'       => 'HTML',
344
                       'title'               => $::form->{title},
345
                       'attachment_basename' => $::locale->text('contact_list') . strftime('_%Y%m%d', localtime time),
346
    );
347
  $report->set_options_from_form;
348

  
349
  $report->set_columns(%column_defs);
350
  $report->set_column_order(@columns);
351

  
352
  $report->set_export_options('list_contacts', @hidden_variables);
353

  
354
  $report->set_sort_indicator($::form->{sort}, $::form->{sortdir});
355

  
356
  foreach my $ref (@contacts) {
357
    my $row = { map { $_ => { 'data' => $ref->{$_} } } @columns };
358

  
359
    $row->{vcname}->{link}   = build_std_url('action=edit', 'id=' . E($ref->{vcid}), 'db=' . E($ref->{db}), 'callback', @hidden_nondefault);
360
    $row->{vcnumber}->{link} = $row->{vcname}->{link};
361
    $row->{cp_email}->{link} = 'mailto:' . E($ref->{cp_email});
362

  
363
    $report->add_data($row);
364
  }
365

  
366
  $report->generate_with_headers;
367

  
368
  $::lxdebug->leave_sub;
369
}
370

  
271 371
sub edit {
272 372
  $main::lxdebug->enter_sub();
273 373

  
locale/de/all
512 512
  'Customer type'               => 'Kundentyp',
513 513
  'Customer/Vendor'             => 'Kunde/Lieferant',
514 514
  'Customer/Vendor (database ID)' => 'Kunde/Lieferant (Datenbank-ID)',
515
  'Customer/Vendor Name'        => 'Kunde/Lieferant',
516
  'Customer/Vendor Number'      => 'Kundennummer/Lieferantennummer',
515 517
  'Customername'                => 'Kundenname',
516 518
  'Customernumberinit'          => 'Kunden-/Lieferantennummernkreis',
517 519
  'Customers'                   => 'Kunden',
......
1091 1093
  'Logout now'                  => 'Lx-Office jetzt verlassen',
1092 1094
  'Long Dates'                  => 'Lange Monatsnamen',
1093 1095
  'Long Description'            => 'Langtext',
1094
  'Lx-Office'                   => 'Lx-Office',
1095 1096
  'MAILED'                      => 'Gesendet',
1096 1097
  'MSG_BROWSER_DOES_NOT_SUPPORT_IFRAMES' => 'Ihr Browser kann leider keine eingebetteten Frames anzeigen. Bitte wählen Sie ein anderes Menü in der Benutzerkonfiguration im Administrationsmenü aus.',
1097 1098
  'Main Preferences'            => 'Grundeinstellungen',
......
1138 1139
  'Missing user id!'            => 'Benutzer ID fehlt!',
1139 1140
  'Mitarbeiter'                 => 'Mitarbeiter',
1140 1141
  'Mixed (requires column "type")' => 'Gemischt (erfordert Spalte "type")',
1142
  'Mobile'                      => 'Mobiltelefon',
1143
  'Mobile 1'                    => '',
1144
  'Mobile 2'                    => '',
1141 1145
  'Mobile1'                     => 'Mobile 1',
1142 1146
  'Mobile2'                     => 'Mobile 2',
1143 1147
  'Model'                       => 'Lieferanten-Art-Nr.',
......
1576 1580
  'Screen'                      => 'Bildschirm',
1577 1581
  'Search AP Aging'             => 'Offene Verbindlichkeiten',
1578 1582
  'Search AR Aging'             => 'Offene Forderungen',
1583
  'Search contacts'             => 'Ansprechpartnersuche',
1584
  'Search term'                 => 'Suchbegriff',
1579 1585
  'Searchable'                  => 'Durchsuchbar',
1580 1586
  'Select'                      => 'auswählen',
1581 1587
  'Select a Customer'           => 'Endkunde auswählen',
......
2185 2191
  'config/lx_office.conf: Key "authentication/ldap" is missing.' => 'config/lx_office.conf: Der Schlüssel "authentication/ldap" fehlt.',
2186 2192
  'config/lx_office.conf: Missing parameters in "authentication/database". Required parameters are "host", "db" and "user".' => 'config/lx_office.conf: Fehlende Parameter in "authentication/database". Benötigte Parameter sind "host", "db" und "user".',
2187 2193
  'config/lx_office.conf: Missing parameters in "authentication/ldap". Required parameters are "host", "attribute" and "base_dn".' => 'config/lx_office.conf: Fehlende Parameter in "authentication/ldap". Benötigt werden "host", "attribute" und "base_dn".',
2194
  'contact_list'                => 'ansprechpartner_liste',
2188 2195
  'continue'                    => 'weiter',
2189 2196
  'correction'                  => 'Korrektur',
2190 2197
  'cp_greeting to cp_gender migration' => 'Datenumwandlung von Titel nach Geschlecht (cp_greeting to cp_gender)',
menu.ini
59 59
action=search
60 60
db=vendor
61 61

  
62
[Master Data--Reports--Contacts]
63
ACCESS=customer_vendor_edit
64
module=ct.pl
65
action=search_contact
66
db=customer
67

  
62 68
[Master Data--Reports--Parts]
63 69
ACCESS=part_service_assembly_edit
64 70
module=ic.pl
templates/webpages/ct/search_contact.html
1
[%- USE HTML %]
2
[%- USE T8 %]
3
<body onload="fokus()">
4

  
5
 <form method="post" action="ct.pl" name="Form">
6

  
7
  <input type="hidden" name="db" value="[% db | html %]">
8

  
9
  <div class="listtop">[% 'Contacts' | $T8 %]</div>
10

  
11
  <table>
12
   <tr>
13
    <th align="right" nowrap>[% 'Name' | $T8 %]</th>
14
    <td><input name="filter.cp_name" size="35"></td>
15
   </tr>
16
   <tr>
17
    <th align="right" nowrap>[% 'Greeting' | $T8 %]</th>
18
    <td><input name="filter.cp_greeting" size="35"></td>
19
   </tr>
20
   <tr>
21
    <th align="right" nowrap>[% 'Title' | $T8 %]</th>
22
    <td><input name="filter.cp_title" size="35"></td>
23
   </tr>
24
   <tr>
25
    <th align="right" nowrap>[% 'E-mail' | $T8 %]</th>
26
    <td><input name="filter.cp_email" size="35"></td>
27
   </tr>
28
   <tr>
29
    <th align="right" nowrap>[% 'Department' | $T8 %]</th>
30
    <td><input name="filter.cp_abteilung" size="35"></td>
31
   </tr>
32
   <tr>
33
    <th align="right" nowrap>[% 'Project' | $T8 %]</th>
34
    <td><input name="filter.cp_project" size="35"></td>
35
   </tr>
36

  
37
   <tr>
38
    <td></td>
39
    <td>
40
     <input name="filter.status" class="radio" type="radio" value="active" checked> [% 'Active' | $T8 %]
41
     <input name="filter.status" class="radio" type="radio" value="all"> [% 'All' | $T8 %]
42
     <input name="filter.status" class="radio" type="radio" value="orphaned"> [% 'Orphaned' | $T8 %]
43
    </td>
44
   </tr>
45

  
46
   <tr>
47
    <th align="right" nowrap>[% 'Include in Report' | $T8 %]</th>
48
    <td>
49
     <table border="0">
50
      <tr>
51
       <td>
52
        <input name="l.cp_id" id="l_cp_id" type="checkbox" class="checkbox" value="Y">
53
        <label for="l_cp_id">[% 'ID' | $T8 %]</label>
54
       </td>
55
       <td>
56
        <input name="l.vcnumber" id="l_vcnumber" type="checkbox" class="checkbox" value="Y" checked>
57
        <label for="l_vcnumber">[% 'Customer/Vendor Number' | $T8 %]</label>
58
       </td>
59
       <td>
60
        <input name="l.vcname" id="l_vcname" type="checkbox" class="checkbox" value="Y" checked>
61
        <label for="l_vcname">[% 'Customer/Vendor Name' | $T8 %]</label>
62
       </td>
63
      </tr>
64

  
65
      <tr>
66
       <td>
67
        <input name="l.cp_name" id="l_cp_name" type="checkbox" class="checkbox" value="Y" checked>
68
        <label for="l_cp_name">[% 'Name' | $T8 %]</label>
69
       </td>
70
       <td>
71
        <input name="l.cp_givenname" id="l_cp_givenname" type="checkbox" class="checkbox" value="Y" checked>
72
        <label for="l_cp_givenname">[% 'Given Name' | $T8 %]</label>
73
       </td>
74
       <td>
75
        <input name="l.cp_street" id="l_cp_street" type="checkbox" class="checkbox" value="Y">
76
        <label for="l_cp_street">[% 'Street' | $T8 %]</label>
77
       </td>
78
      </tr>
79
      <tr>
80
       <td>
81
        <input name="l.cp_phone" id="l_cp_phone" type="checkbox" class="checkbox" value="Y" checked>
82
        <label for="l_cp_phone">[% 'Phone' | $T8 %]</label>
83
       </td>
84
       <td>
85
        <input name="l.cp_mobile" id="l_cp_mobile" type="checkbox" class="checkbox" value="Y" checked>
86
        <label for="l_cp_mobile">[% 'Mobile' | $T8 %]</label>
87
       </td>
88
       <td>
89
        <input name="l.cp_email" id="l_cp_email" type="checkbox" class="checkbox" value="Y" checked>
90
        <label for="l_cp_email">[% 'E-mail' | $T8 %]</label>
91
       </td>
92
      </tr>
93

  
94
      <tr>
95
       <td>
96
        <input name="l.cp_birthday" id="l_cp_birthday" type="checkbox" class="checkbox" value="Y">
97
        <label for="l_cp_birthday">[% 'Birthday' | $T8 %]</label>
98
       </td>
99
       <td>
100
        <input name="l.cp_abteilung" id="l_cp_abteilung" type="checkbox" class="checkbox" value="Y">
101
        <label for="l_cp_abteilung">[% 'Department' | $T8 %]</label>
102
       </td>
103
       <td>
104
        <input name="l.cp_gender" id="l_cp_gender" type="checkbox" class="checkbox" value="Y">
105
        <label for="l_cp_gender">[% 'Gender' | $T8 %]</label>
106
       </td>
107
      </tr>
108

  
109
      [% CUSTOM_VARIABLES_INCLUSION_CODE %]
110

  
111
     </table>
112
    </td>
113
   </tr>
114
  </table>
115

  
116
  <input type="hidden" name="nextsub" value="list_contacts">
117

  
118
  <input type="submit" class="submit" name="action" value="[% 'Continue' | $T8 %]">
119
 </form>
120

  
121
</body>
122
</html>
templates/webpages/menu/menuv3.html
1 1
[%- USE T8 %]
2 2
[% USE HTML %]<body style="padding:0px; margin:0px;">
3 3

  
4
 <script type="text/javascript" src="js/jquery.js"></script>
4 5
 <script type="text/javascript">
5
<!--
6
 <!--
7
function on_keydown_quicksearch(e) {
8
  var key;
9

  
10
  if (window.event)
11
    key = window.event.keyCode;   // IE
12
  else
13
    key = e.which;                // Firefox
14

  
15
  if (key != 13)
16
    return true;
17

  
18
  var search_term = $("#search_term");
19
  var value       = search_term.val();
20
  if (!value)
21
    return true;
22

  
23
  var url = "ct.pl?action=list_contacts&INPUT_ENCODING=utf-8&filter.status=active&search_term=" + encodeURIComponent(value);
24

  
25
  search_term.val('');
26
  $("#win1").attr('src', url);
27

  
28
  return false;
29
}
30

  
6 31
function clockon() {
7 32
  var now = new Date();
8 33
  var h = now.getHours();
......
16 41

  
17 42
 <table border="0" width="100%" background="image/bg_titel.gif" cellpadding="0" cellspacing="0">
18 43
  <tr>
19
   <td style="color:white; font-family:verdana,arial,sans-serif; font-size: 12px;">
44
   <td style="color:white; font-family:verdana,arial,sans-serif; font-size: 12px;" nowrap>
20 45
    &nbsp;
21 46
    [<a href="menuv3.pl?action=display" target="_blank">[% 'new Window' | $T8 %]</a>]
22 47
    &nbsp;
23 48
    [<a href="JavaScript:top.main_window.print()">[% 'print' | $T8 %]</a>]
49
    &nbsp;
50
    [[% 'Search contacts' | $T8 %] <input size="15" name="search_term" id="search_term" onkeydown="return on_keydown_quicksearch(event)">]
24 51
   </td>
25 52
   <td align="right" style="vertical-align:middle; color:white; font-family:verdana,arial,sans-serif; font-size: 12px;" nowrap>
26 53
    [[% 'User' | $T8 %]: [% HTML.escape(login) %] -

Auch abrufbar als: Unified diff