Commit 682bb3cb authored by Raph El's avatar Raph El
Browse files

Answer : hotfix pdf ans csv

parent 2d2bde81
......@@ -24,16 +24,19 @@ class DirectoryAction extends CAction
"collection" => $_POST["collection"],
"slug" => $_POST["slug"] );
$searchRegExp = Search::accentToRegex($search);
//$query=array("parentSlug"=>$slug);
$queryForm = array("parent.".$_POST["id"] => array('$exists' => 1 ) );
if(!empty($controller->costum) && !empty($controller->costum["slug"]))
$queryForm = array('$and' => array( $queryForm , array("source.key" => $controller->costum["slug"]) ) ) ;
$forms = PHDB::find(Form::COLLECTION, array("parent.".$_POST["id"] => array('$exists' => 1 ) ) , array("name") );
$forms = PHDB::find(Form::COLLECTION, $queryForm , array("name") );
$idFs = array();
foreach ($forms as $keyF => $valF) {
$idFs[] = $keyF;
}
$query=array( "form"=>array('$in' => $idFs) );
//Rest::json($query); exit;
$searchRegExp = Search::accentToRegex($search);
$querySearch = array();
if(!empty($querySearch))
$query = array('$and' => array( $query , $querySearch ) ) ;
......@@ -41,7 +44,10 @@ class DirectoryAction extends CAction
if(!empty($panelAdmin['filters'])){
$query = Search::searchFilters($panelAdmin['filters'], $query);
}
if(!empty($controller->costum) && !empty($controller->costum["slug"]))
$query = array('$and' => array( $query , array("source.key" => $controller->costum["slug"]) ) ) ;
//Rest::json($query); exit;
$params["typeDirectory"]=[ Answer::COLLECTION ];
$params["results"] = array();
$answers = PHDB::findAndLimitAndIndex ( Answer::COLLECTION , $query, $stepLim, $limitMin);
......
......@@ -260,5 +260,24 @@ class Answer{
return $answerList;
}
public static function csv($elements, $idElt, $valElt, $forms ){
$elements[$idElt]["id"] = $idElt;
$elements[$idElt]["user"] = $valElt["user"];
$elements[$idElt]["created"] = $valElt["created"];
if(!empty($valElt["answers"])){
foreach ($forms as $keyF => $valF) {
if(!empty($valF["id"]) && !empty($valElt["answers"][$valF["id"]])){
foreach ($valElt["answers"][$valF["id"]] as $keyAns => $valAns) {
if(!empty($valF["inputs"]) && !empty($valF["inputs"][$keyAns]) && !empty($valF["inputs"][$keyAns]["label"])){
$elements[$idElt][$valF["inputs"][$keyAns]["label"]] = $valAns;
}
}
}
}
}
return $elements;
}
}
?>
\ No newline at end of file
......@@ -13,36 +13,37 @@ if( isset( $form["inputs"] ) ){ ?>
foreach ( $form["inputs"] as $key => $input) {
if( stripos( $input["type"] , "tpls.forms.cplx" ) !== false )
$saveOneByOne = true;
}
foreach ( $form["inputs"] as $key => $input) {
if(isset($input["position"])){
$orderInputs[(int)$input["position"]] = $input;
$orderInputsKeys[(int)$input["position"]] = $key;
}
foreach ( $form["inputs"] as $key => $input) {
if(isset($input["position"])){
$orderInputs[(int)$input["position"]] = $input;
$orderInputsKeys[(int)$input["position"]] = $key;
}
}
}
$inV = $form["inputs"];
foreach ( $form["inputs"] as $key => $input) {
if(!isset($input["position"])){
unset( $form["inputs"][$key]);
}else{
unset( $inV[$key]);
}
$inV = $form["inputs"];
foreach ( $form["inputs"] as $key => $input) {
if(!isset($input["position"])){
unset( $form["inputs"][$key]);
}else{
unset( $inV[$key]);
}
}
if(!function_exists('sortByPosOrder'))
{
function sortByPosOrder($a, $b) {
return (int)$a['position'] - (int)$b['position'];
}
if(!function_exists('sortByPosOrder'))
{
function sortByPosOrder($a, $b) {
return (int)$a['position'] - (int)$b['position'];
}
}
uasort($form["inputs"], 'sortByPosOrder');
uasort($form["inputs"], 'sortByPosOrder');
$form["inputs"] = array_merge($form["inputs"], $inV);
$form["inputs"] = array_merge($form["inputs"], $inV);
//nouvelle repositionnement
......@@ -140,8 +141,8 @@ 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>
</div>
<?php } ?>
<?php }
if ($mode != "pdf") { ?>
<script type="text/javascript">
var initValues = <?php echo (!empty($initValues)) ?json_encode( $initValues ) : "null"; ?>;
......@@ -503,3 +504,4 @@ function saveLinks(id,linkType,uid,callB){
}
</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