Browse Source

Merge branch 'hotfix' of https://git.logipro.com/raphael/Phoenix into hotfix

raphael 3 years ago
parent
commit
d52399bda3
1 changed files with 28 additions and 31 deletions
  1. 28
    31
      src/Phoenix/Repository/SocietyRepository.php

+ 28
- 31
src/Phoenix/Repository/SocietyRepository.php View File

@@ -1,4 +1,5 @@
1 1
 <?php
2
+
2 3
 namespace Logipro\Phoenix\Repository;
3 4
 
4 5
 use Doctrine\Bundle\DoctrineBundle\Repository\ServiceEntityRepository;
@@ -24,14 +25,13 @@ class SocietyRepository extends ServiceEntityRepository
24 25
 	public function findSocietiesByFilter(Filter $filter, bool $usePaginator = true)
25 26
 	{
26 27
 		$qb = $this->createQueryBuilder('society');
27
-		
28
+
28 29
 		// Mot-clé
29 30
 		$words = $filter->getFilterWords('term');
30
-		if (count($words) > 0)
31
-		{
32
-			foreach ($words as $i => $word)
33
-			{
34
-				$qb->andWhere("(society.name LIKE ?$i)"
31
+		if (count($words) > 0) {
32
+			foreach ($words as $i => $word) {
33
+				$qb->andWhere(
34
+					"(society.name LIKE ?$i)"
35 35
 				);
36 36
 
37 37
 				// Contient le mot cherché
@@ -42,19 +42,18 @@ class SocietyRepository extends ServiceEntityRepository
42 42
 		// Tri
43 43
 		$sortName = $filter->getSortKey();
44 44
 		$sortOrder = $filter->getSortOrder();
45
-		switch ($sortName)
46
-		{
45
+		switch ($sortName) {
47 46
 			case 'telephone':
48 47
 				$qb->orderBy('society.telephone', $sortOrder);
49 48
 				break;
50 49
 
51 50
 			case 'email':
52
-			$qb->orderBy('society.email', $sortOrder);
53
-				break;				
51
+				$qb->orderBy('society.email', $sortOrder);
52
+				break;
54 53
 
55 54
 			case 'department':
56
-				$qb->orderBy('society.addressPostcode', $sortOrder);
57
-				break;				
55
+				$qb->orderBy('society.addressPostcodeHeadOffice', $sortOrder);
56
+				break;
58 57
 
59 58
 			case 'societyId':
60 59
 				$qb->orderBy('society.societyId', $sortOrder);
@@ -69,12 +68,11 @@ class SocietyRepository extends ServiceEntityRepository
69 68
 		$service = $this->container->get('phxSettings');
70 69
 		$defaultSociety = $service->getDefaultSociety();
71 70
 		$qb->andWhere('society.societyId != :idnot');
72
-		$qb->setParameter('idnot',$defaultSociety->getSocietyId());
71
+		$qb->setParameter('idnot', $defaultSociety->getSocietyId());
73 72
 
74 73
 		$query = $qb->getQuery();
75
-		
76
-		if ($usePaginator)
77
-		{
74
+
75
+		if ($usePaginator) {
78 76
 			$paginator = new Paginator($query);
79 77
 
80 78
 			$filter->paginate($paginator);
@@ -101,7 +99,7 @@ class SocietyRepository extends ServiceEntityRepository
101 99
 		$result = $query->execute();
102 100
 
103 101
 		return !empty($result);
104
-	}	
102
+	}
105 103
 
106 104
 	/**
107 105
 	 * Retourne si le contact est un responsable Administratif dans une société
@@ -120,9 +118,9 @@ class SocietyRepository extends ServiceEntityRepository
120 118
 		$result = $query->execute();
121 119
 
122 120
 		return !empty($result);
123
-	}	
124
-	
125
-	
121
+	}
122
+
123
+
126 124
 	/**
127 125
 	 * Retourne si le contact est un responsable RH dans une société
128 126
 	 * @param int $personId
@@ -140,9 +138,9 @@ class SocietyRepository extends ServiceEntityRepository
140 138
 		$result = $query->execute();
141 139
 
142 140
 		return !empty($result);
143
-	}	
144
-	
145
-/**
141
+	}
142
+
143
+	/**
146 144
 	 *
147 145
 	 * @param string $term
148 146
 	 * @return mixed|\Doctrine\DBAL\Driver\Statement|array|NULL
@@ -153,11 +151,10 @@ class SocietyRepository extends ServiceEntityRepository
153 151
 
154 152
 		// Mot-clé
155 153
 		$words = SearchTools::splitWords($term);
156
-		if (count($words) > 0)
157
-		{
158
-			foreach ($words as $i => $word)
159
-			{
160
-				$qb->andWhere("(society.name LIKE ?$i)"
154
+		if (count($words) > 0) {
155
+			foreach ($words as $i => $word) {
156
+				$qb->andWhere(
157
+					"(society.name LIKE ?$i)"
161 158
 				);
162 159
 
163 160
 				// Contient le mot cherché
@@ -170,10 +167,10 @@ class SocietyRepository extends ServiceEntityRepository
170 167
 		$service = $this->container->get('phxSettings');
171 168
 		$defaultSociety = $service->getDefaultSociety();
172 169
 		$qb->andWhere('society.societyId != :idnot');
173
-		$qb->setParameter('idnot',$defaultSociety->getSocietyId());
170
+		$qb->setParameter('idnot', $defaultSociety->getSocietyId());
174 171
 
175 172
 		$query = $qb->getQuery();
176 173
 
177 174
 		return $query->execute();
178
-	}	
179
-}
175
+	}
176
+}

Loading…
Cancel
Save