Guest User

Untitled

a guest
Nov 24th, 2017
84
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 14.39 KB | None | 0 0
  1. <?php
  2.  
  3. namespace AppBundleEntity;
  4.  
  5. use DoctrineORMMapping as ORM;
  6. use JMSSerializerAnnotation as JMS;
  7.  
  8. /**
  9. * LigneCommande
  10. *
  11. * @ORMTable(name="ligne_commande")
  12. * @ORMEntity(repositoryClass="AppBundleRepositoryLigneCommandeRepository")
  13. */
  14. class LigneCommande
  15. {
  16. /**
  17. * @var int
  18. *
  19. * @JMSGroups({"listeLigneCommandes", "detailLigneCommande"})
  20. *
  21. * @ORMColumn(name="id", type="integer")
  22. * @ORMId
  23. * @ORMGeneratedValue(strategy="AUTO")
  24. */
  25. protected $id;
  26.  
  27. /**
  28. * @var Commande
  29. *
  30. * @JMSGroups({"listeLigneCommandes", "detailLigneCommande"})
  31. *
  32. * Many LigneCommande have One numeroCommande.
  33. * @ORMManyToOne(targetEntity="Commande", inversedBy="lignes", cascade={"all"}, fetch="EAGER")
  34. */
  35. protected $commande;
  36.  
  37. /**
  38. * @var Article
  39. *
  40. * @JMSGroups({"listeLigneCommandes", "detailLigneCommande"})
  41. *
  42. * Many LigneCommande have One codeArticle.
  43. * @ORMManyToOne(targetEntity="Article", inversedBy="lignes", cascade={"all"}, fetch="EAGER")
  44. */
  45. protected $article;
  46.  
  47. /**
  48. * @var string
  49. *
  50. * @JMSGroups({"listeLigneCommandes", "detailLigneCommande"})
  51. *
  52. * @ORMColumn(name="libelle", type="string", length=255)
  53. */
  54. protected $libelle;
  55.  
  56. /**
  57. * @var string
  58. *
  59. * @JMSGroups({"listeLigneCommandes", "detailLigneCommande"})
  60. *
  61. * @ORMColumn(name="unite", type="string", length=255)
  62. */
  63. protected $unite;
  64.  
  65. /**
  66. * @var float
  67. *
  68. * @JMSGroups({"listeLigneCommandes", "detailLigneCommande"})
  69. *
  70. * @ORMColumn(name="qte_commande", type="float")
  71. */
  72. protected $qteCommande;
  73.  
  74. /**
  75. * @var float
  76. *
  77. * @JMSGroups({"listeLigneCommandes", "detailLigneCommande"})
  78. *
  79. * @ORMColumn(name="qte_recue", type="float")
  80. */
  81. protected $qteRecue;
  82.  
  83. /**
  84. * @var float
  85. *
  86. * @JMSGroups({"listeLigneCommandes", "detailLigneCommande"})
  87. *
  88. * @ORMColumn(name="qte_arecevoir", type="float")
  89. */
  90. protected $qteArecevoir;
  91.  
  92. /**
  93. * @var float
  94. *
  95. * @JMSGroups({"listeLigneCommandes", "detailLigneCommande"})
  96. *
  97. * @ORMColumn(name="identifiant", type="float", unique=true)
  98. */
  99. protected $identifiant;
  100.  
  101.  
  102. /**
  103. * Get id
  104. *
  105. * @return int
  106. */
  107. public function getId()
  108. {
  109. return $this->id;
  110. }
  111.  
  112. /**
  113. * Set commande
  114. *
  115. * @param Commande $commande
  116. *
  117. * @return LigneCommande
  118. */
  119. public function setCommande(Commande $commande)
  120. {
  121. $this->numero = $commande;
  122.  
  123. return $this;
  124. }
  125.  
  126. /**
  127. * Get commande
  128. *
  129. * @return Commande
  130. */
  131. public function getCommande()
  132. {
  133. return $this->commande;
  134. }
  135.  
  136. /**
  137. * Set article
  138. *
  139. * @param Article $article
  140. *
  141. * @return LigneCommande
  142. */
  143. public function setArticle(Article $article)
  144. {
  145. $this->article = $article;
  146.  
  147. return $this;
  148. }
  149.  
  150. /**
  151. * Get article
  152. *
  153. * @return Article
  154. */
  155. public function getArticle()
  156. {
  157. return $this->article;
  158. }
  159.  
  160. /**
  161. * Set libelle
  162. *
  163. * @param string $libelle
  164. *
  165. * @return LigneCommande
  166. */
  167. public function setLibelle($libelle)
  168. {
  169. $this->libelle = $libelle;
  170.  
  171. return $this;
  172. }
  173.  
  174. /**
  175. * Get libelle
  176. *
  177. * @return string
  178. */
  179. public function getLibelle()
  180. {
  181. return $this->libelle;
  182. }
  183.  
  184. /**
  185. * Set unite
  186. *
  187. * @param string $unite
  188. *
  189. * @return LigneCommande
  190. */
  191. public function setUnite($unite)
  192. {
  193. $this->unite = $unite;
  194.  
  195. return $this;
  196. }
  197.  
  198. /**
  199. * Get unite
  200. *
  201. * @return string
  202. */
  203. public function getUnite()
  204. {
  205. return $this->unite;
  206. }
  207.  
  208. /**
  209. * Set qteCommande
  210. *
  211. * @param float $qteCommande
  212. *
  213. * @return LigneCommande
  214. */
  215. public function setQteCommande($qteCommande)
  216. {
  217. $this->qteCommande = $qteCommande;
  218.  
  219. return $this;
  220. }
  221.  
  222. /**
  223. * Get qteCommande
  224. *
  225. * @return float
  226. */
  227. public function getQteCommande()
  228. {
  229. return $this->qteCommande;
  230. }
  231.  
  232. /**
  233. * Set qteRecue
  234. *
  235. * @param float $qteRecue
  236. *
  237. * @return LigneCommande
  238. */
  239. public function setQteRecue($qteRecue)
  240. {
  241. $this->qteRecue = $qteRecue;
  242.  
  243. return $this;
  244. }
  245.  
  246. /**
  247. * Get qteRecue
  248. *
  249. * @return float
  250. */
  251. public function getQteRecue()
  252. {
  253. return $this->qteRecue;
  254. }
  255.  
  256. /**
  257. * Set qteArecevoir
  258. *
  259. * @param float $qteArecevoir
  260. *
  261. * @return LigneCommande
  262. */
  263. public function setQteArecevoir($qteArecevoir)
  264. {
  265. $this->qteArecevoir = $qteArecevoir;
  266.  
  267. return $this;
  268. }
  269.  
  270. /**
  271. * Get qteArecevoir
  272. *
  273. * @return float
  274. */
  275. public function getQteArecevoir()
  276. {
  277. return $this->qteArecevoir;
  278. }
  279.  
  280. /**
  281. * Set identifiant
  282. *
  283. * @param float $identifiant
  284. *
  285. * @return LigneCommande
  286. */
  287. public function setIdentifiant($identifiant)
  288. {
  289. $this->identifiant = $identifiant;
  290.  
  291. return $this;
  292. }
  293.  
  294. /**
  295. * Get identifiant
  296. *
  297. * @return float
  298. */
  299. public function getIdentifiant()
  300. {
  301. return $this->identifiant;
  302. }
  303. }
  304.  
  305. <?php
  306.  
  307. namespace AppBundleEntity;
  308.  
  309. use DoctrineCommonCollectionsArrayCollection;
  310. use DoctrineCommonCollectionsCollection;
  311. use DoctrineORMMapping as ORM;
  312. use JMSSerializerAnnotation as JMS;
  313.  
  314. /**
  315. * Commande
  316. *
  317. * @ORMTable(name="commande")
  318. * @ORMEntity(repositoryClass="AppBundleRepositoryCommandeRepository")
  319. */
  320. class Commande
  321. {
  322. /**
  323. * @var int
  324. *
  325. * @JMSGroups({"listeCommandes"})
  326. *
  327. * @ORMColumn(name="id", type="integer")
  328. * @ORMId
  329. * @ORMGeneratedValue(strategy="AUTO")
  330. */
  331. private $id;
  332.  
  333. /**
  334. * @var string
  335. *
  336. * @JMSGroups({"listeCommandes", "detailCommande"})
  337. *
  338. * @ORMColumn(name="numero", type="string", length=8, unique=true)
  339. */
  340. private $numero;
  341.  
  342. /**
  343. * @var DateTime
  344. *
  345. * @JMSGroups({"listeCommandes", "detailCommande"})
  346. *
  347. * @ORMColumn(name="date", type="date")
  348. */
  349. private $date;
  350.  
  351. /**
  352. * @var int
  353. *
  354. * @JMSGroups({"listeCommandes", "detailCommande"})
  355. *
  356. * @ORMColumn(name="chantier_id", type="integer")
  357. *
  358. * Many Commande have One chantierCode.
  359. * @ORMManyToOne(targetEntity="Chantier")
  360. * @ORMJoinColumn(name="chantier_id", referencedColumnName="id")
  361. */
  362. private $chantier;
  363.  
  364. /**
  365. * @var string
  366. *
  367. * @JMSGroups({"listeCommandes", "detailCommande"})
  368. *
  369. * @ORMColumn(name="fournisseur_code", type="string", length=7)
  370. */
  371. private $fournisseurCode;
  372.  
  373. /**
  374. * @var string
  375. *
  376. * @JMSGroups({"listeCommandes", "detailCommande"})
  377. *
  378. * @ORMColumn(name="fournisseur_nom", type="string", length=255)
  379. */
  380. private $fournisseurNom;
  381.  
  382. /**
  383. * @var string
  384. *
  385. * @JMSGroups({"listeCommandes", "detailCommande"})
  386. *
  387. * @ORMColumn(name="redacteur_code", type="string", length=5)
  388. */
  389. private $redacteurCode;
  390.  
  391. /**
  392. * @var string
  393. *
  394. * @JMSGroups({"listeCommandes", "detailCommande"})
  395. *
  396. * @ORMColumn(name="secteur_code", type="string", length=1, nullable=true)
  397. */
  398. private $secteurCode;
  399.  
  400. /**
  401. * @var string
  402. *
  403. * @JMSGroups({"listeCommandes", "detailCommande"})
  404. *
  405. * @ORMColumn(name="livraison_nom", type="string", length=255)
  406. */
  407. private $livraisonNom;
  408.  
  409. /**
  410. * @var string
  411. *
  412. * @JMSGroups({"listeCommandes", "detailCommande"})
  413. *
  414. * @ORMColumn(name="livraison_adresse", type="string", length=255)
  415. */
  416. private $livraisonAdresse;
  417.  
  418. /**
  419. * @var string
  420. *
  421. * @JMSGroups({"listeCommandes", "detailCommande"})
  422. *
  423. * @ORMColumn(name="livraison_cp", type="string", length=5)
  424. */
  425. private $livraisonCp;
  426.  
  427. /**
  428. * @var string
  429. *
  430. * @JMSGroups({"listeCommandes", "detailCommande"})
  431. *
  432. * @ORMColumn(name="livraison_ville", type="string", length=255)
  433. */
  434. private $livraisonVille;
  435.  
  436. /**
  437. * @var Collection
  438. *
  439. * @ORMOneToMany(targetEntity="LigneCommande", mappedBy="commande")
  440. */
  441. protected $lignes;
  442.  
  443.  
  444. public function __construct() {
  445. $this->lignes = new ArrayCollection();
  446. }
  447.  
  448.  
  449. /**
  450. * Get id
  451. *
  452. * @return int
  453. */
  454. public function getId()
  455. {
  456. return $this->id;
  457. }
  458.  
  459. /**
  460. * Set numero
  461. *
  462. * @param string $numero
  463. *
  464. * @return Commande
  465. */
  466. public function setNumero($numero)
  467. {
  468. $this->numero = $numero;
  469.  
  470. return $this;
  471. }
  472.  
  473. /**
  474. * Get numero
  475. *
  476. * @return string
  477. */
  478. public function getNumero()
  479. {
  480. return $this->numero;
  481. }
  482.  
  483. /**
  484. * Set date
  485. *
  486. * @param DateTime $date
  487. *
  488. * @return Commande
  489. */
  490. public function setDate($date)
  491. {
  492. $this->date = $date;
  493.  
  494. return $this;
  495. }
  496.  
  497. /**
  498. * Get date
  499. *
  500. * @return DateTime
  501. */
  502. public function getDate()
  503. {
  504. return $this->date;
  505. }
  506.  
  507. /**
  508. * Set chantier
  509. *
  510. * @param int $chantier
  511. *
  512. * @return Commande
  513. */
  514. public function setChantier($chantier)
  515. {
  516. $this->chantier = $chantier;
  517.  
  518. return $this;
  519. }
  520.  
  521. /**
  522. * Get chantier
  523. *
  524. * @return int
  525. */
  526. public function getChantier()
  527. {
  528. return $this->chantier;
  529. }
  530.  
  531. /**
  532. * Set fournisseurCode
  533. *
  534. * @param string $fournisseurCode
  535. *
  536. * @return Commande
  537. */
  538. public function setFournisseurCode($fournisseurCode)
  539. {
  540. $this->fournisseurCode = $fournisseurCode;
  541.  
  542. return $this;
  543. }
  544.  
  545. /**
  546. * Get fournisseurCode
  547. *
  548. * @return string
  549. */
  550. public function getFournisseurCode()
  551. {
  552. return $this->fournisseurCode;
  553. }
  554.  
  555. /**
  556. * Set fournisseurNom
  557. *
  558. * @param string $fournisseurNom
  559. *
  560. * @return Commande
  561. */
  562. public function setFournisseurNom($fournisseurNom)
  563. {
  564. $this->fournisseurNom = $fournisseurNom;
  565.  
  566. return $this;
  567. }
  568.  
  569. /**
  570. * Get fournisseurNom
  571. *
  572. * @return string
  573. */
  574. public function getFournisseurNom()
  575. {
  576. return $this->fournisseurNom;
  577. }
  578.  
  579. /**
  580. * Set redacteurCode
  581. *
  582. * @param string $redacteurCode
  583. *
  584. * @return Commande
  585. */
  586. public function setRedacteurCode($redacteurCode)
  587. {
  588. $this->redacteurCode = $redacteurCode;
  589.  
  590. return $this;
  591. }
  592.  
  593. /**
  594. * Get redacteurCode
  595. *
  596. * @return string
  597. */
  598. public function getRedacteurCode()
  599. {
  600. return $this->redacteurCode;
  601. }
  602.  
  603. /**
  604. * Set secteurCode
  605. *
  606. * @param string $secteurCode
  607. *
  608. * @return Commande
  609. */
  610. public function setSecteurCode($secteurCode)
  611. {
  612. $this->secteurCode = $secteurCode;
  613.  
  614. return $this;
  615. }
  616.  
  617. /**
  618. * Get secteurCode
  619. *
  620. * @return string
  621. */
  622. public function getSecteurCode()
  623. {
  624. return $this->secteurCode;
  625. }
  626.  
  627. /**
  628. * Set livraisonNom
  629. *
  630. * @param string $livraisonNom
  631. *
  632. * @return Commande
  633. */
  634. public function setLivraisonNom($livraisonNom)
  635. {
  636. $this->livraisonNom = $livraisonNom;
  637.  
  638. return $this;
  639. }
  640.  
  641. /**
  642. * Get livraisonNom
  643. *
  644. * @return string
  645. */
  646. public function getLivraisonNom()
  647. {
  648. return $this->livraisonNom;
  649. }
  650.  
  651. /**
  652. * Set livraisonAdresse
  653. *
  654. * @param string $livraisonAdresse
  655. *
  656. * @return Commande
  657. */
  658. public function setLivraisonAdresse($livraisonAdresse)
  659. {
  660. $this->livraisonAdresse = $livraisonAdresse;
  661.  
  662. return $this;
  663. }
  664.  
  665. /**
  666. * Get livraisonAdresse
  667. *
  668. * @return string
  669. */
  670. public function getLivraisonAdresse()
  671. {
  672. return $this->livraisonAdresse;
  673. }
  674.  
  675. /**
  676. * Set livraisonCp
  677. *
  678. * @param string $livraisonCp
  679. *
  680. * @return Commande
  681. */
  682. public function setLivraisonCp($livraisonCp)
  683. {
  684. $this->livraisonCp = $livraisonCp;
  685.  
  686. return $this;
  687. }
  688.  
  689. /**
  690. * Get livraisonCp
  691. *
  692. * @return string
  693. */
  694. public function getLivraisonCp()
  695. {
  696. return $this->livraisonCp;
  697. }
  698.  
  699. /**
  700. * Set livraisonVille
  701. *
  702. * @param string $livraisonVille
  703. *
  704. * @return Commande
  705. */
  706. public function setLivraisonVille($livraisonVille)
  707. {
  708. $this->livraisonVille = $livraisonVille;
  709.  
  710. return $this;
  711. }
  712.  
  713. /**
  714. * Get livraisonVille
  715. *
  716. * @return string
  717. */
  718. public function getLivraisonVille()
  719. {
  720. return $this->livraisonVille;
  721. }
  722.  
  723. /**
  724. * @return Collection
  725. */
  726. public function getLignes() {
  727. return $this->lignes;
  728. }
  729. }
  730.  
  731. /**
  732. * @RestView(serializerGroups={"detailLigneCommande"})
  733. * @RestGet(
  734. * path = "/ligneCommandes/{id}",
  735. * name = "show_ligne_commande",
  736. * requirements = {"id"="d+"}
  737. * )
  738. */
  739. public function getLigneCommandeAction(Request $request)
  740. {
  741. $ligneCommande = $this->getDoctrine()
  742. ->getRepository('AppBundle:LigneCommande')
  743. ->find($request->get('id'));
  744. /* @var $ligneCommande LigneCommande */
  745.  
  746. $ligneCommande->getCommande();
  747.  
  748. if (empty($ligneCommande)) {
  749. return View::create(['message' => 'Ligne de commande introuvable'], Response::HTTP_OK);
  750. } else {
  751. return $ligneCommande;
  752. }
  753. }
  754.  
  755. {
  756. "id": 1,
  757. "commande": {
  758. "numero": "CF000001",
  759. "date": "2017-10-13T00:00:00+00:00",
  760. "chantier": 1,
  761. "fournisseur_code": "F000001",
  762. "fournisseur_nom": "Fournisseur A",
  763. "redacteur_code": "FTOMA",
  764. "secteur_code": "1",
  765. "livraison_nom": "Nom livraison",
  766. "livraison_adresse": "Adresse livraison",
  767. "livraison_cp": "74940",
  768. "livraison_ville": "Ville livraison"
  769. },
  770. "article": {},
  771. "libelle": "Lorem ipsum dolor sit amet, consectetur adipiscing elit.",
  772. "unite": "TL",
  773. "qte_commande": 10,
  774. "qte_recue": 8,
  775. "qte_arecevoir": 2,
  776. "identifiant": 1
  777. }
  778.  
  779. {
  780. "id": 1,
  781. "commande": {},
  782. "article": {},
  783. "libelle": "Lorem ipsum dolor sit amet, consectetur adipiscing elit.",
  784. "unite": "TL",
  785. "qte_commande": 10,
  786. "qte_recue": 8,
  787. "qte_arecevoir": 2,
  788. "identifiant": 1
  789. }
Add Comment
Please, Sign In to add comment