diff --git a/lib/Alchemy/Phrasea/Controller/Prod/Basket.php b/lib/Alchemy/Phrasea/Controller/Prod/Basket.php index d0620af44d..394986d63f 100644 --- a/lib/Alchemy/Phrasea/Controller/Prod/Basket.php +++ b/lib/Alchemy/Phrasea/Controller/Prod/Basket.php @@ -68,12 +68,12 @@ class Basket implements ControllerProviderInterface } }); - $controllers->post('/{basket_id}/delete/', function(Application $app, $basket_id) use ($basket_controller) + $controllers->post('/{basket_id}/delete/', function(Application $app, Request $request, $basket_id) use ($basket_controller) { $basket = $basket_controller->getUserBasket($app['Core'], $basket_id); $em = $app['Core']->getEntityManager(); - + $em->remove($basket); $em->flush(); @@ -95,6 +95,43 @@ class Basket implements ControllerProviderInterface } }); + $controllers->post( + '/{basket_id}/{basket_element_id}/delete/' + , function(Application $app, Request $request, $basket_id, $basket_element_id) use ($basket_controller) + { + $basket = $basket_controller->getUserBasket($app['Core'], $basket_id); + + /* @var $em \Doctrine\ORM\EntityManager */ + $em = $app['Core']->getEntityManager(); + + foreach ($basket->getElements() as $basket_element) + { + /* @var $basket_element \Entities\BasketElement */ + if ($basket_element->getId() == $basket_element_id) + { + $em->remove($basket_element); + } + } + + $em->flush(); + + $data = array( + 'success' => true + , 'message' => _('Record removed from basket') + ); + + if ($request->getRequestFormat() == 'json') + { + $datas = $app['Core']['Serializer']->serialize($data, 'json'); + + return new Response($datas, 200, array('Content-type' => 'application/json')); + } + else + { + return new RedirectResponse('/'); + } + }); + $controllers->post('/{basket_id}/update/', function(Application $app, $basket_id) use ($basket_controller) @@ -105,7 +142,7 @@ class Basket implements ControllerProviderInterface $basket->setDescription($request->get('description')); $em = $app['Core']->getEntityManager(); - + $em->merge($basket); $em->flush(); @@ -151,7 +188,7 @@ class Basket implements ControllerProviderInterface $basket->setArchived(!!$request->get('archive')); $em = $app['Core']->getEntityManager(); - + $em->merge($basket); $em->flush(); @@ -182,11 +219,11 @@ class Basket implements ControllerProviderInterface $user = $app['Core']->getAuthenticatedUser(); /* @var $user \User_Adapter */ - + $em = $app['Core']->getEntityManager(); $n = 0; - + foreach (explode(';', $request->get('lst')) as $sbas_rec) { $sbas_rec = explode('_', $sbas_rec); @@ -214,7 +251,11 @@ class Basket implements ControllerProviderInterface $basket->addBasketElement($basket_element); $n++; } - catch (\Exception_NotFound $e) + catch (Exception $e) + { + + } + catch (\PDOException $e) { } @@ -251,7 +292,7 @@ class Basket implements ControllerProviderInterface $controllers->get('/{basket_id}/', function(Application $app, $basket_id) use ($basket_controller) { $em = $app['Core']->getEntityManager(); - + $basket = $basket_controller->getUserBasket($app['Core'], $basket_id); $basket->setIsRead(true); @@ -260,7 +301,7 @@ class Basket implements ControllerProviderInterface $em->flush(); $twig = new \supertwig(); - + $html = $twig->render('prod/basket.twig', array('basket' => $basket)); return new Response($html); diff --git a/lib/Alchemy/Phrasea/Core/Service/Doctrine.php b/lib/Alchemy/Phrasea/Core/Service/Doctrine.php index e8a57038ad..425f9dc874 100644 --- a/lib/Alchemy/Phrasea/Core/Service/Doctrine.php +++ b/lib/Alchemy/Phrasea/Core/Service/Doctrine.php @@ -34,7 +34,7 @@ class Doctrine $config = new \Doctrine\ORM\Configuration(); - $config->setMetadataCacheImpl(new \Doctrine\Common\Cache\ApcCache); + $config->setMetadataCacheImpl(new \Doctrine\Common\Cache\ArrayCache); $chainDriverImpl = new \Doctrine\ORM\Mapping\Driver\DriverChain(); diff --git a/templates/web/prod/Baskets/Story.html.twig b/templates/web/prod/Baskets/Story.html.twig new file mode 100644 index 0000000000..9aebdec8d8 --- /dev/null +++ b/templates/web/prod/Baskets/Story.html.twig @@ -0,0 +1,74 @@ +
+{% set basket_length = basket.getElements()|length %} +
+ + + + + + {% if user.ACL().has_right('modifyrecord') %} + + {% endif %} + + {% if user.ACL().has_right('changestatus') %} + + {% endif %} + + {% if user.ACL().has_right('deleterecord') and user.ACL().has_right('addrecord') %} + + {% endif %} + + {% if user.ACL().has_right('push') %} + + {% endif %} + {% if user.ACL().has_right('bas_chupub') %} + + + {% endif %} + + {% if user.ACL().has_right('doctools') %} + + {% endif %} + + +
+
{% trans 'Certaines donnees du panier ont change' %} {% trans 'rafraichir' %}
+{% if basket_length == 0 %} +
+{% endif %} + +{% if basket.is_grouping() %} + {% set basket_scope = 'groupings'%} +{% else %} + {% set basket_scope = 'objects'%} +{% endif %} + +{% if basket.is_my_valid() %} + {% include 'prod/basket_as_validation.twig'%} +{% else %} + {% include 'prod/basket_default.twig'%} +{% endif %} + +
+ +