oforms.php 7.64 KB
Newer Older
Tibor Katelbach's avatar
Tibor Katelbach committed
1 2

<div class="col-md-12 col-sm-12 col-xs-12 labelTitleDir margin-bottom-15">
3 4
	<i class="fa fa-file-text-o fa-2x margin-right-10"></i> <i class="fa fa-angle-down"></i> <?php echo count($forms) ?> <b>Open Forms</b> créé par <span class="Montserrat" id="name-lbl-title"><?php echo $el["name"] ?></span>
	<a href='javascript:dyFObj.openForm(oform);' class="btn btn-sm btn-link bg-green-k pull-right "><i class="fa fa-plus"></i> Nouveau Formulaire</a>
Tibor Katelbach's avatar
Tibor Katelbach committed
5 6
</div>

7 8 9 10 11
<?php 
$ct = 0;
foreach ($forms as $fix => $f) {
	if($ct == 0)
		echo '<div class="row ">';
Tibor Katelbach's avatar
Tibor Katelbach committed
12
?>
Tibor Katelbach's avatar
Tibor Katelbach committed
13
<div class="liForm col-md-4 col-sm-3 col-xs-12 " style="padding:5px;">
14
	<div class="col-xs-12 " style="padding:10px;border:1px solid grey">
Tibor Katelbach's avatar
Tibor Katelbach committed
15
		<h4 class="letter-turq"><?php echo (isset($f['name'])) ? $f['name'] : "Formulaire ".$el["slug"]  ?></h4>
16 17 18 19 20 21 22 23
		steps : <br/>
		<?php 
		if(isset($f['ids'])){
			foreach ( $f["ids"] as $ix => $i ) {
				echo '<i class="fa fa-file-text-o"></i> '.$f[$i]['name']."<br/>"; 	
			}
		}?>
		<a href='javascript:;' data-id='<?php echo $fix ?>' class="showAnswersBtn btn btn-xs btn-default col-sm-4 col-sm-12 bold">
Tibor Katelbach's avatar
Tibor Katelbach committed
24
			<i class='fa fa-comments'></i>(<?php echo $f["answers"]; ?>) <?php echo (isset($f['what'])) ? $f['what'] : "RÉPONSES" ?>
25 26 27 28 29 30
		</a>
		<a href='javascript:;' data-id='<?php echo $fix ?>' class="configBtn btn btn-xs btn-danger col-sm-4 col-sm-12 bold">
			<i class='fa fa-cogs'></i> CONFIG
		</a>
		<a href='costum/co/index/slug/<?php echo $el["slug"] ?>/form/<?php echo $fix ?>' class="btn btn-xs btn-primary col-sm-4 col-xs-12 bold">
			<i class='fa fa-file-text-o'></i> RÉPONDRE
Tibor Katelbach's avatar
Tibor Katelbach committed
31
		</a> 
32
	</div>
Tibor Katelbach's avatar
Tibor Katelbach committed
33 34
</div>

35 36 37 38 39 40 41 42 43 44 45 46 47 48
<?php
	$ct++;
	if($ct == 3){
		echo "</div>";
		$ct = 0;
	}
 } ?>

<script type="text/javascript">
var tplCtx = {};
jQuery(document).ready(function() {

	mylog.log("render","/modules/costum/views/tpls/forms/cplx/answers.php");
	$('.showAnswersBtn').off().on("click",function() { 
49
		getAjax("#central-container",baseUrl+"/survey/answer/get/form/"+$(this).data("id"),function(){
50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65
		        	
		        },"html");
	});
	$('.configBtn').off().on("click",function() { 
		tplCtx.id = $(this).data("id");
		dyFObj.openForm(oformParams)
	});
	
});
var oform = {
	jsonSchema : {	
        title : "Créer un Questionnaire",
        description : "Tout est possible, faut juste poser les bonnes questions",
        icon : "fa-question",
        properties : {
        	name : { label : "Nom du formulaire"},
Tibor Katelbach's avatar
Tibor Katelbach committed
66
        	what : { label : "Nom d'une Réponse, à quoi correspondent les réponses ?", placeholder:"Proposition, Dossiers, Projets..."},
67 68 69 70 71 72 73
            // sections : {
            //     inputType : "array",
            //     label : "Nommé chaque étape de votre questionnaire",
            //     subLabel : "Vous remplirez les question de chaques étapes par la suite",
            //     values :  []
            // },
            image : dyFInputs.image(),
74
            formid : { inputType : "hidden",value:"<?php echo $el["slug"].count($forms) ?>"},
75
            parentSlug : { inputType : "hidden",value:"<?php echo $el["slug"] ?>"},
Raph El's avatar
Raph El committed
76 77 78 79 80 81 82 83 84
            parent : {
	            inputType : "finder",
	            label : tradDynForm.whoiscarrytheproject,
	           	multiple : true,
	           	rules : { required : true, lengthMin:[1, "parent"]}, 
    			initType: ["organizations", "projects"],
    			openSearch :true
	        },
	        image : dyFInputs.image(),
85 86 87 88 89 90 91 92 93 94 95
        	tpl : { inputType : "hidden",value:"survey.views.tpls.forms.formWizard"},
        	answersTpl : { inputType : "hidden",value:"survey.views.tpls.forms.answers"}
        },
        beforeBuild : function(){
	    	dyFObj.setMongoId('forms',function(){
	    		uploadObj.gotoUrl = '#page.type.forms.id.'+uploadObj.id;
	    	});
	    },
	    afterSave : function(){
			dyFObj.commonAfterSave();
		},
Raph El's avatar
Raph El committed
96 97 98 99
        save : function (formData) {
        	mylog.log('save tplCtx formData', formData)

        	delete formData.collection ;
100 101
            tplCtx = {
            	collection : "forms",
Raph El's avatar
Raph El committed
102
            	value : formData
103
            };
104
            delete tplCtx.value.formid;
105
            tplCtx.value.id = tplCtx.value.formid;
106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138
            mylog.log("save tplCtx",tplCtx);
            
            if(typeof tplCtx.value == "undefined")
            	toastr.error('value cannot be empty!');
            else {
                dataHelper.path2Value( tplCtx, function(params) { 
                   urlCtrl.loadByHash(location.hash);
                } );
            }

    	}
    }
};

var oformParams = {
	jsonSchema : {	
        title : "Configurer le Questionnaire",
        description : "lisez bien les options",
        icon : "fa-question",
        properties : {
			private : {	 inputType : "checkboxSimple",
	                    label : "Privé",
	                    subLabel : "Seul la communauté peut éditer ce questionnaire",
	                    params : { onText : "Oui", offText : "Non", onLabel : "Oui", offLabel : "Non",
	                        labelText : "Privé"
	                    },
	                    checked : false },
			canReadOtherAnswers: {	 inputType : "checkboxSimple",
			                    label : "Réponses Ouvertes à la lecture",
			                    subLabel : "Les réponses sont elles ouverte à la lecture public",
			                    params : { onText : "Oui",offText : "Non",onLabel : "Oui",offLabel : "Non",
			                        labelText : "Réponses Ouvertes"
			                    },
Tibor Katelbach's avatar
Tibor Katelbach committed
139
			                    checked : true },
140 141 142 143 144 145 146 147 148 149 150 151 152 153
			startDate: {
				inputType : "date",
			    label : "Date de début",
			},
			endDate: { 	
				inputType : "date",
			    label : "Date de fin" 
			},
			oneAnswerPerPers: {inputType : "checkboxSimple",
			                    label : "Bloquer à une réponse par personne",
			                    subLabel : "Une personne ne pourra répondre qu'une seule fois",
			                    params : { onText : "Oui",offText : "Non",onLabel : "Oui",offLabel : "Non",
			                        labelText : "Réponse unique"
			                    },
Tibor Katelbach's avatar
Tibor Katelbach committed
154
			                    checked : true },
155 156 157 158 159 160
			canModify : { inputType : "checkboxSimple",
		                    label : "Réponse Modifiable",
		                    subLabel : "une fois soumise les réponses sont elles modifiables",
		                    params : { onText : "Oui",offText : "Non",onLabel : "Oui",offLabel : "Non",
		                        labelText : "Réponse Modifiable"
		                    },
Tibor Katelbach's avatar
Tibor Katelbach committed
161
		                    checked : true },
162 163 164 165 166 167
			showAnswers: {inputType : "checkboxSimple",
		                    label : "Réponse Affichés",
		                    subLabel : "Les réponses sont elles affichés publiquement",
		                    params : { onText : "Oui",offText : "Non",onLabel : "Oui",offLabel : "Non",
		                        labelText : "Réponse Affichés"
		                    },
Tibor Katelbach's avatar
Tibor Katelbach committed
168
		                    checked : true },
169 170 171
        },
        save : function () {  
            tplCtx.collection = "forms";
Tibor Katelbach's avatar
Tibor Katelbach committed
172
            tplCtx.path = "allToRoot";
173
            tplCtx.value = {};
Tibor Katelbach's avatar
Tibor Katelbach committed
174 175

            $.each( oformParams.jsonSchema.properties , function(k,val) { 
176 177 178 179 180 181 182 183
        		if(val.inputType == "properties")
        		 	tplCtx.value[k] = getPairsObj('.'+k+val.inputType);
        		else if(val.inputType == "array")
        		 	tplCtx.value[k] = getArray('.'+k+val.inputType);
        		else
        		 	tplCtx.value[k] = $("#"+k).val();
        		 mylog.log("value",'.'+k+val.inputType,tplCtx.value[k]);
        	 });
Tibor Katelbach's avatar
Tibor Katelbach committed
184
            mylog.log("oformParams save tplCtx",tplCtx);
185 186 187 188 189 190 191 192 193 194 195 196
            
            if(typeof tplCtx.value == "undefined")
            	toastr.error('value cannot be empty!');
            else {
                dataHelper.path2Value( tplCtx, function(params) { 
                   urlCtrl.loadByHash(location.hash);
                } );
            }

    	}
    }
};
197

198
</script>