Gabriel Santiago Plaza vor 3 Jahren
Ursprung
Commit
e908550cd8

+ 3
- 2
app/controllers/Objective2Controller.php Datei anzeigen

@@ -294,7 +294,7 @@ class Objective2Controller extends \BaseController
294 294
 	public function edit()
295 295
 	{
296 296
 		$title = "Objective";
297
-		$outcomes = Outcome::whereNull("deactivation_date")->orderBy('name', 'ASC')->lists('name', 'id');
297
+		$outcomes = Outcome::whereNull("deactivation_date")->orderBy('name', 'ASC')->get();
298 298
 
299 299
 		$objectives = Objective::withTrashed()->orderBy('text', 'ASC')->get();
300 300
 		$programs = Program::orderBy('name', 'ASC')->get();
@@ -310,7 +310,7 @@ class Objective2Controller extends \BaseController
310 310
 		$userProgram = DB::select("select program_user.program_id from program_user where user_id = {$userProgram}");
311 311
 
312 312
 		$title = "Objective";
313
-		$outcomes = Outcome::whereNull("deactivation_date")->orderBy('name', 'ASC')->lists('name', 'id');
313
+		$outcomes = Outcome::whereNull("deactivation_date")->orderBy('name', 'ASC')->get();
314 314
 
315 315
 		$objectives = Objective::withTrashed()->orderBy('text', 'ASC')->get();
316 316
 
@@ -387,6 +387,7 @@ class Objective2Controller extends \BaseController
387 387
 
388 388
 
389 389
 			/** Set info */
390
+			Log::info($clean_input);
390 391
 			$Objective->text = $clean_input['text'];
391 392
 
392 393
 

+ 68
- 18
app/views/local/managers/admins/objectives.blade.php Datei anzeigen

@@ -19,8 +19,16 @@
19 19
                     <div class="form-group col-md-11" id='outcomeForm'>
20 20
 
21 21
 
22
-                        {{ Form::select('outcome[0]', $outcomes, null, ['class'=>'form-control selectpicker', 'id' =>'outcome[0]']) }}
23
-
22
+                        <select id="outcome[0]" name="outcome[0]" class="form-control selectpicker">
23
+                            @foreach ($outcomes as $outcome)
24
+                            <option value="{{ $outcome->id }}">
25
+                                {{ $outcome->name }}
26
+    
27
+    
28
+    
29
+                            </option>
30
+                            @endforeach
31
+                        </select>
24 32
                     </div>
25 33
 
26 34
                 </div>
@@ -84,10 +92,11 @@
84 92
                     </div>
85 93
                     <div class="form-group">
86 94
                         <label>Associated Outcome</label>
87
-                        {{ Form::select('assoc_outcomes_fetch', $outcomes, null, ['class'=>'form-control selectpicker', 'id'=>'assoc_outcomes_fetch', 'onchange'=>'fetchAllObjectives("select-program", "assoc_outcomes_fetch")']) }}
95
+                        {{ Form::select('assoc_outcome_fetch', $outcomes, null, ['class'=>'form-control selectpicker', 'id'=>'assoc_outcomes_fetch', 'onchange'=>'fetchAllObjectives("select-program", "assoc_outcomes_fetch")']) }}
88 96
 
89 97
                     </div>
90 98
                 </div>
99
+                <hr>
91 100
                 <div class="form-group">
92 101
                     {{ Form::label('objective_id', 'Objectives') }}
93 102
                     <select id="select-objective" name="id" class="form-control selectpicker">
@@ -113,8 +122,17 @@
113 122
                     <div id='assocOutcomeGroup'>
114 123
                         <label>Associated Outcome</label>
115 124
 
116
-                        {{ Form::select('outcome[]', $outcomes, null, ['class'=>'form-control selectpicker', 'id'=>'assoc_outcome0']) }}
117
-
125
+                        <select id="assoc_outcome0" name="assoc_outcome[]" class="form-control selectpicker">
126
+                            @foreach ($outcomes as $outcome)
127
+                            <option value="{{ $outcome->id }}">
128
+                                {{ $outcome->name }}
129
+    
130
+    
131
+    
132
+                            </option>
133
+                            @endforeach
134
+                        </select><br><br>
135
+                   
118 136
                     </div>
119 137
 
120 138
                 </div>
@@ -135,7 +153,7 @@
135 153
                     {{ Form::label('program_id2', 'Associated Program') }}<br><br>
136 154
                     @foreach ($programs as $program)
137 155
 
138
-                    <input type="checkbox" id="assoc_program_id_{{ $program->id }}" name="program_id[]" value="{{$program->id}}">
156
+                    <input type="checkbox" id="assoc_program_id_{{ $program->id }}" name="assoc_program_id[]" value="{{$program->id}}">
139 157
                     <label for="assoc_program_id_{{ $program->id }}"> {{ $program->name }} <sub>[{{ $program->school->name }}]</sub></label><br>
140 158
                     @endforeach
141 159
                 </div>
@@ -161,7 +179,7 @@
161 179
 
162 180
                 </div>
163 181
 
164
-                {{ Form::submit('Update', array('class' => 'btn btn-primary btn-block')) }}
182
+                {{ Form::submit('Update', array('class' => 'btn btn-primary btn-block', 'id' => 'update_button')) }}
165 183
                 {{ Form::close() }}
166 184
                 <form action="/deleteObjective" method="POST" id='deleteObj'>
167 185
 
@@ -299,7 +317,7 @@
299 317
 
300 318
                 // Select associated outcome
301 319
                 for (var i = counterAssoc; i != 1; i--) {
302
-                    deleteLastAssoc(i - 1);
320
+                    deleteLastAssoc(i);
303 321
 
304 322
                 }
305 323
                 $('#assoc_outcome0').val(json.outcome[0].outcome_id);
@@ -309,7 +327,7 @@
309 327
                     counterAssoc = i + 1;
310 328
                     var $select = $('<select />', {
311 329
                         'class': "selectpicker form-control",
312
-                        'name': "outcome[]",
330
+                        'name': "assoc_outcome[]",
313 331
                         'data-live-search': 'true',
314 332
                         'id': 'assoc_outcome' + i.toString()
315 333
 
@@ -326,7 +344,7 @@
326 344
                     var $button = $('<button />', {
327 345
                         'type': 'button',
328 346
                         'class': 'btn btn-primary',
329
-                        'onclick': 'deleteLastAssoc(' + i + ')'
347
+                        'onclick': 'deleteLastAssoc()'
330 348
                     });
331 349
                     $button.append('X');
332 350
                     $divForButton.append($button);
@@ -430,13 +448,14 @@
430 448
         );
431 449
     }
432 450
 
433
-    function deleteLastAssoc(i) {
451
+    function deleteLastAssoc() {
434 452
 
435
-        div = document.getElementById('assocOutcomeForm' + (i).toString());
436
-        div.remove();
437
-        button = document.getElementById('closeAssoc' + (i).toString());
438
-        button.remove();
439
-        counterAssoc -= 1;
453
+div = document.getElementById('assocOutcomeForm' + (counterAssoc -1).toString());
454
+div.remove();
455
+button = document.getElementById('closeAssoc' + (counterAssoc-1).toString());
456
+button.remove();
457
+counterAssoc -=1;
458
+$('#counterAssoc').val(counterAssoc);
440 459
 
441 460
     }
442 461
 
@@ -445,7 +464,7 @@
445 464
 
446 465
         var $select = $('<select />', {
447 466
             'class': "selectpicker form-control",
448
-            'name': "outcome[]",
467
+            'name': "assoc_outcome[]",
449 468
             'data-live-search': 'true',
450 469
             'id': 'assoc_outcome' + counterAssoc.toString()
451 470
 
@@ -462,7 +481,7 @@
462 481
         var $button = $('<button />', {
463 482
             'type': 'button',
464 483
             'class': 'btn btn-primary',
465
-            'onclick': 'deleteLastAssoc(' + counterAssoc + ')'
484
+            'onclick': 'deleteLastAssoc()'
466 485
         });
467 486
         $button.append('X');
468 487
         $divForButton.append($button);
@@ -476,9 +495,40 @@
476 495
 
477 496
 
478 497
         counterAssoc += 1;
498
+        $('#counterAssoc').val(counterAssoc);
479 499
 
480 500
 
481 501
     }
502
+    $('#update_button').on('click', function(e){
503
+        e.preventDefault();
504
+
505
+        outcome_id= []
506
+        program_id= [];
507
+        status = $('#status').val();
508
+        text =$('#objective-text').val();
509
+        id = $('#select-objective').val();
510
+
511
+        $('#assocOutcomeGroup').find('select').each(function(){
512
+            outcome_id.push($(this).val())
513
+        })
514
+        $('input[name="assoc_program_id[]"]').each(function(){
515
+            if(this.checked)
516
+            program_id.push($(this).val())
517
+        });
518
+        $.post(
519
+            "{{URL::action('Objective2Controller@update')}}",
520
+            {
521
+                assoc_outcome:outcome_id,
522
+                program_id:program_id,
523
+                status:status,
524
+                text:text,
525
+                id:id
526
+            },
527
+   function(){
528
+       location.reload(true);
529
+   }
530
+        )
531
+    })
482 532
 </script>
483 533
 @stop
484 534
 

+ 80
- 12
app/views/local/managers/pCoords/objectives.blade.php Datei anzeigen

@@ -19,8 +19,27 @@
19 19
                     <div class="form-group col-md-11" id='outcomeForm='>
20 20
 
21 21
 
22
-                        {{ Form::select('outcome[0]', $outcomes, null, ['class'=>'form-control selectpicker', 'id' =>'outcome[0]']) }}
23
-
22
+                        <select id="outcome[0]" name="outcome[0]" class="form-control selectpicker">
23
+                            	
24
+                                                        @foreach ($outcomes as $outcome)
25
+                            	
26
+                                                        <option value="{{ $outcome->id }}">
27
+                            	
28
+                                                            {{ $outcome->name }}
29
+                            	
30
+                                
31
+                            	
32
+                                
33
+                            	
34
+                                
35
+                            	
36
+                                                        </option>
37
+                            	
38
+                                                        @endforeach
39
+                            	
40
+                                                    </select>
41
+                            	
42
+                            
24 43
                     </div>
25 44
 
26 45
                 </div>
@@ -40,7 +59,7 @@
40 59
                     <br>
41 60
 
42 61
 
43
-                    <input type="hidden" id='{{ $programs[0]->name }}' name="program_id[]" value="{{$programs[0]->id}}">
62
+                    <input type="hidden" id='assoc_program' name="program_id[]" value="{{$programs[0]->id}}">
44 63
                     <input type="checkbox" id="{{ $programs[0]->name }}" name="program_id[]" value="{{$programs[0]->id}}" disabled checked>
45 64
                     <label for="{{ $programs[0]->name }}"> {{ $programs[0]->name }} [{{ $programs[0]->school->name }}]</label><br>
46 65
 
@@ -95,7 +114,7 @@
95 114
 
96 115
                 <div class="form-group">
97 116
                     {{ Form::label('objective_id', 'Objectives') }}
98
-                    <select id="select-objective" name="id" class="form-control selectpicker">
117
+                    <select id="select-objective" name='id' class="form-control selectpicker" >
99 118
                         @foreach ($objectives as $objective)
100 119
                         <option value="{{ $objective->id }}" data-subtext="
101 120
                                         @if($objective->program)
@@ -109,6 +128,8 @@
109 128
                         </option>
110 129
                         @endforeach
111 130
                     </select>
131
+        
132
+
112 133
                 </div>
113 134
 
114 135
                 <!-- Associated Outcome -->
@@ -117,8 +138,27 @@
117 138
                     <div id='assocOutcomeGroup'>
118 139
                         <label>Associated Outcome</label>
119 140
 
120
-                        {{ Form::select("assoc_outcome[]", $outcomes, null, ['class'=>'form-control selectpicker', 'id'=>'assoc_outcome0']) }}
121
-                        <br><br>
141
+                        <select id="assoc_outcome0" name="assoc_outcome[]" class="form-control selectpicker">
142
+                            
143
+                                                        @foreach ($outcomes as $outcome)
144
+                            
145
+                                                        <option value="{{ $outcome->id }}">
146
+                            
147
+                                                            {{ $outcome->name }}
148
+                        
149
+                                
150
+                        
151
+                                
152
+                        
153
+                                
154
+                        
155
+                                                        </option>
156
+                    	
157
+                                     @endforeach
158
+                        
159
+                                 </select>
160
+                    	
161
+                                                <br><br>
122 162
                     </div>
123 163
 
124 164
                 </div>
@@ -137,7 +177,7 @@
137 177
                     <br>
138 178
 
139 179
 
140
-                    <input type="hidden" id='assoc_program_id_{{ $programs[0]->id }}' name="program_id[]" value="{{$programs[0]->id}}">
180
+                    <input type="hidden" id='assoc_program_id_{{ $programs[0]->id }}' name="assoc_program_id[]" value="{{$programs[0]->id}}">
141 181
 
142 182
                     <input type="checkbox" id="{{ $programs[0]->name }}" id="assoc_program_id_{{$programs[0]->id}}" name="program_id[]" value="{{$programs[0]->id}}" disabled checked>
143 183
                     <label for="{{ $programs[0]->name }}"> {{ $programs[0]->name }} [{{ $programs[0]->school->name }}]</label><br>
@@ -164,7 +204,7 @@
164 204
 
165 205
                 </div>
166 206
 
167
-                {{ Form::submit('Update', array('class' => 'btn btn-primary btn-block')) }}
207
+                {{ Form::submit('Update', array('class' => 'btn btn-primary btn-block', 'id' => 'update_button')) }}
168 208
                 {{ Form::close() }}
169 209
 
170 210
                 <form action="/deleteObjective" method="POST" id='deleteObj'>
@@ -215,6 +255,7 @@
215 255
                 }
216 256
                 $('#select-objective').html(fullHTML);
217 257
                 $('#select-objective').selectpicker('refresh');
258
+                
218 259
                 fetchObjectiveForEditing();
219 260
 
220 261
             },
@@ -292,7 +333,7 @@
292 333
 
293 334
     function fetchObjectiveForEditing() {
294 335
         var id = $('#select-objective').find(':selected').val();
295
-
336
+        
296 337
         $.post(
297 338
             "{{ URL::action('Objective2Controller@fetchObjectiveWithTrashed') }}", {
298 339
                 id: id
@@ -439,7 +480,7 @@
439 480
         div.remove();
440 481
         button = document.getElementById('closeAssoc' + (counterAssoc - 1).toString());
441 482
         button.remove();
442
-        counterAssoc -= 1;
483
+        counterAssoc -=1;
443 484
         $('#counterAssoc').val(counterAssoc);
444 485
 
445 486
     }
@@ -452,8 +493,7 @@
452 493
             'name': "assoc_outcome[]",
453 494
             'data-live-search': 'true',
454 495
             'id': 'assoc_outcome' + counterAssoc.toString(),
455
-            'onchange': 'fetchObjectiveForSelect("outcome' + counter + '", this.value, ' + counterAssoc + ')'
456
-
496
+           
457 497
         });
458 498
         var $div = $('<div />', {
459 499
             'id': 'assocOutcomeForm' + counterAssoc.toString(),
@@ -486,6 +526,33 @@
486 526
 
487 527
 
488 528
     }
529
+    $('#update_button').on('click', function(e){
530
+        e.preventDefault();
531
+
532
+        outcome_id= []
533
+        program_id= $('#assoc_program').val();
534
+        status = $('#status').val();
535
+        text =$('#objective-text').val();
536
+        id = $('#select-objective').val();
537
+
538
+        $('#assocOutcomeGroup').find('select').each(function(){
539
+            outcome_id.push($(this).val())
540
+        })
541
+       
542
+        $.post(
543
+            "{{URL::action('Objective2Controller@update')}}",
544
+            {
545
+                assoc_outcome:outcome_id,
546
+                program_id:program_id,
547
+                status:status,
548
+                text:text,
549
+                id:id
550
+            },
551
+   function(){
552
+       location.reload(true);
553
+   }
554
+        )
555
+    })
489 556
 </script>
490 557
 @stop
491 558
 
@@ -543,6 +610,7 @@ $(this).next().stop().slideToggle();
543 610
 // When list item is clicked, load corresponding info
544 611
 $('#select-objective').on('change', function()
545 612
 {
613
+
546 614
 fetchObjectiveForEditing();
547 615
 $('.selectpicker').selectpicker('refresh');
548 616
 });

+ 42
- 9
app/views/local/managers/sCoords/objectives.blade.php Datei anzeigen

@@ -132,7 +132,7 @@
132 132
     
133 133
                             </option>
134 134
                             @endforeach
135
-                        </select>
135
+                        </select><br><br>
136 136
                    
137 137
 
138 138
                     </div>
@@ -151,7 +151,7 @@
151 151
                     {{ Form::label('program_id2', 'Associated Program') }}<br><br>
152 152
                     @foreach ($programs as $program)
153 153
 
154
-                    <input type="checkbox" id="assoc_program_id_{{ $program->id }}" name="program_id[]" value="{{$program->id}}">
154
+                    <input type="checkbox" id="assoc_program_id_{{ $program->id }}" name="assoc_program_id[]" value="{{$program->id}}">
155 155
                     <label for="assoc_program_id_{{ $program->id }}"> {{ $program->name }} <sub>[{{ $program->school->name }}]</sub></label><br>
156 156
                     @endforeach
157 157
                 </div>
@@ -176,7 +176,7 @@
176 176
 
177 177
                 </div>
178 178
 
179
-                {{ Form::submit('Update', array('class' => 'btn btn-primary btn-block')) }}
179
+                {{ Form::submit('Update', array('class' => 'btn btn-primary btn-block', 'id' => 'update_button')) }}
180 180
                 {{ Form::close() }}
181 181
                 <form action="/deleteObjective" method="POST" id='deleteObj'>
182 182
                 
@@ -329,7 +329,7 @@
329 329
                 for (var i = 1; i < json.outcome.length; i++) {
330 330
                     counterAssoc = i + 1;
331 331
                     var $select = $('<select />', {
332
-                        'class': "selectpicker form-control",
332
+                        'class': "selectpicker form-control ",
333 333
                         'name': "assoc_outcome[]",
334 334
                         'data-live-search': 'true',
335 335
                         'id': 'assoc_outcome' + i.toString()
@@ -454,11 +454,12 @@
454 454
 
455 455
     function deleteLastAssoc() {
456 456
 
457
-        div = document.getElementById('assocOutcomeForm' + (counterAssoc).toString());
457
+        div = document.getElementById('assocOutcomeForm' + (counterAssoc -1).toString());
458 458
         div.remove();
459
-        button = document.getElementById('closeAssoc' + (counterAssoc).toString());
459
+        button = document.getElementById('closeAssoc' + (counterAssoc-1).toString());
460 460
         button.remove();
461
-        counterAssoc -= 1;
461
+        counterAssoc -=1;
462
+        $('#counterAssoc').val(counterAssoc);
462 463
 
463 464
     }
464 465
 
@@ -469,7 +470,8 @@
469 470
             'class': "selectpicker form-control",
470 471
             'name': "assoc_outcome[]",
471 472
             'data-live-search': 'true',
472
-            'id': 'assoc_outcome' + counterAssoc.toString()
473
+            'id': 'assoc_outcome' + counterAssoc.toString(),
474
+ 
473 475
 
474 476
         });
475 477
         var $div = $('<div />', {
@@ -498,9 +500,40 @@
498 500
 
499 501
         ran = true;
500 502
         counterAssoc += 1;
501
-
503
+        $('#counterAssoc').val(counterAssoc);
502 504
 
503 505
     }
506
+
507
+    $('#update_button').on('click', function(e){
508
+        e.preventDefault();
509
+
510
+        outcome_id= []
511
+        program_id= [];
512
+        status = $('#status').val();
513
+        text =$('#objective-text').val();
514
+        id = $('#select-objective').val();
515
+
516
+        $('#assocOutcomeGroup').find('select').each(function(){
517
+            outcome_id.push($(this).val())
518
+        })
519
+        $('input[name="assoc_program_id[]"]').each(function(){
520
+            if(this.checked)
521
+            program_id.push($(this).val())
522
+        });
523
+        $.post(
524
+            "{{URL::action('Objective2Controller@update')}}",
525
+            {
526
+                assoc_outcome:outcome_id,
527
+                program_id:program_id,
528
+                status:status,
529
+                text:text,
530
+                id:id
531
+            },
532
+   function(){
533
+       location.reload(true);
534
+   }
535
+        )
536
+    })
504 537
 </script>
505 538
 @stop
506 539