Commit 47a41982 authored by Anatole Rakotoson's avatar Anatole Rakotoson

Merge remote-tracking branch 'origin/qa' into qa

parents 650083b4 2e68bb95
...@@ -40,7 +40,10 @@ class IndexAction extends CAction ...@@ -40,7 +40,10 @@ class IndexAction extends CAction
$canEditAnswer = false; $canEditAnswer = false;
$canSeeAnswer = false; $canSeeAnswer = false;
if(empty($mode) || ( $mode != "w" && $mode != "r" ) )
if( empty($mode) || ( $mode != "w" && $mode != "r" ) ||
( !empty($answer["validated"]) && $answer["validated"] == true) )
$mode = "r"; $mode = "r";
if(!empty(Yii::app()->session['userId'])){ if(!empty(Yii::app()->session['userId'])){
......
<?php <?php
class ValidateAction extends CAction class ValidateAction extends CAction
{ {
public function run($id=null, $type=null , $tpl=null) public function run()
{ {
//$controller = $this->getController();
$params = $_POST;
$res = Answer::validate($_POST); $params["controller"] = $this->getController();
Rest::json($_POST); $res = Answer::validate($params);
Rest::json($res);
} }
} }
\ No newline at end of file
...@@ -24,7 +24,6 @@ class DirectoryAction extends CAction ...@@ -24,7 +24,6 @@ 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);
......
...@@ -108,6 +108,7 @@ class Answer{ ...@@ -108,6 +108,7 @@ class Answer{
} }
public static function globalAutocomplete($form, $searchParams){ public static function globalAutocomplete($form, $searchParams){
//var_dump($form);
$searchParams["indexMin"] = (isset($searchParams["indexMin"])) ? $searchParams["indexMin"] : 0; $searchParams["indexMin"] = (isset($searchParams["indexMin"])) ? $searchParams["indexMin"] : 0;
$searchParams["indexStep"] = (isset($searchParams["indexStep"])) ? $searchParams["indexStep"] : 100; $searchParams["indexStep"] = (isset($searchParams["indexStep"])) ? $searchParams["indexStep"] : 100;
$mappingData=(isset($form["mapping"])) ? $form["mapping"] : array("name"=>"name", "address"=>"address"); $mappingData=(isset($form["mapping"])) ? $form["mapping"] : array("name"=>"name", "address"=>"address");
...@@ -149,7 +150,7 @@ class Answer{ ...@@ -149,7 +150,7 @@ class Answer{
$query = Search::searchFilters($searchParams['filters'], $query); $query = Search::searchFilters($searchParams['filters'], $query);
} }
$res= array(); $res= array();
//var_dump($query);exit; //Rest::json($query);exit;
$res["results"] = PHDB::findAndLimitAndIndex ( self::COLLECTION , $query, $searchParams["indexStep"], $searchParams["indexMin"]); $res["results"] = PHDB::findAndLimitAndIndex ( self::COLLECTION , $query, $searchParams["indexStep"], $searchParams["indexMin"]);
if(isset($searchParams["count"])) if(isset($searchParams["count"]))
$res["count"][self::COLLECTION] = PHDB::count( self::COLLECTION , $query); $res["count"][self::COLLECTION] = PHDB::count( self::COLLECTION , $query);
...@@ -365,47 +366,77 @@ class Answer{ ...@@ -365,47 +366,77 @@ class Answer{
} }
public static function validate($params){ public static function validate($params){
//Rest::json($params); exit;
$costum = CacheHelper::getCostum(); $costum = CacheHelper::getCostum();
$set = array(); $set = array();
$res = array('result' => false, "msg" => "Erreur");
if(!empty($params["validated"]) && $params["validated"] === true) if(!empty($params["answerId"]))
$set["validated"] = true; $answer = PHDB::findOneById(Answer::COLLECTION, $params["answerId"]);
if(!empty($params["input"]["generateElement"])){ if(!empty($answer)){
$mapping = array(); //Rest::json($answer); exit;
$import = array( if(!empty($params["input"]["validated"]) && ( $params["input"]["validated"] === true || $params["input"]["validated"] === "true" ) )
'file' => array(json_encode(array($params["answer"]))), $set["validated"] = true;
'nameFile' => "test",
'typeFile' => 'json',
"warnings" => "false"
);
foreach ($params["input"]["generateElement"] as $type => $map) { if(!empty($params["input"]["generateElement"])){
$mapping = array(); $mapping = array();
foreach ($map as $k => $v) { $import = array(
$mapping[] =array( 'file' => array(json_encode(array($answer))),
'idHeadCSV' => $v["from"], 'nameFile' => "test",
'valueAttributeElt' => $v["to"] 'typeFile' => 'json',
); "warnings" => "false"
);
//Rest::json($import); exit;
foreach ($params["input"]["generateElement"] as $type => $map) {
$mapping = array();
foreach ($map as $k => $v) {
$mapping[] =array(
'idHeadCSV' => $v["from"],
'valueAttributeElt' => $v["to"]
);
}
$import['infoCreateData'] = $mapping;
$import['typeElement'] = $type;
//Rest::json($import); exit;
$resImport = Import::previewData($import, true, true, true);
Rest::json($resImport); exit;
foreach ($resImport["elementsObj"] as $keyElt => $elt) {
$elt = Import::checkElement($elt, $type);
if(!empty($elt["msgError"]))
unset($elt["msgError"]);
$elt["collection"] = $type;
$elt["key"] = $type;
if(Costum::isSameFunction("generateElementBeforeSave")){
$elt = Costum::sameFunction("generateElementBeforeSave", $elt);
}
$save = Element::save($elt);
//Rest::json($save); exit;
Link::connect($save["id"], $type, $params["answerId"], Answer::COLLECTION, Yii::app()->session["userId"], "answers",false,false,false,false);
Link::connect($params["answerId"], Answer::COLLECTION, $save["id"], $type, Yii::app()->session["userId"], $type,false,false,false,false);
}
$res = array('result' => true, "msg" => "Valider");
//Rest::json($resImport); exit;
} }
$import['infoCreateData'] = $mapping;
$import['typeElement'] = $type;
$resImport = Import::previewData($import, true, true, true);
Rest::json($resImport); exit;
} }
}
if(Costum::isSameFunction("answerValidate")){ if(Costum::isSameFunction("answerValidate")){
$paramBeforeValidate = Costum::sameFunction("answerValidate", $params); $paramBeforeValidate = Costum::sameFunction("answerValidate", $params);
} }
if(!empty($set)){
PHDB::update(Answer::COLLECTION,
array( "_id" => new MongoId((string)$params["answerId"])),
array( '$set' => $set ) );
if(!empty($set)){ $res = array('result' => true, "msg" => "Valider");
PHDB::update(Answer::COLLECTION, }
array( "_id" => new MongoId((string)$params["answerId"])),
array( '$set' => $set ) );
$res = array('result' => true, "msg" => "Valider"); if($res["result"] === true){
$res["html"] = $params["controller"]->renderPartial('survey.views.tpls.forms.finish', $res, true);
}
} }
return $res; return $res;
......
...@@ -184,10 +184,12 @@ class Form { ...@@ -184,10 +184,12 @@ class Form {
} }
$res["form"]=PHDB::findOne( Form::COLLECTION, $queryForm ); $res["form"]=PHDB::findOne( Form::COLLECTION, $queryForm );
$res["forms"] = []; $res["forms"] = [];
foreach ($res["form"]["subForms"] as $ix => $formId) { if(!empty($res["form"]["subForms"])){
$f = PHDB::findOne(Form::COLLECTION, ["id"=>$formId]); foreach ($res["form"]["subForms"] as $ix => $formId) {
$res["forms"][$formId] = $f; $f = PHDB::findOne(Form::COLLECTION, ["id"=>$formId]);
} $res["forms"][$formId] = $f;
}
}
return $res; return $res;
} }
public static function getById($parentForm, $fields=array()){ public static function getById($parentForm, $fields=array()){
......
...@@ -127,7 +127,7 @@ ...@@ -127,7 +127,7 @@
inputType : "text", inputType : "text",
label : "Sujet", label : "Sujet",
values : sectionDyf.<?php echo $kunik ?>ParamsData.mail_type values : sectionDyf.<?php echo $kunik ?>ParamsData.mail_type
} },
mail_type : { mail_type : {
inputType : "textarea", inputType : "textarea",
label : "Mail type", label : "Mail type",
......
...@@ -44,20 +44,20 @@ if( isset($this->costum["tpls"][$keyTpl]) ) { ...@@ -44,20 +44,20 @@ if( isset($this->costum["tpls"][$keyTpl]) ) {
foreach ($formList as $k => $v) { foreach ($formList as $k => $v) {
?> ?>
<div id='<?php echo $v ?>' class='col-sm-offset-1 col-sm-10 sectionStep ' style="padding-bottom:40px"> <div id='<?php echo $v ?>xx' class='col-sm-offset-1 col-sm-10 sectionStep ' style="padding-bottom:40px">
<?php <?php
$form = PHDB::findOne( Form::COLLECTION,[ "id"=>$v ] ); $form = PHDB::findOne( Form::COLLECTION,[ "id"=>$v ] );
?> ?>
<script type="text/javascript"> <script type="text/javascript">
formInputs["<?php echo $v ?>"] = <?php echo json_encode( $form['inputs'] ); ?>; formInputs["<?php echo $v ?>"] = <?php echo json_encode( $form['inputs'] ); ?>;
var formInputsHere = formInputs; var formInputsHere = formInputs;
</script> </script>
<?php <?php
if( !empty($form) ) if( !empty($form) )
{ {
echo '<h1 class="text-center" style="color:'.$color1.'" >'.@$form["name"].'</h1>'; echo '<h1 class="text-center" style="color:'.$color1.'" >'.@$form["name"].'</h1>';
echo "<div class='text-center'>"; echo "<div class='text-center'>";
if(isset($this->costum["cms"][$form["id"]."desc"])) if(isset($this->costum["cms"][$form["id"]."desc"]))
echo htmlentities($this->costum["cms"][$form["id"]."desc"]); echo htmlentities($this->costum["cms"][$form["id"]."desc"]);
...@@ -67,24 +67,24 @@ var formInputsHere = formInputs; ...@@ -67,24 +67,24 @@ var formInputsHere = formInputs;
echo "<a class='btn btn-xs btn-danger editBtn' href='javascript:;' data-key='".@$form["id"]."desc' data-type='textarea' data-markdown='1' data-path='costum.cms.".@$form["id"]."desc' data-label='Expliquez les objectifs de cette étape ? '> <i class='fa fa-pencil'></i></a>"; echo "<a class='btn btn-xs btn-danger editBtn' href='javascript:;' data-key='".@$form["id"]."desc' data-type='textarea' data-markdown='1' data-path='costum.cms.".@$form["id"]."desc' data-label='Expliquez les objectifs de cette étape ? '> <i class='fa fa-pencil'></i></a>";
echo "</div>"; echo "</div>";
//echo "<div class='markdown'>"; //echo "<div class='markdown'>";
echo "<div class=''>"; echo "<div class=''>";
echo $this->renderPartial("survey.views.tpls.forms.formSection", echo $this->renderPartial("survey.views.tpls.forms.formSection",
[ "formId" => $v, [ "formId" => $v,
"form" => $form, "form" => $form,
"wizard" => false, "wizard" => false,
"answer"=>$answer, "answer"=>$answer,
"mode" => "w", "mode" => "w",
"showForm" => $showForm, "showForm" => $showForm,
"canEdit" => $canEdit, "canEdit" => $canEdit,
"el" => $el ] ,true ); "el" => $el ] ,true );
echo "</div>"; echo "</div>";
} }
else else
{ {
echo ""; echo "";
} }
?> ?>
</div> </div>
<?php <?php
} }
...@@ -99,23 +99,13 @@ jQuery(document).ready(function() { ...@@ -99,23 +99,13 @@ jQuery(document).ready(function() {
descHtml = dataHelper.markdownToHtml($(v).html()); descHtml = dataHelper.markdownToHtml($(v).html());
$(v).html(descHtml); $(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> </script>
</div> </div>
</div> </div>
\ No newline at end of file
...@@ -171,7 +171,7 @@ $paramsData = [ ...@@ -171,7 +171,7 @@ $paramsData = [
"email" => "adresse mail", "email" => "adresse mail",
"unique" => "Siret" "unique" => "Siret"
] ]
]; ];
if($saveOneByOne) if($saveOneByOne)
......
<?php <?php
var_dump($input);
if($mode != "pdf"){ if($mode != "pdf"){
//var_dump($input);
?> ?>
<div class=""> <div class="">
<label for="<?php echo $key ?>"><h4 style="color:<?php echo ($titleColor) ? $titleColor : "black"; ?>"><?php echo $label.$editQuestionBtn ?></h4></label> <label for="validation<?php echo $kunik ?>"><h4 style="color:<?php echo ($titleColor) ? $titleColor : "black"; ?>"><?php echo $label.$editQuestionBtn ?></h4></label>
<div class="text-center"> <div class="text-center">
<button class="btn btn-primary" id="validation<?php echo $kunik ?>">Validation</button> <a href="javascript:;" class="btn btn-primary" id="validation<?php echo $kunik ?>">Validation</a>
</div> </div>
</div> </div>
...@@ -13,19 +14,20 @@ if($mode != "pdf"){ ...@@ -13,19 +14,20 @@ if($mode != "pdf"){
var paramsInput = <?php echo json_encode($input); ?>; var paramsInput = <?php echo json_encode($input); ?>;
jQuery(document).ready(function() { jQuery(document).ready(function() {
mylog.log("render form input","/modules/costum/views/tpls/forms/cplx/validate.php"); mylog.log("render form input","/modules/costum/views/tpls/forms/cplx/validate.php");
$("#validation<?php echo $kunik ?>").click(function(){ $("#question<?php echo $key ?> #validation<?php echo $kunik ?>").off().click(function(){
var params = { var paramsValidate = {
answerId : answerId, answerId : answerId,
answer : answerObj.answers,
input : paramsInput input : paramsInput
}; };
ajaxPost( ajaxPost(
null, null,
baseUrl+"/survey/answer/validate", baseUrl+"/survey/answer/validate",
params, paramsValidate,
function(data){ function(data){
toastr.success("Le formulaire à été soumis"); toastr.success("Le formulaire à été soumis");
if(typeof data.html != "undefined")
$("#customHeader").html(data.html);
}, },
function(data){ function(data){
toastr.error("Un soucis est apparue. Contacter l'administrateur"); toastr.error("Un soucis est apparue. Contacter l'administrateur");
...@@ -34,9 +36,5 @@ if($mode != "pdf"){ ...@@ -34,9 +36,5 @@ if($mode != "pdf"){
}); });
}); });
</script> </script>
<?php } ?> <?php } ?>
\ No newline at end of file
<div class="col-xs-12 text-center padding-20 margin-top-10">
<h4>Félicitation!!! Vous avez terminé le formulaire.</h4>
<br/>
<h4>Celui-ci sera traité dans les plus bref délai.</h4>
</div>
\ No newline at end of file
...@@ -145,7 +145,7 @@ if(isset($this->costum["cms"]["color1"])) ...@@ -145,7 +145,7 @@ if(isset($this->costum["cms"]["color1"]))
<div class="col-xs-12 margin-top-20"> <div class="col-xs-12 margin-top-20">
<?php <?php
$wizardUid = (String) $form["_id"]; $wizardUid = (String) $form["_id"];
if($canEdit === true && $mode != "fa"){ if($canEdit === true && $mode != "fa" && empty($answer["validated"]) ){
$nameMode = "mode read"; $nameMode = "mode read";
if($mode == "w") if($mode == "w")
$nameMode = "mode write"; $nameMode = "mode write";
......
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