diff --git a/main/admin/career_dashboard.php b/main/admin/career_dashboard.php index e2e81c1461..10ff258803 100644 --- a/main/admin/career_dashboard.php +++ b/main/admin/career_dashboard.php @@ -38,7 +38,7 @@ echo ''; $career = new Career(); -$careers = $career->get_all(); +$careers = $career->get_all(array('status = ?'=>1)); //only status =1 $column_count = 3; $i = 0; $grid_js = ''; @@ -52,6 +52,9 @@ if (!empty($careers)) { $promotion_array = array(); if (!empty($promotions)) { foreach($promotions as $promotion_item) { + if (!$promotion_item['status']) { + continue; //avoid status = 0 + } //Getting all sessions from this promotion $sessions = SessionManager::get_all_sessions_by_promotion($promotion_item['id']); diff --git a/main/admin/careers.php b/main/admin/careers.php index 9f012172c1..99a9575812 100644 --- a/main/admin/careers.php +++ b/main/admin/careers.php @@ -49,8 +49,8 @@ $columns = array(get_lang('Name'), get_lang('Description'), get_lang('Act //Column config $column_model = array( array('name'=>'name', 'index'=>'name', 'width'=>'80', 'align'=>'left'), - array('name'=>'description', 'index'=>'description', 'width'=>'500', 'align'=>'left'), - array('name'=>'actions', 'index'=>'actions', 'width'=>'100', 'align'=>'left','formatter'=>'action_formatter') + array('name'=>'description', 'index'=>'description', 'width'=>'500', 'align'=>'left','sortable'=>'false'), + array('name'=>'actions', 'index'=>'actions', 'width'=>'100', 'align'=>'left','formatter'=>'action_formatter','sortable'=>'false') ); //Autowidth $extra_params['autowidth'] = 'true'; @@ -119,11 +119,11 @@ if (isset($_GET['action']) && $_GET['action'] == 'add') { if ($check) { $values = $form->exportValues(); $career->update_all_promotion_status_by_career_id($values['id'],$values['status']); - $res = $career->update($values); + $res = $career->update($values); if ($values['status']) { - Display::display_confirmation_message(sprintf(get_lang('CareerXArchived'), $values['name']), false); + Display::display_confirmation_message(sprintf(get_lang('CareerXUnarchived'), $values['name']), false); } else { - Display::display_confirmation_message(sprintf(get_lang('CareerXUnarchived'), $values['name']), false); + Display::display_confirmation_message(sprintf(get_lang('CareerXArchived'), $values['name']), false); } } Security::clear_token(); diff --git a/main/admin/promotions.php b/main/admin/promotions.php index aa8019ea13..ef5b1c8415 100644 --- a/main/admin/promotions.php +++ b/main/admin/promotions.php @@ -55,8 +55,8 @@ $columns = array(get_lang('Name'),get_lang('Career'),get_lang('Descriptio $column_model = array( array('name'=>'name', 'index'=>'name', 'width'=>'80', 'align'=>'left'), array('name'=>'career', 'index'=>'career', 'width'=>'100', 'align'=>'left'), - array('name'=>'description', 'index'=>'description', 'width'=>'500', 'align'=>'left'), - array('name'=>'actions', 'index'=>'actions', 'width'=>'100', 'align'=>'left','formatter'=>'action_formatter'), + array('name'=>'description', 'index'=>'description', 'width'=>'500', 'align'=>'left','sortable'=>'false'), + array('name'=>'actions', 'index'=>'actions', 'width'=>'100', 'align'=>'left','formatter'=>'action_formatter','sortable'=>'false'), ); $extra_params['autowidth'] = 'true'; //use the width of the parent //$extra_params['editurl'] = $url; //use the width of the parent diff --git a/main/inc/ajax/model.ajax.php b/main/inc/ajax/model.ajax.php index 240d76bba1..3a41069ba0 100644 --- a/main/inc/ajax/model.ajax.php +++ b/main/inc/ajax/model.ajax.php @@ -76,13 +76,31 @@ switch ($action) { $sidx = 'name'; } $result = Database::select('*', $obj->table, array('order'=>"$sidx $sord", 'LIMIT'=> "$start , $limit")); + $new_result = array(); + foreach($result as $item) { + if (!$item['status']) { + $item['name'] = ''.$item['name'].''; + } + $new_result[] = $item; + } + $result = $new_result; + break; case 'get_promotions': $columns = array('name', 'career', 'description', 'actions'); if(!in_array($sidx, $columns)) { $sidx = 'name'; } - $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")); + $result = Database::select('p.id,p.name, p.description, c.name as career, p.status', "$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")); + $new_result = array(); + foreach($result as $item) { + if (!$item['status']) { + $item['name'] = ''.$item['name'].''; + } + $new_result[] = $item; + } + $result = $new_result; + break; case 'get_usergroups': $columns = array('name', 'users', 'courses','sessions','actions'); diff --git a/main/inc/lib/career.lib.php b/main/inc/lib/career.lib.php index 6a01273cea..b8fcb31c5a 100644 --- a/main/inc/lib/career.lib.php +++ b/main/inc/lib/career.lib.php @@ -24,8 +24,8 @@ class Career extends Model { $this->table = Database::get_main_table(TABLE_CAREER); } - public function get_all() { - return Database::select('*',$this->table, array('order' =>'name ASC')); + public function get_all($where_conditions = array()) { + return Database::select('*',$this->table, array('where'=>$where_conditions,'order' =>'name ASC')); } /**