Witam Kombinuje wlasnie sobie nad wyswietlaniem stanu konta klienta przy nazwisku na liscie faktur. Wymysliem taka modyfikacje zapytania z funkcji GetInvoiceList:
SELECT d.id AS id, number, cdate, d.type, d.customerid, name, address, zip, city, template, closed, CASE reference WHEN 0 THEN SUM(a.value*a.count) ELSE SUM((a.value+b.value)*(a.count+b.count)) - SUM(b.value*b.count)
END AS value, COUNT(a.docid) AS count , SUM(f.value) AS sum FROM documents d JOIN invoicecontents a ON (a.docid = d.id) JOIN cash f ON (d.customerid = f.customerid) LEFT JOIN invoicecontents b ON (d.reference = b.docid AND a.itemid = b.itemid) LEFT JOIN numberplans ON (d.numberplanid = numberplans.id) LEFT JOIN ( SELECT DISTINCT a.customerid FROM customerassignments a JOIN excludedgroups e ON (a.customergroupid = e.customergroupid ) WHERE e.userid = lms_current_user() ) e ON (e.customerid = d.customerid) WHERE e.customerid IS NULL AND (d.type = 3 OR d.type = 1) AND closed = 0 GROUP BY d.id, number, cdate, d.customerid, name, address, zip, city, template, closed, d.type, reference ORDER BY d.id asc
Ale to nie do konca dziala - szaleje ilosc pozycji na fakturze itp...
Czy ktos ma może jakis pomysl?