<?php
/**
* Created by PhpStorm.
* User: sbrun
* Date: 2018-03-28
* Time: 4:25 PM
*/
namespace App\Entity\Logs;
use App\Entity\Company;
use Doctrine\ORM\Mapping as ORM;
use FOS\UserBundle\Model\User;
use App\Entity\Fournisseurs;
/**
* This entity log is for import invoice and create reception for order provider
* @ORM\Entity
* @ORM\Table(name="log_import_factures_fournisseurs")
*/
class LogReceptionImport
{
const RESULT_OK = 1;
const RESULT_FOURN_UNKNOWN = 2;
const RESULT_TYPE_CREDIT = 3;
const RESULT_ALREADY_IMPORT = 4;
/**
* @ORM\Column(type="integer")
* @ORM\Id
* @ORM\GeneratedValue(strategy="AUTO")
*/
protected $id;
/**
* @ORM\Column(name="facture", type="string", nullable=false)
*/
protected $facture;
/**
* Many logs has one fournisseur
*
* @ORM\ManyToOne(targetEntity="App\Entity\Fournisseurs", cascade={"persist"})
* @ORM\JoinColumn(name="fournisseur", referencedColumnName="id", nullable=true)
*/
protected $fournisseur;
/**
* Many SysUser has one Company
*
* @ORM\ManyToOne(targetEntity="App\Entity\Company", inversedBy="sysUsers")
* @ORM\JoinColumn(name="company", referencedColumnName="id", nullable=false)
*/
protected $company;
/**
* @ORM\Column(name="date_import", type="datetime", nullable=false)
*/
protected $dateImport;
/**
* @ORM\ManyToOne(targetEntity="App\Entity\SysUsers")
* @ORM\JoinColumn(name="user", referencedColumnName="id", nullable=false)
*/
protected $user;
/**
* @ORM\Column(name="result", type="integer", length=50, nullable=false)
*/
protected $result;
public function __construct(User $user, Fournisseurs $fournisseurs, Company $company, $facture, int $result)
{
$this->dateImport = new \DateTime();
$this->user = $user;
$this->fournisseur = $fournisseurs;
$this->company = $company;
$this->facture = $facture;
$this->result = $result;
}
/**
* @return int
*/
public function getId()
{
return $this->id;
}
/**
* @param int $id
*/
public function setId($id)
{
$this->id = $id;
}
/**
* @return string
*/
public function getFacture()
{
return $this->facture;
}
/**
* @param string $facture
*/
public function setFacture($facture)
{
$this->facture = $facture;
}
/**
* @return Fournisseurs
*/
public function getFournisseur()
{
return $this->fournisseur;
}
/**
* @param Fournisseurs $fournisseur
*/
public function setFournisseur($fournisseur)
{
$this->fournisseur = $fournisseur;
}
/**
* @return mixed
*/
public function getCompany()
{
return $this->company;
}
/**
* @param mixed $company
*/
public function setCompany($company)
{
$this->company = $company;
}
/**
* @return \Datetime
*/
public function getDateImport()
{
return $this->dateImport;
}
/**
* @param \DateTime $dateImport
*/
public function setDateImport($dateImport)
{
$this->dateImport = $dateImport;
}
/**
* @return User
*/
public function getUser()
{
return $this->user;
}
/**
* @param User $user
*/
public function setUser($user)
{
$this->user = $user;
}
/**
* @return int
*/
public function getResult()
{
return $this->result;
}
/**
* @param int $result
*/
public function setResult($result)
{
$this->result = $result;
}
public function getResultText()
{
switch ($this->getResult()) {
case $this::RESULT_OK :
return 'Importée';
case $this::RESULT_FOURN_UNKNOWN :
return 'Fournisseur inconnu';
case $this::RESULT_TYPE_CREDIT :
return 'Facture en crédit';
case $this::RESULT_ALREADY_IMPORT :
return 'Facture déjà importée';
//If result is empty, facture is not imported and just in "atraiter" folder
default :
return "Prête à l'importation";
}
}
}