Exemple #1
0
 /**
  * Get all linked clients based on given project
  *
  * @return array<Model\LinkedProjectClient>
  */
 public function getRelatedPartiesByProject(Model\Project $project)
 {
     $action = 'getRelatedPartiesByProject.php';
     $parameters = ['project_id' => $project->getId()];
     $response = $this->doRequest($action, $parameters);
     $parties = [];
     foreach ($response as $client) {
         $projectClient = new Model\LinkedProjectClient();
         $projectClient->setProject($project);
         switch ($client['type']) {
             case 'company':
                 $projectClient->setClient(Model\Company::_create($client));
                 break;
             case 'contact':
                 $projectClient->setClient(Model\Contact::_create($client));
                 break;
         }
         $projectClient->setGroup($client['group']);
         $projectClient->setRole($client['role']);
         $parties[] = $projectClient;
     }
     return $parties;
 }
Exemple #2
0
 /**
  * Get all contacts connected to company
  *
  * @param Model\Company $company
  * @return array<Model\LinkedCompanyContact>
  */
 public function getContactsByCompany(Model\Company $company)
 {
     if ($company->getId() > 0) {
         $action = 'getContactsByCompany.php';
         $parameters = ['company_id' => $company->getId()];
         $response = $this->doRequest($action, $parameters);
         $contacts = [];
         foreach ((array) $response as $contact) {
             $companyContact = new Model\LinkedCompanyContact();
             $companyContact->setContact(Model\Contact::_create($contact));
             $companyContact->setName($contact['name']);
             $companyContact->setFunction($contact['function']);
             $contacts[] = $companyContact;
         }
         return $contacts;
     }
     return null;
 }