2017-12-27 21 views
1

상점 그룹에 대한 판매 보고서의 데이터를 가져 오는 쿼리가 있습니다.루프 및 첨부 파일이있는 CFMAIL

각 상점의 월간 판매에 대한 PDF를 작성한 다음 영업 관리자에게 그 상점에 대한 보고서 만 이메일로 보내야합니다.

PDF 작성 부분이 정상적으로 작동합니다. 각 상점에 대해 별도의 보고서를 작성합니다.

보고서를 전자 메일로 보내려고하면 모든 영업 사원에 대해 하나의 보고서 대신 각 레코드에 대해 하나의 보고서를 보냅니다. 예 : 매장 # 1에 대한 보고서에 4 명이 있으면 영업 관리자는 보고서 하나 대신 4 개의 보고서를 받게됩니다. 여기

내 코드입니다 : 어떻게 각 영업 관리자로 모든 데이터를 포함하는 상점 당 하나 개의 보고서를 이메일 않는 PDF

 <cfoutput query="data" group="site_name"> 
    <cfdocument format="pdf" overwrite="yes" fontembed="yes" 
    pagetype="Letter" 
    filename="xxxxxxxxxxxxxxxsite_name#.pdf" margintop="0.25" 
    marginbottom="0.25" marginleft="0.25" marginright="0.25" 
    backgroundvisible="yes"> 
    <table width="100%" align="center" border="1" cellpadding="5" 
    cellspacing="0"> 
    <tr bgcolor="##e1e8f7"> 
    <td colspan="8" align="center">Sales Report -#today#-#site_name#</td> 
    </tr> 
    <tr align="center"> 
    <td>Sales Person</td> 
    <td>Total Sales</td> 
    </tr> 
    <cfoutput> 
    <tr> 
    <td>#firstName# #lastName#</td> 
    <td>#totalSales#</td> 
    </tr> 
    </cfoutput> 
    </table> 
    </cfdocument> 
    </cfoutput> 

의 cfmail

<cfmail query="data" to="#salesmanageremail#" subject="monthly sales 
    report" 
    type="html"> 
    <style type="text/css"> 
    body { font-size: 12px; font-family: Arial; } 
    </style> 
    <body> 
    Report attached. 
    </body> 
    <cfsilent> 
    <cfmailparam file="xxxxxxxxxxxxxxxsite_name#.pdf"> 
    </cfsilent> 
    </cfmail> 

만들기?

답변

3

cfmail 태그를 cfoutput 태그로 처리 할 수 ​​있습니다. 여기에는 pdf를 만들 때와 마찬가지로 group 속성을 사용하는 것도 포함됩니다.

또는 cfmail 태그를 사용중인 cfoutput 블록 내에 넣을 수 있습니다. 모든 것을 고려하면 그것이 내가 취할 접근법입니다. 그렇게하면 각 사이트에 맞는 파일을 보낼 수 있습니다.

+0

감사합니다. 나는 후자의 제안을 시도 할 것입니다. –

+0

그게 효과가있었습니다. 감사 –