Commit 4b23ef88 authored by Clément Damiens's avatar Clément Damiens
Browse files

Up form and list answer &&
parent 826989c4
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
protected function beforeAction($action) { protected function beforeAction($action) {
//parent::initPage(); parent::initPage();
return parent::beforeAction($action); return parent::beforeAction($action);
} }
...@@ -11,7 +11,8 @@ ...@@ -11,7 +11,8 @@
return array( return array(
'new' => 'survey.controllers.answer.NewAction', 'new' => 'survey.controllers.answer.NewAction',
'index' => 'survey.controllers.answer.IndexAction', 'index' => 'survey.controllers.answer.IndexAction',
'all'=>'survey.controllers.answer.AllAction' 'all'=>'survey.controllers.answer.AllAction',
'admindirectory'=>'survey.controllers.answer.admin.DirectoryAction'
); );
} }
} }
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
protected function beforeAction($action) { protected function beforeAction($action) {
//parent::initPage(); parent::initPage();
return parent::beforeAction($action); return parent::beforeAction($action);
} }
......
<?php
/**
* Display the directory of back office
* @param String $id Not mandatory : if specify, look for the person with this Id.
* Else will get the id of the person logged
* @return type
*/
class DirectoryAction extends CAction
{
public function run( $slug=null, $tpl=null, $view=null ){
$controller = $this->getController();
$panelAdmin = $_POST;
$limitMin=0;
$stepLim=100;
if(@$_POST["page"]){
$limitMin=$limitMin+(100*($_POST["page"]-1));
}
$search="";
if(!empty($_POST["name"])){
$search = trim(urldecode($_POST['name']));
}
$panelAdmin["context"] = array( "id" => $_POST["id"],
"collection" => $_POST["collection"],
"slug" => $_POST["slug"] );
$searchRegExp = Search::accentToRegex($search);
$query=array("parentSlug"=>$slug);
$querySearch = array();
if(!empty($querySearch))
$query = array('$and' => array( $query , $querySearch ) ) ;
if(!empty($panelAdmin['filters'])){
$query = Search::searchFilters($panelAdmin['filters'], $query);
}
$params["typeDirectory"]=[ Form::ANSWER_COLLECTION ];
$params["results"] = array();
$answers = PHDB::findAndLimitAndIndex ( Form::ANSWER_COLLECTION , $query, $stepLim, $limitMin);
$answerList = Form::listForAdmin($answers) ;
$params["results"]["count"][Form::ANSWER_COLLECTION] = PHDB::count( Form::ANSWER_COLLECTION , $query);
$params["results"][Form::ANSWER_COLLECTION] = $answerList ;
$params["panelAdmin"] = $panelAdmin;
$page = "groupAdmin";
if($tpl=="json")
Rest::json( $params );
else if(Yii::app()->request->isAjaxRequest)
echo $controller->renderPartial("costum.views.custom.default.".$page,$params,true);
}
}
<?php <?php
class InitAction extends CAction class EditAction extends CAction
{ {
public function run($id=null, $answer=null, $tpl=null) public function run($id=null, $answer=null, $tpl=null)
{ {
$this->getController()->layout = "//layouts/empty"; $this->getController()->layout = "//layouts/empty";
$params = ["canEdit" => true]; $params = array("canEdit" => true, "showAnswerActions"=>false);
if( isset($test) ){
$params["tpl"]=$id;
}
if(!empty($anwserId)){
$params["answerId"]=$answer;
}
$params = Form::getDataForAnswer($params); $params = Form::getDataForAnswer($params);
$tpl=(!empty($tpl)) ? $tpl : "costum.views.custom.co.formWizard"; $tpl=(!empty($tpl)) ? $tpl : "survey.views.tpls.forms.formWizard";
echo $this->getController()->renderPartial($tpl,$params ); echo $this->getController()->renderPartial($tpl,$params );
} }
......
...@@ -631,6 +631,7 @@ class Form { ...@@ -631,6 +631,7 @@ class Form {
public static function getDataForAnswer($params){ public static function getDataForAnswer($params){
//var_dump(Yii::app()->session['costum']);exit;
if(isset(Yii::app()->session["costum"]["contextType"]) && isset(Yii::app()->session["costum"]["contextId"])) if(isset(Yii::app()->session["costum"]["contextType"]) && isset(Yii::app()->session["costum"]["contextId"]))
$params["el"] = Element::getByTypeAndId(Yii::app()->session["costum"]["contextType"], Yii::app()->session["costum"]["contextId"] ); $params["el"] = Element::getByTypeAndId(Yii::app()->session["costum"]["contextType"], Yii::app()->session["costum"]["contextId"] );
...@@ -776,6 +777,7 @@ class Form { ...@@ -776,6 +777,7 @@ class Form {
$params["answer"] = $answer; $params["answer"] = $answer;
$params["showForm"] = $showForm; $params["showForm"] = $showForm;
$params["showAnswerActions"]=(isset($params["showAnswerActions"])) ? $params["showAnswerActions"] : true;
$allAnswers = PHDB::find( Form::ANSWER_COLLECTION,[ $allAnswers = PHDB::find( Form::ANSWER_COLLECTION,[
"formId" => $params["formId"], "formId" => $params["formId"],
"parentSlug" => $params["el"]["slug"] ] ) ; "parentSlug" => $params["el"]["slug"] ] ) ;
......
...@@ -106,7 +106,7 @@ jQuery(document).ready(function() { ...@@ -106,7 +106,7 @@ jQuery(document).ready(function() {
$('#showAnswerBtn').on("click",function() { $('#showAnswerBtn').on("click",function() {
$("#allAnswersContainer").toggleClass("hide"); $("#allAnswersContainer").toggleClass("hide");
$('#<?php echo $wizid ?>').toggleClass("hide"); $('#<?php echo @$wizid ?>').toggleClass("hide");
}) })
<?php if($canEdit) { ?> <?php if($canEdit) { ?>
......
...@@ -297,6 +297,7 @@ var answerObj = <?php echo (!empty($answer)) ? json_encode( $answer ) : "null"; ...@@ -297,6 +297,7 @@ var answerObj = <?php echo (!empty($answer)) ? json_encode( $answer ) : "null";
<div class="col-xs-12 margin-top-20"> <div class="col-xs-12 margin-top-20">
<?php <?php
$wizardUid = "wizardForm"; $wizardUid = "wizardForm";
if($showAnswerActions){
$params = [ $params = [
"el" => $el, "el" => $el,
"color1" => $color1, "color1" => $color1,
...@@ -305,7 +306,7 @@ var answerObj = <?php echo (!empty($answer)) ? json_encode( $answer ) : "null"; ...@@ -305,7 +306,7 @@ var answerObj = <?php echo (!empty($answer)) ? json_encode( $answer ) : "null";
"what" => "dossiers" "what" => "dossiers"
]; ];
echo $this->renderPartial("survey.views.tpls.answers.allAnswers",$params); echo $this->renderPartial("survey.views.tpls.answers.allAnswers",$params);
}
if($showForm){ if($showForm){
$params = [ $params = [
"formList"=>$formList, "formList"=>$formList,
......
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