Commit 55936d9c authored by Raph El's avatar Raph El
Browse files

Merge branch 'development' of https://gitlab.adullact.net/pixelhumain/survey into development

parents eaef6cfd 86a39d62
//parent form
{
"parent" : creer un form sur un element
"tpl" : "costum.views.custom.deal.form",
"answersTpl" : "costum.views.custom.deal.answers",
"hasStepValidations" : 1,
"id" : "dealForm",
"source" : {
......
......@@ -72,35 +72,40 @@ class Form {
"text" => "texte simple",
"textarea" => "textarea",
"markdown" => "markdown",
"wysiwyg" => "wysiwyg",
"checkbox" => "checkbox",
"finder" => "finder",
//"wysiwyg" => "wysiwyg",
//"checkbox" => "checkbox",
"checkboxSimple" => "checkboxSimple",
"radio" => "radio",
"select" => "select",
"selectMultiple" => "selectMultiple",
"formLocality" => "formLocality",
"location" => "location",
"uploader" => "uploader",
"folder" => "folder",
"finder" => "finder",
//"folder" => "folder",
"lists" => "lists",
"scope" => "scope",
"tags" => "tags",
//2 "scope" => "scope",
"password" => "password",
"openingHours" => "openingHours",
//"password" => "password",
//"openingHours" => "openingHours",
"hidden" => "hidden",
"timestamp" => "timestamp",
//"timestamp" => "timestamp",
"colorpicker" => "colorpicker",
"date" => "date",
"datetime" => "datetime",
"time" => "time",
"link" => "link",
"captcha" => "captcha",
"tagList" => "tagList",
"location" => "location",
"postalcode" => "postalcode",
"arrayForm" => "arrayForm",
//"link" => "link",
//"captcha" => "captcha",
//"tagList" => "tagList",
//2 "postalcode" => "postalcode",
// "arrayForm" => "arrayForm",
"array" => "array",
"properties" => "properties"
];
......
<style type="text/css">
.toolsMenu{
box-shadow: 0px 1px 3px 0px #a3a3a3;
}
</style>
<script type="text/javascript">
var sectionDyf = {};
var formInputs = {};
var answerObj = <?php echo (!empty($element)) ? json_encode( $element ) : "null"; ?>;
</script>
<div id="preview-elt-<?php echo $type ?>-<?php echo (string)$element["_id"] ?>">
<div class="col-xs-12 padding-10 toolsMenu">
<button class="btn btn-default pull-right btn-close-preview">
<i class="fa fa-times"></i>
</button>
<a href="#answer.index.id.<?php echo (string)$element["_id"] ?>" class="lbh btn btn-primary pull-right margin-right-10"><?php echo Yii::t("common", "Open") ?></a>
</div>
<div class="col-xs-12 no-padding">
<div class="col-xs-12 no-padding container-preview">
<?php
$params = array("answer"=>$element ,
"page" => "page",
"type" => $type,
"form"=> PHDB::findOneById( Form::COLLECTION , $element["form"]),
"canEdit"=>@$canEdit,
"canEditForm"=>false,
"controller" => $controller);
$params = [
"form"=> PHDB::findOneById( Form::COLLECTION , $element["form"]),
"canEdit" => @$canEdit,
"answer"=>$element,
"mode" => (isset($_GET["mode"])) ? $_GET["mode"] : "r",
"showWizard"=>false,
"wizid"=> $element["form"],
"color1"=>"",
"color2"=>""
];
if(isset($params["form"]["subForms"]) && count($params["form"]["subForms"]) > 1)
$params["form"]["subForms"]=[$params["form"]["subForms"][0]];
$params = Form::getDataForm($params);
$params["mode"]=(isset($_GET["mode"])) ? $_GET["mode"] : "r";
echo $this->renderPartial('survey.views.tpls.forms.formWizard', $params );
?>
$params["parentForm"]=$params["form"];
$params["canEditForm"]=false;
echo $this->renderPartial("survey.views.tpls.forms.wizard",$params);
?>
</div>
</div>
\ No newline at end of file
......@@ -71,7 +71,7 @@ if( $mode != "pdf" ){
//if role operateurs
if(!$selectedOperator){
if($isOperator && !$alreadyCandidate && $answer["step"]!="deal12"){
if($isOperator && !$alreadyCandidate && @$answer["step"]!="deal12"){
?>
<tr>
<td colspan='2' class="text-center" >
......@@ -90,13 +90,13 @@ if( $mode != "pdf" ){
} ?>
</tbody>
</table>
<?php if($isFinanceur){ ?>
<div class="col-xs-12 text-center margin-top-50 well">
<?php if(@$answer["step"] && $answer["step"]=="deal1"){ ?>
<span style="font-size: 22px;font-weight: 800;">Ce dossier n'a pas encore d'opérateur rattaché. En tant que financeurs ou administrateur de la DEAL, veuillez valider un opérateur afin de passer ce dossier à l'étape suivant d'instruction.</span>
<?php } ?>
</div>
<?php }
<?php if($isFinanceur){
if(@$answer["step"] && $answer["step"]=="deal1"){ ?>
<div class="col-xs-12 text-center margin-top-50 well">
<span style="font-size: 22px;font-weight: 800;">Ce dossier n'a pas encore d'opérateur rattaché. En tant que financeurs ou administrateur de la DEAL, veuillez valider un opérateur afin de passer ce dossier à l'étape suivant d'instruction.</span>
</div>
<?php }
}
} else { ?>
<?php
if(@$answer["step"]){
......
......@@ -6,7 +6,7 @@ else if(!empty($answer) && isset($answer["answers"][$key]))
$value = $answer["answers"][$key];
if($mode == "r" || $mode == "pdf"){ ?>
<div class="col-xs-12" id="<?php echo $kunik ?>">
<div class="col-xs-12 no-padding" id="<?php echo $kunik ?>">
<label for="<?php echo $kunik ?>"><h4 style="color:<?php echo ($titleColor) ? $titleColor : "black"; ?>"><?php echo $label ?></h4></label>
<?php
if(!empty($value)){
......
......@@ -53,9 +53,14 @@ if($mode != "r" && $mode != "pdf"){
<ul id="dynformUl">
<?php
//var_dump($properties);
//echo "<li> open dyn form _id >".$dynForm["_id"]."</li>";
foreach ( $properties as $k => $inp ) {
echo "<li> > ".
$inp["label"]."<span class='miniTxt'>( ".$inp["type"]." )</span> <a href='javascript:;' data-path='inputs.".$k."' class='pull-right btn btn-xs btn-primary editDynformInput' ><i class='fa fa-pencil'></i></a> <a href='javascript:;' data-path='inputs.".$k."' data-collection='forms' data-id='".$dynForm["_id"]."' class='deleteLine pull-right btn btn-xs btn-danger' ><i class='fa fa-trash'></i></a><li>";
echo "<li id='input".$kunik.$k."'> > ".
$inp["label"]."<span class='miniTxt'>( ".@$inp["inputType"]." ) ".@$inp["placeholder"]." </span> ".
//Edit Input
"<a href='javascript:;' data-path='inputs.".$k."' class='pull-right btn btn-xs btn-primary editDynformInput' ><i class='fa fa-pencil'></i></a>".
//Delete Input
" <a href='javascript:;' data-path='inputs.".$k."' data-inputid='".$kunik.$k."' class='deleteInput pull-right btn btn-xs btn-danger' ><i class='fa fa-trash'></i></a><li>";
} ?>
<li class='text-center'>
<a href='javascript:;' data-id='<?php echo $dynForm["_id"]?>' data-collection='<?php echo Form::COLLECTION?>' data-path='inputs' class='addInputDynform_<?php echo $dynForm["id"]?> btn btn-primary' ><i class="fa fa-plus"></i> Ajouter une Question au formulaire </a>
......@@ -106,18 +111,141 @@ $(document).ready(function() {
icon : "fa-plus",
text : "lorem ipsum lorem ipsum lorem ipsum lorem ipsum lorem ipsum lorem ipsum lorem ipsum lorem ipsum lorem ipsum lorem ipsum lorem ipsum lorem ipsum lorem ipsum lorem ipsum lorem ipsum lorem ipsum lorem ipsum lorem ipsum lorem ipsum lorem ipsum lorem ipsum lorem ipsum ",
onLoads : {
onload : function () { bb.modal('hide') }
onload : function () {
bb.modal('hide');
}
},
properties : {
label : { label : "Titre de la Question au sous Formulaire" },
inputType : {
label : "Type de cette question",
inputType : "select",
options : <?php echo json_encode(Form::$dynformInputTypes); ?>,
value : "text" ,
init:function(){
$("#ajaxFormModal #inputType").on( "change", function(){
$("#ajaxFormModal .listarray,.multiplecheckboxSimple, #ajaxFormModal .openSearchcheckboxSimple, #ajaxFormModal .invitecheckboxSimple,#ajaxFormModal .maxlengthtext,#ajaxFormModal .onTexttext, #ajaxFormModal .offTexttext, #ajaxFormModal .initValuecheckboxSimple, #ajaxFormModal .labelKeytext, #ajaxFormModal .labelValuetext").addClass("hide");
if( $.inArray( $(this).val(), [ "select","finder","radio","tags"] ) >= 0 )
$("#ajaxFormModal .listarray").removeClass("hide");
if( $(this).val() == "finder" )
$("#ajaxFormModal .finderTypesselect, #ajaxFormModal .multiplecheckboxSimple, #ajaxFormModal .openSearchcheckboxSimple, #ajaxFormModal .invitecheckboxSimple").removeClass("hide");
if($.inArray( $(this).val(), [ "textarea","tags"] )>=0)
$("#ajaxFormModal .maxlengthtext").removeClass("hide");
if($(this).val() == "checkboxSimple" )
$( "#ajaxFormModal .onTexttext, #ajaxFormModal .offTexttext, #ajaxFormModal .initValuecheckboxSimple" ).removeClass("hide");
if( $(this).val() == "properties" )
$( "#ajaxFormModal .labelKeytext, #ajaxFormModal .labelValuetext" ).removeClass("hide");
})
}
},
label : { label : "Titre de la Question",rules : {required : true} },
subLabel : { label : "Texte sous la la Question" },
placeholder : { label : "Texte dans la Question" },
info : {
inputType : "textarea",
label : "Information complémentaire sur la Question" },
type : { label : "Type de cette question",
inputType : "select",
options : <?php echo json_encode(Form::$dynformInputTypes); ?>,
value : "text" }
required : {
inputType : "checkboxSimple",
label : "Obligatoire",
subLabel : "Ce champs est obligatoire",
params : {
onText : "Oui",
offText : "Non",
onLabel : "Oui",
offLabel : "Non",
labelText : "Obligatoire"
},
checked : false
},
//config inputs activate later by type
initType : {
inputType : "select",
label : "Les types possible du finder",
placeholder : "types d'éléments",
options : {
"persons" : "Personnes",
"organizations":"Organisations",
"projects":"Projets",
"events":"Evennements",
},
topClass : "hide"
},
multiple : {
inputType : "checkboxSimple",
label : "Multiple",
subLabel : "Configuré le Finder",
params : {
onText : "Oui",
offText : "Non",
onLabel : "Oui",
offLabel : "Non",
labelText : "Multiple"
},
checked : true,
topClass : "hide"
},
openSearch : {
inputType : "checkboxSimple",
label : "Chercher Partout",
subLabel : "Configuré le Finder",
params : {
onText : "Oui",
offText : "Non",
onLabel : "Oui",
offLabel : "Non",
labelText : "Chercher Partout"
},
checked : true,
topClass : "hide"
},
invite : {
inputType : "checkboxSimple",
label : "Invité",
subLabel : "Configuré le Finder",
params : {
onText : "Oui",
offText : "Non",
onLabel : "Oui",
offLabel : "Non",
labelText : "Invité"
},
checked : true,
topClass : "hide"
},
list : {
placeholder : "Liste des options | roles",
label : "Liste des options pour les select et role pour les finders",
inputType : "array",
topClass : "hide",
value : []
},
maxlength : {
label : "Limiter le texte",
inputType : "text",
topClass : "hide"
},
//"rules" : {"required":true,"maxlength" : 200},
onText : { label : "Texte de la Valeur Oui", inputType : "text", topClass : "hide" },
offText : { label : "Texte de la Valeur Non", inputType : "text", topClass : "hide" },
initValue : {
inputType : "checkboxSimple",
label : "Valeur d'ouverture",
subLabel : "Valeur d'ouverture",
params : {
onText : "Oui",offText : "Non",onLabel : "Oui",offLabel : "Non",labelText : "Valeur d'ouverture"
},
checked : true,
topClass : "hide"
},
labelKey : { label : "Label pour la clef", inputType : "text", topClass : "hide" },
labelValue : { label : "Label pour la valeur", inputType : "text", topClass : "hide" }
},
save : function (formData) {
......@@ -125,7 +253,102 @@ $(document).ready(function() {
delete formData.collection ;
delete formData.id ;
tplCtx.value = formData;
tplCtx.value = {};
tplCtx.value.label = formData.label;
tplCtx.value.inputType = formData.inputType;
if(formData.subLabel)
tplCtx.value.subLabel = formData.subLabel;
if(formData.info)
tplCtx.value.info = formData.info;
if(formData.placeholder)
tplCtx.value.placeholder = formData.placeholder;
if(formData.required ) {
tplCtx.value.rules = {};
tplCtx.value.rules.required = formData.required;
}
//alert(tplCtx.value.inputType);
// TYPE SELECT && RADIO
// ****************************
if( $.inArray( tplCtx.value.inputType , [ "select","radio"] )>=0 ) {
tplCtx.value.options = {};
//alert(tplCtx.value["list[]"].length);
$.each( formData["list[]"], function(i,v) {
tplCtx.value.options[ slugify(v) ] = v;
} );
}
// TYPE TAGS and ARRAY
// ****************************
if( $.inArray( tplCtx.value.inputType , [ "tags", "array" ] ) >=0 ){
tplCtx.value.values = [];
if(formData["list[]"]){
$.each( formData["list[]"], function(i,v) {
tplCtx.value.values.push(v);
} );
}
}
// TYPE FINDER
// ****************************
if( tplCtx.value.inputType == "finder" ) {
if(notNull(formData["list[]"]))
tplCtx.value.roles = ($.isArray(formData["list[]"])) ? formData["list[]"] : [formData["list[]"] ];
tplCtx.value.initType = [ "persons", "organizations","projects", "events"];
if(notNull(formData["finderTypes"])){
tplCtx.value.initType = ($.isArray(formData.finderTypes)) ? formData.finderTypes : [formData.finderTypes ];
}
tplCtx.value.multiple = parseBool( formData.multiple );
tplCtx.value.invite = parseBool( formData.invite );
tplCtx.value.openSearch = parseBool( formData.openSearch );
}
// TYPE TEXTAREA
// ****************************
if( $.inArray( tplCtx.value.inputType , [ "textarea","tags"] )>=0 && $("#ajaxFormModal #maxlength").val() != "" ) {
if(tplCtx.value.inputType == "textarea"){
if(typeof tplCtx.value.rules != "undefined")
tplCtx.value.rules = {};
tplCtx.value.rules.maxlength = $("#ajaxFormModal #maxlength").val();
}
else if (tplCtx.value.inputType == "tags"){
// TYPE TAGS
// ****************************
tplCtx.value.minimumInputLength = ($("#ajaxFormModal #maxlength").val() != "") ? $("#ajaxFormModal #maxlength").val() : 3
}
}
// TYPE CHECKBOX
// ****************************
if( tplCtx.value.inputType == "checkboxSimple" ){
tplCtx.value.params = {
onText : formData.onText,
offText : formData.offText,
onLabel : formData.onText,
offLabel : formData.offText,
labelText : formData.label
};
tplCtx.value.checked = parseBool(formData.initValue);
}
if( tplCtx.value.inputType == "array" )
tplCtx.value.value = [""];
if( tplCtx.value.inputType == "properties" ){
tplCtx.value.values = {"",""};
tplCtx.value.labelKey = formData.labelKey;
tplCtx.value.labelValue = formData.labelValue;
}
// TYPE FORMLOCATION
// ****************************
// TYPE IMAGE
// ****************************
mylog.log("save tplCtx",tplCtx);
......@@ -163,24 +386,44 @@ $(document).ready(function() {
tplCtx.id = $(this).data("id");
tplCtx.collection = $(this).data("collection");
smallMenu.open( $("#form-buildDynform<?php echo $dynForm["id"]?>").html(),"bootbox",null,function() {
$(".addInputDynform_<?php echo $dynForm["id"]?>").off().click(function() {
tplCtx.path = "inputs.q<?php echo "_".time()."_".count( $properties ); ?>";
mylog.log("addInput tplCtx",tplCtx);
dyFObj.openForm( sectionDyf.newDFInput<?php echo $dynForm["id"]?> );
});
$(".editDynformInput").off().on("click",function() {
tplCtx.id = "<?php echo $dynForm["_id"]?>";
tplCtx.collection = "<?php echo Form::COLLECTION;?>";
tplCtx.path = $(this).data("path");
dyFObj.openForm( sectionDyf.<?php echo $kunik ?>,null, <?php echo $kunik ?>Data[$(this).data("key")]);
});
$(".deleteInput").off().on("click",function() {
tplCtx.id = "<?php echo $dynForm["_id"]?>";
tplCtx.collection = "<?php echo Form::COLLECTION;?>";
tplCtx.path = $(this).data("path");
tplCtx.inputId = $(this).data("inputid");
tplCtx.value = null;
mylog.log('deleteInput tplCtx', tplCtx)
if($('li#input'+tplCtx.inputId).hasClass('bg-red')){
dataHelper.path2Value( tplCtx, function(params) {
$('li#input'+tplCtx.inputId).slideUp();//urlCtrl.loadByHash(location.hash);
} );
} else
$('li#input'+tplCtx.inputId).addClass('bg-red');
});
});
//on pourrait utiliser DF directement en changeant les btn save et ajoutant edit et suppr
//dyFObj.openForm( sectionDyf.<?php echo $kunik ?>,null, <?php echo $kunik ?>Data[$(this).data("key")],null,null,"build");
});
$(".editDynformInput").off().on("click",function() {
tplCtx.id = "<?php echo $dynForm["_id"]?>";
tplCtx.collection = "<?php echo Form::COLLECTION;?>";
tplCtx.path = $(this).data("path");
dyFObj.openForm( sectionDyf.<?php echo $kunik ?>,null, <?php echo $kunik ?>Data[$(this).data("key")]);
});
......
......@@ -37,11 +37,6 @@ if( !isset($parentForm["startDate"]) ||
} else if( count($myAnswers) == 0 ) {
echo "<h4>Bienvenue vous n'avez pas encore participer.</h4>";
// $countTotalAnswers = PHDB::count( Form::ANSWER_COLLECTION,[ "formId" => $formId,
// "parentSlug" => $el["slug"] ] );
// $countdistinctUsers = count(PHDB::distinct( Form::ANSWER_COLLECTION,"user",[ "formId" => $formId,
// "parentSlug" => $el["slug"] ] ));
$countTotalAnswers = PHDB::count( Answer::COLLECTION,[ "form" => (String)$form['_id'] ] );
$countdistinctUsers = count(PHDB::distinct( Answer::COLLECTION,"user",[ "form" => (String)$form['_id'] ] ));
if($countTotalAnswers == 0)
......@@ -51,10 +46,7 @@ if( !isset($parentForm["startDate"]) ||
echo "<a class='btn btn-primary' href='/costum/co/index/slug/".$el["slug"]."/new/true'>Participer</a>";
} else {
// echo "<h4>Vous avez deja participer, vous pouvez retoucher vos ".PHDB::count( Form::ANSWER_COLLECTION,[ "formId" => $formId,
// "parentSlug" => $el["slug"],
// "user" => Yii::app()->session["userId"] ] )." réponses dans la liste.</h4>";
echo "<h4>Vous avez deja participer, vous pouvez retoucher vos ".
PHDB::count( Form::ANSWER_COLLECTION,
[ "form" => (String)$form['_id'],
......
......@@ -204,6 +204,7 @@ if(isset($this->costum["cms"]["color1"]))
"answer"=>$answer,
"showForm" => $showForm,
"mode" => $mode,
"showWizard"=>true,
"wizid"=> $wizardUid
];
......
......@@ -53,7 +53,7 @@ if( isset( $form["inputs"] ) ){ ?>
//fin nouvelle repositionnement
//echo json_encode($form["inputs"]) ;
$dragNDrop = ($canEditForm) ? "dragNDrop" : "" ;
echo "<ul class='questionList ".$dragNDrop."'>";
echo "<ul class='questionList col-xs-12 ".$dragNDrop."'>";
foreach ( $form["inputs"] as $key => $input) {
$canAnswer = (Yii::app()->session["userId"] == $answer["user"] || !empty($parentForm["anyOnewithLinkCanAnswer"])) ? true :false;
$editQuestionBtn = ($canEditForm) ? " <a class='btn btn-xs btn-danger editQuestion' href='javascript:;' data-form='".$form["id"]."' data-id='".$form["_id"]."' data-collection='".Form::COLLECTION."' data-key='".$key."' data-path='inputs.".$key."'><i class='fa fa-pencil'></i></a>".
......
......@@ -12,7 +12,7 @@ if(!isset($options) && isset($parentForm["params"][$key]['options']))
$options = $parentForm["params"][$key]['options'];
if($mode == "r" || $mode == "pdf"){ ?>
<div class="col-xs-12" id="<?php echo $kunik ?>">
<div class="col-xs-12 no-padding" id="<?php echo $kunik ?>">
<label for="<?php echo $kunik ?>"><h4 style="color:<?php echo ($titleColor) ? $titleColor : "black"; ?>"><?php echo $label ?></h4></label><br/>
<?php echo (!empty($options) && !empty($options[$answers])) ? $options[$answers] : "" ; ?>
</div>
......
......@@ -10,7 +10,7 @@ if($saveOneByOne)
$inpClass .= " saveOneByOne";
if($mode == "r" || $mode == "pdf"){ ?>
<div class="col-xs-12" id="<?php echo $kunik ?>">
<div class="col-xs-12 no-padding" id="<?php echo $kunik ?>">
<label for="<?php echo $kunik ?>"><h4 style="color:<?php echo ($titleColor) ? $titleColor : "black"; ?>"><?php echo $label ?></h4></label><br/>
<?php echo $answers; ?>
</div>
......
......@@ -4,7 +4,7 @@ if($saveOneByOne)
$inpClass = " saveOneByOne";
if($mode == "r" || $mode == "pdf"){ ?>
<div class="col-xs-12" id="<?php echo $kunik ?>">
<div class="col-xs-12 no-padding" id="<?php echo $kunik ?>">
<label for="<?php echo $kunik ?>"><h4 style="color:<?php echo ($titleColor) ? $titleColor : "black"; ?>"><?php echo $label ?></h4></label><br/>
<?php echo $answers; ?>
</div>
......
......@@ -40,51 +40,52 @@ if( isset($parentForm["subForms"]) && count($parentForm["subForms"]) > 1 ) {
border-color: <?php echo ( @$color2 ) ? $color2 : $defaultColor ?>;
}
</style>
<ul id="wizardLinks">
<?php
// var_dump($listSteps); exit;
$activeStep = 0;
$nextStepValid =true;
foreach ($parentForm["subForms"] as $k => $v) {
$n = "todo";
$p = null;
if( !empty($forms[$v]) )
$n = $forms[$v]["name"];
<?php if(!empty($showWizard)){ ?>
<ul id="wizardLinks">
<?php
// var_dump($listSteps); exit;
$activeStep = 0;
$nextStepValid =true;
echo "<li>";
foreach ($parentForm["subForms"] as $k => $v) {
$n = "todo";
$p = null;