Proyectos de Subversion LeadersLinked - Backend

Rev

Rev 118 | Rev 120 | Ir a la última revisión | | Comparar con el anterior | Ultima modificación | Ver Log |

Rev Autor Línea Nro. Línea
115 efrain 1
<?php
2
$acl            = $this->viewModel()->getRoot()->getVariable('acl');
3
$currentUser    = $this->currentUserHelper();
4
 
5
$roleName = $currentUser->getUserTypeId();
6
 
7
$routeAdd       = $this->url('self-evaluation/forms/add');
8
$routeDatatable = $this->url('self-evaluation/forms');
9
$routeDashboard = $this->url('dashboard');
10
 
11
$allowAdd               = $acl->isAllowed($roleName, 'self-evaluation/forms/add') ? 1 : 0;
12
$allowEdit              = $acl->isAllowed($roleName, 'self-evaluation/forms/edit') ? 1 : 0;
13
$allowDelete            = $acl->isAllowed($roleName, 'self-evaluation/forms/delete') ? 1 : 0;
14
 
15
 
16
$this->inlineScript()->appendFile($this->basePath('plugins/ckeditor/ckeditor.js'));
17
 
18
 
19
$this->headLink()->appendStylesheet($this->basePath('plugins/nprogress/nprogress.css'));
20
$this->inlineScript()->appendFile($this->basePath('plugins/nprogress/nprogress.js'));
21
 
22
 
23
$this->inlineScript()->appendFile($this->basePath('plugins/jquery-validation/jquery.validate.js'));
24
$this->inlineScript()->appendFile($this->basePath('plugins/jquery-validation/additional-methods.js'));
25
$this->inlineScript()->appendFile($this->basePath('plugins/jquery-validation/localization/messages_es.js'));
26
 
27
$this->headLink()->appendStylesheet($this->basePath('plugins/datatables-bs4/css/dataTables.bootstrap4.min.css'));
28
$this->headLink()->appendStylesheet($this->basePath('plugins/datatables-responsive/css/responsive.bootstrap4.min.css'));
29
 
30
$this->inlineScript()->appendFile($this->basePath('plugins/datatables/jquery.dataTables.min.js'));
31
$this->inlineScript()->appendFile($this->basePath('plugins/datatables-bs4/js/dataTables.bootstrap4.min.js'));
32
$this->inlineScript()->appendFile($this->basePath('plugins/datatables-responsive/js/dataTables.responsive.min.js'));
33
$this->inlineScript()->appendFile($this->basePath('plugins/datatables-responsive/js/responsive.bootstrap4.min.js'));
34
 
35
 
36
$this->headLink()->appendStylesheet($this->basePath('plugins/select2/css/select2.min.css'));
37
$this->headLink()->appendStylesheet($this->basePath('plugins/select2-bootstrap4-theme/select2-bootstrap4.min.css'));
38
 
39
$this->inlineScript()->appendFile($this->basePath('plugins/select2/js/select2.full.min.js'));
40
 
41
$this->inlineScript()->appendFile($this->basePath('plugins/moment/moment-with-locales.min.js'));
42
$this->headLink()->appendStylesheet($this->basePath('plugins/bootstrap-datetimepicker/css/bootstrap-datetimepicker.css'));
43
$this->inlineScript()->appendFile($this->basePath('plugins/bootstrap-datetimepicker/js/bootstrap-datetimepicker.min.js'));
44
 
45
 
46
$this->headLink()->appendStylesheet($this->basePath('plugins/bootstrap4-toggle/css/bootstrap4-toggle.min.css'));
47
$this->inlineScript()->appendFile($this->basePath('plugins/bootstrap4-toggle/js/bootstrap4-toggle.min.js'));
48
 
49
$this->inlineScript()->appendFile($this->basePath('plugins/bootstrap-confirmation/dist/bootstrap-confirmation.js'));
50
$this->headLink()->appendStylesheet($this->basePath('plugins/bootstrap-checkbox/awesome-bootstrap-checkbox.css'));
51
 
52
$status_active = \LeadersLinked\Model\CompanySelfEvaluationForm::STATUS_ACTIVE;
53
 
54
$language_es = \LeadersLinked\Model\CompanySelfEvaluationForm::LANGUAGE_SPANISH;
55
 
56
 
57
 
58
 
59
 
60
$this->inlineScript()->captureStart();
61
echo <<<JS
118 steven 62
		const classFormGenerator = function() {
63
			this.id 				= 0,
64
			this.table				= '',
65
			this.name 				= '',
66
			this.text 				= '',
67
			this.status				= 'a',
68
			this.sections 			= [],
69
			this.clear = function()
70
			{
71
				this.sections = [];
72
				this.render();
73
			},
74
			this.renderSection = function(section_slug)
75
			{
76
 
77
				var s = '';
78
				for(i = 0; i < this.sections.length; i++)
79
				{
80
					if(section_slug !=  this.sections[i].slug) {
81
						continue;
82
					}
83
 
84
					$('span.section-name' + section_slug).html(this.sections[i].name);
85
 
86
					let table = 'table-section-question-option' + this.sections[i].slug;
87
					$('#' + table  + ' tbody').empty();
88
 
89
					s = '<tr class="tr-section" data-slug="' + this.sections[i].slug + '">';
90
					s = s  + '<td class="text-left">Seccion</td>';
91
					s = s  + '<td class="text-left">' + this.sections[i].name +  '</td>';
92
					s = s  + '<td class="text-right">' + this.sections[i].value + '</td>';
93
					s = s  + '<td>&nbsp</td>';
94
					s = s  + '<td>';
95
					s = s  + '<button class="btn btn-default btn-edit-section" data-slug="' + this.sections[i].slug + '" data-toggle="tooltip" title="LABEL_EDIT LABEL_SECTION"><i class="fa fa-edit" aria-hidden="true"></i> LABEL_EDIT LABEL_SECTION </button>&nbsp';
96
					s = s  + '<button class="btn btn-default btn-delete-section" data-slug="' + this.sections[i].slug + '" data-toggle="tooltip" title="LABEL_DELETE LABEL_SECTION"><i class="fa fa-ban" aria-hidden="true"></i> LABEL_DELETE LABEL_SECTION </button>&nbsp';
97
					s = s  + '<button class="btn btn-default btn-add-question" data-slug="' + this.sections[i].slug + '" data-toggle="tooltip" title="LABEL_ADD LABEL_QUESTION"><i class="fa fa-plus" aria-hidden="true"></i> LABEL_ADD LABEL_QUESTION </button>&nbsp';
98
					s = s  + '</td>';
99
					s = s  + '</tr>';
100
					$('#' + table + ' tbody').append(s);
101
 
102
 
103
 
104
					for(j = 0; j < this.sections[i].questions.length; j++)
105
					{
106
						this.sections[i].questions[j].position = j;
107
 
108
						this.drawQuestion( this.sections[i].slug, this.sections[i].questions[j].slug, this.sections[i].questions[j].text, this.sections[i].questions[j].value , this.sections[i].questions[j].type);
109
						if(this.sections[i].questions[j].type == 'simple' || this.sections[i].questions[j].type == 'multiple'|| this.sections[i].questions[j].type == 'rating-open') {
110
 
111
 
112
							this.sections[i].questions[j].options.sort(function(a, b) {
113
										if (a.position > b.position) {
114
												return 1;
115
										}
116
										if (a.position < b.position) {
117
											return -1;
118
										}
119
										return 0;
120
									});
121
 
122
 
123
							for(k = 0; k < this.sections[i].questions[j].options.length; k++)
124
							{
125
								this.sections[i].questions[j].options[k].position = j;
126
								this.drawOption(
127
									this.sections[i].slug,
128
									this.sections[i].questions[j].slug,
129
									this.sections[i].questions[j].type,
130
									this.sections[i].questions[j].options[k].slug,
131
									this.sections[i].questions[j].options[k].text,
132
									this.sections[i].questions[j].options[k].type,
133
									this.sections[i].questions[j].options[k].correct,
134
									this.sections[i].questions[j].options[k].value
135
								);
136
							}
137
						}
138
					}
139
				}
140
 
141
				$('[data-toggle="tooltip"]').tooltip();
142
			},
143
			this.drawSection = function(section_slug, section_name, section_value)
144
			{
145
				let table = 'table-section-question-option' + section_slug;
146
				let collapse = 'collapse-' + section_slug;
147
 
148
				s = '<div class="panel panel-default" id="panel' + section_slug + '">';
149
				s = s + '	<div class="panel-heading">';
150
				s = s + '		<h4 class="panel-title">';
151
				s = s + '			<a class="accordion-toggle collapsed" data-toggle="collapse" data-parent="#accordion" href="#' + collapse + '"><span class="section-name' + section_slug + '">' + section_name + '</span></a>';
152
				s = s + '		</h4>';
153
				s = s + '	</div>';
154
				s = s + '	<div id="' + collapse + '" class="panel-collapse collapse">';
155
				s = s + '		<div class="panel-body">';
156
				s = s + '			<div class="table-responsive">';
157
				s = s + '				<table class="table table-bordered" id="' + table + '">';
158
				s = s + '					<thead>';
159
				s = s + '						<tr>';
160
				s = s + '							<th>LABEL_ELEMENT</th>';
161
				s = s + '							<th>LABEL_TEXT</th>';
162
				s = s + '							<th>LABEL_VALUE</th>';
163
				s = s + '							<th>LABEL_TYPE</th>';
164
				s = s + '							<th>LABEL_ACTIONS</th>';
165
				s = s + '						</tr>';
166
				s = s + '					</thead>';
167
				s = s + '					<tbody>';
168
				s = s + '					</tbody>';
169
				s = s + '				</table>';
170
				s = s + '			</div>';
171
				s = s + '		</div>';
172
				s = s + '	</div>';
173
				s = s + '</div>';
174
 
175
				$('#accordion').append(s);
176
 
177
 
178
				s = '<tr class="tr-section" data-slug="' + section_slug + '">';
179
				s = s  + '<td class="text-left">LABEL_SECTION</td>';
180
				s = s  + '<td class="text-left">' + section_name +  '</td>';
181
				s = s  + '<td class="text-right">' + section_value + '</td>';
182
				s = s  + '<td>&nbsp</td>';
183
				s = s  + '<td>';
184
				s = s  + '<button class="btn btn-default btn-edit-section" data-slug="' + section_slug + '" data-toggle="tooltip" title="LABEL_EDIT LABEL_SECTION"><i class="fa fa-edit" aria-hidden="true"></i> LABEL_EDIT LABEL_SECTION </button>&nbsp';
185
				s = s  + '<button class="btn btn-default btn-delete-section" data-slug="' + section_slug + '" data-toggle="tooltip" title="LABEL_DELETE LABEL_SECTION"><i class="fa fa-ban" aria-hidden="true"></i> LABEL_DELETE LABEL_SECTION </button>&nbsp';
186
				s = s  + '<button class="btn btn-default btn-add-question" data-slug="' + section_slug + '" data-toggle="tooltip" title="LABEL_ADD LABEL_SECTION"><i class="fa fa-plus" aria-hidden="true"></i> LABEL_ADD LABEL_SECTION </button>&nbsp';
187
				s = s  + '</td>';
188
				s = s  + '</tr>';
189
				$('#' + table + ' tbody').append(s);
190
			},
191
 
192
			this.drawQuestion = function(section_slug, question_slug, question_text, question_value, question_type)
193
			{
194
 
195
 
196
				s = '<tr class="tr-question" data-slug="' + question_slug + '">';
197
				s = s  + '<td class="text-left">--LABEL_QUESTION</td>';
198
				s = s  + '<td class="text-left">' + question_text +  '</td>';
199
				s = s  + '<td class="text-right"><font color="red">' + question_value + '</font></td>';
200
				s = s  + '<td>' + question_type.substr(0,1).toUpperCase() + question_type.substr(1) +  '</td>';
201
				s = s  + '<td>';
202
				s = s  + '<button class="btn btn-default btn-edit-question" data-section="' + section_slug + '" data-slug="' + question_slug + '" data-toggle="tooltip" title="LABEL_EDIT LABEL_QUESTION"><i class="fa fa-edit" aria-hidden="true"></i> LABEL_EDIT LABEL_QUESTION</button>&nbsp';
203
				s = s  + '<button class="btn btn-default btn-delete-question" data-section="' + section_slug + '" data-slug="' + question_slug + '" data-toggle="tooltip" title="LABEL_DELETE LABEL_QUESTION"><i class="fa fa-ban" aria-hidden="true"></i> LABEL_DELETE LABEL_QUESTION</button>&nbsp';
204
				if(question_type == 'simple' || question_type == 'multiple' || question_type == 'rating-open') {
205
					s = s  + '<button class="btn btn-default btn-add-option" data-section="' + section_slug + '" data-slug="' + question_slug + '" data-toggle="tooltip" title="LABEL_ADD LABEL_OPTION"><i class="fa fa-plus" aria-hidden="true"></i> LABEL_ADD LABEL_OPTION</button>&nbsp';
206
				}
207
 
208
				s = s  + '</td>';
209
 
210
				let table = 'table-section-question-option' + section_slug;
211
				$('#' + table + ' tbody').append(s);
212
			},
213
 
214
			this.drawOption = function(section_slug, question_slug,  question_type, option_slug, option_text, option_type, option_correct, option_value)
215
			{
216
 
217
 
218
				s = '<tr class="tr-option" data-slug="' + option_slug + '">';
219
				s = s  + '<td class="text-left">---LABEL_OPTION</td>';
220
				s = s  + '<td class="text-left">' + option_text +  '</td>';
221
				if(question_type == 'multiple' || question_type == 'rating-open') {
222
 
223
					if(question_type == 'multiple') {
224
						if(option_correct == 1) {
225
							s = s  + '<td class="text-right">' + option_value + '</td>';
226
						} else {
227
							s = s  + '<td>&nbsp</td>';
228
						}
229
					} else {
230
						s = s  + '<td class="text-right">' + option_value + '</td>';
231
					}
232
				} else {
233
					s = s  + '<td>&nbsp</td>';
234
				}
235
 
236
				if(question_type == 'simple' || question_type == 'multiple') {
237
					if(option_correct == 1) {
238
						s = s  + '<td class="text-left"><font color="green">LABEL_CORRECT</font></td>';
239
					} else {
240
						s = s  + '<td class="text-left"><font color="red">LABEL_FAIL</font></td>';
241
 
242
					}
243
				} else {
244
					s = s  + '<td>&nbsp</td>';
245
				}
246
 
247
 
248
				s = s  + '<td>';
249
				s = s  + '<button class="btn btn-default btn-edit-option" data-section="' + section_slug + '" data-question="' + question_slug + '" data-slug="' + option_slug + '" data-toggle="tooltip" title="LABEL_EDIT LABEL_OPTION"><i class="fa fa-edit" aria-hidden="true"></i></button>&nbsp';
250
				s = s  + '<button class="btn btn-default btn-delete-option" data-section="' + section_slug + '" data-question="' + question_slug + '" data-slug="' + option_slug + '" data-toggle="tooltip" title="LABEL_DELETE LABEL_OPTION"><i class="fa fa-ban" aria-hidden="true"></i></button>&nbsp';
251
				s = s  + '</td>';
252
 
253
				let table = 'table-section-question-option' + section_slug;
254
				$('#' + table + ' tbody').append(s);
255
 
256
			},
257
 
258
			this.render = function()
259
			{
260
				$('#accordion').empty();
261
 
262
				this.sections.sort(function(a, b) {
263
					if (a.position > b.position) {
264
							return 1;
265
					}
266
					if (a.position < b.position) {
267
						return -1;
268
					}
269
					return 0;
270
				});
271
 
272
				var s = '';
273
				for(i = 0; i < this.sections.length; i++)
274
				{
275
					this.sections[i].position = i;
276
 
277
 
278
					this.drawSection(this.sections[i].slug, this.sections[i].name, this.sections[i].value);
279
 
280
 
281
					this.sections[i].questions.sort(function(a, b) {
282
						if (a.position > b.position) {
283
								return 1;
284
						}
285
						if (a.position < b.position) {
286
							return -1;
287
						}
288
						return 0;
289
					});
290
 
291
 
292
					for(j = 0; j < this.sections[i].questions.length; j++)
293
					{
294
						this.sections[i].questions[j].position = j;
295
 
296
						this.drawQuestion( this.sections[i].slug, this.sections[i].questions[j].slug, this.sections[i].questions[j].text, this.sections[i].questions[j].value , this.sections[i].questions[j].type);
297
						if(this.sections[i].questions[j].type == 'simple' || this.sections[i].questions[j].type == 'multiple'|| this.sections[i].questions[j].type == 'rating-open') {
298
 
299
 
300
							this.sections[i].questions[j].options.sort(function(a, b) {
301
										if (a.position > b.position) {
302
												return 1;
303
										}
304
										if (a.position < b.position) {
305
											return -1;
306
										}
307
										return 0;
308
									});
309
 
310
 
311
							for(k = 0; k < this.sections[i].questions[j].options.length; k++)
312
							{
313
								this.sections[i].questions[j].options[k].position = j;
314
								this.drawOption(
315
									this.sections[i].slug,
316
									this.sections[i].questions[j].slug,
317
									this.sections[i].questions[j].type,
318
									this.sections[i].questions[j].options[k].slug,
319
									this.sections[i].questions[j].options[k].text,
320
									this.sections[i].questions[j].options[k].type,
321
									this.sections[i].questions[j].options[k].correct,
322
									this.sections[i].questions[j].options[k].value
323
								);
324
							}
325
						}
326
 
327
					}
328
 
329
 
330
				}
331
 
332
 
333
				$('[data-toggle="tooltip"]').tooltip();
334
 
335
			},
336
 
337
			this.addSection = function (name, text, value)
338
			{
339
				var d = new Date();
340
					var slug = 'section' + d.getTime();
341
 
342
					var position = 0;
343
					$.each(this.sections, function(index, section) {
344
						if(position < section.position) {
345
							position = section.position;
346
						}
347
					});
348
					position++;
349
 
350
				var section = {
351
					'slug' 		: slug,
352
					'name' 		: name,
353
					'text' 		: text,
354
					'value' 	: value,
355
					'position' 	: position,
356
					'questions' : [],
357
				}
358
 
359
				this.sections.push(section);
360
				this.drawSection(slug, name, text);
361
			},
362
			this.editSection = function (slug, name, text, value)
363
			{
364
				var renderTable = false;
365
				for(i = 0; i < this.sections.length; i++)
366
				{
367
						if(slug == this.sections[i].slug) {
368
							this.sections[i].name = name;
369
							this.sections[i].text = text;
370
							this.sections[i].value = value;
371
							renderTable = true;
372
 
373
							break;
374
						}
375
				}
376
				if(renderTable) {
377
					this.renderSection(slug);
378
				}
379
 
380
 
381
			},
382
			this.deleteSection = function(slug)
383
			{
384
				var renderTable = false;
385
				for(i = 0; i < this.sections.length; i++)
386
				{
387
						if(slug == this.sections[i].slug) {
388
							this.sections.splice(i, 1);
389
 
390
							renderTable = true;
391
							break;
392
					}
393
 
394
 
395
				}
396
				if(renderTable) {
397
					$('#panel' + slug).remove();
398
				}
399
			},
400
			this.addQuestion = function (section_slug, text, value, type, maxlength, multiline, range)
401
			{
402
				var d = new Date();
403
				var slug = 'question' + d.getTime();
404
 
405
				var position = 0;
406
				var renderTable = false;
407
				for(i = 0; i < this.sections.length; i++)
408
				{
409
					if(section_slug == this.sections[i].slug) {
410
						$.each(this.sections[i].questions, function(index, question) {
411
							if(position < question.position) {
412
								position = question.position;
413
							}
414
						});
415
						position++;
416
 
417
						var question = {
418
							'slug' : slug,
419
								'text' : text,
420
								'value' : value,
421
								'type' : type,
422
								'position' : position,
423
								'maxlength' :maxlength,
424
								'multiline' : multiline,
425
								'range' : range,
426
								'options' : [],
427
							}
428
 
429
						this.sections[i].questions.push(question);
430
						renderTable = true;
431
						break;
432
					}
433
				}
434
 
435
				if(renderTable) {
436
					this.renderSection(section_slug);
437
				}
438
			},
439
			this.editQuestion = function(section_slug, question_slug, text, value, type, maxlength, multiline, range)
440
			{
441
				var renderTable = false;
442
				for(i = 0; i < this.sections.length; i++)
443
				{
444
					if(section_slug == this.sections[i].slug) {
445
						for(j = 0; j < this.sections[i].questions.length; j++) {
446
							if(question_slug == this.sections[i].questions[j].slug) {
447
								this.sections[i].questions[j].text 	= text,
448
								this.sections[i].questions[j].value	= value,
449
								this.sections[i].questions[j].type 	= type;
450
 
451
								if(type == 'open') {
452
									this.sections[i].questions[j].maxlength	= maxlength;
453
									this.sections[i].questions[j].multiline	= multiline;
454
									this.sections[i].questions[j].options	= [];
455
								} else {
456
									this.sections[i].questions[j].maxlength	= 0;
457
									this.sections[i].questions[j].multiline	= 0;
458
								}
459
 
460
									if(type == 'rating-range') {
461
										this.sections[i].questions[j].range = range;
462
									} else {
463
										this.sections[i].questions[j].range = 0;
464
									}
465
								renderTable = true;
466
								break;
467
							}
468
						}
469
					}
470
					if(renderTable) {
471
						break;
472
					}
473
				}
474
				if(renderTable) {
475
					this.renderSection(section_slug);
476
				}
477
			},
478
			this.deleteQuestion = function(section_slug, question_slug)
479
			{
480
				var renderTable = false;
481
				for(i = 0; i < this.sections.length; i++)
482
				{
483
						if(section_slug == this.sections[i].slug) {
484
							for(j = 0; j < this.sections[i].questions.length; j++) {
485
							if(question_slug == this.sections[i].questions[j].slug) {
486
									this.sections[i].questions.splice(j, 1);
487
										renderTable = true;
488
										break;
489
							}
490
						}
491
					}
492
 
493
					if(renderTable) {
494
						break;
495
					}
496
				}
497
				if(renderTable) {
498
					this.renderSection(section_slug);
499
				}
500
			},
501
			this.addOption = function (section_slug, question_slug, text, correct, value)
502
			{
503
				var d = new Date();
504
				var slug = 'option' + d.getTime();
505
 
506
				var position = 0;
507
				var renderTable = false;
508
				for(i = 0; i < this.sections.length; i++)
509
				{
510
					if(section_slug == this.sections[i].slug) {
511
						for(j = 0; j < this.sections[i].questions.length; j++) {
512
							if(question_slug == this.sections[i].questions[j].slug) {
513
								$.each(this.sections[i].questions[j].options, function(index, option) {
514
										if(position < option.position) {
515
											position = option.position;
516
										}
517
									});
518
									position++;
519
 
520
									var option = {
521
										'slug' : slug,
522
											'text' : text,
523
											'correct' : correct,
524
											'value' : value
525
										}
526
 
527
										this.sections[i].questions[j].options.push(option);
528
									renderTable = true;
529
									break;
530
							}
531
 
532
									if(renderTable) {
533
								break;
534
							}
535
						}
536
					}
537
				}
538
				if(renderTable) {
539
					this.renderSection(section_slug);
540
				}
541
			},
542
			this.editOption = function(section_slug, question_slug, option_slug, text, correct, value)
543
			{
544
				var renderTable = false;
545
				for(i = 0; i < this.sections.length; i++)
546
				{
547
					if(section_slug == this.sections[i].slug) {
548
						for(j = 0; j < this.sections[i].questions.length; j++) {
549
							if(question_slug == this.sections[i].questions[j].slug) {
550
								for(k = 0; k < this.sections[i].questions[j].options.length; k++) {
551
									if(option_slug == this.sections[i].questions[j].options[k].slug) {
552
										this.sections[i].questions[j].options[k].text = text;
553
										this.sections[i].questions[j].options[k].correct = correct;
554
										this.sections[i].questions[j].options[k].value = value;
555
										renderTable = true;
556
												break;
557
									}
558
								}
559
							}
560
									if(renderTable) {
561
								break;
562
							}
563
						}
564
					}
565
						if(renderTable) {
566
							break;
567
						}
568
				}
569
 
570
				if(renderTable) {
571
					this.renderSection(section_slug);
572
				}
573
			},
574
			this.deleteOption = function(section_slug, question_slug, option_slug)
575
			{
576
				var renderTable = false;
577
				for(i = 0; i < this.sections.length; i++)
578
				{
579
						if(section_slug == this.sections[i].slug) {
580
							for(j = 0; j < this.sections[i].questions.length; j++) {
581
							if(question_slug == this.sections[i].questions[j].slug) {
582
								for(k = 0; k < this.sections[i].questions[j].options.length; k++) {
583
									if(option_slug == this.sections[i].questions[j].options[k].slug) {
584
										this.sections[i].questions[j].options.splice(k, 1);
585
										renderTable = true;
586
												break;
587
									}
588
								}
589
							}
590
									if(renderTable) {
591
								break;
592
							}
593
						}
594
					}
595
 
596
					if(renderTable) {
597
						break;
598
					}
599
				}
600
				if(renderTable) {
601
					this.renderSection(section_slug);
602
				}
603
			}
604
		}
605
 
606
		function htmlEntities(str) {
607
				return String(str).replace(/&/g, '&amp;').replace(/</g, '&lt;').replace(/>/g, '&gt;').replace(/"/g, '&quot;');
608
		}
609
    jQuery( document ).ready(function( $ ) {
610
			var objFormGenerator = new classFormGenerator();
611
	objFormGenerator.render();
612
 
613
 
614
	var tableForm = $('#table-form').dataTable({
615
		select :true,
616
        bProcessing: true,
617
        bServerSide: true,
618
        sAjaxSource: "ajax.<?php echo $this->module; ?>.php?action=gridview",
619
        fnServerData: function (sSource, aoData, fnCallback) {
620
         	$.ajax({
621
               	dataType: 'json',
622
                type: "POST",
623
                url: sSource,
624
                data: aoData,
625
                success: fnCallback
626
          	});
627
        },
628
        aaSorting : [],
629
        aoColumns: [
630
					{sName: "checkbox", sTitle : '<input type="checkbox" value="all" data-type="select_all" name="select_all" id="select_all">',bSortable:false,bSearchable:false},
631
					{sName: "name", sTitle: 'LABEL_FIRST_NAME'},
632
					{sName: "language", sTitle: 'LABEL_LANGUAGE'},
633
					{sName: "added_on", sTitle : 'LABEL_ADDED_ON'},
634
					{sName: "status", sTitle: 'LABEL_STATUS', bSortable:false, bSearchable:false},
635
					{sName: "operation", sTitle: 'LABEL_OPERATION', bSortable: false, bSearchable: false},
636
         ],
637
        //  fnServerParams: function(aoData){
638
        //  	setTitle(aoData, this)
639
        //  },
640
         fnDrawCallback: function(oSettings) {
641
         		$('.make-switch-form').bootstrapSwitch();
642
            $('.make-switch-form').bootstrapSwitch('setOnClass', 'success');
643
            $('.make-switch-form').bootstrapSwitch('setOffClass', 'danger');
644
         }
645
	});
646
 
647
	$('body').on('click', 'a.btn-delete-form',function(e) {
648
		e.preventDefault();
649
		form_id =  $(this).data('id')
650
 
651
		bootbox.confirm({
652
		    title: "LABEL_DELETE LABEL_FORM",
653
		    message: "LABEL_ARE_YOU_SURE",
654
		    buttons: {
655
		        cancel: {
656
		            label: '<i class="fa fa-times"></i> LABEL_CANCEL'
657
		        },
658
		        confirm: {
659
		            label: '<i class="fa fa-check"></i> LABEL_ACCEPT'
660
		        }
661
		    },
662
		    callback: function (result) {
663
			    if(result) {
664
    		    	$.ajax({
665
    	                'dataType': 'json',
666
    	                'method': 'post',
667
    	                'url' :  'ajax.<?php echo $this->module; ?>.php?action=delete',
668
    	                'data' :{
669
    	                    'form-id' : form_id
670
    	                },
671
    	            }).done(function(response) {
672
 
673
    	                if(response['success']) {
674
    	                	$.fn.showSuccess(response['message']);
675
    	                	tableForm.fnDraw();
676
    	                } else {
677
    	                	$.fn.showError(response['message']);
678
    	                }
679
    	            }).fail(function( jqXHR, textStatus, errorThrown) {
680
    					$.fn.showError(textStatus);
681
    	            });
682
			    }
683
		    }
684
		});
685
 
686
 
687
    });
688
 
689
    $(document).on('click','[data-action="delete"]',function(){
690
 
691
    	bootbox.confirm({
692
		    title: "LABEL_DELETE LABEL_FORMS_2",
693
		    message: "LABEL_ARE_YOU_SURE",
694
		    buttons: {
695
		        cancel: {
696
		            label: '<i class="fa fa-times"></i> LABEL_CANCEL'
697
		        },
698
		        confirm: {
699
		            label: '<i class="fa fa-check"></i> LABEL_ACCEPT'
700
		        }
701
		    },
702
		    callback: function (result) {
703
			    if(result) {
704
			    	var d = currentSelected();
705
    		    	$.ajax({
706
    	                'dataType': 'json',
707
    	                'method': 'post',
708
    	                'url' :  'ajax.<?php echo $this->module; ?>.php?action=delete-selected',
709
    	                'data' :{
710
    	                	 selected : d
711
    	                },
712
    	            }).done(function(response) {
713
 
714
    	                if(response['success']) {
715
    	                	$.fn.showSuccess(response['message']);
716
    	                	tableForm.fnDraw();
717
    	                } else {
718
    	                	$.fn.showError(response['message']);
719
    	                }
720
    	            }).fail(function( jqXHR, textStatus, errorThrown) {
721
    					$.fn.showError(textStatus);
722
    	            });
723
			    }
724
		    }
725
		});
726
 
727
    });
728
 
729
 
730
    $('body').on('switch-change', 'input[type="checkbox"].make-switch-form', function(e) {
731
		e.preventDefault();
732
		e.stopPropagation();
733
 
734
		form_id =  $(this).data('id')
735
		form_status = $(this).prop('checked') ? 'A' : 'D';
736
 
737
 
738
		$.ajax({
739
        	'dataType': 'json',
740
            'method': 'post',
741
            'url' :  'ajax.<?php echo $this->module; ?>.php?action=status',
742
            'data' :{
743
            	'form-id' : form_id,
744
            	'form-status' : form_status
745
            },
746
        }).done(function(response) {
747
	        if(response['success']) {
748
	        	$.fn.showSuccess(response['message']);
749
	       } else {
750
    	       	$.fn.showError(response['message']);
751
            }
752
         }).fail(function( jqXHR, textStatus, errorThrown) {
753
			$.fn.showError(textStatus);
754
        })
755
    });
756
 
757
	$('body').on('click', 'a.btn-edit-form',function(e) {
758
		e.preventDefault();
759
		form_id =  $(this).data('id')
760
 
761
		$.ajax({
762
			'dataType': 'json',
763
			'method': 'post',
764
			'url' :  '/test/method-one',
765
			'data' :{
766
				'form-id' : form_id
767
			},
768
		}).done(function(response) {
769
			if(response['success']) {
770
					validatorForm.resetForm();
771
 
772
					$('#form-main #form-id' ).val(response['id']),
773
					$('#form-main #form-continue').val('0');
774
					$('#form-main #form-name' ).val(response['name']),
775
 
776
 
777
					instanceName = 'form-description';
778
					let editor = CKEDITOR.instances[instanceName ];
779
					editor.setData(response['description'], function() {
780
							editor.focus();
781
					});
782
 
783
 
784
					instanceName = 'form-text';
785
					CKEDITOR.instances[instanceName ].setData(response['text']);
786
 
787
					$( '#form-main #form-language' ).val(response['language']),
788
					$( '#form-main #form-status' ).val(response['status']);
789
 
790
					objFormGenerator.clear();
791
					objFormGenerator.sections = response['sections'];
792
					objFormGenerator.render();
793
					$('#row-forms').hide();
794
					$('#row-edit').show();
795
 
796
					$('#form-main #form-name').focus();
797
 
798
				} else {
799
					$.fn.showError(response['message']);
800
				}
801
			}).fail(function( jqXHR, textStatus, errorThrown) {
802
				$.fn.showError(textStatus);
803
			});
804
    });
805
 
806
	 $(document).on('click','[data-type="select_all"]',function(){
807
 
808
	        if($('input[name="select_all"]:checked').val() == 'all'){
809
	            $('[data-type="select"]').prop('checked', true);
810
	            $('[data-action="delete"]').removeClass('hide');
811
	        }else{
812
	            $('[data-type="select"]').prop('checked', false);
813
	            $('[data-action="delete"]').addClass('hide');
814
	        }
815
	    });
816
 
817
	    function getLength(){
818
	        return $('[data-type="select"]').length;
819
	    }
820
 
821
	    function currentSelected(){
822
	        var selected = [];
823
	        $.each($("input[name='select[]']:checked"), function(){
824
	            selected.push($(this).val());
825
	        });
826
 
827
	        return selected;
828
	    }
829
 
830
	    $(document).on('change',"input[name='select[]']",function(){
831
	        var c = currentSelected();
832
	        var cc = getLength();
833
 
834
 
835
	        if(c.length == cc){
836
	            if($('[data-action="delete"]').hasClass('hide')){
837
	                $('[data-action="delete"]').removeClass('hide');
838
	            }
839
	            return true;
840
	        }else{
841
	            $('input[name="select_all"]').prop('checked', false);
842
	        }
843
 
844
	        if(c.length > 0){
845
	            if($('[data-action="delete"]').hasClass('hide')){
846
	                $('[data-action="delete"]').removeClass('hide');
847
	            }
848
	        }else{
849
	            if(!$('[data-action="delete"]').hasClass('hide')){
850
	                $('[data-action="delete"]').addClass('hide');
851
	            }
852
	        }
853
	    });
854
 
855
	    var form3 = $('#form_sample_3');
856
        var error3 = $('.alert-danger', form3);
857
        var success3 = $('.alert-success', form3);
858
 
859
	//IMPORTANT: update CKEDITOR textarea with actual content before submit
860
 	$( "#form-main" ).on('submit', function() {
861
		for(var instanceName in CKEDITOR.instances) {
862
			CKEDITOR.instances[instanceName].updateElement();
863
		}
864
	})
865
 
866
	var validatorForm = $( "#form-main" ).validate( {
867
        ignore: [],
868
        errorClass: 'help-block',
869
        errorElement: 'span',
870
		rules: {
871
			'form-name':  {
872
				required: true,
873
				minlength: 2,
874
				maxlength: 50
875
			},
876
			'form-description' : {
877
				required: true,
878
			},
879
			'form-text' : {
880
				required: true,
881
			},
882
			'form-language' : {
883
				required: true,
884
			},
885
			'forrm-status' : {
886
				required: true,
887
			},
888
		},
889
        highlight: function (element) {
890
            $(element).closest('.form-group').addClass('has-error');
891
        },
892
        unhighlight: function (element) {
893
            $(element).closest('.form-group').removeClass('has-error');
894
        },
895
        errorPlacement: function (error, element) {
896
            if (element.attr("data-error-container")) {
897
                error.appendTo(element.attr("data-error-container"));
898
            } else {
899
                error.insertAfter(element);
900
            }
901
        },
902
        invalidHandler: function(form, validator) {
903
            if (!validator.numberOfInvalids())
904
                return;
905
            $('html, body').animate({
906
                scrollTop: $(validator.errorList[0].element).offset().top - 100
907
            }, 1000);
908
        },
909
		submitHandler: function(form) {
910
		    // do other things for a valid form
911
		    //form.submit();
912
 
913
 
914
		    var error = false;
915
		    if(objFormGenerator.sections.length == 0) {
916
		    	$.fn.showError('There are no sections');
917
		    	error = true;
918
		    } else {
919
 
920
		    	for(i = 0; i < objFormGenerator.sections.length; i++)
921
		    	{
922
 
923
		    		if(objFormGenerator.sections[i].questions.length == 0) {
924
		    			$.fn.showError('El "' + objFormGenerator.sections[i].name + '" no tiene preguntas');
925
		    			break;
926
		    		}
927
 
928
		    		var valueSection = parseInt(objFormGenerator.sections[i].value);
929
		    		var totalValueQuestion = 0;
930
 
931
 
932
		    		for(j = 0; j < objFormGenerator.sections[i].questions.length; j++)
933
		    		{
934
		    			valueQuestion = parseInt(objFormGenerator.sections[i].questions[j].value);
935
		    			totalValueQuestion = totalValueQuestion + valueQuestion;
936
		    			if(objFormGenerator.sections[i].questions[j].type == 'simple'
937
			    			|| objFormGenerator.sections[i].questions[j].type == 'multiple'
938
			    			|| objFormGenerator.sections[i].questions[j].type == 'rating-open' ) {
939
 
940
		    				var questionNumber = j + 1;
941
		    				var numberCorrect = 0;
942
 
943
 
944
		    				if(objFormGenerator.sections[i].questions[j].options.length == 0) {
945
		    					$.fn.showError('El "' + objFormGenerator.sections[i].name + '" seccion, La pregunta #' + questionNumber + ' no tiene opciones');
946
									error = true;
947
									break;
948
		    				}
949
 
950
 
951
		    				var totalOption = 0;
952
		    				var maxOption = 0;
953
		    				for(k = 0;  k < objFormGenerator.sections[i].questions[j].options.length; k++)
954
		    				{
955
		    					if(objFormGenerator.sections[i].questions[j].type == 'simple' || objFormGenerator.sections[i].questions[j].type == 'multiple' ) {
956
    		    					if(objFormGenerator.sections[i].questions[j].options[k].correct == 1) {
957
    		    						numberCorrect++;
958
    		    					}
959
		    					}
960
 
961
		    					if(objFormGenerator.sections[i].questions[j].type == 'multiple' && objFormGenerator.sections[i].questions[j].options[k].correct == 1) {
962
		    						totalOption = totalOption + parseInt(objFormGenerator.sections[i].questions[j].options[k].value);
963
			    				}
964
 
965
		    					if(objFormGenerator.sections[i].questions[j].type == 'rating-open') {
966
		    						if(parseInt(objFormGenerator.sections[i].questions[j].options[k].value) > maxOption) {
967
											maxOption = parseInt(objFormGenerator.sections[i].questions[j].options[k].value);
968
					    			}
969
			    				}
970
 
971
		    				}
972
 
973
		    				if(objFormGenerator.sections[i].questions[j].type == 'simple' || objFormGenerator.sections[i].questions[j].type == 'multiple' ) {
974
 
975
    		    				if(numberCorrect == 0) {
976
    		    					$.fn.showError('El "' + objFormGenerator.sections[i].name + '" seccion, La pregunta #' + questionNumber + ' no tiene una opcion correcta');
977
    		    					error = true;
978
    		    					break;
979
    		    				}
980
    		    				if(objFormGenerator.sections[i].questions[j].type == 'simple' && numberCorrect > 1) {
981
    		    					$.fn.showError('El "' + objFormGenerator.sections[i].name + '" seccion, La pregunta #' + questionNumber + ' tiene más de una opción correcta');
982
    		    					error = true;
983
    		    					break;
984
    		    				}
985
    		    				if(objFormGenerator.sections[i].questions[j].type == 'multiple' && numberCorrect == 1) {
986
    		    					$.fn.showError('El "' + objFormGenerator.sections[i].name + '" seccion, La pregunta #' + questionNumber + ' solo tiene una opción correcta');
987
    		    					error = true;
988
    		    					break;
989
    		    				}
990
		    				}
991
 
992
			    			//console.log('totalOption = ' + totalOption + ' valueQuestion = ' + valueQuestion );
993
 
994
			 				if(objFormGenerator.sections[i].questions[j].type == 'multiple' && totalOption > valueQuestion ) {
995
		     					$.fn.showError('El "' + objFormGenerator.sections[i].name + '" seccion, La pregunta #' + questionNumber + ' la suma de los valores de las opciones es mayor que el valor de la pregunta');
996
		    					error = true;
997
		    					break;
998
			    			}
999
 
1000
							//console.log('maxOption = ' + maxOption + ' valueQuestion = ' + valueQuestion );
1001
 
1002
		    				if(objFormGenerator.sections[i].questions[j].type == 'rating-open' && maxOption > valueQuestion ) {
1003
		     					$.fn.showError('El "' + objFormGenerator.sections[i].name + '" seccion, La pregunta #' + questionNumber + ' ');
1004
		    					error = true;
1005
		    					break;
1006
			    			}
1007
						}
1008
 
1009
 
1010
		    		}
1011
 
1012
		    		if(valueSection != totalValueQuestion) {
1013
		    			$.fn.showError('El "' + objFormGenerator.sections[i].name + '" sección y las preguntas no son las mismas');
1014
		    			error = true;
1015
		    			break;
1016
					}
1017
				}
1018
 
1019
 
1020
 
1021
    			if(error) {
1022
    				return false;
1023
    			} else {
1024
 
1025
 
1026
    				var formId		= parseInt($( '#form-main #form-id' ).val());
1027
    				var formContinue = parseInt($( '#form-main #form-continue' ).val());
1028
 
1029
    				var data = {
1030
    	    			'form-id'	: formId,
1031
        				'form-name' : $( '#form-main #form-name' ).val(),
1032
        				'form-description' : $( '#form-main #form-description' ).val(),
1033
        				'form-text' : $( '#form-main #form-text' ).val(),
1034
        				'form-language' : $( '#form-main #form-language' ).val(),
1035
        				'form-status' : $( '#form-main #form-status' ).val(),
1036
        				'sections' : objFormGenerator.sections
1037
    				}
1038
 
1039
 
1040
    				$.ajax({
1041
                        'dataType': 'json',
1042
                        'method': 'post',
1043
                        'url' :  '/test/method-one',
1044
                        'data' : data,
1045
                    }).done(function(response) {
1046
 
1047
                        if(response['success']) {
1048
                        	$.fn.showSuccess(response['message']);
1049
							if(formContinue == 1) {
1050
								$('#form-main #form-id').val(response['form-id']);
1051
								$('#form-main #form-continue').val(0);
1052
							} else {
1053
								$('#row-edit').hide();
1054
                        		$('#row-forms').show();
1055
							}
1056
 
1057
 
1058
							tableForm.fnDraw();
1059
 
1060
                        } else {
1061
                        	$.fn.showError(response['message']);
1062
                        }
1063
                    }).fail(function( jqXHR, textStatus, errorThrown) {
1064
						$.fn.showError(textStatus);
1065
                    });
1066
 
1067
                    return false;
1068
 
1069
 
1070
    			}
1071
			}
1072
 
1073
 
1074
		}
1075
	});
1076
 
1077
	//IMPORTANT: update CKEDITOR textarea with actual content before submit
1078
 	$( "#form-section" ).on('submit', function() {
1079
		for(var instanceName in CKEDITOR.instances) {
1080
			CKEDITOR.instances[instanceName].updateElement();
1081
		}
1082
	})
1083
 
1084
	var validatorFormSection = $( "#form-section" ).validate( {
1085
        ignore: [],
1086
        errorClass: 'help-block',
1087
        errorElement: 'span',
1088
		rules: {
1089
			'section-name':  {
1090
				required: true,
1091
				minlength: 2,
1092
				maxlength: 50
1093
			},
1094
			'section-text' : {
1095
				required: false,
1096
			},
1097
			'section-value' : {
1098
				required: true,
1099
				number: true,
1100
				min: 1
1101
			},
1102
		},
1103
        highlight: function (element) {
1104
            $(element).closest('.form-group').addClass('has-error');
1105
        },
1106
        unhighlight: function (element) {
1107
            $(element).closest('.form-group').removeClass('has-error');
1108
        },
1109
        errorPlacement: function (error, element) {
1110
            if (element.attr("data-error-container")) {
1111
                error.appendTo(element.attr("data-error-container"));
1112
            } else {
1113
                error.insertAfter(element);
1114
            }
1115
        },
1116
        invalidHandler: function(form, validator) {
1117
            if (!validator.numberOfInvalids())
1118
                return;
1119
            $('html, body').animate({
1120
                scrollTop: $(validator.errorList[0].element).offset().top - 100
1121
            }, 1000);
1122
        },
1123
		submitHandler: function(form) {
1124
		    // do other things for a valid form
1125
		    //form.submit();
1126
 
1127
		    var slug = $('#form-section #section-slug').val();
1128
		    if(slug) {
1129
		    	objFormGenerator.editSection(
1130
		    		$('#form-section #section-slug').val(),
1131
			    	$('#form-section #section-name').val(),
1132
			    	$('#form-section #section-text').val(),
1133
			    	$('#form-section #section-value').val()
1134
			  	);
1135
		    } else {
1136
		    	objFormGenerator.addSection(
1137
		    		$('#form-section #section-name').val(),
1138
		    		$('#form-section #section-text').val(),
1139
		    		$('#form-section #section-value').val()
1140
		    	);
1141
		    }
1142
 
1143
 
1144
 
1145
			$('#modal-section').modal('hide');
1146
			return false;
1147
		  }
1148
	} );
1149
 
1150
	//IMPORTANT: update CKEDITOR textarea with actual content before submit
1151
 	$( "#form-question" ).on('submit', function() {
1152
		for(var instanceName in CKEDITOR.instances) {
1153
			CKEDITOR.instances[instanceName].updateElement();
1154
		}
1155
	})
1156
 
1157
 
1158
	var validatorFormQuestion = $( "#form-question" ).validate( {
1159
        ignore: [],
1160
        errorClass: 'help-block',
1161
        errorElement: 'span',
1162
		rules: {
1163
			'question-text' : {
1164
				required: true,
1165
			},
1166
			'question-value' : {
1167
				required: true,
1168
				number: true,
1169
				min: 1
1170
			},
1171
			'question-type':  {
1172
				required: true,
1173
			},
1174
			'question-max-length' : {
1175
				required: true,
1176
				digits: true,
1177
				min: 0
1178
			},
1179
			'question-range' : {
1180
				required: true,
1181
				number: true,
1182
				min: 1
1183
			},
1184
		},
1185
        highlight: function (element) {
1186
            $(element).closest('.form-group').addClass('has-error');
1187
        },
1188
        unhighlight: function (element) {
1189
            $(element).closest('.form-group').removeClass('has-error');
1190
        },
1191
        errorPlacement: function (error, element) {
1192
            if (element.attr("data-error-container")) {
1193
                error.appendTo(element.attr("data-error-container"));
1194
            } else {
1195
                error.insertAfter(element);
1196
            }
1197
        },
1198
        invalidHandler: function(form, validator) {
1199
 
1200
			//console.log(validator);
1201
 
1202
            if (!validator.numberOfInvalids())
1203
                return;
1204
            $('html, body').animate({
1205
                scrollTop: $(validator.errorList[0].element).offset().top - 100
1206
            }, 1000);
1207
        },
1208
		submitHandler: function(form) {
1209
		    // do other things for a valid form
1210
		    //form.submit();
1211
 
1212
		    /*console.log('submitHandler');
1213
		    console.log('question-section = ' + $('#form-question #question-section').val());
1214
		    console.log('question-text = ' + $('#form-question #question-text').val());
1215
		    console.log('question-value = ' + $('#form-question #question-value').val());
1216
		    console.log('question-type = ' + $('#form-question #question-type').val());
1217
		    console.log('question-max-length = ' + $('#form-question #question-max-length').val());
1218
		    console.log('question-multiline = ' + $('#form-question #question-multiline').val());
1219
		    console.log('question-range = ' + $('#form-question #question-range').val());*/
1220
 
1221
 
1222
 
1223
		    if($('#form-question #question-slug').val()) {
1224
		    	console.log('editQuestion');
1225
 
1226
		    	objFormGenerator.editQuestion(
1227
		    		$('#form-question #question-section').val(),
1228
		    		$('#form-question #question-slug').val(),
1229
		    		$('#form-question #question-text').val(),
1230
		    		$('#form-question #question-value').val(),
1231
			    	$('#form-question #question-type').val(),
1232
			    	$('#form-question #question-max-length').val(),
1233
	    			$('#form-question #question-multiline').val(),
1234
	    			$('#form-question #question-range').val()
1235
			  	);
1236
		    } else {
1237
		    	console.log('addQuestion');
1238
 
1239
		    	objFormGenerator.addQuestion(
1240
			    	$('#form-question #question-section').val(),
1241
			    	$('#form-question #question-text').val(),
1242
			    	$('#form-question #question-value').val(),
1243
				    $('#form-question #question-type').val(),
1244
				    $('#form-question #question-max-length').val(),
1245
		    		$('#form-question #question-multiline').val(),
1246
		    		$('#form-question #question-range').val()
1247
		    	);
1248
		    }
1249
 
1250
			$('#modal-question').modal('hide');
1251
			return false;
1252
		  }
1253
	} );
1254
 
1255
	//IMPORTANT: update CKEDITOR textarea with actual content before submit
1256
 	$( "#form-option" ).on('submit', function() {
1257
		for(var instanceName in CKEDITOR.instances) {
1258
			CKEDITOR.instances[instanceName].updateElement();
1259
		}
1260
	})
1261
 
1262
	var validatorFormOption = $( "#form-option" ).validate( {
1263
        ignore: [],
1264
        errorClass: 'help-block',
1265
        errorElement: 'span',
1266
		rules: {
1267
			'option-text' : {
1268
				required: true,
1269
			},
1270
        	'option-value' : {
1271
				required: true,
1272
				number: true,
1273
				min: 1
1274
        	}
1275
		},
1276
        highlight: function (element) {
1277
            $(element).closest('.form-group').addClass('has-error');
1278
        },
1279
        unhighlight: function (element) {
1280
            $(element).closest('.form-group').removeClass('has-error');
1281
        },
1282
        errorPlacement: function (error, element) {
1283
            if (element.attr("data-error-container")) {
1284
                error.appendTo(element.attr("data-error-container"));
1285
            } else {
1286
                error.insertAfter(element);
1287
            }
1288
        },
1289
        invalidHandler: function(form, validator) {
1290
            if (!validator.numberOfInvalids())
1291
                return;
1292
            $('html, body').animate({
1293
                scrollTop: $(validator.errorList[0].element).offset().top - 100
1294
            }, 1000);
1295
        },
1296
		submitHandler: function(form) {
1297
		    // do other things for a valid form
1298
		    //form.submit();
1299
 
1300
 
1301
		    if($('#form-option #option-slug').val()) {
1302
		    	objFormGenerator.editOption(
1303
		    		$('#form-option #option-section').val(),
1304
		    		$('#form-option #option-question').val(),
1305
		    		$('#form-option #option-slug').val(),
1306
		    		$('#form-option #option-text').val(),
1307
		    		$('#form-option #option-correct').val(),
1308
		    		$('#form-option #option-value').val()
1309
			  	);
1310
		    } else {
1311
		    	objFormGenerator.addOption(
1312
			    	$('#form-option #option-section').val(),
1313
			    	$('#form-option #option-question').val(),
1314
			    	$('#form-option #option-text').val(),
1315
			    	$('#form-option #option-correct').val(),
1316
			    	$('#form-option #option-value').val()
1317
		    	);
1318
		    }
1319
 
1320
 
1321
 
1322
 
1323
			$('#modal-option').modal('hide');
1324
			return false;
1325
		  }
1326
	} );
1327
 
1328
	$('body').on('click', 'button[id="btn-add-section"]', function(e){
1329
		e.preventDefault();
1330
 
1331
		validatorFormSection.resetForm();
1332
		$('#form-section #section-slug').val('');
1333
		$('#form-section #section-name').val('');
1334
 
1335
		instanceName = 'section-text';
1336
		let editor = CKEDITOR.instances[instanceName ];
1337
		editor.setData( '', function() {
1338
		    editor.focus();
1339
		});
1340
 
1341
 
1342
		$('#form-section #section-value').val('0');
1343
		$('#modal-section h4[class="modal-title"]').html('New Section');
1344
		$('#modal-section').modal('show');
1345
	});
1346
 
1347
	$('body').on('click', 'button.btn-edit-section', function(e){
1348
	    e.preventDefault();
1349
 
1350
	    var slug = $(this).data('slug');
1351
	    var section;
1352
	    var showForm = false;
1353
 
1354
	    for(i = 0; i < objFormGenerator.sections.length; i++) {
1355
	        section = objFormGenerator.sections[i];
1356
 
1357
	    	if(slug == section.slug) {
1358
 
1359
		    	//console.log('btn-edit-section');
1360
		    	//console.log(section);
1361
 
1362
				validatorFormSection.resetForm();
1363
	    		$('#form-section #section-slug').val(section.slug);
1364
	    		$('#form-section #section-name').val(section.name);
1365
 
1366
	    		instanceName = 'section-text';
1367
	    		let editor = CKEDITOR.instances[instanceName ];
1368
	    		editor.setData( section.text, function() {
1369
	    		    editor.focus();
1370
	    		});
1371
 
1372
				$('#form-section #section-value').val(section.value);
1373
 
1374
				showForm = true;
1375
				break;
1376
	    	}
1377
	    }
1378
 
1379
	    if(showForm) {
1380
	    	$('#modal-section h4[class="modal-title"]').html('Edit Section');
1381
			$('#modal-section').modal('show');
1382
	    }
1383
 
1384
	});
1385
 
1386
	$('body').on('click', 'button.btn-delete-section', function(e){
1387
		e.preventDefault();
1388
		var slug = $(this).data('slug');
1389
 
1390
		bootbox.confirm({
1391
		    title: "LABEL_DELETE LABEL_SECTION?",
1392
		    message: "LABEL_ARE_YOU_SURE",
1393
		    buttons: {
1394
		        cancel: {
1395
		            label: '<i class="fa fa-times"></i> LABEL_CANCEL'
1396
		        },
1397
		        confirm: {
1398
		            label: '<i class="fa fa-check"></i> LABEL_ACCEPT'
1399
		        }
1400
		    },
1401
		    callback: function (result) {
1402
		    	if (result) {
1403
					objFormGenerator.deleteSection(slug);
1404
				}
1405
		    }
1406
		});
1407
 
1408
 
1409
 
1410
	});
1411
 
1412
 
1413
	$('body').on('click', 'button.btn-add-question', function(e){
1414
		e.preventDefault();
1415
 
1416
		validatorFormQuestion.resetForm();
1417
		var slug = $(this).data('slug');
1418
 
1419
		$('#form-question #question-section').val(slug);
1420
		$('#form-question #question-slug').val('');
1421
 
1422
		instanceName = 'question-text';
1423
		let editor = CKEDITOR.instances[instanceName ];
1424
		editor.setData( '', function() {
1425
		    editor.focus();
1426
		});
1427
 
1428
 
1429
		$('#form-question #question-value').val('0');
1430
		$('#form-question #question-type').val($('#form-question #question-type option:first').val());
1431
 
1432
		$('#form-question #question-max-length').val('0');
1433
		$('#form-question #question-max-length').parent().show();
1434
 
1435
		$('#form-question #question-multiline').val('0');
1436
		$('#form-question #question-multiline').parent().show();
1437
 
1438
		$('#form-question #question-range').val('10');
1439
		$('#form-question #question-range').parent().hide();
1440
 
1441
		$('#modal-question h4[class="modal-title"]').html('New Question');
1442
		$('#modal-question').modal('show');
1443
 
1444
	});
1445
 
1446
 
1447
 
1448
	$('body').on('click', 'button.btn-edit-question', function(e){
1449
	    e.preventDefault();
1450
 
1451
	    var slug_section	= $(this).data('section');
1452
	    var slug 			= $(this).data('slug');
1453
	    var showForm 		= false;
1454
 
1455
	    for(i = 0; i < objFormGenerator.sections.length; i++) {
1456
 
1457
	    	if(slug_section == objFormGenerator.sections[i].slug) {
1458
 
1459
	    		for(j = 0; j < objFormGenerator.sections[i].questions.length; j++) {
1460
 
1461
	    			if(slug == objFormGenerator.sections[i].questions[j].slug) {
1462
	    				validatorFormQuestion.resetForm();
1463
 
1464
	    				$('#form-question #question-section').val(objFormGenerator.sections[i].slug);
1465
	    				$('#form-question #question-slug').val(objFormGenerator.sections[i].questions[j].slug);
1466
 
1467
	    	    		instanceName = 'question-text';
1468
	    	    		let editor = CKEDITOR.instances[instanceName ];
1469
	    	    		editor.setData( objFormGenerator.sections[i].questions[j].text, function() {
1470
	    	    		    editor.focus();
1471
	    	    		});
1472
 
1473
 
1474
	        			$('#form-question #question-value').val(objFormGenerator.sections[i].questions[j].value);
1475
	        			$('#form-question #question-type').val(objFormGenerator.sections[i].questions[j].type);
1476
 
1477
 
1478
 
1479
	        			if(objFormGenerator.sections[i].questions[j].type == 'open') {
1480
		        			$('#form-question #question-max-length').val(objFormGenerator.sections[i].questions[j].maxlength);
1481
		        			$('#form-question #question-max-length').parent().show();
1482
 
1483
		        			$('#form-question #question-multiline').val(objFormGenerator.sections[i].questions[j].multiline);
1484
							$('#form-question #question-multiline').parent().show();
1485
	        			} else {
1486
		        			$('#form-question #question-max-length').val('0');
1487
		        			$('#form-question #question-max-length').parent().hide();
1488
 
1489
		        			$('#form-question #question-multiline').val('0');
1490
							$('#form-question #question-multiline').parent().hide();
1491
	        			}
1492
 
1493
	        			if(objFormGenerator.sections[i].questions[j].type == 'rating-range') {
1494
	            			$('#form-question #question-range').val(objFormGenerator.sections[i].questions[j].range);
1495
		        			$('#form-question #question-range').parent().show();
1496
 
1497
	        			} else {
1498
	            			$('#form-question #question-range').val('10');
1499
		        			$('#form-question #question-range').parent().hide();
1500
		        		}
1501
 
1502
    					showForm = true;
1503
    					break;
1504
 
1505
	    			}
1506
 
1507
	    		}
1508
 
1509
	    		break;
1510
	    	}
1511
	    }
1512
 
1513
	    if(showForm) {
1514
	    	$('#modal-question h4[class="modal-title"]').html('LABEL_EDIT LABEL_QUESTION');
1515
				$('#modal-question').modal('show');
1516
	    }
1517
 
1518
	});
1519
 
1520
 
1521
 
1522
 
1523
	$('body').on('click', 'button.btn-delete-question', function(e){
1524
		e.preventDefault();
1525
 
1526
		var slug_section	= $(this).data('section');
1527
		var slug 			= $(this).data('slug');
1528
 
1529
		bootbox.confirm({
1530
			title: "LABEL_DELETE LABEL_QUESTION?",
1531
			message: "LABEL_ARE_YOU_SURE",
1532
			buttons: {
1533
				cancel: {
1534
   					label: '<i class="fa fa-times"></i> LABEL_CANCEL'
1535
    			},
1536
			    confirm: {
1537
			    	label: '<i class="fa fa-check"></i> LABEL_ACCEPT'
1538
			    }
1539
			},
1540
			callback: function (result) {
1541
				if (result) {
1542
					objFormGenerator.deleteQuestion(slug_section, slug);
1543
				}
1544
			}
1545
		});
1546
	});
1547
 
1548
 
1549
	$('body').on('click', 'button.btn-add-option', function(e){
1550
		e.preventDefault();
1551
	    var slug_section	= $(this).data('section');
1552
		var slug_question 	= $(this).data('slug');
1553
		var showForm 		= false;
1554
 
1555
	    for(i = 0; i < objFormGenerator.sections.length; i++) {
1556
	    	if(slug_section == objFormGenerator.sections[i].slug) {
1557
	    		for(j = 0; j < objFormGenerator.sections[i].questions.length; j++) {
1558
	    			if(slug_question == objFormGenerator.sections[i].questions[j].slug) {
1559
 
1560
                		validatorFormOption.resetForm();
1561
                		$('#form-option #option-section').val(slug_section);
1562
                		$('#form-option #option-question').val(slug_question);
1563
                		$('#form-option #option-slug').val('');
1564
 
1565
                		instanceName = 'option-text';
1566
	    	    		let editor = CKEDITOR.instances[instanceName ];
1567
	    	    		editor.setData( '', function() {
1568
	    	    		    editor.focus();
1569
	    	    		});
1570
 
1571
 
1572
	    	    		$('#form-option #option-correct').val('0');
1573
                		if(objFormGenerator.sections[i].questions[j].type == 'rating-open') {
1574
                    		$('#form-option #option-correct').parent().hide();
1575
                        } else {
1576
                    		$('#form-option #option-correct').parent().show();
1577
                        }
1578
 
1579
                		if(objFormGenerator.sections[i].questions[j].type == 'multiple' || objFormGenerator.sections[i].questions[j].type == 'rating-open') {
1580
                			$('#form-option #option-value').val('0');
1581
                			$('#form-option #option-value').parent().show();
1582
                		} else {
1583
                			$('#form-option #option-value').val('1');
1584
                			$('#form-option #option-value').parent().hide();
1585
 
1586
                       	}
1587
                		showForm = true;
1588
	    			}
1589
	    		}
1590
	    	}
1591
	    }
1592
 
1593
		if(showForm) {
1594
    		$('#modal-option h4[class="modal-title"]').html('New Option');
1595
    		$('#modal-option').modal('show');
1596
		}
1597
 
1598
	});
1599
 
1600
 
1601
 
1602
	$('body').on('click', 'button.btn-edit-option', function(e){
1603
	    e.preventDefault();
1604
 
1605
	    var slug_section	= $(this).data('section');
1606
	    var slug_question	= $(this).data('question');
1607
	    var slug 			= $(this).data('slug');
1608
	    var showForm 		= false;
1609
 
1610
	    for(i = 0; i < objFormGenerator.sections.length; i++) {
1611
	    	if(slug_section == objFormGenerator.sections[i].slug) {
1612
	    		for(j = 0; j < objFormGenerator.sections[i].questions.length; j++) {
1613
	    			if(slug_question == objFormGenerator.sections[i].questions[j].slug) {
1614
	    				for(k = 0; k < objFormGenerator.sections[i].questions[j].options.length; k++) {
1615
	    					if(slug == objFormGenerator.sections[i].questions[j].options[k].slug) {
1616
	    						validatorFormOption.resetForm();
1617
	    						$('#form-option #option-section').val(objFormGenerator.sections[i].slug);
1618
	    						$('#form-option #option-question').val(objFormGenerator.sections[i].questions[j].slug);
1619
    		    				$('#form-option #option-slug').val(objFormGenerator.sections[i].questions[j].options[k].slug);
1620
 
1621
    		    				instanceName = 'option-text';
1622
    		    	    		let editor = CKEDITOR.instances[instanceName ];
1623
    		    	    		editor.setData( objFormGenerator.sections[i].questions[j].options[k].text, function() {
1624
    		    	    		    editor.focus();
1625
    		    	    		});
1626
 
1627
 
1628
    		    				$('#form-option #option-correct').val(objFormGenerator.sections[i].questions[j].options[k].correct);
1629
    		    				if(objFormGenerator.sections[i].questions[j].type == 'multiple' || objFormGenerator.sections[i].questions[j].type == 'simple') {
1630
    		    					$('#form-option #option-correct').parent().show();
1631
    		    				} else {
1632
    		    					$('#form-option #option-correct').parent().hide();
1633
            		    		}
1634
 
1635
    		    				$('#form-option #option-value').val(objFormGenerator.sections[i].questions[j].options[k].value);
1636
 
1637
								if(objFormGenerator.sections[i].questions[j].type == 'multiple' || objFormGenerator.sections[i].questions[j].type == 'rating-open') {
1638
    		    					$('#form-option #option-value').parent().show();
1639
								} else {
1640
									$('#form-option #option-value').parent().hide();
1641
								}
1642
 
1643
 
1644
 
1645
    		    				showForm = true;
1646
    	    					break;
1647
	    					}
1648
	    				}
1649
	    			}
1650
	    			if(showForm) {
1651
		    			break;
1652
		    		}
1653
	    		}
1654
	    	}
1655
			if(showForm) {
1656
    			break;
1657
    		}
1658
	    }
1659
 
1660
	    if(showForm) {
1661
	    	$('#modal-option h4[class="modal-title"]').html('LABEL_EDIT LABEL_OPTION');
1662
				$('#modal-option').modal('show');
1663
	    }
1664
	});
1665
 
1666
	$('body').on('click', 'button.btn-delete-option', function(e){
1667
		e.preventDefault();
1668
		var slug_section	= $(this).data('section');
1669
		var slug_question	= $(this).data('question');
1670
		    var slug 			= $(this).data('slug');
1671
 
1672
 
1673
		bootbox.confirm({
1674
			title: "LABEL_DELETE LABEL_OPTION?",
1675
			message: "LABEL_ARE_YOU_SURE",
1676
			buttons: {
1677
				cancel: {
1678
	   				label: '<i class="fa fa-times"></i> LABEL_CANCEL'
1679
	    		},
1680
				confirm: {
1681
					label: '<i class="fa fa-check"></i> LABEL_ACCEPT'
1682
				}
1683
			},
1684
			callback: function (result) {
1685
				if (result) {
1686
					objFormGenerator.deleteOption(slug_section, slug_question, slug);
1687
				}
1688
			}
1689
		});
1690
	})
1691
 
1692
	$('#form-section #section-value').inputNumberFormat({'decimal' : 2});
1693
 
1694
	$('#form-question #question-value').inputNumberFormat({'decimal' : 2});
1695
	$('#form-question #question-max-length').inputNumberFormat({'decimal' : 0});
1696
 
1697
	$('#form-option #option-value').inputNumberFormat({'decimal' : 2});
1698
 
1699
	$('#form-question #question-type').change(function(e) {
1700
		e.preventDefault();
1701
 
1702
		if($('#form-question #question-type').val() == 'open') {
1703
			$('#form-question #question-max-length').parent().show();
1704
			$('#form-question #question-multiline').parent().show();
1705
 
1706
		} else {
1707
			$('#form-question #question-max-length').val('0');
1708
			$('#form-question #question-max-length').parent().hide();
1709
 
1710
			$('#form-question #question-multiline').val('0');
1711
			$('#form-question #question-multiline').parent().hide();
1712
		}
1713
 
1714
		$('#form-question #question-range').val('10');
1715
		if($('#form-question #question-type').val() == 'rating-range') {
1716
			$('#form-question #question-range').parent().show();
1717
		} else {
1718
			$('#form-question #question-range').parent().hide();
1719
		}
1720
 
1721
 
1722
 
1723
	});
1724
 
1725
	$('button.btn-add-form').click(function(e) {
1726
		e.preventDefault();
1727
 
1728
		objFormGenerator.clear();
1729
		objFormGenerator.render();
1730
		validatorForm.resetForm();
1731
 
1732
		$('#form-main #form-id').val('0');
1733
		$('#form-main #form-continue').val('0');
1734
		$('#form-main #form-name').val('');
1735
 
1736
		instanceName = 'form-text';
1737
		let editor = CKEDITOR.instances[instanceName ];
1738
		editor.setData('', function() {
1739
		    editor.focus();
1740
		});
1741
 
1742
 
1743
		instanceName = 'form-description';
1744
		CKEDITOR.instances[instanceName ].setData('');
1745
 
1746
		$( '#form-main #form-language' ).val('EN'),
1747
		$( '#form-main #form-status' ).val('D');
1748
 
1749
		$('#row-forms').hide();
1750
		$('#row-edit').show();
1751
		$('#form-main #form-name').focus();
1752
 
1753
        /*$('html, body').animate({
1754
            scrollTop: $('#form-main #form-name').offset().top - 100
1755
        }, 1000);*/
1756
	});
1757
 
1758
	$('button.btn-edit-cancel').click(function(e) {
1759
		e.preventDefault();
1760
		$('#row-edit').hide();
1761
		$('#row-forms').show();
1762
 
1763
	});
1764
 
1765
 
1766
	$('button.btn-form-save-continue').click(function(e) {
1767
		e.preventDefault();
1768
		$('#form-main #form-continue').val('1')
1769
		$('#form-main').submit();
1770
	});
1771
 
1772
	$('button.btn-form-save-close').click(function(e) {
1773
		e.preventDefault();
1774
		$('#form-main #form-continue').val('0')
1775
		$('#form-main').submit();
1776
 
1777
	});
1778
 
1779
	$('#modal-section, #modal-question, #modal-option').modal({
1780
			backdrop: 'static',
1781
			keyboard: false,
1782
			show: false
1783
		});
1784
	});
1785
JS;
115 efrain 1786
$this->inlineScript()->captureEnd();
1787
?>
118 steven 1788
 
1789
 
115 efrain 1790
 
1791
<!-- Content Header (Page header) -->
1792
<section class="content-header">
1793
	<div class="container-fluid">
1794
    	<div class="row mb-2">
1795
        	<div class="col-sm-12">
1796
            	<h1>LABEL_SELF_EVALUATION_FORMS</h1>
1797
			</div>
1798
		</div>
1799
	</div><!-- /.container-fluid -->
1800
</section>
1801
 
1802
<section class="content">
119 steven 1803
	<div class="container-fluid" id="row-forms">
1804
		<div class="row">
1805
				<div class="col-12">
1806
			<div class="card">
1807
				<div class="card-body">
1808
							<table id="gridTable" class="table   table-hover">
1809
											<thead>
1810
												<tr>
1811
													<th>LABEL_NAME</th>
1812
														<th>LABEL_LANGUAGE</th>
1813
														<th>LABEL_ACTIVE</th>
1814
														<th>LABEL_ACTIONS</th>
1815
												</tr>
1816
											</thead>
1817
											<tbody>
1818
											</tbody>
1819
									</table>
1820
								</div>
1821
							<div class="card-footer clearfix">
1822
								<div style="float:right;">
1823
									<button type="button" class="btn btn-info btn-refresh"><i class="fa fa-refresh"></i> LABEL_REFRESH </button>
1824
									<?php if($allowAdd) : ?>
1825
									<button type="button" class="btn btn-primary btn-add-form"><i class="fa fa-plus"></i> LABEL_ADD </button>
1826
									<?php endif; ?>
1827
								</div>
115 efrain 1828
						</div>
119 steven 1829
				</div>
1830
			</div>
1831
		</div>
115 efrain 1832
 	</div>
119 steven 1833
	<!-- Row Edit -->
1834
	<div class="row" id="row-edit" style="display: none">
1835
		<div class="col-xs-12 col-md-12">
1836
			<form action="#" name="form-main" id="form-main">
1837
				<input type="hidden" name="form-id" id="form-id" value="0" />
1838
				<input type="hidden" name="form-continue" id="form-continue" value="0" />
1839
						<div class="form-group">
1840
							<label for="form-name">LABEL_FIRST_NAME</label>
1841
							<input type="text" name="form-name" id="form-name" class="form-control" maxlength="50" />
115 efrain 1842
						</div>
1843
						<div class="form-group">
119 steven 1844
							<label for="form-description">LABEL_DESCRIPTION</label>
1845
							<!--  ckeditor -->
1846
							<textarea  name="form-description" id="form-description" rows="5" class="ckeditor form-control"></textarea>
115 efrain 1847
						</div>
1848
						<div class="form-group">
119 steven 1849
							<label for="form-text">LABEL_TEXT</label>
1850
							<!--  ckeditor -->
1851
							<textarea  name="form-text" id="form-text" rows="5" class="ckeditor form-control"></textarea>
115 efrain 1852
						</div>
1853
						<div class="form-group">
119 steven 1854
							<label for="form-language">LABEL_LANGUAGES</label>
1855
							<select name="form-language" id="form-language" class="form-control">
1856
								<option value="EN">LABEL_ENGLISH</option>
1857
								<option value="SP">LABEL_SPANISH</option>
1858
							</select>
115 efrain 1859
						</div>
1860
						<div class="form-group">
119 steven 1861
							<label for="form-status">LABEL_STATUS</label>
1862
							<select name="form-status" id="form-status" class="form-control">
1863
								<option value="D">LABEL_INACTIVE</option>
1864
								<option value="A">LABEL_ACTIVE</option>
1865
							</select>
115 efrain 1866
						</div>
119 steven 1867
						<br/>
1868
						<div class="row">
1869
					<div class="col-xs-12 col-md-12 text-right">
1870
						<button class="btn btn-primary" id="btn-add-section" data-toggle="tooltip" title="LABEL_ADD LABEL_SECTION"><i class="fa fa-plus" aria-hidden="true"></i> LABEL_ADD LABEL_SECTION</button>
1871
					</div>
1872
				</div>
1873
				<br />
1874
				<div class="row">
1875
					<div class="col-xs-12 col-md-12">
1876
						<div class="panel-group" id="accordion">
1877
 
115 efrain 1878
 
119 steven 1879
 
1880
						</div>
1881
					</div>
1882
				</div>
1883
 
115 efrain 1884
 
119 steven 1885
				<div class="form-group">
1886
					<button type="submit" form="form-main" class="btn btn-info btn-form-save-continue">LABEL_SAVE & LABEL_CONTINUE</button>
1887
					<button type="button" class="btn btn-primary btn-form-save-close">LABEL_SAVE & LABEL_CLOSE</button>
1888
					<button type="button" class="btn btn-secondary btn-edit-cancel">LABEL_CANCEL</button>
1889
				</div>
1890
			</form>
1891
		</div>
115 efrain 1892
	</div>
119 steven 1893
	<!-- End Row Edit -->
1894
	<!-- Modals -->
1895
		<!-- Section Modal -->
1896
		<div  id="modal-section" class="modal" tabindex="-1" role="dialog">
1897
			<div class="modal-dialog" role="document">
1898
					<form action="#" name="form-section" id="form-section">
1899
						<input type="hidden" name="section-slug" id="section-slug" value="" />
1900
						<div class="modal-content">
1901
								<div class="modal-header">
1902
									<!-- <h4 class="modal-title">Modal title</h4> -->
1903
									<!-- <button type="button" class="close" data-dismiss="modal" aria-label="Close">
1904
								<span aria-hidden="true">&times;</span>
1905
									</button> -->
1906
								</div>
1907
								<div class="modal-body">
1908
							<div class="form-group">
1909
								<label for="section-name">LABEL_FIRST_NAME</label>
1910
										<input type="text" name="section-name" id="section-name" class="form-control" maxlength="50" value="" />
1911
									</div>
1912
									<div class="form-group">
1913
										<label for="section-text">LABEL_TEXT</label>
1914
										<!--  ckeditor -->
1915
										<textarea  name="section-text" id="section-text" rows="5" class="ckeditor form-control"></textarea>
1916
									</div>
1917
									<div class="form-group">
1918
										<label for="section-value">LABEL_VALUE</label>
1919
										<input type="text" name="section-value" id="section-value"  class="form-control" value="0" />
1920
									</div>
1921
								</div>
1922
								<div class="modal-footer">
1923
									<button type="submit" class="btn btn-primary">LABEL_SAVE</button>
1924
									<button type="button" class="btn btn-secondary" data-dismiss="modal">LABEL_CLOSE</button>
1925
								</div>
1926
						</div>
1927
					</form>
1928
			</div>
1929
		</div>
1930
		<!-- End Modal Section -->
1931
		<!-- Question Modal -->
1932
			<div  id="modal-question" class="modal" tabindex="-1" role="dialog">
1933
				<div class="modal-dialog" role="document">
1934
					<form action="#" name="form-question" id="form-question">
1935
						<input type="hidden" name="question-section" id="question-section" />
1936
						<input type="hidden" name="question-slug" id="question-slug" />
1937
							<div class="modal-content">
1938
								<div class="modal-header">
1939
										<h4 class="modal-title">LABEL_ADD LABEL_QUESTION</h4>
1940
										<button type="button" class="close" data-dismiss="modal" aria-label="Close">
1941
											<span aria-hidden="true">&times;</span>
1942
										</button>
1943
									</div>
1944
								<div class="modal-body">
1945
										<div class="form-group">
1946
											<label for="question-text">LABEL_TEXT</label>
1947
											<!--  ckeditor -->
1948
											<textarea  name="question-text" id="question-text" rows="5" class="ckeditor form-control"></textarea>
1949
										</div>
1950
										<div class="form-group">
1951
											<label for="question-value">LABEL_VALUE</label>
1952
											<input type="text" name="question-value" id="question-value"  class="form-control" />
1953
										</div>
1954
										<div class="form-group">
1955
											<label for="question-type">LABEL_TYPE</label>
1956
											<select name="question-type" id="question-type" class="form-control">
1957
												<option value="open">LABEL_OPEN</option>
1958
												<option value="simple">Simple</option>
1959
												<option value="multiple">Multiple</option>
1960
												<option value="rating-open">LABEL_RATING_OPEN</option>
1961
												<option value="rating-range">LABEL_RATING_RANGE</option>
1962
											</select>
1963
										</div>
1964
										<div class="form-group">
1965
											<label for="question-max-length">LABEL_MAXLENGTH</label>
1966
											<input type="text" name="question-max-length" id="question-max-length"  class="form-control" />
1967
										</div>
1968
										<div class="form-group">
1969
											<label for="question-multiline">LABEL_MULTI_LINE</label>
1970
											<select name="question-multiline" id="question-multiline" class="form-control">
1971
												<option value="1">LABEL_YES</option>
1972
												<option value="0">No</option>
1973
											</select>
1974
										</div>
1975
										<div class="form-group">
1976
											<label for="question-range">LABEL_RANGE</label>
1977
											<select name="question-range" id="question-range" class="form-control">
1978
												<option value="10">1-10</option>
1979
												<option value="6">1-6</option>
1980
												<option value="5">1-5</option>
1981
											</select>
1982
										</div>
1983
									</div>
1984
									<div class="modal-footer">
1985
										<button type="submit" class="btn btn-primary">LABEL_SAVE</button>
1986
										<button type="button" class="btn btn-secondary" data-dismiss="modal">LABEL_CLOSE</button>
1987
									</div>
1988
							</div>
1989
						</form>
1990
				</div>
1991
			</div>
1992
		<!-- End Modal Question -->
1993
		<!-- MOdal Options -->
1994
		<div  id="modal-option" class="modal" tabindex="-1" role="dialog">
1995
			<div class="modal-dialog" role="document">
1996
				<form action="#" name="form-option" id="form-option">
1997
						<input type="hidden" name="option-section" id="option-section" value="" />
1998
						<input type="hidden" name="option-question" id="option-question" value="" />
1999
						<input type="hidden" name="option-slug" id="option-slug" value="" />
2000
							<div class="modal-content">
2001
								<div class="modal-header">
2002
									<h4 class="modal-title">LABEL_OPTION</h4>
2003
									<button type="button" class="close" data-dismiss="modal" aria-label="Close">
2004
										<span aria-hidden="true">&times;</span>
2005
									</button>
2006
								</div>
2007
								<div class="modal-body">
2008
									<div class="form-group">
2009
										<label for="option-text">LABEL_TEXT</label>
2010
										<!--  ckeditor -->
2011
										<textarea  name="option-text" id="option-text" rows="5" class="ckeditor form-control"></textarea>
2012
									</div>
2013
									<div class="form-group">
2014
										<label for="option-correct">LABEL_ANSWER_CORRECT</label>
2015
										<select name="option-correct" id="option-correct" class="form-control">
2016
											<option value="1">LABEL_YES</option>
2017
											<option value="0">No</option>
2018
										</select>
2019
									</div>
2020
									<div class="form-group">
2021
										<label for="option-value">LABEL_VALUE</label>
2022
										<input type="text" name="option-value" id="option-value" class="form-control" />
2023
									</div>
2024
								</div>
2025
								<div class="modal-footer">
2026
									<button type="submit" class="btn btn-primary">LABEL_SAVE</button>
2027
									<button type="button" class="btn btn-secondary" data-dismiss="modal">LABEL_CLOSE</button>
2028
								</div>
2029
						</div>
2030
					</form>
2031
			</div>
2032
		</div>
2033
		<!-- End Modal Options -->
2034
	<!-- End Modals -->
2035
</section>