mirror of
https://github.com/alchemy-fr/Phraseanet.git
synced 2025-10-15 22:13:13 +00:00
Added forgotten files, fixed codestyle a little bit
This commit is contained in:
@@ -437,8 +437,8 @@ class Orders implements ControllerProviderInterface
|
||||
|
||||
$app['events-manager']->trigger('__ORDER_NOT_DELIVERED__', $params);
|
||||
}
|
||||
|
||||
$success = true;
|
||||
|
||||
} catch (\Exception $e) {
|
||||
|
||||
}
|
||||
|
272
lib/Doctrine/Entities/Order.php
Normal file
272
lib/Doctrine/Entities/Order.php
Normal file
@@ -0,0 +1,272 @@
|
||||
<?php
|
||||
|
||||
namespace Entities;
|
||||
|
||||
use Alchemy\Phrasea\Application;
|
||||
use Doctrine\ORM\Mapping as ORM;
|
||||
|
||||
/**
|
||||
* Order
|
||||
*/
|
||||
class Order
|
||||
{
|
||||
/**
|
||||
* @var integer
|
||||
*/
|
||||
private $id;
|
||||
|
||||
/**
|
||||
* @var integer
|
||||
*/
|
||||
private $usr_id;
|
||||
|
||||
/**
|
||||
* @var integer
|
||||
*/
|
||||
private $ssel_id;
|
||||
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
private $usage;
|
||||
|
||||
/**
|
||||
* @var \DateTime
|
||||
*/
|
||||
private $deadline;
|
||||
|
||||
/**
|
||||
* @var \DateTime
|
||||
*/
|
||||
private $created_on;
|
||||
|
||||
/**
|
||||
* @var \Doctrine\Common\Collections\Collection
|
||||
*/
|
||||
private $elements;
|
||||
|
||||
/**
|
||||
* Constructor
|
||||
*/
|
||||
public function __construct()
|
||||
{
|
||||
$this->elements = new \Doctrine\Common\Collections\ArrayCollection();
|
||||
}
|
||||
|
||||
/**
|
||||
* Get id
|
||||
*
|
||||
* @return integer
|
||||
*/
|
||||
public function getId()
|
||||
{
|
||||
return $this->id;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set usr_id
|
||||
*
|
||||
* @param integer $usrId
|
||||
* @return Order
|
||||
*/
|
||||
public function setUsrId($usrId)
|
||||
{
|
||||
$this->usr_id = $usrId;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get usr_id
|
||||
*
|
||||
* @return integer
|
||||
*/
|
||||
public function getUsrId()
|
||||
{
|
||||
return $this->usr_id;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set ssel_id
|
||||
*
|
||||
* @param integer $sselId
|
||||
* @return Order
|
||||
*/
|
||||
public function setSselId($sselId)
|
||||
{
|
||||
$this->ssel_id = $sselId;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get ssel_id
|
||||
*
|
||||
* @return integer
|
||||
*/
|
||||
public function getSselId()
|
||||
{
|
||||
return $this->ssel_id;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set deadline
|
||||
*
|
||||
* @param \DateTime $deadline
|
||||
* @return Order
|
||||
*/
|
||||
public function setDeadline($deadline)
|
||||
{
|
||||
$this->deadline = $deadline;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get deadline
|
||||
*
|
||||
* @return \DateTime
|
||||
*/
|
||||
public function getDeadline()
|
||||
{
|
||||
return $this->deadline;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set created_on
|
||||
*
|
||||
* @param \DateTime $createdOn
|
||||
* @return Order
|
||||
*/
|
||||
public function setCreatedOn($createdOn)
|
||||
{
|
||||
$this->created_on = $createdOn;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get created_on
|
||||
*
|
||||
* @return \DateTime
|
||||
*/
|
||||
public function getCreatedOn()
|
||||
{
|
||||
return $this->created_on;
|
||||
}
|
||||
|
||||
/**
|
||||
* Add elements
|
||||
*
|
||||
* @param \Entities\OrderElement $elements
|
||||
* @return Order
|
||||
*/
|
||||
public function addElement(\Entities\OrderElement $elements)
|
||||
{
|
||||
$this->elements[] = $elements;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Remove elements
|
||||
*
|
||||
* @param \Entities\OrderElement $elements
|
||||
*/
|
||||
public function removeElement(\Entities\OrderElement $elements)
|
||||
{
|
||||
$this->elements->removeElement($elements);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get elements
|
||||
*
|
||||
* @return \Doctrine\Common\Collections\Collection
|
||||
*/
|
||||
public function getElements()
|
||||
{
|
||||
return $this->elements;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the user matching to the usr_id property.
|
||||
*
|
||||
* @param Application $app
|
||||
*
|
||||
* @return User_Adapter
|
||||
*/
|
||||
public function getUser(Application $app)
|
||||
{
|
||||
if ($this->getUsrId()) {
|
||||
return \User_Adapter::getInstance($this->getUsrId(), $app);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @var integer
|
||||
*/
|
||||
private $todo;
|
||||
|
||||
|
||||
/**
|
||||
* Set todo
|
||||
*
|
||||
* @param integer $todo
|
||||
* @return Order
|
||||
*/
|
||||
public function setTodo($todo)
|
||||
{
|
||||
$this->todo = $todo;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get todo
|
||||
*
|
||||
* @return integer
|
||||
*/
|
||||
public function getTodo()
|
||||
{
|
||||
return $this->todo;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the total number of elements.
|
||||
*
|
||||
* @return integer
|
||||
*/
|
||||
public function getTotal()
|
||||
{
|
||||
return count($this->elements);
|
||||
}
|
||||
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
private $order_usage;
|
||||
|
||||
|
||||
/**
|
||||
* Set order_usage
|
||||
*
|
||||
* @param string $orderUsage
|
||||
* @return Order
|
||||
*/
|
||||
public function setOrderUsage($orderUsage)
|
||||
{
|
||||
$this->order_usage = $orderUsage;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get order_usage
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getOrderUsage()
|
||||
{
|
||||
return $this->order_usage;
|
||||
}
|
||||
}
|
264
lib/Doctrine/Entities/OrderElement.php
Normal file
264
lib/Doctrine/Entities/OrderElement.php
Normal file
@@ -0,0 +1,264 @@
|
||||
<?php
|
||||
|
||||
namespace Entities;
|
||||
|
||||
use Alchemy\Phrasea\Application;
|
||||
use Doctrine\ORM\Mapping as ORM;
|
||||
|
||||
/**
|
||||
* OrderElement
|
||||
*/
|
||||
class OrderElement
|
||||
{
|
||||
/**
|
||||
* @var integer
|
||||
*/
|
||||
private $id;
|
||||
|
||||
/**
|
||||
* @var integer
|
||||
*/
|
||||
private $order_master_id;
|
||||
|
||||
/**
|
||||
* @var boolean
|
||||
*/
|
||||
private $deny;
|
||||
|
||||
/**
|
||||
* @var \Entities\Basket
|
||||
*/
|
||||
private $basket;
|
||||
|
||||
|
||||
/**
|
||||
* Get id
|
||||
*
|
||||
* @return integer
|
||||
*/
|
||||
public function getId()
|
||||
{
|
||||
return $this->id;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set order_master_id
|
||||
*
|
||||
* @param integer $orderMasterId
|
||||
* @return OrderElement
|
||||
*/
|
||||
public function setOrderMasterId($orderMasterId)
|
||||
{
|
||||
$this->order_master_id = $orderMasterId;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get order_master_id
|
||||
*
|
||||
* @return integer
|
||||
*/
|
||||
public function getOrderMasterId()
|
||||
{
|
||||
return $this->order_master_id;
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* Returns the username matching to the order_master_id
|
||||
*
|
||||
* @param Application $app
|
||||
* @return string
|
||||
*/
|
||||
public function getOrderMasterName(Application $app)
|
||||
{
|
||||
if (isset($this->order_master_id) && null !== $this->order_master_id) {
|
||||
$user = \User_Adapter::getInstance($this->order_master_id, $app);
|
||||
|
||||
return $user->get_firstname();
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set deny
|
||||
*
|
||||
* @param boolean $deny
|
||||
* @return OrderElement
|
||||
*/
|
||||
public function setDeny($deny)
|
||||
{
|
||||
$this->deny = $deny;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get deny
|
||||
*
|
||||
* @return boolean
|
||||
*/
|
||||
public function getDeny()
|
||||
{
|
||||
return $this->deny;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set basket
|
||||
*
|
||||
* @param \Entities\Basket $basket
|
||||
* @return OrderElement
|
||||
*/
|
||||
public function setBasket(\Entities\Basket $basket = null)
|
||||
{
|
||||
$this->basket = $basket;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get basket
|
||||
*
|
||||
* @return \Entities\Basket
|
||||
*/
|
||||
public function getBasket()
|
||||
{
|
||||
return $this->basket;
|
||||
}
|
||||
/**
|
||||
* @var integer
|
||||
*/
|
||||
private $order_id;
|
||||
|
||||
/**
|
||||
* @var integer
|
||||
*/
|
||||
private $base_id;
|
||||
|
||||
/**
|
||||
* @var integer
|
||||
*/
|
||||
private $record_id;
|
||||
|
||||
|
||||
/**
|
||||
* Set order_id
|
||||
*
|
||||
* @param integer $orderId
|
||||
* @return OrderElement
|
||||
*/
|
||||
public function setOrderId($orderId)
|
||||
{
|
||||
$this->order_id = $orderId;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get order_id
|
||||
*
|
||||
* @return integer
|
||||
*/
|
||||
public function getOrderId()
|
||||
{
|
||||
return $this->order_id;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set base_id
|
||||
*
|
||||
* @param integer $baseId
|
||||
* @return OrderElement
|
||||
*/
|
||||
public function setBaseId($baseId)
|
||||
{
|
||||
$this->base_id = $baseId;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get base_id
|
||||
*
|
||||
* @return integer
|
||||
*/
|
||||
public function getBaseId()
|
||||
{
|
||||
return $this->base_id;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set record_id
|
||||
*
|
||||
* @param integer $recordId
|
||||
* @return OrderElement
|
||||
*/
|
||||
public function setRecordId($recordId)
|
||||
{
|
||||
$this->record_id = $recordId;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get record_id
|
||||
*
|
||||
* @return integer
|
||||
*/
|
||||
public function getRecordId()
|
||||
{
|
||||
return $this->record_id;
|
||||
}
|
||||
/**
|
||||
* @var \Entities\Order
|
||||
*/
|
||||
private $order;
|
||||
|
||||
|
||||
/**
|
||||
* Set order
|
||||
*
|
||||
* @param \Entities\Order $order
|
||||
* @return OrderElement
|
||||
*/
|
||||
public function setOrder(\Entities\Order $order = null)
|
||||
{
|
||||
$this->order = $order;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get order
|
||||
*
|
||||
* @return \Entities\Order
|
||||
*/
|
||||
public function getOrder()
|
||||
{
|
||||
return $this->order;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a record from the element's base_id and record_id
|
||||
*
|
||||
* @param Application $app
|
||||
* @return \record_adapter
|
||||
*/
|
||||
public function getRecord(Application $app)
|
||||
{
|
||||
return new \record_adapter($app, $this->getSbasId($app), $this->getRecordId());
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the matching sbasId
|
||||
*
|
||||
* @param Application $app
|
||||
* @return int
|
||||
*/
|
||||
public function getSbasId(Application $app)
|
||||
{
|
||||
return \phrasea::sbasFromBas($app, $this->getBaseId());
|
||||
}
|
||||
}
|
15
lib/Doctrine/Repositories/OrderElementRepository.php
Normal file
15
lib/Doctrine/Repositories/OrderElementRepository.php
Normal file
@@ -0,0 +1,15 @@
|
||||
<?php
|
||||
|
||||
namespace Repositories;
|
||||
|
||||
use Doctrine\ORM\EntityRepository;
|
||||
|
||||
/**
|
||||
* OrderElementRepository
|
||||
*
|
||||
* This class was generated by the Doctrine ORM. Add your own custom
|
||||
* repository methods below.
|
||||
*/
|
||||
class OrderElementRepository extends EntityRepository
|
||||
{
|
||||
}
|
73
lib/Doctrine/Repositories/OrderRepository.php
Normal file
73
lib/Doctrine/Repositories/OrderRepository.php
Normal file
@@ -0,0 +1,73 @@
|
||||
<?php
|
||||
|
||||
namespace Repositories;
|
||||
|
||||
use Doctrine\ORM\EntityRepository;
|
||||
|
||||
/**
|
||||
* OrderRepository
|
||||
*
|
||||
* This class was generated by the Doctrine ORM. Add your own custom
|
||||
* repository methods below.
|
||||
*/
|
||||
class OrderRepository extends EntityRepository
|
||||
{
|
||||
/**
|
||||
* Returns an array of all the orders, starting at $offsetStart, limited to $perPage
|
||||
*
|
||||
* @param array $baseIds
|
||||
* @param integer $offsetStart
|
||||
* @param integer $perPage
|
||||
* @param string $sort
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function listOrders($baseIds, $offsetStart, $perPage, $sort)
|
||||
{
|
||||
$dql = 'SELECT o
|
||||
FROM Entities\OrderElement e, Entities\Order o
|
||||
WHERE e.base_id IN (' . implode(', ', $baseIds) . ')
|
||||
AND e.order = o
|
||||
GROUP BY o.id';
|
||||
|
||||
if ($sort == 'created_on') {
|
||||
$dql .= ' ORDER BY o.created_on DESC';
|
||||
} elseif ($sort == 'user') {
|
||||
$dql .= ' ORDER BY o.user_id ASC';
|
||||
}
|
||||
elseif ($sort == 'o.order_usage') {
|
||||
$dql .= ' ORDER BY o.usage ASC';
|
||||
}
|
||||
|
||||
$query = $this->_em->createQuery($dql);
|
||||
if (null !== $offsetStart && 0 !== $offsetStart) {
|
||||
$query->setFirstResult($offsetStart);
|
||||
}
|
||||
if (null !== $perPage) {
|
||||
$query->setMaxResults($perPage);
|
||||
}
|
||||
|
||||
return $query->getResult();
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the total number of orders from an array of base_id
|
||||
*
|
||||
* @param array $baseIds
|
||||
*
|
||||
* @return integer
|
||||
*/
|
||||
|
||||
public function countTotalOrders(array $baseIds = array())
|
||||
{
|
||||
$dql = 'SELECT distinct o.id
|
||||
FROM Entities\OrderElement e, Entities\Order o
|
||||
WHERE ' . (count($baseIds > 0 ) ? 'e.base_id IN (' . implode(', ', $baseIds) . ') AND ': '' ).
|
||||
'e.order = o
|
||||
GROUP BY o.id';
|
||||
|
||||
$query = $this->_em->createQuery($dql);
|
||||
|
||||
return count($query->getResult());
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user