compteur de visite group (ref #151)
This commit is contained in:
parent
e18790790b
commit
e85f74cda5
|
@ -349,7 +349,7 @@ class GroupController extends Controller
|
|||
// Avatar
|
||||
$avatar="<img onClick='seeUser(".$data->getId().")' src='/".$this->container->getParameter('alias')."/uploads/avatar/".$data->getAvatar()."' style='width:30px;background-color:#337ab7;margin:auto;display:block;cursor:pointer;'>";
|
||||
|
||||
array_push($output["data"],array("DT_RowId"=>"user".$data->getId(),$action,$avatar,$data->getUsername(),$data->getEmail(),$fgmanager));
|
||||
array_push($output["data"],array("DT_RowId"=>"user".$data->getId(),$action,$avatar,$data->getUsername(),$data->getEmail(),"",$fgmanager));
|
||||
}
|
||||
|
||||
// Retour
|
||||
|
@ -459,11 +459,11 @@ class GroupController extends Controller
|
|||
$qb->setParameter("groupid",$id);
|
||||
switch($order[0]["column"]) {
|
||||
case 2 :
|
||||
$qb->orderBy('user.username',$order[0]["dir"]);
|
||||
$qb->orderBy('user.username',$order[0]["dir"]);
|
||||
break;
|
||||
|
||||
case 3 :
|
||||
$qb->orderBy('user.email',$order[0]["dir"]);
|
||||
$qb->orderBy('user.email',$order[0]["dir"]);
|
||||
break;
|
||||
}
|
||||
|
||||
|
@ -491,9 +491,14 @@ class GroupController extends Controller
|
|||
if($fgproprio) $fgmanager="Propriétaire du groupe";
|
||||
|
||||
}
|
||||
|
||||
|
||||
// Visite
|
||||
$visite="";
|
||||
if($usergroup->getVisitedate()) {
|
||||
$visite=$usergroup->getVisitedate()->format("d/m/Y H:i")."<br>nb = ".$usergroup->getVisitecpt();
|
||||
}
|
||||
|
||||
array_push($output["data"],array("DT_RowId"=>"user".$data->getId(),$action,$avatar,$data->getUsername(),$data->getEmail(),$fgmanager));
|
||||
array_push($output["data"],array("DT_RowId"=>"user".$data->getId(),$action,$avatar,$data->getUsername(),$data->getEmail(),$visite,$fgmanager));
|
||||
}
|
||||
|
||||
// Retour
|
||||
|
@ -974,8 +979,8 @@ class GroupController extends Controller
|
|||
public function usergroupexportAction($id,Request $request, $access="config")
|
||||
{
|
||||
// Récupération de l'enregistrement courant
|
||||
$data=$this->getData($id);
|
||||
$this->canManager($data,$access);
|
||||
$group=$this->getData($id);
|
||||
$this->canManager($group,$access);
|
||||
|
||||
$em = $this->getDoctrine()->getManager();
|
||||
$dir = $this->get('kernel')->getRootDir() . '/../uploads/export/';
|
||||
|
@ -989,7 +994,7 @@ class GroupController extends Controller
|
|||
$e = '"'; // this is the default but i like to be explicit
|
||||
|
||||
// Entête de colonne
|
||||
$data=["id","Login","Nom","Prénom","Email","Téléphone",$this->getParameter("labelniveau01"),$this->getParameter("labelniveau02"),"Métier","Fonction","Nom Usage","Autres Prénom","Sexe","Adresse","Date Naissance","Pays Naissance","Ville Naissance"];
|
||||
$data=["id","Login","Nom","Prénom","Email","Téléphone",$this->getParameter("labelniveau01"),$this->getParameter("labelniveau02"),"Métier","Fonction","Nom Usage","Autres Prénom","Sexe","Adresse","Date Naissance","Pays Naissance","Ville Naissance","Date Visite","Nb Visites"];
|
||||
fputcsv($csvh, $data, $d, $e);
|
||||
|
||||
// Liste des utilisateurs en fonction du role de l'utilisateur en cours
|
||||
|
@ -1040,9 +1045,18 @@ class GroupController extends Controller
|
|||
"birthdate"=>($user->getBirthdate()?$user->getBirthdate()->format("d/m/Y"):""),
|
||||
"birthcountry"=>($user->getBirthcountry()?$user->getBirthcountry()->getLabel():""),
|
||||
"birthplace"=>($user->getBirthplace()?$user->getBirthplace()->getLabel():""),
|
||||
|
||||
"visitedate"=>"",
|
||||
"visitecpt"=>"",
|
||||
];
|
||||
|
||||
$usergroup=$em->getRepository("CadolesCoreBundle:UserGroup")->findOneBy(["user"=>$user,"group"=>$group]);
|
||||
if($usergroup) {
|
||||
if($usergroup->getVisitedate()) {
|
||||
$data["visitedate"]=$usergroup->getVisitedate()->format("d/m/Y H:i");
|
||||
$data["visitecpt"]=$usergroup->getVisitecpt();
|
||||
}
|
||||
}
|
||||
|
||||
fputcsv($csvh, $data, $d, $e);
|
||||
}
|
||||
fclose($csvh);
|
||||
|
|
|
@ -44,7 +44,17 @@ class UserGroup
|
|||
* @ORM\Column(type="string", length=60, nullable=true)
|
||||
*/
|
||||
private $keyvalue;
|
||||
|
||||
|
||||
/**
|
||||
* @ORM\Column(type="datetime", nullable=true)
|
||||
*/
|
||||
private $visitedate;
|
||||
|
||||
/**
|
||||
* @ORM\Column(type="integer", nullable=true)
|
||||
*/
|
||||
private $visitecpt;
|
||||
|
||||
/**
|
||||
* Get id
|
||||
*
|
||||
|
@ -150,4 +160,52 @@ class UserGroup
|
|||
{
|
||||
return $this->keyvalue;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set visitedate
|
||||
*
|
||||
* @param \DateTime $visitedate
|
||||
*
|
||||
* @return UserGroup
|
||||
*/
|
||||
public function setVisitedate($visitedate)
|
||||
{
|
||||
$this->visitedate = $visitedate;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get visitedate
|
||||
*
|
||||
* @return \DateTime
|
||||
*/
|
||||
public function getVisitedate()
|
||||
{
|
||||
return $this->visitedate;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set visitecpt
|
||||
*
|
||||
* @param integer $visitecpt
|
||||
*
|
||||
* @return UserGroup
|
||||
*/
|
||||
public function setVisitecpt($visitecpt)
|
||||
{
|
||||
$this->visitecpt = $visitecpt;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get visitecpt
|
||||
*
|
||||
* @return integer
|
||||
*/
|
||||
public function getVisitecpt()
|
||||
{
|
||||
return $this->visitecpt;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -287,7 +287,7 @@
|
|||
|
||||
if($curentuser!="anon.") {
|
||||
$visitedate=$curentuser->getVisitedate();
|
||||
$visitedate->add(new \DateInterval("PT1H"));
|
||||
if($visitedate) $visitedate->add(new \DateInterval("PT1H"));
|
||||
$now=new \DateTime();
|
||||
if($visitedate<$now) {
|
||||
$curentuser->setVisitedate($now);
|
||||
|
|
|
@ -29,7 +29,8 @@
|
|||
<th width="70px" class="no-sort">Action</th>
|
||||
<th width="70px" class="no-sort">Avatar</th>
|
||||
<th width="200px">Login</th>
|
||||
<th>Email</th>
|
||||
<th>Email</th>
|
||||
<th class="no-sort">Visite</th>
|
||||
{% if group.fgcanshare %}
|
||||
<th class="no-sort">Manager</th>
|
||||
{% endif %}
|
||||
|
@ -56,6 +57,7 @@
|
|||
<th width="70px" class="no-sort">Avatar</th>
|
||||
<th width="200px">Login</th>
|
||||
<th>Email</th>
|
||||
<th class="no-sort">Visite</th>
|
||||
{% if group.fgcanshare %}
|
||||
<th class="no-sort">Manager</th>
|
||||
{% endif %}
|
||||
|
|
|
@ -515,6 +515,24 @@ class PageController extends Controller
|
|||
}
|
||||
*/
|
||||
|
||||
// Compteur de visite
|
||||
if($this->getUser()) {
|
||||
$group=$em->getRepository("CadolesCoreBundle:Group")->find($groupid);
|
||||
if($group && $group->getFgcanshare()) {
|
||||
$usergroup=$em->getRepository("CadolesCoreBundle:UserGroup")->findoneby(["group"=>$group,"user"=>$this->getUser()]);
|
||||
if($usergroup) {
|
||||
$visitedate=$usergroup->getVisitedate();
|
||||
if($visitedate) $visitedate->add(new \DateInterval("PT1H"));
|
||||
$now=new \DateTime();
|
||||
if($visitedate<$now) {
|
||||
$usergroup->setVisitedate($now);
|
||||
$usergroup->setVisitecpt($usergroup->getVisitecpt()+1);
|
||||
$em->persist($usergroup);
|
||||
$em->flush();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Type Calendrier
|
||||
if($entity->getPageCategory()->getId()==-100) {
|
||||
|
|
Loading…
Reference in New Issue