Basket route

This commit is contained in:
Romain Neutron
2011-12-19 19:08:44 +01:00
parent e1dce46c9c
commit 8b6278cb2a
3 changed files with 125 additions and 10 deletions

View File

@@ -68,7 +68,7 @@ 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);
@@ -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)
@@ -214,7 +251,11 @@ class Basket implements ControllerProviderInterface
$basket->addBasketElement($basket_element);
$n++;
}
catch (\Exception_NotFound $e)
catch (Exception $e)
{
}
catch (\PDOException $e)
{
}

View File

@@ -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();

View File

@@ -0,0 +1,74 @@
<div style="margin:0 7px;overflow:hidden;">
{% set basket_length = basket.getElements()|length %}
<div class="tools">
<button class="ui-corner-all TOOL_disktt_btn basket_window" title="{% trans 'action : exporter' %}">
<img src="/skins/prod/000000/images/disktt_history.gif"/>
</button>
<button class="ui-corner-all TOOL_print_btn basket_window" title="{% trans 'action : print' %}">
<img src="/skins/prod/000000/images/print_history.gif"/>
</button>
{% if user.ACL().has_right('modifyrecord') %}
<button class="ui-corner-all TOOL_ppen_btn basket_window" title="{% trans 'action : editer' %}">
<img src="/skins/prod/000000/images/ppen_history.gif"/>
</button>
{% endif %}
{% if user.ACL().has_right('changestatus') %}
<button class="ui-corner-all TOOL_chgstatus_btn basket_window" title="{% trans 'action : status' %}">
<img src="/skins/prod/000000/images/chgstatus_history.gif"/>
</button>
{% endif %}
{% if user.ACL().has_right('deleterecord') and user.ACL().has_right('addrecord') %}
<button class="ui-corner-all TOOL_chgcoll_btn basket_window" title="{% trans 'action : collection' %}">
<img src="/skins/prod/000000/images/chgcoll_history.gif"/>
</button>
{% endif %}
{% if user.ACL().has_right('push') %}
<button class="ui-corner-all TOOL_pushdoc_btn basket_window" title="{% trans 'action : push' %}">
<img src="/skins/prod/000000/images/pushdoc_history.gif"/>
</button>
{% endif %}
{% if user.ACL().has_right('bas_chupub') %}
<button class="ui-corner-all TOOL_bridge_btn basket_window" title="{% trans 'action : bridge' %}">
<img src="/skins/icons/door.png"/>
</button>
<button class="ui-corner-all TOOL_publish_btn basket_window" title="{% trans 'action : publier' %}">
<img src="/skins/icons/rss16.png"/>
</button>
{% endif %}
{% if user.ACL().has_right('doctools') %}
<button class="ui-corner-all TOOL_imgtools_btn basket_window" title="{% trans 'action : outils' %}">
<img src="/skins/prod/000000/images/imgtools_history.gif"/>
</button>
{% endif %}
<button class="ui-corner-all TOOL_trash_btn basket_window" title="{% trans 'action : supprimer' %}">
<img src="/skins/icons/delete.png"/>
</button>
</div>
<div class="alert_datas_changed ui-corner-all">{% trans 'Certaines donnees du panier ont change' %} <a class="basket_refresher" href="#">{% trans 'rafraichir' %}</a></div>
{% if basket_length == 0 %}
<div style="height:120px;"></div>
{% 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 %}
</div>