Commit 742489ea authored by Mat's avatar Mat

hop

parent d8486d42
......@@ -9,33 +9,27 @@ class OffreLegumesAPIController extends MasterAPIController
/**
* @param $id
* @return \Symfony\Component\HttpFoundation\JsonResponse
* @throws \Doctrine\ORM\NonUniqueResultException
*/
public function readAction($id)
{
$em = $this->getDoctrine()->getManager();
$offre = $em->getRepository('PotageBundle:Offre')->findOneForAPIRead($id);
// TODO utilise actuellement le repository d'une autre action !
//$sorted = $offre->getSorted();
//if (count($sorted) > 0) {
// $legumes = $em->getRepository('PotageBundle:OffreLegumes')->findAllForSortedRead($id, $sorted);
$legumes = $em->getRepository('PotageBundle:OffreLegumes')->findAllForRead($id);
$sorted = explode(',', $offre->getSorted());
if (count($offre->getSorted()) > 0)
{
$legume = array();
foreach ($sorted as $item)
/*
$offre = $em->getRepository('PotageBundle:Offre')->findOneForAPIRead($id);
// TODO utilise actuellement le repository d'une autre action !
$sorted = $offre->getSorted();
if (count($sorted) > 0)
{
$legume[] = $em->getRepository('PotageBundle:OffreLegumes')->findOneForSortedRead($item);
$legumes = $em->getRepository('PotageBundle:OffreLegumes')->findAllForSortedRead($id, $sorted);
}
$legumes = $legume;
}
else {
$legumes = $em->getRepository('PotageBundle:OffreLegumes')->findAllForRead($id);
}
else {
dump($legumes);
}
*/
return $this->api($legumes);
}
}
File mode changed from 100644 to 100755
......@@ -68,6 +68,7 @@ class OffreLegumesRepository extends \Doctrine\ORM\EntityRepository
* @param $id_offre = '22'
* @param $sorted = '20,26,22,27,45,46'
*
*/
//1
$qb = $this->createQueryBuilder('ol')
......@@ -76,17 +77,16 @@ class OffreLegumesRepository extends \Doctrine\ORM\EntityRepository
'ol.quantiteMin', 'ol.quantiteMax', 'ol.quantiteStep', 'ol.prixUnitaire', 'ol.unite'
)
->where('ol.offre = :id_offre')
->add('orderBy',
$qb->expr()->field('ol.id', ':sorted')
)
//->add('orderBy',
// $qb->expr()->field('ol.id', ':sorted')
//)
//->orderBy(FIELD( ol.id, :sorted))
->setParameters(array(
':id_offre' => $id_offre,
':sorted' => $sorted
// ':sorted' => $sorted
))
;
return $qb->getQuery()->getResult();
*/
/*
//2
......@@ -103,21 +103,8 @@ class OffreLegumesRepository extends \Doctrine\ORM\EntityRepository
))
->getResult();
*/
return null;
}
/**
* @param $id_offre
* @param $id
* @return mixed
* @throws \Doctrine\ORM\NonUniqueResultException
*/
public function findOneForSortedRead($id)
{
return $this->createQueryBuilder('ol')
->where('ol.id = :id')
->setParameter(':id', $id)
->getQuery()
->getOneOrNullResult();
}
}
......@@ -37,11 +37,11 @@
<div class="col right hd-1">
<div style="margin-top: 0.65em;">
{#
#}
<a href="javascript: void(0);" class="btn btn-outline-dark mb-2 btn-sm btn-reload">
<i class="fas fa-sync-alt"></i>
Rafraîchir la liste
</a>
#}
</div>
</div>
</div>
......@@ -406,6 +406,18 @@
reloadTables();
/*
* Bouton pour recharger la page
*/
let reloadBtns = document.querySelectorAll('.btn-reload');
reloadBtns.forEach(function(reloadBtn) {
reloadBtn.addEventListener('click', function()
{
reloadTables();
});
});
/*
* Ajouter une nouvelle offre
*/
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment