Proyectos de Subversion LeadersLinked - Backend

Rev

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

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