mirror of
https://github.com/Sylius/Sylius.git
synced 2026-07-05 20:57:12 +00:00
initial commit.
This commit is contained in:
commit
5e81411e1b
50 changed files with 2926 additions and 0 deletions
|
|
@ -0,0 +1,170 @@
|
|||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of the Sylius package.
|
||||
*
|
||||
* (c) Paweł Jędrzejewski
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace Sylius\Bundle\SalesBundle\Controller\Backend;
|
||||
|
||||
use Symfony\Component\HttpFoundation\RedirectResponse;
|
||||
use Symfony\Component\DependencyInjection\ContainerAware;
|
||||
use Sylius\Bundle\SalesBundle\EventDispatcher\SyliusSalesEvents;
|
||||
use Sylius\Bundle\SalesBundle\EventDispatcher\Event\FilterOrderEvent;
|
||||
|
||||
/**
|
||||
* Backend orders controller.
|
||||
*
|
||||
* @author Paweł Jędrzejewski <pjedrzejewski@diweb.pl>
|
||||
*/
|
||||
class OrderController extends ContainerAware
|
||||
{
|
||||
/**
|
||||
* Displays all orders.
|
||||
*/
|
||||
public function listAction()
|
||||
{
|
||||
$orderManager = $this->container->get('sylius_sales.manager.order');
|
||||
$paginator = $orderManager->createPaginator();
|
||||
|
||||
$paginator->setCurrentPage($this->container->get('request')->query->get('page', 1));
|
||||
|
||||
$orders = $paginator->getCurrentPageResults();
|
||||
|
||||
return $this->container->get('templating')->renderResponse('SyliusSalesBundle:Backend/Order:list.html.' . $this->getEngine(), array(
|
||||
'orders' => $orders,
|
||||
'paginator' => $paginator
|
||||
));
|
||||
}
|
||||
|
||||
/**
|
||||
* Shows an order.
|
||||
*/
|
||||
public function showAction($id)
|
||||
{
|
||||
$order = $this->container->get('sylius_sales.manager.order')->findOrder($id);
|
||||
|
||||
if (!$order) {
|
||||
throw new NotFoundHttpException('Requested order does not exist.');
|
||||
}
|
||||
|
||||
return $this->container->get('templating')->renderResponse('SyliusSalesBundle:Backend/Order:show.html.' . $this->getEngine(), array(
|
||||
'order' => $order
|
||||
));
|
||||
}
|
||||
|
||||
/**
|
||||
* Order status management.
|
||||
*/
|
||||
public function statusAction($id)
|
||||
{
|
||||
$order = $this->container->get('sylius_sales.manager.order')->findOrder($id);
|
||||
|
||||
if (!$order) {
|
||||
throw new NotFoundHttpException('Requested order does not exist.');
|
||||
}
|
||||
|
||||
$request = $this->container->get('request');
|
||||
|
||||
$form = $this->container->get('form.factory')->create($this->container->get('sylius_sales.form.type.status'));
|
||||
$form->setData($order);
|
||||
|
||||
if ('POST' == $request->getMethod()) {
|
||||
$form->bindRequest($request);
|
||||
|
||||
if ($form->isValid()) {
|
||||
$this->container->get('event_dispatcher')->dispatch(SyliusSalesEvents::ORDER_STATUS, new FilterOrderEvent($order));
|
||||
$this->container->get('sylius_sales.manipulator.order')->status($order);
|
||||
|
||||
return new RedirectResponse($request->headers->get('referer'));
|
||||
}
|
||||
}
|
||||
|
||||
return $this->container->get('templating')->renderResponse('SyliusSalesBundle:Backend/Order:status.html.' . $this->getEngine(), array(
|
||||
'form' => $form->createView(),
|
||||
'order' => $order
|
||||
));
|
||||
}
|
||||
|
||||
/**
|
||||
* Confirms order.
|
||||
*/
|
||||
public function confirmAction($id)
|
||||
{
|
||||
$order = $this->container->get('sylius_sales.manager.order')->findOrder($id);
|
||||
|
||||
if (!$order) {
|
||||
throw new NotFoundHttpException('Requested order does not exist.');
|
||||
}
|
||||
|
||||
$this->container->get('event_dispatcher')->dispatch(SyliusSalesEvents::ORDER_CONFIRM, new FilterOrderEvent($order));
|
||||
$this->container->get('sylius_sales.manipulator.order')->confirm($order);
|
||||
|
||||
return new RedirectResponse($this->container->get('router')->generate('sylius_sales_backend_order_list'));
|
||||
}
|
||||
|
||||
/**
|
||||
* Closes order.
|
||||
*/
|
||||
public function closeAction($id)
|
||||
{
|
||||
$order = $this->container->get('sylius_sales.manager.order')->findOrder($id);
|
||||
|
||||
if (!$order) {
|
||||
throw new NotFoundHttpException('Requested order does not exist.');
|
||||
}
|
||||
|
||||
$this->container->get('event_dispatcher')->dispatch(SyliusSalesEvents::ORDER_CLOSE, new FilterOrderEvent($order));
|
||||
$this->container->get('sylius_sales.manipulator.order')->close($order);
|
||||
|
||||
return new RedirectResponse($this->container->get('router')->generate('sylius_sales_backend_order_list'));
|
||||
}
|
||||
|
||||
/**
|
||||
* Opens order.
|
||||
*/
|
||||
public function openAction($id)
|
||||
{
|
||||
$order = $this->container->get('sylius_sales.manager.order')->findOrder($id);
|
||||
|
||||
if (!$order) {
|
||||
throw new NotFoundHttpException('Requested order does not exist.');
|
||||
}
|
||||
|
||||
$this->container->get('event_dispatcher')->dispatch(SyliusSalesEvents::ORDER_OPEN, new FilterOrderEvent($order));
|
||||
$this->container->get('sylius_sales.manipulator.order')->open($order);
|
||||
|
||||
return new RedirectResponse($this->container->get('router')->generate('sylius_sales_backend_order_list'));
|
||||
}
|
||||
|
||||
/**
|
||||
* Deletes order.
|
||||
*/
|
||||
public function deleteAction($id)
|
||||
{
|
||||
$order = $this->container->get('sylius_sales.manager.order')->findOrder($id);
|
||||
|
||||
if (!$order) {
|
||||
throw new NotFoundHttpException('Requested order does not exist.');
|
||||
}
|
||||
|
||||
$this->container->get('event_dispatcher')->dispatch(SyliusSalesEvents::ORDER_DELETE, new FilterOrderEvent($order));
|
||||
$this->container->get('sylius_sales.manipulator.order')->delete($order);
|
||||
|
||||
return new RedirectResponse($this->container->get('router')->generate('sylius_sales_backend_order_list'));
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns templating engine name.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
protected function getEngine()
|
||||
{
|
||||
return $this->container->getParameter('sylius_sales.engine');
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,54 @@
|
|||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of the Sylius package.
|
||||
*
|
||||
* (c) Paweł Jędrzejewski
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace Sylius\Bundle\SalesBundle\Controller\Frontend;
|
||||
|
||||
use Symfony\Component\HttpFoundation\RedirectResponse;
|
||||
use Symfony\Component\DependencyInjection\ContainerAware;
|
||||
use Sylius\Bundle\SalesBundle\EventDispatcher\SyliusSalesEvents;
|
||||
use Sylius\Bundle\SalesBundle\EventDispatcher\Event\FilterOrderEvent;
|
||||
|
||||
/**
|
||||
* Frontend order controller.
|
||||
*
|
||||
* @author Paweł Jędrzejewski <pjedrzejewski@diweb.pl>
|
||||
*/
|
||||
class OrderController extends ContainerAware
|
||||
{
|
||||
/**
|
||||
* Confirms order.
|
||||
*/
|
||||
public function confirmAction($token)
|
||||
{
|
||||
$order = $this->container->get('sylius_sales.manager.order')->findOrderBy(array('confirmationToken' => $token));
|
||||
|
||||
if (!$order) {
|
||||
throw new NotFoundHttpException('Requested order does not exist.');
|
||||
}
|
||||
|
||||
$this->container->get('event_dispatcher')->dispatch(SyliusSalesEvents::ORDER_CONFIRM, new FilterOrderEvent($order));
|
||||
$this->container->get('sylius_sales.manipulator.order')->confirm($order);
|
||||
|
||||
return $this->container->get('templating')->renderResponse('SyliusSalesBundle:Frontend/Order:confirmed.html.' . $this->getEngine(), array(
|
||||
'order' => $order
|
||||
));
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns templating engine name.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
protected function getEngine()
|
||||
{
|
||||
return $this->container->getParameter('sylius_sales.engine');
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,36 @@
|
|||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of the Sylius package.
|
||||
*
|
||||
* (c) Paweł Jędrzejewski
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace Sylius\Bundle\SalesBundle\DependencyInjection\Compiler;
|
||||
|
||||
use Symfony\Component\DependencyInjection\Reference;
|
||||
use Symfony\Component\DependencyInjection\ContainerBuilder;
|
||||
use Symfony\Component\DependencyInjection\Compiler\CompilerPassInterface;
|
||||
|
||||
/**
|
||||
* Compiler pass that registers all processor operations.
|
||||
*
|
||||
* @author Paweł Jędrzejewski <pjedrzejewski@diweb.pl>
|
||||
*/
|
||||
class RegisterOperationsPass implements CompilerPassInterface
|
||||
{
|
||||
public function process(ContainerBuilder $container)
|
||||
{
|
||||
if (!$container->hasDefinition('sylius_sales.processor')) {
|
||||
return;
|
||||
}
|
||||
|
||||
$processor = $container->getDefinition('sylius_sales.processor');
|
||||
foreach ($container->findTaggedServiceIds('sylius_sales.operation') as $id => $attributes) {
|
||||
$processor->addMethodCall('registerOperation', array(new Reference($id)));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,147 @@
|
|||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of the Sylius package.
|
||||
*
|
||||
* (c) Paweł Jędrzejewski
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace Sylius\Bundle\SalesBundle\DependencyInjection;
|
||||
|
||||
use Symfony\Component\Config\Definition\ConfigurationInterface;
|
||||
use Symfony\Component\Config\Definition\Builder\TreeBuilder;
|
||||
use Symfony\Component\Config\Definition\Builder\ArrayNodeDefinition;
|
||||
|
||||
/**
|
||||
* This class contains the configuration information for the bundle.
|
||||
*
|
||||
* This information is solely responsible for how the different configuration
|
||||
* sections are normalized, and merged.
|
||||
*
|
||||
* @author Paweł Jędrzejewski <pjedrzejewski@diweb.pl>
|
||||
*/
|
||||
class Configuration implements ConfigurationInterface
|
||||
{
|
||||
/**
|
||||
* Generates the configuration tree.
|
||||
*
|
||||
* @return \Symfony\Bundle\DependencyInjection\Configuration\NodeInterface
|
||||
*/
|
||||
public function getConfigTreeBuilder()
|
||||
{
|
||||
$treeBuilder = new TreeBuilder();
|
||||
$rootNode = $treeBuilder->root('sylius_sales');
|
||||
|
||||
$rootNode
|
||||
->addDefaultsIfNotSet()
|
||||
->children()
|
||||
->scalarNode('driver')->cannotBeOverwritten()->isRequired()->cannotBeEmpty()->end()
|
||||
->scalarNode('engine')->defaultValue('twig')->end()
|
||||
->arrayNode('statuses')
|
||||
->requiresAtLeastOneElement()
|
||||
->prototype('scalar')
|
||||
->end()
|
||||
->end();
|
||||
|
||||
$this->addClassesSection($rootNode);
|
||||
|
||||
return $treeBuilder;
|
||||
}
|
||||
|
||||
/**
|
||||
* Adds `classes` section.
|
||||
*
|
||||
* @param ArrayNodeDefinition $node
|
||||
*/
|
||||
private function addClassesSection(ArrayNodeDefinition $node)
|
||||
{
|
||||
$node
|
||||
->children()
|
||||
->arrayNode('classes')
|
||||
->isRequired()
|
||||
->addDefaultsIfNotSet()
|
||||
->children()
|
||||
->arrayNode('model')
|
||||
->addDefaultsIfNotSet()
|
||||
->isRequired()
|
||||
->children()
|
||||
->scalarNode('order')->isRequired()->cannotBeEmpty()->end()
|
||||
->scalarNode('item')->defaultValue('')->end()
|
||||
->end()
|
||||
->end()
|
||||
->arrayNode('controller')
|
||||
->addDefaultsIfNotSet()
|
||||
->children()
|
||||
->arrayNode('frontend')
|
||||
->addDefaultsIfNotSet()
|
||||
->children()
|
||||
->scalarNode('order')->defaultValue('Sylius\\Bundle\\SalesBundle\\Controller\\Frontend\\OrderController')->end()
|
||||
->end()
|
||||
->end()
|
||||
->arrayNode('backend')
|
||||
->addDefaultsIfNotSet()
|
||||
->children()
|
||||
->scalarNode('order')->defaultValue('Sylius\\Bundle\\SalesBundle\\Controller\\Backend\\OrderController')->end()
|
||||
->end()
|
||||
->end()
|
||||
->end()
|
||||
->end()
|
||||
->arrayNode('form')
|
||||
->addDefaultsIfNotSet()
|
||||
->children()
|
||||
->arrayNode('type')
|
||||
->addDefaultsIfNotSet()
|
||||
->children()
|
||||
->scalarNode('order')->defaultValue('Sylius\\Bundle\\SalesBundle\\Form\\Type\\OrderFormType')->end()
|
||||
->scalarNode('item')->defaultValue('Sylius\\Bundle\\SalesBundle\\Form\\Type\\ItemType')->end()
|
||||
->end()
|
||||
->end()
|
||||
->end()
|
||||
->end()
|
||||
->arrayNode('manipulator')
|
||||
->addDefaultsIfNotSet()
|
||||
->children()
|
||||
->scalarNode('order')->defaultValue('Sylius\\Bundle\\SalesBundle\\Manipulator\\OrderManipulator')->end()
|
||||
->end()
|
||||
->end()
|
||||
->end()
|
||||
->end()
|
||||
->end();
|
||||
}
|
||||
|
||||
/**
|
||||
* Adds `extensions` section.
|
||||
*
|
||||
* @param ArrayNodeDefinition $node
|
||||
*/
|
||||
private function addExtensionsSection(ArrayNodeDefinition $node)
|
||||
{
|
||||
$node
|
||||
->children()
|
||||
->arrayNode('extensions')
|
||||
->children()
|
||||
->arrayNode('confirmation')
|
||||
->children()
|
||||
->booleanNode('enabled')->end()
|
||||
->arrayNode('options')
|
||||
->addDefaultsIfNotSet()
|
||||
->children()
|
||||
->arrayNode('email')
|
||||
->children()
|
||||
->scalarNode('from')->defaultValue('no-reply@example.com')->end()
|
||||
->scalarNode('subject')->defaultValue('Confirm your order on example.com.')->end()
|
||||
->scalarNode('template')->defaultValue('SyliusSalesBundle:Frontend/Confirmation:email.html.twig')->end()
|
||||
->end()
|
||||
->end()
|
||||
->end()
|
||||
->end()
|
||||
->end()
|
||||
->end()
|
||||
->end()
|
||||
->end()
|
||||
->end();
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,133 @@
|
|||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of the Sylius package.
|
||||
*
|
||||
* (c) Paweł Jędrzejewski
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace Sylius\Bundle\SalesBundle\DependencyInjection;
|
||||
|
||||
use Symfony\Component\HttpKernel\DependencyInjection\Extension;
|
||||
use Symfony\Component\DependencyInjection\ContainerBuilder;
|
||||
use Symfony\Component\DependencyInjection\Loader\XmlFileLoader;
|
||||
use Symfony\Component\Config\FileLocator;
|
||||
use Symfony\Component\Config\Definition\Processor;
|
||||
|
||||
/**
|
||||
* Sales extension.
|
||||
*
|
||||
* @author Paweł Jędrzejewski <pjedrzejewski@diweb.pl>
|
||||
*/
|
||||
class SyliusSalesExtension extends Extension
|
||||
{
|
||||
/**
|
||||
* @see Extension/Symfony\Component\DependencyInjection\Extension.ExtensionInterface::load()
|
||||
*/
|
||||
public function load(array $config, ContainerBuilder $container)
|
||||
{
|
||||
$processor = new Processor();
|
||||
$configuration = new Configuration();
|
||||
|
||||
$config = $processor->processConfiguration($configuration, $config);
|
||||
|
||||
$loader = new XmlFileLoader($container, new FileLocator(__DIR__.'/../Resources/config/container'));
|
||||
|
||||
if (!in_array($config['driver'], array('ORM'))) {
|
||||
throw new \InvalidArgumentException(sprintf('Driver "%s" is unsupported for this extension.', $config['driver']));
|
||||
}
|
||||
|
||||
if (!in_array($config['engine'], array('php', 'twig'))) {
|
||||
throw new \InvalidArgumentException(sprintf('Engine "%s" is unsupported for this extension.', $config['engine']));
|
||||
}
|
||||
|
||||
$loader->load(sprintf('driver/%s.xml', $config['driver']));
|
||||
$loader->load(sprintf('engine/%s.xml', $config['engine']));
|
||||
|
||||
$container->setParameter('sylius_sales.driver', $config['driver']);
|
||||
$container->setParameter('sylius_sales.engine', $config['engine']);
|
||||
|
||||
$container->setParameter('sylius_sales.statuses', $config['statuses']);
|
||||
|
||||
$configurations = array(
|
||||
'controllers',
|
||||
'processor',
|
||||
'manipulators',
|
||||
'forms',
|
||||
);
|
||||
|
||||
if (!empty($config['extensions'])) {
|
||||
if (!empty($config['extensions']['confirmation']) && $config['extensions']['confirmation']['enabled']) {
|
||||
$container->setParameter('sylius_sales.extension.confirmation.options', $config['extensions']['confirmation']['options']);
|
||||
$configurations[] = 'extension/confirmation';
|
||||
}
|
||||
}
|
||||
|
||||
foreach($configurations as $basename) {
|
||||
$loader->load(sprintf('%s.xml', $basename));
|
||||
}
|
||||
|
||||
$this->remapParametersNamespaces($config['classes'], $container, array(
|
||||
'model' => 'sylius_sales.model.%s.class',
|
||||
'manipulator' => 'sylius_sales.manipulator.%s.class',
|
||||
));
|
||||
|
||||
$this->remapParametersNamespaces($config['classes']['controller'], $container, array(
|
||||
'backend' => 'sylius_sales.controller.backend.%s.class',
|
||||
'frontend' => 'sylius_sales.controller.frontend.%s.class'
|
||||
));
|
||||
|
||||
$this->remapParametersNamespaces($config['classes']['form'], $container, array(
|
||||
'type' => 'sylius_sales.form.type.%s.class',
|
||||
));
|
||||
}
|
||||
|
||||
/**
|
||||
* Remap parameters.
|
||||
*
|
||||
* @param $config
|
||||
* @param ContainerBuilder $container
|
||||
* @param $map
|
||||
*/
|
||||
protected function remapParameters(array $config, ContainerBuilder $container, array $map)
|
||||
{
|
||||
foreach ($map as $name => $paramName) {
|
||||
if (isset($config[$name])) {
|
||||
$container->setParameter($paramName, $config[$name]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Remap parameter namespaces.
|
||||
*
|
||||
* @param $config
|
||||
* @param ContainerBuilder $container
|
||||
* @param $map
|
||||
*/
|
||||
protected function remapParametersNamespaces(array $config, ContainerBuilder $container, array $namespaces)
|
||||
{
|
||||
foreach ($namespaces as $ns => $map) {
|
||||
if ($ns) {
|
||||
if (!isset($config[$ns])) {
|
||||
continue;
|
||||
}
|
||||
$namespaceConfig = $config[$ns];
|
||||
} else {
|
||||
$namespaceConfig = $config;
|
||||
}
|
||||
if (is_array($map)) {
|
||||
$this->remapParameters($namespaceConfig, $container, $map);
|
||||
} else {
|
||||
foreach ($namespaceConfig as $name => $value) {
|
||||
if (null !== $value) {
|
||||
$container->setParameter(sprintf($map, $name), $value);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
26
src/Sylius/Bundle/SalesBundle/Entity/ExtendedOrder.php
Normal file
26
src/Sylius/Bundle/SalesBundle/Entity/ExtendedOrder.php
Normal file
|
|
@ -0,0 +1,26 @@
|
|||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of the Sylius package.
|
||||
*
|
||||
* (c) Paweł Jędrzejewski
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace Sylius\Bundle\SalesBundle\Entity;
|
||||
|
||||
use Doctrine\Common\Collections\ArrayCollection;
|
||||
|
||||
use Sylius\Bundle\SalesBundle\Model\ExtendedOrder as BaseExtendedOrder;
|
||||
|
||||
class ExtendedOrder extends BaseExtendedOrder
|
||||
{
|
||||
public function __construct()
|
||||
{
|
||||
parent::__construct();
|
||||
|
||||
$this->items = new ArrayCollection;
|
||||
}
|
||||
}
|
||||
18
src/Sylius/Bundle/SalesBundle/Entity/Item.php
Normal file
18
src/Sylius/Bundle/SalesBundle/Entity/Item.php
Normal file
|
|
@ -0,0 +1,18 @@
|
|||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of the Sylius package.
|
||||
*
|
||||
* (c) Paweł Jędrzejewski
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace Sylius\Bundle\SalesBundle\Entity;
|
||||
|
||||
use Sylius\Bundle\SalesBundle\Model\Item as BaseItem;
|
||||
|
||||
class Item extends BaseItem
|
||||
{
|
||||
}
|
||||
91
src/Sylius/Bundle/SalesBundle/Entity/ItemManager.php
Normal file
91
src/Sylius/Bundle/SalesBundle/Entity/ItemManager.php
Normal file
|
|
@ -0,0 +1,91 @@
|
|||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of the Sylius package.
|
||||
*
|
||||
* (c) Paweł Jędrzejewski
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace Sylius\Bundle\SalesBundle\Entity;
|
||||
|
||||
use Sylius\Bundle\SalesBundle\Model\ItemInterface;
|
||||
|
||||
use Sylius\Bundle\SalesBundle\Model\ItemManager;
|
||||
|
||||
use Doctrine\ORM\EntityManager;
|
||||
use Doctrine\ORM\EntityRepository;
|
||||
|
||||
class ItemManager extends ItemManager
|
||||
{
|
||||
/**
|
||||
* Entity manager.
|
||||
*
|
||||
* @var EntityManager
|
||||
*/
|
||||
protected $entityManager;
|
||||
|
||||
/**
|
||||
* Entity repository.
|
||||
*
|
||||
* @var EntityRepository
|
||||
*/
|
||||
protected $repository;
|
||||
|
||||
/**
|
||||
* Constructor.
|
||||
*
|
||||
* @param EntityManager $entityManager
|
||||
* @param string $class
|
||||
*/
|
||||
public function __construct(EntityManager $entityManager, $class)
|
||||
{
|
||||
parent::__construct($class);
|
||||
|
||||
$this->entityManager = $entityManager;
|
||||
$this->repository = $this->entityManager->getRepository($this->getClass());
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function createItem()
|
||||
{
|
||||
$class = $this->getClass();
|
||||
return new $class;
|
||||
}
|
||||
|
||||
public function persistItem(ItemInterface $order)
|
||||
{
|
||||
$this->entityManager->persist($order);
|
||||
$this->entityManager->flush();
|
||||
}
|
||||
|
||||
public function removeItem(ItemInterface $order)
|
||||
{
|
||||
$this->entityManager->remove($order);
|
||||
$this->entityManager->flush();
|
||||
}
|
||||
|
||||
public function findItem($id)
|
||||
{
|
||||
return $this->repository->find($id);
|
||||
}
|
||||
|
||||
public function findItemBy(array $criteria)
|
||||
{
|
||||
return $this->repository->findOneBy($criteria);
|
||||
}
|
||||
|
||||
public function findItems()
|
||||
{
|
||||
return $this->repository->findAll();
|
||||
}
|
||||
|
||||
public function findItemsBy(array $criteria)
|
||||
{
|
||||
return $this->repository->findBy($criteria);
|
||||
}
|
||||
}
|
||||
18
src/Sylius/Bundle/SalesBundle/Entity/Order.php
Normal file
18
src/Sylius/Bundle/SalesBundle/Entity/Order.php
Normal file
|
|
@ -0,0 +1,18 @@
|
|||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of the Sylius package.
|
||||
*
|
||||
* (c) Paweł Jędrzejewski
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace Sylius\Bundle\SalesBundle\Entity;
|
||||
|
||||
use Sylius\Bundle\SalesBundle\Model\Order as BaseOrder;
|
||||
|
||||
class Order extends BaseOrder
|
||||
{
|
||||
}
|
||||
104
src/Sylius/Bundle/SalesBundle/Entity/OrderManager.php
Normal file
104
src/Sylius/Bundle/SalesBundle/Entity/OrderManager.php
Normal file
|
|
@ -0,0 +1,104 @@
|
|||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of the Sylius package.
|
||||
*
|
||||
* (c) Paweł Jędrzejewski
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace Sylius\Bundle\SalesBundle\Entity;
|
||||
|
||||
use Sylius\Bundle\SalesBundle\Model\OrderInterface;
|
||||
use Sylius\Bundle\SalesBundle\Model\OrderManager as BaseOrderManager;
|
||||
use Doctrine\ORM\EntityManager;
|
||||
use Doctrine\ORM\EntityRepository;
|
||||
use Pagerfanta\Pagerfanta;
|
||||
use Pagerfanta\Adapter\DoctrineORMAdapter;
|
||||
|
||||
class OrderManager extends BaseOrderManager
|
||||
{
|
||||
/**
|
||||
* Entity manager.
|
||||
*
|
||||
* @var EntityManager
|
||||
*/
|
||||
protected $entityManager;
|
||||
|
||||
/**
|
||||
* Entity repository.
|
||||
*
|
||||
* @var EntityRepository
|
||||
*/
|
||||
protected $repository;
|
||||
|
||||
/**
|
||||
* Constructor.
|
||||
*
|
||||
* @param EntityManager $entityManager
|
||||
* @param string $class
|
||||
*/
|
||||
public function __construct(EntityManager $entityManager, $class)
|
||||
{
|
||||
parent::__construct($class);
|
||||
|
||||
$this->entityManager = $entityManager;
|
||||
$this->repository = $this->entityManager->getRepository($this->getClass());
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function createOrder()
|
||||
{
|
||||
$class = $this->getClass();
|
||||
return new $class;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function createPaginator()
|
||||
{
|
||||
$queryBuilder = $this->entityManager->createQueryBuilder()
|
||||
->select('o')
|
||||
->from($this->class, 'o')
|
||||
->orderBy('o.createdAt', 'DESC');
|
||||
|
||||
return new Pagerfanta(new DoctrineORMAdapter($queryBuilder->getQuery()));
|
||||
}
|
||||
|
||||
public function persistOrder(OrderInterface $order)
|
||||
{
|
||||
$this->entityManager->persist($order);
|
||||
$this->entityManager->flush();
|
||||
}
|
||||
|
||||
public function removeOrder(OrderInterface $order)
|
||||
{
|
||||
$this->entityManager->remove($order);
|
||||
$this->entityManager->flush();
|
||||
}
|
||||
|
||||
public function findOrder($id)
|
||||
{
|
||||
return $this->repository->find($id);
|
||||
}
|
||||
|
||||
public function findOrderBy(array $criteria)
|
||||
{
|
||||
return $this->repository->findOneBy($criteria);
|
||||
}
|
||||
|
||||
public function findOrders()
|
||||
{
|
||||
return $this->repository->findAll();
|
||||
}
|
||||
|
||||
public function findOrdersBy(array $criteria)
|
||||
{
|
||||
return $this->repository->findBy($criteria);
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,35 @@
|
|||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of the Sylius package.
|
||||
*
|
||||
* (c) Paweł Jędrzejewski
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace Sylius\Bundle\SalesBundle\EventDispatcher\Event;
|
||||
|
||||
use Symfony\Component\EventDispatcher\Event;
|
||||
use Sylius\Bundle\SalesBundle\Model\OrderInterface;
|
||||
|
||||
/**
|
||||
* Filter order event.
|
||||
*
|
||||
* @author Paweł Jędrzejewski <pjedrzejewski@diweb.pl>
|
||||
*/
|
||||
class FilterOrderEvent extends Event
|
||||
{
|
||||
protected $order;
|
||||
|
||||
public function __construct(OrderInterface $order)
|
||||
{
|
||||
$this->order;
|
||||
}
|
||||
|
||||
public function getOrder()
|
||||
{
|
||||
return $this->order;
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,60 @@
|
|||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of the Sylius package.
|
||||
*
|
||||
* (c) Paweł Jędrzejewski
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace Sylius\Bundle\SalesBundle\EventDispatcher\Listener;
|
||||
|
||||
use Symfony\Bundle\FrameworkBundle\Templating\EngineInterface;
|
||||
use Sylius\Bundle\SalesBundle\EventDispatcher\Event\FilterOrderEvent;
|
||||
|
||||
/**
|
||||
* Confirmation listener.
|
||||
*
|
||||
* @author Paweł Jędrzejewski <pjedrzejewski@diweb.pl>
|
||||
*/
|
||||
class ConfirmationListener
|
||||
{
|
||||
private $options;
|
||||
|
||||
/**
|
||||
* Templating engine.
|
||||
*
|
||||
* @var EngineInterface
|
||||
*/
|
||||
private $templating;
|
||||
|
||||
/**
|
||||
* Mailer service.
|
||||
*/
|
||||
private $mailer;
|
||||
|
||||
public function __construct(array $options, $mailer, EngineInterface $templating)
|
||||
{
|
||||
$this->options = $options;
|
||||
$this->mailer = $mailer;
|
||||
$this->templating = $templating;
|
||||
}
|
||||
|
||||
public function onOrderPlace(FilterOrderEvent $event)
|
||||
{
|
||||
$order = $event->getOrder();
|
||||
$order->setConfirmed(false);
|
||||
|
||||
$message = \Swift_Message::newInstance()
|
||||
->setSubject($this->options['email']['subject'])
|
||||
->setFrom($this->options['email']['from'])
|
||||
->setTo($user->getEmail())
|
||||
->setBody($this->templating->render($this->options['email']['template'], array(
|
||||
'order' => $order
|
||||
)));
|
||||
|
||||
$this->mailer->send($message);
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,29 @@
|
|||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of the Sylius package.
|
||||
*
|
||||
* (c) Paweł Jędrzejewski
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace Sylius\Bundle\SalesBundle\EventDispatcher;
|
||||
|
||||
/**
|
||||
* Sales events.
|
||||
*
|
||||
* @author Paweł Jędrzejewski <pjedrzejewski@diweb.pl>
|
||||
*/
|
||||
final class SyliusSalesEvents
|
||||
{
|
||||
const ORDER_CREATE = 'sylius_sales.event.order.create';
|
||||
const ORDER_UPDATE = 'sylius_sales.event.order.update';
|
||||
const ORDER_DELETE = 'sylius_sales.event.order.delete';
|
||||
const ORDER_CLOSE = 'sylius_sales.event.order.close';
|
||||
const ORDER_OPEN = 'sylius_sales.event.order.close';
|
||||
const ORDER_CONFIRM = 'sylius_sales.event.order.confirm';
|
||||
const ORDER_PLACE = 'sylius_sales.event.order.place';
|
||||
const ORDER_STATUS = 'sylius_sales.event.order.status';
|
||||
}
|
||||
|
|
@ -0,0 +1,55 @@
|
|||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of the Sylius package.
|
||||
*
|
||||
* (c) Paweł Jędrzejewski
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace Sylius\Bundle\SalesBundle\Form\ChoiceList;
|
||||
|
||||
use Sylius\Bundle\SalesBundle\Model\StatusManager;
|
||||
|
||||
use Symfony\Component\Form\Extension\Core\ChoiceList\ArrayChoiceList;
|
||||
|
||||
/**
|
||||
* Order status choice list.
|
||||
*
|
||||
* @author Paweł Jędrzejewski <pjedrzejewski@diweb.pl>
|
||||
*/
|
||||
class StatusChoiceList extends ArrayChoiceList
|
||||
{
|
||||
/**
|
||||
* @var StatusManager
|
||||
*/
|
||||
protected $statusManager;
|
||||
|
||||
/**
|
||||
* Constructor.
|
||||
*
|
||||
* @param $pointManager
|
||||
*/
|
||||
public function __construct(StatusManager $statusManager)
|
||||
{
|
||||
$this->statusManager = $statusManager;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function getChoices()
|
||||
{
|
||||
$choices = array();
|
||||
|
||||
foreach($this->statusManager->getStatuses() as $id => $status) {
|
||||
$choices[] = $this->statusManager->translateStatus($id);
|
||||
}
|
||||
|
||||
$this->choices = $choices;
|
||||
|
||||
return parent::getChoices();
|
||||
}
|
||||
}
|
||||
59
src/Sylius/Bundle/SalesBundle/Form/Type/ItemType.php
Normal file
59
src/Sylius/Bundle/SalesBundle/Form/Type/ItemType.php
Normal file
|
|
@ -0,0 +1,59 @@
|
|||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of the Sylius package.
|
||||
*
|
||||
* (c) Paweł Jędrzejewski
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace Sylius\Bundle\SalesBundle\Form\Type;
|
||||
|
||||
use Symfony\Component\Form\FormBuilder;
|
||||
use Symfony\Component\Form\AbstractType;
|
||||
|
||||
/**
|
||||
* Cart item type.
|
||||
*
|
||||
* @author Paweł Jędrzejewski <pjedrzejewski@diweb.pl>
|
||||
*/
|
||||
class ItemType extends AbstractType
|
||||
{
|
||||
/**
|
||||
* Data class.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $dataClass;
|
||||
|
||||
/**
|
||||
* Constructor.
|
||||
*
|
||||
* @param string $dataClass
|
||||
*/
|
||||
public function __construct($dataClass)
|
||||
{
|
||||
$this->dataClass = $dataClass;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function buildForm(FormBuilder $builder, array $options)
|
||||
{
|
||||
$builder
|
||||
->add('quantity', 'number');
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function getDefaultOptions(array $options)
|
||||
{
|
||||
return array(
|
||||
'data_class' => $this->dataClass
|
||||
);
|
||||
}
|
||||
}
|
||||
62
src/Sylius/Bundle/SalesBundle/Form/Type/OrderFormType.php
Normal file
62
src/Sylius/Bundle/SalesBundle/Form/Type/OrderFormType.php
Normal file
|
|
@ -0,0 +1,62 @@
|
|||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of the Sylius package.
|
||||
*
|
||||
* (c) Paweł Jędrzejewski
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace Sylius\Bundle\SalesBundle\Form\Type;
|
||||
|
||||
use Symfony\Component\Form\FormBuilder;
|
||||
use Symfony\Component\Form\AbstractType;
|
||||
|
||||
/**
|
||||
* Order form type.
|
||||
*
|
||||
* @author Paweł Jędrzejewski <pjedrzejewski@diweb.pl>
|
||||
*/
|
||||
class OrderFormType extends AbstractType
|
||||
{
|
||||
/**
|
||||
* Data class.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $dataClass;
|
||||
|
||||
/**
|
||||
* Constructor.
|
||||
*
|
||||
* @param string $dataClass
|
||||
*/
|
||||
public function __construct($dataClass)
|
||||
{
|
||||
$this->dataClass = $dataClass;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function buildForm(FormBuilder $builder, array $options)
|
||||
{
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function getDefaultOptions(array $options)
|
||||
{
|
||||
return array(
|
||||
'data_class' => $this->dataClass
|
||||
);
|
||||
}
|
||||
|
||||
public function getName()
|
||||
{
|
||||
return 'sylius_sales_order';
|
||||
}
|
||||
}
|
||||
75
src/Sylius/Bundle/SalesBundle/Form/Type/StatusFormType.php
Normal file
75
src/Sylius/Bundle/SalesBundle/Form/Type/StatusFormType.php
Normal file
|
|
@ -0,0 +1,75 @@
|
|||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of the Sylius package.
|
||||
*
|
||||
* (c) Paweł Jędrzejewski
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace Sylius\Bundle\SalesBundle\Form\Type;
|
||||
|
||||
use Sylius\Bundle\SalesBundle\Form\ChoiceList\StatusChoiceList;
|
||||
use Symfony\Component\Form\FormBuilder;
|
||||
use Symfony\Component\Form\AbstractType;
|
||||
|
||||
/**
|
||||
* Order status type.
|
||||
*
|
||||
* @author Paweł Jędrzejewski <pjedrzejewski@diweb.pl>
|
||||
*/
|
||||
class StatusFormType extends AbstractType
|
||||
{
|
||||
/**
|
||||
* Data class.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $dataClass;
|
||||
|
||||
/**
|
||||
* Status choice list.
|
||||
*
|
||||
* @var StatusChoiceList
|
||||
*/
|
||||
protected $statusChoiceList;
|
||||
|
||||
/**
|
||||
* Constructor.
|
||||
*
|
||||
* @param string $dataClass
|
||||
*/
|
||||
public function __construct($dataClass, StatusChoiceList $statusChoiceList)
|
||||
{
|
||||
$this->dataClass = $dataClass;
|
||||
$this->statusChoiceList = $statusChoiceList;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function buildForm(FormBuilder $builder, array $options)
|
||||
{
|
||||
$builder
|
||||
->add('status', 'choice', array(
|
||||
'choice_list' => $this->statusChoiceList,
|
||||
));
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function getDefaultOptions(array $options)
|
||||
{
|
||||
return array(
|
||||
'data_class' => $this->dataClass
|
||||
);
|
||||
}
|
||||
|
||||
public function getName()
|
||||
{
|
||||
return 'sylius_sales_status';
|
||||
}
|
||||
}
|
||||
101
src/Sylius/Bundle/SalesBundle/Manipulator/OrderManipulator.php
Normal file
101
src/Sylius/Bundle/SalesBundle/Manipulator/OrderManipulator.php
Normal file
|
|
@ -0,0 +1,101 @@
|
|||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of the Sylius package.
|
||||
*
|
||||
* (c) Paweł Jędrzejewski
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace Sylius\Bundle\SalesBundle\Manipulator;
|
||||
|
||||
use Sylius\Bundle\SalesBundle\Model\OrderManagerInterface;
|
||||
|
||||
use Sylius\Bundle\SalesBundle\Model\OrderInterface;
|
||||
|
||||
/**
|
||||
* Order manipulator.
|
||||
*
|
||||
* @author Paweł Jędrzejewski <pjedrzejewski@diweb.pl>
|
||||
*/
|
||||
class OrderManipulator implements OrderManipulatorInterface
|
||||
{
|
||||
protected $orderManager;
|
||||
|
||||
public function __construct(OrderManagerInterface $orderManager)
|
||||
{
|
||||
$this->orderManager = $orderManager;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function place(OrderInterface $order)
|
||||
{
|
||||
$order->incrementCreatedAt();
|
||||
$this->orderManager->persistOrder($order);
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function create(OrderInterface $order)
|
||||
{
|
||||
$order->incrementCreatedAt();
|
||||
$this->orderManager->persistOrder($order);
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function update(OrderInterface $order)
|
||||
{
|
||||
$order->incrementUpdatedAt();
|
||||
$this->orderManager->persistOrder($order);
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function delete(OrderInterface $order)
|
||||
{
|
||||
$this->orderManager->removeOrder($order);
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function status(OrderInterface $order)
|
||||
{
|
||||
$this->update($order);
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function confirm(OrderInterface $order)
|
||||
{
|
||||
$order->setConfirmed(true);
|
||||
$this->update($order);
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function close(OrderInterface $order)
|
||||
{
|
||||
$order->setClosed(true);
|
||||
$this->update($order);
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function open(OrderInterface $order)
|
||||
{
|
||||
$order->setClosed(false);
|
||||
$this->update($order);
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,78 @@
|
|||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of the Sylius package.
|
||||
*
|
||||
* (c) Paweł Jędrzejewski
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace Sylius\Bundle\SalesBundle\Manipulator;
|
||||
|
||||
use Sylius\Bundle\SalesBundle\Model\OrderInterface;
|
||||
|
||||
/**
|
||||
* Order manipulator interface.
|
||||
*
|
||||
* @author Paweł Jędrzejewski <pjedrzejewski@diweb.pl>
|
||||
*/
|
||||
interface OrderManipulatorInterface
|
||||
{
|
||||
/**
|
||||
* Places an order.
|
||||
*
|
||||
* @param OrderInterface $order
|
||||
*/
|
||||
function place(OrderInterface $order);
|
||||
|
||||
/**
|
||||
* Creates an order.
|
||||
*
|
||||
* @param OrderInterface $order
|
||||
*/
|
||||
function create(OrderInterface $order);
|
||||
|
||||
/**
|
||||
* Updates an order.
|
||||
*
|
||||
* @param OrderInterface $order
|
||||
*/
|
||||
function update(OrderInterface $order);
|
||||
|
||||
/**
|
||||
* Deletes an order.
|
||||
*
|
||||
* @param OrderInterface $order
|
||||
*/
|
||||
function delete(OrderInterface $order);
|
||||
|
||||
/**
|
||||
* Confirms an order.
|
||||
*
|
||||
* @param OrderInterface $order
|
||||
*/
|
||||
function confirm(OrderInterface $order);
|
||||
|
||||
/**
|
||||
* Saves order status.
|
||||
*
|
||||
* @param OrderInterface $order
|
||||
*/
|
||||
function status(OrderInterface $order);
|
||||
|
||||
/**
|
||||
* Closes an order.
|
||||
*
|
||||
* @param OrderInterface $order
|
||||
*/
|
||||
function close(OrderInterface $order);
|
||||
|
||||
/**
|
||||
* Opens an order.
|
||||
*
|
||||
* @param OrderInterface $order
|
||||
*/
|
||||
function open(OrderInterface $order);
|
||||
}
|
||||
120
src/Sylius/Bundle/SalesBundle/Model/ExtendedOrder.php
Normal file
120
src/Sylius/Bundle/SalesBundle/Model/ExtendedOrder.php
Normal file
|
|
@ -0,0 +1,120 @@
|
|||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of the Sylius package.
|
||||
*
|
||||
* (c) Paweł Jędrzejewski
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace Sylius\Bundle\SalesBundle\Model;
|
||||
|
||||
/**
|
||||
* Model for orders.
|
||||
*
|
||||
* @author Paweł Jędrzejewski <pjedrzejewski@diweb.pl>
|
||||
*/
|
||||
abstract class ExtendedOrder extends Order implements ExtendedOrderInterface
|
||||
{
|
||||
/**
|
||||
* Items in order.
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
protected $items;
|
||||
|
||||
/**
|
||||
* Total items count.
|
||||
*
|
||||
* @var integer
|
||||
*/
|
||||
protected $totalItems;
|
||||
|
||||
/**
|
||||
* Constructor.
|
||||
*/
|
||||
public function __construct()
|
||||
{
|
||||
parent::__construct();
|
||||
|
||||
$this->totalItems = 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function setTotalItems($totalItems)
|
||||
{
|
||||
$this->totalItems = $totalItems;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function getTotalItems()
|
||||
{
|
||||
return $this->totalItems;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function getItems()
|
||||
{
|
||||
return $this->items;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function setItems(array $items)
|
||||
{
|
||||
$this->items = $items;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function addItem(ItemInterface $item)
|
||||
{
|
||||
if (!$this->hasItem($item)) {
|
||||
$this->items[] = $item;
|
||||
}
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function removeItem(ItemInterface $item)
|
||||
{
|
||||
return $this->items->removeElement($item);
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function hasItem(ItemInterface $item)
|
||||
{
|
||||
return $this->items->contains($item);
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function countItems()
|
||||
{
|
||||
return $this->items->count();
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function clearItems()
|
||||
{
|
||||
$this->items = array();
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,73 @@
|
|||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of the Sylius package.
|
||||
*
|
||||
* (c) Paweł Jędrzejewski
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace Sylius\Bundle\SalesBundle\Model;
|
||||
|
||||
/**
|
||||
* Extended order interface.
|
||||
*
|
||||
* @author Paweł Jędrzejewski <pjedrzejewski@diweb.pl>
|
||||
*/
|
||||
interface ExtendedOrderInterface extends OrderInterface
|
||||
{
|
||||
/**
|
||||
* Returns total item count.
|
||||
*
|
||||
* @return integer
|
||||
*/
|
||||
function getTotalItems();
|
||||
|
||||
/**
|
||||
* Sets total item count.
|
||||
*
|
||||
* @param integer $totalItems
|
||||
*/
|
||||
function setTotalItems($totalItems);
|
||||
|
||||
function getItems();
|
||||
|
||||
function setItems(array $items);
|
||||
|
||||
/**
|
||||
* Adds item to order.
|
||||
*
|
||||
* @param ItemInterface $item
|
||||
*/
|
||||
function addItem(ItemInterface $item);
|
||||
|
||||
/**
|
||||
* Remove item from order.
|
||||
*
|
||||
* @param ItemInterface $item
|
||||
*/
|
||||
function removeItem(ItemInterface $item);
|
||||
|
||||
/**
|
||||
* Has item in order?
|
||||
*
|
||||
* @param Item
|
||||
*/
|
||||
function hasItem(ItemInterface $item);
|
||||
|
||||
/**
|
||||
* Returns number of order items.
|
||||
*
|
||||
* @return integer
|
||||
*/
|
||||
function countItems();
|
||||
|
||||
/**
|
||||
* Removes all items from order.
|
||||
*
|
||||
* @return null
|
||||
*/
|
||||
function clearItems();
|
||||
}
|
||||
99
src/Sylius/Bundle/SalesBundle/Model/Item.php
Normal file
99
src/Sylius/Bundle/SalesBundle/Model/Item.php
Normal file
|
|
@ -0,0 +1,99 @@
|
|||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of the Sylius package.
|
||||
*
|
||||
* (c) Paweł Jędrzejewski
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace Sylius\Bundle\SalesBundle\Model;
|
||||
|
||||
/**
|
||||
* Model for order items.
|
||||
*
|
||||
* @author Paweł Jędrzejewski <pjedrzejewski@diweb.pl>
|
||||
*/
|
||||
abstract class Item implements ItemInterface
|
||||
{
|
||||
/**
|
||||
* Item id.
|
||||
*
|
||||
* @var integer
|
||||
*/
|
||||
protected $id;
|
||||
|
||||
/**
|
||||
* Order.
|
||||
*
|
||||
* @var OrderInterface
|
||||
*/
|
||||
protected $order;
|
||||
|
||||
/**
|
||||
* Quantity.
|
||||
*
|
||||
* @var integer
|
||||
*/
|
||||
protected $quantity;
|
||||
|
||||
/**
|
||||
* Constructor.
|
||||
*/
|
||||
public function __construct()
|
||||
{
|
||||
$this->quantity = 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns item id.
|
||||
*
|
||||
* @return integer
|
||||
*/
|
||||
public function getId()
|
||||
{
|
||||
return $this->id;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get item quantity.
|
||||
*
|
||||
* @return integer
|
||||
*/
|
||||
public function getQuantity()
|
||||
{
|
||||
return $this->quantity;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets quantity.
|
||||
*
|
||||
* @param integer $quantity
|
||||
*/
|
||||
public function setQuantity($quantity)
|
||||
{
|
||||
$this->quantity = $quantity;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns order.
|
||||
*
|
||||
* @return OrderInterface
|
||||
*/
|
||||
public function getOrder()
|
||||
{
|
||||
return $this->order;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets order.
|
||||
*
|
||||
* @param OrderInterface $order
|
||||
*/
|
||||
public function setOrder(OrderInterface $order)
|
||||
{
|
||||
$this->order = $order;
|
||||
}
|
||||
}
|
||||
55
src/Sylius/Bundle/SalesBundle/Model/ItemInterface.php
Normal file
55
src/Sylius/Bundle/SalesBundle/Model/ItemInterface.php
Normal file
|
|
@ -0,0 +1,55 @@
|
|||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of the Sylius package.
|
||||
*
|
||||
* (c) Paweł Jędrzejewski
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace Sylius\Bundle\SalesBundle\Model;
|
||||
|
||||
/**
|
||||
* Interface for order item model.
|
||||
*
|
||||
* @author Paweł Jędrzejewski <pjedrzejewski@diweb.pl>
|
||||
*/
|
||||
interface ItemInterface
|
||||
{
|
||||
/**
|
||||
* Returns item id.
|
||||
*
|
||||
* @return integer
|
||||
*/
|
||||
function getId();
|
||||
|
||||
/**
|
||||
* Returns order.
|
||||
*
|
||||
* @return OrderInterface
|
||||
*/
|
||||
function getOrder();
|
||||
|
||||
/**
|
||||
* Sets order.
|
||||
*
|
||||
* @param OrderInterface $order
|
||||
*/
|
||||
function setOrder(OrderInterface $order);
|
||||
|
||||
/**
|
||||
* Get item quantity.
|
||||
*
|
||||
* @return integer
|
||||
*/
|
||||
function getQuantity();
|
||||
|
||||
/**
|
||||
* Sets quantity.
|
||||
*
|
||||
* @param integer $quantity
|
||||
*/
|
||||
function setQuantity($quantity);
|
||||
}
|
||||
45
src/Sylius/Bundle/SalesBundle/Model/ItemManager.php
Normal file
45
src/Sylius/Bundle/SalesBundle/Model/ItemManager.php
Normal file
|
|
@ -0,0 +1,45 @@
|
|||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of the Sylius package.
|
||||
*
|
||||
* (c) Paweł Jędrzejewski
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace Sylius\Bundle\SalesBundle\Model;
|
||||
|
||||
/**
|
||||
* Base class for order item model manager.
|
||||
*
|
||||
* @author Paweł Jędrzejewski <pjedrzejewski@diweb.pl>
|
||||
*/
|
||||
abstract class ItemManager implements ItemManagerInterface
|
||||
{
|
||||
/**
|
||||
* FQCN for order item model.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $class;
|
||||
|
||||
/**
|
||||
* Constructor.
|
||||
*
|
||||
* @param string $class The FQCN for order item model
|
||||
*/
|
||||
public function __construct($class)
|
||||
{
|
||||
$this->class = $class;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function getClass()
|
||||
{
|
||||
return $this->class;
|
||||
}
|
||||
}
|
||||
60
src/Sylius/Bundle/SalesBundle/Model/ItemManagerInterface.php
Normal file
60
src/Sylius/Bundle/SalesBundle/Model/ItemManagerInterface.php
Normal file
|
|
@ -0,0 +1,60 @@
|
|||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of the Sylius package.
|
||||
*
|
||||
* (c) Paweł Jędrzejewski
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace Sylius\Bundle\SalesBundle\Model;
|
||||
|
||||
/**
|
||||
* Interface for order item model manager.
|
||||
*
|
||||
* @author Paweł Jędrzejewski <pjedrzejewski@diweb.pl>
|
||||
*/
|
||||
interface ItemManagerInterface
|
||||
{
|
||||
/**
|
||||
* Returns FQCN of order item model.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
function getClass();
|
||||
|
||||
/**
|
||||
* Creates item model object.
|
||||
*/
|
||||
function createItem();
|
||||
|
||||
/**
|
||||
* Finds item by id.
|
||||
*
|
||||
* @param integer $id
|
||||
*/
|
||||
function findItem($id);
|
||||
|
||||
/**
|
||||
* Finds item by criteria.
|
||||
*
|
||||
* @param array $criteria
|
||||
*/
|
||||
function findItemBy(array $criteria);
|
||||
|
||||
/**
|
||||
* Finds all items.
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
function findItems();
|
||||
|
||||
/**
|
||||
* Finds items by criteria.
|
||||
*
|
||||
* @param array $criteria
|
||||
*/
|
||||
function findItemsBy(array $criteria);
|
||||
}
|
||||
171
src/Sylius/Bundle/SalesBundle/Model/Order.php
Normal file
171
src/Sylius/Bundle/SalesBundle/Model/Order.php
Normal file
|
|
@ -0,0 +1,171 @@
|
|||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of the Sylius package.
|
||||
*
|
||||
* (c) Paweł Jędrzejewski
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace Sylius\Bundle\SalesBundle\Model;
|
||||
|
||||
/**
|
||||
* Model for orders.
|
||||
*
|
||||
* @author Paweł Jędrzejewski <pjedrzejewski@diweb.pl>
|
||||
*/
|
||||
abstract class Order implements OrderInterface
|
||||
{
|
||||
/**
|
||||
* Id.
|
||||
*
|
||||
* @var integer
|
||||
*/
|
||||
protected $id;
|
||||
|
||||
protected $confirmed;
|
||||
|
||||
protected $confirmationToken;
|
||||
|
||||
/**
|
||||
* Is closed.
|
||||
*
|
||||
* @var Boolean
|
||||
*/
|
||||
protected $closed;
|
||||
|
||||
protected $status;
|
||||
|
||||
/**
|
||||
* Creation time.
|
||||
*
|
||||
* @var \DateTime
|
||||
*/
|
||||
protected $createdAt;
|
||||
|
||||
/**
|
||||
* Modification time.
|
||||
*
|
||||
* @var \DateTime
|
||||
*/
|
||||
protected $updatedAt;
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
$this->closed = false;
|
||||
$this->confirmed = true;
|
||||
$this->generateConfirmationToken();
|
||||
$this->status = 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function getId()
|
||||
{
|
||||
return $this->id;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function isClosed()
|
||||
{
|
||||
return $this->closed;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function setClosed($closed)
|
||||
{
|
||||
$this->closed = $closed;
|
||||
}
|
||||
|
||||
public function isConfirmed()
|
||||
{
|
||||
return $this->confirmed;
|
||||
}
|
||||
|
||||
public function setConfirmed($confirmed)
|
||||
{
|
||||
$this->confirmed = $confirmed;
|
||||
}
|
||||
|
||||
public function getConfirmationToken()
|
||||
{
|
||||
return $this->confirmationToken;
|
||||
}
|
||||
|
||||
public function setConfirmationToken($confirmationToken)
|
||||
{
|
||||
$this->confirmationToken = $confirmationToken;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function generateConfirmationToken()
|
||||
{
|
||||
if (null === $this->confirmationToken) {
|
||||
$bytes = false;
|
||||
if (function_exists('openssl_random_pseudo_bytes') && 0 !== stripos(PHP_OS, 'win')) {
|
||||
$bytes = openssl_random_pseudo_bytes(32, $strong);
|
||||
|
||||
if (true !== $strong) {
|
||||
$bytes = false;
|
||||
}
|
||||
}
|
||||
|
||||
if (false === $bytes) {
|
||||
$bytes = hash('sha256', uniqid(mt_rand(), true), true);
|
||||
}
|
||||
|
||||
$this->confirmationToken = base_convert(bin2hex($bytes), 16, 36);
|
||||
}
|
||||
}
|
||||
|
||||
public function getStatus()
|
||||
{
|
||||
return $this->status;
|
||||
}
|
||||
|
||||
public function setStatus($status)
|
||||
{
|
||||
$this->status = $status;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function getCreatedAt()
|
||||
{
|
||||
return $this->createdAt;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function incrementCreatedAt()
|
||||
{
|
||||
$this->createdAt = new \DateTime();
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function getUpdatedAt()
|
||||
{
|
||||
return $this->updatedAt;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function incrementUpdatedAt()
|
||||
{
|
||||
$this->updatedAt = new \DateTime();
|
||||
}
|
||||
}
|
||||
59
src/Sylius/Bundle/SalesBundle/Model/OrderInterface.php
Normal file
59
src/Sylius/Bundle/SalesBundle/Model/OrderInterface.php
Normal file
|
|
@ -0,0 +1,59 @@
|
|||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of the Sylius package.
|
||||
*
|
||||
* (c) Paweł Jędrzejewski
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace Sylius\Bundle\SalesBundle\Model;
|
||||
|
||||
/**
|
||||
* Order interface.
|
||||
*
|
||||
* @author Paweł Jędrzejewski <pjedrzejewski@diweb.pl>
|
||||
*/
|
||||
interface OrderInterface
|
||||
{
|
||||
function getId();
|
||||
function isConfirmed();
|
||||
function setConfirmed($confirmed);
|
||||
function generateConfirmationToken();
|
||||
function getConfirmationToken();
|
||||
function setConfirmationToken($confirmationToken);
|
||||
function isClosed();
|
||||
function setClosed($closed);
|
||||
function getStatus();
|
||||
function setStatus($status);
|
||||
|
||||
/**
|
||||
* Get creation time.
|
||||
*
|
||||
* @return \DateTime
|
||||
*/
|
||||
function getCreatedAt();
|
||||
|
||||
/**
|
||||
* Increments creation time.
|
||||
*
|
||||
* @return null
|
||||
*/
|
||||
function incrementCreatedAt();
|
||||
|
||||
/**
|
||||
* Get modification time.
|
||||
*
|
||||
* @return \DateTime
|
||||
*/
|
||||
function getUpdatedAt();
|
||||
|
||||
/**
|
||||
* Increments modification time.
|
||||
*
|
||||
* @return null
|
||||
*/
|
||||
function incrementUpdatedAt();
|
||||
}
|
||||
47
src/Sylius/Bundle/SalesBundle/Model/OrderManager.php
Normal file
47
src/Sylius/Bundle/SalesBundle/Model/OrderManager.php
Normal file
|
|
@ -0,0 +1,47 @@
|
|||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of the Sylius package.
|
||||
*
|
||||
* (c) Paweł Jędrzejewski
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace Sylius\Bundle\SalesBundle\Model;
|
||||
|
||||
/**
|
||||
* Abstract order manager class.
|
||||
*
|
||||
* @author Paweł Jędrzejewski <pjedrzejewski@diweb.pl>
|
||||
*/
|
||||
abstract class OrderManager implements OrderManagerInterface
|
||||
{
|
||||
/**
|
||||
* Order class.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $class;
|
||||
|
||||
/**
|
||||
* Constructor.
|
||||
*
|
||||
* @var string $class
|
||||
*/
|
||||
public function __construct($class)
|
||||
{
|
||||
$this->class = $class;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns FQCN of order.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getClass()
|
||||
{
|
||||
return $this->class;
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,79 @@
|
|||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of the Sylius package.
|
||||
*
|
||||
* (c) Paweł Jędrzejewski
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace Sylius\Bundle\SalesBundle\Model;
|
||||
|
||||
/**
|
||||
* Order manager interface.
|
||||
*
|
||||
* @author Paweł Jędrzejewski <pjedrzejewski@diweb.pl>
|
||||
*/
|
||||
interface OrderManagerInterface
|
||||
{
|
||||
/**
|
||||
* Creates new order object.
|
||||
*
|
||||
* @return OrderInterface
|
||||
*/
|
||||
function createOrder();
|
||||
|
||||
/**
|
||||
* Persist order.
|
||||
*
|
||||
* @param OrderInterface
|
||||
*/
|
||||
function persistOrder(OrderInterface $order);
|
||||
|
||||
/**
|
||||
* Removes order.
|
||||
*
|
||||
* @param OrderInterface $order
|
||||
*/
|
||||
function removeOrder(OrderInterface $order);
|
||||
|
||||
/**
|
||||
* Finds order by id.
|
||||
*
|
||||
* @param integer $id
|
||||
* @return OrderInterface
|
||||
*/
|
||||
function findOrder($id);
|
||||
|
||||
/**
|
||||
* Finds order by criteria.
|
||||
*
|
||||
* @param array $criteria
|
||||
* @return OrderInterface
|
||||
*/
|
||||
function findOrderBy(array $criteria);
|
||||
|
||||
/**
|
||||
* Finds all orders.
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
function findOrders();
|
||||
|
||||
/**
|
||||
* Finds orders by criteria.
|
||||
*
|
||||
* @param array $criteria
|
||||
* @return array
|
||||
*/
|
||||
function findOrdersBy(array $criteria);
|
||||
|
||||
/**
|
||||
* Returns FQCN of order.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
function getClass();
|
||||
}
|
||||
49
src/Sylius/Bundle/SalesBundle/Model/StatusManager.php
Normal file
49
src/Sylius/Bundle/SalesBundle/Model/StatusManager.php
Normal file
|
|
@ -0,0 +1,49 @@
|
|||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of the Sylius package.
|
||||
*
|
||||
* (c) Paweł Jędrzejewski
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace Sylius\Bundle\SalesBundle\Model;
|
||||
|
||||
use Symfony\Component\Translation\TranslatorInterface;
|
||||
|
||||
class StatusManager
|
||||
{
|
||||
protected $statuses;
|
||||
protected $translator;
|
||||
|
||||
public function __construct(array $statuses, TranslatorInterface $translator = null)
|
||||
{
|
||||
$this->statuses = $statuses;
|
||||
$this->translator = $translator;
|
||||
}
|
||||
|
||||
public function resolveStatus(OrderInterface $order)
|
||||
{
|
||||
$this->translateStatus($order->getStatus());
|
||||
}
|
||||
|
||||
public function translateStatus($status)
|
||||
{
|
||||
if (isset($this->statuses[$status])) {
|
||||
if (null != $this->translator) {
|
||||
return $this->translator->trans($this->statuses[$status], array(), 'Statuses');
|
||||
}
|
||||
|
||||
return $this->statuses[$status];
|
||||
}
|
||||
|
||||
throw new \InvalidArgumentException('Wrong status alias supplied.');
|
||||
}
|
||||
|
||||
public function getStatuses()
|
||||
{
|
||||
return $this->statuses;
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,29 @@
|
|||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of the Sylius package.
|
||||
*
|
||||
* (c) Paweł Jędrzejewski
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace Sylius\Bundle\SalesBundle\Processor\Operation;
|
||||
|
||||
use Sylius\Bundle\SalesBundle\Model\OrderInterface;
|
||||
|
||||
/**
|
||||
* Interface for order processor operations.
|
||||
*
|
||||
* @author Paweł Jędrzejewski <pjedrzejewski@diweb.pl>
|
||||
*/
|
||||
interface OperationInterface
|
||||
{
|
||||
/**
|
||||
* Processes order.
|
||||
*
|
||||
* @param OrderInterface $order
|
||||
*/
|
||||
function process(OrderInterface $order);
|
||||
}
|
||||
63
src/Sylius/Bundle/SalesBundle/Processor/Processor.php
Normal file
63
src/Sylius/Bundle/SalesBundle/Processor/Processor.php
Normal file
|
|
@ -0,0 +1,63 @@
|
|||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of the Sylius package.
|
||||
*
|
||||
* (c) Paweł Jędrzejewski
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace Sylius\Bundle\SalesBundle\Processor;
|
||||
|
||||
use Sylius\Bundle\SalesBundle\Processor\Operation\OperationInterface;
|
||||
use Sylius\Bundle\SalesBundle\Model\OrderInterface;
|
||||
|
||||
/**
|
||||
* Order processor.
|
||||
*
|
||||
* @author Paweł Jędrzejewski <pjedrzejewski@diweb.pl>
|
||||
*/
|
||||
class Processor
|
||||
{
|
||||
/**
|
||||
* Processor operation.
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
private $operations = array();
|
||||
|
||||
/**
|
||||
* Processes order. Calls all operations.
|
||||
*
|
||||
* @param OrderInterface $order
|
||||
*/
|
||||
public function processOrder(OrderInterface $order)
|
||||
{
|
||||
foreach ($this->operations as $operation) {
|
||||
$operation->process($order);
|
||||
}
|
||||
|
||||
return $order;
|
||||
}
|
||||
|
||||
/**
|
||||
* Registers processor.
|
||||
*
|
||||
* @var OperationInterface $operation
|
||||
*/
|
||||
public function registerOperation(OperationInterface $operation)
|
||||
{
|
||||
$this->operations = $operation;
|
||||
}
|
||||
|
||||
/**
|
||||
* Unergisters operation.
|
||||
*
|
||||
* @param OperationInterface $operation
|
||||
*/
|
||||
public function unregisterOperation(OperationInterface $operation)
|
||||
{
|
||||
}
|
||||
}
|
||||
31
src/Sylius/Bundle/SalesBundle/README.md
Normal file
31
src/Sylius/Bundle/SalesBundle/README.md
Normal file
|
|
@ -0,0 +1,31 @@
|
|||
About SyliusSalesBundle...
|
||||
=================================
|
||||
|
||||
Sales management, orders and this kind of stuff.
|
||||
|
||||
Sylius.
|
||||
-------
|
||||
|
||||
**Sylius** is a Symfony2 powered e-commerce system. Visit [sylius.org](http://sylius.org).
|
||||
|
||||
Documentation.
|
||||
--------------
|
||||
|
||||
Docs are available [here](https://github.com/Sylius/SyliusSalesBundle/blob/master/Resources/doc/index.md).
|
||||
|
||||
Dependencies.
|
||||
-------------
|
||||
|
||||
This bundle uses the awesome [Pagerfanta library](https://github.com/whiteoctober/Pagerfanta) and [Pagerfanta bundle](https://github.com/whiteoctober/WhiteOctoberPagerfantaBundle).
|
||||
|
||||
License.
|
||||
--------
|
||||
|
||||
Licence can be found here...
|
||||
|
||||
Resources/meta/LICENSE
|
||||
|
||||
Authors.
|
||||
--------
|
||||
|
||||
See the list of [contributors](https://github.com/Sylius/SyliusSalesBundle/contributors).
|
||||
|
|
@ -0,0 +1,20 @@
|
|||
<?xml version="1.0" encoding="UTF-8" ?>
|
||||
|
||||
<container xmlns="http://symfony.com/schema/dic/services"
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:schemaLocation="http://symfony.com/schema/dic/services http://symfony.com/schema/dic/services/services-1.0.xsd">
|
||||
|
||||
<services>
|
||||
<service id="sylius_sales.controller.frontend.order" class="%sylius_sales.controller.frontend.order.class%">
|
||||
<call method="setContainer">
|
||||
<argument type="service" id="service_container" />
|
||||
</call>
|
||||
</service>
|
||||
<service id="sylius_sales.controller.backend.order" class="%sylius_sales.controller.backend.order.class%">
|
||||
<call method="setContainer">
|
||||
<argument type="service" id="service_container" />
|
||||
</call>
|
||||
</service>
|
||||
</services>
|
||||
|
||||
</container>
|
||||
|
|
@ -0,0 +1,28 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
|
||||
<container xmlns="http://symfony.com/schema/dic/services"
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:schemaLocation="http://symfony.com/schema/dic/services http://symfony.com/schema/dic/services/services-1.0.xsd">
|
||||
|
||||
<parameters>
|
||||
<parameter key="sylius_sales.manager.order.class">Sylius\Bundle\SalesBundle\Entity\OrderManager</parameter>
|
||||
<parameter key="sylius_sales.manager.item.class">Sylius\Bundle\SalesBundle\Entity\ItemManager</parameter>
|
||||
<parameter key="sylius_sales.manager.status.class">Sylius\Bundle\SalesBundle\Model\StatusManager</parameter>
|
||||
</parameters>
|
||||
|
||||
<services>
|
||||
<service id="sylius_sales.manager.order" class="%sylius_sales.manager.order.class%">
|
||||
<argument type="service" id="doctrine.orm.default_entity_manager" />
|
||||
<argument>%sylius_sales.model.order.class%</argument>
|
||||
</service>
|
||||
<service id="sylius_sales.manager.item" class="%sylius_sales.manager.item.class%">
|
||||
<argument type="service" id="doctrine.orm.default_entity_manager" />
|
||||
<argument>%sylius_sales.model.item.class%</argument>
|
||||
</service>
|
||||
<service id="sylius_sales.manager.status" class="%sylius_sales.manager.status.class%">
|
||||
<argument>%sylius_sales.statuses%</argument>
|
||||
<argument type="service" id="translator" />
|
||||
</service>
|
||||
</services>
|
||||
|
||||
</container>
|
||||
|
|
@ -0,0 +1,7 @@
|
|||
<?xml version="1.0" encoding="UTF-8" ?>
|
||||
|
||||
<container xmlns="http://symfony.com/schema/dic/services"
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:schemaLocation="http://symfony.com/schema/dic/services http://symfony.com/schema/dic/services/services-1.0.xsd">
|
||||
|
||||
</container>
|
||||
|
|
@ -0,0 +1,31 @@
|
|||
<?xml version="1.0" encoding="UTF-8" ?>
|
||||
|
||||
<container xmlns="http://symfony.com/schema/dic/services"
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:schemaLocation="http://symfony.com/schema/dic/services http://symfony.com/schema/dic/services/services-1.0.xsd">
|
||||
|
||||
<parameters>
|
||||
<parameter key="sylius_sales.form.type.status.class">Sylius\Bundle\SalesBundle\Form\Type\StatusFormType</parameter>
|
||||
<parameter key="sylius_sales.form.choice_list.status.class">Sylius\Bundle\SalesBundle\Form\ChoiceList\StatusChoiceList</parameter>
|
||||
</parameters>
|
||||
|
||||
<services>
|
||||
<service id="sylius_sales.form.choice_list.status" class="%sylius_sales.form.choice_list.status.class%">
|
||||
<argument type="service" id="sylius_sales.manager.status" />
|
||||
</service>
|
||||
<service id="sylius_sales.form.type.order" class="%sylius_sales.form.type.order.class%">
|
||||
<argument>%sylius_sales.model.order.class%</argument>
|
||||
<tag name="form.type" alias="sylius_sales_order" />
|
||||
</service>
|
||||
<service id="sylius_sales.form.type.status" class="%sylius_sales.form.type.status.class%">
|
||||
<argument>%sylius_sales.model.order.class%</argument>
|
||||
<argument type="service" id="sylius_sales.form.choice_list.status" />
|
||||
<tag name="form.type" alias="sylius_sales_status" />
|
||||
</service>
|
||||
<service id="sylius_sales.form.type.item" class="%sylius_sales.form.type.item.class%">
|
||||
<argument>%sylius_sales.model.item.class%</argument>
|
||||
<tag name="form.type" alias="sylius_sales_item" />
|
||||
</service>
|
||||
</services>
|
||||
|
||||
</container>
|
||||
|
|
@ -0,0 +1,24 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
|
||||
<!--
|
||||
|
||||
This file is part of the Sylius package.
|
||||
|
||||
(c) Paweł Jędrzejewski
|
||||
|
||||
For the full copyright and license information, please view the LICENSE
|
||||
file that was distributed with this source code.
|
||||
|
||||
-->
|
||||
|
||||
<container xmlns="http://symfony.com/schema/dic/services"
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:schemaLocation="http://symfony.com/schema/dic/services http://symfony.com/schema/dic/services/services-1.0.xsd">
|
||||
|
||||
<services>
|
||||
<service id="sylius_sales.manipulator.order" class="%sylius_sales.manipulator.order.class%">
|
||||
<argument type="service" id="sylius_sales.manager.order" />
|
||||
</service>
|
||||
</services>
|
||||
|
||||
</container>
|
||||
|
|
@ -0,0 +1,15 @@
|
|||
<?xml version="1.0" encoding="UTF-8" ?>
|
||||
|
||||
<container xmlns="http://symfony.com/schema/dic/services"
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:schemaLocation="http://symfony.com/schema/dic/services http://symfony.com/schema/dic/services/services-1.0.xsd">
|
||||
|
||||
<parameters>
|
||||
<parameter key="sylius_sales.processor.class">Sylius\Bundle\SalesBundle\Processor\Processor</parameter>
|
||||
</parameters>
|
||||
|
||||
<services>
|
||||
<service id="sylius_sales.processor" class="%sylius_sales.processor.class%" />
|
||||
</services>
|
||||
|
||||
</container>
|
||||
|
|
@ -0,0 +1,17 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
|
||||
<doctrine-mapping xmlns="http://doctrine-project.org/schemas/orm/doctrine-mapping"
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:schemaLocation="http://doctrine-project.org/schemas/orm/doctrine-mapping
|
||||
http://doctrine-project.org/schemas/orm/doctrine-mapping.xsd">
|
||||
|
||||
<mapped-superclass name="Sylius\Bundle\SalesBundle\Entity\ExtendedOrder" table="sylius_sales_order">
|
||||
<field name="totalItems" column="total_items" type="integer" />
|
||||
<field name="confirmed" column="confirmed" type="boolean" />
|
||||
<field name="closed" column="closed" type="boolean" />
|
||||
<field name="status" column="status" type="integer" />
|
||||
<field name="createdAt" column="created_at" type="datetime" />
|
||||
<field name="updatedAt" column="updated_at" type="datetime" nullable="true" />
|
||||
</mapped-superclass>
|
||||
|
||||
</doctrine-mapping>
|
||||
|
|
@ -0,0 +1,12 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
|
||||
<doctrine-mapping xmlns="http://doctrine-project.org/schemas/orm/doctrine-mapping"
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:schemaLocation="http://doctrine-project.org/schemas/orm/doctrine-mapping
|
||||
http://doctrine-project.org/schemas/orm/doctrine-mapping.xsd">
|
||||
|
||||
<mapped-superclass name="Sylius\Bundle\SalesBundle\Entity\Item" table="sylius_sales_order_item">
|
||||
<field name="quantity" column="quantity" type="integer" />
|
||||
</mapped-superclass>
|
||||
|
||||
</doctrine-mapping>
|
||||
|
|
@ -0,0 +1,16 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
|
||||
<doctrine-mapping xmlns="http://doctrine-project.org/schemas/orm/doctrine-mapping"
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:schemaLocation="http://doctrine-project.org/schemas/orm/doctrine-mapping
|
||||
http://doctrine-project.org/schemas/orm/doctrine-mapping.xsd">
|
||||
|
||||
<mapped-superclass name="Sylius\Bundle\SalesBundle\Entity\Order" table="sylius_sales_order">
|
||||
<field name="confirmed" column="confirmed" type="boolean" />
|
||||
<field name="closed" column="closed" type="boolean" />
|
||||
<field name="status" column="status" type="integer" />
|
||||
<field name="createdAt" column="created_at" type="datetime" />
|
||||
<field name="updatedAt" column="updated_at" type="datetime" nullable="true" />
|
||||
</mapped-superclass>
|
||||
|
||||
</doctrine-mapping>
|
||||
|
|
@ -0,0 +1,27 @@
|
|||
sylius_sales_backend_order_list:
|
||||
pattern: /list
|
||||
defaults: { _controller: sylius_sales.controller.backend.order:listAction }
|
||||
|
||||
sylius_sales_backend_order_status:
|
||||
pattern: /{id}/status
|
||||
defaults: { _controller: sylius_sales.controller.backend.order:statusAction }
|
||||
|
||||
sylius_sales_backend_order_confirm:
|
||||
pattern: /{id}/confirm
|
||||
defaults: { _controller: sylius_sales.controller.backend.order:confirmAction }
|
||||
|
||||
sylius_sales_backend_order_delete:
|
||||
pattern: /{id}/delete
|
||||
defaults: { _controller: sylius_sales.controller.backend.order:deleteAction }
|
||||
|
||||
sylius_sales_backend_order_close:
|
||||
pattern: /{id}/close
|
||||
defaults: { _controller: sylius_sales.controller.backend.order:closeAction }
|
||||
|
||||
sylius_sales_backend_order_open:
|
||||
pattern: /{id}/open
|
||||
defaults: { _controller: sylius_sales.controller.backend.order:openAction }
|
||||
|
||||
sylius_sales_backend_order_show:
|
||||
pattern: /{id}
|
||||
defaults: { _controller: sylius_sales.controller.backend.order:showAction }
|
||||
|
|
@ -0,0 +1,3 @@
|
|||
sylius_sales_order_confirm:
|
||||
pattern: /confirm/{token}
|
||||
defaults: { _controller: sylius_sales.controller.frontend.order:confirmAction }
|
||||
0
src/Sylius/Bundle/SalesBundle/Resources/doc/index.rst
Normal file
0
src/Sylius/Bundle/SalesBundle/Resources/doc/index.rst
Normal file
19
src/Sylius/Bundle/SalesBundle/Resources/meta/LICENSE
Normal file
19
src/Sylius/Bundle/SalesBundle/Resources/meta/LICENSE
Normal file
|
|
@ -0,0 +1,19 @@
|
|||
Copyright (c) 2011 Paweł Jędrzejewski
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
in the Software without restriction, including without limitation the rights
|
||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
copies of the Software, and to permit persons to whom the Software is furnished
|
||||
to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in all
|
||||
copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
THE SOFTWARE.
|
||||
|
|
@ -0,0 +1,107 @@
|
|||
{% extends 'SyliusBackendBundle::layout.html.twig' %}
|
||||
|
||||
{% block content %}
|
||||
|
||||
<h1>Zarządzanie zamówieniami...</h1>
|
||||
|
||||
<p>Panel operacji na bieżących zamówieniach.</p>
|
||||
|
||||
<table cellspacing="1">
|
||||
|
||||
<col class="col1" /><col class="col2" /><col class="col1" /><col class="col2" /><col class="col2" /><col class="col2" /><col class="col1" /><col class="col1" />
|
||||
|
||||
<thead>
|
||||
|
||||
<tr>
|
||||
|
||||
<th style="width: 3%;">ID</th>
|
||||
|
||||
<th>klient</th>
|
||||
|
||||
<th>wartość</th>
|
||||
|
||||
<th>typ płatności</th>
|
||||
|
||||
<th>typ przesyłki</th>
|
||||
|
||||
<th>status</th>
|
||||
|
||||
<th style="text-align: center;">+ / -</th>
|
||||
|
||||
<th>opcje</th>
|
||||
|
||||
</tr>
|
||||
|
||||
</thead>
|
||||
|
||||
<tbody>
|
||||
|
||||
{% for order in orders %}
|
||||
|
||||
<tr{% if order.status == 5 %} class="row0"{% endif %}>
|
||||
|
||||
<td style="text-align: center;"> <strong> <?php echo $O['order_Id']; ?> </strong> </td>
|
||||
|
||||
<?php if($O['user_Id'] > 0): ?>
|
||||
|
||||
<td style="text-align: center;"> <a href="<?php dfUrl::_('ACP/klient/' . $O['user_Id'] . '.html'); ?>" class="button2"> Dane zamawiającego </a> </td>
|
||||
|
||||
<?php else: ?>
|
||||
|
||||
<td style="text-align: center;"> <?php echo $O['Name']; ?> <?php echo $O['Surname']; ?> </td>
|
||||
|
||||
<?php endif; ?>
|
||||
|
||||
<td> <strong> <?php echo Price($O['Value']); ?></strong> PLN. </td>
|
||||
|
||||
<td> <?php echo Order::Payment($O['Payment']); ?> </td>
|
||||
|
||||
<td> <?php echo Order::Delivery($O['Delivery']); ?> </td>
|
||||
|
||||
<td> <?php echo Order::Status($O['Status']); ?> </td>
|
||||
|
||||
<td style="text-align: center;">
|
||||
|
||||
<?php if($O['Status'] < 5): ?>
|
||||
|
||||
<a href="<?php dfUrl::_('ACP/zamowienia/uaktualnij/plus/' . $O['order_Id'] . '.html'); ?>" class="button2">+</a>
|
||||
|
||||
<?php endif; ?>
|
||||
|
||||
<?php if($O['Status'] > 0): ?>
|
||||
|
||||
<a href="<?php dfUrl::_('ACP/zamowienia/uaktualnij/minus/' . $O['order_Id'] . '.html'); ?>" class="button2">-</a>
|
||||
|
||||
<?php endif; ?>
|
||||
|
||||
</td>
|
||||
|
||||
<td style="text-align: center;">
|
||||
|
||||
<a href="<?php dfUrl::_('ACP/zamowienia/wyswietl/' . $O['order_Id'] . '.html'); ?>" class="button2">szczegóły</a>
|
||||
|
||||
<a href="<?php dfUrl::_('ACP/zamowienia/skasuj/' . $O['order_Id'] . '.html'); ?>" class="button2">usuń</a>
|
||||
|
||||
</td>
|
||||
|
||||
</tr>
|
||||
|
||||
{% else %}
|
||||
|
||||
<tr class="row0">
|
||||
|
||||
<td colspan="8">
|
||||
|
||||
Brak zamówień...
|
||||
|
||||
</td>
|
||||
|
||||
</tr>
|
||||
|
||||
{% endfor %}
|
||||
|
||||
</tbody>
|
||||
|
||||
</table>
|
||||
|
||||
{% endblock %}
|
||||
|
|
@ -0,0 +1,238 @@
|
|||
{% extends 'SyliusBackendBundle::layout.html.twig' %}
|
||||
|
||||
{% block content %}
|
||||
|
||||
<h1>Szczegóły zamówienia...</h1>
|
||||
|
||||
<p> Podstawowe informacje o zamówieniu i lista zakupionych przedmiotów. </p>
|
||||
|
||||
<fieldset>
|
||||
|
||||
<a href="{{ path('backend_order_delete', {'id': order.id}) }}" class="button2">usuń</a>
|
||||
|
||||
<a href="{{ path('backend_order_revert', {'id': order.id}) }}" class="button2">wycofaj</a>
|
||||
|
||||
</fieldset>
|
||||
|
||||
<fieldset>
|
||||
|
||||
<legend>Informacje o zamówieniu.</legend>
|
||||
|
||||
<dl>
|
||||
|
||||
<dt> <label>Identyfikator zamówienia</label>...</dt>
|
||||
|
||||
<dd> <strong>{{ order.id }}</strong> </dd>
|
||||
|
||||
</dl>
|
||||
|
||||
<dl>
|
||||
|
||||
<dt> <label>Data złożenia</label>...</dt>
|
||||
|
||||
<dd> {{ order.createdAt }} </dd>
|
||||
|
||||
</dl>
|
||||
|
||||
<dl>
|
||||
|
||||
<dt> <label>Status</label>...</dt>
|
||||
|
||||
<dd> {{ order.status }}... </dd>
|
||||
|
||||
</dl>
|
||||
|
||||
<dl>
|
||||
|
||||
<dt> <label>Zamawiający</label>... </dt>
|
||||
|
||||
<dd>
|
||||
|
||||
{{ order.user.name }} {{ order.user.surname }}
|
||||
|
||||
</dd>
|
||||
|
||||
</dl>
|
||||
|
||||
<dl>
|
||||
|
||||
<dt> <label>Wartość</label>...</dt>
|
||||
<dd> <strong>{{ order.value }}</strong> PLN!</dd>
|
||||
|
||||
</dl>
|
||||
|
||||
</fieldset>
|
||||
|
||||
<fieldset>
|
||||
|
||||
<legend>Informacje o dostawie i płatnościach.</legend>
|
||||
|
||||
<dl>
|
||||
|
||||
<dt> <label>Imię</label>...</dt>
|
||||
|
||||
<dd> {{ order.address.name }} </dd>
|
||||
|
||||
</dl>
|
||||
|
||||
<dl>
|
||||
|
||||
<dt> <label>Nazwisko</label>...</dt>
|
||||
|
||||
<dd> {{ order.address.surname }} </dd>
|
||||
|
||||
</dl>
|
||||
|
||||
<dl>
|
||||
|
||||
<dt> <label>Miejscowość</label>...</dt>
|
||||
|
||||
<dd> {{ order.address.city }} </dd>
|
||||
|
||||
</dl>
|
||||
|
||||
<dl>
|
||||
|
||||
<dt> <label>Adres</label>...</dt>
|
||||
|
||||
<dd> {{ order.address.street }} </dd>
|
||||
|
||||
</dl>
|
||||
|
||||
<dl>
|
||||
|
||||
<dt> <label>Kod pocztowy</label>...</dt>
|
||||
|
||||
<dd> {{ order.address.postcode }} </dd>
|
||||
|
||||
</dl>
|
||||
|
||||
<dl>
|
||||
|
||||
<dt> <label>Telefon kontaktowy</label>...</dt>
|
||||
|
||||
<dd> {{ order.address.phone }} </dd>
|
||||
|
||||
</dl>
|
||||
|
||||
<dl>
|
||||
|
||||
<dt> <label>E-mail kontaktowy</label>...</dt>
|
||||
|
||||
<dd> {{ order.address.email }} </dd>
|
||||
|
||||
</dl>
|
||||
|
||||
<dl>
|
||||
|
||||
<dt> <label>Typ dostawy</label>...</dt>
|
||||
|
||||
<dd> {{ order.delivery.title }} </dd>
|
||||
|
||||
</dl>
|
||||
|
||||
<dl>
|
||||
|
||||
<dt> <label>Typ płatności</label>...</dt>
|
||||
|
||||
<dd> {{ order.payment.title }} </dd>
|
||||
|
||||
</dl>
|
||||
|
||||
</fieldset>
|
||||
|
||||
<div class="infoBox" style="margin-left: 7px;">
|
||||
|
||||
Poniższe dane dotyczą tylko klientów hurtowych.
|
||||
|
||||
</div>
|
||||
|
||||
<fieldset>
|
||||
|
||||
<legend>Dane firmowe.</legend>
|
||||
|
||||
<dl>
|
||||
|
||||
<dt> <label>Nazwa</label>...</dt>
|
||||
|
||||
<dd> {{ order.address.company }} </dd>
|
||||
|
||||
</dl>
|
||||
|
||||
<dl>
|
||||
|
||||
<dt> <label>NIP</label>...</dt>
|
||||
|
||||
<dd> {{ order.address.nip }} </dd>
|
||||
|
||||
</dl>
|
||||
|
||||
</fieldset>
|
||||
|
||||
<table cellspacing="1">
|
||||
|
||||
<col class="col1" /> <col class="col2" /> <col class="col1" />
|
||||
|
||||
<thead>
|
||||
|
||||
<tr>
|
||||
|
||||
<th>fotografia</th>
|
||||
|
||||
<th>produkt</th>
|
||||
|
||||
<th>ilość</th>
|
||||
|
||||
</tr>
|
||||
|
||||
</thead>
|
||||
|
||||
<tbody>
|
||||
|
||||
{% for item in order.items %}
|
||||
|
||||
<tr style="border-bottom: 1px dotted #493355">
|
||||
|
||||
<td rowspan="2" style="padding: 0; width: 170px;"> </td>
|
||||
|
||||
<td style="border-right: 0; text-align: left; vertical-align: top;">
|
||||
|
||||
<strong><a href="{{ path('backend_product_show', {'id': item.product.id}) }}" class="productTitle">{{ item.product.title }}</a></strong> <br /><br />
|
||||
|
||||
{{ item.product.description }}
|
||||
|
||||
</td>
|
||||
|
||||
<td style="width: 1%; text-align: center;">
|
||||
|
||||
<strong>{{ item.quantity }}</strong> {{ item.product.sku }}
|
||||
|
||||
</td>
|
||||
|
||||
</tr>
|
||||
|
||||
<tr>
|
||||
|
||||
<td style="border-right: 0; text-align: left; padding-right: 0; vertical-align: bottom;" colspan="2">
|
||||
|
||||
<strong>Cena</strong>:
|
||||
|
||||
|
||||
|
||||
<br />
|
||||
|
||||
<strong>Dostępność</strong>:
|
||||
|
||||
|
||||
|
||||
</td>
|
||||
|
||||
</tr>
|
||||
|
||||
{% endfor %}
|
||||
|
||||
</tbody>
|
||||
|
||||
</table>
|
||||
|
||||
{% endblock %}
|
||||
31
src/Sylius/Bundle/SalesBundle/SyliusSalesBundle.php
Normal file
31
src/Sylius/Bundle/SalesBundle/SyliusSalesBundle.php
Normal file
|
|
@ -0,0 +1,31 @@
|
|||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of the Sylius package.
|
||||
*
|
||||
* (c) Paweł Jędrzejewski
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace Sylius\Bundle\SalesBundle;
|
||||
|
||||
use Symfony\Component\HttpKernel\Bundle\Bundle;
|
||||
use Symfony\Component\DependencyInjection\ContainerBuilder;
|
||||
use Sylius\Bundle\SalesBundle\DependencyInjection\Compiler\RegisterOperationsPass;
|
||||
|
||||
/**
|
||||
* Bundle of sales system.
|
||||
*
|
||||
* @author Paweł Jędrzejewski <pjedrzejewski@diweb.pl>
|
||||
*/
|
||||
class SyliusSalesBundle extends Bundle
|
||||
{
|
||||
public function build(ContainerBuilder $container)
|
||||
{
|
||||
parent::build($container);
|
||||
|
||||
$container->addCompilerPass(new RegisterOperationsPass());
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Reference in a new issue