예제 #1
0
파일: Email.php 프로젝트: chinazan/zzcrm
 public function loadAdditionalFieldsForList(Entity $entity)
 {
     parent::loadAdditionalFieldsForList($entity);
     $userEmailAdddressIdList = [];
     foreach ($this->getUser()->get('emailAddresses') as $ea) {
         $userEmailAdddressIdList[] = $ea->id;
     }
     $status = $entity->get('status');
     if (in_array($entity->get('fromEmailAddressId'), $userEmailAdddressIdList)) {
         $entity->loadLinkMultipleField('toEmailAddresses');
         $idList = $entity->get('toEmailAddressesIds');
         $names = $entity->get('toEmailAddressesNames');
         if (!empty($idList)) {
             $arr = [];
             foreach ($idList as $emailAddressId) {
                 $person = $this->getEntityManager()->getRepository('EmailAddress')->getEntityByAddressId($emailAddressId);
                 if ($person) {
                     $arr[] = $person->get('name');
                 } else {
                     $arr[] = $names->{$emailAddressId};
                 }
             }
             $entity->set('personStringData', 'To: ' . implode(', ', $arr));
         }
     } else {
         $fromEmailAddressId = $entity->get('fromEmailAddressId');
         if (!empty($fromEmailAddressId)) {
             $person = $this->getEntityManager()->getRepository('EmailAddress')->getEntityByAddressId($fromEmailAddressId);
             if ($person) {
                 $entity->set('personStringData', $person->get('name'));
             } else {
                 $fromName = self::parseFromName($entity->get('fromString'));
                 if (!empty($fromName)) {
                     $entity->set('personStringData', $fromName);
                 } else {
                     $entity->set('personStringData', $entity->get('fromEmailAddressName'));
                 }
             }
         }
     }
     $this->loadUserColumnFields($entity);
 }