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