Overview

Namespaces

  • Igestis
    • Modules
      • Commercial
  • None

Classes

  • CommercialAccounting
  • CommercialArticle
  • CommercialArticleCategory
  • CommercialAutoIncrement
  • CommercialBankAccount
  • CommercialBankAssocOperations
  • CommercialBankOperation
  • CommercialCommercialDocument
  • CommercialCompanyConfig
  • CommercialEstimate
  • CommercialEstimateArticle
  • CommercialFreeDocument
  • CommercialInvoice
  • CommercialInvoiceItem
  • CommercialParametersController
  • CommercialProject
  • CommercialProviderInvoice
  • CommercialProviderInvoiceAssocAmounts
  • CommercialPurchasingAccount
  • CommercialPurchasingAccountRepository
  • CommercialSellingAccount
  • CommercialSellingAccountRepository
  • CommercialSoldType
  • CommercialSupportCredit
  • CommercialSupportInitialSold
  • CommercialSupportIntervention
  • CommercialUserConfig
  • Overview
  • Namespace
  • Class
  • Tree
  • Todo
  1: <?php
  2: 
  3: 
  4: 
  5: 
  6: 
  7: /**
  8:  * CommercialPurchasingAccount
  9:  *
 10:  * @Table(name="COMMERCIAL_PURCHASING_ACCOUNT")
 11:  * @Entity(repositoryClass="CommercialPurchasingAccountRepository")
 12:  * @HasLifecycleCallbacks
 13:  */
 14: class CommercialPurchasingAccount
 15: {
 16:     /**
 17:      * @var string $label
 18:      *
 19:      * @Column(name="label", type="string", length=45)
 20:      */
 21:     private $label;
 22: 
 23:     /**
 24:      * @var string $accountNumber
 25:      *
 26:      * @Column(name="account_number", type="string", length=15)
 27:      */
 28:     private $accountNumber;
 29: 
 30:     /**
 31:      * @var integer $id
 32:      *
 33:      * @Column(name="id", type="integer")
 34:      * @Id
 35:      * @GeneratedValue(strategy="IDENTITY")
 36:      */
 37:     private $id;
 38: 
 39:     /**
 40:      * @var CoreCompanies
 41:      *
 42:      * @ManyToOne(targetEntity="CoreCompanies")
 43:      * @JoinColumns({
 44:      *   @JoinColumn(name="company_id", referencedColumnName="id")
 45:      * })
 46:      */
 47:     private $company;
 48: 
 49: 
 50:     /**
 51:      * Set label
 52:      *
 53:      * @param string $label
 54:      * @return CommercialPurchasingAccount
 55:      */
 56:     public function setLabel($label)
 57:     {
 58:         $this->label = $label;
 59:         return $this;
 60:     }
 61: 
 62:     /**
 63:      * Get label
 64:      *
 65:      * @return string 
 66:      */
 67:     public function getLabel()
 68:     {
 69:         return $this->label;
 70:     }
 71: 
 72:     /**
 73:      * Set accountNumber
 74:      *
 75:      * @param string $accountNumber
 76:      * @return CommercialPurchasingAccount
 77:      */
 78:     public function setAccountNumber($accountNumber)
 79:     {
 80:         $this->accountNumber = $accountNumber;
 81:         return $this;
 82:     }
 83: 
 84:     /**
 85:      * Get accountNumber
 86:      *
 87:      * @return string 
 88:      */
 89:     public function getAccountNumber()
 90:     {
 91:         return $this->accountNumber;
 92:     }
 93: 
 94:     /**
 95:      * Get id
 96:      *
 97:      * @return integer 
 98:      */
 99:     public function getId()
100:     {
101:         return $this->id;
102:     }
103: 
104:     /**
105:      * Set company
106:      *
107:      * @param CoreCompanies $company
108:      * @return CommercialPurchasingAccount
109:      */
110:     public function setCompany(\CoreCompanies $company = null)
111:     {
112:         $this->company = $company;
113:         return $this;
114:     }
115: 
116:     /**
117:      * Get company
118:      *
119:      * @return CoreCompanies 
120:      */
121:     public function getCompany()
122:     {
123:         return $this->company;
124:     }
125:     
126:     /**
127:      * @PrePersist
128:      * @PreUpdate
129:      */
130:     public function prePersist() {
131:         if($this->company == null) {
132:             $this->company = \IgestisSecurity::init()->user->getCompany();
133:         }
134:     }
135: }
136: 
137: // ---------------------------------------------------------------------
138: 
139: class CommercialPurchasingAccountRepository extends \Doctrine\ORM\EntityRepository {
140: 
141:     public function findAll() {
142:         try {
143:             $userCompany = \IgestisSecurity::init()->user->getCompany();
144:             $qb = $this->_em->createQueryBuilder();
145:             $qb->select("pa")
146:                ->from("CommercialPurchasingAccount", "pa")
147:                ->where("pa.company = :company")
148:                ->setParameter("company", $userCompany);
149:         }
150:         catch (\Exception $e) {
151:             throw $e;
152:         }
153:         
154:         return $qb->getQuery()->getResult();
155:         
156:         
157:     }
158:     
159:     public function find($id, $lockMode = \Doctrine\DBAL\LockMode::NONE, $lockVersion = null) {
160:         $result = parent::find($id, $lockMode, $lockVersion);
161:         if(!$result || $result->getCompany()->getId() != \IgestisSecurity::init()->user->getCompany()->getId()) return null;
162:         return $result;
163:     }
164: 
165: }
igestis-iprojectis-v2 API documentation generated by ApiGen 2.8.0