Commit 5b28888d authored by Clément Damiens's avatar Clément Damiens
Browse files

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

parents ef2f0581 a793d6f5
......@@ -16,6 +16,8 @@ class ApiController extends CommunecterController {
public function actions() {
return array(
'form' => 'survey.controllers.actions.form.GetAction',
'answers' => 'survey.controllers.actions.answer.GetAction',
);
}
......
......@@ -7,20 +7,21 @@ class NewAction extends CAction
$params = array();
if(!empty($id) && !empty($type)){
$params["forms"] = PHDB::find(Form::COLLECTION,
array("parent.".$id ),
array("name") ) ;
[ "parent.".$id => ['$exists'=>1] ],
[ "name" ] ) ;
} else if( !empty($this->getController()->costum) ){
$params["forms"] = PHDB::find(Form::COLLECTION,
array('$and' => array(
array("active" => true),
array("parent.".$this->getController()->costum["contextId"] => array('$exists' => 1))
// array('$or' => array(
// array("parent.".$this->getController()->costum["contextId"] => array('$exists' => 1) ),
// array("source.keys" => array('$in' => array($this->getController()->costum["slug"]) ) )
// ) )
)),
array("name") ) ;
[ '$and' => [
["active" => true],
["parent.".$this->getController()->costum["contextId"] => ['$exists' => 1]
// array('$or' => array(
// array("parent.".$this->getController()->costum["contextId"] => array('$exists' => 1) ),
// array("source.keys" => array('$in' => array($this->getController()->costum["slug"]) ) )
// ) )
]]], ["name"] ) ;
}
//var_dump($this->getController()->costum); exit;
$tpl= "survey.views.tpls.views.new";
echo $this->getController()->renderPartial($tpl,$params );
......
//parent form
{
"parent" : creer un form sur un element
"parent" : {
"5eaa96df539f2224608b456a" : {
"type" : "organizations",
"name": "DEAL A H "
}
}
"hasStepValidations" : 1,
"id" : "dealForm",
"source" : {
......
......@@ -342,4 +342,4 @@ function closePrioModalRel (){
}
?>
\ No newline at end of file
?>
......@@ -65,6 +65,8 @@ if( $mode != "pdf" && ( $canAdminAnswer === true || $canEdit === true ) )
}
}
}
} else if($i == "group" && isset($paramsData["group"][$a[$i]])){
$tds .= $paramsData["group"][$a[$i]];
}
else if(isset($a[$i]))
$tds .= $a[$i];
......
......@@ -30,7 +30,6 @@ $editBtnL = "";
$editParamsBtn = ($canEditForm) ? " <a href='javascript:;' data-id='".$parentForm["_id"]."' data-collection='".Form::COLLECTION."' data-path='params.".$kunik."' class='previewTpl edit".$kunik."Params btn btn-xs btn-danger'><i class='fa fa-cog'></i> </a>" : "";
$paramsData = [
"financerTypeList" => Ctenat::$financerTypeList,
"limitRoles" =>["Financeur"],
......
......@@ -7,12 +7,15 @@ if( $mode != "pdf" ){
$editParamsBtn = ($canEdit) ? " <a href='javascript:;' data-id='".$parentForm["_id"]."' data-collection='".Form::COLLECTION."' data-path='params.".$kunik."' class='previewTpl edit".$kunik."Params btn btn-xs btn-danger'><i class='fa fa-cog'></i> </a>" : "";
$paramsData = [
"limitRoles" =>["Financeur"]
"canValidRoles" =>["Financeur"],
"canRequestRoles" =>["Opérateur"],
];
if( isset($parentForm["params"][$kunik]) ) {
if( isset($parentForm["params"][$kunik]["limitRoles"]) )
$paramsData["financersList"] = $parentForm["params"][$kunik]["limitRoles"];
if( isset($parentForm["params"][$kunik]["canValidRoles"]) )
$paramsData["canValidRoles"] = $parentForm["params"][$kunik]["canValidRoles"];
if( isset($parentForm["params"][$kunik]["canRequestRoles"]) )
$paramsData["canRequestRoles"] = $parentForm["params"][$kunik]["canRequestRoles"];
}
?>
......@@ -27,7 +30,7 @@ if( $mode != "pdf" ){
</td>
</tr>
<?php
if( isset( $answer["validation"][ $form['id'] ] ) ){ ?>
if( isset( $answer["validation"][ $form['id'] ]["valid"] ) && in_array($answer["validation"][$form['id']]["valid"], ["valid","validReserve"] ) ){ ?>
<tr>
<td colspan='2' align="center">
<button id="generateCopil2" class="generateCopil btn btn-primary" data-id="<?php echo (string)$answer["_id"] ?>" data-date="<?php echo date("Y-m-d") ?>" data-title="Compte Rendu de la réunion de finalisation" data-key="copilReunionFinalisation">Générer le dossier validé</button>
......@@ -49,6 +52,9 @@ if( $mode != "pdf" ){
} else if( $answer["validation"][$form['id']]["valid"] == "validReserve" ){
$color = "warning";
$lbl = "Validé avec réserves";
}else if( $answer["validation"][$form['id']]["valid"] == "request" ){
$color = "default";
$lbl = "Demande de Validation";
}
}
......@@ -81,12 +87,35 @@ if( $mode != "pdf" ){
} ?>
<?php
} ?>
<tr>
<td colspan='2' class="text-center" >
<a href="javascript:;" data-type="<?php echo $form['id'] ?>" class="validEdit btn btn-primary">Valider cette action</a>
</td>
</tr>
}
?>
<tr>
<td colspan='2' class="text-center" >
<?php
// var_dump(Yii::app()->session["costum"][$el['costum']['slug']]["hasRoles"][0]);
// var_dump($paramsData['canValidRoles']);
if( (!isset($answer["validation"][$form['id']]) || (isset( $answer["validation"][ $form['id'] ]["valid"] ) && $answer["validation"][ $form['id'] ]["valid"] == "notValid")) &&
isset( Yii::app()->session["costum"][$el['costum']['slug']]["hasRoles"][0]) &&
in_array(Yii::app()->session["costum"][$el['costum']['slug']]["hasRoles"][0], $paramsData['canRequestRoles']) )
echo '<a href="javascript:;" data-type="'.$form['id'].'" class="requestValid btn btn-primary">Étape terminé , Demander la Validation</a>';
else if( isset( $answer["validation"][ $form['id'] ]["valid"] ) &&
$answer["validation"][ $form['id'] ]["valid"] == "request" &&
isset( Yii::app()->session["costum"][$el['costum']['slug']]["hasRoles"][0] ) &&
in_array(Yii::app()->session["costum"][$el['costum']['slug']]["hasRoles"][0], $paramsData['canValidRoles']) )
echo '<a href="javascript:;" data-type="'.$form['id'].'" class="validEdit btn btn-primary">Valider cette Étape</a>';
else {
if(isset( $answer["validation"][ $form['id'] ] ) &&
$answer["validation"][ $form['id'] ]["valid"] == "request")
echo "Étape en cours de validation ";
else
echo "Étape en cours de traitement";
}
?>
</td>
</tr>
</tbody>
</table>
......@@ -111,10 +140,28 @@ if( $mode != "pdf" ){
"title" : "<?php echo $kunik ?> config",
"icon" : "fa-cog",
"properties" : {
limitRoles : {
useValidationRoles : {
inputType : "checkboxSimple",
label : "Utiliser des Role de validation",
subLabel : "Permet de définir des demandes et de validations",
params : {
onText : "Oui",
offText : "Non",
onLabel : "Oui",
offLabel : "Non",
labelText : "Obligatoire"
},
checked : false
},
canValidRoles : {
inputType : "array",
label : "Liste des roles qui pourront valider cette étape",
values : sectionDyf.<?php echo $kunik ?>ParamsData.canValidRoles
},
canRequestRoles : {
inputType : "array",
label : "Liste des roles qui pourront valider cette étape",
values : sectionDyf.<?php echo $kunik ?>ParamsData.limitRoles
values : sectionDyf.<?php echo $kunik ?>ParamsData.canRequestRoles
}
},
save : function () {
......@@ -204,6 +251,15 @@ if( $mode != "pdf" ){
};
mylog.log("save step save",ctxTpl);
dataHelper.path2Value( ctxTpl, function(params) {
ajaxPost(
null,
baseUrl+"/survey/answer/sendmail/id/<?php echo (string)$answer['_id'] ?>",
{ step : step },
function(data){
toastr.success("Un mail a été envoyé à toutes les parties prenantes afin de les notifier");
urlCtrl.loadByHash(location.hash);
}
);
urlCtrl.loadByHash(location.hash);
} );
} else
......@@ -217,7 +273,15 @@ if( $mode != "pdf" ){
inputType : "custom",
html:"<p></p>",
},
valid : {
valid : dyFInputs.inputHidden(),
description : dyFInputs.textarea( tradDynForm["description"], "..." ),
form : dyFInputs.inputHidden()
}
}
};
$('.validEdit').off().on("click", function() {
var setVal = { form : $(this).data("type")};
typeObj[ 'validation'+setVal.form ].jsonSchema.properties.valid = {
"label" : "Valider",
"inputType" : "select",
"placeholder" : "---- Selectionner Valider ----",
......@@ -226,25 +290,16 @@ if( $mode != "pdf" ){
"validReserve" : "Validé avec réserves",
"valid" : "Validé sans réserve"
}
},
description : dyFInputs.textarea( tradDynForm["description"], "..." ),
// date : {
// inputType : "date",
// label : "Date",
// placeholder : "Date de Validation",
// rules : {
// required : true,
// greaterThanNow : ["DD/MM/YYYY"]
// }
// },
form : dyFInputs.inputHidden()
}
}
};
$('.validEdit').off().on("click", function() {
};
dyFObj.openForm( typeObj[ 'validation'+setVal.form ], null, setVal );
});
$('.requestValid').off().on("click", function() {
var setVal = { form : $(this).data("type")};
typeObj[ 'validation'+setVal.form ].jsonSchema.properties.valid = dyFInputs.inputHidden("request");
dyFObj.openForm( typeObj[ 'validation'+setVal.form ], null, setVal );
});
......
......@@ -60,7 +60,7 @@ if( isset($parentForm["subForms"]) && count($parentForm["subForms"]) > 1 ) {
$lbl = "?";
// if(isset($parentForm["hasStepValidations"]) )
// $lbl = "";
$forms[$v]['open'] = false;
if( (!isset($answer["step"]) && !isset($parentForm["hasStepValidations"])) ||
$k == 0 ||
(isset($answer["step"]) && $answer["step"] == "all" ) ||
......@@ -72,6 +72,7 @@ if( isset($parentForm["subForms"]) && count($parentForm["subForms"]) > 1 ) {
$lbl = $k;
$l = 'showStepForm(\'#'.$v.'\')' ;
$activeStep = $k;
$forms[$v]['open'] = true;
}
echo '<a onclick="'.$l.'" href="javascript:;" '.$d.' >';
......@@ -115,12 +116,13 @@ if( isset($parentForm["subForms"]) && count($parentForm["subForms"]) > 1 ) {
$(".sectionStep").addClass("hide");
$(id).removeClass("hide");
localStorage.setItem("wizardStep",id);
$('html, body').animate({scrollTop: $("#customHeader").offset().top}, 500);
}
</script>
<?php
if( !empty($forms[$v]) )
if( !empty($forms[$v]) && $forms[$v]['open'] )
{
echo '<h1 class="text-center" style="color:'.$color1.'" >'.@$forms[$v]["name"].'</h1>';
......@@ -138,7 +140,16 @@ if( isset($parentForm["subForms"]) && count($parentForm["subForms"]) > 1 ) {
"canEdit" => $canEdit,
"canEditForm" => @$canEditForm,
"canAdminAnswer" => @$canAdminAnswer,
"el" => $el ] ,true );
"el" => $el ] ,true );
if( $k < count($parentForm["subForms"])-1 )
{
$nextFormId = $parentForm["subForms"][$k+1];
if( $forms[$nextFormId]['open'] )
{
echo '<a href="javascript:showStepForm(\'#'.$nextFormId.'\')" class="btn col-xs-12" style="background-color:<?php echo ( $color2 ) ? $color2 : $defaultColor ?>"> <h4>Étape suivante</h4> </a>' ;
}
}
echo "</div>";
}
else
......
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