ReportPart.php (6240B)
1 <?php 2 3 namespace PartKeepr\ProjectBundle\Entity; 4 5 use Doctrine\Common\Collections\ArrayCollection; 6 use Doctrine\ORM\Mapping as ORM; 7 use PartKeepr\CoreBundle\Entity\BaseEntity; 8 use PartKeepr\DistributorBundle\Entity\Distributor; 9 use PartKeepr\DoctrineReflectionBundle\Annotation\TargetService; 10 use PartKeepr\DoctrineReflectionBundle\Annotation\VirtualOneToMany; 11 use PartKeepr\PartBundle\Entity\Part; 12 use Symfony\Component\Serializer\Annotation\Groups; 13 14 /** 15 * Represents a project part. 16 * 17 * @ORM\Entity 18 * @TargetService("/api/project_report_parts") 19 */ 20 class ReportPart extends BaseEntity 21 { 22 /** 23 * @ORM\ManyToOne(targetEntity="PartKeepr\ProjectBundle\Entity\Report",inversedBy="reportParts") 24 * @Groups({"default"}) 25 * 26 * @var Report 27 */ 28 private $report; 29 30 /** 31 * @ORM\ManyToOne(targetEntity="PartKeepr\PartBundle\Entity\Part") 32 * @Groups({"default"}) 33 * 34 * @var Part 35 */ 36 private $part; 37 38 /** 39 * @ORM\Column(type="integer",nullable=false) 40 * @Groups({"default"}) 41 * 42 * @var int 43 */ 44 private $quantity; 45 46 /** 47 * @ORM\ManyToOne(targetEntity="PartKeepr\DistributorBundle\Entity\Distributor") 48 * @Groups({"default"}) 49 * 50 * @var Distributor 51 */ 52 private $distributor; 53 54 /** 55 * @Groups({"default"}) 56 * 57 * @var string 58 */ 59 private $distributorOrderNumber; 60 61 /** 62 * @Groups({"default"}) 63 * 64 * @var string 65 */ 66 private $itemPrice; 67 68 /** 69 * @Groups({"default"}) 70 * 71 * @var string 72 */ 73 private $orderSum; 74 75 /** 76 * @Groups({"default"}) 77 * 78 * @var bool 79 */ 80 private $metaPart; 81 82 /** 83 * @VirtualOneToMany(target="PartKeepr\PartBundle\Entity\Part") 84 * @Groups({"default"}) 85 * 86 * @var Part[] 87 */ 88 private $subParts; 89 90 /** 91 * @VirtualOneToMany(target="PartKeepr\ProjectBundle\Entity\ProjectPart") 92 * @Groups({"default"}) 93 * 94 * @var ProjectPart[] 95 */ 96 private $projectParts; 97 /** 98 * @Groups({"default"}) 99 * 100 * @var string 101 */ 102 private $itemSum; 103 104 /** 105 * @Groups({"default"}) 106 * 107 * @var int 108 */ 109 private $missing; 110 111 public function __construct() 112 { 113 $this->projectParts = new ArrayCollection(); 114 } 115 116 /** 117 * @return ArrayCollection|ProjectPart[] 118 */ 119 public function getProjectParts() 120 { 121 if (!$this->projectParts instanceof ArrayCollection) { 122 $this->projectParts = new ArrayCollection(); 123 } 124 125 return $this->projectParts; 126 } 127 128 /** 129 * @return Part[] 130 */ 131 public function getSubParts() 132 { 133 return $this->subParts; 134 } 135 136 /** 137 * @param Part[] $subParts 138 */ 139 public function setSubParts($subParts) 140 { 141 $this->subParts = $subParts; 142 } 143 144 /** 145 * @return bool 146 */ 147 public function isMetaPart() 148 { 149 return $this->metaPart; 150 } 151 152 /** 153 * @param bool $metaPart 154 */ 155 public function setMetaPart($metaPart) 156 { 157 $this->metaPart = $metaPart; 158 } 159 160 /** 161 * @return string 162 */ 163 public function getDistributorOrderNumber() 164 { 165 return $this->distributorOrderNumber; 166 } 167 168 /** 169 * @param string $distributorOrderNumber 170 * 171 * @return ReportPart 172 */ 173 public function setDistributorOrderNumber($distributorOrderNumber) 174 { 175 $this->distributorOrderNumber = $distributorOrderNumber; 176 177 return $this; 178 } 179 180 /** 181 * @return string 182 */ 183 public function getItemPrice() 184 { 185 return $this->itemPrice; 186 } 187 188 /** 189 * @param string $itemPrice 190 * 191 * @return ReportPart 192 */ 193 public function setItemPrice($itemPrice) 194 { 195 $this->itemPrice = $itemPrice; 196 197 return $this; 198 } 199 200 /** 201 * @return string 202 */ 203 public function getOrderSum() 204 { 205 return $this->orderSum; 206 } 207 208 /** 209 * @param string $orderSum 210 * 211 * @return ReportPart 212 */ 213 public function setOrderSum($orderSum) 214 { 215 $this->orderSum = $orderSum; 216 217 return $this; 218 } 219 220 /** 221 * @return string 222 */ 223 public function getItemSum() 224 { 225 return $this->itemSum; 226 } 227 228 /** 229 * @param string $itemSum 230 * 231 * @return ReportPart 232 */ 233 public function setItemSum($itemSum) 234 { 235 $this->itemSum = $itemSum; 236 237 return $this; 238 } 239 240 /** 241 * @return mixed 242 */ 243 public function getDistributor() 244 { 245 return $this->distributor; 246 } 247 248 /** 249 * @param mixed $distributor 250 * 251 * @return ReportPart 252 */ 253 public function setDistributor($distributor) 254 { 255 $this->distributor = $distributor; 256 257 return $this; 258 } 259 260 /** 261 * @return int 262 */ 263 public function getMissing() 264 { 265 return $this->missing; 266 } 267 268 /** 269 * @param int $missing 270 * 271 * @return ReportPart 272 */ 273 public function setMissing($missing) 274 { 275 $this->missing = $missing; 276 277 return $this; 278 } 279 280 /** 281 * @return int 282 */ 283 public function getQuantity() 284 { 285 return $this->quantity; 286 } 287 288 /** 289 * @param int $quantity 290 * 291 * @return ReportPart 292 */ 293 public function setQuantity($quantity) 294 { 295 $this->quantity = $quantity; 296 297 return $this; 298 } 299 300 /** 301 * @return Report 302 */ 303 public function getReport() 304 { 305 return $this->report; 306 } 307 308 /** 309 * @param Report $report 310 * 311 * @return ReportPart 312 */ 313 public function setReport($report) 314 { 315 $this->report = $report; 316 317 return $this; 318 } 319 320 /** 321 * @return Part 322 */ 323 public function getPart() 324 { 325 return $this->part; 326 } 327 328 /** 329 * @param mixed $part 330 * 331 * @return ReportPart 332 */ 333 public function setPart($part) 334 { 335 $this->part = $part; 336 337 return $this; 338 } 339 340 public function __toString() 341 { 342 // @todo i18n 343 return sprintf( 344 "Used in project report %s %s", 345 $this->getReport()->getName(), 346 $this->getReport()->getCreateDateTime()->format("Y-m-d H:i:s") 347 )." / ".parent::__toString(); 348 } 349 }