Browse Source

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

parent
commit
db45d56367

+ 22
- 0
app/controllers/AnnualPlansController.php View File

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')));
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
     $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];
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
     $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
     $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
     $typ_info['transformative_actions'] = DB::select("select * from transformative_actions where by_professor =0 and is_custom=0");
255
     $typ_info['transformative_actions'] = DB::select("select * from transformative_actions where by_professor =0 and is_custom=0");
255
     foreach ($typ_info['objectives'] as $objective) {
256
     foreach ($typ_info['objectives'] as $objective) {
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
   public function transformativeReport()
353
   public function transformativeReport()
332
   {
354
   {
333
     $json_to_send = array();
355
     $json_to_send = array();

+ 1
- 0
app/routes.php View File

488
 
488
 
489
         Route::get('annual-plan-program/{program_id}/{typ_id?}', 'AnnualPlansController@showPlan');
489
         Route::get('annual-plan-program/{program_id}/{typ_id?}', 'AnnualPlansController@showPlan');
490
         Route::post('annual-plan-fetchTYP/{program_id}', 'AnnualPlansController@fetchTYP');
490
         Route::post('annual-plan-fetchTYP/{program_id}', 'AnnualPlansController@fetchTYP');
491
+        Route::post('annual-plan-CreateOrEdit/{program_id}', 'AnnualPlansController@CreateOrEdit');
491
         Route::post('annual-plan-postOnChange', 'AnnualPlansController@postAnnualPlan');
492
         Route::post('annual-plan-postOnChange', 'AnnualPlansController@postAnnualPlan');
492
         Route::post('annual-plan-deleteCriteria', 'AnnualPlansController@deleteCriteria');
493
         Route::post('annual-plan-deleteCriteria', 'AnnualPlansController@deleteCriteria');
493
 
494
 

+ 62
- 3
app/views/local/managers/shared/annual-plans.blade.php View File

41
     
41
     
42
 
42
 
43
     <div class="col-md-9">
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
       <div id="outcome-display" class="panel panel-default">
52
       <div id="outcome-display" class="panel panel-default">
45
         <div class="panel-heading">
53
         <div class="panel-heading">
46
-          <h4 class=" panel-title" style="cursor:auto!important;">
54
+          <h4 class=" panel-title" >
47
             Primer Semestre 2019-2020
55
             Primer Semestre 2019-2020
48
           </h4>
56
           </h4>
49
         </div>
57
         </div>
84
   // --------------------------------------------------------------------------
92
   // --------------------------------------------------------------------------
85
 
93
 
86
   // Hide accordion panel contents by default
94
   // Hide accordion panel contents by default
95
+  // $('.panel-group .panel-body').hide();
96
+
87
   $('.panel-group .panel-body').hide();
97
   $('.panel-group .panel-body').hide();
88
 
98
 
89
   $('#outcome-display').parent().hide();
99
   $('#outcome-display').parent().hide();
97
   // --------------------------------------------------------------------------
107
   // --------------------------------------------------------------------------
98
 
108
 
99
    // When list item is clicked, load corresponding info
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
     var id = $(li).data('outcome-id');
137
     var id = $(li).data('outcome-id');
105
     var name = $(li).data('outcome-name');
138
     var name = $(li).data('outcome-name');
106
     var semester = $(li).data('semester-id');
139
     var semester = $(li).data('semester-id');
107
     var annual_plan = $(li).data('annual-plan');
140
     var annual_plan = $(li).data('annual-plan');
141
+    $('#expected-outcome').data('semester-id', semester);
142
+
143
+    
144
+    
108
     $('#theChange').data('annual-plan', annual_plan);
145
     $('#theChange').data('annual-plan', annual_plan);
109
     $.post(
146
     $.post(
110
     "../annual-plan-fetchTYP/{{$program->id}}",
147
     "../annual-plan-fetchTYP/{{$program->id}}",
111
     { id: id,
148
     { id: id,
112
     semester: semester
149
     semester: semester
113
   },
150
   },
151
+
114
     function(json)
152
     function(json)
115
     {
153
     {
116
-        // Retrieve datatable instance
117
         
154
         
118
         
155
         
119
 
156
 
139
 
176
 
140
         //Display title and definition
177
         //Display title and definition
141
         $('#outcome-display .panel-title').html(name);
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
         //Empty table
203
         //Empty table