Browse Source

Fixing column order + avoiding some warnings

Julio Montoya 14 years ago
parent
commit
5a1b3d57d3
4 changed files with 18 additions and 12 deletions
  1. 6 4
      main/admin/careers.php
  2. 3 1
      main/admin/promotions.php
  3. 8 6
      main/inc/ajax/model.ajax.php
  4. 1 1
      main/session/index.php

+ 6 - 4
main/admin/careers.php

@@ -47,6 +47,7 @@ if (isset($_GET['action']) && $_GET['action'] == 'editnote') {
 }
 
 $url            = api_get_path(WEB_AJAX_PATH).'model.ajax.php?a=get_careers';
+//The order is important you need to check the model.ajax.php the $column variable
 $columns        = array(get_lang('Name'),get_lang('Description'),get_lang('Actions'));
 $column_model   = array(array('name'=>'name',           'index'=>'name',        'width'=>'80',   'align'=>'left'),
                         array('name'=>'description',    'index'=>'description', 'width'=>'500',  'align'=>'left'),
@@ -55,17 +56,18 @@ $column_model   = array(array('name'=>'name',           'index'=>'name',
 $extra_params['autowidth'] = 'true'; //use the width of the parent
 $extra_params['height'] = 'auto'; //use the width of the parent
 
+//With this function we can add actions to the jgrid
 $action_links = 'function action_formatter (cellvalue, options, rowObject) {
-                         return \'<a href="?action=edit&id=\'+options.rowId+\'"><img src="../img/edit.gif" title="'.get_lang('Edit').'"></a><a href="?action=delete&id=\'+options.rowId+\'"><img title="'.get_lang('Delete').'" src="../img/delete.gif"></a>\'; 
+                         return \'<a href="?action=edit&id=\'+options.rowId+\'"><img src="../img/edit.gif" title="'.get_lang('Edit').'"></a> <a href="?action=delete&id=\'+options.rowId+\'"><img title="'.get_lang('Delete').'" src="../img/delete.gif"></a>\'; 
                  }';
                  
 
 ?>
 <script>
 $(function() {    
-    <?php 
-         echo Display::grid_js('careers',  $url,$columns,$column_model,$extra_params,array(), $action_links);       
-    ?> 
+<?php 
+     echo Display::grid_js('careers',  $url,$columns,$column_model,$extra_params, array(), $action_links);       
+?> 
 });
 </script>   
 <?php

+ 3 - 1
main/admin/promotions.php

@@ -43,6 +43,7 @@ if (isset($_GET['action']) && $_GET['action'] == 'edit') {
 }
 
 $url            = api_get_path(WEB_AJAX_PATH).'model.ajax.php?a=get_promotions';
+//The order is important you need to check the model.ajax.php the $column variable
 $columns        = array(get_lang('Name'),get_lang('Career'),get_lang('Description'),get_lang('Actions'));
 $column_model   = array(array('name'=>'name',           'index'=>'name',        'width'=>'80',   'align'=>'left'),
                         array('name'=>'career',         'index'=>'career',      'width'=>'100',  'align'=>'left'),
@@ -51,8 +52,9 @@ $column_model   = array(array('name'=>'name',           'index'=>'name',
                        );                        
 $extra_params['autowidth'] = 'true'; //use the width of the parent
 //$extra_params['editurl'] = $url; //use the width of the parent
-$extra_params['height'] = 'auto'; //use the width of the parent
 
+$extra_params['height'] = 'auto'; //use the width of the parent
+//With this function we can add actions to the jgrid
 $action_links = 'function action_formatter (cellvalue, options, rowObject) {
                     return \'<a href="add_sessions_to_promotion.php?id=\'+options.rowId+\'"><img title="'.get_lang('AddSession').'" src="../img/addd.gif"></a> <a href="?action=edit&id=\'+options.rowId+\'"><img src="../img/edit.gif" title="'.get_lang('Edit').'"></a>  <a href="?action=delete&id=\'+options.rowId+\'"><img title="'.get_lang('Delete').'" src="../img/delete.gif"></a>\'; 
                  }';

+ 8 - 6
main/inc/ajax/model.ajax.php

@@ -49,30 +49,32 @@ if ($page > $total_pages) {
 $start = $limit * $page - $limit; 
 
 //2. Querying the DB
+$columns = array();
 switch ($action) {
     case 'get_careers':
         if ($_REQUEST['oper'] == 'del') {
             $obj->delete($_REQUEST['id']);
         }
-        $columns    = $obj->columns;
-        $columns[]  = 'actions';        
+        $columns = array('name', 'description', 'actions');        
         $result     = Database::select('*', $obj->table, array('order'=>"$sidx $sord", 'LIMIT'=> "$start , $limit"));
     break;
     case 'get_promotions':
         if ($_REQUEST['oper'] == 'del') {
         	$obj->delete($_REQUEST['id']);
         }
-        $columns    = $obj->columns;
-        $columns[]  = 'career';
-        $columns[]  = 'actions';                
+        $columns = array('name', 'career', 'description', 'actions');                        
         $result     = Database::select('p.id, p.name, p.description, c.name as career', "$obj->table p LEFT JOIN ".Database::get_main_table(TABLE_CAREER)." c  ON c.id = p.career_id ", array('order' =>"$sidx $sord", 'LIMIT'=> "$start , $limit"));       
     break;
     default:
         exit;            
 }
 
+
+//echo '<pre>';
+
+
 if (in_array($action, array('get_careers','get_promotions'))) {
-    //3. Creating an obj return a json
+    //3. Creating an obj to return a json
     $responce = new stdClass();           
     $responce->page     = $page; 
     $responce->total    = $total_pages; 

+ 1 - 1
main/session/index.php

@@ -168,7 +168,7 @@ foreach($final_array as $session_data) {
                     exe_id*/
                     $score          = $exercise_result['exe_result'].' / '.$exercise_result['exe_weighting'];
                     $platform_score = show_score($exercise_result['exe_result'], $exercise_result['exe_weighting'], false);
-                    if (!empty($exercise_result['exe_weighting'])) {
+                    if (!empty($exercise_result['exe_weighting']) && intval($exercise_result['exe_weighting']) != 0 ) {                        
                         $my_score = $exercise_result['exe_result']/$exercise_result['exe_weighting'];
                     } else {
                     	$my_score = 0;