Commit 6bd29e78 authored by Raph El's avatar Raph El
Browse files

Hotfix formList and drap N drop uniquement en mode fa

parent 09c9956f
...@@ -660,22 +660,25 @@ class Form { ...@@ -660,22 +660,25 @@ class Form {
$budgetInputList = []; $budgetInputList = [];
$allforms = []; $allforms = [];
$stockBudgetInputs = false; $stockBudgetInputs = false;
foreach ($params["formList"] as $i => $formId) if(!empty($params["formList"])){
{ foreach ($params["formList"] as $i => $formId)
$f = PHDB::findOne(Form::COLLECTION, ["id"=>$formId]); {
$allforms[$formId] = $f; $f = PHDB::findOne(Form::COLLECTION, ["id"=>$formId]);
foreach ($f["inputs"] as $key => $inp) $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.budget"] ) )
if( in_array($inp["type"], [ $budgetInputList[$formId.".".$key] = $formId.".".$key;
"tpls.forms.cplx.tpls.forms.cplx.financementFromBudget", if( in_array($inp["type"], [
"tpls.forms.cplx.tpls.forms.cplx.suiviFromBudget", "tpls.forms.cplx.tpls.forms.cplx.financementFromBudget",
"tpls.forms.cplx.tpls.forms.cplx.decideFromBudget"] ) ) "tpls.forms.cplx.tpls.forms.cplx.suiviFromBudget",
$stockBudgetInputs = true; "tpls.forms.cplx.tpls.forms.cplx.decideFromBudget"] ) )
$stockBudgetInputs = true;
}
} }
}
}
if(count($budgetInputList)) if(count($budgetInputList))
Yii::app()->session["budgetInputList"] = $budgetInputList; Yii::app()->session["budgetInputList"] = $budgetInputList;
//var_dump($budgetInputList); //var_dump($budgetInputList);
...@@ -743,91 +746,95 @@ class Form { ...@@ -743,91 +746,95 @@ class Form {
$showForm = true; $showForm = true;
$myAnswers = self::getListAnswersBy($params["formId"], $params["el"]["slug"], Yii::app()->session["userId"]);
if(!empty($params["formId"])){
$myAnswers = self::getListAnswersBy($params["formId"], $params["el"]["slug"], Yii::app()->session["userId"]);
if(!isset($costum["form"]["oneAnswerPerPerson"]) || count($myAnswers) == 0){ if(!isset($costum["form"]["oneAnswerPerPerson"]) || count($myAnswers) == 0){
//si ya qu'une réponse et on la charge directe //si ya qu'une réponse et on la charge directe
if(count($myAnswers) == 1 ) if(count($myAnswers) == 1 )
$answer = $myAnswers[ array_keys($myAnswers)[0] ]; $answer = $myAnswers[ array_keys($myAnswers)[0] ];
else { else {
//sinon on cherche la reponse incomplete //sinon on cherche la reponse incomplete
foreach ($myAnswers as $id => $ans) foreach ($myAnswers as $id => $ans)
{ {
//chercher les reponse incomplete //chercher les reponse incomplete
if(!isset( $ans["answers"]) && $answer == null ) if(!isset( $ans["answers"]) && $answer == null )
$answer = $ans; $answer = $ans;
} }
} }
if( $answer == null && count( $myAnswers ) > 1 && !$params["canEdit"] ) if( $answer == null && count( $myAnswers ) > 1 && !$params["canEdit"] )
$showForm = false; $showForm = false;
//si aucune reponse existe //si aucune reponse existe
//et qu'on a des input complexe alors on génere une answer //et qu'on a des input complexe alors on génere une answer
// if( !isset($_GET['answer']) && $answer == null ){ // if( !isset($_GET['answer']) && $answer == null ){
// if(isset($params["formList"])){ // if(isset($params["formList"])){
// $generateAnswer = true; // $generateAnswer = true;
// } // }
// else if(isset($form["inputs"])){ // else if(isset($form["inputs"])){
// foreach ($form["inputs"] as $key => $inp) // foreach ($form["inputs"] as $key => $inp)
// { // {
// if( stripos( $inp["type"] , "tpls.forms.cplx" ) !== false ) // if( stripos( $inp["type"] , "tpls.forms.cplx" ) !== false )
// $generateAnswer = true; // $generateAnswer = true;
// } // }
// } // }
// } // }
// if( isset($answerId) && $answerId == "new" ) // if( isset($answerId) && $answerId == "new" )
// $generateAnswer = true; // $generateAnswer = true;
//on pré genere un anwser que quand il n'y en pas //on pré genere un anwser que quand il n'y en pas
//pour permettre le save onBlur , ou s'il y a des cplx forms //pour permettre le save onBlur , ou s'il y a des cplx forms
//il ne peut y avoir qu'un seul answer en cours simultanement //il ne peut y avoir qu'un seul answer en cours simultanement
//on pré genere un anwser que quand il n'y en pas //on pré genere un anwser que quand il n'y en pas
//pour permettre le save onBlur , ou s'il y a des cplx forms //pour permettre le save onBlur , ou s'il y a des cplx forms
//il ne peut y avoir qu'un seul answer en cours simultanement //il ne peut y avoir qu'un seul answer en cours simultanement
///TODO purger ANSwers via CRON ///TODO purger ANSwers via CRON
// if( $generateAnswer ) // if( $generateAnswer )
// { // {
// //var_dump("create new" ); // //var_dump("create new" );
// $ans = [ // $ans = [
// "formId" => $params["formId"], // "formId" => $params["formId"],
// "user" => Yii::app()->session["userId"], // "user" => Yii::app()->session["userId"],
// "parentSlug" => $params["el"]["slug"], // "parentSlug" => $params["el"]["slug"],
// "links"=>[ // "links"=>[
// "answered" => [ Yii::app()->session["userId"] ] , // "answered" => [ Yii::app()->session["userId"] ] ,
// //proposed ,particpated,decision,financed,financed,referenced,commented,worked,payed,tested,validated // //proposed ,particpated,decision,financed,financed,referenced,commented,worked,payed,tested,validated
// //each actor is connectable to his activitystream // //each actor is connectable to his activitystream
// ], // ],
// "created" => time() // "created" => time()
// ]; // ];
// if(isset($params["formList"])) // if(isset($params["formList"]))
// $ans["formList"] = count($params["formList"]); // $ans["formList"] = count($params["formList"]);
// PHDB::insert(Form::ANSWER_COLLECTION, $ans); // PHDB::insert(Form::ANSWER_COLLECTION, $ans);
// $answer = PHDB::findOne( Form::ANSWER_COLLECTION, [ "_id" => new MongoId($ans["_id"]) ] ); // $answer = PHDB::findOne( Form::ANSWER_COLLECTION, [ "_id" => new MongoId($ans["_id"]) ] );
// } // }
// var_dump($params["el"]["slug"] ); // var_dump($params["el"]["slug"] );
// var_dump($params["formId"] ); // var_dump($params["formId"] );
// var_dump($answer ); // var_dump($answer );
// var_dump(Yii::app()->getRequest()->getQuery('answer')); // var_dump(Yii::app()->getRequest()->getQuery('answer'));
// exit; // exit;
$params["answer"] = $answer; $params["answer"] = $answer;
$params["showForm"] = $showForm; $params["showForm"] = $showForm;
$params["showAnswerActions"]=(isset($params["showAnswerActions"])) ? $params["showAnswerActions"] : true; $params["showAnswerActions"]=(isset($params["showAnswerActions"])) ? $params["showAnswerActions"] : true;
$allAnswers = self::getListAnswersBy($params["formId"], $params["el"]["slug"] ) ; $allAnswers = self::getListAnswersBy($params["formId"], $params["el"]["slug"] ) ;
$params["allAnswers"] = (isset($allAnswers)) ? $allAnswers : [] ; $params["allAnswers"] = (isset($allAnswers)) ? $allAnswers : [] ;
//var_dump($params["el"]["slug"]);exit; //var_dump($params["el"]["slug"]);exit;
//var_dump($params["allAnswers"]);exit; //var_dump($params["allAnswers"]);exit;
} else { } else {
echo "<h4 class='text-center text-red'><i class='fa fa-warning'></i> Une seul réponse n'est possible.</h4>"; echo "<h4 class='text-center text-red'><i class='fa fa-warning'></i> Une seul réponse n'est possible.</h4>";
echo "<a class='btn btn-primary' href='/costum/co/index/slug/".$el["slug"]."/answer/".$myAnswers[0]."'>Votre réponse</a>"; echo "<a class='btn btn-primary' href='/costum/co/index/slug/".$el["slug"]."/answer/".$myAnswers[0]."'>Votre réponse</a>";
}
} }
} }
return $params; return $params;
} }
......
...@@ -51,8 +51,8 @@ if( isset( $form["inputs"] ) ){ ?> ...@@ -51,8 +51,8 @@ if( isset( $form["inputs"] ) ){ ?>
//fin nouvelle repositionnement //fin nouvelle repositionnement
//echo json_encode($form["inputs"]) ; //echo json_encode($form["inputs"]) ;
$dragNDrop = ($canEditForm) ? "dragNDrop" : "" ;
echo "<ul class='questionList'>"; echo "<ul class='questionList ".$dragNDrop."'>";
foreach ( $form["inputs"] as $key => $input) { foreach ( $form["inputs"] as $key => $input) {
$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>". $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>".
...@@ -309,7 +309,7 @@ jQuery(document).ready(function() { ...@@ -309,7 +309,7 @@ jQuery(document).ready(function() {
} }
//questions can be ordered by drag n drop //questions can be ordered by drag n drop
$( ".questionList" ).sortable({ $( ".dragNDrop" ).sortable({
stop: function(event, ui) { stop: function(event, ui) {
//alert("New position: " + ui.item.index()+ ui.item.data("key")+ ui.item.data("form")); //alert("New position: " + ui.item.index()+ ui.item.data("key")+ ui.item.data("form"));
tplCtx.id = ui.item.data("id"); tplCtx.id = ui.item.data("id");
......
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