updates for removing id and date of birth
[namibia] / module / User / src / User / Service / Registration.php
1 <?php
2 namespace User\Service;
3
4
5
6 /**
7  * Registration, login and forgot password functionality.
8  * @author andre.fourie
9  */
10 class Registration extends \User\DataBin\Registration
11 {
12
13         /**
14          * ExecuteAfter: RegisterFinal.
15          * Register a new dealership and its primary user.
16          * @param array $meta
17          * @param object|null $jobRecord
18          * @param object|null $record
19          * @param \Workspace\Utility\ServiceInputParams $contract
20          * @return array
21          */
22         public function RegisterCompany($meta, $jobRecord, $session, \Workspace\Utility\ServiceInputParams $contract)
23         {
24                 $contactService = new \Person\Service\Contact();
25                 $contactService->setWorkflow(new \Person\Workflow());
26 //              $companyService = new \Company\Service\Company();
27 //              $companyService->setWorkflow(new \Company\Workflow());
28                 $profileService = new \User\Service\Profile();
29                 $profileService->setWorkflow(new \User\Workflow());
30                 //\Utility\Debug::errorLog('create contact', $session->Contact);
31                 $contact = $contactService->create($session->Contact);
32                 $session->Company['contact'] = $contact->id;
33 //              if (isset($session->BillingContact))
34 //              {
35 //              //\Utility\Debug::errorLog('create billing contact', $session->BillingContact);
36 //                      $billingContact = $contactService->create($session->BillingContact);
37 //                      $session->Company['contbillingContactact'] = $billingContact->id;
38 //              }
39                 //\Utility\Debug::errorLog('create company', $session->Company);
40 //              $company = $companyService->create($session->Company);
41 //              $session->Profile['company'] = $company->id;
42 //              if ($session->Profile['permissions'] < 5 || $session->Profile['permissions'] > 8)
43 //              {
44 //                      $session->Profile['permissions'] = 5;
45 //              }
46                 $session->Profile['permissions'] = 12;
47                 \Utility\Debug::errorLog('create profile', $session->Profile);
48                 $profile = $profileService->create($session->Profile);
49
50                 $toCompanyId    = '';
51                 $toProfileId    = $profile->id;
52                 $email                  = $profile->email;
53                 $mobile                 = null;
54                 $subject                = null;
55                 $templateName   = 'activation-pending';
56
57                 $params = array();
58                 $params['firstName']    = $profile->firstName;
59                 $params['familyName']   = $profile->familyName;
60                 $params['message']              = 'Thank you for registering. Your registration was submitted for approval '
61                                                                 . 'and you will receive email confirmation once your account has been verified.'
62                                                                 . 'Please note that if any documents were not uploaded they need to be emailed'
63                                                                 . ' (info@bid4cars.com.na) or faxed (086 618 5584) before we can approve your '
64                                                                 . 'account.';
65
66                 #-> Send welcome notification to User.
67                 $oNotify = new \Utility\Comms\Notification();
68                 $oNotify->sendFromTemplate(
69                                 null, null,
70                                 $toCompanyId, $toProfileId,
71                                 $email, $mobile,
72                                 $subject,
73                                 $templateName,
74                                 $params
75                 );
76                 
77                 
78                 #-> Send welcome notification to Admin.
79                 $oNotify = new \Utility\Comms\Notification();
80                 $oNotify->sendFromTemplate(
81                                 null, null,
82                                 $toCompanyId, $toProfileId,
83                                 'info@bid4cars.com.na', $mobile,
84                                 $subject,
85                                 $templateName,
86                                 $params
87                 );
88         }
89
90 }