text changes to registration mail content
[namibia] / module / Config / src / Config / Service / RegionalManager.php
1 <?php
2 namespace Config\Service;
3
4
5
6 class RegionalManager extends \Config\DataBin\RegionalManager
7 {
8
9
10         /**
11          * Contract for custom select list.
12          * @param object|null $jobRecord
13          * @param array $input
14          * @return \Workspace\Contract\Recurring
15          */
16         public function contractJoinedSelectList($jobRecord, array $input = array())
17         {
18
19                 $options = new \Workspace\UseCase\Options();
20                 $requirement = new \Workspace\UseCase\Requirement();
21                 $requirement->addRequiredInput(array(
22                                 'Filter' => array(
23                                                 'group'                         => 'Id',
24                                                 'region'                        => 'Id'
25                                 )
26                 ));
27                 return new \Workspace\Contract\Recurring($options, $requirement);
28         }
29
30         /**
31          * A custom select list.
32          * @param object|null $jobRecord
33          * @param \Workspace\Utility\ServiceInputParams $contract
34          * @return array
35          */
36         public function executeJoinedSelectList($jobRecord, \Workspace\Utility\ServiceInputParams $contract)
37         {
38                 $items = $this->em->createQuery(
39                                 'SELECT partial regionalManager.{id,firstName,familyName} '
40                                 . 'FROM Config\Entity\RegionalManager regionalManager '
41                                 . 'JOIN regionalManager.group grp '
42                                 . 'JOIN grp.companies company '
43                                 . 'WHERE IDENTITY(regionalManager.group) = :groupId '
44                                 . ' AND IDENTITY(company.region) = :regionId '
45                                 . 'ORDER BY regionalManager.firstName, regionalManager.familyName ASC'
46                         )
47                         ->setParameter('groupId', $contract->data->Filter['group'])
48                         ->setParameter('regionId', $contract->data->Filter['region'])
49                         ->getArrayResult();
50                 $data = array();
51                 $ids = array();
52                 foreach ($items as $item)
53                 {
54                         if (isset($ids[$item['id']]))
55                         {
56                                 continue;
57                         }
58                         $ids[$item['id']] = true;
59                         $data[] = array(
60                                         'value' => $item['id'],
61                                         'label' => $item['firstName'] . ' ' . $item['familyName']
62                         );
63                 }
64                 return $contract->success(
65                                 'List retrieved.',
66                                 $data
67                                 );
68         }
69
70
71 }