$::form->{type} = 'letter'; # needed for print_options
$::form->{vc} = $letter->is_sales ? 'customer' : 'vendor'; # needs to be for _get_contacts...
- $::request->layout->add_javascripts('customer_or_vendor_selection.js');
- $::request->layout->add_javascripts('edit_part_window.js');
-
$::form->{language_id} ||= $params{language_id};
$::form->{languages} ||= SL::DB::Manager::Language->get_all_sorted;
$::form->{printers} = SL::DB::Manager::Printer->get_all_sorted;
# -------------------------------------------------------------------------
-sub cov_selection_internal {
- $main::lxdebug->enter_sub();
-
- my $form = $main::form;
- my %myconfig = %main::myconfig;
- my $locale = $main::locale;
-
- my $order_by = "name";
- $order_by = $form->{"order_by"} if (defined($form->{"order_by"}));
- my $order_dir = 1;
- $order_dir = $form->{"order_dir"} if (defined($form->{"order_dir"}));
-
- my $type = $form->{"is_vendor"} ? $locale->text("vendor") : $locale->text("customer");
-
- my $covs = Common->retrieve_customers_or_vendors(\%myconfig, $form, $order_by, $order_dir, $form->{"is_vendor"}, $form->{"allow_both"});
- map({ $covs->[$_]->{"selected"} = $_ ? 0 : 1; } (0..$#{$covs}));
-
- if (0 == scalar(@{$covs})) {
- $form->show_generic_information(sprintf($locale->text("No %s was found matching the search parameters."), $type));
- } elsif (1 == scalar(@{$covs})) {
- $::request->{layout}->add_javascripts_inline("cov_selected('1')");
- }
-
- my $callback = "$form->{script}?action=cov_selection_internal&";
- map({ $callback .= "$_=" . $form->escape($form->{$_}) . "&" }
- (qw(name input_name input_id is_vendor allow_both), grep({ /^[fl]_/ } keys %$form)));
- my @header_sort = qw(name address contact);
- my %header_title = ( "name" => $locale->text("Name"),
- "address" => $locale->text("Address"),
- "contact" => $locale->text("Contact"),
- );
-
- my @header =
- map(+{ "column_title" => $header_title{$_},
- "column" => $_,
- "callback" => $callback . "order_by=${_}&order_dir=" . ($order_by eq $_ ? 1 - $order_dir : $order_dir),
- },
- @header_sort);
-
- foreach my $cov (@{ $covs }) {
- $cov->{address} = "$cov->{street}, $cov->{zipcode} $cov->{city}";
- $cov->{address} =~ s{^,}{}x;
- $cov->{address} =~ s{\ +}{\ }gx;
-
- $cov->{contact} = join " ", map { $cov->{$_} } qw(cp_gender cp_title cp_givenname cp_name);
- $cov->{contact} =~ s{\ +}{\ }gx;
- }
-
- $form->{"title"} = $form->{is_vendor} ? $locale->text("Select a vendor") : $locale->text("Select a customer");
- $form->header();
- print($form->parse_html_template("generic/cov_selection", { "HEADER" => \@header,
- "COVS" => $covs, }));
-
- $main::lxdebug->leave_sub();
-}
# Functions to call add routines beneath different reports
+++ /dev/null
-function customer_or_vendor_selection_window(input_name, input_id, is_vendor, allow_both, action_on_cov_selected) {
- var parm = centerParms(800,600) + ",width=800,height=600,status=yes,scrollbars=yes";
- var name = document.getElementsByName(input_name)[0].value;
- url = "common.pl?" +
- "INPUT_ENCODING=UTF-8&" +
- "action=cov_selection_internal&" +
- "name=" + encodeURIComponent(name) + "&" +
- "input_name=" + encodeURIComponent(input_name) + "&" +
- "input_id=" + encodeURIComponent(input_id) + "&" +
- "is_vendor=" + (is_vendor ? "1" : "0") + "&" +
- "allow_both=" + (allow_both ? "1" : "0") + "&" +
- "action_on_cov_selected=" + (action_on_cov_selected ? encodeURIComponent(action_on_cov_selected) : "")
- //alert(url);
- window.open(url, "_new_cov_selection", parm);
-}
+++ /dev/null
-[%- USE T8 %]
-[%- USE HTML %]
-<h1>[% title %]</h1>
-
- <form method="post">
-
- <input type="hidden" name="input_name" value="[% HTML.escape(input_name) %]">
- <input type="hidden" name="input_id" value="[% HTML.escape(input_id) %]">
- <input type="hidden" name="is_vendor" value="[% HTML.escape(is_vendor) %]">
- <input type="hidden" name="allow_both" value="[% HTML.escape(allow_both) %]">
- <input type="hidden" name="action_on_cov_selected" value="[% HTML.escape(action_on_cov_selected) %]">
-
- <tr>
- <td>
- [%- IF !is_vendor %]
- [% 'Please select a customer from the list below.' | $T8 %]
- [%- ELSE %]
- [% 'Please select a vendor from the list below.' | $T8 %]
- [%- END %]
- </td>
- </tr>
-
- <tr>
- <td>
-
- <table>
- <tr class="listheading">
- <th class="listheading"> </th>
- [%- FOREACH row = HEADER %]
- <th nowrap class="listheading"><a href="[% HTML.escape(row.callback) %]">[% row.column_title %]</a></th>
- [%- END %]
- </tr>
-
- [%- FOREACH row = COVS %]
- <tr class="listrow[% loop.count % 2 %]">
- <td valign="top"><button type="button" onclick="cov_selected('[% loop.count %]')">Auswahl</button></td>
- <td valign="top"><input type="hidden" id="id_[% loop.count %]" name="id_[% loop.count %]" value="[% HTML.escape(row.id) %]">
- <input type="hidden" id="name_[% loop.count %]" name="name_[% loop.count %]" value="[% HTML.escape(row.name) %]">
- <input type="hidden" id="customer_is_vendor_[% loop.count %]" name="customer_is_vendor_[% loop.count %]" value="[% HTML.escape(row.customer_is_vendor) %]">
- [% HTML.escape(row.name) %]</td>
- <td valign="top">[% HTML.escape(row.address) %]</td>
- <td valign="top">[% HTML.escape(row.contact) %]</td>
- </tr>
- [% END %]
- </table>
-
- </td>
- </tr>
- </table>
-
- </form>
-
- <script type="text/javascript">
- <!--
- function cov_selected(selected) {
- var name = document.getElementsByName("name_" + selected)[0].value
- var id = document.getElementsByName("id_" + selected)[0].value
- var customer_is_vendor = document.getElementsByName("customer_is_vendor_" + selected)[0].value
- var cov_name = document.forms[0].input_name.value;
- window.opener.document.getElementsByName(cov_name)[0].value = name;
- if (document.forms[0].input_id.value != "") {
- window.opener.document.getElementsByName(document.forms[0].input_id.value)[0].value = id;
- }
-
- var cov_is_vendor = cov_name + "_is_vendor";
- var input = window.opener.document.getElementsByName(cov_is_vendor)[0];
- if (input) {
- input.value = customer_is_vendor;
- }
-
- var prefix = "";
- if (cov_name.substr(0, 2) == "f_") {
- prefix = "f_";
- cov_name = cov_name.substr(2);
- }
- cov_name = prefix + "old_" + cov_name;
- var input = window.opener.document.getElementsByName(cov_name)[0];
- if (input) {
- input.value = name;
- }
- cov_name = prefix + "old" + cov_name;
- input = window.opener.document.getElementsByName(cov_name)[0];
- if (input) {
- input.value = name;
- }
-
- if (document.forms[0].action_on_cov_selected.value != "") {
- window.opener.document.getElementsByName("action")[0].value = document.forms[0].action_on_cov_selected.value;
- window.opener.document.forms[0].submit();
- }
-
- self.close();
- }
- //-->
- </script>
-