Commit 4a98a6fe authored by Raph El's avatar Raph El
Browse files

Form : contact mail modif

parent e6620388
...@@ -183,8 +183,8 @@ ...@@ -183,8 +183,8 @@
"deal14" : { "deal14" : {
"label" : "Contacter les auteurs de ce dossier", "label" : "Contacter les auteurs de ce dossier",
"buttonLabel" : "Envoyer un email", "buttonLabel" : "Envoyer un email",
"accessRoles" : [ "canAccess" : [
"financeur" "Financeur"
], ],
"selectContact" : { "selectContact" : {
"answered" : "Demandeur(s)", "answered" : "Demandeur(s)",
......
<?php $inputsObj=$form["inputs"][$key]; <?php
if(!isset($inputsObj["canAccess"]) || Form::canAccess($inputsObj["canAccess"])){ ?>
<div class="contactFormEmail col-xs-12 no-padding margin-bottom-20"> if($mode != "pdf" && ( !isset($inputsObj["canAccess"]) || Form::canAccess($inputsObj["canAccess"]) ) ) {
<br/><h4 style="color:<?php echo ($titleColor) ? $titleColor : "black"; ?>"><?php echo @$inputsObj["label"] ?></h4>
<?php if(isset($inputsObj["info"])){ ?> $inputsObj=$form["inputs"][$key];
<span class="italic"> ?>
<?php echo $inputsObj["info"] ?> <div class="contactFormEmail col-xs-12 no-padding margin-bottom-20">
</span> <br/>
<?php } ?> <h4 style="color:<?php echo ($titleColor) ? $titleColor : "black"; ?>"><?php echo @$inputsObj["label"] ?></h4>
<button class="btn btn-success contactMail" data-key="<?php echo $key ?>"> <?php if(isset($inputsObj["info"])){ ?>
<?php echo $inputsObj["buttonLabel"] ?> <span class="italic">
</button> <?php echo $inputsObj["info"] ?>
</div> </span>
<!-- check on select answer + add default obj + add default content--> <?php } ?>
<?php if(isset($inputsObj["formAdmin"])){ ?> <button class="btn btn-success contactMail" data-key="<?php echo $key ?>">
<?php }else if (isset($inputsObj["selectContact"])){ <?php echo $inputsObj["buttonLabel"] ?>
$inputsObj["selectOptByGroup"]=array(); </button>
foreach($inputsObj["selectContact"] as $k => $v){ </div>
$inputsObj["selectOptByGroup"][$k]=array(); <!-- check on select answer + add default obj + add default content-->
if(isset($answer["links"][$k])){ <?php
$typeElt=($k=="answered") ? Person::COLLECTION : Organization::COLLECTION; if(isset($inputsObj["formAdmin"])){
foreach($answer["links"][$k] as $e => $st){
$idCol=($k=="answered") ? $st : $e; }else if (isset($inputsObj["selectContact"])){
$elt=Element::getElementById($idCol, $typeElt, null, array("name","slug", "profilThumbImageUrl")); $inputsObj["selectOptByGroup"]=array();
$elt["collection"]=$typeElt; foreach($inputsObj["selectContact"] as $k => $v){
$inputsObj["selectOptByGroup"][$k][$idCol]=$elt; $inputsObj["selectOptByGroup"][$k]=array();
if(isset($answer["links"][$k])){
$typeElt=($k=="answered") ? Person::COLLECTION : Organization::COLLECTION;
foreach($answer["links"][$k] as $e => $st){
$idCol=($k=="answered") ? $st : $e;
$elt=Element::getElementById($idCol, $typeElt, null, array("name","slug", "profilThumbImageUrl"));
$elt["collection"]=$typeElt;
$inputsObj["selectOptByGroup"][$k][$idCol]=$elt;
}
} }
} }
} //$inputsObj["selectOptByGroup"]=$selectOptByGroup;
//$inputsObj["selectOptByGroup"]=$selectOptByGroup; } ?>
} ?> <script type="text/javascript">
<script type="text/javascript"> //if(typeof answerMailConfig =="undefined") var answerMailConfig={};
//if(typeof answerMailConfig =="undefined") var answerMailConfig={}; //var answerObject.mailConfig.inputs[<?php echo $key ?>]=new Object;
//var answerObject.mailConfig.inputs[<?php echo $key ?>]=new Object; answerObject.mailConfig.inputs["<?php echo $key; ?>"]=<?php echo json_encode($inputsObj); ?>;
answerObject.mailConfig.inputs["<?php echo $key; ?>"]=<?php echo json_encode($inputsObj); ?>; var answerValues=<?php echo json_encode($answer); ?>;
var answerValues=<?php echo json_encode($answer); ?>; jQuery(document).ready(function() {
jQuery(document).ready(function() { $(".contactMail").off().on("click", function(){
$(".contactMail").off().on("click", function(){ inputsMailConfig=answerObject.mailConfig.inputs[$(this).data("key")];
inputsMailConfig=answerObject.mailConfig.inputs[$(this).data("key")]; bootbox.dialog({
bootbox.dialog({ onEscape: function() {},
onEscape: function() {}, message: '<div id="send-mail-answer" class="row"> ' +
message: '<div id="send-mail-answer" class="row"> ' + '<div class="col-xs-12"> ' +
'<div class="col-xs-12"> ' + answerObject.mailConfig.setContactList(inputsMailConfig)+
answerObject.mailConfig.setContactList(inputsMailConfig)+ //'<input type="text" id="contact-email" class="col-xs-12" value="'+aObj.mailTo.initMail(elt)+'"/>'+
//'<input type="text" id="contact-email" class="col-xs-12" value="'+aObj.mailTo.initMail(elt)+'"/>'+ '</div>'+
'</div>'+ '<div class="col-xs-12"> ' +
'<div class="col-xs-12"> ' + '<span class="col-xs-12 bold no-padding">Object</span> ' +
'<span class="col-xs-12 bold no-padding">Object</span> ' + answerObject.mailConfig.setObject(inputsMailConfig)+
answerObject.mailConfig.setObject(inputsMailConfig)+ '</div>'+
'</div>'+ '<div class="col-xs-12"> ' +
'<div class="col-xs-12"> ' + '<span class="col-xs-12 bold no-padding">Message</span> ' +
'<span class="col-xs-12 bold no-padding">Message</span> ' + '<textarea id="message-email" class="col-xs-12 text-dark" style="min-height:250px;" placeholder="Ecrivez votre message">'+answerObject.mailConfig.defaultMessage(inputsMailConfig)+'</textarea>'+
'<textarea id="message-email" class="col-xs-12 text-dark" style="min-height:250px;" placeholder="Ecrivez votre message">'+answerObject.mailConfig.defaultMessage(inputsMailConfig)+'</textarea>'+ '</div>'+
'</div>'+ '</div>',
'</div>', buttons: {
buttons: { success: {
success: { label: "Ok",
label: "Ok", className: "btn-primary",
className: "btn-primary", callback: function () {
callback: function () { errorMsg={
errorMsg={ msg : "Veuillez écrire un message",
msg : "Veuillez écrire un message", object : "Veuillez renseigner un objet",
object : "Veuillez renseigner un objet", contact : "Veuillez saisir un destinataire"
contact : "Veuillez saisir un destinataire" }
} var msg="";
var msg="";
if(notEmpty($("#send-mail-answer #message-email").val())) if(notEmpty($("#send-mail-answer #message-email").val()))
msg="<span style='white-space: pre-line;'>"+$("#send-mail-answer #message-email").val()+"<br/></span>"; msg="<span style='white-space: pre-line;'>"+$("#send-mail-answer #message-email").val()+"<br/></span>";
//var email //var email
else { else {
toastr.error(errorMsg.msg);return false; toastr.error(errorMsg.msg);return false;
} }
if(!notEmpty($("#send-mail-answer #object-email").val())){ if(!notEmpty($("#send-mail-answer #object-email").val())){
toastr.error(errorMsg.object);return false; toastr.error(errorMsg.object);return false;
} }
var params={ var params={
tpl : "default", tpl : "default",
tplObject : $("#send-mail-answer #object-email").val(), tplObject : $("#send-mail-answer #object-email").val(),
html: msg html: msg
}; };
if($("#send-mail-answer #contact-email").length > 0) if($("#send-mail-answer #contact-email").length > 0)
params.tplMail=$("#send-mail-answer #contact-email").val(); params.tplMail=$("#send-mail-answer #contact-email").val();
if($("#send-mail-answer .checkboxAnswerContact").length > 0){ if($("#send-mail-answer .checkboxAnswerContact").length > 0){
listContact={}; listContact={};
$("#send-mail-answer .checkboxAnswerContact input[type='checkbox']:checked").each(function(){ $("#send-mail-answer .checkboxAnswerContact input[type='checkbox']:checked").each(function(){
listContact[$(this).data("value")] = { type : $(this).data("collection")}; listContact[$(this).data("value")] = { type : $(this).data("collection")};
}); });
params.listContact=listContact; params.listContact=listContact;
} }
if((typeof params.listContact != "undefined" && Object.keys(params.listContact).length > 0) || (typeof params.tplMail != "undefined" && notEmpty(params.tplMail))){ if((typeof params.listContact != "undefined" && Object.keys(params.listContact).length > 0) || (typeof params.tplMail != "undefined" && notEmpty(params.tplMail))){
ajaxPost( ajaxPost(
null, null,
baseUrl+"/survey/answer/sendmail/tpl/default/id/"+answerObj._id.$id, baseUrl+"/survey/answer/sendmail/tpl/default/id/"+answerObj._id.$id,
params, params,
function(data){ function(data){
toastr.success("Le mail a été envoyé avec succès"); toastr.success("Le mail a été envoyé avec succès");
} }
); );
}else{ toastr.error(errorMsg.contact);return false; } }else{ toastr.error(errorMsg.contact);return false; }
//aObj.mailTo.sendMail(aObj, elt, type, id); //aObj.mailTo.sendMail(aObj, elt, type, id);
} }
}, },
cancel: { cancel: {
label: trad["cancel"], label: trad["cancel"],
className: "btn-secondary", className: "btn-secondary",
callback: function() {} callback: function() {}
} }
} }
}); });
});
}); });
}); </script>
</script>
<?php } ?> <?php } ?>
\ No newline at end of file
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment