Commit 85d2ca9d authored by Raph El's avatar Raph El
Browse files

Form : Test & hotfix for mode fa

parent b1d0a9da
......@@ -65,12 +65,14 @@ class IndexAction extends CAction
}
// var_dump($canEditAnswer);
// var_dump($canSeeAnswer);
if($canEditAnswer === true || $canSeeAnswer === true){
$params["canEditForm"] = $canEditForm;
$params["canEdit"] = $canEditAnswer;
$params["canSee"] = $canSeeAnswer;
$params["mode"] = (!empty($mode) ? $mode : "r");
//$tpl=(!empty($tpl)) ? $tpl : "survey.views.tpls.forms.formWizard";
//Rest::json($params); exit;
$tpl=(!empty($this->getController()->costum["form"]["tpl"])) ? $this->getController()->costum["form"]["tpl"] : "survey.views.tpls.forms.formWizard";
echo $this->getController()->renderPartial($tpl,$params );
} else {
......
......@@ -36,7 +36,7 @@ class GetAction extends CTKAction
}
// $params["forms"][$fix]["answers"] = PHDB::count( Form::ANSWER_COLLECTION, ["formId"=>$formId , "parentSlug" => $slug] );
$params["forms"][$fix]["answers"] = PHDB::count( Form::ANSWER_COLLECTION, ["form"=>$fix] );
$params["forms"][$fix]["answers"] = PHDB::count( Answer::COLLECTION, ["form"=>$fix] );
}
}
......
......@@ -669,17 +669,20 @@ class Form {
{
$f = PHDB::findOne(Form::COLLECTION, ["id"=>$formId]);
$allforms[$formId] = $f;
foreach ($f["inputs"] as $key => $inp)
{
if( in_array($inp["type"], ["tpls.forms.cplx.budget"] ) )
$budgetInputList[$formId.".".$key] = $formId.".".$key;
if( in_array($inp["type"], [
"tpls.forms.cplx.tpls.forms.cplx.financementFromBudget",
"tpls.forms.cplx.tpls.forms.cplx.suiviFromBudget",
"tpls.forms.cplx.tpls.forms.cplx.decideFromBudget"] ) )
$stockBudgetInputs = true;
if(!empty($f["inputs"])){
foreach ($f["inputs"] as $key => $inp)
{
if( in_array($inp["type"], ["tpls.forms.cplx.budget"] ) )
$budgetInputList[$formId.".".$key] = $formId.".".$key;
if( in_array($inp["type"], [
"tpls.forms.cplx.tpls.forms.cplx.financementFromBudget",
"tpls.forms.cplx.tpls.forms.cplx.suiviFromBudget",
"tpls.forms.cplx.tpls.forms.cplx.decideFromBudget"] ) )
$stockBudgetInputs = true;
}
}
}
}
......
......@@ -29,7 +29,7 @@ if( !isset($parentForm["startDate"]) ||
$params["saveOneByOne"] = true;
$params["wizard"] = true;
}
echo $this->renderPartial("survey.views.tpls.forms.formbuilder",$params ,true );
} else if( count($myAnswers) == 0 ) {
echo "<h4>Bienvenue vous n'avez pas encore participer.</h4>";
......
......@@ -133,7 +133,7 @@ if( isset( $form["inputs"] ) ){ ?>
<?php } ?>
</form>
<?php }
var_dump($canEditForm);
if ($canEditForm) { ?>
<div class="text-center">
<a href="javascript:;" class="addQuestion btn btn-danger" data-form="<?php echo $formId ?>" data-id="<?php echo $form['_id'] ?>" ><i class="fa fa-plus"></i> Ajouter Une Question</a>
......
......@@ -44,11 +44,13 @@ if( isset($this->costum["tpls"][$keyTpl]) ) {
// var_dump($listSteps); exit;
$activeStep = 0;
$nextStepValid =true;
foreach ($formList as $k => $v) {
$n = "todo";
$p = null;
$form = PHDB::findOne( Form::COLLECTION,[ "id"=>$v ] );
$form = PHDB::findOne( Form::COLLECTION,[ "id"=>$v ] );
if( !empty($form) )
$n = $form["name"];
......@@ -82,41 +84,47 @@ if( isset($this->costum["tpls"][$keyTpl]) ) {
</ul>
<?php
<?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;
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);
});
<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 ( !empty($form['inputs']) ? json_encode( $form['inputs'] ) : json_encode([]) ) ?>;
var formInputsHere = formInputs;
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>
function showStepForm(id){
mylog.log("showStepForm", id);
$(".sectionStep").addClass("hide");
$(id).removeClass("hide");
localStorage.setItem("wizardStep",id);
}
</script>
<?php
if( !empty($form) )
{
echo '<h1 class="text-center" style="color:'.$color1.'" >'.@$form["name"].'</h1>';
echo "<div class='text-center'>";
if(isset($this->costum["cms"][$form["id"]."desc"]))
......
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