repondre pas mail à un message chat (ref #179)
This commit is contained in:
parent
cb5b98237d
commit
2da3128312
|
@ -55,14 +55,15 @@
|
|||
font-size:12px;
|
||||
}
|
||||
|
||||
.btnreplymessage {
|
||||
.btnreplymessage, .btnreplymessagemail {
|
||||
padding: 5px;
|
||||
background-color: #{{ colorbodyfont }};
|
||||
color : #{{ colorbodyback }};
|
||||
border-radius:5px;
|
||||
cursor:pointer;
|
||||
margin-right:5px;
|
||||
}
|
||||
.btnreplymessage:hover {
|
||||
.btnreplymessage:hover, .btnreplymessagemail:hover {
|
||||
color : #{{ colorbodyback }};
|
||||
}
|
||||
.replymessage { display:none}
|
||||
|
@ -168,6 +169,7 @@
|
|||
</div>
|
||||
|
||||
<a class="btnreplymessage" data-id='{{message.id}}'>Répondre</a>
|
||||
<a class="btnreplymessagemail" data-id='{{message.id}}'>Répondre par Mail</a>
|
||||
<div id="replymessage-{{message.id}}" class="replymessage">
|
||||
<textarea></textarea>
|
||||
<a id="sendreply" class="btn btn-success sendreply" data-id='{{message.id}}'>Envoyer</a>
|
||||
|
@ -199,6 +201,7 @@
|
|||
{{ form_widget(form.messagemail) }}
|
||||
</div>
|
||||
<a id="sendbtnmail" class="btn btn-success" style="margin-top:5px; width:100%; margin-bottom:15px">Envoyer</a>
|
||||
<a id="sendbtnmailreply" class="btn btn-success" data-id="" style="margin-top:5px; width:100%; margin-bottom:15px">Envoyer</a>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
@ -386,6 +389,7 @@
|
|||
html+="<div class='msgtopic'>"+payload.msg.message+"</div>";
|
||||
html+="<div id='msgreplys-"+payload.msg.id+"' class='msgreplys'></div>";
|
||||
html+="<a class='btnreplymessage' data-id='"+payload.msg.id+"'>Répondre</a>";
|
||||
html+="<a class='btnreplymessagemail' data-id='"+payload.msg.id+"'>Répondre par Mail</a>";
|
||||
html+="<div id='replymessage-"+payload.msg.id+"' class='replymessage'>";
|
||||
html+="<textarea></textarea>";
|
||||
html+="<a id='sendreply' class='btn btn-success sendreply' data-id='"+payload.msg.id+"'>Envoyer</a>";
|
||||
|
@ -492,7 +496,9 @@
|
|||
$("#listtoavatar").append($("<img class='avatar' title='{{user.user.lastname}} {{user.user.firstname}}' data-mail='{{user.user.email}}' src='\\{{alias}}\\uploads\\avatar\\{{user.user.avatar}}'>"));
|
||||
{%endif%}
|
||||
{% endfor %}
|
||||
|
||||
|
||||
$("#sendbtnmail").show();
|
||||
$("#sendbtnmailreply").hide();
|
||||
$('#mymodal-sendmail').modal('show');
|
||||
}
|
||||
else {
|
||||
|
@ -568,12 +574,58 @@
|
|||
else alert("Sujet, corps et destinataire(s) obligatoire");
|
||||
}
|
||||
|
||||
$( "#sendbtnmailreply" ).click(function() {
|
||||
sendbtnmailreply();
|
||||
});
|
||||
|
||||
function sendbtnmailreply() {
|
||||
var data = CKEDITOR.instances["chat_messagemail"].getData();
|
||||
var subject=$("#mailsuject").val();
|
||||
var mailto=$("#mailto").val();
|
||||
|
||||
if(data&&subject&&mailto) {
|
||||
|
||||
try {
|
||||
// Flager que l'envoit c'est fait
|
||||
tosendmail=false;
|
||||
$("#sendbtnmailreply").html("Envoyer");
|
||||
$("#sendbtnmailreply").removeClass("btn-danger");
|
||||
$("#sendbtnmailreply").css('cursor','auto');
|
||||
|
||||
// Push envent sur le websocket
|
||||
id=$("#sendbtnmailreply").data("id");
|
||||
event={mykey: "{{userkey}}", type: "reply", message: data, parent: id, mail: "true", to: mailto, subject: subject};
|
||||
session.publish("websocket/channel/{{groupid}}", event);
|
||||
CKEDITOR.instances["chat_message"].setData('');
|
||||
|
||||
// Cacher la popup
|
||||
$("#sendbymail").bootstrapSwitch('state',false);
|
||||
$('#mymodal-sendmail').modal('hide');
|
||||
}
|
||||
catch(error) {
|
||||
// L'envoi ne s'est pas fait
|
||||
console.log("Retry to send reply");
|
||||
|
||||
// On flag le fait de retenter l'envoit à la reconnexion
|
||||
tosendmail=true;
|
||||
|
||||
// On signal que l'envoi est en cours sur le bouton
|
||||
$("#sendbtnmailreply").html("Envoi en cours");
|
||||
$("#sendbtnmailreply").addClass("btn-danger");
|
||||
$("#sendbtnmailreply").css('cursor','progress');
|
||||
}
|
||||
|
||||
}
|
||||
else alert("Sujet, corps et destinataire(s) obligatoire");
|
||||
}
|
||||
|
||||
$(document).on('click', '.delmessage', function(){
|
||||
delmessage($(this).data("id"));
|
||||
});
|
||||
|
||||
function delmessage(id) {
|
||||
try {
|
||||
console.log("cestk"+id);
|
||||
// Flager que l'envoit c'est fait
|
||||
todelete=false;
|
||||
idtodelete=null;
|
||||
|
@ -626,6 +678,27 @@
|
|||
$("#replymessage-"+id+" textarea").focus();
|
||||
}
|
||||
|
||||
$(document).on('click', '.btnreplymessagemail', function(){
|
||||
CKEDITOR.instances["chat_messagemail"].setData("");
|
||||
$("#mailsuject").val("{{app.session.get('appname')}} = Notification {{ group.label }}");
|
||||
$("#mailto").val("");
|
||||
$("#listtoavatar").html("");
|
||||
|
||||
{% for user in group.users %}
|
||||
{%if(user.user!=app.user)%}
|
||||
$("#mailto").val($("#mailto").val()+";{{user.user.email}}");
|
||||
$("#listtoavatar").append($("<img class='avatar' title='{{user.user.lastname}} {{user.user.firstname}}' data-mail='{{user.user.email}}' src='\\{{alias}}\\uploads\\avatar\\{{user.user.avatar}}'>"));
|
||||
{%endif%}
|
||||
{% endfor %}
|
||||
|
||||
$("#sendbtnmail").hide();
|
||||
$("#sendbtnmailreply").show();
|
||||
$("#sendbtnmailreply").data("id",$(this).data("id"));
|
||||
|
||||
$('#mymodal-sendmail').modal('show');
|
||||
});
|
||||
|
||||
|
||||
$(document).on('click', '.sendreply', function(){
|
||||
sendreply($(this).data("id"));
|
||||
});
|
||||
|
@ -697,6 +770,7 @@
|
|||
|
||||
html+="</div>";
|
||||
html+="<a class='btnreplymessage' data-id='"+data.id+"'>Répondre</a>";
|
||||
html+="<a class='btnreplymessagemail' data-id='"+payload.msg.id+"'>Répondre par Mail</a>";
|
||||
html+="<div id='replymessage-"+data.id+"' class='replymessage'>";
|
||||
html+="<textarea></textarea>";
|
||||
html+="<a id='sendreply' class='btn btn-success sendreply' data-id='"+data.id+"'>Envoyer</a>";
|
||||
|
|
|
@ -154,6 +154,29 @@ class WebsocketTopic implements TopicInterface
|
|||
if($event["type"]=="reply") {
|
||||
$parent=$this->em->getRepository("CadolesWebsocketBundle:Message")->find($event["parent"]);
|
||||
if($parent) {
|
||||
if(array_key_exists("mail",$event)) {
|
||||
$mail = $this->container->get('cadoles.core.service.mail');
|
||||
if($mail) {
|
||||
$pages=$group->getPages();
|
||||
$pageid=$pages[0]->getId();
|
||||
$cplt="<br><br><b>Attention pour répondre à ce message : n’utilisez pas votre mail mais rendez vous dans ce groupe sur Transnum et utilisez le fil de conversation (chat)</b><br>";
|
||||
$url="https://".$this->container->getParameter('weburl')."/".$this->container->getParameter('alias').$this->container->get('router')->generate('cadoles_core_redirect', ['route'=>'cadoles_core_home','id'=>$pageid]);
|
||||
$cplturl="<br><a href='".$url."'>".$url."</a>";
|
||||
$mail_params=array(
|
||||
"subject" => $event["subject"],
|
||||
"body_html"=>$event["message"].$cplt.$cplturl,
|
||||
"body_text"=>strip_tags($event["message"].$cplt.$url)
|
||||
);
|
||||
|
||||
// Transformer la liste des destinataires en tableau : [0] tjr vide on l'unset
|
||||
$to=explode(";",$event["to"]);
|
||||
unset($to[0]);
|
||||
|
||||
$mail->sendEmail("template", $mail_params, $to, $this->container->getParameter('noreply'), $user->getLastname()." ".$user->getFirstname());
|
||||
$event["message"].="<br><i>Notification envoyée par mail</i>";
|
||||
}
|
||||
}
|
||||
|
||||
$message=new Message();
|
||||
$message->setTopic($event["message"]);
|
||||
$message->setUser($user);
|
||||
|
|
Loading…
Reference in New Issue