mirror of
https://github.com/Part-DB/Part-DB-server.git
synced 2025-12-21 18:39:31 +00:00
Added Doctrine Entities.
This commit is contained in:
parent
a0801afdbd
commit
160e826b51
20 changed files with 3400 additions and 1 deletions
81
src/Entity/Supplier.php
Normal file
81
src/Entity/Supplier.php
Normal file
|
|
@ -0,0 +1,81 @@
|
|||
<?php
|
||||
/**
|
||||
* Created by PhpStorm.
|
||||
* User: janhb
|
||||
* Date: 23.02.2019
|
||||
* Time: 19:40
|
||||
*/
|
||||
|
||||
namespace App\Entity;
|
||||
|
||||
use Doctrine\ORM\Mapping as ORM;
|
||||
|
||||
/**
|
||||
* Class Supplier
|
||||
* @package App\Entity
|
||||
*
|
||||
* @ORM\Entity()
|
||||
* @ORM\Table("suppliers")
|
||||
*/
|
||||
class Supplier extends Company
|
||||
{
|
||||
/**
|
||||
* @ORM\OneToMany(targetEntity="Category", mappedBy="parent")
|
||||
*/
|
||||
protected $children;
|
||||
|
||||
/**
|
||||
* @ORM\ManyToOne(targetEntity="Category", inversedBy="children")
|
||||
* @ORM\JoinColumn(name="parent_id", referencedColumnName="id")
|
||||
*/
|
||||
protected $parent;
|
||||
|
||||
/**
|
||||
* @ORM\OneToMany(targetEntity="Orderdetail", mappedBy="supplier")
|
||||
*/
|
||||
protected $orderdetails;
|
||||
|
||||
/**
|
||||
* Get all parts from this element
|
||||
*
|
||||
* @return int all parts in a one-dimensional array of Part objects
|
||||
*
|
||||
* @throws Exception if there was an error
|
||||
*/
|
||||
public function getCountOfPartsToOrder() : int
|
||||
{
|
||||
/*
|
||||
$query = 'SELECT COUNT(*) as count FROM parts '.
|
||||
'LEFT JOIN device_parts ON device_parts.id_part = parts.id '.
|
||||
'LEFT JOIN devices ON devices.id = device_parts.id_device '.
|
||||
'LEFT JOIN orderdetails ON orderdetails.id = parts.order_orderdetails_id '.
|
||||
'WHERE ((parts.instock < parts.mininstock) OR (parts.manual_order != false) '.
|
||||
'OR ((devices.order_quantity > 0) '.
|
||||
'AND ((devices.order_only_missing_parts = false) '.
|
||||
'OR (parts.instock - device_parts.quantity * devices.order_quantity < parts.mininstock)))) '.
|
||||
'AND (parts.order_orderdetails_id IS NOT NULL) '.
|
||||
'AND (orderdetails.id_supplier = ?)';
|
||||
|
||||
$query_data = $this->database->query($query, array($this->getID()));
|
||||
|
||||
|
||||
|
||||
return (int) $query_data[0]['count']; */
|
||||
|
||||
|
||||
//TODO
|
||||
throw new \Exception("Not implemented yet!");
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Returns the ID as an string, defined by the element class.
|
||||
* This should have a form like P000014, for a part with ID 14.
|
||||
* @return string The ID as a string;
|
||||
*/
|
||||
public function getIDString(): string
|
||||
{
|
||||
return 'L' . sprintf('%06d', $this->getID());
|
||||
}
|
||||
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue