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
$canEditAnswer = 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";
if(!empty(Yii::app()->session['userId'])){
......
<?php
class ValidateAction extends CAction
{
public function run($id=null, $type=null , $tpl=null)
public function run()
{
$res = Answer::validate($_POST);
Rest::json($_POST);
//$controller = $this->getController();
$params = $_POST;
$params["controller"] = $this->getController();
$res = Answer::validate($params);
Rest::json($res);
}
}
......@@ -24,7 +24,6 @@ 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);
......
......@@ -108,6 +108,7 @@ class Answer{
}
public static function globalAutocomplete($form, $searchParams){
//var_dump($form);
$searchParams["indexMin"] = (isset($searchParams["indexMin"])) ? $searchParams["indexMin"] : 0;
$searchParams["indexStep"] = (isset($searchParams["indexStep"])) ? $searchParams["indexStep"] : 100;
$mappingData=(isset($form["mapping"])) ? $form["mapping"] : array("name"=>"name", "address"=>"address");
......@@ -149,7 +150,7 @@ class Answer{
$query = Search::searchFilters($searchParams['filters'], $query);
}
$res= array();
//var_dump($query);exit;
//Rest::json($query);exit;
$res["results"] = PHDB::findAndLimitAndIndex ( self::COLLECTION , $query, $searchParams["indexStep"], $searchParams["indexMin"]);
if(isset($searchParams["count"]))
$res["count"][self::COLLECTION] = PHDB::count( self::COLLECTION , $query);
......@@ -365,21 +366,27 @@ class Answer{
}
public static function validate($params){
//Rest::json($params); exit;
$costum = CacheHelper::getCostum();
$set = array();
$res = array('result' => false, "msg" => "Erreur");
if(!empty($params["answerId"]))
$answer = PHDB::findOneById(Answer::COLLECTION, $params["answerId"]);
if(!empty($params["validated"]) && $params["validated"] === true)
if(!empty($answer)){
//Rest::json($answer); exit;
if(!empty($params["input"]["validated"]) && ( $params["input"]["validated"] === true || $params["input"]["validated"] === "true" ) )
$set["validated"] = true;
if(!empty($params["input"]["generateElement"])){
$mapping = array();
$import = array(
'file' => array(json_encode(array($params["answer"]))),
'file' => array(json_encode(array($answer))),
'nameFile' => "test",
'typeFile' => 'json',
"warnings" => "false"
);
//Rest::json($import); exit;
foreach ($params["input"]["generateElement"] as $type => $map) {
$mapping = array();
foreach ($map as $k => $v) {
......@@ -390,8 +397,26 @@ class Answer{
}
$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;
}
}
......@@ -408,6 +433,12 @@ class Answer{
$res = array('result' => true, "msg" => "Valider");
}
if($res["result"] === true){
$res["html"] = $params["controller"]->renderPartial('survey.views.tpls.forms.finish', $res, true);
}
}
return $res;
}
......
......@@ -184,10 +184,12 @@ class Form {
}
$res["form"]=PHDB::findOne( Form::COLLECTION, $queryForm );
$res["forms"] = [];
if(!empty($res["form"]["subForms"])){
foreach ($res["form"]["subForms"] as $ix => $formId) {
$f = PHDB::findOne(Form::COLLECTION, ["id"=>$formId]);
$res["forms"][$formId] = $f;
}
}
return $res;
}
public static function getById($parentForm, $fields=array()){
......
......@@ -127,7 +127,7 @@
inputType : "text",
label : "Sujet",
values : sectionDyf.<?php echo $kunik ?>ParamsData.mail_type
}
},
mail_type : {
inputType : "textarea",
label : "Mail type",
......
......@@ -44,7 +44,7 @@ if( isset($this->costum["tpls"][$keyTpl]) ) {
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
$form = PHDB::findOne( Form::COLLECTION,[ "id"=>$v ] );
?>
......@@ -99,23 +99,13 @@ jQuery(document).ready(function() {
descHtml = dataHelper.markdownToHtml($(v).html());
$(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>
</div>
</div>
......@@ -171,7 +171,7 @@ $paramsData = [
"email" => "adresse mail",
"unique" => "Siret"
]
];
];
if($saveOneByOne)
......
<?php
var_dump($input);
if($mode != "pdf"){
//var_dump($input);
?>
<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">
<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>
......@@ -13,19 +14,20 @@ if($mode != "pdf"){
var paramsInput = <?php echo json_encode($input); ?>;
jQuery(document).ready(function() {
mylog.log("render form input","/modules/costum/views/tpls/forms/cplx/validate.php");
$("#validation<?php echo $kunik ?>").click(function(){
var params = {
$("#question<?php echo $key ?> #validation<?php echo $kunik ?>").off().click(function(){
var paramsValidate = {
answerId : answerId,
answer : answerObj.answers,
input : paramsInput
};
ajaxPost(
null,
baseUrl+"/survey/answer/validate",
params,
paramsValidate,
function(data){
toastr.success("Le formulaire à été soumis");
if(typeof data.html != "undefined")
$("#customHeader").html(data.html);
},
function(data){
toastr.error("Un soucis est apparue. Contacter l'administrateur");
......@@ -34,9 +36,5 @@ if($mode != "pdf"){
});
});
</script>
<?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"]))
<div class="col-xs-12 margin-top-20">
<?php
$wizardUid = (String) $form["_id"];
if($canEdit === true && $mode != "fa"){
if($canEdit === true && $mode != "fa" && empty($answer["validated"]) ){
$nameMode = "mode read";
if($mode == "w")
$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