Proyectos de Subversion LeadersLinked - Backend

Rev

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