diff --git a/lib/Alchemy/Phrasea/Controller/Prod/Orders.php b/lib/Alchemy/Phrasea/Controller/Prod/Orders.php index 54a28a8e35..9a200ada82 100644 --- a/lib/Alchemy/Phrasea/Controller/Prod/Orders.php +++ b/lib/Alchemy/Phrasea/Controller/Prod/Orders.php @@ -437,8 +437,8 @@ class Orders implements ControllerProviderInterface $app['events-manager']->trigger('__ORDER_NOT_DELIVERED__', $params); } - $success = true; + } catch (\Exception $e) { } diff --git a/lib/Doctrine/Entities/Order.php b/lib/Doctrine/Entities/Order.php new file mode 100644 index 0000000000..2fbba9436e --- /dev/null +++ b/lib/Doctrine/Entities/Order.php @@ -0,0 +1,272 @@ +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; + } +} \ No newline at end of file diff --git a/lib/Doctrine/Entities/OrderElement.php b/lib/Doctrine/Entities/OrderElement.php new file mode 100644 index 0000000000..d654a6118e --- /dev/null +++ b/lib/Doctrine/Entities/OrderElement.php @@ -0,0 +1,264 @@ +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()); + } +} \ No newline at end of file diff --git a/lib/Doctrine/Repositories/OrderElementRepository.php b/lib/Doctrine/Repositories/OrderElementRepository.php new file mode 100644 index 0000000000..26b72d24c5 --- /dev/null +++ b/lib/Doctrine/Repositories/OrderElementRepository.php @@ -0,0 +1,15 @@ +_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()); + } +}