Projekt

Allgemein

Profil

« Zurück | Weiter » 

Revision 2eaa3936

Von Jan Büren vor etwa 6 Jahren hinzugefügt

  • ID 2eaa39366f97994db3548a9b139d35b16fbb0903
  • Vorgänger c13f301e
  • Nachfolger 74d90fe6

Toten Code entfernt: customer_or_vendor_selection.js

Bevor es den Customer-Picker gab, bestand die Möglichkeit
über einen Klick auf ein Fragezeichen den Kunden/Lieferanten
rauszusuchen. Die Funktion war noch ein bisschen erweitert,
da der Ansprechpartner noch separat angezeigt wurde (toter Projektcode im
Standard ?), die zusätzlich Auswahl-Funktion hatte keine weitere
Auswirkung. Die aktuelle einzige Stelle, wo der Code noch geladen
wurde ist im Letter-Controller. Das Deaktivieren des js-Codes
zeigt, wie erwartet, keine Unterschiede im Verhalten =>
Alles mittlerweile komplett überflüssig, inkl. edit_part.js (?) in Letter.pm

Unterschiede anzeigen:

SL/Controller/Letter.pm
323 323
  $::form->{type}             = 'letter';   # needed for print_options
324 324
  $::form->{vc}               = $letter->is_sales ? 'customer' : 'vendor'; # needs to be for _get_contacts...
325 325

  
326
  $::request->layout->add_javascripts('customer_or_vendor_selection.js');
327
  $::request->layout->add_javascripts('edit_part_window.js');
328

  
329 326
  $::form->{language_id} ||= $params{language_id};
330 327
  $::form->{languages}   ||= SL::DB::Manager::Language->get_all_sorted;
331 328
  $::form->{printers}      = SL::DB::Manager::Printer->get_all_sorted;
bin/mozilla/common.pl
332 332

  
333 333
# -------------------------------------------------------------------------
334 334

  
335
sub cov_selection_internal {
336
  $main::lxdebug->enter_sub();
337

  
338
  my $form     = $main::form;
339
  my %myconfig = %main::myconfig;
340
  my $locale   = $main::locale;
341

  
342
  my $order_by = "name";
343
  $order_by = $form->{"order_by"} if (defined($form->{"order_by"}));
344
  my $order_dir = 1;
345
  $order_dir = $form->{"order_dir"} if (defined($form->{"order_dir"}));
346

  
347
  my $type = $form->{"is_vendor"} ? $locale->text("vendor") : $locale->text("customer");
348

  
349
  my $covs = Common->retrieve_customers_or_vendors(\%myconfig, $form, $order_by, $order_dir, $form->{"is_vendor"}, $form->{"allow_both"});
350
  map({ $covs->[$_]->{"selected"} = $_ ? 0 : 1; } (0..$#{$covs}));
351

  
352
  if (0 == scalar(@{$covs})) {
353
    $form->show_generic_information(sprintf($locale->text("No %s was found matching the search parameters."), $type));
354
  } elsif (1 == scalar(@{$covs})) {
355
    $::request->{layout}->add_javascripts_inline("cov_selected('1')");
356
  }
357

  
358
  my $callback = "$form->{script}?action=cov_selection_internal&";
359
  map({ $callback .= "$_=" . $form->escape($form->{$_}) . "&" }
360
      (qw(name input_name input_id is_vendor allow_both), grep({ /^[fl]_/ } keys %$form)));
361 335

  
362
  my @header_sort = qw(name address contact);
363
  my %header_title = ( "name" => $locale->text("Name"),
364
                       "address" => $locale->text("Address"),
365
                       "contact" => $locale->text("Contact"),
366
                       );
367

  
368
  my @header =
369
    map(+{ "column_title" => $header_title{$_},
370
           "column" => $_,
371
           "callback" => $callback . "order_by=${_}&order_dir=" . ($order_by eq $_ ? 1 - $order_dir : $order_dir),
372
         },
373
        @header_sort);
374

  
375
  foreach my $cov (@{ $covs }) {
376
    $cov->{address} = "$cov->{street}, $cov->{zipcode} $cov->{city}";
377
    $cov->{address} =~ s{^,}{}x;
378
    $cov->{address} =~ s{\ +}{\ }gx;
379

  
380
    $cov->{contact} = join " ", map { $cov->{$_} } qw(cp_gender cp_title cp_givenname cp_name);
381
    $cov->{contact} =~ s{\ +}{\ }gx;
382
  }
383

  
384
  $form->{"title"} = $form->{is_vendor} ? $locale->text("Select a vendor") : $locale->text("Select a customer");
385
  $form->header();
386
  print($form->parse_html_template("generic/cov_selection", { "HEADER" => \@header,
387
                                                              "COVS" => $covs, }));
388

  
389
  $main::lxdebug->leave_sub();
390
}
391 336

  
392 337

  
393 338
# Functions to call add routines beneath different reports
js/customer_or_vendor_selection.js
1
function customer_or_vendor_selection_window(input_name, input_id, is_vendor, allow_both, action_on_cov_selected) {
2
  var parm = centerParms(800,600) + ",width=800,height=600,status=yes,scrollbars=yes";
3
  var name = document.getElementsByName(input_name)[0].value;
4
  url = "common.pl?" +
5
    "INPUT_ENCODING=UTF-8&" +
6
    "action=cov_selection_internal&" +
7
    "name=" + encodeURIComponent(name) + "&" +
8
    "input_name=" + encodeURIComponent(input_name) + "&" +
9
    "input_id=" + encodeURIComponent(input_id) + "&" +
10
    "is_vendor=" + (is_vendor ? "1" : "0") + "&" +
11
    "allow_both=" + (allow_both ? "1" : "0") + "&" +
12
    "action_on_cov_selected=" + (action_on_cov_selected ? encodeURIComponent(action_on_cov_selected) : "")
13
  //alert(url);
14
  window.open(url, "_new_cov_selection", parm);
15
}
templates/webpages/generic/cov_selection.html
1
[%- USE T8 %]
2
[%- USE HTML %]
3
<h1>[% title %]</h1>
4

  
5
 <form method="post">
6

  
7
  <input type="hidden" name="input_name" value="[% HTML.escape(input_name) %]">
8
  <input type="hidden" name="input_id" value="[% HTML.escape(input_id) %]">
9
  <input type="hidden" name="is_vendor" value="[% HTML.escape(is_vendor) %]">
10
  <input type="hidden" name="allow_both" value="[% HTML.escape(allow_both) %]">
11
  <input type="hidden" name="action_on_cov_selected" value="[% HTML.escape(action_on_cov_selected) %]">
12

  
13
   <tr>
14
    <td>
15
     [%- IF !is_vendor %]
16
      [% 'Please select a customer from the list below.' | $T8 %]
17
     [%- ELSE %]
18
      [% 'Please select a vendor from the list below.' | $T8 %]
19
     [%- END %]
20
    </td>
21
   </tr>
22

  
23
   <tr>
24
    <td>
25

  
26
     <table>
27
      <tr class="listheading">
28
       <th class="listheading">&nbsp;</th>
29
       [%- FOREACH row = HEADER %]
30
        <th nowrap class="listheading"><a href="[% HTML.escape(row.callback) %]">[% row.column_title %]</a></th>
31
       [%- END %]
32
      </tr>
33

  
34
      [%- FOREACH row = COVS %]
35
       <tr class="listrow[% loop.count % 2 %]">
36
        <td valign="top"><button type="button" onclick="cov_selected('[% loop.count %]')">Auswahl</button></td>
37
        <td valign="top"><input type="hidden" id="id_[% loop.count %]" name="id_[% loop.count %]" value="[% HTML.escape(row.id) %]">
38
         <input type="hidden" id="name_[% loop.count %]" name="name_[% loop.count %]" value="[% HTML.escape(row.name) %]">
39
         <input type="hidden" id="customer_is_vendor_[% loop.count %]" name="customer_is_vendor_[% loop.count %]" value="[% HTML.escape(row.customer_is_vendor) %]">
40
         [% HTML.escape(row.name) %]</td>
41
        <td valign="top">[% HTML.escape(row.address) %]</td>
42
        <td valign="top">[% HTML.escape(row.contact) %]</td>
43
       </tr>
44
      [% END %]
45
     </table>
46

  
47
    </td>
48
   </tr>
49
  </table>
50

  
51
 </form>
52

  
53
 <script type="text/javascript">
54
  <!--
55
      function cov_selected(selected) {
56
        var name = document.getElementsByName("name_" + selected)[0].value
57
        var id = document.getElementsByName("id_" + selected)[0].value
58
        var customer_is_vendor = document.getElementsByName("customer_is_vendor_" + selected)[0].value
59
        var cov_name = document.forms[0].input_name.value;
60
        window.opener.document.getElementsByName(cov_name)[0].value = name;
61
        if (document.forms[0].input_id.value != "") {
62
          window.opener.document.getElementsByName(document.forms[0].input_id.value)[0].value = id;
63
        }
64

  
65
        var cov_is_vendor = cov_name + "_is_vendor";
66
        var input = window.opener.document.getElementsByName(cov_is_vendor)[0];
67
        if (input) {
68
          input.value = customer_is_vendor;
69
        }
70

  
71
        var prefix = "";
72
        if (cov_name.substr(0, 2) == "f_") {
73
          prefix = "f_";
74
          cov_name = cov_name.substr(2);
75
        }
76
        cov_name = prefix + "old_" + cov_name;
77
        var input = window.opener.document.getElementsByName(cov_name)[0];
78
        if (input) {
79
          input.value = name;
80
        }
81
        cov_name = prefix + "old" + cov_name;
82
        input = window.opener.document.getElementsByName(cov_name)[0];
83
        if (input) {
84
          input.value = name;
85
        }
86

  
87
        if (document.forms[0].action_on_cov_selected.value != "") {
88
          window.opener.document.getElementsByName("action")[0].value = document.forms[0].action_on_cov_selected.value;
89
          window.opener.document.forms[0].submit();
90
        }
91

  
92
        self.close();
93
      }
94
      //-->
95
 </script>
96

  

Auch abrufbar als: Unified diff