correction affectation utilisateur, et ajout vue caendrier
This commit is contained in:
@@ -35,6 +35,48 @@ class TimerController extends AbstractController
|
||||
]);
|
||||
}
|
||||
|
||||
public function view(Request $request)
|
||||
{
|
||||
$em = $this->getDoctrine()->getManager();
|
||||
|
||||
$iduser = $this->get("session")->get("iduser");
|
||||
$user = $em->getRepository("App:User")->find($iduser);
|
||||
$tasks = $em->getRepository("App:Task")->findAll();
|
||||
$timers = $em->getRepository("App:Timer")->findBy(["user"=>$iduser]);
|
||||
|
||||
return $this->render($this->render.'list.cal.html.twig',[
|
||||
"useheader" => true,
|
||||
"usesidebar" => true,
|
||||
"user" => $user,
|
||||
"tasks" => $tasks,
|
||||
"timers" => $timers,
|
||||
]);
|
||||
}
|
||||
|
||||
public function load(Request $request)
|
||||
{
|
||||
$em = $this->getDoctrine()->getManager();
|
||||
$tbtimers=[];
|
||||
|
||||
// Evenements
|
||||
$iduser=$this->get("session")->get("iduser");
|
||||
if($iduser=="all")
|
||||
$timers=$em->getRepository("App:Timer")->findAll();
|
||||
else {
|
||||
$iduser=$this->get("session")->get("iduser");
|
||||
$user=$em->getRepository("App:User")->find($iduser);
|
||||
$timers=$em->getRepository("App:Timer")->findBy(["user"=>$user]);
|
||||
}
|
||||
|
||||
foreach($timers as $timer) {
|
||||
$tmp=$this->formatTimer($timer);
|
||||
array_push($tbtimers,$tmp);
|
||||
}
|
||||
|
||||
// Retour
|
||||
return new Response(json_encode($tbtimers));
|
||||
}
|
||||
|
||||
public function create(Request $request)
|
||||
{
|
||||
// Initialisation de l'enregistrement
|
||||
@@ -62,11 +104,15 @@ class TimerController extends AbstractController
|
||||
$output=["return"=>"OK"];
|
||||
return new Response(json_encode($output));
|
||||
}
|
||||
|
||||
public function submit(Request $request)
|
||||
{
|
||||
// Initialisation de l'enregistrement
|
||||
$em = $this->getDoctrine()->getManager();
|
||||
$data = new Entity();
|
||||
|
||||
$iduser = $this->get("session")->get("iduser");
|
||||
$user = $em->getRepository("App:User")->find($iduser);
|
||||
|
||||
// Création du formulaire
|
||||
$form = $this->createForm(Form::class,$data,array("mode"=>"submit"));
|
||||
@@ -79,7 +125,8 @@ class TimerController extends AbstractController
|
||||
|
||||
// Sur validation
|
||||
if ($form->get('submit')->isClicked() && $form->isValid()) {
|
||||
$data = $form->getData();
|
||||
$data = $form->getData();
|
||||
$data->setUser($user);
|
||||
$em->persist($data);
|
||||
$em->flush();
|
||||
|
||||
@@ -173,4 +220,33 @@ class TimerController extends AbstractController
|
||||
}
|
||||
}
|
||||
}
|
||||
public function formatTimer($timer) {
|
||||
|
||||
$tmp= [
|
||||
"id"=> $timer->getId(),
|
||||
"title" => $timer->getTask()->getDisplayname(),
|
||||
"start" => $timer->getStart()->format("Y-m-d H:i"),
|
||||
"end" => $timer->getEnd()->format("Y-m-d H:i"),
|
||||
"backgroundColor" => $timer->getTask()->getColor(),
|
||||
"borderColor" => $timer->getTask()->getColor(),
|
||||
"textColor" => "#ffffff",
|
||||
"allDay" => false,
|
||||
"editable" => true,
|
||||
"durationEditable" => false,
|
||||
"extendedProps" => [
|
||||
"fulldescription" => $timer->getTask()->getDisplayname()."\n\n".$timer->getDescription(),
|
||||
"description" => $timer->getDescription(),
|
||||
"userid" => $timer->getUser()->getId(),
|
||||
"username" => $timer->getUser()->getUsername(),
|
||||
"taskid" => $timer->getTask()->getId(),
|
||||
"avatar" => "/".$this->getParameter("appAlias")."/uploads/avatar/".$timer->getUser()->getAvatar(),
|
||||
"estimate" => $timer->getDuration()->format("H:i"),
|
||||
"locked" => false,
|
||||
"editable" => true,
|
||||
"astreinte" => false
|
||||
]
|
||||
];
|
||||
return $tmp;
|
||||
}
|
||||
|
||||
}
|
||||
|
Reference in New Issue
Block a user