mirror of
https://github.com/Part-DB/Part-DB-server.git
synced 2025-08-28 05:54:05 +02:00
Added an page for editing order informations
This commit is contained in:
parent
1776cd9a77
commit
8c6342bffe
14 changed files with 504 additions and 12 deletions
|
@ -65,9 +65,12 @@ use App\Entity\Base\DBElement;
|
|||
use App\Entity\Base\TimestampTrait;
|
||||
use App\Entity\Parts\Part;
|
||||
use App\Entity\Parts\Supplier;
|
||||
use Doctrine\Common\Collections\ArrayCollection;
|
||||
use Doctrine\Common\Collections\Collection;
|
||||
use Doctrine\ORM\Mapping as ORM;
|
||||
use Doctrine\ORM\PersistentCollection;
|
||||
use Exception;
|
||||
use Symfony\Component\Form\Extension\Core\Type\CollectionType;
|
||||
use Symfony\Component\Validator\Constraints as Assert;
|
||||
|
||||
/**
|
||||
|
@ -85,6 +88,7 @@ class Orderdetail extends DBElement
|
|||
* @var Part
|
||||
* @ORM\ManyToOne(targetEntity="App\Entity\Parts\Part", inversedBy="orderdetails")
|
||||
* @ORM\JoinColumn(name="part_id", referencedColumnName="id")
|
||||
* @Assert\NotNull()
|
||||
*/
|
||||
protected $part;
|
||||
|
||||
|
@ -96,7 +100,8 @@ class Orderdetail extends DBElement
|
|||
protected $supplier;
|
||||
|
||||
/**
|
||||
* @ORM\OneToMany(targetEntity="Pricedetail", mappedBy="orderdetail")
|
||||
* @ORM\OneToMany(targetEntity="Pricedetail", mappedBy="orderdetail", cascade={"persist", "remove"}, orphanRemoval=true)
|
||||
* @Assert\Valid()
|
||||
*/
|
||||
protected $pricedetails;
|
||||
|
||||
|
@ -119,6 +124,11 @@ class Orderdetail extends DBElement
|
|||
*/
|
||||
protected $supplier_product_url = "";
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
$this->pricedetails = new ArrayCollection();
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the ID as an string, defined by the element class.
|
||||
* This should have a form like P000014, for a part with ID 14.
|
||||
|
@ -205,11 +215,34 @@ class Orderdetail extends DBElement
|
|||
*
|
||||
* @throws Exception if there was an error
|
||||
*/
|
||||
public function getPricedetails(): PersistentCollection
|
||||
public function getPricedetails(): Collection
|
||||
{
|
||||
return $this->pricedetails;
|
||||
}
|
||||
|
||||
/**
|
||||
* Adds an pricedetail to this orderdetail
|
||||
* @param Pricedetail $pricedetail The pricedetail to add
|
||||
* @return Orderdetail
|
||||
*/
|
||||
public function addPricedetail(Pricedetail $pricedetail) : Orderdetail
|
||||
{
|
||||
$pricedetail->setOrderdetail($this);
|
||||
$this->pricedetails->add($pricedetail);
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Removes an pricedetail from this orderdetail
|
||||
* @param Pricedetail $pricedetail
|
||||
* @return Orderdetail
|
||||
*/
|
||||
public function removePricedetail(Pricedetail $pricedetail) : Orderdetail
|
||||
{
|
||||
$this->pricedetails->removeElement($pricedetail);
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the price for a specific quantity.
|
||||
* @param int $quantity this is the quantity to choose the correct pricedetails
|
||||
|
@ -264,6 +297,15 @@ class Orderdetail extends DBElement
|
|||
*
|
||||
*********************************************************************************/
|
||||
|
||||
/**
|
||||
* Sets a new part with which this orderdetail is associated
|
||||
* @param Part $part
|
||||
*/
|
||||
public function setPart(Part $part)
|
||||
{
|
||||
$this->part = $part;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the new supplier associated with this orderdetail.
|
||||
* @param Supplier $new_supplier
|
||||
|
@ -310,6 +352,11 @@ class Orderdetail extends DBElement
|
|||
*/
|
||||
public function setSupplierProductUrl(string $new_url)
|
||||
{
|
||||
//Only change the internal URL if it is not the auto generated one
|
||||
if ($new_url == $this->supplier->getAutoProductUrl($this->getSupplierPartNr())) {
|
||||
return $this;
|
||||
}
|
||||
|
||||
$this->supplier_product_url = $new_url;
|
||||
|
||||
return $this;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue