src/Entity/Logs/LogReceptionImport.php line 21

Open in your IDE?
  1. <?php
  2. /**
  3.  * Created by PhpStorm.
  4.  * User: sbrun
  5.  * Date: 2018-03-28
  6.  * Time: 4:25 PM
  7.  */
  8. namespace App\Entity\Logs;
  9. use App\Entity\Company;
  10. use Doctrine\ORM\Mapping as ORM;
  11. use FOS\UserBundle\Model\User;
  12. use App\Entity\Fournisseurs;
  13. /**
  14.  * This entity log is for import invoice and create reception for order provider
  15.  * @ORM\Entity
  16.  * @ORM\Table(name="log_import_factures_fournisseurs")
  17.  */
  18. class LogReceptionImport
  19. {
  20.     const RESULT_OK 1;
  21.     const RESULT_FOURN_UNKNOWN 2;
  22.     const RESULT_TYPE_CREDIT 3;
  23.     const RESULT_ALREADY_IMPORT 4;
  24.     /**
  25.      * @ORM\Column(type="integer")
  26.      * @ORM\Id
  27.      * @ORM\GeneratedValue(strategy="AUTO")
  28.      */
  29.     protected $id;
  30.     /**
  31.      * @ORM\Column(name="facture", type="string", nullable=false)
  32.      */
  33.     protected $facture;
  34.     /**
  35.      * Many logs has one fournisseur
  36.      *
  37.      * @ORM\ManyToOne(targetEntity="App\Entity\Fournisseurs", cascade={"persist"})
  38.      * @ORM\JoinColumn(name="fournisseur", referencedColumnName="id", nullable=true)
  39.      */
  40.     protected $fournisseur;
  41.     /**
  42.      * Many SysUser has one Company
  43.      *
  44.      * @ORM\ManyToOne(targetEntity="App\Entity\Company", inversedBy="sysUsers")
  45.      * @ORM\JoinColumn(name="company", referencedColumnName="id", nullable=false)
  46.      */
  47.     protected $company;
  48.     /**
  49.      * @ORM\Column(name="date_import", type="datetime", nullable=false)
  50.      */
  51.     protected $dateImport;
  52.     /**
  53.      * @ORM\ManyToOne(targetEntity="App\Entity\SysUsers")
  54.      * @ORM\JoinColumn(name="user", referencedColumnName="id", nullable=false)
  55.      */
  56.     protected $user;
  57.     /**
  58.      * @ORM\Column(name="result", type="integer", length=50, nullable=false)
  59.      */
  60.     protected $result;
  61.     public function __construct(User $userFournisseurs $fournisseursCompany $company$factureint $result)
  62.     {
  63.         $this->dateImport = new \DateTime();
  64.         $this->user $user;
  65.         $this->fournisseur $fournisseurs;
  66.         $this->company $company;
  67.         $this->facture $facture;
  68.         $this->result $result;
  69.     }
  70.     /**
  71.      * @return int
  72.      */
  73.     public function getId()
  74.     {
  75.         return $this->id;
  76.     }
  77.     /**
  78.      * @param int $id
  79.      */
  80.     public function setId($id)
  81.     {
  82.         $this->id $id;
  83.     }
  84.     /**
  85.      * @return string
  86.      */
  87.     public function getFacture()
  88.     {
  89.         return $this->facture;
  90.     }
  91.     /**
  92.      * @param string $facture
  93.      */
  94.     public function setFacture($facture)
  95.     {
  96.         $this->facture $facture;
  97.     }
  98.     /**
  99.      * @return Fournisseurs
  100.      */
  101.     public function getFournisseur()
  102.     {
  103.         return $this->fournisseur;
  104.     }
  105.     /**
  106.      * @param Fournisseurs $fournisseur
  107.      */
  108.     public function setFournisseur($fournisseur)
  109.     {
  110.         $this->fournisseur $fournisseur;
  111.     }
  112.     /**
  113.      * @return mixed
  114.      */
  115.     public function getCompany()
  116.     {
  117.         return $this->company;
  118.     }
  119.     /**
  120.      * @param mixed $company
  121.      */
  122.     public function setCompany($company)
  123.     {
  124.         $this->company $company;
  125.     }
  126.     /**
  127.      * @return \Datetime
  128.      */
  129.     public function getDateImport()
  130.     {
  131.         return $this->dateImport;
  132.     }
  133.     /**
  134.      * @param \DateTime $dateImport
  135.      */
  136.     public function setDateImport($dateImport)
  137.     {
  138.         $this->dateImport $dateImport;
  139.     }
  140.     /**
  141.      * @return User
  142.      */
  143.     public function getUser()
  144.     {
  145.         return $this->user;
  146.     }
  147.     /**
  148.      * @param User $user
  149.      */
  150.     public function setUser($user)
  151.     {
  152.         $this->user $user;
  153.     }
  154.     /**
  155.      * @return int
  156.      */
  157.     public function getResult()
  158.     {
  159.         return $this->result;
  160.     }
  161.     /**
  162.      * @param int $result
  163.      */
  164.     public function setResult($result)
  165.     {
  166.         $this->result $result;
  167.     }
  168.     public function getResultText()
  169.     {
  170.         switch ($this->getResult()) {
  171.             case $this::RESULT_OK :
  172.                 return 'Importée';
  173.             case $this::RESULT_FOURN_UNKNOWN :
  174.                 return 'Fournisseur inconnu';
  175.             case $this::RESULT_TYPE_CREDIT :
  176.                 return 'Facture en crédit';
  177.             case $this::RESULT_ALREADY_IMPORT :
  178.                 return 'Facture déjà importée';
  179.             //If result is empty, facture is not imported and just in "atraiter" folder
  180.             default :
  181.                 return "Prête à l'importation";
  182.         }
  183.     }
  184. }