Created
December 17, 2015 05:05
-
-
Save hkouns/2586ff5b7b3e9bac63dd to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
GivingUnits = ''' | |
DECLARE | |
@startdt DATETIME | |
, @enddt DATETIME | |
, @campusid INT = 0 | |
, @pledges INT = 0 | |
, @nontaxded INT = 0 | |
, @includeUnclosed INT = 1; | |
SET @enddt = GETDATE(); | |
SET @startdt = DATEADD(day, -90, @enddt); | |
WITH givers AS ( | |
SELECT | |
FamilyId | |
, CreditGiverId | |
, SpouseId | |
, SUM(Amount) AS Total | |
FROM Contributions2(@startdt, @enddt, @campusid, @pledges, @nontaxded, @includeUnclosed) | |
GROUP BY FamilyId, CreditGiverId, SpouseId | |
) | |
SELECT | |
p.Name2 | |
,p.preferredname | |
,p.PeopleId | |
,p.BDate | |
,p.CellPhone | |
,p.HomePhone | |
,p.MaritalStatusId | |
,sp.preferredname Spouse | |
,sp.PeopleId SpouseID | |
,givers.SpouseId GiverSpouseId | |
,givers.Total | |
,givers.FamilyId | |
,p.ContributionOptionsId | |
,p.PositionInFamilyId | |
FROM givers | |
JOIN dbo.People p ON p.PeopleId = givers.CreditGiverId | |
LEFT JOIN dbo.People sp ON sp.PeopleId = givers.SpouseId | |
WHERE p.PeopleId = 339 | |
OR p.PeopleId = 1010 | |
ORDER BY p.Name2 | |
''' | |
template = ''' | |
<html> | |
<head> | |
<style> | |
table, th, td { | |
border: 1px solid black; | |
} | |
th, td { | |
padding: 2px; | |
} | |
td { | |
border: 1px solid black; | |
} | |
</style> | |
</head> | |
<body> | |
<table width=1600"> | |
<tbody> | |
<tr> | |
<th width="50"> | |
<p align="center"><strong>Id</strong></p> | |
</th> | |
<th width="190"> | |
<p><small><strong>Name</strong></BR> {{FmtPhone phone# "prefix"}}</small></p> | |
</th> | |
<th width="300"> | |
<p align="center"><small><strong> | |
{{IfCond lval "==" rval}}</BR> | |
{{IfCond lval "!=" rval}}</BR> | |
</BR></strong></small></p> | |
</th> | |
<th width="300"> | |
<p align="center"><small><strong> | |
{{IfCond lval ">" rval}}</BR> | |
{{IfCond lval ">=" rval}}</BR> | |
{{IfCond lval "<" rval}}</BR> | |
{{IfCond lval "<=" rval}}</BR> | |
</strong></small></p> | |
</th> | |
<th width="300"> | |
<p align="center"><small><strong> | |
{{IfCond lval "&&" rval}}</BR> | |
{{IfCond lval "||" rval}}</BR> | |
</strong></small></p> | |
</th> | |
<th width="300"> | |
<p align="center"><small><strong> | |
{{Compare lval "==" rval}}</BR> | |
{{Compare lval "!=" rval}}</BR> | |
</BR></strong></small></p> | |
</th> | |
<th width="300"> | |
{{Compare lval ">" rval}}</BR> | |
{{Compare lval ">=" rval}}</BR> | |
{{Compare lval "<" rval}}</BR> | |
{{Compare lval "<=" rval}}</BR> | |
</strong></small></p> | |
</th> | |
<th width="300"> | |
<p align="center"><small><strong> | |
{{Compare lval "&&" rval}}</BR> | |
{{Compare lval "||" rval}}</BR> | |
</strong></small></p> | |
</th> | |
</tr> | |
{{#each this}} | |
<tr> | |
<td width="50"> | |
<p align="center"><small>{{PeopleId}}</small></p> | |
</td> | |
<td width="190"> | |
<p>{{Name2}}</BR></BR> | |
{{FmtPhone CellPhone "(c) "}}</BR></BR> | |
{{FmtPhone HomePhone "Home: "}} | |
</p> | |
</td> | |
<td width="300"> | |
<p><small> | |
{{IfCond 21 "==" 5}}</BR> | |
{{#IfCond 21 "==" 5}} True {{else}} False {{/IfCond}} </br> | |
{{IfCond "A" "==" "A"}}</BR> | |
{{#IfCond "A" "==" "A"}} True {{else}} False {{/IfCond}}</br> | |
{{IfCond "A" "==" "AB"}}</BR> | |
{{#IfCond "A" "==" "AB"}} True {{else}} False {{/IfCond}} </br> | |
{{IfCond PeopleId "==" PeopleId}}</BR> | |
{{#IfCond PeopleId "==" PeopleId}} True {{else}} False {{/IfCond}} </br></br> | |
BDate: {{BDate}}</br> | |
{{IfCond BDate "==" BDate}}</BR> | |
{{#IfCond BDate "==" BDate}} True {{else}} False {{/IfCond}} </br></br> | |
MaritalStatusId: {{MaritalStatusId}}</br> | |
{{IfCond MaritalStatusId "==" 20}}</BR> | |
{{#IfCond MaritalStatusId "==" 20}} True {{else}} False {{/IfCond}} </br></br> | |
{{IfCond 21 "!=" 5}}</BR> | |
{{IfCond 21 "!=" 5}} True {{else}} False {{/IfCond}} </br> | |
{{IfCond "A" "!=" "A"}}</BR> | |
{{#IfCond "A" "!=" "A"}} True {{else}} False {{/IfCond}}</br> | |
{{IfCond "A" "!=" "AB"}}</BR> | |
{{#IfCond "A" "!=" "AB"}} True {{else}} False {{/IfCond}} </br></br> | |
{{IfCond MaritalStatusId "!=" 20}}</BR> | |
{{#IfCond MaritalStatusId "!=" 20}} True {{else}} False {{/IfCond}} </br></br> | |
</small></p> | |
</td> | |
<td width="300"> | |
<p><small> | |
{{IfCond 21 ">" 5}}</BR> | |
{{IfCond 21 ">" 5}} True {{else}} False {{/IfCond}} </br> | |
{{IfCond "A" ">" "B"}}</BR> | |
{{IfCond "A" ">" "B"}} True {{else}} False {{/IfCond}}</br></br> | |
{{IfCond 21 ">=" 5}}</BR> | |
{{IfCond 21 ">=" 5}} True {{else}} False {{/IfCond}} </br> | |
{{IfCond 21 ">=" 21}}</BR> | |
{{IfCond 21 ">=" 21}} True {{else}} False {{/IfCond}} </br> | |
{{IfCond 21 ">=" 22}}</BR> | |
{{IfCond 21 ">=" 22}} True {{else}} False {{/IfCond}} </br> | |
{{IfCond Total ">=" 100}}</BR> | |
{{IfCond Total ">=" 100}} True {{else}} False {{/IfCond}}</br></br> | |
{{IfCond 21 "<" 5}}</BR> | |
{{IfCond 21 "<" 5}} True {{else}} False {{/IfCond}} </br> | |
{{IfCond 5.12 "<" 5.21}}</BR> | |
{{IfCond 5.12 "<" 5.2}} True {{else}} False {{/IfCond}} </br> | |
{{IfCond "A" "<" 5}}</BR> | |
{{IfCond "A" "<" 5}} True {{else}} False {{/IfCond}}</br></br> | |
{{IfCond 4 "<" BDate}}</BR> | |
{{IfCond 4 "<" BDate}} True {{else}} False {{/IfCond}}</br></br> | |
{{IfCond 21 "<=" 5}}</BR> | |
{{IfCond 21 "<=" 5}} True {{else}} False {{/IfCond}} </br> | |
{{IfCond 21 "<=" 21}}</BR> | |
{{IfCond 5.12 "<=" 5.12}} True {{else}} False {{/IfCond}} </br> | |
{{IfCond 21 "<=" 22}}</BR> | |
{{IfCond 21 "<=" 22}} True {{else}} False {{/IfCond}} </br></br> | |
</small></p> | |
</td> | |
<td width="300"> | |
<p><small> | |
{{IfCond "true" "&&" "true"}}</BR> | |
{{IfCond "true" "&&" "true"}} True {{else}} False {{/IfCond}} </br> | |
{{IfCond "True" "&&" "True"}}</BR> | |
{{IfCond "True" "&&" "True"}} True {{else}} False {{/IfCond}} </br></br> | |
{{IfCond "True" "&&" "False"}}</BR> | |
{{IfCond "True" "&&" "False"}} True {{else}} False {{/IfCond}} </br></br> | |
{{IfCond "true" "||" "true"}}</BR> | |
{{IfCond "true" "||" "true"}} True {{else}} False {{/IfCond}} </br> | |
{{IfCond "false" "||" "false"}}</BR> | |
{{IfCond "false" "||" "false"}} True {{else}} False {{/IfCond}} </br></br> | |
{{IfCond "True" "||" "False"}}</BR> | |
{{IfCond "True" "||" "False"}} True {{else}} False {{/IfCond}} </br></br> | |
</small></p> | |
</td> | |
<td width="300"> | |
<p><small> | |
{{Compare 21 "==" 5}}</BR> | |
{{Compare 21 "==" 5}} </br> | |
{{Compare "A" "==" "A"}}</BR> | |
{{Compare "A" "==" "A"}} </br> | |
{{Compare "A" "==" "AB"}}</BR> | |
{{Compare "A" "==" "AB"}} </br> | |
{{Compare PeopleId "==" PeopleId}}</BR> | |
{{Compare PeopleId "==" PeopleId}} </br></br> | |
BDate: {{BDate}}</br> | |
{{Compare BDate "==" BDate}}</BR> | |
{{Compare BDate "==" BDate}} </br></br> | |
MaritalStatusId: {{MaritalStatusId}}</br> | |
{{Compare MaritalStatusId "==" 20}}</BR> | |
{{Compare MaritalStatusId "==" 20}} </br></br> | |
{{Compare 21 "!=" 5}}</BR> | |
{{Compare 21 "!=" 5}} </br> | |
{{Compare "A" "!=" "A"}}</BR> | |
{{Compare "A" "!=" "A"}} </br> | |
{{Compare "A" "!=" "AB"}}</BR> | |
{{Compare "A" "!=" "AB"}} </br></br> | |
{{Compare MaritalStatusId "!=" 20}}</BR> | |
{{Compare MaritalStatusId "!=" 20}} </br></br> | |
</small></p> | |
</td> | |
<td width="300"> | |
<p><small> | |
{{Compare 21 ">" 5}}</BR> | |
{{Compare 21 ">" 5}} </br> | |
{{Compare "A" ">" "B"}}</BR> | |
{{Compare "A" ">" "B"}} </br></br> | |
{{Compare 21 ">=" 5}}</BR> | |
{{Compare 21 ">=" 5}} </br> | |
{{Compare 21 ">=" 21}}</BR> | |
{{Compare 21 ">=" 21}} </br> | |
{{Compare 21 ">=" 22}}</BR> | |
{{Compare 21 ">=" 22}} </br> | |
{{Compare Total ">=" 100}}</BR> | |
{{Compare Total ">=" 100}} </br></br> | |
{{Compare 21 "<" 5}}</BR> | |
{{Compare 21 "<" 5}} </br> | |
{{Compare 5.12 "<" 5.21}}</BR> | |
{{Compare 5.12 "<" 5.2}} </br> | |
{{Compare "A" "<" 5}}</BR> | |
{{Compare "A" "<" 5}} </br></br> | |
{{Compare 4 "<" BDate}}</BR> | |
{{Compare 4 "<" BDate}} </br></br> | |
{{Compare 21 "<=" 5}}</BR> | |
{{Compare 21 "<=" 5}} </br> | |
{{Compare 21 "<=" 21}}</BR> | |
{{Compare 5.12 "<=" 5.12}} </br> | |
{{Compare 21 "<=" 22}}</BR> | |
{{Compare 21 "<=" 22}} </br></br> | |
</small></p> | |
</td> | |
<td width="300"> | |
<p><small> | |
{{Compare "true" "&&" "true"}}</BR> | |
{{Compare "true" "&&" "true"}} </br> | |
{{Compare "True" "&&" "True"}}</BR> | |
{{Compare "True" "&&" "True"}} </br></br> | |
{{Compare "True" "&&" "False"}}</BR> | |
{{Compare "True" "&&" "False"}} </br></br> | |
{{Compare "true" "||" "true"}}</BR> | |
{{Compare "true" "||" "true"}} </br> | |
{{Compare "false" "||" "false"}}</BR> | |
{{Compare "false" "||" "false"}} </br></br> | |
{{Compare "True" "||" "False"}}</BR> | |
{{Compare "True" "||" "False"}} </br></br> | |
</small></p> | |
</td> | |
</tr> | |
{{/each}} | |
</tbody> | |
</table> | |
</body> | |
</html> | |
''' | |
sqlpeople = q.QuerySql(GivingUnits) | |
body = model.RenderTemplate(template, sqlpeople) | |
print body |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment