Commit bedc4a12 authored by Raph El's avatar Raph El
Browse files

Hotfix form + test admin form

parent 880ce88f
......@@ -24,12 +24,12 @@ class DirectoryAction extends CAction
$idFs[] = $keyF;
}
$res = Form::getBySourceAndId($controller->costum["slug"]);
//Rest::json($res); exit;
$searchParams = $_POST;
$searchParams["count"] = true;
$answers=Answer::globalAutocomplete($res["form"], $searchParams);
$answerList = Form::listForAdmin($answers["results"]) ;
$answerList = Answer::getDataAnswers($answerList, $res["forms"]);
$answerList = Answer::getDataAnswers($answerList, $res["forms"], $res["form"]);
$panelAdmin["context"] = array( "id" => $_POST["id"],
"collection" => $_POST["collection"],
......
......@@ -172,13 +172,13 @@ class Answer{
}
public static function getDataAnswers($answerList, $forms){
public static function getDataAnswers($answerList, $subForms, $form){
$globalLinks = [];
$gUids = [];
if(!empty($answerList)){
foreach ($answerList as $key => $ans) {
if(isset($res["form"]["mapping"])){
$answerList[$key]["mappingValues"]=Answer::getMappingValues($res["form"]["mapping"], $ans);
if(isset($form["mapping"])){
$answerList[$key]["mappingValues"]=Answer::getMappingValues($form["mapping"], $ans);
}
$answerList[$key]["countComment"] = PHDB::count(Comment::COLLECTION, array("contextId"=>$key,"contextType"=>Form::ANSWER_COLLECTION));
......@@ -192,7 +192,7 @@ class Answer{
} else {
$totalInputs = 0;
$answeredInputs = 0;
foreach ($forms as $fid => $f){
foreach ($subForms as $fid => $f){
$totalInputs += count($f["inputs"]);
if( isset( $ans["answers"][$fid] ) ){
$answeredInputs += count( $ans["answers"][$fid] );
......@@ -254,7 +254,6 @@ class Answer{
}
}
return $answerList;
}
public static function csv($elements, $idElt, $valElt, $forms ){
......
......@@ -17,7 +17,6 @@ if($canEditForm === true){
<script type="text/javascript">
var tplCtx = {};
var form = <?php echo (!empty($form)) ? json_encode( $form ) : "null"; ?>;
var subForms = <?php echo json_encode($subFormIds)?>;
jQuery(document).ready(function() {
......
......@@ -142,6 +142,7 @@ if(isset($this->costum["cms"]["color1"]))
<script type="text/javascript">
var formInputs = {};
var answerObj = <?php echo (!empty($answer)) ? json_encode( $answer ) : "null"; ?>;
var form = <?php echo (!empty($form)) ? json_encode( $form ) : "null"; ?>;
</script>
<div class="col-xs-12 margin-top-20">
<?php
......
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