Arjuna Aircraft Ident.: F-MBSD | Bon, j'y remet ma petite couche
AVANT :
Code :
- CREATE PROCEDURE ics_usersListForPerimDroit
- @orgId int,
- @accId int,
- @depId int,
- @locId int,
- @droitId int,
- @tous int=1,
- @lResult int output
- AS
- -- SCR V7.1
- /*SCR V7.0.1
- userId : id de l'utilisateur pour lequel on doit verifier les contraintes
- depid, locid, accid :
-
- id pour lequel on doit verifier la retriction, si null, pas de test
- combinaison : (0,1,2,3,4,5,6) 0:cs+ac+dep 1:cs 2:ac 3:dep 4:cs+ac 5:cs+dep 6:ac+dep
- on utilise les contrainte sur ca.
- isOk : 1 l'utilisateur a verifier toutes les contraintes,
- 0 une contrainte n'est pas satisfaite
-
- */
- DECLARE @combinaison int
- DECLARE @tstAcc smallint
- DECLARE @tstDep smallint
- DECLARE @tstLoc smallint
- select @combinaison=perimetreCombinaison
- from zperimetreCombinaison
- where orgId=@orgId
- if @combinaison=7 select @tstAcc=0, @tstDep=0, @tstLoc=0
- if @combinaison=0 select @tstAcc=1, @tstDep=1, @tstLoc=1
- if @combinaison=1 select @tstAcc=0, @tstDep=0, @tstLoc=1
- if @combinaison=2 select @tstAcc=0, @tstDep=1, @tstLoc=0
- if @combinaison=3 select @tstAcc=1, @tstDep=0, @tstLoc=0
- if @combinaison=4 select @tstAcc=1, @tstDep=0, @tstLoc=1
- if @combinaison=5 select @tstAcc=0, @tstDep=1, @tstLoc=1
- if @combinaison=6 select @tstAcc=1, @tstDep=1, @tstLoc=0
- /** permet de ne pas tester dans le select le (@tstLoc=0) OR (@locId=0) mais juste le 1er**/
- if (@locId is null) or (@locId=0) select @locId=0, @tstLoc=0
- if (@depId is null) or (@depId=0) select @depId=0, @tstDep=0
- if (@accId is null) or (@accId=0) select @accId=0, @tstAcc=0
- if @combinaison = 7 and @droitid<>0
- begin
- /***************** pas de perimetre *********/
- select distinct u.userId, emp.employeeid, emp.lastname, emp.firstname, u.login as LoginName,
- emp.emailaddress
- from users u, employee emp, zUserProfilePerimetre zupp, zprofileGroupeDroit zpgd, UserOrg uo
- where uo.orgid = @orgid
- and u.userid = uo.userid
- and zupp.userId = u.userId
- and zupp.profileId = zpgd.profileId
- and zpgd.groupeDroitId = @droitId
- and u.employeeid *= emp.employeeid
- and u.active = 'A'
- -- and emp.orgid = @orgid
- order by emp.lastname
- end
- else
- begin
- if @droitid=0
- begin
- if @tous = 1
- begin
- -- Liste de tous les utilisateurs
- select distinct u.userId, emp.employeeid, emp.lastname, emp.firstname, u.login as LoginName,
- emp.emailaddress
- from users u, ZVue_UserProfilePerimRegion zupp, employee emp, UserOrg uo
- where uo.orgid = @orgid
- and u.userid = uo.userid
- and u.userId = zupp.userId
- and ( (locId=@locId) or (@tstLoc=0) or (locId=0) )
- and ( (accId=@accId) or (@tstAcc=0) or (accId=0) )
- and ( (depId=@depId) or (@tstDep=0) or (depid=0) )
- and u.employeeid *= emp.employeeid
- and u.active = 'A'
- -- and emp.orgid = @orgid
- order by emp.lastname
- end
- else
- begin
- -- Liste des utilisateurs qu'en fonction du COUPLE
- select distinct u.userId, emp.employeeid, emp.lastname, emp.firstname, u.login as LoginName,
- emp.emailaddress
- from users u, ZVue_UserProfilePerimRegion zupp, employee emp, UserOrg uo
- where uo.orgid = @orgid
- and u.userid = uo.userid
- and u.userId=zupp.userId
- and ( (locId=@locId) or (@tstLoc=0) )
- and ( (accId=@accId) or (@tstAcc=0) )
- and ( (depId=@depId) or (@tstDep=0) )
- and u.employeeid *= emp.employeeid
- and u.active = 'A'
- -- and emp.orgid = @orgid
- order by emp.lastname
- end
- end
- else
- begin
- if @tous = 1
- begin
- -- Liste de tous les utilisateurs
- select distinct u.userId, emp.employeeid, emp.lastname, emp.firstname, u.login as LoginName,
- emp.emailaddress
- from users u, ZVue_UserProfilePerimRegion zupp, zprofileGroupeDroit zpgd, employee emp, UserOrg uo
- where uo.orgid = @orgid
- and u.userid = uo.userid
- and u.userId = zupp.userId
- and zupp.profileId = zpgd.profileId
- and zpgd.GroupedroitId = @droitId
- and ( (locId=@locId) or (@tstLoc=0) or (locId=0) )
- and ( (accId=@accId) or (@tstAcc=0) or (accId=0) )
- and ( (depId=@depId) or (@tstDep=0) or (depid=0) )
- and u.employeeid *= emp.employeeid
- and u.active = 'A'
- -- and emp.orgid = @orgid
- order by emp.lastname
- end
- else
- begin
- -- Liste des utilisateurs qu'en fonction du COUPLE et du DROIT
- select distinct u.userId, emp.employeeid, emp.lastname, emp.firstname, u.login as LoginName,
- emp.emailaddress
- from users u, ZVue_UserProfilePerimRegion zupp, zprofileGroupeDroit zpgd, employee emp, UserOrg uo
- where uo.orgid = @orgid
- and u.userid = uo.userid
- and u.userId = zupp.userId
- and zupp.profileId=zpgd.profileId
- and zpgd.GroupedroitId = @droitId
- and ( (locId=@locId) or (@tstLoc=0) )
- and ( (accId=@accId) or (@tstAcc=0) )
- and ( (depId=@depId) or (@tstDep=0) )
- and u.employeeid *= emp.employeeid
- and u.active = 'A'
- -- and emp.orgid = @orgid
- order by emp.lastname
- end
- end
- end
- select @lResult = @@rowcount
- GO
|
APRES :
Code :
- CREATE PROCEDURE ics_usersListForPerimDroit
- @orgId int,
- @accId int,
- @depId int,
- @locId int,
- @droitId int,
- @tous int=1,
- @lResult int output
- AS
- -- SCR V7.1
- /*SCR V7.0.1
- userId : id de l'utilisateur pour lequel on doit verifier les contraintes
- depid, locid, accid :
-
- id pour lequel on doit verifier la retriction, si null, pas de test
- combinaison : (0,1,2,3,4,5,6) 0:cs+ac+dep 1:cs 2:ac 3:dep 4:cs+ac 5:cs+dep 6:ac+dep
- on utilise les contrainte sur ca.
- isOk : 1 l'utilisateur a verifier toutes les contraintes,
- 0 une contrainte n'est pas satisfaite
-
- */
- -- SD : 22/02/2005
- -- Maintenant, si cette procédure reçoit @orgid = -1 alors on doit récupérer les comptes dans toutes les organizations
- -- SD : 22/02/2005
- -- Crétation d'une table temporaire qui va recevoir tous les userid correspondants aux critères pour chaque organization
- create table #tmpU
- (
- userid int
- )
- DECLARE cur_org CURSOR FOR
- select orgid
- from organization
- where (orgid = @orgid or @orgid = -1)
- and active = 'A'
- and type = 'C'
- OPEN cur_org
- FETCH NEXT FROM cur_org
- INTO @orgid
- WHILE @@FETCH_STATUS = 0
- BEGIN
- DECLARE @combinaison int
- DECLARE @tstAcc smallint
- DECLARE @tstDep smallint
- DECLARE @tstLoc smallint
- select @combinaison=perimetreCombinaison
- from zperimetreCombinaison
- where orgId=@orgId
- if @combinaison=7 select @tstAcc=0, @tstDep=0, @tstLoc=0
- if @combinaison=0 select @tstAcc=1, @tstDep=1, @tstLoc=1
- if @combinaison=1 select @tstAcc=0, @tstDep=0, @tstLoc=1
- if @combinaison=2 select @tstAcc=0, @tstDep=1, @tstLoc=0
- if @combinaison=3 select @tstAcc=1, @tstDep=0, @tstLoc=0
- if @combinaison=4 select @tstAcc=1, @tstDep=0, @tstLoc=1
- if @combinaison=5 select @tstAcc=0, @tstDep=1, @tstLoc=1
- if @combinaison=6 select @tstAcc=1, @tstDep=1, @tstLoc=0
- /** permet de ne pas tester dans le select le (@tstLoc=0) OR (@locId=0) mais juste le 1er**/
- if (@locId is null) or (@locId=0) select @locId=0, @tstLoc=0
- if (@depId is null) or (@depId=0) select @depId=0, @tstDep=0
- if (@accId is null) or (@accId=0) select @accId=0, @tstAcc=0
- if @combinaison = 7 and @droitid<>0
- begin
- /***************** pas de perimetre *********/
- insert into #tmpU
- select u.userid
- from zprofileGroupeDroit zpgd, zUserProfilePerimetre zupp, users u, userorg uo
- where uo.orgid = @orgid
- and u.userid = uo.userid
- and u.active = 'A'
- and zupp.userid = u.userid
- and zupp.userId = u.userId
- and zpgd.profileId = zupp.profileId
- and zpgd.groupeDroitId = @droitId
- /* select distinct u.userId, emp.employeeid, emp.lastname, emp.firstname, u.login as LoginName, emp.emailaddress
- from users u, employee emp, zUserProfilePerimetre zupp, zprofileGroupeDroit zpgd, UserOrg uo
- where uo.orgid = @orgid
- and u.userid = uo.userid
- and zupp.userId = u.userId
- and zupp.profileId = zpgd.profileId
- and zpgd.groupeDroitId = @droitId
- and u.employeeid *= emp.employeeid
- and u.active = 'A'
- order by emp.lastname */
- end
- else
- begin
- if @droitid=0
- begin
- if @tous = 1
- begin
- -- Liste de tous les utilisateurs
- insert into #tmpU
- select u.userid
- from ZVue_UserProfilePerimRegion zupp, users u, UserOrg uo
- where uo.orgid = @orgid
- and u.userid = uo.userid
- and u.active = 'A'
- and zupp.userid = u.userid
- and ((zupp.locId = @locId) or (@tstLoc = 0) or (zupp.locId=0))
- and ((zupp.accId = @accId) or (@tstAcc = 0) or (zupp.accId=0))
- and ((zupp.depId = @depId) or (@tstDep = 0) or (zupp.depid=0))
- /* select distinct u.userId, emp.employeeid, emp.lastname, emp.firstname, u.login as LoginName, emp.emailaddress
- from users u, ZVue_UserProfilePerimRegion zupp, employee emp, UserOrg uo
- where uo.orgid = @orgid
- and u.userid = uo.userid
- and u.userId = zupp.userId
- and ( (locId=@locId) or (@tstLoc=0) or (locId=0) )
- and ( (accId=@accId) or (@tstAcc=0) or (accId=0) )
- and ( (depId=@depId) or (@tstDep=0) or (depid=0) )
- and u.employeeid *= emp.employeeid
- and u.active = 'A'
- order by emp.lastname */
- end
- else
- begin
- -- Liste des utilisateurs qu'en fonction du COUPLE
- insert into #tmpU
- select u.userid
- from ZVue_UserProfilePerimRegion zupp, users u, UserOrg uo
- where uo.orgid = @orgid
- and u.userid = uo.userid
- and u.active = 'A'
- and zupp.userId = u.userId
- and ((zupp.locId = @locId) or (@tstLoc = 0))
- and ((zupp.accId = @accId) or (@tstAcc = 0))
- and ((zupp.depId = @depId) or (@tstDep = 0))
- /* select distinct u.userId, emp.employeeid, emp.lastname, emp.firstname, u.login as LoginName, emp.emailaddress
- from users u, ZVue_UserProfilePerimRegion zupp, employee emp, UserOrg uo
- where uo.orgid = @orgid
- and u.userid = uo.userid
- and u.userId=zupp.userId
- and ( (locId=@locId) or (@tstLoc=0) )
- and ( (accId=@accId) or (@tstAcc=0) )
- and ( (depId=@depId) or (@tstDep=0) )
- and u.employeeid *= emp.employeeid
- and u.active = 'A'
- order by emp.lastname */
- end
- end
- else
- begin
- if @tous = 1
- begin
- -- Liste de tous les utilisateurs
- insert into #tmpU
- select u.userid
- from zprofileGroupeDroit zpgd, ZVue_UserProfilePerimRegion zupp, users u, UserOrg uo
- where uo.orgid = @orgid
- and u.userid = uo.userid
- and u.active = 'A'
- and zupp.userId = u.userId
- and ((zupp.locId = @locId) or (@tstLoc = 0) or (zupp.locId = 0))
- and ((zupp.accId = @accId) or (@tstAcc = 0) or (zupp.accId = 0))
- and ((zupp.depId = @depId) or (@tstDep = 0) or (zupp.depid = 0))
- and zpgd.profileId = zupp.profileId
- and zpgd.GroupedroitId = @droitId
- /* select distinct u.userId, emp.employeeid, emp.lastname, emp.firstname, u.login as LoginName, emp.emailaddress
- from users u, ZVue_UserProfilePerimRegion zupp, zprofileGroupeDroit zpgd, employee emp, UserOrg uo
- where uo.orgid = @orgid
- and u.userid = uo.userid
- and u.userId = zupp.userId
- and zupp.profileId = zpgd.profileId
- and zpgd.GroupedroitId = @droitId
- and ( (locId=@locId) or (@tstLoc=0) or (locId=0) )
- and ( (accId=@accId) or (@tstAcc=0) or (accId=0) )
- and ( (depId=@depId) or (@tstDep=0) or (depid=0) )
- and u.employeeid *= emp.employeeid
- and u.active = 'A'
- order by emp.lastname */
- end
- else
- begin
- -- Liste des utilisateurs qu'en fonction du COUPLE et du DROIT
- insert into #tmpU
- select u.userid
- from zprofileGroupeDroit zpgd, ZVue_UserProfilePerimRegion zupp, users u, UserOrg uo
- where uo.orgid = @orgid
- and u.userid = uo.userid
- and u.active = 'A'
- and zupp.userId = u.userId
- and ((zupp.locId = @locId) or (@tstLoc = 0))
- and ((zupp.accId = @accId) or (@tstAcc = 0))
- and ((zupp.depId = @depId) or (@tstDep = 0))
- and zpgd.profileId = zupp.profileId
- and zpgd.GroupedroitId = @droitId
- /* select distinct u.userId, emp.employeeid, emp.lastname, emp.firstname, u.login as LoginName, emp.emailaddress
- from users u, ZVue_UserProfilePerimRegion zupp, zprofileGroupeDroit zpgd, employee emp, UserOrg uo
- where uo.orgid = @orgid
- and u.userid = uo.userid
- and u.userId = zupp.userId
- and zupp.profileId=zpgd.profileId
- and zpgd.GroupedroitId = @droitId
- and ( (locId=@locId) or (@tstLoc=0) )
- and ( (accId=@accId) or (@tstAcc=0) )
- and ( (depId=@depId) or (@tstDep=0) )
- and u.employeeid *= emp.employeeid
- and u.active = 'A'
- order by emp.lastname */
- end
- end
- end
- FETCH NEXT FROM cur_org
- INTO @orgid
- END
- CLOSE authors_cursor
- DEALLOCATE authors_cursor
- select distinct u.userId, emp.employeeid, emp.lastname, emp.firstname, u.login as LoginName, emp.emailaddress
- from employee emp, users, #tmpU
- where users.userid = u.userid
- and emp.employeeid =* u.empployeeid
- select @lResult = @@rowcount
- GO
|
Si avec ça ça marche encore, bah je peux aller me faire moine Message édité par Arjuna le 22-02-2005 à 16:29:23
|