Commit 46a7451e authored by Tibor Katelbach's avatar Tibor Katelbach

Merge branch 'anatole' into 'master'

Anatole

See merge request !2
parents 3eb5a5e4 69fb7303
......@@ -12,7 +12,8 @@
'new' => 'survey.controllers.answer.NewAction',
'index' => 'survey.controllers.answer.IndexAction',
'all'=>'survey.controllers.answer.AllAction',
'admindirectory'=>'survey.controllers.answer.admin.DirectoryAction'
'admindirectory'=>'survey.controllers.answer.admin.DirectoryAction',
'sendmail' => 'survey.controllers.answer.mail.SendAction',
);
}
}
<?php
class SendAction extends CAction {
public function run($id, $tpl="validation", $step=null) {
$controller=$this->getController();
$msg=null;
$infos=array();
if(isset($_POST["tpl"]))
$tpl=$_POST["tpl"];
if(isset($_POST["step"]))
$step=$_POST["step"];
// ALL infos
if(isset($_POST["tplObject"]))
$infos["tplObject"]=$_POST["tplObject"];
if(isset($_POST["html"]))
$infos["html"]=$_POST["html"];
if(isset($_POST["msg"]))
$infos["msg"]=$_POST["msg"];
if(isset($_POST["tplMail"]))
$infos["emails"]=$_POST["tplMail"];
if(isset($_POST["listContact"]))
$infos["community"]=$_POST["listContact"];
$mailParams=Answer::mailProcess($id, $tpl, $step, $infos);
Rest::json(array("result"=>true, "msg"=>"Ok : webhook handdled"));
}
}
<?php if($answer){
?>
<div class="form-group">
<?php
$i = 0;
$show = true;
if (isset($answers)) {
foreach ($answers as $q => $a) {
if (isset($answers)) {
$i++;
}
}
}
$editBtnL = (Yii::app()->session["userId"] == $answer["user"]) ? " <a href='javascript:;' data-id='".$answer["_id"]."' data-collection='".Form::ANSWER_COLLECTION."' data-path='".$answerPath."' class='add".$kunik." btn btn-default'><i class='fa fa-plus'></i> Ajouter une ligne </a>" : "";
$editParamsBtn = ($canEdit) ? " <a href='javascript:;' data-id='".$el["_id"]."' data-collection='".Yii::app()->session["costum"]["contextType"]."' data-path='costum.form.params.".$kunik."' class='previewTpl edit".$kunik."Params btn btn-xs btn-danger'><i class='fa fa-cog'></i> </a>" : "";
$paramsData = [
"mail_type" => ""
];
if( isset(Yii::app()->session["costum"]["form"]["params"][$kunik]["mail_type"]) )
$paramsData["mail_type"] = Yii::app()->session["costum"]["form"]["params"][$kunik]["mail_type"];
$properties = [
"liste_row" => [
"label" => "mot ou phrase",
"placeholder" => "mot ou phrase",
"inputType" => "text",
"rules" => [ "required" => true ]
]
];
?>
<h4 style="color:<?php echo ($titleColor) ? $titleColor : "black"; ?>"><?php echo $label.$editQuestionBtn.$editParamsBtn.$editBtnL?></h4>
<?php echo $info ?>
<style>
.s19{list-style: none;}
.s19 li:before{
content: '\f0a9';
margin-right: 15px;
font-family: FontAwesome;
color: #d9534f;
}
</style>
<ol class="s19" style="
white-space: normal;
">
<?php
$ct = 0;
if(isset($answers)){
foreach ($answers as $q => $a) {
?>
<li> <?php echo $a['liste_row']; ?>
<div class="pull-right"><?php
$this->renderPartial( "survey.views.tpls.forms.cplx.editDeleteLineBtn" , [
"canEdit"=>($canEdit||Yii::app()->session["userId"] == $answer["user"]),
"id" => $answer["_id"],
"collection" => Form::ANSWER_COLLECTION,
"q" => $q,
"path" => "answers.".$kunik.".".$q,
"keyTpl"=>$kunik
] ); ?><a href="javascript:;" class="btn btn-xs btn-primary openAnswersComment" onclick="commentObj.openPreview('answers','<?php echo $answer["_id"]?>','<?php echo $answer["_id"].$key.$q ?>', '<?php echo @$a['step'] ?>')"><?php echo PHDB::count(Comment::COLLECTION, array("contextId"=>$answer["_id"],"contextType"=>"answers", "path"=>$answer["_id"].$key.$q))?> <i class='fa fa-commenting'></i></a></div>
</li>
<?php
}
}
?>
</ol>
</div>
<script type="text/javascript">
var <?php echo $kunik ?>Data = <?php echo json_encode( (isset($answers)) ? $answers : null ); ?>;
sectionDyf.<?php echo $kunik ?>ParamsData = <?php echo json_encode( $paramsData ); ?>;
$(document).ready(function() {
sectionDyf.<?php echo $kunik ?> = {
"jsonSchema" : {
"title" : "Mail",
"icon" : "fa-money",
"text" : "",
"properties" : <?php echo json_encode( $properties ); ?>,
save : function () {
var today = new Date();
tplCtx.value = { date : today.getDate() + '/' + (today.getMonth()+1) + '/' + today.getFullYear() };
$.each( sectionDyf.<?php echo $kunik ?>.jsonSchema.properties , function(k,val) {
tplCtx.value[k] = $("#"+k).val();
});
mylog.log("save tplCtx",tplCtx);
if(typeof tplCtx.value == "undefined")
toastr.error('value cannot be empty!');
else {
ajaxPost(
null,
baseUrl+"/survey/answer/sendmail/id/<?php echo (string)$answer['_id'] ?>",
{to:$("#liste_row").val(),msg:sectionDyf.<?php echo $kunik ?>ParamsData.mail_type},
function(data){
toastr.success("Un mail a été envoyé à toutes les parties prenantes afin de les notifier");
//urlCtrl.loadByHash(location.hash);
dataHelper.path2Value( tplCtx, function(params) {
$("#ajax-modal").html("<div class='text-center'><i class='fa fa-spin fa-spinner'></i></div>");//$("#ajax-modal").modal('hide');
//location.reload();
} );
}
);
}
}
}
};
sectionDyf.<?php echo $kunik ?>Params = {
"jsonSchema" : {
"title" : "<?php echo $kunik ?> config",
"description" : "Mail type",
"icon" : "fa-cog",
"properties" : {
subject : {
inputType : "text",
label : "Sujet",
values : sectionDyf.<?php echo $kunik ?>ParamsData.mail_type
}
mail_type : {
inputType : "textarea",
label : "Mail type",
values : sectionDyf.<?php echo $kunik ?>ParamsData.mail_type
}
},
save : function () {
tplCtx.value = {};
$.each( sectionDyf.<?php echo $kunik ?>Params.jsonSchema.properties , function(k,val) {
if(val.inputType == "properties")
tplCtx.value[k] = getPairsObj('.'+k+val.inputType);
else if(val.inputType == "array")
tplCtx.value[k] = getArray('.'+k+val.inputType);
else
tplCtx.value[k] = $("#"+k).val();
mylog.log("value",'.'+k+val.inputType,tplCtx.value[k]);
});
mylog.log("save tplCtx",tplCtx);
if(typeof tplCtx.value == "undefined")
toastr.error('value cannot be empty!');
else {
dataHelper.path2Value( tplCtx, function(params) {
$("#ajax-modal").html("<div class='text-center'><i class='fa fa-spin fa-spinner'></i></div>");
location.reload();
} );
}
}
}
};
mylog.log("render","/modules/costum/views/tpls/forms/<?php echo $kunik ?>.php");
//adds a line into answer
$(".add<?php echo $kunik ?>").off().on("click",function() {
tplCtx.id = $(this).data("id");
tplCtx.collection = $(this).data("collection");
tplCtx.path = $(this).data("path")+((notNull(<?php echo $kunik ?>Data) ? <?php echo $kunik ?>Data.length : "0"));
dyFObj.openForm( sectionDyf.<?php echo $kunik ?> );
});
$(".edit<?php echo $kunik ?>").off().on("click",function() {
tplCtx.id = $(this).data("id");
tplCtx.collection = $(this).data("collection");
tplCtx.path = $(this).data("path");
dyFObj.openForm( sectionDyf.<?php echo $kunik ?>,null, <?php echo $kunik ?>Data[$(this).data("key")]);
});
$(".edit<?php echo $kunik ?>Params").off().on("click",function() {
tplCtx.id = $(this).data("id");
tplCtx.collection = $(this).data("collection");
tplCtx.path = $(this).data("path");
//if no params config on the element.costum.form.params.<?php echo $kunik ?>
//then we load default values available in forms.inputs.<?php echo $kunik ?>xxx.params
//mylog.log(".editParams",sectionDyf.<?php echo $kunik ?>Params,calData);
dyFObj.openForm( sectionDyf.<?php echo $kunik ?>Params,null, sectionDyf.<?php echo $kunik ?>ParamsData);
});
});
</script>
<?php } else {
//echo "<h4 class='text-red'>CALENDAR works with existing answers</h4>";
} ?>
\ No newline at end of file
<?php
$defaultColor = "#354C57";
$structField = "structags";
$keyTpl = "wizard";
$paramsData = [ "title" => "",
"color" => "",
"background" => "",
"nbList" => 2,
"defaultcolor" => "#354C57",
"tags" => "structags"
];
if( isset(Yii::app()->session["costum"]["tpls"][$keyTpl]) ) {
foreach ($paramsData as $i => $v) {
if( isset(Yii::app()->session["costum"]["tpls"][$keyTpl][$i]) )
$paramsData[$i] = Yii::app()->session["costum"]["tpls"][$keyTpl][$i];
}
}
?>
<div class="col-xs-12 margin-top-20">
<div id="<?php echo $wizid ?>" class="swMain">
<style type="text/css">
.swMain ul li > a.done .stepNumber {
border-color: <?php echo ( @$color1 ) ? $color1 : $defaultColor ?>;
background-color: <?php echo ( @$color1 ) ? $color1 : $defaultColor ?>;
}
swMain > ul li > a.selected .stepDesc, .swMain li > a.done .stepDesc {
color: <?php echo ( @$color1 ) ? $color1 : $defaultColor ?>;
font-weight: bolder;
}
.swMain > ul li > a.selected::before, .swMain li > a.done::before{
border-color: <?php echo ( @$color1 ) ? $color1 : $defaultColor ?>;
}
</style>
<ul id="wizardLinks">
<?php
// var_dump($listSteps); exit;
$activeStep = 1;
$nextStepValid =false;
?>
</ul>
<?php
foreach ($formList as $k => $v) {
$hide = ($k==$activeStep) ? "" : "hide";
?>
<div id='<?php echo $v ?>' class='col-sm-offset-1 col-sm-10 sectionStep <?php echo $hide ?>' style="padding-bottom:40px">
<?php
$form = PHDB::findOne( Form::COLLECTION,[ "id"=>$v ] );
?>
<script type="text/javascript">
formInputs["<?php echo $v ?>"] = <?php echo json_encode( $form['inputs'] ); ?>;
var formInputsHere = formInputs;
</script>
<?php
if( !empty($form) )
{
echo '<h1 class="text-center" style="color:'.$color1.'" >'.@$form["name"].'</h1>';
echo "<div class='text-center'>";
if(isset(Yii::app()->session["costum"]["cms"][$form["id"]."desc"]))
echo htmlentities(Yii::app()->session["costum"]["cms"][$form["id"]."desc"]);
else
echo "<span style='color:#aaa'>* section description</span>";
if($canEdit)
echo "<a class='btn btn-xs btn-danger editBtn' href='javascript:;' data-key='".@$form["id"]."desc' data-type='textarea' data-markdown='1' data-path='costum.cms.".@$form["id"]."desc' data-label='Expliquez les objectifs de cette étape ? '> <i class='fa fa-pencil'></i></a>";
echo "</div>";
//echo "<div class='markdown'>";
echo "<div class=''>";
echo $this->renderPartial("survey.views.tpls.forms.formSection",
[ "formId" => $v,
"form" => $form,
"wizard" => true,
"answer"=>$answer,
"mode" => "w",
"showForm" => $showForm,
"canEdit" => $canEdit,
"el" => $el ] ,true );
echo "</div>";
}
else
{
echo "";
}
?>
</div>
<?php
}
?>
<script type="text/javascript">
jQuery(document).ready(function() {
mylog.log("render","survey.views.tpls.forms.wizard");
$.each($(".markdown"), function(k,v){
descHtml = dataHelper.markdownToHtml($(v).html());
$(v).html(descHtml);
});
// Todo BUG en nav private
if( localStorage !== null && localStorage.wizardStep !== null)
showStepForm(localStorage.wizardStep);
});
function showStepForm(id){
mylog.log("showStepForm", id);
$(".sectionStep").addClass("hide");
$(id).removeClass("hide");
localStorage.setItem("wizardStep",id);
}
</script>
</div>
</div>
\ No newline at end of file
......@@ -15,11 +15,13 @@ if($mode == "r"){ ?>
<?php
}else{
?>
<link href="https://cdnjs.cloudflare.com/ajax/libs/select2/4.0.6-rc.0/css/select2.min.css" rel="stylesheet" />
<div class="form-group">
<label for="<?php echo $key ?>"><h4 style="color:<?php echo ($titleColor) ? $titleColor : "black"; ?>"><?php echo $label.$editQuestionBtn ?></h4></label>
<br/>
<select class="form-control js-example-tags">
<select id="tags<?php echo $kunik ?>" multiple>
<option selected="selected">orange</option>
<option>white</option>
<option>purple</option>
......@@ -29,11 +31,17 @@ if($mode == "r"){ ?>
<?php } ?>
</div>
<script src="https://cdnjs.cloudflare.com/ajax/libs/select2/4.0.6-rc.0/js/select2.min.js"></script>
<script type="text/javascript">
jQuery(document).ready(function() {
$(".js-example-tags").select2({
});
});
let optionSelect2<?php echo $kunik ?> = {
templateResult: formatResult,
closeOnSelect: false,
width: '90%',
placeholder: 'Saisir un territoire'
};
let $select2<?php echo $kunik ?> = $("#tags<?php echo $kunik ?>").select2(optionSelect2<?php echo $kunik ?>);
</script>
<?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