USP_DATAFORMTEMPLATE_VIEW_SPONSORSHIPOPPORTUNITYSUMMARYVIEW
The load procedure used by the view dataform template "Sponsorship Opportunity Summary View Form"
Parameters
Parameter | Parameter Type | Mode | Description |
---|---|---|---|
@ID | uniqueidentifier | IN | The input ID parameter used to load the fields defined on the form. |
@DATALOADED | bit | INOUT | Output parameter indicating whether or not data was actually loaded. |
@SPONSORSHIPOPPORTUNITYGROUPID | uniqueidentifier | INOUT | SPONSORSHIPOPPORTUNITYGROUPID |
@SPONSORSHIPOPPORTUNITYTYPECODE | int | INOUT | Sponsorship opportunity type |
@LOOKUPID | nvarchar(100) | INOUT | Lookup ID |
@LOCATION | nvarchar(255) | INOUT | Location |
@ELIGIBILITY | nvarchar(115) | INOUT | Eligibility |
@AVAILABILITY | nvarchar(115) | INOUT | Availability |
@GROUPNAME | nvarchar(100) | INOUT | Opportunity group |
@PICTURE | varbinary | INOUT | Image |
@PICTURETHUMBNAIL | varbinary | INOUT | Image thumbnail |
@ACTIVESPONSORS | int | INOUT | Active sponsors |
@PENDINGTRANSFERSIN | int | INOUT | Pending transfers in |
@PENDINGTRANSFERSOUT | int | INOUT | Pending transfers out |
@LASTDOCUMENTATIONDATE | date | INOUT | Last documentation date |
Definition
Copy
CREATE procedure dbo.USP_DATAFORMTEMPLATE_VIEW_SPONSORSHIPOPPORTUNITYSUMMARYVIEW
(
@ID uniqueidentifier,
@DATALOADED bit = 0 output,
@SPONSORSHIPOPPORTUNITYGROUPID uniqueidentifier = null output,
@SPONSORSHIPOPPORTUNITYTYPECODE int = null output,
@LOOKUPID nvarchar(100) = null output,
@LOCATION nvarchar(255)= null output,
@ELIGIBILITY nvarchar(115) = null output,
@AVAILABILITY nvarchar(115) = null output,
@GROUPNAME nvarchar(100) = null output,
@PICTURE varbinary(max) = null output,
@PICTURETHUMBNAIL varbinary(max) = null output,
@ACTIVESPONSORS integer=null output,
@PENDINGTRANSFERSIN integer =null output,
@PENDINGTRANSFERSOUT integer = null output,
@LASTDOCUMENTATIONDATE date = null output
)
as
set nocount on;
-- be sure to set this, in case the select returns no rows
set @DATALOADED = 0;
-- populate the output parameters, which correspond to fields on the form. Note that
-- we set @DATALOADED = 1 to indicate that the load was successful. Otherwise, the system
-- will display a "no data loaded" message.
select @DATALOADED=1,
@SPONSORSHIPOPPORTUNITYGROUPID = SPONSORSHIPOPPORTUNITY.SPONSORSHIPOPPORTUNITYGROUPID,
@SPONSORSHIPOPPORTUNITYTYPECODE = SPONSORSHIPOPPORTUNITYGROUP.SPONSORSHIPOPPORTUNITYTYPECODE,
@GROUPNAME = SPONSORSHIPOPPORTUNITYGROUP.NAME,
@LOOKUPID = SPONSORSHIPOPPORTUNITY.LOOKUPID,
@LOCATION = dbo.UFN_SPONSORSHIPLOCATION_GETFULLNAME(SPONSORSHIPLOCATION.ID),
@ELIGIBILITY =
case SPONSORSHIPOPPORTUNITYGROUP.SPONSORSHIPOPPORTUNITYTYPECODE
when 1 then SPONSORSHIPOPPORTUNITY.ELIGIBILITY
when 2 then case SPONSORSHIPOPPORTUNITY.ELIGIBILITYCODE
when 1 then 'Open'
when 2 then 'Closed'
else SPONSORSHIPOPPORTUNITY.ELIGIBILITY
end
end +
case SPONSORSHIPOPPORTUNITY.ELIGIBILITYCODE
when 2 then ' (' + SPONSORSHIPREASON.REASON + ')'
else ''
end,
@AVAILABILITY =
case SPONSORSHIPOPPORTUNITY.AVAILABILITYCODE
when 1 then SPONSORSHIPOPPORTUNITY.AVAILABILITY + ' (' + SPR.NAME + ')'
when 2 then SPONSORSHIPOPPORTUNITY.AVAILABILITY + ' (' + case SPONSORSHIPLOCATION.STATUSCODE
when 0 then 'Sponsored'
when 1 then 'Location inactive'
when 2 then 'Location closed'
end + ')'
else SPONSORSHIPOPPORTUNITY.AVAILABILITY
end,
@LASTDOCUMENTATIONDATE = SPONSORSHIPOPPORTUNITY.LASTDOCUMENTATIONDATE
from dbo.SPONSORSHIPOPPORTUNITY
inner join dbo.SPONSORSHIPOPPORTUNITYGROUP on SPONSORSHIPOPPORTUNITYGROUP.ID = SPONSORSHIPOPPORTUNITY.SPONSORSHIPOPPORTUNITYGROUPID
left outer join dbo.SPONSORSHIPLOCATION on SPONSORSHIPLOCATION.ID = SPONSORSHIPOPPORTUNITY.SPONSORSHIPLOCATIONID
left outer join dbo.SPONSORSHIPOPPORTUNITYRESERVEPROCESS SPR on SPR.ID = SPONSORSHIPOPPORTUNITY.RESERVATIONKEYID
left outer join dbo.SPONSORSHIPREASON on SPONSORSHIPREASON.ID = SPONSORSHIPOPPORTUNITY.SPONSORSHIPREASONID
where SPONSORSHIPOPPORTUNITY.ID = @ID
if(@SPONSORSHIPOPPORTUNITYTYPECODE=1)
begin
select @PICTURE = CONSTITUENT.PICTURE,
@PICTURETHUMBNAIL = CONSTITUENT.PICTURETHUMBNAIL
from dbo.SPONSORSHIPOPPORTUNITYCHILD inner join dbo.CONSTITUENT on CONSTITUENT.ID = SPONSORSHIPOPPORTUNITYCHILD.CONSTITUENTID where SPONSORSHIPOPPORTUNITYCHILD.ID= @ID
end
SET @ACTIVESPONSORS = dbo.UFN_SPONSORSHIPOPPORTUNITY_ACTIVESPONSORSHIPS(@ID)
select @PENDINGTRANSFERSIN = COUNT(SPONSORSHIPTRANSACTION.ID)
from dbo.SPONSORSHIP
inner join dbo.SPONSORSHIPTRANSACTION on SPONSORSHIP.ID = SPONSORSHIPTRANSACTION.TARGETSPONSORSHIPID
where STATUSCODE=0 and SPONSORSHIPTRANSACTION.ACTIONCODE=6 and SPONSORSHIP.SPONSORSHIPOPPORTUNITYID=@ID;
select @PENDINGTRANSFERSOUT= COUNT(ST.ID)
from dbo.SPONSORSHIP S
inner join dbo.SPONSORSHIPTRANSACTION ST on S.ID = ST.CONTEXTSPONSORSHIPID
and S.SPONSORSHIPOPPORTUNITYID = @ID
where ST.ACTIONCODE=6 and (select SS.STATUSCODE from dbo.SPONSORSHIP SS where SS.ID=ST.TARGETSPONSORSHIPID)=0;
return 0;