lié les taches aux agendas (ref #222)

This commit is contained in:
afornerot 2021-03-18 17:14:05 +01:00
parent 0886f96cf4
commit e9242e4b0c
3 changed files with 79 additions and 3 deletions

View File

@ -73,11 +73,37 @@ class CalendareventController extends Controller
array_push($events,$tmp);
array_push($eventids,$tmp["id"]);
}
// On recherche les taches associées aux groupes du calendrier
if($this->getUser()) {
$groups=$calendar->getGroups();
foreach($groups as $group) {
$projects=$group->getProjects();
foreach($projects as $project) {
$projecttasks = $this->getDoctrine()->getRepository("CadolesPortalBundle:Projecttask")->getProjectTasksByDate($project,$this->getUser(),$start,$end);
foreach($projecttasks as $projecttask) {
$tmp=[];
$tmp['id'] = "TASK".strval($projecttask->getId());
$tmp['title'] = "TACHE = ".$projecttask->getName();
$tmp['description'] = $projecttask->getDescription();
$tmp['start'] = $projecttask->getEnd()->format("Y-m-d\TH:i:s");
$tmp['end'] = $projecttask->getEnd()->format("Y-m-d\TH:i:s");
$tmp['color'] = "#".$this->get('session')->get('color')["main"];
$tmp['allDay'] = true;
$tmp['calendar'] = $project->getId();
$tmp['name'] = $project->getName()." - Tache";
$tmp['editable'] = false;
array_push($events,$tmp);
array_push($eventids,$tmp["id"]);
}
}
}
}
}
// On récupére les évenement partagé de l'utilisateur
if($this->getUser()) {
$calendarevents = $this->getDoctrine()->getRepository("CadolesPortalBundle:Calendarevent")->getCalendareventGroupsShareByDate($this->getUser(),$start,$end);
foreach($calendarevents as $calendarevent) {

View File

@ -100,12 +100,10 @@ class CalendareventRepository extends EntityRepository
// On récupère soit les calendriers du group en cours soit l'ensemble des calendriers de l'utilisateur
if($usage=="group") {
$calendars=$em->getRepository("CadolesPortalBundle:Calendar")->getCalendarsGroup($user,$group);
if($calendars) $firstcalendar=$calendars[0]->getId();
}
else {
$em->getRepository("CadolesPortalBundle:Calendar")->getCalendarsUser($user,$calendarssuser,$calendarsadmin,$calendarsshared);
$calendars=array_merge($calendarssuser,$calendarsadmin->toArray(),$calendarsshared);
$firstcalendar="all";
}
// Début & fin
@ -176,6 +174,41 @@ class CalendareventRepository extends EntityRepository
}
}
}
// On récupère les taches associé à l'utilisateur
if($user) {
if($usage=="group") {
$projects=$em->getRepository("CadolesPortalBundle:Project")->getProjectsGroup($user,$group);
if($projects) $firstproject=$projects[0]->getId();
}
else {
$em->getRepository("CadolesPortalBundle:Project")->getProjectsUser($user,$projectssuser,$projectsadmin,$projectsshared);
$projects=array_merge($projectssuser,$projectsadmin->toArray(),$projectsshared);
$firstcalendar="all";
}
foreach($projects as $project) {
$projecttasks = $em->getRepository("CadolesPortalBundle:Projecttask")->getProjectTasksByDate($project,$user,$start,$end);
foreach($projecttasks as $projecttask) {
$tmp=[];
$tmp['id'] = "TASK".strval($projecttask->getId());
$tmp['title'] = $projecttask->getName();
$tmp['description'] = $projecttask->getDescription();
$tmp['start'] = $projecttask->getEnd();
$tmp['end'] = $projecttask->getEnd();
$tmp['color'] = "#".$sessioncolor;
$tmp['allDay'] = true;
$tmp['calendar'] = $project->getId();
$tmp['name'] = $project->getName()." - Tache";
$tmp['editable'] = false;
array_push($events,$tmp);
array_push($eventids,$tmp["id"]);
}
}
}
return $events;
}
}

View File

@ -25,4 +25,21 @@ class ProjecttaskRepository extends EntityRepository
->setFirstResult($start)->setMaxResults($length)
->getQuery()->getResult();
}
public function getProjectTasksByDate($project,$user,$start,$end)
{
$projecttasks=$this->createQueryBuilder('projecttask')
->where('projecttask.project=:project')
->andWhere('projecttask.owner=:user OR projecttask.user=:user')
->andWhere('projecttask.end>=:start')
->andWhere('projecttask.end<=:end')
->setParameter('project',$project)
->setParameter('user',$user)
->setParameter('start',$start)
->setParameter('end',$end)
->OrderBy('projecttask.end', 'ASC')
->getQuery()->getResult();
return $projecttasks;
}
}