private Sub lista1(sql As SQL,in As StringBuilder) As ResumableSub
Dim sqlstr As String
sqlstr = $"
select *,round(((teljes-brutto)/teljes)*100,3) as atlag,
round(teljes/smenny,2) as listar,round(brutto/smenny,2) as szlaar from (
select date(keltdat) as keltdat,szfej.rksh,megnevezes,me,sum(menny)as smenny,
sum(ebruttoar*menny) as teljes,
sum((ebruttoar-bruttoar)*menny) as engedmeny,
sum(sorbrutto) as brutto
from sztet
join szfej on sztet.bsz=szfej.bsz
where ebruttoar-bruttoar>=0 and szfej.kommid in (${in.ToString})
group by keltdat,szfej.rksh,megnevezes,Me
having sum(menny)<>0
order by 2,1,3) a
"$
Codebase.doLog("Email", $"Automatikus adatküldés emailben: Cikkenkénti eladások naponta/készlethely"$)
Dim pdfnev As String = File.Combine(File.DirTemp,"ARBEVCIKKNAP"&DateTime.GetSecond(DateTime.Now)&".pdf")
Dim lid As Int = sql.ExecQuerySingleResult2($"
INSERT INTO winlista (cegid,listanev,sql,filter,szerkeszt,outfname)
VALUES (?,?,?,?,?,?) RETURNING id
"$,Array As Object(Codebase.selceg.focegid,"ARBEVCIKKNAP",sqlstr,"komm.id=" & in.ToString, _
"N",pdfnev))
Log($"$DateTime{DateTime.Now} - startLister2 hívása."$)
wait for (Codebase.startLister2($"ID=${lid}"$)) complete (res As Boolean)
Log($"$DateTime{DateTime.Now} - startLister2 kész."$)
Return pdfnev
End Sub