示例#1
0
 /**
  * This class extends default class, by operating on Entity.
  * @param Entity $entity Entity, to manage.
  */
 public function setEntity(Entity $entity)
 {
     $this->entity = $entity;
     $this->setEntityName($entity->getEntityName());
     $this->setEntityId($entity->getId());
     $this->repository = $this->orm->repository($this->entityName, $this->module)->get($this->entityName, $this->module);
     return $this;
 }
 public function getEndValue(Entity $entity, $field)
 {
     if ($field == 'owner') {
         $user = $this->repo('User', 'User')->find($entity->getOwner());
         if ($user) {
             return $user->getName() . ' (ID:' . $entity->getOwner() . ')';
         } else {
             return $entity->getOwner();
         }
     }
     return parent::getEndValue($entity, $field);
 }
 public function getEndValue(Entity $entity, $field)
 {
     switch ($field) {
         case 'createDate':
             return date('Y-m-d', $entity->getCreateDate());
             break;
         case 'discount':
             return $entity->getDiscount() . ' %';
             break;
         case 'tax':
             return $entity->getTax() . ' %';
             break;
     }
     return parent::getEndValue($entity, $field);
 }
 public function getEndValue(Entity $entity, $field)
 {
     if ($field == 'type') {
         if ($entity->getType() == 1) {
             return $this->t('contractorTypePerson');
         }
         if ($entity->getType() == 2) {
             return $this->t('contractorTypeCompany');
         }
     }
     if ($field == 'owner') {
         $user = $this->repo('User', 'User')->find($entity->getOwner());
         if ($user) {
             return $user->getName() . ' (ID:' . $entity->getOwner() . ')';
         } else {
             return $entity->getOwner();
         }
     }
     return parent::getEndValue($entity, $field);
 }
 public function getEndValue(Entity $entity, $field)
 {
     switch ($field) {
         case 'releaseDate':
             return date('Y-m-d', $entity->getReleaseDate());
             break;
         case 'sellDate':
             return date('Y-m-d', $entity->getSellDate());
             break;
         case 'paymentDate':
             return date('Y-m-d', $entity->getPaymentDate());
             break;
         case 'showShipment':
             return $entity->getShowShipment() == 1 ? $this->t('syes') : $this->t('sno');
             break;
         case 'status':
             return $this->t('invoiceStatus' . $entity->getStatus());
             break;
         case 'contractor':
             $contractor = $this->repo('Contractor', 'Contractor')->find($entity->getContractor());
             if ($contractor) {
                 return $contractor->getName();
             } else {
                 $entity->getContractor();
             }
             break;
         case 'owner':
             $user = $this->repo('User', 'User')->find($entity->getOwner());
             if ($user) {
                 return $user->getName() . ' (ID:' . $entity->getOwner() . ')';
             } else {
                 return $entity->getOwner();
             }
             break;
     }
     return parent::getEndValue($entity, $field);
 }
 /**
  * {@inheritdoc}
  */
 public function getEndValue(Entity $entity, $field)
 {
     if ($field == 'tax') {
         $tax = $this->get('helper.tax')->get($entity->getTax());
         if ($tax) {
             return $tax->name;
         }
     }
     if ($field == 'unit') {
         $unit = $this->get('helper.measureUnit')->name($entity->getUnit());
         if ($unit) {
             return $unit;
         }
     }
     if ($field == 'sellStart') {
         return $this->datetime()->dateShort($entity->getSellStart());
     }
     if ($field == 'sellEnd') {
         return $this->datetime()->dateShort($entity->getSellEnd());
     }
     if ($field == 'supportStart') {
         return $this->datetime()->dateShort($entity->getSupportStart());
     }
     if ($field == 'supportEnd') {
         return $this->datetime()->dateShort($entity->getSupportEnd());
     }
     if ($field == 'sellAllowed') {
         return $entity->getSellAllowed() ? $this->t('syes') : $this->t('sno');
     }
     if ($field == 'owner') {
         $user = $this->repo('User', 'User')->find($entity->getOwner());
         if ($user) {
             return $user->getName() . ' (ID:' . $entity->getOwner() . ')';
         } else {
             return $entity->getOwner();
         }
     }
     return parent::getEndValue($entity, $field);
 }