@@ -113,8 +113,9 @@ |
||
113 | 113 | |
114 | 114 | return true; |
115 | 115 | } catch (\Exception $e) { |
116 | - if ($this->manager->getConnection()->isTransactionActive()) |
|
117 | - $this->manager->getConnection()->rollBack(); |
|
116 | + if ($this->manager->getConnection()->isTransactionActive()) { |
|
117 | + $this->manager->getConnection()->rollBack(); |
|
118 | + } |
|
118 | 119 | |
119 | 120 | throw new \InvalidArgumentException($e->getMessage()); |
120 | 121 | } |
@@ -27,13 +27,13 @@ discard block |
||
27 | 27 | * |
28 | 28 | * @var Request |
29 | 29 | */ |
30 | - private $request = null; |
|
30 | + private $request = null; |
|
31 | 31 | |
32 | 32 | |
33 | 33 | |
34 | 34 | public function __construct(EntityManagerInterface $manager) |
35 | 35 | { |
36 | - $this->manager = $manager; |
|
36 | + $this->manager = $manager; |
|
37 | 37 | } |
38 | 38 | |
39 | 39 | public function __invoke(People $data, Request $request): JsonResponse |
@@ -75,12 +75,12 @@ discard block |
||
75 | 75 | throw new \InvalidArgumentException('Document id is not defined'); |
76 | 76 | } |
77 | 77 | |
78 | - $users = $this->manager->getRepository(User::class)->findBy(['people' => $person]); |
|
78 | + $users = $this->manager->getRepository(User::class)->findBy(['people' => $person]); |
|
79 | 79 | if (count($users) == 1) { |
80 | 80 | throw new \InvalidArgumentException('Deve existir pelo menos um usuário'); |
81 | 81 | } |
82 | 82 | |
83 | - $user = $this->manager->getRepository(User::class)->findOneBy(['id' => $payload['id'], 'people' => $person]); |
|
83 | + $user = $this->manager->getRepository(User::class)->findOneBy(['id' => $payload['id'], 'people' => $person]); |
|
84 | 84 | if (!$user instanceof User) { |
85 | 85 | throw new \InvalidArgumentException('Person user was not found'); |
86 | 86 | } |
@@ -41,7 +41,7 @@ |
||
41 | 41 | } |
42 | 42 | |
43 | 43 | |
44 | - public function getCompanyPeopleLinks(People $company, People $people, $linkType = null, $maxResults = null) |
|
44 | + public function getCompanyPeopleLinks(People $company, People $people, $linkType = null, $maxResults = null) |
|
45 | 45 | { |
46 | 46 | $queryBuilder = $this->getEntityManager()->createQueryBuilder(); |
47 | 47 | $queryBuilder->select('pl') |
@@ -51,8 +51,9 @@ |
||
51 | 51 | ->setParameter('company', $company->getId()) |
52 | 52 | ->setParameter('people', $people->getId()); |
53 | 53 | |
54 | - if ($linkType) |
|
55 | - $queryBuilder->setParameter('linkType', $linkType)->andWhere('pl.link_type = :linkType'); |
|
54 | + if ($linkType) { |
|
55 | + $queryBuilder->setParameter('linkType', $linkType)->andWhere('pl.link_type = :linkType'); |
|
56 | + } |
|
56 | 57 | |
57 | 58 | if ($maxResults) { |
58 | 59 | $queryBuilder->setMaxResults($maxResults); |
@@ -112,31 +112,31 @@ discard block |
||
112 | 112 | |
113 | 113 | case 'active': |
114 | 114 | |
115 | - $queryBuilder->innerJoin(Order::class, 'O' , 'WITH', 'O.client = myclients.id'); |
|
116 | - $queryBuilder->innerJoin(People::class, 'C' , 'WITH', 'C.id = O.provider'); |
|
115 | + $queryBuilder->innerJoin(Order::class, 'O', 'WITH', 'O.client = myclients.id'); |
|
116 | + $queryBuilder->innerJoin(People::class, 'C', 'WITH', 'C.id = O.provider'); |
|
117 | 117 | $queryBuilder->innerJoin(PeopleSalesman::class, 'kkk', 'WITH', 'kkk.company = C.id'); |
118 | - $queryBuilder->innerJoin(People::class, 'S' , 'WITH', 'S.id = kkk.salesman'); |
|
119 | - $queryBuilder->innerJoin(PeopleClient::class, 'PC' , 'WITH', 'PC.client = myclients.id AND PC.company_id = S.id'); |
|
118 | + $queryBuilder->innerJoin(People::class, 'S', 'WITH', 'S.id = kkk.salesman'); |
|
119 | + $queryBuilder->innerJoin(PeopleClient::class, 'PC', 'WITH', 'PC.client = myclients.id AND PC.company_id = S.id'); |
|
120 | 120 | $queryBuilder->andWhere('O.provider = :provider'); |
121 | 121 | $queryBuilder->andWhere('S.id IN (:my_companies)'); |
122 | 122 | $queryBuilder->andWhere('O.status NOT IN (:statuses)'); |
123 | 123 | $queryBuilder->andWhere('O.orderDate BETWEEN :from_date AND :to_date'); |
124 | - $queryBuilder->setParameter('provider' , $provider); |
|
125 | - $queryBuilder->setParameter('statuses' , $this->getEntityManager()->getRepository(Status::class)->findBy(['realStatus' => ['open','canceled']])); |
|
126 | - $queryBuilder->setParameter('from_date' , $fromDate); |
|
127 | - $queryBuilder->setParameter('to_date' , $toDate); |
|
124 | + $queryBuilder->setParameter('provider', $provider); |
|
125 | + $queryBuilder->setParameter('statuses', $this->getEntityManager()->getRepository(Status::class)->findBy(['realStatus' => ['open', 'canceled']])); |
|
126 | + $queryBuilder->setParameter('from_date', $fromDate); |
|
127 | + $queryBuilder->setParameter('to_date', $toDate); |
|
128 | 128 | $queryBuilder->setParameter('my_companies', $this->getMyCompanies($salesman)); |
129 | 129 | |
130 | 130 | break; |
131 | 131 | |
132 | 132 | case 'inactive': |
133 | 133 | |
134 | - $queryBuilder->innerJoin(Order::class, 'O' , 'WITH', 'O.client = myclients.id'); |
|
135 | - $queryBuilder->innerJoin(People::class, 'C' , 'WITH', 'C.id = O.provider'); |
|
134 | + $queryBuilder->innerJoin(Order::class, 'O', 'WITH', 'O.client = myclients.id'); |
|
135 | + $queryBuilder->innerJoin(People::class, 'C', 'WITH', 'C.id = O.provider'); |
|
136 | 136 | $queryBuilder->innerJoin(PeopleSalesman::class, 'kkk', 'WITH', 'kkk.company = C.id'); |
137 | - $queryBuilder->innerJoin(People::class, 'S' , 'WITH', 'S.id = kkk.salesman'); |
|
138 | - $queryBuilder->innerJoin(PeopleClient::class, 'PC' , 'WITH', 'PC.client = myclients.id AND PC.company_id = S.id'); |
|
139 | - $queryBuilder->leftJoin (Order::class, 'jj' , 'WITH', 'jj.client = myclients.id |
|
137 | + $queryBuilder->innerJoin(People::class, 'S', 'WITH', 'S.id = kkk.salesman'); |
|
138 | + $queryBuilder->innerJoin(PeopleClient::class, 'PC', 'WITH', 'PC.client = myclients.id AND PC.company_id = S.id'); |
|
139 | + $queryBuilder->leftJoin(Order::class, 'jj', 'WITH', 'jj.client = myclients.id |
|
140 | 140 | AND (jj.status NOT IN (:statuses) OR jj.id IS NULL) |
141 | 141 | AND ((jj.orderDate BETWEEN :from_date AND :to_date) OR jj.id IS NULL) |
142 | 142 | AND (jj.provider = :provider OR jj.id IS NULL)'); |
@@ -147,23 +147,23 @@ discard block |
||
147 | 147 | $queryBuilder->groupBy('myclients.id'); |
148 | 148 | $queryBuilder->having('COUNT(jj.id) > :count'); |
149 | 149 | $queryBuilder->andHaving('COUNT(O.id) = :count'); |
150 | - $queryBuilder->setParameter('provider' , $provider); |
|
151 | - $queryBuilder->setParameter('statuses' , $this->getEntityManager()->getRepository(Status::class)->findBy(['realStatus' => ['open','canceled']])); |
|
150 | + $queryBuilder->setParameter('provider', $provider); |
|
151 | + $queryBuilder->setParameter('statuses', $this->getEntityManager()->getRepository(Status::class)->findBy(['realStatus' => ['open', 'canceled']])); |
|
152 | 152 | $queryBuilder->setParameter('from_date', $fromDate); |
153 | - $queryBuilder->setParameter('to_date' , $toDate); |
|
154 | - $queryBuilder->setParameter('count' , 0); |
|
153 | + $queryBuilder->setParameter('to_date', $toDate); |
|
154 | + $queryBuilder->setParameter('count', 0); |
|
155 | 155 | $queryBuilder->setParameter('my_companies', $this->getMyCompanies($salesman)); |
156 | 156 | |
157 | 157 | break; |
158 | 158 | |
159 | 159 | case 'prospect': |
160 | 160 | |
161 | - $queryBuilder->innerJoin(Order::class, 'O' , 'WITH', 'O.client = myclients.id'); |
|
162 | - $queryBuilder->innerJoin(People::class, 'C' , 'WITH', 'C.id = O.provider'); |
|
161 | + $queryBuilder->innerJoin(Order::class, 'O', 'WITH', 'O.client = myclients.id'); |
|
162 | + $queryBuilder->innerJoin(People::class, 'C', 'WITH', 'C.id = O.provider'); |
|
163 | 163 | $queryBuilder->innerJoin(PeopleSalesman::class, 'PS', 'WITH', 'PS.company = C.id'); |
164 | - $queryBuilder->innerJoin(People::class, 'S' , 'WITH', 'S.id = PS.salesman'); |
|
165 | - $queryBuilder->innerJoin(PeopleClient::class, 'PC', 'WITH', 'PC.client = myclients.id AND PC.company_id = S.id'); |
|
166 | - $queryBuilder->leftJoin (Order::class, 'jj' , 'WITH', 'jj.client = myclients.id |
|
164 | + $queryBuilder->innerJoin(People::class, 'S', 'WITH', 'S.id = PS.salesman'); |
|
165 | + $queryBuilder->innerJoin(PeopleClient::class, 'PC', 'WITH', 'PC.client = myclients.id AND PC.company_id = S.id'); |
|
166 | + $queryBuilder->leftJoin(Order::class, 'jj', 'WITH', 'jj.client = myclients.id |
|
167 | 167 | AND (jj.status NOT IN (:statuses) OR jj.id IS NULL) |
168 | 168 | AND (jj.provider = :provider OR jj.id IS NULL)'); |
169 | 169 | $queryBuilder->andWhere('O.provider = :provider'); |
@@ -173,19 +173,19 @@ discard block |
||
173 | 173 | $queryBuilder->having('COUNT(jj.id) = :count'); |
174 | 174 | |
175 | 175 | $queryBuilder->setParameter('provider', $provider); |
176 | - $queryBuilder->setParameter('statuses', $this->getEntityManager()->getRepository(Status::class)->findBy(['realStatus' => ['open','canceled']])); |
|
177 | - $queryBuilder->setParameter('count' , 0); |
|
176 | + $queryBuilder->setParameter('statuses', $this->getEntityManager()->getRepository(Status::class)->findBy(['realStatus' => ['open', 'canceled']])); |
|
177 | + $queryBuilder->setParameter('count', 0); |
|
178 | 178 | $queryBuilder->setParameter('my_companies', $this->getMyCompanies($salesman)); |
179 | 179 | |
180 | 180 | break; |
181 | 181 | |
182 | 182 | case 'new': |
183 | 183 | |
184 | - $queryBuilder->innerJoin(Order::class, 'O' , 'WITH', 'O.client = myclients.id'); |
|
185 | - $queryBuilder->innerJoin(People::class, 'C' , 'WITH', 'C.id = O.provider'); |
|
184 | + $queryBuilder->innerJoin(Order::class, 'O', 'WITH', 'O.client = myclients.id'); |
|
185 | + $queryBuilder->innerJoin(People::class, 'C', 'WITH', 'C.id = O.provider'); |
|
186 | 186 | $queryBuilder->innerJoin(PeopleSalesman::class, 'kkk', 'WITH', 'kkk.company = C.id'); |
187 | - $queryBuilder->innerJoin(People::class, 'S' , 'WITH', 'S.id = kkk.salesman'); |
|
188 | - $queryBuilder->innerJoin(PeopleClient::class, 'PC' , 'WITH', 'PC.client = myclients.id AND PC.company_id = S.id'); |
|
187 | + $queryBuilder->innerJoin(People::class, 'S', 'WITH', 'S.id = kkk.salesman'); |
|
188 | + $queryBuilder->innerJoin(PeopleClient::class, 'PC', 'WITH', 'PC.client = myclients.id AND PC.company_id = S.id'); |
|
189 | 189 | |
190 | 190 | $queryBuilder->andWhere('O.provider = :provider'); |
191 | 191 | $queryBuilder->andWhere('S.id IN (:my_companies)'); |
@@ -193,10 +193,10 @@ discard block |
||
193 | 193 | $queryBuilder->andWhere('O.orderDate BETWEEN :from_date AND :to_date'); |
194 | 194 | $queryBuilder->andWhere('myclients.registerDate BETWEEN :from_date AND :to_date'); |
195 | 195 | |
196 | - $queryBuilder->setParameter('provider' , $provider); |
|
197 | - $queryBuilder->setParameter('statuses' , $this->getEntityManager()->getRepository(Status::class)->findBy(['realStatus' => ['open','canceled']])); |
|
198 | - $queryBuilder->setParameter('from_date' , $fromDate); |
|
199 | - $queryBuilder->setParameter('to_date' , $toDate); |
|
196 | + $queryBuilder->setParameter('provider', $provider); |
|
197 | + $queryBuilder->setParameter('statuses', $this->getEntityManager()->getRepository(Status::class)->findBy(['realStatus' => ['open', 'canceled']])); |
|
198 | + $queryBuilder->setParameter('from_date', $fromDate); |
|
199 | + $queryBuilder->setParameter('to_date', $toDate); |
|
200 | 200 | $queryBuilder->setParameter('my_companies', $this->getMyCompanies($salesman)); |
201 | 201 | |
202 | 202 | break; |
@@ -130,7 +130,7 @@ discard block |
||
130 | 130 | } |
131 | 131 | } |
132 | 132 | |
133 | - $peopleemployee = $this->em->getRepository(PeopleLink::class)->findOneBy(['company' => $company, 'employee' => $userPeople]); |
|
133 | + $peopleemployee = $this->em->getRepository(PeopleLink::class)->findOneBy(['company' => $company, 'employee' => $userPeople]); |
|
134 | 134 | |
135 | 135 | $permissions[$company->getId()][] = 'salesman'; |
136 | 136 | $myCompanies[$company->getId()] = [ |
@@ -158,7 +158,7 @@ discard block |
||
158 | 158 | $myCompanies[$key]['permission'] = array_values($permission); |
159 | 159 | } |
160 | 160 | |
161 | - usort($myCompanies, function ($a, $b) { |
|
161 | + usort($myCompanies, function($a, $b) { |
|
162 | 162 | |
163 | 163 | if ($a['alias'] == $b['alias']) { |
164 | 164 | return 0; |
@@ -204,11 +204,11 @@ discard block |
||
204 | 204 | $p_m[$package_module->getId()]['module'] = $package_module->getModule()->getName(); |
205 | 205 | } |
206 | 206 | |
207 | - $packages[$people_package->getId()]['id'] = $people_package->getId(); |
|
208 | - $packages[$people_package->getId()]['package']['id'] = $package->getId(); |
|
209 | - $packages[$people_package->getId()]['package']['name'] = $package->getName(); |
|
210 | - $packages[$people_package->getId()]['package']['active'] = $package->isActive() ? true : false; |
|
211 | - $packages[$people_package->getId()]['package']['modules'] = $p_m; |
|
207 | + $packages[$people_package->getId()]['id'] = $people_package->getId(); |
|
208 | + $packages[$people_package->getId()]['package']['id'] = $package->getId(); |
|
209 | + $packages[$people_package->getId()]['package']['name'] = $package->getName(); |
|
210 | + $packages[$people_package->getId()]['package']['active'] = $package->isActive() ? true : false; |
|
211 | + $packages[$people_package->getId()]['package']['modules'] = $p_m; |
|
212 | 212 | } |
213 | 213 | |
214 | 214 | return $packages; |
@@ -243,7 +243,7 @@ discard block |
||
243 | 243 | /** |
244 | 244 | * @var \ControleOnline\Entity\Document $document |
245 | 245 | */ |
246 | - $documents = $documents->filter(function ($document) { |
|
246 | + $documents = $documents->filter(function($document) { |
|
247 | 247 | return $document->getDocumentType()->getDocumentType() == 'CNPJ'; |
248 | 248 | }); |
249 | 249 |
@@ -88,7 +88,7 @@ |
||
88 | 88 | 'background' => $this->domainService->getPeopleDomain()->getTheme()->getBackground() ? [ |
89 | 89 | 'id' => $this->domainService->getPeopleDomain()->getTheme()->getBackground(), |
90 | 90 | 'domain' => $this->domainService->getMainDomain(), |
91 | - 'url' => '/files/' . $this->domainService->getPeopleDomain()->getTheme()->getBackground() . '/download' |
|
91 | + 'url' => '/files/'.$this->domainService->getPeopleDomain()->getTheme()->getBackground().'/download' |
|
92 | 92 | ] : null, |
93 | 93 | ]; |
94 | 94 | } |
@@ -111,7 +111,7 @@ |
||
111 | 111 | if (self::$mainCompany) return self::$mainCompany; |
112 | 112 | |
113 | 113 | $peopleDomain = $this->domainService->getPeopleDomain(); |
114 | - self::$mainCompany = $peopleDomain->getPeople(); |
|
114 | + self::$mainCompany = $peopleDomain->getPeople(); |
|
115 | 115 | |
116 | 116 | return self::$mainCompany; |
117 | 117 | } |
@@ -34,7 +34,9 @@ discard block |
||
34 | 34 | $isSalesman = false; |
35 | 35 | |
36 | 36 | $isSalesman = $this->manager->getRepository(People::class)->getCompanyPeopleLinks($mainCompany, $people, 'salesman', 1); |
37 | - if ($isSalesman) return true; |
|
37 | + if ($isSalesman) { |
|
38 | + return true; |
|
39 | + } |
|
38 | 40 | |
39 | 41 | $getPeopleCompanies = $this->manager->getRepository(PeopleLink::class)->findBy([ |
40 | 42 | 'people' => $people, |
@@ -45,7 +47,9 @@ discard block |
||
45 | 47 | */ |
46 | 48 | foreach ($getPeopleCompanies as $peopleCompany) { |
47 | 49 | $isSalesman = $this->manager->getRepository(People::class)->getCompanyPeopleLinks($mainCompany, $peopleCompany->getCompany(), 'salesman', 1); |
48 | - if ($isSalesman) return true; |
|
50 | + if ($isSalesman) { |
|
51 | + return true; |
|
52 | + } |
|
49 | 53 | } |
50 | 54 | return $isSalesman; |
51 | 55 | } |
@@ -57,8 +61,9 @@ discard block |
||
57 | 61 | $mainCompany = $this->getMainCompany(); |
58 | 62 | |
59 | 63 | $isSuper = $this->manager->getRepository(People::class)->getCompanyPeopleLinks($mainCompany, $people, 'employee', 1); |
60 | - if ($isSuper) |
|
61 | - $peopleRole[] = 'super'; |
|
64 | + if ($isSuper) { |
|
65 | + $peopleRole[] = 'super'; |
|
66 | + } |
|
62 | 67 | |
63 | 68 | |
64 | 69 | |
@@ -69,13 +74,15 @@ discard block |
||
69 | 74 | } |
70 | 75 | |
71 | 76 | $isClient = $this->manager->getRepository(People::class)->getCompanyPeopleLinks($mainCompany, $people, 'client', 1); |
72 | - if ($isClient) |
|
73 | - $peopleRole[] = 'client'; |
|
77 | + if ($isClient) { |
|
78 | + $peopleRole[] = 'client'; |
|
79 | + } |
|
74 | 80 | |
75 | 81 | |
76 | 82 | $isSalesman = $this->isSalesman($people); |
77 | - if ($isSalesman) |
|
78 | - $peopleRole[] = 'salesman'; |
|
83 | + if ($isSalesman) { |
|
84 | + $peopleRole[] = 'salesman'; |
|
85 | + } |
|
79 | 86 | |
80 | 87 | |
81 | 88 | return array_values(array_unique(empty($peopleRole) ? ['guest'] : $peopleRole)); |
@@ -89,7 +96,9 @@ discard block |
||
89 | 96 | public function getMainCompany(): People |
90 | 97 | { |
91 | 98 | |
92 | - if (self::$mainCompany) return self::$mainCompany; |
|
99 | + if (self::$mainCompany) { |
|
100 | + return self::$mainCompany; |
|
101 | + } |
|
93 | 102 | |
94 | 103 | $peopleDomain = $this->domainService->getPeopleDomain(); |
95 | 104 | self::$mainCompany = $peopleDomain->getPeople(); |
@@ -22,7 +22,7 @@ discard block |
||
22 | 22 | private Security $security, |
23 | 23 | private RequestStack $requestStack |
24 | 24 | ) { |
25 | - $this->request = $requestStack->getCurrentRequest(); |
|
25 | + $this->request = $requestStack->getCurrentRequest(); |
|
26 | 26 | } |
27 | 27 | |
28 | 28 | public function prePersist(People $people) |
@@ -122,29 +122,29 @@ discard block |
||
122 | 122 | public function checkLink(QueryBuilder $queryBuilder, $resourceClass = null, $applyTo = null, $rootAlias = null): void |
123 | 123 | { |
124 | 124 | |
125 | - $link = $this->request->query->get('link', null); |
|
125 | + $link = $this->request->query->get('link', null); |
|
126 | 126 | $company = $this->request->query->get('company', null); |
127 | 127 | $link_type = $this->request->query->get('link_type', null); |
128 | 128 | |
129 | 129 | if ($link_type) { |
130 | - $queryBuilder->join(sprintf('%s.' . ($link ? 'company' : 'link'), $rootAlias), 'PeopleLink'); |
|
130 | + $queryBuilder->join(sprintf('%s.'.($link ? 'company' : 'link'), $rootAlias), 'PeopleLink'); |
|
131 | 131 | $queryBuilder->andWhere('PeopleLink.link_type IN(:link_type)'); |
132 | 132 | $queryBuilder->setParameter('link_type', $link_type); |
133 | 133 | } |
134 | 134 | |
135 | 135 | if ($company || $link) { |
136 | - $queryBuilder->andWhere('PeopleLink.' . ($link ? 'people' : 'company') . ' IN(:people)'); |
|
136 | + $queryBuilder->andWhere('PeopleLink.'.($link ? 'people' : 'company').' IN(:people)'); |
|
137 | 137 | $queryBuilder->setParameter('people', preg_replace("/[^0-9]/", "", ($link ?: $company))); |
138 | 138 | } |
139 | 139 | } |
140 | 140 | public function checkCompany($type, QueryBuilder $queryBuilder, $resourceClass = null, $applyTo = null, $rootAlias = null): void |
141 | 141 | { |
142 | - $companies = $this->getMyCompanies(); |
|
143 | - $queryBuilder->andWhere(sprintf('%s.' . $type . ' IN(:companies)', $rootAlias, $rootAlias)); |
|
142 | + $companies = $this->getMyCompanies(); |
|
143 | + $queryBuilder->andWhere(sprintf('%s.'.$type.' IN(:companies)', $rootAlias, $rootAlias)); |
|
144 | 144 | $queryBuilder->setParameter('companies', $companies); |
145 | 145 | |
146 | 146 | if ($payer = $this->request->query->get('company', null)) { |
147 | - $queryBuilder->andWhere(sprintf('%s.' . $type . ' IN(:people)', $rootAlias)); |
|
147 | + $queryBuilder->andWhere(sprintf('%s.'.$type.' IN(:people)', $rootAlias)); |
|
148 | 148 | $queryBuilder->setParameter('people', preg_replace("/[^0-9]/", "", $payer)); |
149 | 149 | } |
150 | 150 | } |
@@ -158,7 +158,7 @@ discard block |
||
158 | 158 | */ |
159 | 159 | $token = $this->security->getToken(); |
160 | 160 | if (!$token) return []; |
161 | - $currentUser = $token->getUser(); |
|
161 | + $currentUser = $token->getUser(); |
|
162 | 162 | $companies = []; |
163 | 163 | if (!$currentUser) return []; |
164 | 164 |
@@ -39,8 +39,9 @@ discard block |
||
39 | 39 | { |
40 | 40 | |
41 | 41 | $document = $this->manager->getRepository(Document::class)->findOneBy(['document' => $document_number]); |
42 | - if ($document) |
|
43 | - return $document->getPeople(); |
|
42 | + if ($document) { |
|
43 | + return $document->getPeople(); |
|
44 | + } |
|
44 | 45 | |
45 | 46 | |
46 | 47 | if ($name) { |
@@ -72,9 +73,9 @@ discard block |
||
72 | 73 | $payload = json_decode($request->getContent()); |
73 | 74 | if (isset($payload->link_type)) { |
74 | 75 | $company = $this->manager->getRepository(People::class)->find(preg_replace('/\D/', '', $payload->company)); |
75 | - if ($company) |
|
76 | - $this->addLink($company, $people, $payload->link_type); |
|
77 | - else { |
|
76 | + if ($company) { |
|
77 | + $this->addLink($company, $people, $payload->link_type); |
|
78 | + } else { |
|
78 | 79 | $link = $this->manager->getRepository(People::class)->find(preg_replace('/\D/', '', $payload->link)); |
79 | 80 | if ($payload->link_type == 'employee' && $link) { |
80 | 81 | $this->addLink($people, $link, $payload->link_type); |
@@ -102,8 +103,9 @@ discard block |
||
102 | 103 | 'link_type' => $link_type |
103 | 104 | ]); |
104 | 105 | |
105 | - if (!$peopleLink) |
|
106 | - $peopleLink = new PeopleLink(); |
|
106 | + if (!$peopleLink) { |
|
107 | + $peopleLink = new PeopleLink(); |
|
108 | + } |
|
107 | 109 | |
108 | 110 | $peopleLink->setCompany($company); |
109 | 111 | $peopleLink->setPeople($people); |
@@ -157,10 +159,14 @@ discard block |
||
157 | 159 | * @var \ControleOnline\Entity\User $currentUser |
158 | 160 | */ |
159 | 161 | $token = $this->security->getToken(); |
160 | - if (!$token) return []; |
|
162 | + if (!$token) { |
|
163 | + return []; |
|
164 | + } |
|
161 | 165 | $currentUser = $token->getUser(); |
162 | 166 | $companies = []; |
163 | - if (!$currentUser) return []; |
|
167 | + if (!$currentUser) { |
|
168 | + return []; |
|
169 | + } |
|
164 | 170 | |
165 | 171 | if (!$currentUser->getPeople()->getLink()->isEmpty()) { |
166 | 172 | foreach ($currentUser->getPeople()->getLink() as $company) { |
@@ -698,7 +698,7 @@ |
||
698 | 698 | |
699 | 699 | public function getOneDocument(): ?Document |
700 | 700 | { |
701 | - $documents = $this->getDocument()->filter(function ($peopleDocument) { |
|
701 | + $documents = $this->getDocument()->filter(function($peopleDocument) { |
|
702 | 702 | if ($peopleDocument->getPeople()->getPeopleType() == 'F') { |
703 | 703 | return $peopleDocument->getDocumentType()->getDocumentType() == 'CPF'; |
704 | 704 | } |