Переглянути джерело

Merge branch 'Merge_gabriel_mayo' of https://git.ccom.uprrp.edu/CDCC/OLAS into Merge_gabriel_mayo

Gabriel Santiago Plaza 2 роки тому
джерело
коміт
db45d56367

+ 22
- 0
app/controllers/AnnualPlansController.php Переглянути файл

@@ -250,6 +250,7 @@ class AnnualPlansController extends \BaseController
250 250
     //  $typ_info['criteria'][$objective->id] = DB::select("select * from criteria where id in (select criterion_id from criterion_objective_outcome where outcome_id = ? and objective_id = {$objective->id})", array(Input::get('id')));
251 251
     //}
252 252
     $annual_plan = DB::select("select annual_plans.id from annual_plans, annual_cycle where annual_plans.annual_cycle_id = annual_cycle.id and (semester_start = {$semester->id} or semester_end ={$semester->id}) and program_id ={$program_id}")[0];
253
+    $typ_info['expected_target'] = DB::select("select * from target_outcomes_program where program_id = {$program_id} and semester_id = {$semester->id}");
253 254
     $typ_info['objectives'] = DB::select("select * from objectives where id in (select objective_id from typ_semester_objectives where typ_semester_outcome_id in(select id from typ_semester_outcome where outcome_id = ? and semester_id = {$semester->id} and typ_program_id in (select id from typ_program where program_id ={$program_id})))", array(Input::get('id')));
254 255
     $typ_info['transformative_actions'] = DB::select("select * from transformative_actions where by_professor =0 and is_custom=0");
255 256
     foreach ($typ_info['objectives'] as $objective) {
@@ -328,6 +329,27 @@ class AnnualPlansController extends \BaseController
328 329
       }
329 330
     }
330 331
   }
332
+
333
+  public function CreateOrEdit($program_id){
334
+
335
+    $semester_id = Input::get('semester_id');
336
+    $expected_target = Input::get('expected_target');
337
+    
338
+    $exist = DB::select("select * from target_outcomes_program where program_id = {$program_id} and semester_id = {$semester_id}");
339
+    
340
+    
341
+    if($exist){
342
+      //update
343
+      DB::update("update target_outcomes_program set expected_target = {$expected_target}, updated_at = now() where program_id = {$program_id} and semester_id = {$semester_id}");
344
+    }
345
+
346
+
347
+    else{
348
+      //create a new one
349
+      DB::insert("insert into target_outcomes_program (program_id, semester_id, expected_target, created_at, updated_at) values({$program_id}, {$semester_id}, '{$expected_target}', '{now()}', '{now()}')");
350
+    }
351
+    return;
352
+  }
331 353
   public function transformativeReport()
332 354
   {
333 355
     $json_to_send = array();

+ 1
- 0
app/routes.php Переглянути файл

@@ -488,6 +488,7 @@ Route::group(array('before' => 'auth|has_access'), function () {
488 488
 
489 489
         Route::get('annual-plan-program/{program_id}/{typ_id?}', 'AnnualPlansController@showPlan');
490 490
         Route::post('annual-plan-fetchTYP/{program_id}', 'AnnualPlansController@fetchTYP');
491
+        Route::post('annual-plan-CreateOrEdit/{program_id}', 'AnnualPlansController@CreateOrEdit');
491 492
         Route::post('annual-plan-postOnChange', 'AnnualPlansController@postAnnualPlan');
492 493
         Route::post('annual-plan-deleteCriteria', 'AnnualPlansController@deleteCriteria');
493 494
 

+ 62
- 3
app/views/local/managers/shared/annual-plans.blade.php Переглянути файл

@@ -41,9 +41,17 @@
41 41
     
42 42
 
43 43
     <div class="col-md-9">
44
+      <div id="expected-outcome" class="panel panel-default" data-semester-id ="">
45
+        <div class="panel-heading">
46
+          <h3 class="panel-title">
47
+            Expected Target Outcomes
48
+          </h3>
49
+          <input style="width: 150px;" min="0" class="form-control" type="number" >
50
+        </div>
51
+      </div>
44 52
       <div id="outcome-display" class="panel panel-default">
45 53
         <div class="panel-heading">
46
-          <h4 class=" panel-title" style="cursor:auto!important;">
54
+          <h4 class=" panel-title" >
47 55
             Primer Semestre 2019-2020
48 56
           </h4>
49 57
         </div>
@@ -84,6 +92,8 @@ $(document).ready(function()
84 92
   // --------------------------------------------------------------------------
85 93
 
86 94
   // Hide accordion panel contents by default
95
+  // $('.panel-group .panel-body').hide();
96
+
87 97
   $('.panel-group .panel-body').hide();
88 98
 
89 99
   $('#outcome-display').parent().hide();
@@ -97,23 +107,50 @@ $(document).ready(function()
97 107
   // --------------------------------------------------------------------------
98 108
 
99 109
    // When list item is clicked, load corresponding info
110
+   $('#expected-outcome .form-control').on('change', function(){
111
+          
112
+           program_id = {{$program->id}};
113
+
114
+           semester_id = $('#expected-outcome').data('semester-id');
115
+            $.post(
116
+            "../annual-plan-CreateOrEdit/{{$program->id}}",
117
+            { 
118
+              program_id: program_id,
119
+              semester_id: semester_id,
120
+              expected_target: $('#expected-outcome .form-control').val(),
121
+            },
122
+
123
+            ) 
124
+      
125
+           });
100 126
 
101 127
 });
102
-   function fetchEverything(li)
128
+  //   function CreateOrEdit(id){
129
+  //   //send data to the database
130
+  //   console.log(id);
131
+  //   annual_id = $("#"+id);
132
+  //   console.log(console.log(annual_id));
133
+  // }
134
+
135
+     function fetchEverything(li)
103 136
   {
104 137
     var id = $(li).data('outcome-id');
105 138
     var name = $(li).data('outcome-name');
106 139
     var semester = $(li).data('semester-id');
107 140
     var annual_plan = $(li).data('annual-plan');
141
+    $('#expected-outcome').data('semester-id', semester);
142
+
143
+    
144
+    
108 145
     $('#theChange').data('annual-plan', annual_plan);
109 146
     $.post(
110 147
     "../annual-plan-fetchTYP/{{$program->id}}",
111 148
     { id: id,
112 149
     semester: semester
113 150
   },
151
+
114 152
     function(json)
115 153
     {
116
-        // Retrieve datatable instance
117 154
         
118 155
         
119 156
 
@@ -139,6 +176,28 @@ $(document).ready(function()
139 176
 
140 177
         //Display title and definition
141 178
         $('#outcome-display .panel-title').html(name);
179
+
180
+
181
+        var expected_target = json.expected_target;
182
+
183
+
184
+        //check the data type of the expected target   
185
+        //if the expected_target var is an empty array, set default value
186
+        if(expected_target.length == 0)
187
+        {
188
+          $('#expected-outcome .form-control').val(0);
189
+          
190
+          
191
+        }
192
+        else
193
+        {
194
+          $('#expected-outcome .form-control').val(expected_target[0].expected_target);
195
+      
196
+        
197
+          
198
+        }
199
+        
200
+        
142 201
      
143 202
 
144 203
         //Empty table