alert profilée par niveau01 (fixes #62)
This commit is contained in:
parent
6741bfffe6
commit
6729035f15
|
@ -91,6 +91,10 @@ class Niveau01
|
|||
*/
|
||||
protected $items;
|
||||
|
||||
/**
|
||||
* @ORM\ManyToMany(targetEntity="Cadoles\PortalBundle\Entity\Alert", mappedBy="niveau01s")
|
||||
*/
|
||||
protected $alerts;
|
||||
|
||||
/**
|
||||
* Constructor
|
||||
|
@ -427,4 +431,38 @@ class Niveau01
|
|||
{
|
||||
return $this->items;
|
||||
}
|
||||
|
||||
/**
|
||||
* Add alert
|
||||
*
|
||||
* @param \Cadoles\PortalBundle\Entity\Alert $alert
|
||||
*
|
||||
* @return Niveau01
|
||||
*/
|
||||
public function addAlert(\Cadoles\PortalBundle\Entity\Alert $alert)
|
||||
{
|
||||
$this->alerts[] = $alert;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Remove alert
|
||||
*
|
||||
* @param \Cadoles\PortalBundle\Entity\Alert $alert
|
||||
*/
|
||||
public function removeAlert(\Cadoles\PortalBundle\Entity\Alert $alert)
|
||||
{
|
||||
$this->alerts->removeElement($alert);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get alerts
|
||||
*
|
||||
* @return \Doctrine\Common\Collections\Collection
|
||||
*/
|
||||
public function getAlerts()
|
||||
{
|
||||
return $this->alerts;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -274,7 +274,7 @@ span.item-drag {
|
|||
.grid-item .item-link img {
|
||||
display: block;
|
||||
max-width: 100%;
|
||||
max-height: 110px;
|
||||
//max-height: 110px;
|
||||
height: auto;
|
||||
}
|
||||
|
||||
|
@ -500,7 +500,7 @@ a.item-heart {
|
|||
word-wrap: break-word;
|
||||
width: 100%;
|
||||
display: block;
|
||||
line-height: initial;
|
||||
line-height: 14px;
|
||||
padding: 0px;
|
||||
}
|
||||
|
||||
|
@ -513,9 +513,9 @@ a.item-heart {
|
|||
|
||||
.grid .grid-preview .grid-item-title small {
|
||||
margin-bottom: 10px;
|
||||
font-size:9px;
|
||||
}
|
||||
|
||||
|
||||
@media (max-width: 991px) {
|
||||
.grid .grid-preview {
|
||||
width:32.666666667%;
|
||||
|
|
|
@ -64,14 +64,7 @@ body.simple {
|
|||
min-width: 138px;
|
||||
}
|
||||
|
||||
.grid .grid-preview .grid-item-title {
|
||||
font-size:14px;
|
||||
line-height: 8px;
|
||||
}
|
||||
|
||||
.grid .grid-preview .grid-item-title small {
|
||||
font-size:9px;
|
||||
}
|
||||
|
||||
.widget-bordered .grid-preview img {
|
||||
border-radius: 0px;
|
||||
|
|
|
@ -69,7 +69,7 @@ class AlertController extends Controller
|
|||
$data = new Alert();
|
||||
|
||||
// Création du formulaire
|
||||
$form = $this->createForm(AlertType::class,$data,array("mode"=>"submit"));
|
||||
$form = $this->createForm(AlertType::class,$data,array("mode"=>"submit","labelniveau01" => $this->GetParameter("labelsniveau01")));
|
||||
|
||||
// Récupération des data du formulaire
|
||||
$form->handleRequest($request);
|
||||
|
@ -111,7 +111,8 @@ class AlertController extends Controller
|
|||
|
||||
// Création du formulaire
|
||||
$form = $this->createForm(AlertType::class,$data,array(
|
||||
"mode" => "update"
|
||||
"mode" => "update",
|
||||
"labelniveau01" => $this->GetParameter("labelsniveau01")
|
||||
));
|
||||
|
||||
// Récupération des data du formulaire
|
||||
|
|
|
@ -737,6 +737,7 @@ class PagewidgetController extends Controller
|
|||
// Profilage
|
||||
$user=$this->getUser();
|
||||
$roles=($user?$user->getRoles():["ROLE_ANONYME"]);
|
||||
$niveau01=($user?$user->getNiveau01():null);
|
||||
$groups=($user?$user->getGroups():[]);
|
||||
|
||||
// Initialisation du calcul des alerts
|
||||
|
@ -765,6 +766,28 @@ class PagewidgetController extends Controller
|
|||
}
|
||||
}
|
||||
|
||||
// Récupération par Niveau01
|
||||
$qb = $em->createQueryBuilder();
|
||||
$qb->select('alert')
|
||||
->from("CadolesPortalBundle:Alert", 'alert')
|
||||
->where(":niveau01 MEMBER OF alert.niveau01s")
|
||||
->andWhere('alert.publishedat <= :today')
|
||||
->andWhere($qb->expr()->orX(
|
||||
$qb->expr()->gt('alert.unpublishedat', ':today'),
|
||||
$qb->expr()->isNull('alert.unpublishedat')
|
||||
))
|
||||
->setParameter("niveau01",$niveau01)
|
||||
->setParameter('today', date('Y-m-d'));
|
||||
|
||||
if($idalertcategory && $alertcategoryfilter) {
|
||||
$qb->andWhere("alert.alertcategory=:alertcategory")
|
||||
->setParameter("alertcategory",$alertcategoryfilter);
|
||||
}
|
||||
$alertsniveau01s=$qb->getQuery()->getResult();
|
||||
foreach($alertsniveau01s as $alertsniveau01) {
|
||||
if(!$alerts->contains($alertsniveau01s)) $alerts->add($alertsniveau01);
|
||||
}
|
||||
|
||||
// Récupération des alerts par group
|
||||
foreach($groups as $group) {
|
||||
$qb = $em->createQueryBuilder();
|
||||
|
|
|
@ -82,6 +82,16 @@ class Alert
|
|||
*/
|
||||
protected $groups;
|
||||
|
||||
/**
|
||||
* @ORM\ManyToMany(targetEntity="Cadoles\CoreBundle\Entity\Niveau01", inversedBy="alerts", cascade={"persist"})
|
||||
* @ORM\JoinTable(name="alertniveau01",
|
||||
* joinColumns={@ORM\JoinColumn(name="alert", referencedColumnName="id")},
|
||||
* inverseJoinColumns={@ORM\JoinColumn(name="niveau01", referencedColumnName="id")}
|
||||
* )
|
||||
*/
|
||||
protected $niveau01s;
|
||||
|
||||
|
||||
// Is Online
|
||||
public function isOnline()
|
||||
{
|
||||
|
@ -346,4 +356,38 @@ class Alert
|
|||
{
|
||||
return $this->groups;
|
||||
}
|
||||
|
||||
/**
|
||||
* Add niveau01
|
||||
*
|
||||
* @param \Cadoles\CoreBundle\Entity\Niveau01 $niveau01
|
||||
*
|
||||
* @return Alert
|
||||
*/
|
||||
public function addNiveau01(\Cadoles\CoreBundle\Entity\Niveau01 $niveau01)
|
||||
{
|
||||
$this->niveau01s[] = $niveau01;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Remove niveau01
|
||||
*
|
||||
* @param \Cadoles\CoreBundle\Entity\Niveau01 $niveau01
|
||||
*/
|
||||
public function removeNiveau01(\Cadoles\CoreBundle\Entity\Niveau01 $niveau01)
|
||||
{
|
||||
$this->niveau01s->removeElement($niveau01);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get niveau01s
|
||||
*
|
||||
* @return \Doctrine\Common\Collections\Collection
|
||||
*/
|
||||
public function getNiveau01s()
|
||||
{
|
||||
return $this->niveau01s;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -57,6 +57,24 @@ class AlertType extends AbstractType
|
|||
"disabled" => ($options["mode"]=="delete"?true:false),
|
||||
])
|
||||
|
||||
->add('niveau01s', Select2EntityType::class, [
|
||||
'label' => 'Visible pour les '.$options["labelniveau01"],
|
||||
'class' => 'CadolesCoreBundle:Niveau01',
|
||||
'text_property' => 'label',
|
||||
'multiple' => true,
|
||||
'remote_route' => 'cadoles_core_ajax_niveau01_list',
|
||||
'primary_key' => 'id',
|
||||
'text_property' => 'label',
|
||||
'minimum_input_length' => 0,
|
||||
'page_limit' => 100,
|
||||
'allow_clear' => true,
|
||||
'delay' => 250,
|
||||
'cache' => false,
|
||||
'cache_timeout' => 60000,
|
||||
'language' => 'fr',
|
||||
'placeholder' => 'Selectionner des '.$options["labelniveau01"],
|
||||
])
|
||||
|
||||
->add('groups', Select2EntityType::class, [
|
||||
'label' => 'Visible pour les Groupes',
|
||||
'class' => 'CadolesCoreBundle:Group',
|
||||
|
@ -106,6 +124,7 @@ class AlertType extends AbstractType
|
|||
$resolver->setDefaults([
|
||||
'data_class' => 'Cadoles\PortalBundle\Entity\Alert',
|
||||
'mode' => "string",
|
||||
'labelniveau01' => "string",
|
||||
]);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -60,6 +60,7 @@
|
|||
</div>
|
||||
<div class="col-md-4">
|
||||
{{ form_row(form.roles) }}
|
||||
{{ form_row(form.niveau01s) }}
|
||||
{{ form_row(form.groups) }}
|
||||
</div>
|
||||
|
||||
|
|
Loading…
Reference in New Issue