eduardo-santin пре 3 година
родитељ
комит
76a41feb0e

+ 22
- 0
app/controllers/AnnualPlansController.php Прегледај датотеку

@@ -211,6 +211,7 @@ class AnnualPlansController extends \BaseController
211 211
     //  $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')));
212 212
     //}
213 213
     $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];
214
+    $typ_info['expected_target'] = DB::select("select * from target_outcomes_program where program_id = {$program_id} and semester_id = {$semester->id}");
214 215
     $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')));
215 216
     $typ_info['transformative_actions'] = DB::select("select * from transformative_actions where by_professor =0 and is_custom=0");
216 217
     foreach ($typ_info['objectives'] as $objective) {
@@ -289,6 +290,27 @@ class AnnualPlansController extends \BaseController
289 290
       }
290 291
     }
291 292
   }
293
+
294
+  public function CreateOrEdit($program_id){
295
+    $semester_id = Input::get('semester_id');
296
+    $expected_target = Input::get('expected_target');
297
+    $created_at = Input::get('created_at');
298
+    $updated_at = Input::get('updated_at');
299
+    $exist = DB::select("select * from target_outcomes_program where program_id = {$program_id} and semester_id = {$semester_id}");
300
+    //log both semester and program id
301
+    
302
+    if($exist){
303
+      //log the in the laravel log
304
+      Log::info("Updating target_outcomes_program");
305
+      DB::update("update target_outcomes_program set expected_target = {$expected_target}, updated_at = now() where program_id = {$program_id} and semester_id = {$semester_id}");
306
+    }
307
+    else{
308
+      //create a new one
309
+      Log::info("Creating target_outcomes_program");
310
+      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()}')");
311
+    }
312
+    return;
313
+  }
292 314
   public function transformativeReport()
293 315
   {
294 316
     $json_to_send = array();

+ 1
- 0
app/routes.php Прегледај датотеку

@@ -477,6 +477,7 @@ Route::group(array('before' => 'auth|has_access'), function () {
477 477
 
478 478
         Route::get('annual-plan-program/{program_id}/{typ_id?}', 'AnnualPlansController@showPlan');
479 479
         Route::post('annual-plan-fetchTYP/{program_id}', 'AnnualPlansController@fetchTYP');
480
+        Route::post('annual-plan-CreateOrEdit/{program_id}', 'AnnualPlansController@CreateOrEdit');
480 481
         Route::post('annual-plan-postOnChange', 'AnnualPlansController@postAnnualPlan');
481 482
         Route::post('annual-plan-deleteCriteria', 'AnnualPlansController@deleteCriteria');
482 483
 

+ 63
- 4
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,9 +92,11 @@ $(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
-  $('#outcome-display').parent().hide();
99
+  // $('#outcome-display').parent().hide();
90 100
 
91 101
   // --------------------------------------------------------------------------
92 102
   // Functions
@@ -97,23 +107,48 @@ $(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
+            //create the expected target in the database
112
+           program_id = {{$program->id}};
113
+           semester_id = $('#expected-outcome').data('semester-id');
114
+            $.post(
115
+            "../annual-plan-CreateOrEdit/{{$program->id}}",
116
+            { 
117
+              program_id: program_id,
118
+              semester_id: semester_id,
119
+              expected_target: $('#expected-outcome .form-control').val(),
120
+            },
121
+            ) 
122
+      
123
+           });
100 124
 
101 125
 });
102
-   function fetchEverything(li)
126
+  //   function CreateOrEdit(id){
127
+  //   //send data to the database
128
+  //   console.log(id);
129
+  //   annual_id = $("#"+id);
130
+  //   console.log(console.log(annual_id));
131
+  // }
132
+
133
+     function fetchEverything(li)
103 134
   {
104 135
     var id = $(li).data('outcome-id');
105 136
     var name = $(li).data('outcome-name');
106 137
     var semester = $(li).data('semester-id');
107 138
     var annual_plan = $(li).data('annual-plan');
139
+    $('#expected-outcome').data('semester-id', semester);
140
+
141
+    
142
+    
108 143
     $('#theChange').data('annual-plan', annual_plan);
109 144
     $.post(
110 145
     "../annual-plan-fetchTYP/{{$program->id}}",
111 146
     { id: id,
112 147
     semester: semester
113 148
   },
149
+
114 150
     function(json)
115 151
     {
116
-        // Retrieve datatable instance
117 152
         
118 153
         
119 154
 
@@ -139,6 +174,30 @@ $(document).ready(function()
139 174
 
140 175
         //Display title and definition
141 176
         $('#outcome-display .panel-title').html(name);
177
+
178
+
179
+        var expected_target = json.expected_target;
180
+        //check the data type of the expected target
181
+        // console.log(expected_target);
182
+        //if the expected_target var is an empty array, set default value
183
+        var created_at = new Date();
184
+            created_at = created_at.getFullYear()+"-"+created_at.getMonth()+"-"+created_at.getDate()
185
+             + " " + created_at.getHours() + ":" + created_at.getMinutes() + ":" + created_at.getSeconds();
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