Browse Source

Final Push?

parent
commit
e908550cd8

+ 3
- 2
app/controllers/Objective2Controller.php View File

294
 	public function edit()
294
 	public function edit()
295
 	{
295
 	{
296
 		$title = "Objective";
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
 		$objectives = Objective::withTrashed()->orderBy('text', 'ASC')->get();
299
 		$objectives = Objective::withTrashed()->orderBy('text', 'ASC')->get();
300
 		$programs = Program::orderBy('name', 'ASC')->get();
300
 		$programs = Program::orderBy('name', 'ASC')->get();
310
 		$userProgram = DB::select("select program_user.program_id from program_user where user_id = {$userProgram}");
310
 		$userProgram = DB::select("select program_user.program_id from program_user where user_id = {$userProgram}");
311
 
311
 
312
 		$title = "Objective";
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
 		$objectives = Objective::withTrashed()->orderBy('text', 'ASC')->get();
315
 		$objectives = Objective::withTrashed()->orderBy('text', 'ASC')->get();
316
 
316
 
387
 
387
 
388
 
388
 
389
 			/** Set info */
389
 			/** Set info */
390
+			Log::info($clean_input);
390
 			$Objective->text = $clean_input['text'];
391
 			$Objective->text = $clean_input['text'];
391
 
392
 
392
 
393
 

+ 68
- 18
app/views/local/managers/admins/objectives.blade.php View File

19
                     <div class="form-group col-md-11" id='outcomeForm'>
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
                     </div>
32
                     </div>
25
 
33
 
26
                 </div>
34
                 </div>
84
                     </div>
92
                     </div>
85
                     <div class="form-group">
93
                     <div class="form-group">
86
                         <label>Associated Outcome</label>
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
                     </div>
97
                     </div>
90
                 </div>
98
                 </div>
99
+                <hr>
91
                 <div class="form-group">
100
                 <div class="form-group">
92
                     {{ Form::label('objective_id', 'Objectives') }}
101
                     {{ Form::label('objective_id', 'Objectives') }}
93
                     <select id="select-objective" name="id" class="form-control selectpicker">
102
                     <select id="select-objective" name="id" class="form-control selectpicker">
113
                     <div id='assocOutcomeGroup'>
122
                     <div id='assocOutcomeGroup'>
114
                         <label>Associated Outcome</label>
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
                     </div>
136
                     </div>
119
 
137
 
120
                 </div>
138
                 </div>
135
                     {{ Form::label('program_id2', 'Associated Program') }}<br><br>
153
                     {{ Form::label('program_id2', 'Associated Program') }}<br><br>
136
                     @foreach ($programs as $program)
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
                     <label for="assoc_program_id_{{ $program->id }}"> {{ $program->name }} <sub>[{{ $program->school->name }}]</sub></label><br>
157
                     <label for="assoc_program_id_{{ $program->id }}"> {{ $program->name }} <sub>[{{ $program->school->name }}]</sub></label><br>
140
                     @endforeach
158
                     @endforeach
141
                 </div>
159
                 </div>
161
 
179
 
162
                 </div>
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
                 {{ Form::close() }}
183
                 {{ Form::close() }}
166
                 <form action="/deleteObjective" method="POST" id='deleteObj'>
184
                 <form action="/deleteObjective" method="POST" id='deleteObj'>
167
 
185
 
299
 
317
 
300
                 // Select associated outcome
318
                 // Select associated outcome
301
                 for (var i = counterAssoc; i != 1; i--) {
319
                 for (var i = counterAssoc; i != 1; i--) {
302
-                    deleteLastAssoc(i - 1);
320
+                    deleteLastAssoc(i);
303
 
321
 
304
                 }
322
                 }
305
                 $('#assoc_outcome0').val(json.outcome[0].outcome_id);
323
                 $('#assoc_outcome0').val(json.outcome[0].outcome_id);
309
                     counterAssoc = i + 1;
327
                     counterAssoc = i + 1;
310
                     var $select = $('<select />', {
328
                     var $select = $('<select />', {
311
                         'class': "selectpicker form-control",
329
                         'class': "selectpicker form-control",
312
-                        'name': "outcome[]",
330
+                        'name': "assoc_outcome[]",
313
                         'data-live-search': 'true',
331
                         'data-live-search': 'true',
314
                         'id': 'assoc_outcome' + i.toString()
332
                         'id': 'assoc_outcome' + i.toString()
315
 
333
 
326
                     var $button = $('<button />', {
344
                     var $button = $('<button />', {
327
                         'type': 'button',
345
                         'type': 'button',
328
                         'class': 'btn btn-primary',
346
                         'class': 'btn btn-primary',
329
-                        'onclick': 'deleteLastAssoc(' + i + ')'
347
+                        'onclick': 'deleteLastAssoc()'
330
                     });
348
                     });
331
                     $button.append('X');
349
                     $button.append('X');
332
                     $divForButton.append($button);
350
                     $divForButton.append($button);
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
 
464
 
446
         var $select = $('<select />', {
465
         var $select = $('<select />', {
447
             'class': "selectpicker form-control",
466
             'class': "selectpicker form-control",
448
-            'name': "outcome[]",
467
+            'name': "assoc_outcome[]",
449
             'data-live-search': 'true',
468
             'data-live-search': 'true',
450
             'id': 'assoc_outcome' + counterAssoc.toString()
469
             'id': 'assoc_outcome' + counterAssoc.toString()
451
 
470
 
462
         var $button = $('<button />', {
481
         var $button = $('<button />', {
463
             'type': 'button',
482
             'type': 'button',
464
             'class': 'btn btn-primary',
483
             'class': 'btn btn-primary',
465
-            'onclick': 'deleteLastAssoc(' + counterAssoc + ')'
484
+            'onclick': 'deleteLastAssoc()'
466
         });
485
         });
467
         $button.append('X');
486
         $button.append('X');
468
         $divForButton.append($button);
487
         $divForButton.append($button);
476
 
495
 
477
 
496
 
478
         counterAssoc += 1;
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
 </script>
532
 </script>
483
 @stop
533
 @stop
484
 
534
 

+ 80
- 12
app/views/local/managers/pCoords/objectives.blade.php View File

19
                     <div class="form-group col-md-11" id='outcomeForm='>
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
                     </div>
43
                     </div>
25
 
44
 
26
                 </div>
45
                 </div>
40
                     <br>
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
                     <input type="checkbox" id="{{ $programs[0]->name }}" name="program_id[]" value="{{$programs[0]->id}}" disabled checked>
63
                     <input type="checkbox" id="{{ $programs[0]->name }}" name="program_id[]" value="{{$programs[0]->id}}" disabled checked>
45
                     <label for="{{ $programs[0]->name }}"> {{ $programs[0]->name }} [{{ $programs[0]->school->name }}]</label><br>
64
                     <label for="{{ $programs[0]->name }}"> {{ $programs[0]->name }} [{{ $programs[0]->school->name }}]</label><br>
46
 
65
 
95
 
114
 
96
                 <div class="form-group">
115
                 <div class="form-group">
97
                     {{ Form::label('objective_id', 'Objectives') }}
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
                         @foreach ($objectives as $objective)
118
                         @foreach ($objectives as $objective)
100
                         <option value="{{ $objective->id }}" data-subtext="
119
                         <option value="{{ $objective->id }}" data-subtext="
101
                                         @if($objective->program)
120
                                         @if($objective->program)
109
                         </option>
128
                         </option>
110
                         @endforeach
129
                         @endforeach
111
                     </select>
130
                     </select>
131
+        
132
+
112
                 </div>
133
                 </div>
113
 
134
 
114
                 <!-- Associated Outcome -->
135
                 <!-- Associated Outcome -->
117
                     <div id='assocOutcomeGroup'>
138
                     <div id='assocOutcomeGroup'>
118
                         <label>Associated Outcome</label>
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
                     </div>
162
                     </div>
123
 
163
 
124
                 </div>
164
                 </div>
137
                     <br>
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
                     <input type="checkbox" id="{{ $programs[0]->name }}" id="assoc_program_id_{{$programs[0]->id}}" name="program_id[]" value="{{$programs[0]->id}}" disabled checked>
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
                     <label for="{{ $programs[0]->name }}"> {{ $programs[0]->name }} [{{ $programs[0]->school->name }}]</label><br>
183
                     <label for="{{ $programs[0]->name }}"> {{ $programs[0]->name }} [{{ $programs[0]->school->name }}]</label><br>
164
 
204
 
165
                 </div>
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
                 {{ Form::close() }}
208
                 {{ Form::close() }}
169
 
209
 
170
                 <form action="/deleteObjective" method="POST" id='deleteObj'>
210
                 <form action="/deleteObjective" method="POST" id='deleteObj'>
215
                 }
255
                 }
216
                 $('#select-objective').html(fullHTML);
256
                 $('#select-objective').html(fullHTML);
217
                 $('#select-objective').selectpicker('refresh');
257
                 $('#select-objective').selectpicker('refresh');
258
+                
218
                 fetchObjectiveForEditing();
259
                 fetchObjectiveForEditing();
219
 
260
 
220
             },
261
             },
292
 
333
 
293
     function fetchObjectiveForEditing() {
334
     function fetchObjectiveForEditing() {
294
         var id = $('#select-objective').find(':selected').val();
335
         var id = $('#select-objective').find(':selected').val();
295
-
336
+        
296
         $.post(
337
         $.post(
297
             "{{ URL::action('Objective2Controller@fetchObjectiveWithTrashed') }}", {
338
             "{{ URL::action('Objective2Controller@fetchObjectiveWithTrashed') }}", {
298
                 id: id
339
                 id: id
439
         div.remove();
480
         div.remove();
440
         button = document.getElementById('closeAssoc' + (counterAssoc - 1).toString());
481
         button = document.getElementById('closeAssoc' + (counterAssoc - 1).toString());
441
         button.remove();
482
         button.remove();
442
-        counterAssoc -= 1;
483
+        counterAssoc -=1;
443
         $('#counterAssoc').val(counterAssoc);
484
         $('#counterAssoc').val(counterAssoc);
444
 
485
 
445
     }
486
     }
452
             'name': "assoc_outcome[]",
493
             'name': "assoc_outcome[]",
453
             'data-live-search': 'true',
494
             'data-live-search': 'true',
454
             'id': 'assoc_outcome' + counterAssoc.toString(),
495
             'id': 'assoc_outcome' + counterAssoc.toString(),
455
-            'onchange': 'fetchObjectiveForSelect("outcome' + counter + '", this.value, ' + counterAssoc + ')'
456
-
496
+           
457
         });
497
         });
458
         var $div = $('<div />', {
498
         var $div = $('<div />', {
459
             'id': 'assocOutcomeForm' + counterAssoc.toString(),
499
             'id': 'assocOutcomeForm' + counterAssoc.toString(),
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
 </script>
556
 </script>
490
 @stop
557
 @stop
491
 
558
 
543
 // When list item is clicked, load corresponding info
610
 // When list item is clicked, load corresponding info
544
 $('#select-objective').on('change', function()
611
 $('#select-objective').on('change', function()
545
 {
612
 {
613
+
546
 fetchObjectiveForEditing();
614
 fetchObjectiveForEditing();
547
 $('.selectpicker').selectpicker('refresh');
615
 $('.selectpicker').selectpicker('refresh');
548
 });
616
 });

+ 42
- 9
app/views/local/managers/sCoords/objectives.blade.php View File

132
     
132
     
133
                             </option>
133
                             </option>
134
                             @endforeach
134
                             @endforeach
135
-                        </select>
135
+                        </select><br><br>
136
                    
136
                    
137
 
137
 
138
                     </div>
138
                     </div>
151
                     {{ Form::label('program_id2', 'Associated Program') }}<br><br>
151
                     {{ Form::label('program_id2', 'Associated Program') }}<br><br>
152
                     @foreach ($programs as $program)
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
                     <label for="assoc_program_id_{{ $program->id }}"> {{ $program->name }} <sub>[{{ $program->school->name }}]</sub></label><br>
155
                     <label for="assoc_program_id_{{ $program->id }}"> {{ $program->name }} <sub>[{{ $program->school->name }}]</sub></label><br>
156
                     @endforeach
156
                     @endforeach
157
                 </div>
157
                 </div>
176
 
176
 
177
                 </div>
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
                 {{ Form::close() }}
180
                 {{ Form::close() }}
181
                 <form action="/deleteObjective" method="POST" id='deleteObj'>
181
                 <form action="/deleteObjective" method="POST" id='deleteObj'>
182
                 
182
                 
329
                 for (var i = 1; i < json.outcome.length; i++) {
329
                 for (var i = 1; i < json.outcome.length; i++) {
330
                     counterAssoc = i + 1;
330
                     counterAssoc = i + 1;
331
                     var $select = $('<select />', {
331
                     var $select = $('<select />', {
332
-                        'class': "selectpicker form-control",
332
+                        'class': "selectpicker form-control ",
333
                         'name': "assoc_outcome[]",
333
                         'name': "assoc_outcome[]",
334
                         'data-live-search': 'true',
334
                         'data-live-search': 'true',
335
                         'id': 'assoc_outcome' + i.toString()
335
                         'id': 'assoc_outcome' + i.toString()
454
 
454
 
455
     function deleteLastAssoc() {
455
     function deleteLastAssoc() {
456
 
456
 
457
-        div = document.getElementById('assocOutcomeForm' + (counterAssoc).toString());
457
+        div = document.getElementById('assocOutcomeForm' + (counterAssoc -1).toString());
458
         div.remove();
458
         div.remove();
459
-        button = document.getElementById('closeAssoc' + (counterAssoc).toString());
459
+        button = document.getElementById('closeAssoc' + (counterAssoc-1).toString());
460
         button.remove();
460
         button.remove();
461
-        counterAssoc -= 1;
461
+        counterAssoc -=1;
462
+        $('#counterAssoc').val(counterAssoc);
462
 
463
 
463
     }
464
     }
464
 
465
 
469
             'class': "selectpicker form-control",
470
             'class': "selectpicker form-control",
470
             'name': "assoc_outcome[]",
471
             'name': "assoc_outcome[]",
471
             'data-live-search': 'true',
472
             'data-live-search': 'true',
472
-            'id': 'assoc_outcome' + counterAssoc.toString()
473
+            'id': 'assoc_outcome' + counterAssoc.toString(),
474
+ 
473
 
475
 
474
         });
476
         });
475
         var $div = $('<div />', {
477
         var $div = $('<div />', {
498
 
500
 
499
         ran = true;
501
         ran = true;
500
         counterAssoc += 1;
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
 </script>
537
 </script>
505
 @stop
538
 @stop
506
 
539