Commit 81d520b2 authored by Anatole Rakotoson's avatar Anatole Rakotoson

sommom aress

parent d8c5335a
<style type="text/css">
.ckd-grp {
/*position: absolute;
top: calc(50% - 10px);*/
}
.ckd-grp label {
cursor: pointer;
-webkit-tap-highlight-color: transparent;
padding: 6px 8px;
border-radius: 20px;
float: left;
transition: all 0.2s ease;
}
.ckd-grp label:hover {
background: rgba(125,100,247,0.06);
}
.ckd-grp label:not(:last-child) {
margin-right: 16px;
}
.ckd-grp label span {
vertical-align: middle;
}
.ckd-grp label span:first-child {
position: relative;
display: inline-block;
vertical-align: middle;
width: 27px;
height: 27px;
background: #e8eaed;
border-radius: 10px;
transition: all 0.2s ease;
margin-right: 8px;
padding: 3px;
}
.ckd-grp label span:first-child:after {
content: '';
position: absolute;
width: 16px;
height: 16px;
margin: 2px;
background: #fff;
border-radius: 6px;
transition: all 0.2s ease;
}
.ckd-grp label:hover span:first-child {
/*background*/: #7d64f7;
}
.ckb-grp label:hover span:first-child:after {
/*background: #7d64f7;*/
/*background: #7d64f7;*/
padding: 0px;
background: white;
}
.ckd-grp input {
display: none;
}
.ckd-grp input:checked + label span:first-child {
/*background: #7d64f7;*/
background: #e8eaed;
}
.ckd-grp input:checked + label span:first-child:after {
/*transform: scale(0.5);*/
background: #7d64f7;
}
.effect-2{border: 0; padding: 7px 0; border-bottom: 1px solid #ccc;}
.effect-2 ~ .focus-border{position: absolute; bottom: 0; left: 0; width: 0; height: 2px; background-color: #3399FF; transition: 0.4s;}
.effect-2:focus ~ .focus-border{width: 100%; transition: 0.4s;}
.paramsonebtn , .paramsonebtnP {
font-size: 17px;
display: none;
padding: 5px;
}
.paramsonebtn:hover {
color: red;
}
.paramsonebtnP:hover {
color: blue;
}
.thckd:hover .paramsonebtn, .thckd:hover .paramsonebtnP {
display: inline-block;
}
.effect-2:focus {
outline: none !important;
}
</style>
<?php
$value = (!empty($answers)) ? " value='".$answers."' " : "";
$inpClass = " saveOneByOne";
$editParamsBtn = ($canEdit) ? " <a href='javascript:;' data-id='".$el["_id"]."' data-collection='".Yii::app()->session["costum"]["contextType"]."' data-path='costum.form.params.".$kunik."' class='previewTpl edit".$kunik."Params btn btn-xs btn-danger'><i class='fa fa-cog'></i> </a>" : "";
$paramsData = [
"list" => [ ],
"tofill" => [ ],
"placeholdersckb" => [ ],
"type" => [
"simple" => "Sans champ de saisie",
"cplx" => "Avec champ de saisie"
],
'checked' => [],
"width" => [
"12" => "1",
"6" => "2",
"4" => "3"
]
];
if( isset(Yii::app()->session["costum"]["form"]["params"][$kunik]) ) {
if( isset(Yii::app()->session["costum"]["form"]["params"][$kunik]["global"]["list"]) ) {
$paramsData["list"] = Yii::app()->session["costum"]["form"]["params"][$kunik]["global"]["list"];
foreach ($paramsData["list"] as $k => $v) {
if(isset(Yii::app()->session["costum"]["form"]["params"][$kunik]["tofill"][$v]) ){
$paramsData["tofill"] += array($v => Yii::app()->session["costum"]["form"]["params"][$kunik]["tofill"][$v]);
} else {
$paramsData["tofill"] += [$v => "simple"];
}
}
}
}
if( isset(Yii::app()->session["costum"]["form"]["params"][$kunik]) ) {
if( isset(Yii::app()->session["costum"]["form"]["params"][$kunik]["global"]["list"]) ) {
//$paramsData["list"] = Yii::app()->session["costum"]["form"]["params"][$kunik]["global"]["list"];
foreach ($paramsData["list"] as $k => $v) {
if(isset(Yii::app()->session["costum"]["form"]["params"][$kunik]["placeholdersckb"][$v]) ){
$paramsData["placeholdersckb"] += array($v => Yii::app()->session["costum"]["form"]["params"][$kunik]["placeholdersckb"][$v]);
} else {
$paramsData["placeholdersckb"] += [$v => ""];
}
}
}
}
if( isset($answer["answers"][$form["id"]][$kunik]) ) {
$paramsData["checked"] = $answer["answers"][$form["id"]][$kunik];
}
if($mode == "r")
{
?>
<div class="col-xs-12" id="<?php echo $kunik ?>">
<label for="<?php echo $kunik ?>"><h4 style="color:<?php echo ($titleColor) ? $titleColor : "black"; ?>"><?php echo $label ?></h4></label>
<?php echo $answers; ?>
</div>
<?php
}else
{
?>
<div class="" style="padding-top: 50px; text-transform: unset;">
<label class="form-check-label" for="<?php echo $key ?>">
<h4 style="text-transform: unset; color: <?php echo ($titleColor) ? $titleColor : "black"; ?>;"><?php echo $label.$editQuestionBtn.$editParamsBtn ?>
</h4>
</label>
<?php
if( !isset(Yii::app()->session["costum"]["form"]["params"][$kunik]["global"]['list']) )
{
echo "<br/><span class='text-red text-center'><i class='fa fa-warning fa-2x'></i> THIS FIELD HAS TO BE CONFIGURED FIRST ".$editParamsBtn."</span>";
} else
{
?>
<div class="ckd-grp">
<table style="width: 100%">
<tr class=""><th >
<div class="col-md-12">
<?php
foreach (Yii::app()->session["costum"]["form"]["params"][$kunik]["global"]["list"] as $ix => $lbl)
{
$ckd = "";
$place = "";
foreach ($paramsData["checked"] as $key => $value) {
foreach ($value as $ke => $va) {
if($ke == $lbl){
$ckd = "checked";
}
}
}
?>
<!-- <tr class="thckd"><theih > -->
<div class="col-md-<?php echo (isset(Yii::app()->session["costum"]["form"]["params"][$kunik]['global']['width'])) ? Yii::app()->session["costum"]["form"]["params"][$kunik]['global']['width'] : '12'; ?> col-xs-12 col-sm-12" style="min-height: 50px;">
<div class="thckd">
<input data-id="<?php echo $kunik ?>" class=" ckbCo " id="<?php echo $kunik.$ix ?>" data-form='<?php echo $form["id"] ?>' <?php echo $ckd?> type="checkbox" name="<?php echo $kunik ?>" data-type="<?php
if(count($paramsData["tofill"]) != 0)
{
foreach ($paramsData["tofill"] as $key => $value)
{
if($lbl == $key)
{
if($value == "cplx")
{
echo "cplx";
}else
{
echo "simple";
}
}
}
}
?>" value="<?php echo $lbl ?>" />
<label for="<?php echo $kunik.$ix ?>">
<span>
</span>
<span><?php echo $lbl ?>
<div style="position: relative; display: inline-block;">
<?php
if(count($paramsData["tofill"]) != 0)
{
foreach ($paramsData["tofill"] as $key => $value)
{
if($lbl == $key && $value == "cplx")
{
?>
<input data-impname="<?php echo $kunik ?>" class="effect-1 inputckbCo" data-id="<?php echo $kunik ?>" data-form='<?php echo $form["id"] ?>' type="text" data-imp="<?php echo $key; ?>" placeholder="<?php echo $paramsData['placeholdersckb'][$key]; ?>" style="display: inline-block !important; position: relative;" value="<?php
if(isset($answer["answers"][$form["id"]][$kunik][0][$key]["textsup"]) && isset($answer["answers"][$form["id"]][$kunik][0][$key]["value"]) && $answer["answers"][$form["id"]][$kunik][0][$key]["value"] == $key )
{
echo $answer["answers"][$form["id"]][$kunik][0][$key]["textsup"] ;
}
?>">
<span class="focus-border"></span>
<!-- az -->
<?php
}
}
}
?>
</div>
<?php
if($canEdit)
{
echo " <a href='javascript:;' data-id='".$el["_id"]."' data-collection='".Yii::app()->session["costum"]["contextType"]."' data-path='costum.form.params.".$kunik."' class='previewTpl paramsonebtn editone".$kunik."Params".$ix." '><i class='fa fa-cog'></i> </a>";
if(count($paramsData["tofill"]) != 0)
{
foreach ($paramsData["tofill"] as $key => $value)
{
if($lbl == $key)
{
if($value == "cplx")
{
echo " <a alt='placeholder' href='javascript:;' data-id='".$el["_id"]."' data-collection='".Yii::app()->session["costum"]["contextType"]."' data-path='costum.form.params.".$kunik."' class='previewTpl paramsonebtnP editonep".$kunik."Params".$ix." '><i class='fa fa-pencil'></i> </a>";
}
}
}
}
}
?>
</span>
</label>
</div>
</div>
<?php
}
?>
</div>
</th></tr>
</table>
</div>
<?php
}
?>
<?php
if(!empty($info))
{
?>
<small id="<?php echo $key ?>Help" class="form-text text-muted"><?php echo $info ?></small>
<?php
}
?>
</div>
<script type="text/javascript">
var <?php echo $kunik ?>Data = <?php echo json_encode( (isset($answer["answers"][$kunik])) ? $answer["answers"][$kunik] : null ); ?>;
sectionDyf.<?php echo $kunik ?>ParamsData = <?php echo json_encode( $paramsData ); ?>;
sectionDyf.<?php echo $kunik ?>ParamsPlace = "";
jQuery(document).ready(function() {
mylog.log("render form input","/modules/costum/views/tpls/forms/cplx/multiCheckbox.php");
answer = {};
$('.ckbCo').change(function(){
var allckd = [];
alert('<?php echo $kunik ?>');
$("input:checkbox[name='"+$(this).attr("name")+"']:checked").each(function(){
mylog.log("ckd", $(this).val());
var key = $(this).val();
var b = { [key] : { 'type' : $(this).data("type"), 'textsup' : $('input[data-imp="' + $(this).val() + '"]').val() }};
allckd.push(b);
});
mylog.log("hehe",allckd);
// alert(allckd);
answer.path = "answers."+$(this).data("form")+"."+$(this).data("id");
answer.collection = "answers" ;
answer.id = "<?php echo $answer["_id"]; ?>";
answer.value = allckd;
dataHelper.path2Value(answer , function(params) {
});
});
$('.inputckbCo').keyup(function(){
if($('input[value="' + $(this).data("imp") + '"]').is(':checked')) {
var allckd = [];
$("input:checkbox[name='"+$(this).data("impname")+"']:checked").each(function(){
mylog.log("ckd", $(this).val());
var key = $(this).val();
var b = { [key] : { 'value' : $(this).val(), 'type' : $(this).data("type"), 'textsup' : $('input[data-imp="' + $(this).val() + '"]').val() }};
allckd.push(b);
});
// alert(allckd);
answer.path = "answers."+$(this).data("form")+"."+$(this).data("id");
answer.collection = "answers" ;
answer.id = "<?php echo $answer["_id"]; ?>";
answer.value = allckd;
dataHelper.path2Value(answer , function(params) {
});
}
})
sectionDyf.<?php echo $kunik ?>Params = {
"jsonSchema" : {
"title" : "<?php echo $kunik ?> config",
"icon" : "fa-cog",
"properties" : {
list : {
inputType : "array",
label : "Liste de bouton check",
values : sectionDyf.<?php echo $kunik ?>ParamsData.list
},
width : {
inputType : "select",
label : "Nombre d'element par ligne",
options : sectionDyf.<?php echo $kunik ?>ParamsData.width,
value : "<?php echo (isset(Yii::app()->session["costum"]["form"]["params"][$kunik]['global']['width']) and Yii::app()->session["costum"]["form"]["params"][$kunik]['global']['width'] != "") ? $paramsData["width"][strval(Yii::app()->session["costum"]["form"]["params"][$kunik]['global']['width'])] : ''; ?>"
}
},
save : function () {
tplCtx.value = {};
$.each( sectionDyf.<?php echo $kunik ?>Params.jsonSchema.properties , function(k,val) {
if(val.inputType == "properties")
tplCtx.value = getPairsObj('.'+k+val.inputType);
else if(val.inputType == "array")
tplCtx.value[k] = getArray('.'+k+val.inputType);
else if(val.inputType == "formLocality")
tplCtx.value[k] = getArray('.'+k+val.inputType);
else
tplCtx.value[k] = $("#"+k).val();
});
mylog.log("save tplCtx",tplCtx);
if(typeof tplCtx.value == "undefined")
toastr.error('value cannot be empty!');
else {
dataHelper.path2Value( tplCtx, function(params) {
$("#ajax-modal").modal('hide');
location.reload();
} );
}
}
}
};
<?php if(count($paramsData["list"]) != 0){
foreach ($paramsData["list"] as $key => $value) {
// if($lbl == $key){
// if($value == "cplx"){
?>
sectionDyf.<?php echo $kunik ?>oneParams<?php echo $key ?> = {
"jsonSchema" : {
"title" : "<?php echo $kunik ?> config",
"icon" : "fa-cog",
"properties" : {
tofill : {
inputType : "select",
label : "Bouton check avec champ de saisie",
options : sectionDyf.<?php echo $kunik ?>ParamsData.type,
values : "<?php echo (isset($paramsData["tofill"][$value])) ? $paramsData["tofill"][$value] : ''; ?>"
}
},
save : function () {
tplCtx.value = {};
$.each( sectionDyf.<?php echo $kunik ?>oneParams<?php echo $key ?>.jsonSchema.properties , function(ko,valo) {
$.each(sectionDyf.<?php echo $kunik ?>ParamsData.tofill, function(ke, va) {
if(ke == "<?php echo $value; ?>"){
var azerazer = ke.toString();
sectionDyf.<?php echo $kunik ?>ParamsData.tofill[azerazer] = $("#"+ko).val();
}
})
tplCtx.value = sectionDyf.<?php echo $kunik ?>ParamsData.tofill;
});
mylog.log("save tplCtx",tplCtx);
if(typeof tplCtx.value == "undefined")
toastr.error('value cannot be empty!');
else {
dataHelper.path2Value( tplCtx, function(params) {
$("#ajax-modal").modal('hide');
location.reload();
} );
}
}
}
};
$(".editone<?php echo $kunik ?>Params<?php echo $key ?>").off().on("click",function() {
tplCtx.id = $(this).data("id");
tplCtx.collection = $(this).data("collection");
tplCtx.path = $(this).data("path")+'.tofill';
//mylog.log(".edit<?php echo $kunik ?>Params",tplCtx,sectionDyf.<?php echo $kunik ?>ParamsData);
dyFObj.openForm( sectionDyf.<?php echo $kunik ?>oneParams<?php echo $key ?>,null, sectionDyf.<?php echo $kunik ?>oneParams<?php echo $key ?>);
});
<?php
}
}
// }
// }
?>
<?php if(count($paramsData["list"]) != 0){
foreach ($paramsData["list"] as $key => $value) {
// if($lbl == $key){
if($paramsData["tofill"][$value] == "cplx"){
?>
sectionDyf.<?php echo $kunik ?>oneParamsPlaceholders<?php echo $key ?> = {
"jsonSchema" : {
"title" : "<?php echo $kunik ?> config",
"icon" : "fa-cog",
"properties" : {
placeholdersckb : {
inputType : "text",
label : "Modifier les textes à l'interieur du champs de saisie",
values : "<?php echo $paramsData["placeholdersckb"][$value]; ?>"
}
},
save : function () {
tplCtx.value = {};
$.each( sectionDyf.<?php echo $kunik ?>oneParamsPlaceholders<?php echo $key ?>.jsonSchema.properties , function(kk,vall) {
$.each(sectionDyf.<?php echo $kunik ?>ParamsData.placeholdersckb, function(ke, va) {
if(ke == "<?php echo $value; ?>"){
var azerazer = ke.toString();
sectionDyf.<?php echo $kunik ?>ParamsData.placeholdersckb[azerazer] = $("#"+kk).val();
}
})
tplCtx.value = sectionDyf.<?php echo $kunik ?>ParamsData.placeholdersckb;
});
mylog.log("save tplCtx",tplCtx);
if(typeof tplCtx.value == "undefined")
toastr.error('value cannot be empty!');
else {
dataHelper.path2Value( tplCtx, function(params) {
$("#ajax-modal").modal('hide');
location.reload();
} );
}
}
}
};
$(".editonep<?php echo $kunik ?>Params<?php echo $key ?>").off().on("click",function() {
tplCtx.id = $(this).data("id");
tplCtx.collection = $(this).data("collection");
tplCtx.path = $(this).data("path")+'.placeholdersckb';
//mylog.log(".edit<?php echo $kunik ?>Params",tplCtx,sectionDyf.<?php echo $kunik ?>ParamsData);
dyFObj.openForm( sectionDyf.<?php echo $kunik ?>oneParamsPlaceholders<?php echo $key ?>,null, sectionDyf.<?php echo $kunik ?>oneParamsPlaceholders<?php echo $key ?>);
});
<?php
}
}
}
// }
?>
$(".edit<?php echo $kunik ?>Params").off().on("click",function() {
tplCtx.id = $(this).data("id");
tplCtx.collection = $(this).data("collection");
tplCtx.path = $(this).data("path")+'.global';
//mylog.log(".edit<?php echo $kunik ?>Params",tplCtx,sectionDyf.<?php echo $kunik ?>ParamsData);
dyFObj.openForm( sectionDyf.<?php echo $kunik ?>Params,null, sectionDyf.<?php echo $kunik ?>ParamsData);
});
});
</script>
<?php
}
?> <!-- else 164 -->
\ No newline at end of file
......@@ -24,8 +24,8 @@
position: relative;
display: inline-block;
vertical-align: middle;
width: 20px;
height: 20px;
width: 27px;
height: 27px;
background: #e8eaed;
border-radius: 50%;
transition: all 0.2s ease;
......@@ -34,9 +34,9 @@
.rdo-grp label span:first-child:after {
content: '';
position: absolute;
width: 16px;
height: 16px;
margin: 2px;
width: 19px;
height: 19px;
margin: 4px;
background: #fff;
border-radius: 50%;
transition: all 0.2s ease;
......@@ -51,7 +51,7 @@
background: #7d64f7;
}
.rdo-grp input:checked + label span:first-child:after {
transform: scale(0.5);
transform: scale(0.7);
}
.effect-1{border: 0; padding: 7px 0; border-bottom: 1px solid #ccc;}
......@@ -101,13 +101,18 @@ $paramsData = [
"type" => [
"simple" => "Sans champ de saisie",