public function run() { global $request; $em = \Shared\DoctrineHelper::getEntityManager(); $idCompte = $request->request->get("idCompte"); $idDiscussion = $request->request->get("idDiscussion"); $message = $request->request->get("message"); $objSupportMessage = new \Site\Entity\SupportMessages(); $objSupportMessage->setIdCompte($idCompte); $objSupportMessage->setIdDiscussion($idDiscussion); $objSupportMessage->setMessage($message); $objSupportMessage->setDate(new \DateTime(date("Y-m-d H:i:s"))); $objSupportMessage->setEtat(\SupportEtatMessageHelper::NON_LU); $objSupportMessage->setDatechangementEtat(new \DateTime(date("Y-m-d H:i:s"))); $objSupportMessage->setIp($this->ipAdresse); try { $objSupportDiscussion = \Site\SiteHelper::getSupportDiscussionsRepository()->find($idDiscussion); $objSupportDiscussion->setDateDernierMessage(new \DateTime(date("Y-m-d H:i:s"))); $em->persist($objSupportDiscussion); $em->persist($objSupportMessage); $em->flush(); if ($idCompte == $objSupportDiscussion->getIdAdmin()) { $objAccountJoueur = \Account\AccountHelper::getAccountRepository()->find($objSupportDiscussion->getIdCompte()); if ($objAccountJoueur !== null) { $template = $this->objTwig->loadTemplate("MessagerieMessageAdd.html5.twig"); $result = $template->render(["compte" => $objAccountJoueur->getLogin(), "objet" => \SupportObjetsHelper::getLibelle($objSupportDiscussion->getIdObjet())]); $subject = 'VamosMT2 - Réponse à votre ticket'; \EmailHelper::sendEmail($objAccountJoueur->getEmail(), $subject, $result); } } echo json_encode(["id" => $objSupportMessage->getId(), "date" => \DateTimeHelper::dateTimeToFormatedString($objSupportMessage->getDate(), "H:i"), "message" => nl2br($objSupportMessage->getMessage())]); } catch (Exception $ex) { } }
public function run() { $columnsParameters = array(array('dbField' => 'SupportDiscussionsEntity.idObjet', 'dtField' => 'objet', 'formatter' => function ($d, $row) { return \SupportObjetsHelper::getLibelle($d); }), array('dbField' => 'AdminsEntity.name', 'dtField' => 'compte', 'formatter' => function ($d, $row) { if ($this->isAdmin) { return $row["user"]; } else { return $d; } }), array('dbField' => 'AccountEntityUser.login', 'dtField' => 'user'), array('dbField' => 'SupportDiscussionsEntity.date', 'dtField' => 'date', 'formatter' => function ($d, $row) { return \DateTimeHelper::dateTimeToFormatedString($d, "d/m/Y"); }), array('dbField' => 'SupportDiscussionsEntity.dateDernierMessage', 'dtField' => 'lastMessage', 'formatter' => function ($d, $row) { $firstDate = date("Y-m-d"); $secondDate = $d->format('Y-m-d'); if ($firstDate == $secondDate) { return \DateTimeHelper::dateTimeToFormatedString($d, "H:i:s"); } else { return \DateTimeHelper::dateTimeToFormatedString($d); } }), array('dbField' => 'SupportMessagesEntity.id', 'dtField' => 'nonLuInDiscussion', 'formatter' => function ($d, $row) { if ($d === null) { return ""; } else { return "lineGreen"; } }), array('dbField' => 'SupportDiscussionsEntity.id', 'dtField' => 'actions', 'formatter' => function ($d, $row) { $varButton = '<a class="btn btn-material btn-primary btn-sm" onclick="DiscussionOpen(\'' . \Encryption::encrypt($d) . '\')"><i class="material-icons md-icon-message"></i></a>'; $varButton .= '<a class="btn btn-material btn-warning btn-sm" onclick="DiscussionArchivage(\'' . \Encryption::encrypt($d) . '\', 1)"><i class="material-icons md-icon-archive"></i></a>'; return '<div class="btn-toolbar">' . $varButton . "</div>"; })); $datatable = new \DataTable(); $datatable->setColumnsParameters($columnsParameters)->setRequest($_GET)->from("\\Site\\Entity\\SupportDiscussions", "SupportDiscussionsEntity")->innerJoin("\\Site\\Entity\\Admins", "AdminsEntity", "WITH", "AdminsEntity.idCompte = SupportDiscussionsEntity.idAdmin")->leftJoin("\\Account\\Entity\\Account", "AccountEntityUser", "WITH", "AccountEntityUser.id = SupportDiscussionsEntity.idCompte")->leftJoin("\\Site\\Entity\\SupportMessages", "SupportMessagesEntity", "WITH", "SupportMessagesEntity.idDiscussion = SupportDiscussionsEntity.id AND SupportMessagesEntity.etat = " . \SupportEtatMessageHelper::NON_LU . " AND SupportMessagesEntity.idCompte != " . $this->objAccount->getId() . "")->andWhere("SupportDiscussionsEntity.idCompte = " . $this->objAccount->getId() . " OR SupportDiscussionsEntity.idAdmin = " . $this->objAccount->getId() . "")->andWhere("SupportDiscussionsEntity.estArchive = 0")->groupBy("SupportDiscussionsEntity.id"); $datatable->getResult()->toJson(); }
public function run() { $nombreDiscussionOuverte = \Site\SiteHelper::getSupportDiscussionsRepository()->countDiscussionActiveByIdAccount($this->objAccount->getId()); $this->arrayTemplate["nombreDiscussionOuverte"] = $nombreDiscussionOuverte; $arrSupportObjets = \SupportObjetsHelper::getAll(false); $this->arrayTemplate["arrSupportObjets"] = $arrSupportObjets; $this->arrayTemplate["objAccount"] = $this->objAccount->getId(); $view = $this->template->render($this->arrayTemplate); $this->response->setContent($view); $this->response->send(); }
public function run() { $columnsParameters = array(array('dbField' => 'SupportDiscussionsEntity.idObjet', 'dtField' => 'objet', 'formatter' => function ($d, $row) { return \SupportObjetsHelper::getLibelle($d); }), array('dbField' => 'AdminsEntity.name', 'dtField' => 'compte', 'formatter' => function ($d, $row) { if ($this->isAdmin) { return $row["user"]; } else { return $d; } }), array('dbField' => 'AccountEntityUser.login', 'dtField' => 'user'), array('dbField' => 'SupportDiscussionsEntity.date', 'dtField' => 'date', 'formatter' => function ($d, $row) { return \DateTimeHelper::dateTimeToFormatedString($d, "d/m/Y"); }), array('dbField' => 'SupportDiscussionsEntity.id', 'dtField' => 'actions', 'formatter' => function ($d, $row) { $varButton = '<a class="btn btn-material btn-primary btn-sm" onclick="DiscussionOpen(\'' . \Encryption::encrypt($d) . '\')"><i class="material-icons md-icon-search"></i></a>'; return '<div class="btn-toolbar">' . $varButton . "</div>"; })); $datatable = new \DataTable(); $datatable->setColumnsParameters($columnsParameters)->setRequest($_GET)->from("\\Site\\Entity\\SupportDiscussions", "SupportDiscussionsEntity")->innerJoin("\\Site\\Entity\\Admins", "AdminsEntity", "WITH", "AdminsEntity.idCompte = SupportDiscussionsEntity.idAdmin")->leftJoin("\\Account\\Entity\\Account", "AccountEntityUser", "WITH", "AccountEntityUser.id = SupportDiscussionsEntity.idCompte")->andWhere("SupportDiscussionsEntity.idCompte = " . $this->objAccount->getId() . " OR SupportDiscussionsEntity.idAdmin = " . $this->objAccount->getId() . "")->andWhere("SupportDiscussionsEntity.estArchive = 1"); $datatable->getResult()->toJson(); }
public function run() { global $request; $em = \Shared\DoctrineHelper::getEntityManager(); $idDiscussion = \Encryption::decrypt($request->request->get("idDiscussion")); $objSupportDiscussion = \Site\SiteHelper::getSupportDiscussionsRepository()->find($idDiscussion); $objAccount = \Account\AccountHelper::getAccountRepository()->find($objSupportDiscussion->getIdCompte()); if ($objSupportDiscussion !== null) { if ($objSupportDiscussion->getIdCompte() == $this->objAccount->getId() or $objSupportDiscussion->getIdAdmin() == $this->objAccount->getId()) { $objSupportDiscussion->setEstArchive(1); $em->persist($objSupportDiscussion); $em->flush(); $template = $this->objTwig->loadTemplate("MessagerieDiscussionCloture.html5.twig"); $result = $template->render(["compte" => $objAccount->getLogin(), "objet" => \SupportObjetsHelper::getLibelle($objSupportDiscussion->getIdObjet())]); $subject = 'VamosMT2 - Clôture de votre ticket'; \EmailHelper::sendEmail($objAccount->getEmail(), $subject, $result); echo json_encode(["result" => true]); } else { echo json_encode(["result" => false, "message" => "Le ticket est introuvable."]); } } }
public function helpSupportObjet($objet = 0) { return SupportObjetsHelper::getLibelle($objet); }