OffreLegumes.php 12 KB
Newer Older
1 2 3 4
<?php

namespace PotageBundle\Entity;

Mat's avatar
Mat committed
5
use JMS\Serializer\Annotation as Serializer;
6
use Doctrine\ORM\Mapping as ORM;
7 8 9
use Symfony\Component\HttpFoundation\File\File;
use Vich\UploaderBundle\Mapping\Annotation as Vich;

10 11 12 13 14 15

/**
 * OffreLegumes
 *
 * @ORM\Table(name="offre_legumes")
 * @ORM\Entity(repositoryClass="PotageBundle\Repository\OffreLegumesRepository")
16 17 18
 * @ORM\HasLifecycleCallbacks()
 * @Vich\Uploadable
 *
19 20 21 22 23 24 25 26 27
 */
class OffreLegumes
{
    /**
     * @var int
     *
     * @ORM\Column(name="id", type="integer")
     * @ORM\Id
     * @ORM\GeneratedValue(strategy="AUTO")
28
     * @Serializer\Groups({"readOffres", "readOffreLegumes"})
29 30
     */
    private $id;
31 32 33 34 35 36 37 38 39 40 41
    
    /**
     * @var int
     * @ORM\ManyToOne(targetEntity="PotageBundle\Entity\Offre", inversedBy="offreLegumes")
     * @ORM\JoinColumn(name="id_offre", nullable=false)
     */
    private $offre;
    
    /**
     * @var string
     *
42
     * @ORM\Column(name="reference", type="string", length=16, unique=false)
43 44 45 46 47 48
     */
    private $reference;
    
    /**
     * @var \DateTime
     *
49
     * @ORM\Column(name="created_at", type="datetime")
50
     * @Serializer\Groups({"readOffreLegumes"})
51 52 53 54 55 56
     */
    private $createdAt;
    
    /**
     * @var \DateTime
     *
57
     * @ORM\Column(name="updated_at", type="datetime", nullable=true)
58
     * @Serializer\Groups({"readOffreLegumes"})
59 60 61 62 63 64 65
     */
    private $updatedAt;
    
    /**
     * @var string
     *
     * @ORM\Column(name="nom", type="string", length=100)
66
     * @Serializer\Groups({"readOffres", "readOffreLegumes"})
67 68 69 70 71 72 73
     */
    private $nom;
    
    /**
     * @var string
     *
     * @ORM\Column(name="description", type="text")
74
     * @Serializer\Groups({"readOffreLegumes"})
75 76 77 78 79 80
     */
    private $description;
    
    /**
     * @var boolean
     * @ORM\Column(name="is_fruit", type="boolean")
81
     * @Serializer\Groups({"readOffreLegumes"})
82 83 84 85 86 87
     */
    private $fruit;
    
    /**
     * @var boolean
     * @ORM\Column(name="is_revente", type="boolean")
88
     * @Serializer\Groups({"readOffreLegumes"})
89 90 91 92 93 94 95
     */
    private $revente;
    
    /**
     * @var string
     *
     * @ORM\Column(name="origine", type="string", length=100, nullable=true)
96
     * @Serializer\Groups({"readOffreLegumes"})
97 98 99 100 101 102 103
     */
    private $origine;
    
    /**
     * @var float
     *
     * @ORM\Column(name="prix_unitaire", type="float")
104
     * @Serializer\Groups({"readOffreLegumes"})
105 106 107 108 109 110 111
     */
    private $prixUnitaire;
    
    /**
     * @var string
     *
     * @ORM\Column(name="unite", type="string", length=25)
112
     * @Serializer\Groups({"readOffreLegumes"})
113 114 115
     */
    private $unite;
    
116 117 118
    /**
     * @var float
     *
119
     * @ORM\Column(name="quantite_min", type="float", nullable=true)
120
     * @Serializer\Groups({"readOffreLegumes"})
121 122 123 124 125 126 127
     */
    private $quantiteMin;
    
    /**
     * @var float
     *
     * @ORM\Column(name="quantite_max", type="float", nullable=true)
128
     * @Serializer\Groups({"readOffreLegumes"})
129 130 131 132 133 134 135
     */
    private $quantiteMax;
    
    /**
     * @var float
     *
     * @ORM\Column(name="quantite_step", type="float", nullable=true)
136
     * @Serializer\Groups({"readOffreLegumes"})
137 138 139 140
     */
    private $quantiteStep;
    
    /**
141
     * @ORM\Column(type="string", length=255, nullable=true)
142
     * @var string
143
     * @Serializer\Groups({"readOffreLegumes"})
144 145 146 147 148 149 150 151 152 153 154 155 156
     */
    private $image;
    
    /**
     * @Vich\UploadableField(mapping="legume_images", fileNameProperty="image")
     * @var File
     */
    private $imageFile;
    
    /**
     * @var float
     *
     * @ORM\Column(name="volume_max", type="float", nullable=true)
157
     * @Serializer\Groups({"readOffreLegumes"})
158 159 160 161 162 163 164
     */
    private $volumeMax;

    /**
     * @var bool
     *
     * @ORM\Column(name="is_promo", type="boolean")
165
     * @Serializer\Groups({"readOffreLegumes"})
166 167 168 169 170 171 172
     */
    private $isPromo;

    /**
     * @var string
     *
     * @ORM\Column(name="promo", type="string", length=100, nullable=true)
173
     * @Serializer\Groups({"readOffreLegumes"})
174 175
     */
    private $promo;
176 177
    
    
178 179
    /**
     * OffreLegumes constructor.
Mat's avatar
Mat committed
180 181
     *
     * @param $id_offre
182
     */
Mat's avatar
Mat committed
183
    public function __construct($id_offre)
184
    {
Mat's avatar
Mat committed
185
        $this->offre = $id_offre;
186
        $this->isPromo = false;
187 188
        $this->fruit = false;
        $this->revente = false;
189 190
    }
    
191 192 193 194 195 196 197
    /**
     *
     * @ORM\PrePersist()
     */
    public function prePersist()
    {
        $this->createdAt = new \DateTime();
198
        
199 200 201 202 203 204 205 206 207 208
    }
    /**
     *
     * @ORM\PreUpdate()
     */
    public function preUpdate()
    {
        $this->updatedAt = new \DateTime();
    }
    
209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291

    /**
     * Get id
     *
     * @return int
     */
    public function getId()
    {
        return $this->id;
    }

    /**
     * Set volumeMax
     *
     * @param float $volumeMax
     *
     * @return OffreLegumes
     */
    public function setVolumeMax($volumeMax)
    {
        $this->volumeMax = $volumeMax;

        return $this;
    }

    /**
     * Get volumeMax
     *
     * @return float
     */
    public function getVolumeMax()
    {
        return $this->volumeMax;
    }

    /**
     * Set isPromo
     *
     * @param boolean $isPromo
     *
     * @return OffreLegumes
     */
    public function setIsPromo($isPromo)
    {
        $this->isPromo = $isPromo;

        return $this;
    }

    /**
     * Get isPromo
     *
     * @return bool
     */
    public function getIsPromo()
    {
        return $this->isPromo;
    }

    /**
     * Set promo
     *
     * @param string $promo
     *
     * @return OffreLegumes
     */
    public function setPromo($promo)
    {
        $this->promo = $promo;

        return $this;
    }

    /**
     * Get promo
     *
     * @return string
     */
    public function getPromo()
    {
        return $this->promo;
    }

292 293 294
    /**
     * Set reference
     *
295 296
     * @param $reference
     * @return $this
297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313
     */
    public function setReference($reference)
    {
        $this->reference = $reference;

        return $this;
    }

    /**
     * Get reference
     *
     * @return string
     */
    public function getReference()
    {
        return $this->reference;
    }
314 315 316 317 318 319 320 321 322
    
    /**
     * @return string
     */
    public function getReferenceMore()
    {
        return '(#' . sprintf("%03d", $this->id) . ') ' . $this->reference;
    }
    
323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633
    /**
     * Set createdAt
     *
     * @param \DateTime $createdAt
     *
     * @return OffreLegumes
     */
    public function setCreatedAt($createdAt)
    {
        $this->createdAt = $createdAt;

        return $this;
    }

    /**
     * Get createdAt
     *
     * @return \DateTime
     */
    public function getCreatedAt()
    {
        return $this->createdAt;
    }

    /**
     * Set updatedAt
     *
     * @param \DateTime $updatedAt
     *
     * @return OffreLegumes
     */
    public function setUpdatedAt($updatedAt)
    {
        $this->updatedAt = $updatedAt;

        return $this;
    }

    /**
     * Get updatedAt
     *
     * @return \DateTime
     */
    public function getUpdatedAt()
    {
        return $this->updatedAt;
    }

    /**
     * Set nom
     *
     * @param string $nom
     *
     * @return OffreLegumes
     */
    public function setNom($nom)
    {
        $this->nom = $nom;

        return $this;
    }

    /**
     * Get nom
     *
     * @return string
     */
    public function getNom()
    {
        return $this->nom;
    }

    /**
     * Set description
     *
     * @param string $description
     *
     * @return OffreLegumes
     */
    public function setDescription($description)
    {
        $this->description = $description;

        return $this;
    }

    /**
     * Get description
     *
     * @return string
     */
    public function getDescription()
    {
        return $this->description;
    }

    /**
     * Set fruit
     *
     * @param boolean $fruit
     *
     * @return OffreLegumes
     */
    public function setFruit($fruit)
    {
        $this->fruit = $fruit;

        return $this;
    }

    /**
     * Get fruit
     *
     * @return boolean
     */
    public function getFruit()
    {
        return $this->fruit;
    }

    /**
     * Set revente
     *
     * @param boolean $revente
     *
     * @return OffreLegumes
     */
    public function setRevente($revente)
    {
        $this->revente = $revente;

        return $this;
    }

    /**
     * Get revente
     *
     * @return boolean
     */
    public function getRevente()
    {
        return $this->revente;
    }

    /**
     * Set origine
     *
     * @param string $origine
     *
     * @return OffreLegumes
     */
    public function setOrigine($origine)
    {
        $this->origine = $origine;

        return $this;
    }

    /**
     * Get origine
     *
     * @return string
     */
    public function getOrigine()
    {
        return $this->origine;
    }

    /**
     * Set prixUnitaire
     *
     * @param float $prixUnitaire
     *
     * @return OffreLegumes
     */
    public function setPrixUnitaire($prixUnitaire)
    {
        $this->prixUnitaire = $prixUnitaire;

        return $this;
    }

    /**
     * Get prixUnitaire
     *
     * @return float
     */
    public function getPrixUnitaire()
    {
        return $this->prixUnitaire;
    }

    /**
     * Set unite
     *
     * @param string $unite
     *
     * @return OffreLegumes
     */
    public function setUnite($unite)
    {
        $this->unite = $unite;

        return $this;
    }

    /**
     * Get unite
     *
     * @return string
     */
    public function getUnite()
    {
        return $this->unite;
    }

    /**
     * Set quantiteMin
     *
     * @param float $quantiteMin
     *
     * @return OffreLegumes
     */
    public function setQuantiteMin($quantiteMin)
    {
        $this->quantiteMin = $quantiteMin;

        return $this;
    }

    /**
     * Get quantiteMin
     *
     * @return float
     */
    public function getQuantiteMin()
    {
        return $this->quantiteMin;
    }

    /**
     * Set quantiteMax
     *
     * @param float $quantiteMax
     *
     * @return OffreLegumes
     */
    public function setQuantiteMax($quantiteMax)
    {
        $this->quantiteMax = $quantiteMax;

        return $this;
    }

    /**
     * Get quantiteMax
     *
     * @return float
     */
    public function getQuantiteMax()
    {
        return $this->quantiteMax;
    }

    /**
     * Set quantiteStep
     *
     * @param float $quantiteStep
     *
     * @return OffreLegumes
     */
    public function setQuantiteStep($quantiteStep)
    {
        $this->quantiteStep = $quantiteStep;

        return $this;
    }

    /**
     * Get quantiteStep
     *
     * @return float
     */
    public function getQuantiteStep()
    {
        return $this->quantiteStep;
    }

    /**
     * Set image
     *
     * @param string $image
     *
     * @return OffreLegumes
     */
    public function setImage($image)
    {
        $this->image = $image;

        return $this;
    }

    /**
     * Get image
     *
     * @return string
     */
    public function getImage()
    {
        return $this->image;
    }
634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659
    
    /**
     * @param File|null $image
     */
    public function setImageFile(File $image = null)
    {
        $this->imageFile = $image;
        
        // VERY IMPORTANT:
        // It is required that at least one field changes if you are using Doctrine,
        // otherwise the event listeners won't be called and the file is lost
        if ($image) {
            // if 'updatedAt' is not defined in your entity, use another property
            $this->updatedAt = new \DateTime('now');
        }
    }
    
    /**
     * @return File
     */
    public function getImageFile()
    {
        return $this->imageFile;
    }
    
    
660 661 662 663 664 665 666 667 668 669 670 671 672
    /**
     * Set offre
     *
     * @param \PotageBundle\Entity\Offre $offre
     *
     * @return OffreLegumes
     */
    public function setOffre(\PotageBundle\Entity\Offre $offre)
    {
        $this->offre = $offre;

        return $this;
    }
673
    
674
    /**
675
     * @return int
676 677 678 679 680
     */
    public function getOffre()
    {
        return $this->offre;
    }
681 682 683 684 685 686 687 688 689
    
    /*
    private OffrePrepa;
    
    public function setOffrePrepa($offresPrepa)
    {
    
    }
    */
690
}