X-Git-Url: http://wagnertech.de/git?a=blobdiff_plain;f=SL%2FCT.pm;h=6a52ee71675087a11382c3ee400cd7be5cd52e46;hb=9b039e37be3108c90d20d4db36f0a9a54400c800;hp=d8497d008e914b222a34f5e4d172a293d7fd7996;hpb=7349649bae8d80eabfd253592d59f8455f9ef6b0;p=kivitendo-erp.git diff --git a/SL/CT.pm b/SL/CT.pm index d8497d008..6a52ee716 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 @@ -40,6 +41,7 @@ package CT; use SL::Common; use SL::CVar; use SL::DBUtils; +use SL::DB; use Text::ParseWords; use strict; @@ -252,10 +254,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) | . @@ -341,7 +351,7 @@ sub get_contact { die 'Missing argument: cp_id' unless $::form->{cp_id}; - my $dbh = $form->dbconnect($myconfig); + my $dbh = SL::DB->client->dbh; my $query = qq|SELECT * FROM contacts c | . qq|WHERE cp_id = ? ORDER BY cp_id limit 1|; @@ -359,7 +369,6 @@ sub get_contact { ($form->{cp_used}) = selectfirst_array_query($form, $dbh, $query, ($form->{cp_id})x2); $sth->finish; - $dbh->disconnect; $main::lxdebug->leave_sub(); }