Gabriel Santiago Plaza преди 3 години
родител
ревизия
0da7a31910

+ 0
- 1
app/controllers/CriteriaController.php Целия файл

@@ -100,7 +100,6 @@ class CriteriaController extends \BaseController
100 100
         $json['outcomes'] = DB::select("select  DISTINCT outcomes.id, outcomes.name from outcomes , criterion_objective_outcome where criterion_objective_outcome.criterion_id = ? and outcomes.id = criterion_objective_outcome.outcome_id order by outcomes.id", array(Input::get('id')));
101 101
         $json['objectives'] = DB::select("SELECT DISTINCT objectives.id, objectives.text FROM objectives, criterion_objective_outcome where criterion_objective_outcome.criterion_id = ? and criterion_objective_outcome.objective_id= objectives.id ", array(Input::get('id')));
102 102
         $json['objectives_outcome'] = DB::select("select objectives.id, objectives.text, objective_outcome.outcome_id from objective_outcome, objectives where objective_outcome.outcome_id in(select  DISTINCT outcomes.id from outcomes , criterion_objective_outcome where criterion_objective_outcome.criterion_id = ? and outcomes.id = criterion_objective_outcome.outcome_id) and objectives.id = objective_outcome.objective_id ORDER BY outcome_id", array(Input::get('id')));
103
-        $json['scales'] = DB::select("select title, description, min_score, max_score from scales, criterion_scale where criterion_scale.scale_id = scales.id and criterion_id = ?", array(Input::get('id')));
104 103
         $json['program'] = DB::select("select criterion_id, program_id from program_criterion where criterion_id =?", array(Input::get('id')));
105 104
         $json['activity_criterion'] = DB::select("select * from new_assessments where activity_criterion_id  in (select id from activity_criterion where criterion_id = ?)", array(Input::get('id')));
106 105
 

+ 2
- 2
app/controllers/Objective2Controller.php Целия файл

@@ -106,7 +106,7 @@ class Objective2Controller extends \BaseController
106 106
 
107 107
 
108 108
 		$clean_input['outcome_id'] = Input::get('assoc_outcome');
109
-
109
+		Log::info(Input::all());
110 110
 
111 111
 
112 112
 		$clean_input['program_id'] = Input::get('program_id');
@@ -135,7 +135,7 @@ class Objective2Controller extends \BaseController
135 135
 		$program_id = Input::get('program_fetch');
136 136
 		$outcome_id = Input::get('outcome_fetch');
137 137
 		$json = array();
138
-		$json['objective'] = DB::select("SELECT * FROM `objectives` where id in (select objective_id from criterion_objective_outcome where outcome_id ={$outcome_id}) and id in(select objective_id from objective_program where program_id = {$program_id})");
138
+		$json['objective'] = DB::select("SELECT * FROM `objectives` where id in (select objective_id from objective_outcome where outcome_id ={$outcome_id}) and id in (select objective_id from objective_program where program_id = {$program_id})");
139 139
 		return json_encode($json);
140 140
 	}
141 141
 	public function delete()

+ 20
- 219
app/views/local/managers/admins/criteria.blade.php Целия файл

@@ -68,19 +68,7 @@
68 68
                     <p class="help-block"><strong>Manually add</strong> bullets or numbering.</p>
69 69
                     {{ Form::textarea('subcriteria', '', array('class' => 'form-control', 'rows'=>3, 'aria-labelledby'=>'subcriteria')) }}
70 70
                 </div>
71
-                <div class="form-group">
72
-                    {{ Form::label('maximum_score', 'Maximum Score') }}
73
-                    {{ Form::text('maximum_score', '1', array('class' => 'form-control', 'id'=>'maximum_score', 'oninput'=>'addOptions("Num_scale", "maximum_score", "Scales")')) }}
74
-                </div>
75
-                <div class="form-group">
76
-                    {{ Form::label('scales', 'Number of Scales') }}
77
-                    <select id="Num_scale" name="scales" class="form-control selectpicker" onchange='numberOfScales("Num_scale", "Scales")'>
78
-
79
-                    </select>
80
-                </div>
81
-                <div id='Scales' data-value="0">
82
-
83
-                </div>
71
+               
84 72
 
85 73
 
86 74
                 <div class="form-group">
@@ -112,19 +100,23 @@
112 100
                     </span>
113 101
                     Filters
114 102
                   </button>
103
+                  <div class ="filterSection">
115 104
                 <div class="form-group">
105
+                    
116 106
                     {{ Form::label('program_id2', 'Associated Program')}}
117 107
                     <select id='select-program' class="form-control selectpicker" onchange='fetchAllCriterion("select-program", "assoc_outcomes_fetch")'>
118 108
                         @foreach ($programs as $program)
119 109
                         <option value='{{$program->id}}' data-subtext="{{$program->code}}">{{$program->name}}</option>
120 110
                         @endforeach
121 111
                     </select>
112
+
122 113
                 </div>
123 114
                 <div class="form-group">
124 115
                     <label>Associated Outcome</label>
125 116
                     {{ Form::select('assoc_outcome_fetch', $outcomes, null, ['class'=>'form-control selectpicker', 'id'=>'assoc_outcomes_fetch', 'onchange'=>'fetchAllCriterion("select-program", "assoc_outcomes_fetch")']) }}
126 117
 
127 118
                 </div>
119
+                    </div>
128 120
 
129 121
                 <div class="form-group">
130 122
                     {{ Form::label('criterion_id', 'Criterion') }}
@@ -211,21 +203,6 @@
211 203
                     {{ Form::textarea('subcriteria', '', array('class' => 'form-control', 'rows'=>3, 'id' => 'criterion_subcriteria')) }}
212 204
                 </div>
213 205
 
214
-                <div class="form-group">
215
-                    {{ Form::label('assoc_maximum_score', 'Maximum Score') }}
216
-                    {{ Form::text('assoc_maximum_score', '', array('class' => 'form-control', 'id'=>'assoc_maximum_score', 'oninput'=>'addOptions("Num_assoc_scale", "assoc_maximum_score", "Assoc_Scales")')) }}
217
-                </div>
218
-
219
-
220
-                <div class="form-group">
221
-                    {{ Form::label('scales', 'Number of Scales') }}
222
-                    <select id="Num_assoc_scale" class="form-control selectpicker" onchange='numberOfAssoc("Num_assoc_scale", "Assoc_Scales")'>
223
-
224
-                    </select>
225
-                </div>
226
-                <div id='Assoc_Scales' data-value="0">
227
-
228
-                </div>
229 206
 
230 207
 
231 208
                 <div class="form-group">
@@ -255,75 +232,6 @@
255 232
     var counter = 1;
256 233
     var counterObj = 1;
257 234
     var outcomeString = 'OutcomeGroup_';
258
-    $(document).ready(function() {
259
-        addOptions('Num_scale', 'maximum_score', 'Scales');
260
-        numberOfScales('Num_scale', 'Scales');
261
-    });
262
-
263
-
264
-    function numberOfAssoc(string, Scales) {
265
-        var maximum = $('#assoc_maximum_score').val();
266
-        var amountOfScale = parseInt($('#' + string).val());
267
-        var dataValue = parseInt($('#' + Scales).attr('data-value'));
268
-        //add
269
-        if (dataValue < amountOfScale) {
270
-
271
-            fullDiv = '';
272
-
273
-            for (var i = dataValue; i < amountOfScale; i++) {
274
-                div = '<div id="assoc_eval' + i.toString() + Scales + '">' +
275
-                    '<div class ="form-row">' +
276
-                    '<label for="header' + (i).toString() + '">Evaluación ' + (i + 1).toString() + '</label><br><br>' +
277
-                    '<input type="hidden"  id="header' + i.toString() + '">' +
278
-                    '<div class="form-group col-md-8" >' +
279
-                    '<label for="title' + i.toString() + '">Nombre de Evaluación ' + (i + 1).toString() + '</label>' +
280
-                    '<input class="form-control" name="assoc_title[]" type="text"  id="title' + i.toString() + '" placeholder ="Nombre de evaluacion" ></div>' +
281
-                    '<div class ="form-group col-md-2">' +
282
-                    '<label for="min' + i.toString() + '">Mínimo </label>' +
283
-                    '<input class="form-control" type="number" id="assoc_min' + i.toString() + '" min="1" max = "' + maximum + '" oninput ="changedMin(' + "'assoc_min" + i.toString() + "', '" + i.toString() + "', 'Assoc_Scales' " + ')" name = "assoc_min[]"></div>' +
284
-                    '<div class ="form-group col-md-2">' +
285
-                    '<label for="max' + i.toString() + '">Máximo </label>' +
286
-                    '<input class="form-control" type="number" id="assoc_max' + i.toString() + '" min="1" max = "' + maximum + '" oninput ="changedMax(' + "'assoc_max" + i.toString() + "', '" + i.toString() + "', 'Assoc_Scales' " + ')" name = "assoc_max[]"></div></div>' +
287
-                    '<div class ="form-group">' +
288
-                    '<label for ="descripcion' + i.toString() + '">Descripción de evaluación</label>' +
289
-                    '<textarea class="form-control" rows="2" aria-labelledby="descripcion' + i.toString() + '" name="assoc_scales[]" cols="50" ></textarea></div></div>';
290
-                fullDiv += div;
291
-
292
-
293
-            }
294
-
295
-            $('#' + Scales).append(fullDiv);
296
-            $('#' + Scales).attr('data-value', amountOfScale);
297
-        } else {
298
-            for (var i = dataValue; i > amountOfScale; i--) {
299
-                $('#assoc_eval' + (i - 1).toString()).remove();
300
-            }
301
-        }
302
-        $('#' + Scales).attr('data-value', amountOfScale);
303
-
304
-    }
305
-
306
-    function addOptions(select, max, scaleDiv) {
307
-        var maxscore = parseInt($('#' + max).val())
308
-        options = '';
309
-        for (var i = 1; i <= maxscore; i++) {
310
-            options += '<option value="' + i.toString() + '">' + i.toString() + '</option>';
311
-
312
-        }
313
-
314
-        var previousvalue = parseInt($('#' + select).val());
315
-        $('#' + select).html(options);
316
-        $('#' + select).val(previousvalue);
317
-        $('#' + select).selectpicker('refresh');
318
-
319
-        var attribute = parseInt($('#' + scaleDiv).attr('data-value'));
320
-
321
-        for (var i = 0; i < attribute; i++) {
322
-            $('#max' + i.toString()).attr('max', maxscore);
323
-            $('#min' + i.toString()).attr('max', maxscore);
324
-        }
325
-
326
-    }
327 235
   
328 236
 
329 237
     $('.filterSection').hide();
@@ -337,68 +245,9 @@
337 245
   }
338 246
   $('.filterSection').toggle(533);
339 247
 });
340
-    function numberOfScales(string, Scales) {
341
-        var maximum = $('#maximum_score').val();
342
-        var amountOfScale = parseInt($('#' + string).val());
343
-        var dataValue = parseInt($('#' + Scales).attr('data-value'));
344
-        //add
345
-        if (dataValue < amountOfScale) {
346
-
347
-            fullDiv = '';
348
-
349
-            for (var i = dataValue; i < amountOfScale; i++) {
350
-                div = '<div id="eval' + i.toString() + Scales + '">' +
351
-                    '<div class ="form-row">' +
352
-                    '<label for="header' + (i).toString() + '">Evaluación ' + (i + 1).toString() + '</label><br><br>' +
353
-                    '<input type="hidden"  id="header' + i.toString() + '">' +
354
-                    '<div class="form-group col-md-8" >' +
355
-                    '<label for="title' + i.toString() + '">Nombre de Evaluación ' + (i + 1).toString() + '</label>' +
356
-                    '<input class="form-control" name="title[]" type="text"  id="title' + i.toString() + '" placeholder ="Nombre de evaluacion" ></div>' +
357
-                    '<div class ="form-group col-md-2">' +
358
-                    '<label for="min' + i.toString() + '">Mínimo </label>' +
359
-                    '<input class="form-control" type="number" id="min' + i.toString() + '" min="1" max = "' + maximum + '" oninput ="changedMin(' + "'min" + i.toString() + "', '" + i.toString() + "', 'Scales' " + ')" name = "min[]"></div>' +
360
-                    '<div class ="form-group col-md-2">' +
361
-                    '<label for="max' + i.toString() + '">Máximo </label>' +
362
-                    '<input class="form-control" type="number" id="max' + i.toString() + '" min="1" max = "' + maximum + '" oninput ="changedMax(' + "'max" + i.toString() + "', '" + i.toString() + "', 'Scales' " + ')" name = "max[]"></div></div>' +
363
-                    '<div class ="form-group">' +
364
-                    '<label for ="descripcion' + i.toString() + '">Descripción de evaluación</label>' +
365
-                    '<textarea class="form-control" rows="2" aria-labelledby="descripcion' + i.toString() + '" name="' + Scales + '[]" cols="50" ></textarea></div></div>';
366
-                fullDiv += div;
367
-            }
368
-
369
-            $('#' + Scales).append(fullDiv);
370
-
371
-        } else {
372
-            for (var i = dataValue; i > amountOfScale; i--) {
373
-                $('#eval' + (i - 1).toString() + Scales).remove();
374
-            }
375
-        }
376
-        $('#' + Scales).attr('data-value', amountOfScale);
377
-
378
-    }
379
-
380
-    function changedMin(min, index, scaleDiv) {
381
-        var maximum = parseInt($('#' + min).val()) + 1;
382
-        var maxScaleScore = parseInt($('#' + scaleDiv).attr('data-value'));
383 248
 
384
-        for (var i = parseInt(index); i < maxScaleScore; i++) {
385
-            $('#max' + i).attr('min', maximum);
386 249
 
387
-        }
388
-
389
-    }
390
-
391
-    function changedMax(max, index, scaleDiv) {
392
-        var maximum = parseInt($('#' + max).val()) + 1;
393
-        var maxScaleScore = parseInt($('#' + scaleDiv).attr('data-value'));
394
-
395
-        for (var i = parseInt(index) + 1; i < maxScaleScore; i++) {
396
-            $('#min' + i).attr('min', maximum)
397
-
398
-        }
399
-
400
-
401
-    }
250
+    
402 251
 
403 252
     //Add outcome Button
404 253
     function addOutcomeTest() {
@@ -501,7 +350,7 @@
501 350
         var $button = $('<button/>', {
502 351
             'type': 'button',
503 352
             'class': 'btn btn-primary',
504
-            'onclick': 'deleteObjective("assoc_objectiveForm' + assocObjectiveCounter.toString() + '", "assoc_closeObj' + assocObjectiveCounter.toString() + ', assoc_objectiveGroup")'
353
+            'onclick': 'deleteObjective("assoc_objectiveForm' + assocObjectiveCounter.toString() + '", "assoc_closeObj' + assocObjectiveCounter.toString() + ', "assoc_objectiveGroup")'
505 354
         });
506 355
 
507 356
         $button.append('X');
@@ -522,7 +371,7 @@
522 371
     function addObjectiveTest() {
523 372
         selectObj = document.getElementById('objective_0').innerHTML;
524 373
         counter = $("#objectiveGroup").data('value');
525
-        $('#objectiveGroup')
374
+       
526 375
         var $select = $('<select/>', {
527 376
             'class': "selectpicker form-control",
528 377
             'name': "objective[]",
@@ -750,7 +599,7 @@
750 599
 
751 600
     //after post
752 601
 
753
-    fetchAllCriterion("select-program", "assoc_outcomes_fetch");
602
+    
754 603
     //For editing criterion
755 604
     function fetchAllCriterion(program, outcome) {
756 605
         var program_id_fetch = $('#' + program).find(':selected').val();
@@ -800,10 +649,10 @@
800 649
 
801 650
                 if (!(json.activity_criterion.length)) {
802 651
 
803
-                    $('#DeleteButton').prop('disabled', true);
652
+                    $('#DeleteButton').prop('enabled', true);
804 653
 
805 654
                 } else {
806
-                    $('#DeleteButton').prop('enabled', true);
655
+                    $('#DeleteButton').prop('disabled', true);
807 656
                 }
808 657
 
809 658
                 if (!(json.criteria.length)) {
@@ -961,62 +810,6 @@
961 810
                 // Select status
962 811
 
963 812
 
964
-                scaleLength = json.scales.length;
965
-                fullDiv = '';
966
-                if (!scaleLength) {
967
-                    div = '<div id="assoc_eval 0"">' +
968
-                        '<div class ="form-row">' +
969
-                        '<label for="header0">Evaluación 1</label><br><br>' +
970
-                        '<input type="hidden"  id="header0">' +
971
-                        '<div class="form-group col-md-8" >' +
972
-                        '<label for="title0">Nombre de Evaluación 1</label>' +
973
-                        '<input class="form-control" name="assoc_title[]" value =" "type="text"  id="title0" placeholder ="Nombre de evaluacion" ></div>' +
974
-                        '<div class ="form-group col-md-2">' +
975
-                        '<label for="min0">Mínimo </label>' +
976
-                        '<input class="form-control" type="number" id="assoc_min0" min="1" max = "1" value =" " name = "assoc_min[]"></div>' +
977
-                        '<div class ="form-group col-md-2">' +
978
-                        '<label for="max">Máximo </label>' +
979
-                        '<input class="form-control" type="number" id="assoc_max" min="1" max = "" value =" " name = "assoc_max[]"></div></div>' +
980
-                        '<div class ="form-group">' +
981
-                        '<label for ="descripcion">Descripción de evaluación</label>' +
982
-                        '<textarea class="form-control" rows="2" aria-labelledby="descripcion" name="assoc_scales[]" cols="50" ></textarea></div></div>';
983
-                    fullDiv += div;
984
-                } else {
985
-                    var dataValue = parseInt($('#Assoc_Scales').attr('data-value'));
986
-                    $('#assoc_maximum_score').val(json.criteria[0].maximum_score);
987
-                    var maximum = json.criteria[0].maximum_score;
988
-
989
-
990
-                    $('#Assoc_Scales').html(' ');
991
-                    for (var i = 0; i < scaleLength; i++) {
992
-
993
-                        div = '<div id="assoc_eval' + i.toString() + '">' +
994
-                            '<div class ="form-row">' +
995
-                            '<label for="header' + (i).toString() + '">Evaluación ' + (i + 1).toString() + '</label><br><br>' +
996
-                            '<input type="hidden"  id="header' + i.toString() + '">' +
997
-                            '<div class="form-group col-md-8" >' +
998
-                            '<label for="title' + i.toString() + '">Nombre de Evaluación ' + (i + 1).toString() + '</label>' +
999
-                            '<input class="form-control" name="assoc_title[]" value ="' + json.scales[i].title + '"type="text"  id="title' + i.toString() + '" placeholder ="Nombre de evaluacion" ></div>' +
1000
-                            '<div class ="form-group col-md-2">' +
1001
-                            '<label for="min' + i.toString() + '">Mínimo </label>' +
1002
-                            '<input class="form-control" type="number" id="assoc_min' + i.toString() + '" min="1" max = "' + maximum + '" value ="' + json.scales[i].min_score + '"oninput ="changedMin(' + "'assoc_min" + i.toString() + "', '" + i.toString() + "', 'Assoc_Scales' " + ')" name = "assoc_min[]"></div>' +
1003
-                            '<div class ="form-group col-md-2">' +
1004
-                            '<label for="max' + i.toString() + '">Máximo </label>' +
1005
-                            '<input class="form-control" type="number" id="assoc_max' + i.toString() + '" min="1" max = "' + maximum + '" value ="' + json.scales[i].max_score + '"oninput ="changedMax(' + "'assoc_max" + i.toString() + "', '" + i.toString() + "', 'Assoc_Scales' " + ')" name = "assoc_max[]"></div></div>' +
1006
-                            '<div class ="form-group">' +
1007
-                            '<label for ="descripcion' + i.toString() + '">Descripción de evaluación</label>' +
1008
-                            '<textarea class="form-control" rows="2" aria-labelledby="descripcion' + i.toString() + '" name="assoc_scales[]" cols="50" >' + json.scales[i].description + '</textarea></div></div>';
1009
-                        fullDiv += div;
1010
-
1011
-                    }
1012
-                }
1013
-
1014
-                addOptions('Num_assoc_scale', 'assoc_maximum_score');
1015
-
1016
-                $('#Assoc_Scales').append(fullDiv);
1017
-                $('#Assoc_Scales').attr('data-value', scaleLength);
1018
-                $('#Num_assoc_scale').val(scaleLength);
1019
-                $('#Num_assoc_scale').selectpicker('refresh')
1020 813
 
1021 814
 
1022 815
 
@@ -1043,7 +836,7 @@ $('#outcome-display').parent().hide();
1043 836
 fetchCriterionForEditing();
1044 837
 fetchObjectiveForSelect('outcomeGroup', 'objectiveGroup');
1045 838
 // setCriterionStatus();
1046
-
839
+fetchAllCriterion("select-program", "assoc_outcomes_fetch");
1047 840
 
1048 841
 
1049 842
 
@@ -1078,6 +871,14 @@ e.preventDefault();
1078 871
 
1079 872
 return false;
1080 873
 });
874
+
875
+$('.filterButton').on('click', function(e) {
876
+    // Prevent the default action of the clicked item. In this case that is submit
877
+    e.preventDefault();
878
+    
879
+    
880
+    return false;
881
+    });
1081 882
 // Fetch criterion info for editing
1082 883
 
1083 884
 

+ 30
- 13
app/views/local/managers/admins/objectives.blade.php Целия файл

@@ -67,7 +67,12 @@
67 67
                 Edit
68 68
             </div>
69 69
             <div class="panel-body">
70
-
70
+                <button class="btn btn-md btn-secondary filterButton">
71
+                    <span class="glyphicon glyphicon-plus">
72
+                    </span>
73
+                    Filters
74
+                  </button>
75
+                  <div class='filterSection'>
71 76
                 {{ Form::open(array('action' => 'Objective2Controller@update')) }}
72 77
                 <div class="form-group">
73 78
                     {{ Form::label('program_id2', 'Associated Program')}}
@@ -79,9 +84,10 @@
79 84
                 </div>
80 85
                 <div class="form-group">
81 86
                     <label>Associated Outcome</label>
82
-                    {{ Form::select('assoc_outcome_fetch', $outcomes, null, ['class'=>'form-control selectpicker', 'id'=>'assoc_outcomes_fetch', 'onchange'=>'fetchAllObjectives("select-program", "assoc_outcomes_fetch")']) }}
87
+                    {{ Form::select('assoc_outcomes_fetch', $outcomes, null, ['class'=>'form-control selectpicker', 'id'=>'assoc_outcomes_fetch', 'onchange'=>'fetchAllObjectives("select-program", "assoc_outcomes_fetch")']) }}
83 88
 
84 89
                 </div>
90
+                  </div>
85 91
                 <div class="form-group">
86 92
                     {{ Form::label('objective_id', 'Objectives') }}
87 93
                     <select id="select-objective" name="id" class="form-control selectpicker">
@@ -106,7 +112,7 @@
106 112
                     <div id='assocOutcomeGroup'>
107 113
                         <label>Associated Outcome</label>
108 114
 
109
-                        {{ Form::select('assoc_outcome[]', $outcomes, null, ['class'=>'form-control selectpicker', 'id'=>'assoc_outcome0']) }}
115
+                        {{ Form::select('outcome[]', $outcomes, null, ['class'=>'form-control selectpicker', 'id'=>'assoc_outcome0']) }}
110 116
 
111 117
                     </div>
112 118
                 </div>
@@ -165,10 +171,20 @@
165 171
     </div>
166 172
 </div>
167 173
 <script>
174
+    $('.filterSection').hide();
175
+    $('.filterButton').on('click', function()
176
+{
177
+  var span = $(this).find('span');
178
+  if(span.attr('class') == 'glyphicon glyphicon-plus'){
179
+    span.attr('class','glyphicon glyphicon-minus');
180
+  } else{
181
+    span.attr('class','glyphicon glyphicon-plus');
182
+  }
183
+  $('.filterSection').toggle(533);
184
+});
168 185
     var outcomeHTML = document.getElementById('outcomeGroup').innerHTML;
169 186
     var selectOptions = document.getElementById('outcome[0]').innerHTML;
170
-    fetchAllObjectives("select-program", "assoc_outcomes_fetch")
171
-
187
+   
172 188
     function fetchAllObjectives(program, outcome) {
173 189
         var program_id_fetch = $('#' + program).find(':selected').val();
174 190
         var outcome_fetch = $('#' + outcome).find(':selected').val();
@@ -280,7 +296,7 @@
280 296
 
281 297
                 // Select associated outcome
282 298
                 for (var i = counterAssoc; i != 1; i--) {
283
-                    deleteLastAssoc(i);
299
+                    deleteLastAssoc(i-1);
284 300
 
285 301
                 }
286 302
                 $('#assoc_outcome0').val(json.outcome[0].outcome_id);
@@ -290,7 +306,7 @@
290 306
                     counterAssoc = i + 1;
291 307
                     var $select = $('<select />', {
292 308
                         'class': "selectpicker form-control",
293
-                        'name': "assoc_outcome[]",
309
+                        'name': "outcome[]",
294 310
                         'data-live-search': 'true',
295 311
                         'id': 'assoc_outcome' + i.toString()
296 312
 
@@ -307,7 +323,7 @@
307 323
                     var $button = $('<button />', {
308 324
                         'type': 'button',
309 325
                         'class': 'btn btn-primary',
310
-                        'onclick': 'deleteLastAssoc()'
326
+                        'onclick': 'deleteLastAssoc('+i+')'
311 327
                     });
312 328
                     $button.append('X');
313 329
                     $divForButton.append($button);
@@ -411,11 +427,11 @@
411 427
         );
412 428
     }
413 429
 
414
-    function deleteLastAssoc() {
430
+    function deleteLastAssoc(i) {
415 431
 
416
-        div = document.getElementById('assocOutcomeForm' + (counterAssoc).toString());
432
+        div = document.getElementById('assocOutcomeForm' + (i).toString());
417 433
         div.remove();
418
-        button = document.getElementById('closeAssoc' + (counterAssoc).toString());
434
+        button = document.getElementById('closeAssoc' + (i).toString());
419 435
         button.remove();
420 436
         counterAssoc -= 1;
421 437
 
@@ -426,7 +442,7 @@
426 442
 
427 443
         var $select = $('<select />', {
428 444
             'class': "selectpicker form-control",
429
-            'name': "assoc_outcome[]",
445
+            'name': "outcome[]",
430 446
             'data-live-search': 'true',
431 447
             'id': 'assoc_outcome' + counterAssoc.toString()
432 448
 
@@ -443,7 +459,7 @@
443 459
         var $button = $('<button />', {
444 460
             'type': 'button',
445 461
             'class': 'btn btn-primary',
446
-            'onclick': 'deleteLastAssoc()'
462
+            'onclick': 'deleteLastAssoc('+counterAssoc+')'
447 463
         });
448 464
         $button.append('X');
449 465
         $divForButton.append($button);
@@ -478,6 +494,7 @@ fetchObjectiveForEditing();
478 494
 // setCriterionStatus();
479 495
 
480 496
 
497
+fetchAllObjectives("select-program", "assoc_outcomes_fetch")
481 498
 
482 499
 
483 500
 // --------------------------------------------------------------------------

+ 118
- 292
app/views/local/managers/pCoords/criteria.blade.php Целия файл

@@ -18,7 +18,7 @@
18 18
                     <div class="form-group col-md-11">
19 19
                         <label>Associated Outcomes</label>
20 20
 
21
-                        {{ Form::select('outcome[]', $outcomes, reset($outcomes),  ['class'=>'form-control selectpicker', 'id' =>'outcome0', 'onchange'=>'fetchObjectiveForSelect("outcome0")']) }}
21
+                        {{ Form::select('outcome[]', $outcomes, reset($outcomes),  ['class'=>'form-control selectpicker', 'id' =>'outcome0', 'onchange'=>'fetchObjectiveForSelect("outcomeGroup", "objectiveGroup")']) }}
22 22
                     </div>
23 23
                 </div>
24 24
                 <input type='hidden' name='counterOutcome' id='counterOutcome' value=1>
@@ -28,7 +28,7 @@
28 28
                     </span>
29 29
                     Add another Outcome
30 30
                 </button>
31
-                <div id='objectiveGroup'>
31
+                <div id='objectiveGroup' data-value = '1'>
32 32
                     <div class="form-group">
33 33
                         <label>Associated Objectives</label>
34 34
                         <select id="objective_0" name="objective[]" class="form-control selectpicker">
@@ -67,19 +67,7 @@
67 67
                     <p class="help-block"><strong>Manually add</strong> bullets or numbering.</p>
68 68
                     {{ Form::textarea('subcriteria', '', array('class' => 'form-control', 'rows'=>3, 'aria-labelledby'=>'subcriteria')) }}
69 69
                 </div>
70
-                <div class="form-group">
71
-                    {{ Form::label('maximum_score', 'Maximum Score') }}
72
-                    {{ Form::text('maximum_score', '1', array('class' => 'form-control', 'id'=>'maximum_score', 'oninput'=>'addOptions("Num_scale", "maximum_score", "Scales")')) }}
73
-                </div>
74
-                <div class="form-group">
75
-                    {{ Form::label('scales', 'Number of Scales') }}
76
-                    <select id="Num_scale" name="scales" class="form-control selectpicker" onchange='numberOfScales("Num_scale", "Scales")'>
77
-
78
-                    </select>
79
-                </div>
80
-                <div id='Scales' data-value="0">
81
-
82
-                </div>
70
+                
83 71
 
84 72
 
85 73
                 <div class="form-group">
@@ -146,7 +134,7 @@
146 134
                 </div>
147 135
 
148 136
                 <!-- Associated Outcome -->
149
-                <div id='assocOutcomeGroup'>
137
+                <div id='assocOutcomeGroup' data-value="1">
150 138
                     <div class="form-group">
151 139
                         <label>Associated Outcome</label>
152 140
                         {{ Form::select('assoc_outcome[]', $outcomes, null, ['class'=>'form-control selectpicker', 'id'=>'assoc_outcome_0', 'onchange'=>'fetchAssocObjective("assoc_outcome_0")']) }}
@@ -160,10 +148,11 @@
160 148
                     Add another Outcome
161 149
                 </button>
162 150
 
163
-                <div id='assoc_objectiveGroup'>
151
+                <div id='assoc_objectiveGroup' data-value="1">
164 152
                     <div class="form-group">
165 153
                         <label>Associated Objectives</label>
166 154
                         <select id="assoc_objective_0" name="assoc_objective[]" class="form-control selectpicker">
155
+                            <option value="0">No associated objectives</option>
167 156
                         </select>
168 157
 
169 158
                     </div>
@@ -212,21 +201,7 @@
212 201
                     {{ Form::textarea('subcriteria', '', array('class' => 'form-control', 'rows'=>3, 'id' => 'criterion_subcriteria')) }}
213 202
                 </div>
214 203
 
215
-                <div class="form-group">
216
-                    {{ Form::label('assoc_maximum_score', 'Maximum Score') }}
217
-                    {{ Form::text('assoc_maximum_score', '', array('class' => 'form-control', 'id'=>'assoc_maximum_score', 'oninput'=>'addOptions("Num_assoc_scale", "assoc_maximum_score", "Assoc_Scales")')) }}
218
-                </div>
219
-
220
-
221
-                <div class="form-group">
222
-                    {{ Form::label('scales', 'Number of Scales') }}
223
-                    <select id="Num_assoc_scale" class="form-control selectpicker" onchange='numberOfAssoc("Num_assoc_scale", "Assoc_Scales")'>
224
-
225
-                    </select>
226
-                </div>
227
-                <div id='Assoc_Scales' data-value="0">
228 204
 
229
-                </div>
230 205
 
231 206
 
232 207
                 <div class="form-group">
@@ -241,9 +216,11 @@
241 216
                
242 217
                 {{ Form::submit('Update', array('class' => 'btn btn-primary btn-block')) }}
243 218
                 {{ Form::close() }}
244
- <div id='delete'>
245
-
246
-                </div>
219
+                {{ Form::open(array('action' => 'CriteriaController@delete')) }}
220
+                
221
+                                <input type='hidden' name='criterion_delete' id='deleteCriteria'>
222
+               
223
+                                {{Form::submit("Delete", array('class'=> 'btn btn-primary btn-block', 'id'=>"DeleteButton"))}}
247 224
 
248 225
             </div>
249 226
         </div>
@@ -255,75 +232,7 @@
255 232
     var counter = 1;
256 233
     var counterObj = 1;
257 234
     var outcomeString = 'OutcomeGroup_';
258
-    $(document).ready(function() {
259
-        addOptions('Num_scale', 'maximum_score', 'Scales');
260
-        numberOfScales('Num_scale', 'Scales');
261
-    });
262
-
263
-
264
-    function numberOfAssoc(string, Scales) {
265
-        var maximum = $('#assoc_maximum_score').val();
266
-        var amountOfScale = parseInt($('#' + string).val());
267
-        var dataValue = parseInt($('#' + Scales).attr('data-value'));
268
-        //add
269
-        if (dataValue < amountOfScale) {
270
-
271
-            fullDiv = '';
272
-
273
-            for (var i = dataValue; i < amountOfScale; i++) {
274
-                div = '<div id="assoc_eval' + i.toString() + Scales + '">' +
275
-                    '<div class ="form-row">' +
276
-                    '<label for="header' + (i).toString() + '">Evaluación ' + (i + 1).toString() + '</label><br><br>' +
277
-                    '<input type="hidden"  id="header' + i.toString() + '">' +
278
-                    '<div class="form-group col-md-8" >' +
279
-                    '<label for="title' + i.toString() + '">Nombre de Evaluación ' + (i + 1).toString() + '</label>' +
280
-                    '<input class="form-control" name="assoc_title[]" type="text"  id="title' + i.toString() + '" placeholder ="Nombre de evaluacion" ></div>' +
281
-                    '<div class ="form-group col-md-2">' +
282
-                    '<label for="min' + i.toString() + '">Mínimo </label>' +
283
-                    '<input class="form-control" type="number" id="assoc_min' + i.toString() + '" min="1" max = "' + maximum + '" oninput ="changedMin(' + "'assoc_min" + i.toString() + "', '" + i.toString() + "', 'Assoc_Scales' " + ')" name = "assoc_min[]"></div>' +
284
-                    '<div class ="form-group col-md-2">' +
285
-                    '<label for="max' + i.toString() + '">Máximo </label>' +
286
-                    '<input class="form-control" type="number" id="assoc_max' + i.toString() + '" min="1" max = "' + maximum + '" oninput ="changedMax(' + "'assoc_max" + i.toString() + "', '" + i.toString() + "', 'Assoc_Scales' " + ')" name = "assoc_max[]"></div></div>' +
287
-                    '<div class ="form-group">' +
288
-                    '<label for ="descripcion' + i.toString() + '">Descripción de evaluación</label>' +
289
-                    '<textarea class="form-control" rows="2" aria-labelledby="descripcion' + i.toString() + '" name="assoc_scales[]" cols="50" ></textarea></div></div>';
290
-                fullDiv += div;
291
-
292
-
293
-            }
294
-
295
-            $('#' + Scales).append(fullDiv);
296
-            $('#' + Scales).attr('data-value', amountOfScale);
297
-        } else {
298
-            for (var i = dataValue; i > amountOfScale; i--) {
299
-                $('#assoc_eval' + (i - 1).toString()).remove();
300
-            }
301
-        }
302
-        $('#' + Scales).attr('data-value', amountOfScale);
303
-
304
-    }
305
-
306
-    function addOptions(select, max, scaleDiv) {
307
-        var maxscore = parseInt($('#' + max).val())
308
-        options = '';
309
-        for (var i = 1; i <= maxscore; i++) {
310
-            options += '<option value="' + i.toString() + '">' + i.toString() + '</option>';
311
-
312
-        }
313
-
314
-        var previousvalue = parseInt($('#' + select).val());
315
-        $('#' + select).html(options);
316
-        $('#' + select).val(previousvalue);
317
-        $('#' + select).selectpicker('refresh');
318
-
319
-        var attribute = parseInt($('#' + scaleDiv).attr('data-value'));
320
-
321
-        for (var i = 0; i < attribute; i++) {
322
-            $('#max' + i.toString()).attr('max', maxscore);
323
-            $('#min' + i.toString()).attr('max', maxscore);
324
-        }
325
-
326
-    }
235
+   
327 236
 
328 237
 
329 238
 $('.filterSection').hide();
@@ -338,71 +247,11 @@ $('.filterSection').hide();
338 247
   $('.filterSection').toggle(533);
339 248
 });
340 249
 
341
-    function numberOfScales(string, Scales) {
342
-        var maximum = $('#maximum_score').val();
343
-        var amountOfScale = parseInt($('#' + string).val());
344
-        var dataValue = parseInt($('#' + Scales).attr('data-value'));
345
-        //add
346
-        if (dataValue < amountOfScale) {
347
-
348
-            fullDiv = '';
349
-
350
-            for (var i = dataValue; i < amountOfScale; i++) {
351
-                div = '<div id="eval' + i.toString() + Scales + '">' +
352
-                    '<div class ="form-row">' +
353
-                    '<label for="header' + (i).toString() + '">Evaluación ' + (i + 1).toString() + '</label><br><br>' +
354
-                    '<input type="hidden"  id="header' + i.toString() + '">' +
355
-                    '<div class="form-group col-md-8" >' +
356
-                    '<label for="title' + i.toString() + '">Nombre de Evaluación ' + (i + 1).toString() + '</label>' +
357
-                    '<input class="form-control" name="title[]" type="text"  id="title' + i.toString() + '" placeholder ="Nombre de evaluacion" ></div>' +
358
-                    '<div class ="form-group col-md-2">' +
359
-                    '<label for="min' + i.toString() + '">Mínimo </label>' +
360
-                    '<input class="form-control" type="number" id="min' + i.toString() + '" min="1" max = "' + maximum + '" oninput ="changedMin(' + "'min" + i.toString() + "', '" + i.toString() + "', 'Scales' " + ')" name = "min[]"></div>' +
361
-                    '<div class ="form-group col-md-2">' +
362
-                    '<label for="max' + i.toString() + '">Máximo </label>' +
363
-                    '<input class="form-control" type="number" id="max' + i.toString() + '" min="1" max = "' + maximum + '" oninput ="changedMax(' + "'max" + i.toString() + "', '" + i.toString() + "', 'Scales' " + ')" name = "max[]"></div></div>' +
364
-                    '<div class ="form-group">' +
365
-                    '<label for ="descripcion' + i.toString() + '">Descripción de evaluación</label>' +
366
-                    '<textarea class="form-control" rows="2" aria-labelledby="descripcion' + i.toString() + '" name="' + Scales + '[]" cols="50" ></textarea></div></div>';
367
-                fullDiv += div;
368
-            }
369
-
370
-            $('#' + Scales).append(fullDiv);
371
-
372
-        } else {
373
-            for (var i = dataValue; i > amountOfScale; i--) {
374
-                $('#eval' + (i - 1).toString() + Scales).remove();
375
-            }
376
-        }
377
-        $('#' + Scales).attr('data-value', amountOfScale);
378
-
379
-    }
380
-
381
-    function changedMin(min, index, scaleDiv) {
382
-        var maximum = parseInt($('#' + min).val()) + 1;
383
-        var maxScaleScore = parseInt($('#' + scaleDiv).attr('data-value'));
384 250
 
385
-        for (var i = parseInt(index); i < maxScaleScore; i++) {
386
-            $('#max' + i).attr('min', maximum);
387
-
388
-        }
389
-
390
-    }
391
-
392
-    function changedMax(max, index, scaleDiv) {
393
-        var maximum = parseInt($('#' + max).val()) + 1;
394
-        var maxScaleScore = parseInt($('#' + scaleDiv).attr('data-value'));
395
-
396
-        for (var i = parseInt(index) + 1; i < maxScaleScore; i++) {
397
-            $('#min' + i).attr('min', maximum)
398
-
399
-        }
400
-
401
-
402
-    }
403 251
 
404 252
     //Add outcome Button
405 253
     function addOutcomeTest() {
254
+        counter = parseInt($('#outcomeGroup').data("value"));
406 255
         var $select = $('<select/>', {
407 256
             'class': "selectpicker form-control",
408 257
             'name': "outcome[]",
@@ -434,11 +283,12 @@ $('.filterSection').hide();
434 283
         $select.append(selectOptions);
435 284
 
436 285
         $select.appendTo('#outcomeForm' + counter.toString()).selectpicker('refresh');
286
+        $('#outcomeGroup').data("value", counter +1);
437 287
         fetchObjectiveForSelect('outcomeGroup', "objectiveGroup");
438 288
         counter += 1;
439 289
         $divForButton.appendTo('#outcomeGroup');
440 290
 
441
-        $('#counterOutcome').val(counter)
291
+        
442 292
 
443 293
 
444 294
     }
@@ -458,11 +308,14 @@ $('.filterSection').hide();
458 308
 
459 309
     }
460 310
     //Delete Objective
461
-    function deleteObjective(objectiveForm, closeObj) {
311
+ 
312
+    function deleteObjective(objectiveForm, closeObj, objectiveGroup) {
462 313
         $div = document.getElementById(objectiveForm);
463 314
         $div.remove();
464 315
         $div = document.getElementById(closeObj);
465 316
         $div.remove();
317
+        counter = parseInt($('#'+objectiveGroup).data("value"));
318
+        $('#'+objectiveGroup).data("value", counter-1);
466 319
 
467 320
 
468 321
     }
@@ -471,6 +324,7 @@ $('.filterSection').hide();
471 324
 
472 325
     function addAssocObjective() {
473 326
         selectObj = document.getElementById('assoc_objective_0').innerHTML;
327
+        assocObjectiveCounter = parseInt($('#assoc_objectiveGroup').data('value'));
474 328
         var $select = $('<select/>', {
475 329
             'class': "selectpicker form-control",
476 330
             'name': "assoc_objective[]",
@@ -491,7 +345,7 @@ $('.filterSection').hide();
491 345
         var $button = $('<button/>', {
492 346
             'type': 'button',
493 347
             'class': 'btn btn-primary',
494
-            'onclick': 'deleteObjective("assoc_objectiveForm' + assocObjectiveCounter.toString() + '", "assoc_closeObj' + assocObjectiveCounter.toString() + '")'
348
+            'onclick': 'deleteObjective("assoc_objectiveForm' + assocObjectiveCounter.toString() + '", "assoc_closeObj' + assocObjectiveCounter.toString() + ', "assoc_objectiveGroup")'
495 349
         });
496 350
 
497 351
         $button.append('X');
@@ -501,7 +355,7 @@ $('.filterSection').hide();
501 355
         $select.append(selectObj);
502 356
 
503 357
         $select.appendTo('#assoc_objectiveForm' + assocObjectiveCounter.toString()).selectpicker('refresh');
504
-        counterObj += 1;
358
+        $('#assoc_objectiveGroup').data("value", assocObjectiveCounter +1);
505 359
 
506 360
         $divForButton.appendTo('#assoc_objectiveGroup');
507 361
 
@@ -511,26 +365,27 @@ $('.filterSection').hide();
511 365
     //Add objective when creating a criteria
512 366
     function addObjectiveTest() {
513 367
         selectObj = document.getElementById('objective_0').innerHTML;
368
+        counter = $("#objectiveGroup").data('value');
514 369
         var $select = $('<select/>', {
515 370
             'class': "selectpicker form-control",
516 371
             'name': "objective[]",
517 372
             'data-live-search': 'true',
518
-            'id': 'objective_' + counterObj.toString()
373
+            'id': 'objective_' + counter.toString()
519 374
 
520 375
         });
521 376
         var $div = $('<div/>', {
522
-            'id': 'objectiveForm' + counterObj.toString(),
377
+            'id': 'objectiveForm' + counter.toString(),
523 378
             'class': 'form-group col-md-11'
524 379
         });
525 380
         var $divForButton = $('<div/>', {
526 381
             'class': 'col-md-1',
527
-            'id': 'closeObj' + counterObj.toString()
382
+            'id': 'closeObj' + counter.toString()
528 383
 
529 384
         });
530 385
         var $button = $('<button/>', {
531 386
             'type': 'button',
532 387
             'class': 'btn btn-primary',
533
-            'onclick': 'deleteObjective("objectiveForm' + counterObj.toString() + '", "closeObj' + counterObj.toString() + '")'
388
+            'onclick': 'deleteObjective("objectiveForm' + counter.toString() + '", "closeObj' + counter.toString() + '")'
534 389
         });
535 390
 
536 391
         $button.append('X');
@@ -539,11 +394,11 @@ $('.filterSection').hide();
539 394
         $div.appendTo('#objectiveGroup')
540 395
         $select.append(selectObj);
541 396
 
542
-        $select.appendTo('#objectiveForm' + counterObj.toString()).selectpicker('refresh');
543
-        counterObj += 1;
397
+        $select.appendTo('#objectiveForm' + counter.toString()).selectpicker('refresh');
398
+        
544 399
 
545 400
         $divForButton.appendTo('#objectiveGroup');
546
-        $('#counterObjective').val(counterObj)
401
+        $('#objectiveGroup').data('value', counter +1);
547 402
     }
548 403
 
549 404
     //Create outcome for editing
@@ -552,6 +407,7 @@ $('.filterSection').hide();
552 407
 
553 408
 
554 409
     function addAssocOutcome() {
410
+        assocOutcomeCounter = parseInt($('#assocOutcomeGroup').data('value'));
555 411
         var $select = $('<select/>', {
556 412
             'class': "selectpicker form-control",
557 413
             'name': "assoc_outcome[]",
@@ -583,11 +439,10 @@ $('.filterSection').hide();
583 439
         $select.append(selectOptions);
584 440
 
585 441
         $select.appendTo('#assoc_outcomeForm' + assocOutcomeCounter.toString()).selectpicker('refresh');
586
-        //fetchAssocObjective('assoc_outcome_' + assocOutcomeCounter.toString());
587
-        assocOutcomeCounter += 1;
442
+         assocOutcomeCounter += 1;
588 443
         $divForButton.appendTo('#assocOutcomeGroup');
589 444
 
590
-
445
+        $('#assocOutcomeGroup').data('value', assocOutcomeCounter);
591 446
 
592 447
 
593 448
     }
@@ -596,37 +451,64 @@ $('.filterSection').hide();
596 451
 
597 452
     var assocObjectiveCounter = 1;
598 453
 
599
-    function fetchAssocObjective(outcomeId) {
600
-        var id = $('#' + outcomeId).find(':selected').val();
454
+    function fetchAssocObjective(outcomeDiv, objectiveGroup) {
455
+        var count = $('#'+outcomeDiv).data('value');
456
+        var allOutcomes =[];
457
+
458
+         $("#" + outcomeDiv + ' select').each(function() {
459
+            allOutcomes.push( this.value);
460
+
461
+        })
462
+        var allObjectives = [];
463
+        $("#" + objectiveGroup + ' select').each(function() {
464
+            var temp = {
465
+                id: this.id,
466
+                value: this.value
467
+            }
468
+            allObjectives.push(temp);
469
+        })
601 470
 
602 471
 
603 472
         $.post(
604 473
             "{{ URL::action('CriteriaController@fetchObjectivesForSelect') }}", {
605
-                id: id
474
+                allOutcomes: allOutcomes
606 475
             },
607 476
 
608 477
             function(json) {
609 478
 
610
-                var optionName = '<optgroup id="' + 'Associated_Outcome' + (assocOutcomeCounter - 1).toString() + '"label="' + 'Associated Outcome' + (assocOutcomeCounter).toString() + '"';
611
-                for (var i = 0; i < json.length; i++) {
612
-                    var option = '<option value ="' + json[i].id.toString() + '">' + json[i].text + '</option>'
613
-                    optionName += (option)
614
-
615
-                }
616
-                optGroup = document.getElementById('Associated_Outcome' + (assocOutcomeCounter - 1).toString());
617
-                if (optGroup != null) {
618
-                    optGroup.remove()
479
+                optionName = '';
480
+                for(outcome in varArray.outcomes){
481
+                    optionName += '<optgroup label="' + varArray.outcomes[outcome][0].name + '"';
482
+                    var objectiveForOutcome = varArray.objectives;
483
+                    var objectives = objectiveForOutcome[outcome];
484
+                    for (objective in objectives) {
485
+                
619 486
 
487
+                        var obj= objectives[objective];
488
+                        var option = '<option value ="' + obj.id + '">' +obj.text + '</option>';
489
+                        optionName += (option);
490
+                    }
620 491
                 }
621 492
 
622 493
 
623
-                $('#assoc_objective_0').append(optionName);
494
+                $('#assoc_objective_0').html(optionName);
624 495
                 $('#assoc_objective_0').selectpicker('refresh');
496
+                if($("#assoc_objective_0 option[value='"+allObjectives[0].value+"']").length>0){
497
+                    $("#assoc_objective_0").val(allObjectives[0].value);
498
+                    $('#assoc_objective_0').selectpicker('refresh');
499
+                }
625 500
 
626
-                for (var i = assocObjectiveCounter - 1; i > 0; i--) {
627
-                    deleteObjective('assoc_objectiveForm' + i.toString(), 'assoc_closeObj' + i.toString())
501
+                for (var i = allObjectives.length - 1; i > 0; i--) {
502
+                    deleteObjective('assoc_objectiveForm' + i.toString(), 'assoc_closeObj' + i.toString(), 'assoc_objectiveGroup');
503
+                }
504
+                for(var i=1; i<allObjectives.length; i++){
505
+                    addAssocObjective();
506
+                    $('#assoc_objective_'+i.toString()).selectpicker('refresh');
507
+                    if($("#assoc_objective_"+i.toString()+" option[value='"+allObjectives[i].value+"']").length>0){
508
+                    $("#assoc_objective_"+i.toString()).val(allObjectives[i].value);
509
+                    $("#assoc_objective_"+i.toString()).selectpicker("refresh");
510
+                    }
628 511
                 }
629
-                assocObjectiveCounter = 1;
630 512
 
631 513
 
632 514
 
@@ -708,7 +590,7 @@ $('.filterSection').hide();
708 590
     }
709 591
     //after post
710 592
 
711
-    fetchAllCriterion("select-program", "assoc_outcomes_fetch");
593
+   
712 594
     //For editing criterion
713 595
     function fetchAllCriterion(program, outcome) {
714 596
         var program_id_fetch = $('#' + program).find(':selected').val();
@@ -758,10 +640,11 @@ $('.filterSection').hide();
758 640
 
759 641
                 if (!(json.activity_criterion.length)) {
760 642
 
761
-                    var button = "<button type='button' class ='btn btn-primary btn-block' onclick ='deleteCriterion()'>Delete Criterion</button><br><br>"
762
-                    $('#delete').html(button)
643
+$('#DeleteButton').prop('enabled', true);
763 644
 
764
-                }
645
+} else {
646
+$('#DeleteButton').prop('disabled', true);
647
+}
765 648
 
766 649
                 if (!(json.criteria.length)) {
767 650
                     name = ' ';
@@ -777,9 +660,16 @@ $('.filterSection').hide();
777 660
                     var name = json.criteria[0].name;
778 661
                     if (json.criteria[0].subcriteria) {
779 662
                         subcriteria = JSON.parse(json.criteria[0].subcriteria).join('\n');
663
+                    }else {
664
+                        subcriteria = "";
780 665
                     }
781
-                    var copyright = json.criteria[0].copyright;
782
-                    var notes = json.criteria[0].notes;
666
+                    if (json.criteria[0].copyright) {
667
+                        var copyright = json.criteria[0].copyright;
668
+                    } else {
669
+                        var copyright = ''
670
+                    }
671
+                    if (json.criteria[0].notes) notes = json.criteria[0].notes;
672
+                    else notes = '';
783 673
 
784 674
                     // Display info
785 675
                     $('#criterion_name').val(name);
@@ -796,16 +686,12 @@ $('.filterSection').hide();
796 686
                 }
797 687
 
798 688
 
799
-                if (copyright) {
689
+               
800 690
                     $('#criterion_copyright').text(copyright);
801
-                } else {
802
-                    $('#criterion_copyright').text('');
803
-                }
804
-                if (notes) {
691
+                
692
+                
805 693
                     $('#criterion_notes').text(notes);
806
-                } else {
807
-                    $('#criterion_notes').text('');
808
-                }
694
+               
809 695
 
810 696
 
811 697
 
@@ -814,6 +700,7 @@ $('.filterSection').hide();
814 700
 
815 701
                 // Select associated outcome
816 702
                 try {
703
+                    assocOutcomeCounter= parseInt($("#assocOutcomeGroup").data('value'));
817 704
                     for (var i = assocOutcomeCounter - 1; i > 0; i--) {
818 705
                         deleteLast("assoc_outcomeForm" + i.toString() , "assocOutcomeGroup", "assoc_close" + i.toString() ,"assoc_objectiveGroup");
819 706
                                }
@@ -838,17 +725,17 @@ $('.filterSection').hide();
838 725
 
839 726
                 }
840 727
 
841
-
728
+                counterObj =$('#assoc_objectiveGroup').data('value');
842 729
 
843 730
 
844 731
                 try {
845 732
                     for (var i = counterObj - 1; i > 0; i--) {
846
-                        deleteObjective('objectiveForm' + i.toString(), 'closeObj' + i.toString())
733
+                        deleteObjective('assoc_objectiveForm' + i.toString(), 'assoc_closeObj' + i.toString(), 'assoc_objectiveGroup')
847 734
                     }
848 735
                 } catch (err) {
849 736
                     var noEntro = true;
850 737
                 }
851
-                counterObj = 1;
738
+                $('#assoc_objectiveGroup').data('value', 1);
852 739
 
853 740
 
854 741
 
@@ -856,32 +743,27 @@ $('.filterSection').hide();
856 743
 
857 744
                 assocOutcomeCounter = 0;
858 745
                 var i = 0;
859
-                for (var j = 0; j < json.outcomes.length; j++) {
860
-                    assocOutcomeCounter += 1;
861
-                    var optionName = '<optgroup id="' + 'Associated_Outcome' + (assocOutcomeCounter - 1).toString() + '"label="' + json.outcomes[j].name + '"';
862
-                    for (; i < json.objectives_outcome.length; i++) {
863
-                        if (json.objectives_outcome[i].outcome_id != json.outcomes[j].id) break;
864
-
865
-                        var option = '<option value ="' + json.objectives_outcome[i].id.toString() + '">' + json.objectives_outcome[i].text + '</option>'
866
-                        optionName += (option)
867
-
868
-                    }
869
-                    optGroup = document.getElementById('Associated_Outcome' + (assocOutcomeCounter - 1).toString());
870
-                    if (optGroup != null) {
871
-                        optGroup.remove()
746
+                optionName = '';
747
+                for(outcome in json.outcomes_assoc){
748
+                    optionName += '<optgroup label="' + json.outcomes_assoc[outcome][0].name + '"';
749
+                    var objectiveForOutcome = json.objectives_assoc;
750
+                    var objectives = objectiveForOutcome[outcome];
751
+                    for (objective in objectives) {
752
+                
872 753
 
754
+                        var obj= objectives[objective];
755
+                        var option = '<option value ="' + obj.id + '">' +obj.text + '</option>';
756
+                        optionName += (option);
873 757
                     }
874
-                    $('#assoc_objective_0').append(optionName);
875
-                    $('#assoc_objective_0').selectpicker('refresh');
876 758
                 }
759
+                $('#assoc_objective_0').html(optionName);
877 760
 
761
+                $('#assoc_objective_0').selectpicker('refresh');  
878 762
 
879 763
 
880 764
 
881
-                for (var i = assocObjectiveCounter - 1; i > 0; i--) {
882
-                    deleteObjective('assoc_objectiveForm' + i.toString(), 'assoc_closeObj' + i.toString())
883
-                }
884
-                assocObjectiveCounter = 1;
765
+
766
+        
885 767
 
886 768
 
887 769
 
@@ -903,8 +785,7 @@ $('.filterSection').hide();
903 785
                     $('#assoc_objective_' + i.toString()).val(json.objectives[i].id);
904 786
                     $('#assoc_objective_' + i.toString()).selectpicker('refresh');
905 787
                 }
906
-                assocObjectiveCounter = json.objectives.length;
907
-
788
+                $('assoc_objectiveGroup').data('value',json.objectives.length);
908 789
 
909 790
                 
910 791
 
@@ -916,62 +797,7 @@ $('.filterSection').hide();
916 797
                 // Select status
917 798
 
918 799
 
919
-                scaleLength = json.scales.length;
920
-                fullDiv = '';
921
-                if (!scaleLength) {
922
-                    div = '<div id="assoc_eval 0"">' +
923
-                        '<div class ="form-row">' +
924
-                        '<label for="header0">Evaluación 1</label><br><br>' +
925
-                        '<input type="hidden"  id="header0">' +
926
-                        '<div class="form-group col-md-8" >' +
927
-                        '<label for="title0">Nombre de Evaluación 1</label>' +
928
-                        '<input class="form-control" name="assoc_title[]" value =" "type="text"  id="title0" placeholder ="Nombre de evaluacion" ></div>' +
929
-                        '<div class ="form-group col-md-2">' +
930
-                        '<label for="min0">Mínimo </label>' +
931
-                        '<input class="form-control" type="number" id="assoc_min0" min="1" max = "1" value =" " name = "assoc_min[]"></div>' +
932
-                        '<div class ="form-group col-md-2">' +
933
-                        '<label for="max">Máximo </label>' +
934
-                        '<input class="form-control" type="number" id="assoc_max" min="1" max = "" value =" " name = "assoc_max[]"></div></div>' +
935
-                        '<div class ="form-group">' +
936
-                        '<label for ="descripcion">Descripción de evaluación</label>' +
937
-                        '<textarea class="form-control" rows="2" aria-labelledby="descripcion" name="assoc_scales[]" cols="50" ></textarea></div></div>';
938
-                    fullDiv += div;
939
-                } else {
940
-                    var dataValue = parseInt($('#Assoc_Scales').attr('data-value'));
941
-                    $('#assoc_maximum_score').val(json.criteria[0].maximum_score);
942
-                    var maximum = json.criteria[0].maximum_score;
943
-
944
-
945
-                    $('#Assoc_Scales').html(' ');
946
-                    for (var i = 0; i < scaleLength; i++) {
947
-
948
-                        div = '<div id="assoc_eval' + i.toString() + '">' +
949
-                            '<div class ="form-row">' +
950
-                            '<label for="header' + (i).toString() + '">Evaluación ' + (i + 1).toString() + '</label><br><br>' +
951
-                            '<input type="hidden"  id="header' + i.toString() + '">' +
952
-                            '<div class="form-group col-md-8" >' +
953
-                            '<label for="title' + i.toString() + '">Nombre de Evaluación ' + (i + 1).toString() + '</label>' +
954
-                            '<input class="form-control" name="assoc_title[]" value ="' + json.scales[i].title + '"type="text"  id="title' + i.toString() + '" placeholder ="Nombre de evaluacion" ></div>' +
955
-                            '<div class ="form-group col-md-2">' +
956
-                            '<label for="min' + i.toString() + '">Mínimo </label>' +
957
-                            '<input class="form-control" type="number" id="assoc_min' + i.toString() + '" min="1" max = "' + maximum + '" value ="' + json.scales[i].min_score + '"oninput ="changedMin(' + "'assoc_min" + i.toString() + "', '" + i.toString() + "', 'Assoc_Scales' " + ')" name = "assoc_min[]"></div>' +
958
-                            '<div class ="form-group col-md-2">' +
959
-                            '<label for="max' + i.toString() + '">Máximo </label>' +
960
-                            '<input class="form-control" type="number" id="assoc_max' + i.toString() + '" min="1" max = "' + maximum + '" value ="' + json.scales[i].max_score + '"oninput ="changedMax(' + "'assoc_max" + i.toString() + "', '" + i.toString() + "', 'Assoc_Scales' " + ')" name = "assoc_max[]"></div></div>' +
961
-                            '<div class ="form-group">' +
962
-                            '<label for ="descripcion' + i.toString() + '">Descripción de evaluación</label>' +
963
-                            '<textarea class="form-control" rows="2" aria-labelledby="descripcion' + i.toString() + '" name="assoc_scales[]" cols="50" >' + json.scales[i].description + '</textarea></div></div>';
964
-                        fullDiv += div;
965
-
966
-                    }
967
-                }
968
-
969
-                addOptions('Num_assoc_scale', 'assoc_maximum_score');
970
-
971
-                $('#Assoc_Scales').append(fullDiv);
972
-                $('#Assoc_Scales').attr('data-value', scaleLength);
973
-                $('#Num_assoc_scale').val(scaleLength);
974
-                $('#Num_assoc_scale').selectpicker('refresh')
800
+             
975 801
 
976 802
 
977 803
 
@@ -1000,7 +826,7 @@ fetchObjectiveForSelect('outcomeGroup', 'objectiveGroup');
1000 826
 // setCriterionStatus();
1001 827
 
1002 828
 
1003
-
829
+fetchAllCriterion("select-program", "assoc_outcomes_fetch");
1004 830
 
1005 831
 // --------------------------------------------------------------------------
1006 832
 // Functions
@@ -1053,10 +879,10 @@ $('.panel-group .panel-heading').on('click', function()
1053 879
 $(this).next().stop().slideToggle();
1054 880
 })
1055 881
 
1056
-$('#outcome[0]').on('change', function(){
882
+//$('#outcome[0]').on('change', function(){
1057 883
 
1058
-$('.selectpicker').selectpicker('refresh');
1059
-})
884
+//$('.selectpicker').selectpicker('refresh');
885
+//})
1060 886
 // When list item is clicked, load corresponding info
1061 887
 
1062 888
 

+ 73
- 1
app/views/local/managers/pCoords/objectives.blade.php Целия файл

@@ -65,8 +65,30 @@
65 65
             <div class="panel-heading">
66 66
                 Edit
67 67
             </div>
68
+            <button class="btn btn-md btn-secondary filterButton">
69
+                <span class="glyphicon glyphicon-plus">
70
+                </span>
71
+                Filters
72
+              </button>
68 73
             <div class="panel-body">
69
-                {{ Form::open(array('action' => 'Objective2Controller@update')) }}
74
+                <div class='filterSection'>
75
+            
76
+                    {{ Form::open(array('action' => 'Objective2Controller@update')) }}
77
+                    
78
+                    <div class="form-group">
79
+                        {{ Form::label('program_id2', 'Associated Program')}}
80
+                        <select id='select-program' class="form-control selectpicker" onchange='fetchAllObjectives("select-program", "assoc_outcomes_fetch")'>
81
+                            @foreach ($programs as $program)
82
+                            <option value='{{$program->id}}' data-subtext="{{$program->code}}">{{$program->name}}</option>
83
+                            @endforeach
84
+                        </select>
85
+                    </div>
86
+                    <div class="form-group">
87
+                        <label>Associated Outcome</label>
88
+                        {{ Form::select('assoc_outcome_fetch', $outcomes, null, ['class'=>'form-control selectpicker', 'id'=>'assoc_outcomes_fetch', 'onchange'=>'fetchAllObjectives("select-program", "assoc_outcomes_fetch")']) }}
89
+    
90
+                    </div>
91
+                      </div>
70 92
 
71 93
                 <div class="form-group">
72 94
                     {{ Form::label('objective_id', 'Objectives') }}
@@ -133,8 +155,17 @@
133 155
                     {{ Form::label('text', 'Text') }}
134 156
                     {{ Form::text('text', Input::old('text'), array('class' => 'form-control', 'id'=>'objective-text')) }}
135 157
                 </div>
158
+                <div id="text">
159
+
160
+                </div>
161
+
136 162
                 {{ Form::submit('Update', array('class' => 'btn btn-primary btn-block')) }}
137 163
                 {{ Form::close() }}
164
+
165
+                <form action="/deleteObjective" method="POST" id='deleteObj'>
166
+                
167
+                    
168
+                </form>
138 169
             </div>
139 170
 
140 171
 
@@ -145,9 +176,48 @@
145 176
     </div>
146 177
 </div>
147 178
 <script>
179
+
180
+$('.filterSection').hide();
181
+	
182
+    $('.filterButton').on('click', function()
183
+{
184
+  var span = $(this).find('span');
185
+  if(span.attr('class') == 'glyphicon glyphicon-plus'){
186
+    span.attr('class','glyphicon glyphicon-minus');
187
+  } else{	
188
+    span.attr('class','glyphicon glyphicon-plus');
189
+	
190
+  }
191
+
192
+  $('.filterSection').toggle(533);
193
+
194
+});
148 195
     var outcomeHTML = document.getElementById('outcomeGroup').innerHTML;
149 196
     var selectOptions = document.getElementById('outcome[0]').innerHTML;
150 197
     var ran = false;
198
+   
199
+    function fetchAllObjectives(program, outcome) {
200
+        var program_id_fetch = $('#' + program).find(':selected').val();
201
+        var outcome_fetch = $('#' + outcome).find(':selected').val();
202
+        $.post(
203
+            "{{URL::action('Objective2Controller@fetchAllObjectives')}}", {
204
+                program_fetch: program_id_fetch,
205
+                outcome_fetch: outcome_fetch
206
+            },
207
+            function(json) {
208
+                json_length = (json.objective.length);
209
+                fullHTML = '';
210
+                for (var i = 0; i < json_length; i++) {
211
+                    fullHTML += '<option value="' + json.objective[i].id + '">' + json.objective[i].text + '</option>';
212
+                }
213
+                $('#select-objective').html(fullHTML);
214
+                $('#select-objective').selectpicker('refresh');
215
+                fetchObjectiveForEditing();
216
+
217
+            },
218
+            'json'
219
+        );
220
+    }
151 221
 
152 222
     var counter = 1;
153 223
     var counterAssoc = 1;
@@ -427,6 +497,8 @@ fetchObjectiveForEditing();
427 497
 // setCriterionStatus();
428 498
 
429 499
 
500
+ 
501
+fetchAllObjectives("select-program", "assoc_outcomes_fetch")
430 502
 
431 503
 
432 504
 // --------------------------------------------------------------------------

+ 41
- 240
app/views/local/managers/sCoords/criteria.blade.php Целия файл

@@ -14,11 +14,11 @@
14 14
             </div>
15 15
             <div class="panel-body">
16 16
                 {{ Form::open(array('action' => 'CriteriaController@create')) }}
17
-                <div id='outcomeGroup'>
17
+                <div id='outcomeGroup' data-value='1'>
18 18
                     <div class="form-group col-md-11">
19 19
                         <label>Associated Outcomes</label>
20 20
 
21
-                        {{ Form::select('outcome[]', $outcomes, reset($outcomes),  ['class'=>'form-control selectpicker', 'id' =>'outcome0', 'onchange'=>'fetchObjectiveForSelect("outcome0")']) }}
21
+                        {{ Form::select('outcome[]', $outcomes, reset($outcomes),  ['class'=>'form-control selectpicker', 'id' =>'outcome0', 'onchange'=>'fetchObjectiveForSelect("outcomeGroup", "objectiveGroup")']) }}
22 22
 
23 23
                     </div>
24 24
                 </div>
@@ -29,7 +29,7 @@
29 29
                     </span>
30 30
                     Add another Outcome
31 31
                 </button>
32
-                <div id='objectiveGroup'>
32
+                <div id='objectiveGroup' data-value ="1">
33 33
                     <div class="form-group">
34 34
                         <label>Associated Objectives</label>
35 35
                         <select id="objective_0" name="objective[]" class="form-control selectpicker">
@@ -68,19 +68,7 @@
68 68
                     <p class="help-block"><strong>Manually add</strong> bullets or numbering.</p>
69 69
                     {{ Form::textarea('subcriteria', '', array('class' => 'form-control', 'rows'=>3, 'aria-labelledby'=>'subcriteria')) }}
70 70
                 </div>
71
-                <div class="form-group">
72
-                    {{ Form::label('maximum_score', 'Maximum Score') }}
73
-                    {{ Form::text('maximum_score', '1', array('class' => 'form-control', 'id'=>'maximum_score', 'oninput'=>'addOptions("Num_scale", "maximum_score", "Scales")')) }}
74
-                </div>
75
-                <div class="form-group">
76
-                    {{ Form::label('scales', 'Number of Scales') }}
77
-                    <select id="Num_scale" name="scales" class="form-control selectpicker" onchange='numberOfScales("Num_scale", "Scales")'>
78
-
79
-                    </select>
80
-                </div>
81
-                <div id='Scales' data-value="0">
82
-
83
-                </div>
71
+                
84 72
 
85 73
 
86 74
                 <div class="form-group">
@@ -146,7 +134,7 @@
146 134
                 </div>
147 135
 
148 136
                 <!-- Associated Outcome -->
149
-                <div id='assocOutcomeGroup'>
137
+                <div id='assocOutcomeGroup' data-value='1'>
150 138
                     <div class="form-group">
151 139
                         <label>Associated Outcome</label>
152 140
                         {{ Form::select('assoc_outcome[]', $outcomes, null, ['class'=>'form-control selectpicker', 'id'=>'assoc_outcome_0', 'onchange'=>'fetchAssocObjective("assoc_outcome_0")']) }}
@@ -160,10 +148,11 @@
160 148
                     Add another Outcome
161 149
                 </button>
162 150
 
163
-                <div id='assoc_objectiveGroup'>
151
+                <div id='assoc_objectiveGroup' data-value='1'>
164 152
                     <div class="form-group">
165 153
                         <label>Associated Objectives</label>
166 154
                         <select id="assoc_objective_0" name="assoc_objective[]" class="form-control selectpicker">
155
+                            <option value="0">No associated objectives</option>
167 156
                         </select>
168 157
 
169 158
                     </div>
@@ -211,22 +200,7 @@
211 200
                     {{ Form::textarea('subcriteria', '', array('class' => 'form-control', 'rows'=>3, 'id' => 'criterion_subcriteria')) }}
212 201
                 </div>
213 202
 
214
-                <div class="form-group">
215
-                    {{ Form::label('assoc_maximum_score', 'Maximum Score') }}
216
-                    {{ Form::text('assoc_maximum_score', '', array('class' => 'form-control', 'id'=>'assoc_maximum_score', 'oninput'=>'addOptions("Num_assoc_scale", "assoc_maximum_score", "Assoc_Scales")')) }}
217
-                </div>
218
-
219
-
220
-                <div class="form-group">
221
-                    {{ Form::label('scales', 'Number of Scales') }}
222
-                    <select id="Num_assoc_scale" class="form-control selectpicker" onchange='numberOfAssoc("Num_assoc_scale", "Assoc_Scales")'>
223
-
224
-                    </select>
225
-                </div>
226
-                <div id='Assoc_Scales' data-value="0">
227
-
228
-                </div>
229
-
203
+                
230 204
 
231 205
                 <div class="form-group">
232 206
                     {{ Form::label('copyright', 'Copyright Information') }}
@@ -237,18 +211,29 @@
237 211
                     {{ Form::label('notes', 'Additional Notes') }}
238 212
                     {{ Form::textarea('notes', Input::old('notes'), array('class' => 'form-control', 'rows'=>2, 'id'=>'criterion_notes', 'placeholder'=>'(optional)')) }}
239 213
                 </div>
240
-                <div id='delete'>
241
-
242
-                </div>
214
+                
243 215
                 {{ Form::submit('Update', array('class' => 'btn btn-primary btn-block')) }}
244 216
                 {{ Form::close() }}
245 217
 
218
+                {{ Form::open(array('action' => 'CriteriaController@delete')) }}
219
+	
220
+                <input type='hidden' name='criterion_delete' id='deleteCriteria'>
221
+
222
+                {{Form::submit("Delete", array('class'=> 'btn btn-primary btn-block', 'id'=>"DeleteButton"))}}
223
+
246 224
 
247 225
             </div>
248 226
         </div>
249 227
     </div>
250 228
 </div>
251 229
 <script>
230
+
231
+    var selectOptions = document.getElementById('outcome0').innerHTML;
232
+
233
+    var counter = 1;
234
+    var counterObj = 1;
235
+    var outcomeString = 'OutcomeGroup_';
236
+   
252 237
     $('.filterSection').hide();
253 238
     $('.filterButton').on('click', function()
254 239
 {
@@ -260,146 +245,8 @@
260 245
   }
261 246
   $('.filterSection').toggle(533);
262 247
 });
263
-    var selectOptions = document.getElementById('outcome0').innerHTML;
264
-
265
-    var counter = 1;
266
-    var counterObj = 1;
267
-    var outcomeString = 'OutcomeGroup_';
268
-    $(document).ready(function() {
269
-        addOptions('Num_scale', 'maximum_score', 'Scales');
270
-        numberOfScales('Num_scale', 'Scales');
271
-    });
272
-
273
-
274
-    function numberOfAssoc(string, Scales) {
275
-        var maximum = $('#assoc_maximum_score').val();
276
-        var amountOfScale = parseInt($('#' + string).val());
277
-        var dataValue = parseInt($('#' + Scales).attr('data-value'));
278
-        //add
279
-        if (dataValue < amountOfScale) {
280
-
281
-            fullDiv = '';
282
-
283
-            for (var i = dataValue; i < amountOfScale; i++) {
284
-                div = '<div id="assoc_eval' + i.toString() + Scales + '">' +
285
-                    '<div class ="form-row">' +
286
-                    '<label for="header' + (i).toString() + '">Evaluación ' + (i + 1).toString() + '</label><br><br>' +
287
-                    '<input type="hidden"  id="header' + i.toString() + '">' +
288
-                    '<div class="form-group col-md-8" >' +
289
-                    '<label for="title' + i.toString() + '">Nombre de Evaluación ' + (i + 1).toString() + '</label>' +
290
-                    '<input class="form-control" name="assoc_title[]" type="text"  id="title' + i.toString() + '" placeholder ="Nombre de evaluacion" ></div>' +
291
-                    '<div class ="form-group col-md-2">' +
292
-                    '<label for="min' + i.toString() + '">Mínimo </label>' +
293
-                    '<input class="form-control" type="number" id="assoc_min' + i.toString() + '" min="1" max = "' + maximum + '" oninput ="changedMin(' + "'assoc_min" + i.toString() + "', '" + i.toString() + "', 'Assoc_Scales' " + ')" name = "assoc_min[]"></div>' +
294
-                    '<div class ="form-group col-md-2">' +
295
-                    '<label for="max' + i.toString() + '">Máximo </label>' +
296
-                    '<input class="form-control" type="number" id="assoc_max' + i.toString() + '" min="1" max = "' + maximum + '" oninput ="changedMax(' + "'assoc_max" + i.toString() + "', '" + i.toString() + "', 'Assoc_Scales' " + ')" name = "assoc_max[]"></div></div>' +
297
-                    '<div class ="form-group">' +
298
-                    '<label for ="descripcion' + i.toString() + '">Descripción de evaluación</label>' +
299
-                    '<textarea class="form-control" rows="2" aria-labelledby="descripcion' + i.toString() + '" name="assoc_scales[]" cols="50" ></textarea></div></div>';
300
-                fullDiv += div;
301
-
302
-
303
-            }
304
-
305
-            $('#' + Scales).append(fullDiv);
306
-            $('#' + Scales).attr('data-value', amountOfScale);
307
-        } else {
308
-            for (var i = dataValue; i > amountOfScale; i--) {
309
-                $('#assoc_eval' + (i - 1).toString()).remove();
310
-            }
311
-        }
312
-        $('#' + Scales).attr('data-value', amountOfScale);
313
-
314
-    }
315
-
316
-    function addOptions(select, max, scaleDiv) {
317
-        var maxscore = parseInt($('#' + max).val())
318
-        options = '';
319
-        for (var i = 1; i <= maxscore; i++) {
320
-            options += '<option value="' + i.toString() + '">' + i.toString() + '</option>';
321
-
322
-        }
323
-
324
-        var previousvalue = parseInt($('#' + select).val());
325
-        $('#' + select).html(options);
326
-        $('#' + select).val(previousvalue);
327
-        $('#' + select).selectpicker('refresh');
328
-
329
-        var attribute = parseInt($('#' + scaleDiv).attr('data-value'));
330
-
331
-        for (var i = 0; i < attribute; i++) {
332
-            $('#max' + i.toString()).attr('max', maxscore);
333
-            $('#min' + i.toString()).attr('max', maxscore);
334
-        }
335
-
336
-    }
337
-
338
-
339
-
340
-    function numberOfScales(string, Scales) {
341
-        var maximum = $('#maximum_score').val();
342
-        var amountOfScale = parseInt($('#' + string).val());
343
-        var dataValue = parseInt($('#' + Scales).attr('data-value'));
344
-        //add
345
-        if (dataValue < amountOfScale) {
346
-
347
-            fullDiv = '';
348
-
349
-            for (var i = dataValue; i < amountOfScale; i++) {
350
-                div = '<div id="eval' + i.toString() + Scales + '">' +
351
-                    '<div class ="form-row">' +
352
-                    '<label for="header' + (i).toString() + '">Evaluación ' + (i + 1).toString() + '</label><br><br>' +
353
-                    '<input type="hidden"  id="header' + i.toString() + '">' +
354
-                    '<div class="form-group col-md-8" >' +
355
-                    '<label for="title' + i.toString() + '">Nombre de Evaluación ' + (i + 1).toString() + '</label>' +
356
-                    '<input class="form-control" name="title[]" type="text"  id="title' + i.toString() + '" placeholder ="Nombre de evaluacion" ></div>' +
357
-                    '<div class ="form-group col-md-2">' +
358
-                    '<label for="min' + i.toString() + '">Mínimo </label>' +
359
-                    '<input class="form-control" type="number" id="min' + i.toString() + '" min="1" max = "' + maximum + '" oninput ="changedMin(' + "'min" + i.toString() + "', '" + i.toString() + "', 'Scales' " + ')" name = "min[]"></div>' +
360
-                    '<div class ="form-group col-md-2">' +
361
-                    '<label for="max' + i.toString() + '">Máximo </label>' +
362
-                    '<input class="form-control" type="number" id="max' + i.toString() + '" min="1" max = "' + maximum + '" oninput ="changedMax(' + "'max" + i.toString() + "', '" + i.toString() + "', 'Scales' " + ')" name = "max[]"></div></div>' +
363
-                    '<div class ="form-group">' +
364
-                    '<label for ="descripcion' + i.toString() + '">Descripción de evaluación</label>' +
365
-                    '<textarea class="form-control" rows="2" aria-labelledby="descripcion' + i.toString() + '" name="' + Scales + '[]" cols="50" ></textarea></div></div>';
366
-                fullDiv += div;
367
-            }
368
-
369
-            $('#' + Scales).append(fullDiv);
370
-
371
-        } else {
372
-            for (var i = dataValue; i > amountOfScale; i--) {
373
-                $('#eval' + (i - 1).toString() + Scales).remove();
374
-            }
375
-        }
376
-        $('#' + Scales).attr('data-value', amountOfScale);
377
-
378
-    }
379
-
380
-    function changedMin(min, index, scaleDiv) {
381
-        var maximum = parseInt($('#' + min).val()) + 1;
382
-        var maxScaleScore = parseInt($('#' + scaleDiv).attr('data-value'));
383
-
384
-        for (var i = parseInt(index); i < maxScaleScore; i++) {
385
-            $('#max' + i).attr('min', maximum);
386
-
387
-        }
388
-
389
-    }
390
-
391
-    function changedMax(max, index, scaleDiv) {
392
-        var maximum = parseInt($('#' + max).val()) + 1;
393
-        var maxScaleScore = parseInt($('#' + scaleDiv).attr('data-value'));
394
-
395
-        for (var i = parseInt(index) + 1; i < maxScaleScore; i++) {
396
-            $('#min' + i).attr('min', maximum)
397
-
398
-        }
399
-
400
-
401
-    }
402 248
 
249
+ 
403 250
     //Add outcome Button
404 251
     function addOutcomeTest() {
405 252
         counter = parseInt($('#outcomeGroup').data("value"));
@@ -522,7 +369,7 @@
522 369
     function addObjectiveTest() {
523 370
         selectObj = document.getElementById('objective_0').innerHTML;
524 371
         counter = $("#objectiveGroup").data('value');
525
-        $('#objectiveGroup')
372
+       
526 373
         var $select = $('<select/>', {
527 374
             'class': "selectpicker form-control",
528 375
             'name': "objective[]",
@@ -750,7 +597,7 @@
750 597
 
751 598
     //after post
752 599
 
753
-    fetchAllCriterion("select-program", "assoc_outcomes_fetch");
600
+
754 601
     //For editing criterion
755 602
     function fetchAllCriterion(program, outcome) {
756 603
         var program_id_fetch = $('#' + program).find(':selected').val();
@@ -800,10 +647,10 @@
800 647
 
801 648
                 if (!(json.activity_criterion.length)) {
802 649
 
803
-                    $('#DeleteButton').prop('disabled', true);
650
+                    $('#DeleteButton').prop('enabled', true);
804 651
 
805 652
                 } else {
806
-                    $('#DeleteButton').prop('enabled', true);
653
+                    $('#DeleteButton').prop('disabled', true);
807 654
                 }
808 655
 
809 656
                 if (!(json.criteria.length)) {
@@ -961,64 +808,6 @@
961 808
                 // Select status
962 809
 
963 810
 
964
-                scaleLength = json.scales.length;
965
-                fullDiv = '';
966
-                if (!scaleLength) {
967
-                    div = '<div id="assoc_eval 0"">' +
968
-                        '<div class ="form-row">' +
969
-                        '<label for="header0">Evaluación 1</label><br><br>' +
970
-                        '<input type="hidden"  id="header0">' +
971
-                        '<div class="form-group col-md-8" >' +
972
-                        '<label for="title0">Nombre de Evaluación 1</label>' +
973
-                        '<input class="form-control" name="assoc_title[]" value =" "type="text"  id="title0" placeholder ="Nombre de evaluacion" ></div>' +
974
-                        '<div class ="form-group col-md-2">' +
975
-                        '<label for="min0">Mínimo </label>' +
976
-                        '<input class="form-control" type="number" id="assoc_min0" min="1" max = "1" value =" " name = "assoc_min[]"></div>' +
977
-                        '<div class ="form-group col-md-2">' +
978
-                        '<label for="max">Máximo </label>' +
979
-                        '<input class="form-control" type="number" id="assoc_max" min="1" max = "" value =" " name = "assoc_max[]"></div></div>' +
980
-                        '<div class ="form-group">' +
981
-                        '<label for ="descripcion">Descripción de evaluación</label>' +
982
-                        '<textarea class="form-control" rows="2" aria-labelledby="descripcion" name="assoc_scales[]" cols="50" ></textarea></div></div>';
983
-                    fullDiv += div;
984
-                } else {
985
-                    var dataValue = parseInt($('#Assoc_Scales').attr('data-value'));
986
-                    $('#assoc_maximum_score').val(json.criteria[0].maximum_score);
987
-                    var maximum = json.criteria[0].maximum_score;
988
-
989
-
990
-                    $('#Assoc_Scales').html(' ');
991
-                    for (var i = 0; i < scaleLength; i++) {
992
-
993
-                        div = '<div id="assoc_eval' + i.toString() + '">' +
994
-                            '<div class ="form-row">' +
995
-                            '<label for="header' + (i).toString() + '">Evaluación ' + (i + 1).toString() + '</label><br><br>' +
996
-                            '<input type="hidden"  id="header' + i.toString() + '">' +
997
-                            '<div class="form-group col-md-8" >' +
998
-                            '<label for="title' + i.toString() + '">Nombre de Evaluación ' + (i + 1).toString() + '</label>' +
999
-                            '<input class="form-control" name="assoc_title[]" value ="' + json.scales[i].title + '"type="text"  id="title' + i.toString() + '" placeholder ="Nombre de evaluacion" ></div>' +
1000
-                            '<div class ="form-group col-md-2">' +
1001
-                            '<label for="min' + i.toString() + '">Mínimo </label>' +
1002
-                            '<input class="form-control" type="number" id="assoc_min' + i.toString() + '" min="1" max = "' + maximum + '" value ="' + json.scales[i].min_score + '"oninput ="changedMin(' + "'assoc_min" + i.toString() + "', '" + i.toString() + "', 'Assoc_Scales' " + ')" name = "assoc_min[]"></div>' +
1003
-                            '<div class ="form-group col-md-2">' +
1004
-                            '<label for="max' + i.toString() + '">Máximo </label>' +
1005
-                            '<input class="form-control" type="number" id="assoc_max' + i.toString() + '" min="1" max = "' + maximum + '" value ="' + json.scales[i].max_score + '"oninput ="changedMax(' + "'assoc_max" + i.toString() + "', '" + i.toString() + "', 'Assoc_Scales' " + ')" name = "assoc_max[]"></div></div>' +
1006
-                            '<div class ="form-group">' +
1007
-                            '<label for ="descripcion' + i.toString() + '">Descripción de evaluación</label>' +
1008
-                            '<textarea class="form-control" rows="2" aria-labelledby="descripcion' + i.toString() + '" name="assoc_scales[]" cols="50" >' + json.scales[i].description + '</textarea></div></div>';
1009
-                        fullDiv += div;
1010
-
1011
-                    }
1012
-                }
1013
-
1014
-                addOptions('Num_assoc_scale', 'assoc_maximum_score');
1015
-
1016
-                $('#Assoc_Scales').append(fullDiv);
1017
-                $('#Assoc_Scales').attr('data-value', scaleLength);
1018
-                $('#Num_assoc_scale').val(scaleLength);
1019
-                $('#Num_assoc_scale').selectpicker('refresh')
1020
-
1021
-
1022 811
 
1023 812
 
1024 813
 
@@ -1042,7 +831,7 @@ $('#outcome-display').parent().hide();
1042 831
 fetchCriterionForEditing();
1043 832
 fetchObjectiveForSelect('outcomeGroup', 'objectiveGroup');
1044 833
 // setCriterionStatus();
1045
-
834
+fetchAllCriterion("select-program", "assoc_outcomes_fetch");
1046 835
 
1047 836
 
1048 837
 
@@ -1089,7 +878,19 @@ $('.panel-group .panel-heading').on('click', function()
1089 878
 {
1090 879
 $(this).next().stop().slideToggle();
1091 880
 })
1092
-
881
+$('.filterButton').on('click', function(e) {
882
+    
883
+        // Prevent the default action of the clicked item. In this case that is submit
884
+    
885
+        e.preventDefault();
886
+    
887
+        
888
+    
889
+        
890
+    
891
+        return false;
892
+    
893
+        });
1093 894
 //$('#outcome[0]').on('change', function(){
1094 895
 //fetchObjectiveForSelect(0);
1095 896
 //$('.selectpicker').selectpicker('refresh');

+ 70
- 1
app/views/local/managers/sCoords/objectives.blade.php Целия файл

@@ -65,9 +65,30 @@
65 65
             <div class="panel-heading">
66 66
                 Edit
67 67
             </div>
68
-            <div class="panel-body">
68
+            <button class="btn btn-md btn-secondary filterButton">
69
+                <span class="glyphicon glyphicon-plus">
70
+                </span>
71
+                Filters
72
+              </button>
73
+              <div class="panel-body">
74
+              <div class='filterSection'>
75
+            
69 76
                 {{ Form::open(array('action' => 'Objective2Controller@update')) }}
77
+                
78
+                <div class="form-group">
79
+                    {{ Form::label('program_id2', 'Associated Program')}}
80
+                    <select id='select-program' class="form-control selectpicker" onchange='fetchAllObjectives("select-program", "assoc_outcomes_fetch")'>
81
+                        @foreach ($programs as $program)
82
+                        <option value='{{$program->id}}' data-subtext="{{$program->code}}">{{$program->name}}</option>
83
+                        @endforeach
84
+                    </select>
85
+                </div>
86
+                <div class="form-group">
87
+                    <label>Associated Outcome</label>
88
+                    {{ Form::select('assoc_outcome_fetch', $outcomes, null, ['class'=>'form-control selectpicker', 'id'=>'assoc_outcomes_fetch', 'onchange'=>'fetchAllObjectives("select-program", "assoc_outcomes_fetch")']) }}
70 89
 
90
+                </div>
91
+                  </div>
71 92
                 <div class="form-group">
72 93
                     {{ Form::label('objective_id', 'Objectives') }}
73 94
                     <select id="select-objective" name="id" class="form-control selectpicker">
@@ -131,8 +152,16 @@
131 152
                     {{ Form::label('text', 'Text') }}
132 153
                     {{ Form::text('text', Input::old('text'), array('class' => 'form-control', 'id'=>'objective-text')) }}
133 154
                 </div>
155
+                <div id="text">
156
+
157
+                </div>
158
+
134 159
                 {{ Form::submit('Update', array('class' => 'btn btn-primary btn-block')) }}
135 160
                 {{ Form::close() }}
161
+                <form action="/deleteObjective" method="POST" id='deleteObj'>
162
+                
163
+                    
164
+                                    </form>
136 165
             </div>
137 166
 
138 167
 
@@ -142,8 +171,47 @@
142 171
     </div>
143 172
 </div>
144 173
 <script>
174
+        $('.filterSection').hide();
175
+	
176
+    $('.filterButton').on('click', function()
177
+{
178
+  var span = $(this).find('span');
179
+  if(span.attr('class') == 'glyphicon glyphicon-plus'){
180
+    span.attr('class','glyphicon glyphicon-minus');
181
+  } else{	
182
+    span.attr('class','glyphicon glyphicon-plus');
183
+	
184
+  }
185
+
186
+  $('.filterSection').toggle(533);
187
+
188
+});
145 189
     var outcomeHTML = document.getElementById('outcomeGroup').innerHTML;
146 190
     var selectOptions = document.getElementById('outcome[0]').innerHTML;
191
+
192
+    
193
+    function fetchAllObjectives(program, outcome) {
194
+        var program_id_fetch = $('#' + program).find(':selected').val();
195
+        var outcome_fetch = $('#' + outcome).find(':selected').val();
196
+        $.post(
197
+            "{{URL::action('Objective2Controller@fetchAllObjectives')}}", {
198
+                program_fetch: program_id_fetch,
199
+                outcome_fetch: outcome_fetch
200
+            },
201
+            function(json) {
202
+                json_length = (json.objective.length);
203
+                fullHTML = '';
204
+                for (var i = 0; i < json_length; i++) {
205
+                    fullHTML += '<option value="' + json.objective[i].id + '">' + json.objective[i].text + '</option>';
206
+                }
207
+                $('#select-objective').html(fullHTML);
208
+                $('#select-objective').selectpicker('refresh');
209
+                fetchObjectiveForEditing();
210
+
211
+            },
212
+            'json'
213
+        );
214
+    }
147 215
     var ran = false;
148 216
 
149 217
     var counter = 1;
@@ -430,6 +498,7 @@ $('#outcome-display').parent().hide();
430 498
 fetchObjectiveForEditing();
431 499
 // setCriterionStatus();
432 500
 
501
+fetchAllObjectives("select-program", "assoc_outcomes_fetch")
433 502
 
434 503
 
435 504
 

+ 2
- 4
app/views/local/managers/sCoords/view-annual-plans.blade.php Целия файл

@@ -106,9 +106,7 @@
106 106
         transformative:transformative, 
107 107
         annual_id: an_id}
108 108
         )
109
-     
110
-  
111
-                                 }
109
+    }
112 110
 
113 111
 
114 112
 function fetchInfoTrans(){
@@ -120,7 +118,7 @@ function fetchInfoTrans(){
120 118
                                     function(json){
121 119
                                       json_to_use = json;
122 120
                                       $('#report_print').click();
123
-                                       $('#trans_print').click();
121
+                                      $('#trans_print').click();
124 122
                                     },
125 123
                                     'json'
126 124