Commit e6c746f1 authored by Ifaliana Arimanana's avatar Ifaliana Arimanana
Browse files

reponse automatique

parent 2fc8f1c9
......@@ -9,6 +9,11 @@ class NewanswerAction extends CAction
{
public function run($form=null, $contextId=null, $contextType=null)
{
if($_POST["action"] == "newanswer"){
$params = Element::getElementById($_POST["answerId"],Answer::COLLECTION);
$params["seen"] = $_POST["seen"];
PHDB::update(Answer::COLLECTION,[ "_id" => new MongoId($_POST["answerId"]) ],['$set'=>$params]);
}else{
$formParent =PHDB::findOneById( Form::COLLECTION, $form);
$context = null;
if(!empty($contextId) && !empty($contextType)){
......@@ -23,4 +28,5 @@ class NewanswerAction extends CAction
$answer = Answer::generateAnswer($formParent, false, $context);
return Rest::json($answer);
}
}
}
\ No newline at end of file
......@@ -75,6 +75,15 @@
"OpérateurValidated"=>"Opérateur validé",
"customInput" => "Réponse d'une question"
];
$logo = [
""=>"Par défaut",
"logo"=>"Logo",
"banner" => "Photo de couverture"
];
$emailtpl = [
"basic"=>"Basic",
"lilaBasic" => "Basic simple"
];
foreach ($form["inputs"] as $forminputskey => $forminputsvalue) {
if (isset($forminputsvalue["label"])) {
......@@ -106,6 +115,8 @@
"inputList" => [],
"step" => "",
"contact" => [],
"logo" => "",
"emailtpl" => "basic",
"object" => "",
"msg" => "",
"msgbox" => "",
......@@ -139,6 +150,15 @@
if( isset($parentForm["params"][$kunik]["contact"]) ){
$paramsData["contact"] = $parentForm["params"][$kunik]["contact"];
}
if( isset($parentForm["params"][$kunik]["emailtpl"]) ){
$paramsData["emailtpl"] = $parentForm["params"][$kunik]["emailtpl"];
}
if( isset($parentForm["params"][$kunik]["logo"]) ){
$paramsData["logo"] = $parentForm["params"][$kunik]["logo"];
}
if( isset($parentForm["params"][$kunik]["signature"]) ){
$paramsData["signature"] = $parentForm["params"][$kunik]["signature"];
}
$totalToChecked = sizeof($paramsData["inputList"]);
......@@ -216,7 +236,7 @@
</div>
<?php } elseif (!$isValidate && $lastForm) { ?>
<div style="border: 2px solid darkgrey;padding: 20px;border-radius: 20px; overflow-x: auto; text-align: center" class="step-vld">
<?php if($canValidate){ ?>
<?php if(!$canValidate){ ?>
<button type="button" class="btn validate<?php echo $kunik ?>Params" >Terminer</button>
<?php } else { echo $message; } echo $editParamsBtn?>
......@@ -277,9 +297,26 @@ $mailList = array_unique($mailList);
?>
<script>
var stepVld = {
newThis : function (answerId){
var params = {
"answerId" : answerId,
"seen" : false,
"action" : "newanswer"
}
$.ajax({
type : 'POST',
data : params,
url : baseUrl+"/survey/answer/newanswer",
dataType : "json",
async : false,
success : function(data){
}
});
}
}
var contacttplMail = <?php echo json_encode( (isset($mailList)) ? $mailList : null ); ?>;
......@@ -357,6 +394,18 @@ $mailList = array_unique($mailList);
label : "Question avec une réponse en format email",
options : <?php echo json_encode($inputListOptions) ?>,
values : sectionDyf.<?php echo $kunik ?>ParamsData.inputscontact
},
emailtpl : {
inputType : "selectMultiple",
label : "Template d'email",
options : <?php echo json_encode($emailtpl) ?>,
values : sectionDyf.<?php echo $kunik ?>ParamsData.emailtpl
},
logo : {
inputType : "selectMultiple",
label : "Logo à afficher dans l'email",
options : <?php echo json_encode($logo) ?>,
values : sectionDyf.<?php echo $kunik ?>ParamsData.logo
},
object : {
inputType : "text",
......@@ -368,6 +417,11 @@ $mailList = array_unique($mailList);
label : "Message",
values : sectionDyf.<?php echo $kunik ?>ParamsData.msg
},
signature : {
inputType : "text",
label : "Signature",
values : sectionDyf.<?php echo $kunik ?>ParamsData.signature
},
msgbox : {
inputType : "text",
label : "Text à afficher si validé",
......@@ -415,7 +469,6 @@ $mailList = array_unique($mailList);
});
$(".validate<?php echo $kunik ?>Params").off().on("click",function() {
tplCtxR = {};
tplCtxR.id = "<?php echo $answer["_id"] ?>";
tplCtxR.collection = "<?php echo Form::ANSWER_COLLECTION ?>";
......@@ -431,6 +484,8 @@ $mailList = array_unique($mailList);
dataHelper.path2Value( tplCtxR, function(params) {} );
stepVld.newThis("<?php echo $answer["_id"] ?>");
<?php if($paramsData['step'] != $form['id']) { ?>
tplCtx = {};
tplCtx.id = "<?php echo $answer["_id"] ?>",
......@@ -444,10 +499,11 @@ $mailList = array_unique($mailList);
<?php }else{?>
urlCtrl.loadByHash(location.hash);
<?php }?>
var answerId = <?php echo json_encode((String)$answer['_id']); ?>;
var paramsmail<?php echo $kunik ?> = {
tpl : "basic",
var paramsmail<?php echo $kunik ?> = {
tpl : sectionDyf.<?php echo $kunik ?>Params.jsonSchema.properties.emailtpl.values[0],
signature : sectionDyf.<?php echo $kunik ?>Params.jsonSchema.properties.signature.values,
logo : sectionDyf.<?php echo $kunik ?>Params.jsonSchema.properties.logo.values,
tplObject : "<?php echo (isset($parentForm["params"][$kunik]["object"]) ? $parentForm["params"][$kunik]["object"] : "") ?>",
tplMail : contacttplMail,
html: "<?php echo (isset($parentForm["params"][$kunik]["msg"]) ? $parentForm["params"][$kunik]["msg"] : "") ?>",
......
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