(file) Return to act_addservices.cfm CVS log (file) (dir) Up to [Development] / p2rx-programs

File: [Development] / p2rx-programs / act_addservices.cfm (download)
Revision: 1.2, Fri Aug 26 16:08:19 2005 UTC (4 years, 2 months ago) by pKanel
Branch: MAIN
CVS Tags: HEAD
Changes since 1.1: +62 -17 lines
Enhancements made to resolve programs added or udpated by Outsite users.

<!--- 	Name:  act_addservices.cfm
    	Purpose: This functions as the action file to insert the information of the services of type resource, expertise or client. 
		Each time this page is called,the field values are first deleted from the dOrgToService table using a query .
		Fresh records are then inserted for each of the services that the user had selected in the dsp_addservices or 
		dsp_editservices form. The new "Other" services are also inserted in the dservice table and dorgtoservice table.
		Date created: 02/23/2005
       	Dependancy: URL.Orgid 
		Variables: 	
					
		Functions: 
		Date changed: 
					02/23/2005			Prabin & Neena  Created
					02/23/2005			Neena		    Documentation
					05/05/2005			Neena			Made changes to balance the code for removing Autonumber Field 
														from dOrgtoService Table for maximum ServicetoOrgID field. 
					08/15/2005			Terry			Added URL variable for skipping step
					08/15/2005			Terry			Documentation
---> 

<!--- checks to see if the skip variable is present in the URL - determines whether a user can skip through the step --->
<cfif #url.skip# NEQ 1>
<cfquery name="getservicelink" datasource="#programsdb#">
Select serviceid 
from dorgtoservice 
where orgID = #URL.Orgid# 
</cfquery>

<cfset OtherServiceList = ValueList(getServicelink.ServiceID)>
<cfset OtherServiceArray = ListToArray(OtherServiceList)>

<cfif getServicelink.recordcount is not 0>
	<cfloop from="1" to="#ArrayLen(OtherServiceArray)#" index="x">
		<cfquery datasource="#Programsdb#">
			Delete from dOrgtoService
			where OrgID =#URL.orgid# and ServiceID = #OtherServiceArray[x]#
		</cfquery>
	</cfloop>
</cfif>

<cfquery name="deletepg" datasource="#programsdb#">
delete 
from   dOrgToService
Where	OrgID = #URL.ORGID#
</cfquery> 

<cfset Array = #ListToArray(form.ServiceID)#>
<cfloop from="1" to="#ArrayLen(Array)#" index="x">

	<!--- New code added in next 4 statements to compute maximum servicetoOrgID --->
		<cfquery name="maxOSId" datasource="#programsdb#">
		Select max(ServicetoOrgID) as maxOrgtoServiceID from dOrgtoService
		</cfquery>
		<cfset newServicetoOrgID = #maxOSId.maxOrgtoServiceID# +1>
	
		<cfquery datasource="#Programsdb#">
			Insert Into dOrgtoService (ServicetoOrgID, OrgID, ServiceID) 
			Values(#newServicetoOrgID#, #URL.OrgID#, #Array[x]#)
		</cfquery>
</cfloop>

<cfif IsDefined("form.OtherExpertise")> 
	<!--- New code added in next 8 statements to compute maximum servicetoOrgID --->
		<cfquery name="maxServicetoOrgID" datasource="#programsDb#">
		 Select max(ServicetoOrgID) as maxOrgtoServiceID from dorgtoservice		
		</cfquery>
		<cfset newServicetoOrgID = #maxServicetoOrgID.maxOrgtoServiceID# +1>
		
		<cfquery name="maxServiceID" datasource="#programsDb#">
		 Select max(ServiceID) as maxServiceID from dService		
		</cfquery>
		<cfset newServiceID = #maxServiceID.maxServiceID# +1>
		
		
		<cfquery name="newExp" datasource="#Programsdb#">
			 Insert into dService(Serviceid, Service,Type, Approved,CenterID)
			Values(#newServiceID#, '#form.Other1#','Expertise',1,6) 
		</cfquery>

		<Cfquery name="getmaxServiceID" datasource="#Programsdb#">
				Select Max(serviceid) as maxSid from dService
		</Cfquery>
		
		<cfquery name="newOrgToService" datasource="#Programsdb#">
			Insert into dOrgtoService (ServicetoOrgID, OrgID, ServiceID)
			Values(#newServicetoOrgID#, #URL.OrgID#, #getMaxServiceid.maxSid#)
		</cfquery> 
</cfif>
<!--- </cfif> --->
<cfif IsDefined("form.OtherResources")> 
		<!--- New code added in next 8 statements to compute maximum servicetoOrgID --->
			<cfquery name="maxServiceID" datasource="#programsDb#">
			 Select max(ServiceID) as maxServiceID from dService		
			</cfquery>
			<cfset newServiceID = #maxServiceID.maxServiceID# +1>
			
			<cfquery name="maxServicetoOrgID" datasource="#programsDb#">
			 Select max(ServicetoOrgID) as maxOrgtoServiceID from dorgtoservice		
			</cfquery>
			<cfset newServicetoOrgID = #maxServicetoOrgID.maxOrgtoServiceID# +1>
		
			<cfquery name="newRes" datasource="#Programsdb#">
				Insert into dService(ServiceID, Service,Type, Approved,CenterID)
				 Values(#newServiceID#, '#form.Other2#','Resources',1,6)
			</cfquery>
			
			<Cfquery name="getmaxServiceID" datasource="#Programsdb#">
				Select Max(serviceid) as maxSid from dService
			</Cfquery>
			
			<cfquery name="newOrgToService" datasource="#Programsdb#">
				Insert into dOrgtoService (ServicetoOrgID, OrgID, ServiceID)
				Values(#newServicetoOrgID#, #URL.OrgID#, #getMaxServiceid.maxSid#)
			</cfquery> 
		
		<!--- </cfif> --->
</cfif>
<cfif IsDefined("form.OtherClients")> 
		<!--- New code added in next 8 statements to compute maximum servicetoOrgID --->
			<cfquery name="maxServiceID" datasource="#programsDb#">
			 Select max(ServiceID) as maxServiceID from dService		
			</cfquery>
			<cfset newServiceID = #maxServiceID.maxServiceID# +1>
			
			<cfquery name="maxServicetoOrgID" datasource="#programsDb#">
			 Select max(ServicetoOrgID) as maxOrgtoServiceID from dorgtoservice		
			</cfquery>
			<cfset newServicetoOrgID = #maxServicetoOrgID.maxOrgtoServiceID# +1>
			
			<cfquery name="newClient" datasource="#Programsdb#">
				Insert into dService(ServiceID, Service,Type, Approved,CenterID)
	 			Values(#newServiceID#, '#form.Other3#','Clients',1,6)
			</cfquery>
			
			<Cfquery name="getmaxServiceID" datasource="#Programsdb#">
				Select Max(serviceid) as maxSid from dService
			</Cfquery>
			
			<cfquery name="newOrgToService" datasource="#Programsdb#">
			Insert into dOrgtoService (ServicetoOrgID, OrgID, ServiceID)
			Values(#newServicetoOrgID#, #URL.OrgID#, #getMaxServiceid.maxSid#)
			</cfquery> 
			
</cfif>
</cfif>




CVS Admin
Powered by
ViewCVS 1.0-dev