Gabriel Santiago Plaza 3 yıl önce
ebeveyn
işleme
7ecf1627a8

+ 37
- 1
app/controllers/AnnualPlansController.php Dosyayı Görüntüle

687
     return View::make('local.managers.shared.annual_select', compact('title', 'programs'));
687
     return View::make('local.managers.shared.annual_select', compact('title', 'programs'));
688
   }
688
   }
689
 
689
 
690
-
690
+  //Fetch report in annual_plan_report
691
 
691
 
692
   public function fetchReportWithOutcome()
692
   public function fetchReportWithOutcome()
693
   {
693
   {
712
     $outcome->semester_info = DB::table('semesters')
712
     $outcome->semester_info = DB::table('semesters')
713
       ->where('id', $semester_id)
713
       ->where('id', $semester_id)
714
       ->first();
714
       ->first();
715
+    $outcome->comments = DB::table('typ_outcome_report_comments')
716
+      ->where('typ_semester_outcome_id', $typ_semester_outcome_id)
717
+      ->get();
718
+
715
 
719
 
716
     foreach ($outcome->objectives as $index => $objective) {
720
     foreach ($outcome->objectives as $index => $objective) {
717
       $objective->courses = Objective::getPlanReport($objective);
721
       $objective->courses = Objective::getPlanReport($objective);
818
       ->first();
822
       ->first();
819
     return $array_to_send;
823
     return $array_to_send;
820
   }
824
   }
825
+
826
+  public function addCommentsToOutcome()
827
+  {
828
+    $edit_id = Input::get('edit_id');
829
+    $typ_semester_outcome_id = Input::get('typ_outcome_semester_id');
830
+    $comments = Input::get('comments');
831
+
832
+    Log::info(Input::all());
833
+
834
+    if ($edit_id) {
835
+      DB::table('typ_outcome_report_comments')
836
+        ->where('id', $edit_id)->update(array(
837
+          'user_id' => Auth::user()->id,
838
+          'typ_semester_outcome_id' => $typ_semester_outcome_id,
839
+          'comments' => $comments
840
+        ));
841
+    } else {
842
+      $edit_id = DB::table('typ_outcome_report_comments')->insertGetId(array(
843
+        'user_id' => Auth::user()->id,
844
+        'typ_semester_outcome_id' => $typ_semester_outcome_id,
845
+        'comments' => $comments
846
+      ));
847
+    }
848
+    return $edit_id;
849
+  }
850
+  public function deleteCommentsFromOutcome()
851
+  {
852
+    $comment_id = Input::get('id');
853
+
854
+    DB::table('typ_outcome_report_comments')->where('id', $comment_id)->delete();
855
+    return;
856
+  }
821
 }
857
 }

app/database/migrations/2022_02_13_122758_create_annual_report_comments.php → app/database/migrations/2022_02_13_122758_create_typ_outcome_report_comments.php Dosyayı Görüntüle

3
 use Illuminate\Database\Schema\Blueprint;
3
 use Illuminate\Database\Schema\Blueprint;
4
 use Illuminate\Database\Migrations\Migration;
4
 use Illuminate\Database\Migrations\Migration;
5
 
5
 
6
-class CreateAnnualReportComments extends Migration
6
+class CreateTypOutcomeReportComments extends Migration
7
 {
7
 {
8
 
8
 
9
 	/**
9
 	/**
13
 	 */
13
 	 */
14
 	public function up()
14
 	public function up()
15
 	{
15
 	{
16
-		Schema::create('annual_report_comments', function (Blueprint $table) {
16
+		Schema::create('typ_outcome_report_comments', function (Blueprint $table) {
17
 			$table->increments('id');
17
 			$table->increments('id');
18
 			$table->integer('user_id')->unsigned();
18
 			$table->integer('user_id')->unsigned();
19
-			$table->integer('annual_plan_id')->unsigned();
19
+			$table->integer('typ_semester_outcome_id')->unsigned();
20
 			$table->text('comments');
20
 			$table->text('comments');
21
 			$table->foreign('user_id')
21
 			$table->foreign('user_id')
22
 				->references('id')
22
 				->references('id')
23
 				->on('users')
23
 				->on('users')
24
 				->onDelete('cascade')
24
 				->onDelete('cascade')
25
 				->onUpdate('cascade');
25
 				->onUpdate('cascade');
26
-			$table->foreign('annual_plan_id')
26
+			$table->foreign('typ_semester_outcome_id')
27
 				->references('id')
27
 				->references('id')
28
-				->on('annual_plans')
28
+				->on('typ_semester_outcome')
29
 				->onDelete('cascade')
29
 				->onDelete('cascade')
30
 				->onUpdate('cascade');
30
 				->onUpdate('cascade');
31
 		});
31
 		});
38
 	 */
38
 	 */
39
 	public function down()
39
 	public function down()
40
 	{
40
 	{
41
-		Schema::drop('annual_report_comments');
41
+		Schema::drop('typ_outcome_report_comments');
42
 	}
42
 	}
43
 }
43
 }

+ 2
- 1
app/routes.php Dosyayı Görüntüle

168
      */
168
      */
169
 
169
 
170
     // Annual Plan routes
170
     // Annual Plan routes
171
-
171
+    Route::post('deleteCommentsFromOutcome', array('uses' => 'AnnualPlansController@deleteCommentsFromOutcome'));
172
+    Route::post('addCommentsToOutcome', array('uses' => 'AnnualPlansController@addCommentsToOutcome'));
172
     Route::post('fetchAnnualPlan', array('uses' => 'AnnualPlansController@fetchTheAnnualPlan'));
173
     Route::post('fetchAnnualPlan', array('uses' => 'AnnualPlansController@fetchTheAnnualPlan'));
173
 
174
 
174
     Route::post('deleteTaFromOutcome', array('uses' => 'TransformativeActionsController@deleteTaFromOutcome'));
175
     Route::post('deleteTaFromOutcome', array('uses' => 'TransformativeActionsController@deleteTaFromOutcome'));

+ 151
- 9
app/views/local/managers/shared/annual_report.blade.php Dosyayı Görüntüle

155
 
155
 
156
             $('#outcome-display').parent().hide();
156
             $('#outcome-display').parent().hide();
157
 
157
 
158
-            // --------------------------------------------------------------------------
159
-            // Functions
160
-            // --------------------------------------------------------------------------
158
+            
159
+    
161
 
160
 
162
-            // --------------------------------------------------------------------------
163
-            // Events
164
-            // --------------------------------------------------------------------------
161
+        });
162
+
163
+        function draw_comment_section(typ_semester_outcome_id, outcome_comments){
164
+            $('#levelTabs').append('<li role = "presentation" id = "comments_for_outcome">'+
165
+                            '<a data-toggle="tab" id="a_for_ta_outcome" href="#comments_outcome" role="tab" >Comments for Outcome</a>'+
166
+                            '</li>');
167
+            $('#allLists').append('<div role="tabpanel" class="tab-pane" data-typ-semester-outcome-id = "'+typ_semester_outcome_id+'" id="comments_outcome"></div>');
168
+            button_for_adding_comments = $('<button>', {
169
+                'class':'btn btn-secondary',
170
+                'id':'add_comments_button',
171
+                'style':'float: right',
172
+                'onclick': 'add_comments_to_plan()'
173
+            }).html("<span class='glyphicon glyphicon-plus'></span> Add Comments");
174
+            $('#comments_outcome').append('<h3>Comments</h3>')
175
+        if(outcome_comments.length){
176
+            table_for_comments = $('<table>',{
177
+               'class':'table table-striped table-condensed datatable',
178
+               'id':'table_for_comments'
179
+            }).html('<thead><th>Comments</th><th>Edit or Delete</th></thead><tbody></tbody>');
180
+            table_for_comments.appendTo('#comments_outcome');
181
+            table_for_comments = table_for_comments.DataTable();
182
+            $.each(outcome_comments, function(index, comment){
183
+                
184
+                comment_td = '<div id="comments_id_'+comment.id+'">'+comment.comments+'</div>';
185
+                
186
+                inputEdit = $('<input>', {
187
+                                    'type': 'button',
188
+                                    'class': 'btn btn-secondary',
189
+                                    'onclick': 'add_comments_to_plan('+comment.id+')',
190
+                                    'id': 'edit_button_comment_' + comment.id,
191
+                                    'value': 'Edit'
192
+                                }).html('Edit');
193
+                inputDelete = $('<input>', {
194
+                                    'type': 'button',
195
+                                    'class': 'btn btn-primary',
196
+                                    'style': 'display: inline',
197
+                                    'onclick': 'deleteCommentsFromOutcome('+comment.id+')',
198
+                                    'value': 'Delete'
199
+            })
200
+            div = $('<div>');
201
+                                div.append(inputEdit);
202
+                                div.append(inputDelete);
203
+                                table_for_comments.row.add([
204
+                                    comment_td,
205
+                                    div.html()
206
+
207
+                                ]).draw();
208
+         });
209
+         
210
+        }
211
+
212
+            $('#comments_outcome').append('<hr>');
213
+            $('#comments_outcome').append(button_for_adding_comments);
214
+
215
+
216
+
217
+           
218
+       
219
+
220
+        
221
+        }
222
+
223
+        function add_comments_to_plan(edit_id = null){
224
+            $('#add_comments_button').hide();
225
+            div_for_inputs = $('<div>', {
226
+                'id':'add_comment_div'
227
+            });
228
+            textarea = $('<textarea>',{
229
+                'class':'form-control',
230
+                'data-comment-id':edit_id,
231
+                'id':'comment_textbox'
232
+            });
233
+            if(edit_id){
234
+            textarea.val($("#comments_id_"+edit_id).html());
235
+            }
236
+            save_button = $('<button>', {
237
+                'class':'btn btn-primary',
238
+                'onclick':'saveComment()',
239
+                'style':'float: right'
240
+            }).html('Save');
241
+            $('#comments_outcome').append(div_for_inputs);
242
+            div_for_inputs.append('<h5>Add new comment</h5>');
243
+            div_for_inputs.append(textarea);
244
+            div_for_inputs.append(save_button);
245
+
246
+        }
247
+
248
+        function saveComment(){
249
+            typ_outcome_semester_id = $("#comments_outcome").data('typ-semester-outcome-id');
250
+            comment_area = $('#comment_textbox');
251
+
252
+            $.post(
253
+                "{{URL::action('AnnualPlansController@addCommentsToOutcome')}}",
254
+                {
255
+                    typ_outcome_semester_id:typ_outcome_semester_id,
256
+                    comments:comment_area.val(),
257
+                    edit_id:comment_area.data('comment-id')
258
+                },
259
+                function(edit_id){
260
+                    $('#add_comment_div').remove();
261
+                    $('#add_comments_button').show();
262
+                    if($('#comments_id_'+edit_id).length){
263
+                        $('#comments_id_'+edit_id).html(comment_area.val());
264
+                    }
265
+                    else{
266
+                        table_for_comments = $('#table_for_comments').DataTable();
267
+                        comment_td = '<div id="comments_id_'+edit_id+'">'+comment_area.val()+'</div>';
268
+                
269
+                inputEdit = $('<input>', {
270
+                                    'type': 'button',
271
+                                    'class': 'btn btn-secondary',
272
+                                    'onclick': 'add_comments_to_plan('+edit_id+')',
273
+                                    'id': 'edit_button_comment_' + edit_id,
274
+                                    'value': 'Edit'
275
+                                }).html('Edit');
276
+                inputDelete = $('<input>', {
277
+                                    'type': 'button',
278
+                                    'class': 'btn btn-primary',
279
+                                    'style': 'display: inline',
280
+                                    'onclick': 'deleteCommentsFromOutcome('+edit_id+')',
281
+                                    'value': 'Delete'
282
+            })
283
+            div = $('<div>');
284
+                                div.append(inputEdit);
285
+                                div.append(inputDelete);
286
+                                table_for_comments.row.add([
287
+                                    comment_td,
288
+                                    div.html()
289
+
290
+                                ]).draw();
291
+                    }
292
+                }
293
+            )
294
+            
295
+        }
296
+
297
+        function deleteCommentsFromOutcome(id){
298
+            $.post(
299
+                "{{URL::action('AnnualPlansController@deleteCommentsFromOutcome')}}",
300
+                {id:id},
301
+                function(){
302
+                    $('#comments_id_'+id).parent().parent().remove();
303
+                    
304
+                }
305
+            )
306
+        }
165
 
307
 
166
-            // When list item is clicked, load corresponding info
167
 
308
 
168
-        });
169
 
309
 
170
         // Create everything 
310
         // Create everything 
171
 
311
 
175
             }
315
             }
176
             else{
316
             else{
177
                 $('#levelTabs').prepend('<li role = "presentation" id = "transformative_for_outcome">'+
317
                 $('#levelTabs').prepend('<li role = "presentation" id = "transformative_for_outcome">'+
178
-                            '<a data-toggle="tab" id="a_for_ta_outcome" href="#transformative_actions" role="tab" >Transformative Actions</a>'+
318
+                            '<a data-toggle="tab" id="a_for_ta_outcome" href="#transformative_actions" role="tab" >Transformative Actions to Outcome</a>'+
179
                             '</li>');
319
                             '</li>');
180
                 $('#allLists').prepend('<div role="tabpanel" class="tab-pane" id="transformative_actions"></div>');
320
                 $('#allLists').prepend('<div role="tabpanel" class="tab-pane" id="transformative_actions"></div>');
181
                         
321
                         
425
                         })
565
                         })
426
 
566
 
427
                         draw_transformative_actions(outcome.transforming_actions, outcome.semester_info.id)
567
                         draw_transformative_actions(outcome.transforming_actions, outcome.semester_info.id)
568
+                        draw_comment_section(typ_semester_outcome_id, outcome.comments);
569
+                        
428
                         //$('#a_for_'+first_objective_id).click();
570
                         //$('#a_for_'+first_objective_id).click();
429
                         theArray = [];
571
                         theArray = [];
430
 
572