Adding career filter and fixing order in promotions see BT#2386

skala
Julio Montoya 14 years ago
parent bfe17e2e6c
commit a5a3319baf
  1. 39
      main/admin/career_dashboard.php
  2. 31
      main/inc/lib/database.lib.php
  3. 4
      main/inc/lib/promotion.lib.php

@ -30,25 +30,52 @@ $interbreadcrumb[]=array('url' => 'career_dashboard.php','name' => get_lang('Car
Display :: display_header($nameTools);
$form = new FormValidator('filter_form','GET', api_get_self());
$career = new Career();
$condition = array('status = ?' => 1);
if ($form->validate()) {
$data = $form->getSubmitValues();
$filter = intval($data['filter']);
if (!empty($filter)) {
$condition = array('status = ? AND id = ? ' => array(1, $filter));
}
}
$careers = $career->get_all(array('status = ?' => 1)); //only status =1
$career_select_list = array();
$career_select_list[0] = ' -- '.get_lang('Select').' --';
foreach ($careers as $item) {
$career_select_list[$item['id']] = $item['name'];
}
$form->addElement('select', 'filter', get_lang('Career'), $career_select_list);
$form->addElement('style_submit_button', 'submit', get_lang('Filter'), 'class="search"');
// action links
echo '<div class="actions" style="margin-bottom:20px">';
echo '<a href="../admin/index.php">'.Display::return_icon('back.png', get_lang('BackTo').' '.get_lang('PlatformAdmin'),'','32').'</a>';
echo '<a href="../admin/index.php">'.Display::return_icon('back.png', get_lang('BackTo').' '.get_lang('PlatformAdmin'),'','32').'</a>';
echo '<a href="careers.php">'.Display::return_icon('career.png',get_lang('Careers'),'','32').'</a>';
echo '<a href="promotions.php">'.Display::return_icon('promotion.png',get_lang('Promotions'),'','32').'</a>';
echo '<a href="promotions.php">'.Display::return_icon('promotion.png',get_lang('Promotions'),'','32').'</a>';
echo '</div>';
$form->display();
$careers = $career->get_all($condition); //only status =1
$career = new Career();
$careers = $career->get_all(array('status = ?'=>1)); //only status =1
$column_count = 3;
$i = 0;
$grid_js = '';
$career_array = array();
if (!empty($careers)) {
foreach($careers as $career_item) {
foreach($careers as $career_item) {
$promotion = new Promotion();
//Getting all promotions
$promotions = $promotion->get_all_promotions_by_career_id($career_item['id']);
$promotions = $promotion->get_all_promotions_by_career_id($career_item['id'], 'name DESC');
$career_content = '';
$promotion_array = array();
if (!empty($promotions)) {

@ -1359,10 +1359,7 @@ class Database {
}
}
$sql = "SELECT $clean_columns FROM $table_name $conditions";
$sql = "SELECT $clean_columns FROM $table_name $conditions";
$result = self::query($sql);
$array = array();
@ -1391,11 +1388,14 @@ class Database {
if (empty($conditions)) {
return '';
}
$return_value = '';
foreach ($conditions as $type_condition => $condition_data) {
$return_value = '';
foreach ($conditions as $type_condition => $condition_data) {
if ($condition_data == false) {
continue;
}
$type_condition = strtolower($type_condition);
switch($type_condition) {
case 'where':
switch($type_condition) {
case 'where':
foreach ($condition_data as $condition => $value_array) {
if (is_array($value_array)) {
$clean_values = array();
@ -1418,12 +1418,11 @@ class Database {
if (!empty($where_return)) {
$return_value = " WHERE $where_return" ;
}
break;
break;
case 'order':
$order_array = explode(' ', $condition_data);
if (!empty($order_array)) {
if (count($order_array) > 1) {
if (count($order_array) > 1 && !empty($order_array[0])) {
$order_array[0] = self::escape_string($order_array[0]);
if (!empty($order_array[1])) {
$order_array[1] = strtolower($order_array[1]);
@ -1434,11 +1433,10 @@ class Database {
}
$return_value .= ' ORDER BY '.$order_array[0].' '.$order;
} else {
$return_value .= ' ORDER BY '.$order_array[0].' DESC ';
$return_value .= ' ORDER BY '.$order_array[0].' DESC ';
}
}
break;
}
break;
case 'limit':
$limit_array = explode(',', $condition_data);
if (!empty($limit_array)) {
@ -1448,8 +1446,7 @@ class Database {
$return_value .= ' LIMIT '.intval($limit_array[0]);
}
}
break;
break;
}
}
return $return_value;

@ -27,8 +27,8 @@ class Promotion extends Model {
* @param int career id
* @return array results
*/
public function get_all_promotions_by_career_id($career_id) {
return Database::select('*', $this->table, array('where'=>array('career_id = ?'=>$career_id)));
public function get_all_promotions_by_career_id($career_id, $order = false) {
return Database::select('*', $this->table, array('where'=>array('career_id = ?'=>$career_id),'order' =>$order));
}
public function get_status_list() {

Loading…
Cancel
Save