|
|
|
|
File: [Development] / p2rx-programs / act_insertPrograms.cfm
(download)
Revision: 1.1, Wed Mar 9 03:18:14 2005 UTC (4 years, 8 months ago) by neenan Branch: MAIN *** empty log message *** |
<P>
<a href="../directories/programs.cfm" class="sublink2">
Agencies and Programs <img src="../images/siteimage/dart.gif" border="0"></a>
</p>
<cfquery name="dorg" datasource="#programsdb#">
Select * from Organization where Orgid = #URL.Orgid#
</cfquery>
<cfquery name="InsertOrg" datasource="#programsdb#">
Insert Into dOrganization
(OrganizationName, Phone, Extension, Division, FaxNumber, TimeZone, Address1, EmailName, GeoServiceID, Address2, Hotline, City, StateOrProvince, URL, PostalCode, Country, GraphicURL, Profile)
Values ('#dorg.OrganizationName#',
'#dorg.Phone#',
'#dorg.Extension#',
'#dorg.Division#',
'#dorg.FaxNumber#',
'#dorg.TimeZone#',
'#dorg.Address1#',
'#dorg.EmailName#',
#dorg.GeoServiceID#,
'#dorg.Address2#',
'#dorg.Hotline#',
'#dorg.City#',
'#dorg.StateOrProvince#',
'#dorg.URL#',
'#dorg.PostalCode#',
'#dorg.Country#',
'#dorg.GraphicURL#',
'#dorg.Profile#'
)
</cfquery>
<cfquery name="getorgid" datasource="#programsdb#">
Select max(orgid) as maxid from dorganization
</cfquery>
<cfset maxorgid = getorgid.maxid>
<!--- Associating the dummy table from dcontacts table with the new orgID in the Contacts table - This query will get all the program type id's that have been
associated with the program type.--->
<cfquery name="getcontacts" datasource="#programsdb#">
Select * from contacts where Orgid = #URL.Orgid#
</cfquery>
<CFLOOP Query="getcontacts">
<CFQUERY NAME="insertcontacts" DATASOURCE="#programsdb#">
INSERT INTO dContacts(Prefix, FirstName, Middle, LastName, NameSuffix, Title, Primary, WorkPhone, WorkExtension, MobilePhone, FaxNumber, EmailName, Address, City, State, Zip, OrgID)
Values('#Prefix#','#FirstName#','#Middle#','#LastName#','#NameSuffix#','#Title#','#Primary#','#WorkPhone#','#WorkExtension#','#MobilePhone#','#FaxNumber#','#EmailName#','#Address#','#City#','#State#','#Zip#',#getorgid.maxid#)
</cfquery>
</CFLOOP>
<!--- Associating the program types to the organization - This query will get all the program type id's that have been
associated with the program type.--->
<cfquery name="getOrgProgtype" datasource="#programsdb#">
Select * from OrgtoProgramtype
where Orgid = #URL.Orgid#
</cfquery>
<cfset ProgList = ValueList(getOrgProgtype.ProgramTypeID)>
<cfset ProgTypeArray = ListToArray(ProgList)>
<cfif GetOrgProgType.recordcount is not 0>
<cfloop from="1" to="#ArrayLen(ProgTypeArray)#" index="x">
<cfquery datasource="#programsdb#">
Insert Into dOrgtoprogramtype (OrgID,ProgramTypeID)
Values(#getorgid.maxID#, #ProgTypeArray[x]#)
</cfquery>
</cfloop>
</cfif>
<!-- section for adding services and relate it to the organization --->
<cfquery name="getmaxserviceid" datasource="#programsdb#">
SELECT orgid, ServiceID
FROM OrgtoService
</cfquery>
<cfquery name="getService" datasource="#programsdb#">
SELECT orgid, ServiceID
FROM OrgtoService
WHERE Orgid=#URL.orgid# And serviceid Not in (select serviceid from service where approved=1);
</cfquery>
<cfset ServiceList = ValueList(getService.ServiceID)>
<cfset ServiceArray = ListToArray(ServiceList)>
<cfif getService.recordcount is not 0>
<cfloop from="1" to="#ArrayLen(ServiceArray)#" index="x">
<cfquery datasource="#programsdb#">
Insert Into dOrgtoService (OrgID, ServiceID)
Values(#getorgid.maxID#, #ServiceArray[x]#)
</cfquery>
</cfloop>
</cfif>
<!--- The Query below gets the new unapproved service names entered by the admin/online user and appends
the services and the links in the Service and OrgtoService Tables --->
<cfif #URL.fuseaction# is "editservices">
<cfquery name="getNewServices" datasource="#programsdb#">
SELECT ds.service,ds.type,ds.Approved, os.orgid
FROM Service AS ds, Orgtoservice AS os
WHERE os.Orgid=#URL.Orgid# and os.serviceid=ds.serviceid and ds.approved=0;
</cfquery>
<cfset NewServiceList = ValueList(getNewServices.Service)>
<cfset NewTypeList = ValueList(getNewServices.Type)>
<cfset NewServiceArray = ListToArray(NewServiceList)>
<cfset NewTypeArray = ListToArray(NewTypeList)>
<cfif getNewServices.recordcount is not 0>
<cfloop from="1" to="#ArrayLen(NewServiceArray)#" index="x">
<cfquery name="Addnewservice" datasource="#programsdb#">
Insert Into dService(Service,Type,Approved,CenterID)
Values('#NewServiceArray[x]#','#NewTypeArray[x]#',1,7)
</cfquery>
<cfquery name="getserviceid" datasource="#programsdb#">
Select max(serviceid) as maxserviceid from dService
</cfquery>
<cfquery name="link" datasource="#programsdb#">
Insert Into dOrgtoService (OrgID, ServiceID)
Values(#getorgid.maxID#, #getserviceid.maxserviceid#)
</cfquery>
</cfloop>
</cfif>
</cfif>
<!--- <cfoutput>
<input type="hidden" name="mainOrgId" value="URL.mainorgid">
<input type="hidden" name="orgid" value="#getorgid.maxid#">
</cfoutput>
--->
<CFIF #URL.fuseaction# IS "GETORG">
<cfquery name="provider1" datasource="#programsdb#">
SELECT *
FROM dOrganization
where orgID = #maxOrgID#
</cfquery>
<cfoutput><input type="hidden" name="OrgID" value="maxorgid"></cfoutput>
<table width="100%" border="0" cellspacing="0" cellpadding="10" name="text">
<tr>
<td>
<p><span class="tableheading">Programs in Region 7</span> <br><br>
<p><cfoutput query="provider1"><a href="details.cfm?orgid=#maxorgid#" class="subheading">#organizationName#</a>
<a href="addeditprograms.cfm?FuseAction=Editorg&OrgID=#maxorgid#">Edit</a>
<br><br><!--- </cfoutput> --->
</cfoutput>
<a href="#top"><img src="../images/SiteImage/top.gif" border="0"></a><br><br>
</tr>
</table>
</CFIF>
| CVS Admin |
Powered by ViewCVS 1.0-dev |