Proyectos de Subversion LeadersLinked - Backend

Rev

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

Rev Autor Línea Nro. Línea
135 geraldo 1
<?php
2
$acl = $this->viewModel()->getRoot()->getVariable('acl');
3
$currentUser = $this->currentUserHelper();
115 efrain 4
 
5
$roleName = $currentUser->getUserTypeId();
6
 
135 geraldo 7
$routeAdd = $this->url('self-evaluation/forms/add');
115 efrain 8
$routeDatatable = $this->url('self-evaluation/forms');
9
$routeDashboard = $this->url('dashboard');
10
 
135 geraldo 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;
115 efrain 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
 
137 geraldo 53
// bootbox Alert //
54
$this->inlineScript()->appendFile($this->basePath('plugins/bootbox/bootbox.min.js'));
55
 
115 efrain 56
$status_active = \LeadersLinked\Model\CompanySelfEvaluationForm::STATUS_ACTIVE;
57
 
58
$language_es = \LeadersLinked\Model\CompanySelfEvaluationForm::LANGUAGE_SPANISH;
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 + '">';
136 geraldo 91
					s = s  + '<td class="text-left">LABEL_SECTION</td>';
118 steven 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';
136 geraldo 187
				s = s  + '<button class="btn btn-default btn-add-question" data-slug="' + section_slug + '" data-toggle="tooltip" title="LABEL_ADD LABEL_QUESTION"><i class="fa fa-plus" aria-hidden="true"></i> LABEL_ADD LABEL_QUESTION </button>&nbsp';
118 steven 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
 
122 steven 614
	var allowEdit   = $allowEdit;
615
	var allowDelete = $allowDelete;
118 steven 616
 
122 steven 617
	var tableForm = $('#gridTable').dataTable( {
618
			'processing': true,
619
			'serverSide': true,
620
			'searching': true,
621
			'order': [[ 0, 'asc' ]],
622
			'ordering':  true,
623
			'ordenable' : true,
624
			'responsive': true,
625
			'select' : false,
626
			'paging': true,
627
			'pagingType': 'simple_numbers',
628
			'ajax': {
629
				'url' : '$routeDatatable',
630
				'type' : 'get',
631
				'beforeSend': function (request) {
632
						NProgress.start();
633
				},
634
				'dataFilter': function(response) {
635
						var response = jQuery.parseJSON( response );
636
 
637
						var json                = {};
638
						json.recordsTotal       = 0;
639
						json.recordsFiltered    = 0;
640
						json.data               = [];
641
 
642
 
643
						if(response.success) {
644
								json.recordsTotal       = response.data.total;
645
								json.recordsFiltered    = response.data.total;
646
								json.data               = response.data.items;
647
						} else {
648
								$.fn.showError(response.data)
649
						}
650
 
651
						return JSON.stringify( json );
652
				}
653
			},
654
			'language' : {
655
					'sProcessing':     'LABEL_DATATABLE_SPROCESSING',
656
					'sLengthMenu':     'LABEL_DATATABLE_SLENGTHMENU',
657
					'sZeroRecords':    'LABEL_DATATABLE_SZERORECORDS',
658
					'sEmptyTable':     'LABEL_DATATABLE_SEMPTYTABLE',
659
					'sInfo':           'LABEL_DATATABLE_SINFO',
660
					'sInfoEmpty':      'LABEL_DATATABLE_SINFOEMPTY',
661
					'sInfoFiltered':   'LABEL_DATATABLE_SINFOFILTERED',
662
					'sInfoPostFix':    '',
663
					'sSearch':         'LABEL_DATATABLE_SSEARCH',
664
					'sUrl':            '',
665
					'sInfoThousands':  ',',
666
					'sLoadingRecords': 'LABEL_DATATABLE_SLOADINGRECORDS',
667
					'oPaginate': {
668
							'sFirst':    'LABEL_DATATABLE_SFIRST',
669
							'sLast':     'LABEL_DATATABLE_SLAST',
670
							'sNext':     'LABEL_DATATABLE_SNEXT',
671
							'sPrevious': 'LABEL_DATATABLE_SPREVIOUS'
672
					},
673
					'oAria': {
674
							'sSortAscending':  ': LABEL_DATATABLE_SSORTASCENDING',
675
							'sSortDescending': ':LABEL_DATATABLE_SSORTDESCENDING'
676
					},
677
			},
678
			'drawCallback': function( settings ) {
679
					NProgress.done();
680
					$('button.btn-delete').confirmation({
681
							rootSelector: 'button.btn-delete',
682
							title : 'LABEL_ARE_YOU_SURE',
683
							singleton : true,
684
							btnOkLabel: 'LABEL_YES',
685
							btnCancelLabel: 'LABEL_NO',
686
							onConfirm: function(value) {
687
									action = $(this).data('href');
688
									NProgress.start();
689
									$.ajax({
690
											'dataType'  : 'json',
691
											'accept'    : 'application/json',
692
											'method'    : 'post',
693
											'url'       :  action,
694
									}).done(function(response) {
695
											if(response['success']) {
696
													$.fn.showSuccess(response['data']);
697
													gridTable.api().ajax.reload(null, false);
698
											} else {
699
													$.fn.showError(response['data']);
700
											}
701
									}).fail(function( jqXHR, textStatus, errorThrown) {
702
											$.fn.showError(textStatus);
703
									}).always(function() {
704
											NProgress.done();
705
									});
706
							},
707
					});
708
			},
709
			'aoColumns': [
710
					{ 'mDataProp': 'name' },
711
				{ 'mDataProp': 'language'},
712
					{ 'mDataProp': 'status' },
713
					{ 'mDataProp': 'actions' },
714
		],
715
			'columnDefs': [
716
					{
717
							'targets': 0,
718
							'className' : 'text-vertical-middle',
719
					},
720
					{
721
							'targets': 1,
722
							'className' : 'text-vertical-middle',
723
					},
724
					{
725
							'targets': -2,
726
							'orderable': false,
727
							'className' : 'text-center',
728
								'render' : function ( data, type, row ) {
729
 
730
									checked = data == 'a' ? ' checked="checked" ' : '';
731
									return '<div class="checkbox checkbox-success">' +
732
											'<input class="styled" type="checkbox" ' + checked + ' disabled="disabled">' +
733
											'<label ></label></div>';
734
							}
735
					},
736
					{
737
							'targets': -1,
738
							'orderable': false,
739
							'render' : function ( data, type, row ) {
740
									s = '';
741
 
742
									if(allowEdit) {
123 steven 743
											s = s + '<button class="btn btn-primary btn-edit-form" data-href="' + data['link_edit']+ '" data-toggle="tooltip" title="LABEL_EDIT"><i class="fa fa-pencil"></i> LABEL_EDIT </button>&nbsp;';
122 steven 744
									}
745
									if(allowDelete) {
746
											s = s + '<button class="btn btn-danger btn-delete" data-href="' + data['link_delete']+ '" data-toggle="tooltip" title="LABEL_DELETE"><i class="fa fa-trash"></i> LABEL_DELETE </button>&nbsp;';
747
									}
748
									return s;
749
							}
750
					}
751
				],
118 steven 752
	});
753
 
139 geraldo 754
 
118 steven 755
	$('body').on('click', 'a.btn-delete-form',function(e) {
756
		e.preventDefault();
757
		form_id =  $(this).data('id')
758
 
759
		bootbox.confirm({
760
		    title: "LABEL_DELETE LABEL_FORM",
138 geraldo 761
		    message: "LABEL_QUESTION_DELETE",
118 steven 762
		    buttons: {
763
		        cancel: {
764
		            label: '<i class="fa fa-times"></i> LABEL_CANCEL'
765
		        },
766
		        confirm: {
767
		            label: '<i class="fa fa-check"></i> LABEL_ACCEPT'
768
		        }
769
		    },
770
		    callback: function (result) {
771
			    if(result) {
772
    		    	$.ajax({
773
    	                'dataType': 'json',
774
    	                'method': 'post',
775
    	                'url' :  'ajax.<?php echo $this->module; ?>.php?action=delete',
776
    	                'data' :{
777
    	                    'form-id' : form_id
778
    	                },
779
    	            }).done(function(response) {
780
 
781
    	                if(response['success']) {
782
    	                	$.fn.showSuccess(response['message']);
783
    	                	tableForm.fnDraw();
784
    	                } else {
139 geraldo 785
    	                	$.fn.showError(response['message'] || ERROR_UNKNOWN);
118 steven 786
    	                }
787
    	            }).fail(function( jqXHR, textStatus, errorThrown) {
788
    					$.fn.showError(textStatus);
789
    	            });
790
			    }
791
		    }
792
		});
793
 
794
 
795
    });
796
 
797
    $(document).on('click','[data-action="delete"]',function(){
798
 
799
    	bootbox.confirm({
800
		    title: "LABEL_DELETE LABEL_FORMS_2",
138 geraldo 801
		    message: "LABEL_QUESTION_DELETE",
118 steven 802
		    buttons: {
803
		        cancel: {
804
		            label: '<i class="fa fa-times"></i> LABEL_CANCEL'
805
		        },
806
		        confirm: {
807
		            label: '<i class="fa fa-check"></i> LABEL_ACCEPT'
808
		        }
809
		    },
810
		    callback: function (result) {
811
			    if(result) {
812
			    	var d = currentSelected();
813
    		    	$.ajax({
814
    	                'dataType': 'json',
815
    	                'method': 'post',
816
    	                'url' :  'ajax.<?php echo $this->module; ?>.php?action=delete-selected',
817
    	                'data' :{
818
    	                	 selected : d
819
    	                },
820
    	            }).done(function(response) {
821
 
822
    	                if(response['success']) {
823
    	                	$.fn.showSuccess(response['message']);
824
    	                	tableForm.fnDraw();
825
    	                } else {
139 geraldo 826
    	                	$.fn.showError(response['message'] || ERROR_UNKNOWN);
118 steven 827
    	                }
828
    	            }).fail(function( jqXHR, textStatus, errorThrown) {
829
    					$.fn.showError(textStatus);
830
    	            });
831
			    }
832
		    }
833
		});
834
 
835
    });
836
 
837
 
838
    $('body').on('switch-change', 'input[type="checkbox"].make-switch-form', function(e) {
839
		e.preventDefault();
840
		e.stopPropagation();
841
 
842
		form_id =  $(this).data('id')
843
		form_status = $(this).prop('checked') ? 'A' : 'D';
844
 
845
 
846
		$.ajax({
847
        	'dataType': 'json',
848
            'method': 'post',
849
            'url' :  'ajax.<?php echo $this->module; ?>.php?action=status',
850
            'data' :{
851
            	'form-id' : form_id,
852
            	'form-status' : form_status
853
            },
854
        }).done(function(response) {
855
	        if(response['success']) {
856
	        	$.fn.showSuccess(response['message']);
857
	       } else {
139 geraldo 858
    	       	$.fn.showError(response['message'] || ERROR_UNKNOWN);
118 steven 859
            }
860
         }).fail(function( jqXHR, textStatus, errorThrown) {
861
			$.fn.showError(textStatus);
862
        })
863
    });
864
 
124 steven 865
	$('body').on('click', 'button.btn-edit-form',function(e) {
118 steven 866
		e.preventDefault();
867
		form_id =  $(this).data('id')
125 steven 868
    var action = $(this).data('href');
118 steven 869
		$.ajax({
125 steven 870
			'dataType'  : 'json',
871
			'accept'    : 'application/json',
872
			'method'    : 'get',
873
			'url'       :  action,
118 steven 874
		}).done(function(response) {
875
			if(response['success']) {
876
					validatorForm.resetForm();
877
 
878
					$('#form-main #form-id' ).val(response['id']),
879
					$('#form-main #form-continue').val('0');
880
					$('#form-main #form-name' ).val(response['name']),
881
 
882
 
883
					instanceName = 'form-description';
884
					let editor = CKEDITOR.instances[instanceName ];
885
					editor.setData(response['description'], function() {
886
							editor.focus();
887
					});
888
 
889
 
890
					instanceName = 'form-text';
891
					CKEDITOR.instances[instanceName ].setData(response['text']);
892
 
893
					$( '#form-main #form-language' ).val(response['language']),
894
					$( '#form-main #form-status' ).val(response['status']);
895
 
896
					objFormGenerator.clear();
126 steven 897
					objFormGenerator.sections = response['sections'] || [];
118 steven 898
					objFormGenerator.render();
899
					$('#row-forms').hide();
900
					$('#row-edit').show();
901
 
902
					$('#form-main #form-name').focus();
903
 
904
				} else {
139 geraldo 905
					$.fn.showError(response['message'] || ERROR_UNKNOWN);
118 steven 906
				}
907
			}).fail(function( jqXHR, textStatus, errorThrown) {
908
				$.fn.showError(textStatus);
909
			});
910
    });
911
 
912
	 $(document).on('click','[data-type="select_all"]',function(){
913
 
914
	        if($('input[name="select_all"]:checked').val() == 'all'){
915
	            $('[data-type="select"]').prop('checked', true);
916
	            $('[data-action="delete"]').removeClass('hide');
917
	        }else{
918
	            $('[data-type="select"]').prop('checked', false);
919
	            $('[data-action="delete"]').addClass('hide');
920
	        }
921
	    });
922
 
923
	    function getLength(){
924
	        return $('[data-type="select"]').length;
925
	    }
926
 
927
	    function currentSelected(){
928
	        var selected = [];
929
	        $.each($("input[name='select[]']:checked"), function(){
930
	            selected.push($(this).val());
931
	        });
932
 
933
	        return selected;
934
	    }
935
 
936
	    $(document).on('change',"input[name='select[]']",function(){
937
	        var c = currentSelected();
938
	        var cc = getLength();
939
 
940
 
941
	        if(c.length == cc){
942
	            if($('[data-action="delete"]').hasClass('hide')){
943
	                $('[data-action="delete"]').removeClass('hide');
944
	            }
945
	            return true;
946
	        }else{
947
	            $('input[name="select_all"]').prop('checked', false);
948
	        }
949
 
950
	        if(c.length > 0){
951
	            if($('[data-action="delete"]').hasClass('hide')){
952
	                $('[data-action="delete"]').removeClass('hide');
953
	            }
954
	        }else{
955
	            if(!$('[data-action="delete"]').hasClass('hide')){
956
	                $('[data-action="delete"]').addClass('hide');
957
	            }
958
	        }
959
	    });
960
 
961
	    var form3 = $('#form_sample_3');
962
        var error3 = $('.alert-danger', form3);
963
        var success3 = $('.alert-success', form3);
964
 
965
	//IMPORTANT: update CKEDITOR textarea with actual content before submit
966
 	$( "#form-main" ).on('submit', function() {
967
		for(var instanceName in CKEDITOR.instances) {
968
			CKEDITOR.instances[instanceName].updateElement();
969
		}
970
	})
971
 
972
	var validatorForm = $( "#form-main" ).validate( {
973
        ignore: [],
974
        errorClass: 'help-block',
975
        errorElement: 'span',
976
		rules: {
977
			'form-name':  {
978
				required: true,
979
				minlength: 2,
980
				maxlength: 50
981
			},
982
			'form-description' : {
983
				required: true,
984
			},
985
			'form-text' : {
986
				required: true,
987
			},
988
			'form-language' : {
989
				required: true,
990
			},
991
			'forrm-status' : {
992
				required: true,
993
			},
994
		},
995
        highlight: function (element) {
996
            $(element).closest('.form-group').addClass('has-error');
997
        },
998
        unhighlight: function (element) {
999
            $(element).closest('.form-group').removeClass('has-error');
1000
        },
1001
        errorPlacement: function (error, element) {
1002
            if (element.attr("data-error-container")) {
1003
                error.appendTo(element.attr("data-error-container"));
1004
            } else {
1005
                error.insertAfter(element);
1006
            }
1007
        },
1008
        invalidHandler: function(form, validator) {
1009
            if (!validator.numberOfInvalids())
1010
                return;
1011
            $('html, body').animate({
1012
                scrollTop: $(validator.errorList[0].element).offset().top - 100
1013
            }, 1000);
1014
        },
1015
		submitHandler: function(form) {
1016
		    // do other things for a valid form
1017
		    //form.submit();
1018
 
1019
 
1020
		    var error = false;
1021
		    if(objFormGenerator.sections.length == 0) {
139 geraldo 1022
		    	$.fn.showError(ERROR_SECCTIONS);
118 steven 1023
		    	error = true;
1024
		    } else {
1025
 
1026
		    	for(i = 0; i < objFormGenerator.sections.length; i++)
1027
		    	{
1028
 
1029
		    		if(objFormGenerator.sections[i].questions.length == 0) {
139 geraldo 1030
		    			$.fn.showError( ERROR_QUESTION.str_replace('%s', objFormGenerator.sections[i].name ));
118 steven 1031
		    			break;
1032
		    		}
1033
 
1034
		    		var valueSection = parseInt(objFormGenerator.sections[i].value);
1035
		    		var totalValueQuestion = 0;
1036
 
1037
 
1038
		    		for(j = 0; j < objFormGenerator.sections[i].questions.length; j++)
1039
		    		{
1040
		    			valueQuestion = parseInt(objFormGenerator.sections[i].questions[j].value);
1041
		    			totalValueQuestion = totalValueQuestion + valueQuestion;
1042
		    			if(objFormGenerator.sections[i].questions[j].type == 'simple'
1043
			    			|| objFormGenerator.sections[i].questions[j].type == 'multiple'
1044
			    			|| objFormGenerator.sections[i].questions[j].type == 'rating-open' ) {
1045
 
1046
		    				var questionNumber = j + 1;
1047
		    				var numberCorrect = 0;
1048
 
1049
 
1050
		    				if(objFormGenerator.sections[i].questions[j].options.length == 0) {
139 geraldo 1051
 
1052
								$.fn.showError( ERROR_OPTIONS.str_replace('%s', objFormGenerator.sections[i].name ).str_replace('%n', questionNumber));
1053
								error = true;
118 steven 1054
									break;
1055
		    				}
1056
 
1057
		    				var totalOption = 0;
1058
		    				var maxOption = 0;
1059
		    				for(k = 0;  k < objFormGenerator.sections[i].questions[j].options.length; k++)
1060
		    				{
1061
		    					if(objFormGenerator.sections[i].questions[j].type == 'simple' || objFormGenerator.sections[i].questions[j].type == 'multiple' ) {
1062
    		    					if(objFormGenerator.sections[i].questions[j].options[k].correct == 1) {
1063
    		    						numberCorrect++;
1064
    		    					}
1065
		    					}
1066
 
1067
		    					if(objFormGenerator.sections[i].questions[j].type == 'multiple' && objFormGenerator.sections[i].questions[j].options[k].correct == 1) {
1068
		    						totalOption = totalOption + parseInt(objFormGenerator.sections[i].questions[j].options[k].value);
1069
			    				}
1070
 
1071
		    					if(objFormGenerator.sections[i].questions[j].type == 'rating-open') {
1072
		    						if(parseInt(objFormGenerator.sections[i].questions[j].options[k].value) > maxOption) {
1073
											maxOption = parseInt(objFormGenerator.sections[i].questions[j].options[k].value);
1074
					    			}
1075
			    				}
1076
 
1077
		    				}
1078
 
1079
		    				if(objFormGenerator.sections[i].questions[j].type == 'simple' || objFormGenerator.sections[i].questions[j].type == 'multiple' ) {
1080
 
1081
    		    				if(numberCorrect == 0) {
139 geraldo 1082
    		    					$.fn.showError( ERROR_OPTIONS_CORRECT.str_replace('%s', objFormGenerator.sections[i].name ).str_replace('%n', questionNumber));
118 steven 1083
    		    					error = true;
1084
    		    					break;
1085
    		    				}
1086
    		    				if(objFormGenerator.sections[i].questions[j].type == 'simple' && numberCorrect > 1) {
139 geraldo 1087
    		    					$.fn.showError( ERROR_OPTIONS_DUPLICATE_CORRECT.str_replace('%s', objFormGenerator.sections[i].name ).str_replace('%n', questionNumber));
118 steven 1088
    		    					error = true;
1089
    		    					break;
1090
    		    				}
1091
    		    				if(objFormGenerator.sections[i].questions[j].type == 'multiple' && numberCorrect == 1) {
139 geraldo 1092
    		    					$.fn.showError( ERROR_OPTIONS_ONE_CORRECT.str_replace('%s', objFormGenerator.sections[i].name ).str_replace('%n', questionNumber));
118 steven 1093
    		    					error = true;
1094
    		    					break;
1095
    		    				}
1096
		    				}
1097
 
1098
			 				if(objFormGenerator.sections[i].questions[j].type == 'multiple' && totalOption > valueQuestion ) {
139 geraldo 1099
 
1100
								$.fn.showError( ERROR_OPTIONS_SUM_VALUES.str_replace('%s', objFormGenerator.sections[i].name ).str_replace('%n', questionNumber));
118 steven 1101
		    					error = true;
1102
		    					break;
1103
			    			}
1104
 
1105
		    				if(objFormGenerator.sections[i].questions[j].type == 'rating-open' && maxOption > valueQuestion ) {
139 geraldo 1106
								$.fn.showError( ERROR_OPTIONS_MAX_OPTION.str_replace('%s', objFormGenerator.sections[i].name ).str_replace('%n', questionNumber));
118 steven 1107
		    					error = true;
1108
		    					break;
1109
			    			}
1110
						}
1111
 
1112
		    		}
1113
 
1114
		    		if(valueSection != totalValueQuestion) {
139 geraldo 1115
		    			$.fn.showError( ERROR_VALUE_SECTIONS.str_replace('%s', objFormGenerator.sections[i].name ));
118 steven 1116
		    			error = true;
1117
		    			break;
1118
					}
1119
				}
1120
 
1121
 
1122
 
1123
    			if(error) {
1124
    				return false;
1125
    			} else {
1126
 
1127
 
1128
    				var formId		= parseInt($( '#form-main #form-id' ).val());
1129
    				var formContinue = parseInt($( '#form-main #form-continue' ).val());
1130
 
1131
    				var data = {
1132
    	    			'form-id'	: formId,
1133
        				'form-name' : $( '#form-main #form-name' ).val(),
1134
        				'form-description' : $( '#form-main #form-description' ).val(),
1135
        				'form-text' : $( '#form-main #form-text' ).val(),
1136
        				'form-language' : $( '#form-main #form-language' ).val(),
1137
        				'form-status' : $( '#form-main #form-status' ).val(),
1138
        				'sections' : objFormGenerator.sections
1139
    				}
1140
 
127 steven 1141
					$.ajax({
1142
						'dataType': 'json',
1143
						'method': 'post',
1144
						'url' :  '$routeAdd',
1145
						'data' : data,
1146
					}).done(function(response) {
1147
						if(response['success']) {
1148
							$.fn.showSuccess(response['message']);
118 steven 1149
							if(formContinue == 1) {
1150
								$('#form-main #form-id').val(response['form-id']);
1151
								$('#form-main #form-continue').val(0);
1152
							} else {
1153
								$('#row-edit').hide();
127 steven 1154
								$('#row-forms').show();
118 steven 1155
							}
1156
							tableForm.fnDraw();
127 steven 1157
						} else {
139 geraldo 1158
							$.fn.showError(response['message'] || ERROR_UNKNOWN);
127 steven 1159
						}
1160
					}).fail(function( jqXHR, textStatus, errorThrown) {
118 steven 1161
						$.fn.showError(textStatus);
127 steven 1162
					});
1163
						return false;
118 steven 1164
    			}
1165
			}
1166
 
1167
 
1168
		}
1169
	});
1170
 
1171
	//IMPORTANT: update CKEDITOR textarea with actual content before submit
1172
 	$( "#form-section" ).on('submit', function() {
1173
		for(var instanceName in CKEDITOR.instances) {
1174
			CKEDITOR.instances[instanceName].updateElement();
1175
		}
1176
	})
1177
 
1178
	var validatorFormSection = $( "#form-section" ).validate( {
1179
        ignore: [],
1180
        errorClass: 'help-block',
1181
        errorElement: 'span',
1182
		rules: {
1183
			'section-name':  {
1184
				required: true,
1185
				minlength: 2,
1186
				maxlength: 50
1187
			},
1188
			'section-text' : {
1189
				required: false,
1190
			},
1191
			'section-value' : {
1192
				required: true,
1193
				number: true,
1194
				min: 1
1195
			},
1196
		},
1197
        highlight: function (element) {
1198
            $(element).closest('.form-group').addClass('has-error');
1199
        },
1200
        unhighlight: function (element) {
1201
            $(element).closest('.form-group').removeClass('has-error');
1202
        },
1203
        errorPlacement: function (error, element) {
1204
            if (element.attr("data-error-container")) {
1205
                error.appendTo(element.attr("data-error-container"));
1206
            } else {
1207
                error.insertAfter(element);
1208
            }
1209
        },
1210
        invalidHandler: function(form, validator) {
1211
            if (!validator.numberOfInvalids())
1212
                return;
1213
            $('html, body').animate({
1214
                scrollTop: $(validator.errorList[0].element).offset().top - 100
1215
            }, 1000);
1216
        },
1217
		submitHandler: function(form) {
1218
		    // do other things for a valid form
1219
		    //form.submit();
1220
 
1221
		    var slug = $('#form-section #section-slug').val();
1222
		    if(slug) {
1223
		    	objFormGenerator.editSection(
1224
		    		$('#form-section #section-slug').val(),
1225
			    	$('#form-section #section-name').val(),
1226
			    	$('#form-section #section-text').val(),
1227
			    	$('#form-section #section-value').val()
1228
			  	);
1229
		    } else {
1230
		    	objFormGenerator.addSection(
1231
		    		$('#form-section #section-name').val(),
1232
		    		$('#form-section #section-text').val(),
1233
		    		$('#form-section #section-value').val()
1234
		    	);
1235
		    }
1236
 
1237
 
1238
 
1239
			$('#modal-section').modal('hide');
1240
			return false;
1241
		  }
1242
	} );
1243
 
1244
	//IMPORTANT: update CKEDITOR textarea with actual content before submit
1245
 	$( "#form-question" ).on('submit', function() {
1246
		for(var instanceName in CKEDITOR.instances) {
1247
			CKEDITOR.instances[instanceName].updateElement();
1248
		}
1249
	})
1250
 
1251
 
1252
	var validatorFormQuestion = $( "#form-question" ).validate( {
1253
        ignore: [],
1254
        errorClass: 'help-block',
1255
        errorElement: 'span',
1256
		rules: {
1257
			'question-text' : {
1258
				required: true,
1259
			},
1260
			'question-value' : {
1261
				required: true,
1262
				number: true,
1263
				min: 1
1264
			},
1265
			'question-type':  {
1266
				required: true,
1267
			},
1268
			'question-max-length' : {
1269
				required: true,
1270
				digits: true,
1271
				min: 0
1272
			},
1273
			'question-range' : {
1274
				required: true,
1275
				number: true,
1276
				min: 1
1277
			},
1278
		},
1279
        highlight: function (element) {
1280
            $(element).closest('.form-group').addClass('has-error');
1281
        },
1282
        unhighlight: function (element) {
1283
            $(element).closest('.form-group').removeClass('has-error');
1284
        },
1285
        errorPlacement: function (error, element) {
1286
            if (element.attr("data-error-container")) {
1287
                error.appendTo(element.attr("data-error-container"));
1288
            } else {
1289
                error.insertAfter(element);
1290
            }
1291
        },
1292
        invalidHandler: function(form, validator) {
1293
 
1294
 
1295
            if (!validator.numberOfInvalids())
1296
                return;
1297
            $('html, body').animate({
1298
                scrollTop: $(validator.errorList[0].element).offset().top - 100
1299
            }, 1000);
1300
        },
1301
		submitHandler: function(form) {
1302
 
139 geraldo 1303
 
1304
		    if($('#form-question #question-slug').val()) {
118 steven 1305
 
139 geraldo 1306
 
118 steven 1307
		    	objFormGenerator.editQuestion(
1308
		    		$('#form-question #question-section').val(),
1309
		    		$('#form-question #question-slug').val(),
1310
		    		$('#form-question #question-text').val(),
1311
		    		$('#form-question #question-value').val(),
1312
			    	$('#form-question #question-type').val(),
1313
			    	$('#form-question #question-max-length').val(),
1314
	    			$('#form-question #question-multiline').val(),
1315
	    			$('#form-question #question-range').val()
1316
			  	);
1317
		    } else {
1318
 
1319
		    	objFormGenerator.addQuestion(
1320
			    	$('#form-question #question-section').val(),
1321
			    	$('#form-question #question-text').val(),
1322
			    	$('#form-question #question-value').val(),
1323
				    $('#form-question #question-type').val(),
1324
				    $('#form-question #question-max-length').val(),
1325
		    		$('#form-question #question-multiline').val(),
1326
		    		$('#form-question #question-range').val()
1327
		    	);
1328
		    }
1329
 
1330
			$('#modal-question').modal('hide');
1331
			return false;
1332
		  }
1333
	} );
1334
 
1335
	//IMPORTANT: update CKEDITOR textarea with actual content before submit
1336
 	$( "#form-option" ).on('submit', function() {
1337
		for(var instanceName in CKEDITOR.instances) {
1338
			CKEDITOR.instances[instanceName].updateElement();
1339
		}
1340
	})
1341
 
1342
	var validatorFormOption = $( "#form-option" ).validate( {
1343
        ignore: [],
1344
        errorClass: 'help-block',
1345
        errorElement: 'span',
1346
		rules: {
1347
			'option-text' : {
1348
				required: true,
1349
			},
1350
        	'option-value' : {
1351
				required: true,
1352
				number: true,
1353
				min: 1
1354
        	}
1355
		},
1356
        highlight: function (element) {
1357
            $(element).closest('.form-group').addClass('has-error');
1358
        },
1359
        unhighlight: function (element) {
1360
            $(element).closest('.form-group').removeClass('has-error');
1361
        },
1362
        errorPlacement: function (error, element) {
1363
            if (element.attr("data-error-container")) {
1364
                error.appendTo(element.attr("data-error-container"));
1365
            } else {
1366
                error.insertAfter(element);
1367
            }
1368
        },
1369
        invalidHandler: function(form, validator) {
1370
            if (!validator.numberOfInvalids())
1371
                return;
1372
            $('html, body').animate({
1373
                scrollTop: $(validator.errorList[0].element).offset().top - 100
1374
            }, 1000);
1375
        },
1376
		submitHandler: function(form) {
1377
 
1378
 
1379
		    if($('#form-option #option-slug').val()) {
1380
		    	objFormGenerator.editOption(
1381
		    		$('#form-option #option-section').val(),
1382
		    		$('#form-option #option-question').val(),
1383
		    		$('#form-option #option-slug').val(),
1384
		    		$('#form-option #option-text').val(),
1385
		    		$('#form-option #option-correct').val(),
1386
		    		$('#form-option #option-value').val()
1387
			  	);
1388
		    } else {
1389
		    	objFormGenerator.addOption(
1390
			    	$('#form-option #option-section').val(),
1391
			    	$('#form-option #option-question').val(),
1392
			    	$('#form-option #option-text').val(),
1393
			    	$('#form-option #option-correct').val(),
1394
			    	$('#form-option #option-value').val()
1395
		    	);
1396
		    }
1397
 
1398
			$('#modal-option').modal('hide');
1399
			return false;
1400
		  }
1401
	} );
1402
 
1403
	$('body').on('click', 'button[id="btn-add-section"]', function(e){
1404
		e.preventDefault();
1405
 
1406
		validatorFormSection.resetForm();
1407
		$('#form-section #section-slug').val('');
1408
		$('#form-section #section-name').val('');
1409
 
1410
		instanceName = 'section-text';
1411
		let editor = CKEDITOR.instances[instanceName ];
1412
		editor.setData( '', function() {
1413
		    editor.focus();
1414
		});
1415
 
1416
 
1417
		$('#form-section #section-value').val('0');
136 geraldo 1418
		$('#modal-section h4[class="modal-title"]').html('LABEL_ADD LABEL_SECTION');
118 steven 1419
		$('#modal-section').modal('show');
1420
	});
1421
 
1422
	$('body').on('click', 'button.btn-edit-section', function(e){
1423
	    e.preventDefault();
1424
 
1425
	    var slug = $(this).data('slug');
1426
	    var section;
1427
	    var showForm = false;
1428
 
1429
	    for(i = 0; i < objFormGenerator.sections.length; i++) {
1430
	        section = objFormGenerator.sections[i];
1431
 
1432
	    	if(slug == section.slug) {
1433
 
1434
				validatorFormSection.resetForm();
1435
	    		$('#form-section #section-slug').val(section.slug);
1436
	    		$('#form-section #section-name').val(section.name);
1437
 
1438
	    		instanceName = 'section-text';
1439
	    		let editor = CKEDITOR.instances[instanceName ];
1440
	    		editor.setData( section.text, function() {
1441
	    		    editor.focus();
1442
	    		});
1443
 
1444
				$('#form-section #section-value').val(section.value);
1445
 
1446
				showForm = true;
1447
				break;
1448
	    	}
1449
	    }
1450
 
1451
	    if(showForm) {
136 geraldo 1452
	    	$('#modal-section h4[class="modal-title"]').html('LABEL_EDIT LABEL_SECTION');
118 steven 1453
			$('#modal-section').modal('show');
1454
	    }
1455
 
1456
	});
1457
 
1458
	$('body').on('click', 'button.btn-delete-section', function(e){
1459
		e.preventDefault();
1460
		var slug = $(this).data('slug');
1461
 
1462
		bootbox.confirm({
138 geraldo 1463
		    title: "LABEL_DELETE LABEL_SECTION",
1464
		    message: "LABEL_QUESTION_DELETE",
118 steven 1465
		    buttons: {
1466
		        cancel: {
1467
		            label: '<i class="fa fa-times"></i> LABEL_CANCEL'
1468
		        },
1469
		        confirm: {
1470
		            label: '<i class="fa fa-check"></i> LABEL_ACCEPT'
1471
		        }
1472
		    },
1473
		    callback: function (result) {
1474
		    	if (result) {
1475
					objFormGenerator.deleteSection(slug);
1476
				}
1477
		    }
1478
		});
1479
 
1480
 
1481
 
1482
	});
1483
 
1484
 
1485
	$('body').on('click', 'button.btn-add-question', function(e){
1486
		e.preventDefault();
1487
 
1488
		validatorFormQuestion.resetForm();
1489
		var slug = $(this).data('slug');
1490
 
1491
		$('#form-question #question-section').val(slug);
1492
		$('#form-question #question-slug').val('');
1493
 
1494
		instanceName = 'question-text';
1495
		let editor = CKEDITOR.instances[instanceName ];
1496
		editor.setData( '', function() {
1497
		    editor.focus();
1498
		});
1499
 
1500
 
1501
		$('#form-question #question-value').val('0');
1502
		$('#form-question #question-type').val($('#form-question #question-type option:first').val());
1503
 
1504
		$('#form-question #question-max-length').val('0');
1505
		$('#form-question #question-max-length').parent().show();
1506
 
1507
		$('#form-question #question-multiline').val('0');
1508
		$('#form-question #question-multiline').parent().show();
1509
 
1510
		$('#form-question #question-range').val('10');
1511
		$('#form-question #question-range').parent().hide();
1512
 
136 geraldo 1513
		$('#modal-question h4[class="modal-title"]').html('LABEL_ADD LABEL_QUESTION');
118 steven 1514
		$('#modal-question').modal('show');
1515
 
1516
	});
1517
 
1518
 
1519
 
1520
	$('body').on('click', 'button.btn-edit-question', function(e){
1521
	    e.preventDefault();
1522
 
1523
	    var slug_section	= $(this).data('section');
1524
	    var slug 			= $(this).data('slug');
1525
	    var showForm 		= false;
1526
 
1527
	    for(i = 0; i < objFormGenerator.sections.length; i++) {
1528
 
1529
	    	if(slug_section == objFormGenerator.sections[i].slug) {
1530
 
1531
	    		for(j = 0; j < objFormGenerator.sections[i].questions.length; j++) {
1532
 
1533
	    			if(slug == objFormGenerator.sections[i].questions[j].slug) {
1534
	    				validatorFormQuestion.resetForm();
1535
 
1536
	    				$('#form-question #question-section').val(objFormGenerator.sections[i].slug);
1537
	    				$('#form-question #question-slug').val(objFormGenerator.sections[i].questions[j].slug);
1538
 
1539
	    	    		instanceName = 'question-text';
1540
	    	    		let editor = CKEDITOR.instances[instanceName ];
1541
	    	    		editor.setData( objFormGenerator.sections[i].questions[j].text, function() {
1542
	    	    		    editor.focus();
1543
	    	    		});
1544
 
1545
 
1546
	        			$('#form-question #question-value').val(objFormGenerator.sections[i].questions[j].value);
1547
	        			$('#form-question #question-type').val(objFormGenerator.sections[i].questions[j].type);
1548
 
1549
 
1550
 
1551
	        			if(objFormGenerator.sections[i].questions[j].type == 'open') {
1552
		        			$('#form-question #question-max-length').val(objFormGenerator.sections[i].questions[j].maxlength);
1553
		        			$('#form-question #question-max-length').parent().show();
1554
 
1555
		        			$('#form-question #question-multiline').val(objFormGenerator.sections[i].questions[j].multiline);
1556
							$('#form-question #question-multiline').parent().show();
1557
	        			} else {
1558
		        			$('#form-question #question-max-length').val('0');
1559
		        			$('#form-question #question-max-length').parent().hide();
1560
 
1561
		        			$('#form-question #question-multiline').val('0');
1562
							$('#form-question #question-multiline').parent().hide();
1563
	        			}
1564
 
1565
	        			if(objFormGenerator.sections[i].questions[j].type == 'rating-range') {
1566
	            			$('#form-question #question-range').val(objFormGenerator.sections[i].questions[j].range);
1567
		        			$('#form-question #question-range').parent().show();
1568
 
1569
	        			} else {
1570
	            			$('#form-question #question-range').val('10');
1571
		        			$('#form-question #question-range').parent().hide();
1572
		        		}
1573
 
1574
    					showForm = true;
1575
    					break;
1576
 
1577
	    			}
1578
 
1579
	    		}
1580
 
1581
	    		break;
1582
	    	}
1583
	    }
1584
 
1585
	    if(showForm) {
1586
	    	$('#modal-question h4[class="modal-title"]').html('LABEL_EDIT LABEL_QUESTION');
1587
				$('#modal-question').modal('show');
1588
	    }
1589
 
1590
	});
1591
 
1592
 
1593
 
1594
 
1595
	$('body').on('click', 'button.btn-delete-question', function(e){
1596
		e.preventDefault();
1597
 
1598
		var slug_section	= $(this).data('section');
1599
		var slug 			= $(this).data('slug');
1600
 
1601
		bootbox.confirm({
138 geraldo 1602
			title: "LABEL_DELETE LABEL_QUESTION",
1603
			message: "LABEL_QUESTION_DELETE",
118 steven 1604
			buttons: {
1605
				cancel: {
1606
   					label: '<i class="fa fa-times"></i> LABEL_CANCEL'
1607
    			},
1608
			    confirm: {
1609
			    	label: '<i class="fa fa-check"></i> LABEL_ACCEPT'
1610
			    }
1611
			},
1612
			callback: function (result) {
1613
				if (result) {
1614
					objFormGenerator.deleteQuestion(slug_section, slug);
1615
				}
1616
			}
1617
		});
1618
	});
1619
 
1620
 
1621
	$('body').on('click', 'button.btn-add-option', function(e){
1622
		e.preventDefault();
1623
	    var slug_section	= $(this).data('section');
1624
		var slug_question 	= $(this).data('slug');
1625
		var showForm 		= false;
1626
 
1627
	    for(i = 0; i < objFormGenerator.sections.length; i++) {
1628
	    	if(slug_section == objFormGenerator.sections[i].slug) {
1629
	    		for(j = 0; j < objFormGenerator.sections[i].questions.length; j++) {
1630
	    			if(slug_question == objFormGenerator.sections[i].questions[j].slug) {
1631
 
1632
                		validatorFormOption.resetForm();
1633
                		$('#form-option #option-section').val(slug_section);
1634
                		$('#form-option #option-question').val(slug_question);
1635
                		$('#form-option #option-slug').val('');
1636
 
1637
                		instanceName = 'option-text';
1638
	    	    		let editor = CKEDITOR.instances[instanceName ];
1639
	    	    		editor.setData( '', function() {
1640
	    	    		    editor.focus();
1641
	    	    		});
1642
 
1643
 
1644
	    	    		$('#form-option #option-correct').val('0');
1645
                		if(objFormGenerator.sections[i].questions[j].type == 'rating-open') {
1646
                    		$('#form-option #option-correct').parent().hide();
1647
                        } else {
1648
                    		$('#form-option #option-correct').parent().show();
1649
                        }
1650
 
1651
                		if(objFormGenerator.sections[i].questions[j].type == 'multiple' || objFormGenerator.sections[i].questions[j].type == 'rating-open') {
1652
                			$('#form-option #option-value').val('0');
1653
                			$('#form-option #option-value').parent().show();
1654
                		} else {
1655
                			$('#form-option #option-value').val('1');
1656
                			$('#form-option #option-value').parent().hide();
1657
 
1658
                       	}
1659
                		showForm = true;
1660
	    			}
1661
	    		}
1662
	    	}
1663
	    }
1664
 
1665
		if(showForm) {
139 geraldo 1666
    		$('#modal-option h4[class="modal-title"]').html('LABEL_ADD LABEL_OPTION');
118 steven 1667
    		$('#modal-option').modal('show');
1668
		}
1669
 
1670
	});
1671
 
1672
 
1673
 
1674
	$('body').on('click', 'button.btn-edit-option', function(e){
1675
	    e.preventDefault();
1676
 
1677
	    var slug_section	= $(this).data('section');
1678
	    var slug_question	= $(this).data('question');
1679
	    var slug 			= $(this).data('slug');
1680
	    var showForm 		= false;
1681
 
1682
	    for(i = 0; i < objFormGenerator.sections.length; i++) {
1683
	    	if(slug_section == objFormGenerator.sections[i].slug) {
1684
	    		for(j = 0; j < objFormGenerator.sections[i].questions.length; j++) {
1685
	    			if(slug_question == objFormGenerator.sections[i].questions[j].slug) {
1686
	    				for(k = 0; k < objFormGenerator.sections[i].questions[j].options.length; k++) {
1687
	    					if(slug == objFormGenerator.sections[i].questions[j].options[k].slug) {
1688
	    						validatorFormOption.resetForm();
1689
	    						$('#form-option #option-section').val(objFormGenerator.sections[i].slug);
1690
	    						$('#form-option #option-question').val(objFormGenerator.sections[i].questions[j].slug);
1691
    		    				$('#form-option #option-slug').val(objFormGenerator.sections[i].questions[j].options[k].slug);
1692
 
1693
    		    				instanceName = 'option-text';
1694
    		    	    		let editor = CKEDITOR.instances[instanceName ];
1695
    		    	    		editor.setData( objFormGenerator.sections[i].questions[j].options[k].text, function() {
1696
    		    	    		    editor.focus();
1697
    		    	    		});
1698
 
1699
 
1700
    		    				$('#form-option #option-correct').val(objFormGenerator.sections[i].questions[j].options[k].correct);
1701
    		    				if(objFormGenerator.sections[i].questions[j].type == 'multiple' || objFormGenerator.sections[i].questions[j].type == 'simple') {
1702
    		    					$('#form-option #option-correct').parent().show();
1703
    		    				} else {
1704
    		    					$('#form-option #option-correct').parent().hide();
1705
            		    		}
1706
 
1707
    		    				$('#form-option #option-value').val(objFormGenerator.sections[i].questions[j].options[k].value);
1708
 
1709
								if(objFormGenerator.sections[i].questions[j].type == 'multiple' || objFormGenerator.sections[i].questions[j].type == 'rating-open') {
1710
    		    					$('#form-option #option-value').parent().show();
1711
								} else {
1712
									$('#form-option #option-value').parent().hide();
1713
								}
1714
 
1715
 
1716
 
1717
    		    				showForm = true;
1718
    	    					break;
1719
	    					}
1720
	    				}
1721
	    			}
1722
	    			if(showForm) {
1723
		    			break;
1724
		    		}
1725
	    		}
1726
	    	}
1727
			if(showForm) {
1728
    			break;
1729
    		}
1730
	    }
1731
 
1732
	    if(showForm) {
1733
	    	$('#modal-option h4[class="modal-title"]').html('LABEL_EDIT LABEL_OPTION');
1734
				$('#modal-option').modal('show');
1735
	    }
1736
	});
1737
 
1738
	$('body').on('click', 'button.btn-delete-option', function(e){
1739
		e.preventDefault();
1740
		var slug_section	= $(this).data('section');
1741
		var slug_question	= $(this).data('question');
1742
		    var slug 			= $(this).data('slug');
1743
 
1744
 
1745
		bootbox.confirm({
138 geraldo 1746
			title: "LABEL_DELETE LABEL_OPTION",
1747
			message: "LABEL_QUESTION_DELETE",
118 steven 1748
			buttons: {
1749
				cancel: {
1750
	   				label: '<i class="fa fa-times"></i> LABEL_CANCEL'
1751
	    		},
1752
				confirm: {
1753
					label: '<i class="fa fa-check"></i> LABEL_ACCEPT'
1754
				}
1755
			},
1756
			callback: function (result) {
1757
				if (result) {
1758
					objFormGenerator.deleteOption(slug_section, slug_question, slug);
1759
				}
1760
			}
1761
		});
1762
	})
1763
 
1764
	$('#form-section #section-value').inputNumberFormat({'decimal' : 2});
1765
 
1766
	$('#form-question #question-value').inputNumberFormat({'decimal' : 2});
1767
	$('#form-question #question-max-length').inputNumberFormat({'decimal' : 0});
1768
 
1769
	$('#form-option #option-value').inputNumberFormat({'decimal' : 2});
1770
 
1771
	$('#form-question #question-type').change(function(e) {
1772
		e.preventDefault();
1773
 
1774
		if($('#form-question #question-type').val() == 'open') {
1775
			$('#form-question #question-max-length').parent().show();
1776
			$('#form-question #question-multiline').parent().show();
1777
 
1778
		} else {
1779
			$('#form-question #question-max-length').val('0');
1780
			$('#form-question #question-max-length').parent().hide();
1781
 
1782
			$('#form-question #question-multiline').val('0');
1783
			$('#form-question #question-multiline').parent().hide();
1784
		}
1785
 
1786
		$('#form-question #question-range').val('10');
1787
		if($('#form-question #question-type').val() == 'rating-range') {
1788
			$('#form-question #question-range').parent().show();
1789
		} else {
1790
			$('#form-question #question-range').parent().hide();
1791
		}
1792
 
1793
 
1794
 
1795
	});
1796
 
1797
	$('button.btn-add-form').click(function(e) {
1798
		e.preventDefault();
1799
 
1800
		objFormGenerator.clear();
1801
		objFormGenerator.render();
1802
		validatorForm.resetForm();
1803
 
1804
		$('#form-main #form-id').val('0');
1805
		$('#form-main #form-continue').val('0');
1806
		$('#form-main #form-name').val('');
1807
 
1808
		instanceName = 'form-text';
1809
		let editor = CKEDITOR.instances[instanceName ];
1810
		editor.setData('', function() {
1811
		    editor.focus();
1812
		});
1813
 
1814
 
1815
		instanceName = 'form-description';
1816
		CKEDITOR.instances[instanceName ].setData('');
1817
 
1818
		$( '#form-main #form-language' ).val('EN'),
1819
		$( '#form-main #form-status' ).val('D');
1820
 
1821
		$('#row-forms').hide();
1822
		$('#row-edit').show();
1823
		$('#form-main #form-name').focus();
1824
 
1825
        /*$('html, body').animate({
1826
            scrollTop: $('#form-main #form-name').offset().top - 100
1827
        }, 1000);*/
1828
	});
1829
 
1830
	$('button.btn-edit-cancel').click(function(e) {
1831
		e.preventDefault();
1832
		$('#row-edit').hide();
1833
		$('#row-forms').show();
1834
 
1835
	});
1836
 
1837
 
1838
	$('button.btn-form-save-continue').click(function(e) {
1839
		e.preventDefault();
1840
		$('#form-main #form-continue').val('1')
1841
		$('#form-main').submit();
1842
	});
1843
 
1844
	$('button.btn-form-save-close').click(function(e) {
1845
		e.preventDefault();
1846
		$('#form-main #form-continue').val('0')
1847
		$('#form-main').submit();
1848
 
1849
	});
1850
 
1851
	$('#modal-section, #modal-question, #modal-option').modal({
1852
			backdrop: 'static',
1853
			keyboard: false,
1854
			show: false
1855
		});
1856
	});
1857
JS;
115 efrain 1858
$this->inlineScript()->captureEnd();
1859
?>
118 steven 1860
 
121 steven 1861
<style type="text/css">
135 geraldo 1862
    tbody input[type="checkbox"]{
1863
        margin-left: 14px;
1864
    }
1865
    .panel-heading .accordion-toggle:after {
1866
        /* symbol for "opening" panels */
1867
        display: inline-block;
1868
        font: normal normal normal 14px/1 FontAwesome;
1869
        font-size: inherit;
1870
        content: "\f077" ;
1871
        float: right;        /* adjust as needed */
1872
        color: grey;         /* adjust as needed */
1873
        text-rendering: auto;
1874
        -webkit-font-smoothing: antialiased;
1875
    }
1876
    .panel-heading .accordion-toggle.collapsed:after {
1877
        /* symbol for "collapsed" panels */
1878
        content: "\f078";    /* adjust as needed, taken from bootstrap.css */
1879
    }
121 steven 1880
</style>
135 geraldo 1881
 
115 efrain 1882
<!-- Content Header (Page header) -->
1883
<section class="content-header">
135 geraldo 1884
    <div class="container-fluid">
1885
        <div class="row mb-2">
1886
            <div class="col-sm-12">
1887
                <h1>LABEL_SELF_EVALUATION_FORMS</h1>
1888
            </div>
1889
        </div>
1890
    </div><!-- /.container-fluid -->
115 efrain 1891
</section>
1892
 
1893
<section class="content">
135 geraldo 1894
    <div class="container-fluid" id="row-forms">
1895
        <div class="row">
1896
            <div class="col-12">
1897
                <div class="card">
1898
                    <div class="card-body">
1899
                        <table id="gridTable" class="table   table-hover">
1900
                            <thead>
1901
                                <tr>
1902
                                    <th>LABEL_NAME</th>
1903
                                    <th>LABEL_LANGUAGE</th>
1904
                                    <th>LABEL_ACTIVE</th>
1905
                                    <th>LABEL_ACTIONS</th>
1906
                                </tr>
1907
                            </thead>
1908
                            <tbody>
1909
                            </tbody>
1910
                        </table>
1911
                    </div>
1912
                    <div class="card-footer clearfix">
1913
                        <div style="float:right;">
1914
                            <button type="button" class="btn btn-info btn-refresh"><i class="fa fa-refresh"></i> LABEL_REFRESH </button>
1915
                            <?php if ($allowAdd) : ?>
1916
                                <button type="button" class="btn btn-primary btn-add-form"><i class="fa fa-plus"></i> LABEL_ADD </button>
1917
                            <?php endif; ?>
1918
                        </div>
1919
                    </div>
1920
                </div>
1921
            </div>
1922
        </div>
1923
    </div>
1924
    <!-- Row Edit -->
1925
    <div class="row" id="row-edit" style="display: none">
1926
        <div class="col-xs-12 col-md-12">
1927
            <form action="#" name="form-main" id="form-main">
1928
                <input type="hidden" name="form-id" id="form-id" value="0" />
1929
                <input type="hidden" name="form-continue" id="form-continue" value="0" />
1930
                <div class="form-group">
1931
                    <label for="form-name">LABEL_FIRST_NAME</label>
1932
                    <input type="text" name="form-name" id="form-name" class="form-control" maxlength="50" />
1933
                </div>
1934
                <div class="form-group">
1935
                    <label for="form-description">LABEL_DESCRIPTION</label>
1936
                    <!--  ckeditor -->
1937
                    <textarea  name="form-description" id="form-description" rows="5" class="ckeditor form-control"></textarea>
1938
                </div>
1939
                <div class="form-group">
1940
                    <label for="form-text">LABEL_TEXT</label>
1941
                    <!--  ckeditor -->
1942
                    <textarea  name="form-text" id="form-text" rows="5" class="ckeditor form-control"></textarea>
1943
                </div>
1944
                <div class="form-group">
1945
                    <label for="form-language">LABEL_LANGUAGES</label>
1946
                    <select name="form-language" id="form-language" class="form-control">
1947
                        <option value="EN">LABEL_ENGLISH</option>
1948
                        <option value="SP">LABEL_SPANISH</option>
1949
                    </select>
1950
                </div>
1951
                <div class="form-group">
1952
                    <label for="form-status">LABEL_STATUS</label>
1953
                    <select name="form-status" id="form-status" class="form-control">
1954
                        <option value="D">LABEL_INACTIVE</option>
1955
                        <option value="A">LABEL_ACTIVE</option>
1956
                    </select>
1957
                </div>
1958
                <br/>
1959
                <div class="row">
1960
                    <div class="col-xs-12 col-md-12 text-right">
1961
                        <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>
1962
                    </div>
1963
                </div>
1964
                <br />
1965
                <div class="row">
1966
                    <div class="col-xs-12 col-md-12">
1967
                        <div class="panel-group" id="accordion"></div>
1968
                    </div>
1969
                </div>
115 efrain 1970
 
1971
 
135 geraldo 1972
                <div class="form-group">
1973
                    <button type="submit" form="form-main" class="btn btn-info btn-form-save-continue">LABEL_SAVE & LABEL_CONTINUE</button>
1974
                    <button type="button" class="btn btn-primary btn-form-save-close">LABEL_SAVE & LABEL_CLOSE</button>
1975
                    <button type="button" class="btn btn-secondary btn-edit-cancel">LABEL_CANCEL</button>
1976
                </div>
1977
            </form>
1978
        </div>
1979
    </div>
1980
    <!-- End Row Edit -->
1981
    <!-- Modals -->
1982
    <!-- Section Modal -->
1983
    <div  id="modal-section" class="modal" tabindex="-1" role="dialog">
139 geraldo 1984
        <div class="modal-dialog modal-lg" role="document">
135 geraldo 1985
            <form action="#" name="form-section" id="form-section">
1986
                <input type="hidden" name="section-slug" id="section-slug" value="" />
1987
                <div class="modal-content">
1988
                    <div class="modal-header">
139 geraldo 1989
                        <h4 class="modal-title">LABEL_ADD LABEL_SECTION</h4>
1990
                        <button type="button" class="close" data-dismiss="modal" aria-label="Close">
136 geraldo 1991
                            <span aria-hidden="true">&times;</span>
1992
                        </button>
135 geraldo 1993
                    </div>
1994
                    <div class="modal-body">
1995
                        <div class="form-group">
1996
                            <label for="section-name">LABEL_FIRST_NAME</label>
1997
                            <input type="text" name="section-name" id="section-name" class="form-control" maxlength="50" value="" />
1998
                        </div>
1999
                        <div class="form-group">
2000
                            <label for="section-text">LABEL_TEXT</label>
2001
                            <!--  ckeditor -->
2002
                            <textarea  name="section-text" id="section-text" rows="5" class="ckeditor form-control"></textarea>
2003
                        </div>
2004
                        <div class="form-group">
2005
                            <label for="section-value">LABEL_VALUE</label>
2006
                            <input type="text" name="section-value" id="section-value"  class="form-control" value="0" />
2007
                        </div>
2008
                    </div>
2009
                    <div class="modal-footer">
2010
                        <button type="submit" class="btn btn-primary">LABEL_SAVE</button>
2011
                        <button type="button" class="btn btn-secondary" data-dismiss="modal">LABEL_CLOSE</button>
2012
                    </div>
2013
                </div>
2014
            </form>
2015
        </div>
2016
    </div>
2017
    <!-- End Modal Section -->
2018
    <!-- Question Modal -->
2019
    <div  id="modal-question" class="modal" tabindex="-1" role="dialog">
139 geraldo 2020
        <div class="modal-dialog modal-lg" role="document">
135 geraldo 2021
            <form action="#" name="form-question" id="form-question">
2022
                <input type="hidden" name="question-section" id="question-section" />
2023
                <input type="hidden" name="question-slug" id="question-slug" />
2024
                <div class="modal-content">
2025
                    <div class="modal-header">
2026
                        <h4 class="modal-title">LABEL_ADD LABEL_QUESTION</h4>
2027
                        <button type="button" class="close" data-dismiss="modal" aria-label="Close">
2028
                            <span aria-hidden="true">&times;</span>
2029
                        </button>
2030
                    </div>
2031
                    <div class="modal-body">
2032
                        <div class="form-group">
2033
                            <label for="question-text">LABEL_TEXT</label>
2034
                            <!--  ckeditor -->
2035
                            <textarea  name="question-text" id="question-text" rows="5" class="ckeditor form-control"></textarea>
2036
                        </div>
2037
                        <div class="form-group">
2038
                            <label for="question-value">LABEL_VALUE</label>
2039
                            <input type="text" name="question-value" id="question-value"  class="form-control" />
2040
                        </div>
2041
                        <div class="form-group">
2042
                            <label for="question-type">LABEL_TYPE</label>
2043
                            <select name="question-type" id="question-type" class="form-control">
2044
                                <option value="open">LABEL_OPEN</option>
2045
                                <option value="simple">Simple</option>
2046
                                <option value="multiple">Multiple</option>
2047
                                <option value="rating-open">LABEL_RATING_OPEN</option>
2048
                                <option value="rating-range">LABEL_RATING_RANGE</option>
2049
                            </select>
2050
                        </div>
2051
                        <div class="form-group">
2052
                            <label for="question-max-length">LABEL_MAXLENGTH</label>
2053
                            <input type="text" name="question-max-length" id="question-max-length"  class="form-control" />
2054
                        </div>
2055
                        <div class="form-group">
2056
                            <label for="question-multiline">LABEL_MULTI_LINE</label>
2057
                            <select name="question-multiline" id="question-multiline" class="form-control">
2058
                                <option value="1">LABEL_YES</option>
2059
                                <option value="0">No</option>
2060
                            </select>
2061
                        </div>
2062
                        <div class="form-group">
2063
                            <label for="question-range">LABEL_RANGE</label>
2064
                            <select name="question-range" id="question-range" class="form-control">
2065
                                <option value="10">1-10</option>
2066
                                <option value="6">1-6</option>
2067
                                <option value="5">1-5</option>
2068
                            </select>
2069
                        </div>
2070
                    </div>
2071
                    <div class="modal-footer">
2072
                        <button type="submit" class="btn btn-primary">LABEL_SAVE</button>
2073
                        <button type="button" class="btn btn-secondary" data-dismiss="modal">LABEL_CLOSE</button>
2074
                    </div>
2075
                </div>
2076
            </form>
2077
        </div>
2078
    </div>
2079
    <!-- End Modal Question -->
2080
    <!-- MOdal Options -->
2081
    <div  id="modal-option" class="modal" tabindex="-1" role="dialog">
139 geraldo 2082
        <div class="modal-dialog modal-lg" role="document">
135 geraldo 2083
            <form action="#" name="form-option" id="form-option">
2084
                <input type="hidden" name="option-section" id="option-section" value="" />
2085
                <input type="hidden" name="option-question" id="option-question" value="" />
2086
                <input type="hidden" name="option-slug" id="option-slug" value="" />
2087
                <div class="modal-content">
2088
                    <div class="modal-header">
2089
                        <h4 class="modal-title">LABEL_OPTION</h4>
2090
                        <button type="button" class="close" data-dismiss="modal" aria-label="Close">
2091
                            <span aria-hidden="true">&times;</span>
2092
                        </button>
2093
                    </div>
2094
                    <div class="modal-body">
2095
                        <div class="form-group">
2096
                            <label for="option-text">LABEL_TEXT</label>
2097
                            <!--  ckeditor -->
2098
                            <textarea  name="option-text" id="option-text" rows="5" class="ckeditor form-control"></textarea>
2099
                        </div>
2100
                        <div class="form-group">
2101
                            <label for="option-correct">LABEL_ANSWER_CORRECT</label>
2102
                            <select name="option-correct" id="option-correct" class="form-control">
2103
                                <option value="1">LABEL_YES</option>
2104
                                <option value="0">No</option>
2105
                            </select>
2106
                        </div>
2107
                        <div class="form-group">
2108
                            <label for="option-value">LABEL_VALUE</label>
2109
                            <input type="text" name="option-value" id="option-value" class="form-control" />
2110
                        </div>
2111
                    </div>
2112
                    <div class="modal-footer">
2113
                        <button type="submit" class="btn btn-primary">LABEL_SAVE</button>
2114
                        <button type="button" class="btn btn-secondary" data-dismiss="modal">LABEL_CLOSE</button>
2115
                    </div>
2116
                </div>
2117
            </form>
2118
        </div>
2119
    </div>
2120
    <!-- End Modal Options -->
2121
    <!-- End Modals -->
119 steven 2122
</section>