my %allowed_sort_columns =
map { $_, 1 } qw(
id customernumber vendornumber name contact phone fax email street
- taxnumber business invnumber ordnumber quonumber zipcode city
+ taxnumber business invnumber ordnumber quonumber zipcode city country salesman
);
my $sortorder = $form->{sort} && $allowed_sort_columns{$form->{sort}} ? $form->{sort} : "name";
$form->{sort} = $sortorder;
push @values, ('%' . $form->{addr_city} . '%') x 2;
}
+ if ($form->{addr_country}) {
+ $where .= " AND ((lower(ct.country) LIKE lower(?))
+ OR
+ (ct.id IN (
+ SELECT trans_id
+ FROM shipto
+ WHERE (module = 'CT')
+ AND (lower(shiptocountry) LIKE lower(?))
+ ))
+ )";
+ push @values, ('%' . $form->{addr_country} . '%') x 2;
+ }
+
if ( $form->{status} eq 'orphaned' ) {
$where .=
qq| AND ct.id NOT IN | .
qq| WHERE cv.id = a.vendor_id)|;
}
$form->{l_invnumber} = $form->{l_ordnumber} = $form->{l_quonumber} = "";
- }
+ };
if ($form->{obsolete} eq "Y") {
$where .= qq| AND obsolete|;
}
my $query =
- qq|SELECT ct.*, b.description AS business | .
+ qq|SELECT ct.*, b.description AS business, e.name as salesman | .
(qq|, NULL AS invnumber, NULL AS ordnumber, NULL AS quonumber, NULL AS invid, NULL AS module, NULL AS formtype, NULL AS closed | x!! $join_records) .
qq|FROM $cv ct | .
qq|LEFT JOIN business b ON (ct.business_id = b.id) | .
+ qq|LEFT JOIN employee e ON (ct.salesman_id = e.id) | .
qq|WHERE $where|;
my @saved_values = @values;
push(@values, @saved_values);
$query .=
qq| UNION | .
- qq|SELECT ct.*, b.description AS business, | .
+ qq|SELECT ct.*, b.description AS business, e.name as salesman, | .
qq| a.invnumber, a.ordnumber, a.quonumber, a.id AS invid, | .
qq| '$module' AS module, 'invoice' AS formtype, | .
qq| (a.amount = a.paid) AS closed | .
qq|FROM $cv ct | .
qq|JOIN $ar a ON (a.${cv}_id = ct.id) | .
qq|LEFT JOIN business b ON (ct.business_id = b.id) | .
+ qq|LEFT JOIN employee e ON (ct.salesman_id = e.id) | .
qq|WHERE $where AND (a.invoice = '1')|;
}
push(@values, @saved_values);
$query .=
qq| UNION | .
- qq|SELECT ct.*, b.description AS business,| .
+ qq|SELECT ct.*, b.description AS business, e.name as salesman, | .
qq| ' ' AS invnumber, o.ordnumber, o.quonumber, o.id AS invid, | .
qq| 'oe' AS module, 'order' AS formtype, o.closed | .
qq|FROM $cv ct | .
qq|JOIN oe o ON (o.${cv}_id = ct.id) | .
qq|LEFT JOIN business b ON (ct.business_id = b.id) | .
+ qq|LEFT JOIN employee e ON (ct.salesman_id = e.id) | .
qq|WHERE $where AND (o.quotation = '0')|;
}
push(@values, @saved_values);
$query .=
qq| UNION | .
- qq|SELECT ct.*, b.description AS business, | .
+ qq|SELECT ct.*, b.description AS business, e.name as salesman, | .
qq| ' ' AS invnumber, o.ordnumber, o.quonumber, o.id AS invid, | .
qq| 'oe' AS module, 'quotation' AS formtype, o.closed | .
qq|FROM $cv ct | .
qq|JOIN oe o ON (o.${cv}_id = ct.id) | .
qq|LEFT JOIN business b ON (ct.business_id = b.id) | .
+ qq|LEFT JOIN employee e ON (ct.salesman_id = e.id) | .
qq|WHERE $where AND (o.quotation = '1')|;
}
}
push @options, $locale->text('Billing/shipping address (city)') . " : $form->{addr_city}" if $form->{addr_city};
push @options, $locale->text('Billing/shipping address (zipcode)') . " : $form->{zipcode}" if $form->{addr_zipcode};
push @options, $locale->text('Billing/shipping address (street)') . " : $form->{street}" if $form->{addr_street};
+ push @options, $locale->text('Billing/shipping address (country)') . " : $form->{country}" if $form->{addr_country};
if ($form->{business_id}) {
my $business = SL::DB::Manager::Business->find_by(id => $form->{business_id});
}
my @columns = (
- 'id', 'name', "$form->{db}number", 'contact', 'phone',
- 'fax', 'email', 'taxnumber', 'street', 'zipcode' , 'city',
- 'business', 'invnumber', 'ordnumber', 'quonumber'
+ 'id', 'name', "$form->{db}number", 'contact', 'phone',
+ 'fax', 'email', 'taxnumber', 'street', 'zipcode' , 'city',
+ 'business', 'invnumber', 'ordnumber', 'quonumber', 'salesman', 'country'
);
my @includeable_custom_variables = grep { $_->{includeable} } @{ $cvar_configs };
'street' => { 'text' => $locale->text('Street'), },
'zipcode' => { 'text' => $locale->text('Zipcode'), },
'city' => { 'text' => $locale->text('City'), },
+ 'country' => { 'text' => $locale->text('Country'), },
+ 'salesman' => { 'text' => $locale->text('Salesman'), },
%column_defs_cvars,
);
<th align="right" nowrap>[% 'Billing/shipping address (city)' | $T8 %]</th>
<td><input name="addr_city" size="35"></td>
</tr>
+ <tr>
+ <th align="right" nowrap>[% 'Billing/shipping address (country)' | $T8 %]</th>
+ <td><input name="addr_country" size="35"></td>
+ </tr>
+
[% IF SHOW_BUSINESS_TYPES %]
<tr>
<th align="right" nowrap>[% IF IS_CUSTOMER %][% 'Customer type' | $T8 %][% ELSE %][% 'Vendor type' | $T8 %][% END %]</th>
<td>
<input name="l_city" id="l_city" type="checkbox" class="checkbox" value="Y" checked>
<label for="l_city">[% 'City' | $T8 %]</label>
- </td>
+ </td>
</tr>
<tr>
<label for="l_quonumber">[% IF IS_CUSTOMER %][% 'Quotations' | $T8 %][% ELSE %][% 'RFQs' | $T8 %][% END %]</label>
</td>
<td>
+ <input name="l_country" id="l_country" type="checkbox" class="checkbox" value="Y" checked>
+ <label for="l_country">[% 'Country' | $T8 %]</label>
+ </td>
+ </tr>
+ <tr>
+ <td>
+ <input name="l_salesman" id="l_salesman" type="checkbox" class="checkbox" value="Y">
+ <label for="l_salesman">[% IF IS_CUSTOMER %][% 'Salesman' | $T8 %][% END %]</label>
</td>
</tr>