X-Git-Url: http://wagnertech.de/git?a=blobdiff_plain;f=SL%2FCT.pm;h=031ef112db172ea2411ef733e57477f15bdc07a3;hb=2d0387d1624b5b7ed6b13b79b9d5a87ce9b6d12b;hp=e4b1ee0b188ce3c33353d886ed6f02a9e0502a8e;hpb=582dc2d8f1af7fe53bf1bdc0489de6b2c00f5ae7;p=kivitendo-erp.git diff --git a/SL/CT.pm b/SL/CT.pm index e4b1ee0b1..031ef112d 100644 --- a/SL/CT.pm +++ b/SL/CT.pm @@ -25,7 +25,8 @@ # GNU General Public License for more details. # You should have received a copy of the GNU General Public License # along with this program; if not, write to the Free Software -# Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. +# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, +# MA 02110-1335, USA. #====================================================================== # # backend code for customers and vendors @@ -83,6 +84,9 @@ sub search { "salesman" => "e.name", "payment" => "pt.description", "pricegroup" => "pg.pricegroup", + "ustid" => "ct.ustid", + "creditlimit" => "ct.creditlimit", + "commercial_court" => "ct.commercial_court", ); $form->{sort} ||= "name"; @@ -97,7 +101,7 @@ sub search { } my $sortdir = !defined $form->{sortdir} ? 'ASC' : $form->{sortdir} ? 'ASC' : 'DESC'; - if ($sortorder !~ /(business|id|discount|itime)/ && !$join_records) { + if ($sortorder !~ /(business|creditlimit|id|discount|itime)/ && !$join_records) { $sortorder = "lower($sortorder) ${sortdir}"; } else { $sortorder .= " ${sortdir}"; @@ -235,11 +239,9 @@ sub search { push @values, ("%$_%")x2 for @tokens; } - # Nur Kunden finden, bei denen ich selber der Verkäufer bin - # Gilt nicht für Lieferanten - if ($cv eq 'customer' && !$main::auth->assert('customer_vendor_all_edit', 1)) { - $where .= qq| AND ct.salesman_id = (select em.id from employee em where em.login = ?)|; - push(@values, $::myconfig{login}); + if (($form->{create_zugferd_invoices} // '') ne '') { + $where .= qq| AND (ct.create_zugferd_invoices = ?)|; + push @values, $form->{create_zugferd_invoices}; } my ($cvar_where, @cvar_values) = CVar->build_filter_query('module' => 'CT', @@ -253,10 +255,18 @@ sub search { my $pg_select = $form->{l_pricegroup} ? qq|, pg.pricegroup as pricegroup | : ''; my $pg_join = $form->{l_pricegroup} ? qq|LEFT JOIN pricegroup pg ON (ct.pricegroup_id = pg.id) | : ''; + + my $main_cp_select = ''; + if ($form->{l_main_contact_person}) { + $main_cp_select = qq/, (SELECT concat(cp.cp_givenname, ' ', cp.cp_name, ' | ', cp.cp_email, ' | ', cp.cp_phone1) + FROM contacts cp WHERE ct.id=cp.cp_cv_id AND cp.cp_main LIMIT 1) + AS main_contact_person /; + } my $query = qq|SELECT ct.*, ct.itime::DATE AS insertdate, b.description AS business, e.name as salesman, | . qq| pt.description as payment | . $pg_select . + $main_cp_select . (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) | .