|
|
|
@ -17,24 +17,25 @@ define ('PROMOTION_STATUS_INACTIVE',0); |
|
|
|
|
/** |
|
|
|
|
* @package chamilo.library |
|
|
|
|
*/ |
|
|
|
|
class Promotion extends Model { |
|
|
|
|
class Promotion extends Model |
|
|
|
|
{ |
|
|
|
|
public $table; |
|
|
|
|
public $columns = array('id','name','description','career_id','status','created_at','updated_at'); |
|
|
|
|
|
|
|
|
|
var $table; |
|
|
|
|
var $columns = array('id','name','description','career_id','status','created_at','updated_at'); |
|
|
|
|
|
|
|
|
|
public function __construct() { |
|
|
|
|
public function __construct() |
|
|
|
|
{ |
|
|
|
|
$this->table = Database::get_main_table(TABLE_PROMOTION); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
* Get the count of elements |
|
|
|
|
*/ |
|
|
|
|
public function get_count() { |
|
|
|
|
public function get_count() |
|
|
|
|
{ |
|
|
|
|
$row = Database::select('count(*) as count', $this->table, array(), 'first'); |
|
|
|
|
return $row['count']; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
* Copies the promotion to a new one |
|
|
|
|
* @param integer Promotion ID |
|
|
|
@ -42,7 +43,8 @@ class Promotion extends Model { |
|
|
|
|
* @param boolean Whether or not to copy the sessions inside |
|
|
|
|
* @return integer New promotion ID on success, false on failure |
|
|
|
|
*/ |
|
|
|
|
public function copy($id, $career_id = null, $copy_sessions = false) { |
|
|
|
|
public function copy($id, $career_id = null, $copy_sessions = false) |
|
|
|
|
{ |
|
|
|
|
$pid = false; |
|
|
|
|
$promotion = $this->get($id); |
|
|
|
|
if (!empty($promotion)) { |
|
|
|
@ -105,13 +107,19 @@ class Promotion extends Model { |
|
|
|
|
/** |
|
|
|
|
* Gets all promotions by career id |
|
|
|
|
* @param int career id |
|
|
|
|
* @param bool $order |
|
|
|
|
* @return array results |
|
|
|
|
*/ |
|
|
|
|
public function get_all_promotions_by_career_id($career_id, $order = false) { |
|
|
|
|
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() { |
|
|
|
|
/** |
|
|
|
|
* @return array |
|
|
|
|
*/ |
|
|
|
|
public function get_status_list() |
|
|
|
|
{ |
|
|
|
|
return array(PROMOTION_STATUS_ACTIVE => get_lang('Active'), PROMOTION_STATUS_INACTIVE => get_lang('Inactive')); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
@ -134,7 +142,8 @@ class Promotion extends Model { |
|
|
|
|
* @param int promotion id |
|
|
|
|
* @param int status (1, 0) |
|
|
|
|
*/ |
|
|
|
|
public function update_all_sessions_status_by_promotion_id($promotion_id, $status) { |
|
|
|
|
public function update_all_sessions_status_by_promotion_id($promotion_id, $status) |
|
|
|
|
{ |
|
|
|
|
$session_list = SessionManager::get_all_sessions_by_promotion($promotion_id); |
|
|
|
|
if (!empty($session_list)) { |
|
|
|
|
foreach($session_list as $item) { |
|
|
|
@ -152,8 +161,8 @@ class Promotion extends Model { |
|
|
|
|
* @return obj form validator obj |
|
|
|
|
*/ |
|
|
|
|
|
|
|
|
|
function return_form($url, $action = 'add') { |
|
|
|
|
|
|
|
|
|
function return_form($url, $action = 'add') |
|
|
|
|
{ |
|
|
|
|
$oFCKeditor = new FCKeditor('description') ; |
|
|
|
|
$oFCKeditor->ToolbarSet = 'careers'; |
|
|
|
|
$oFCKeditor->Width = '100%'; |
|
|
|
@ -209,7 +218,8 @@ class Promotion extends Model { |
|
|
|
|
return $form; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
public function save($params, $show_query = false) { |
|
|
|
|
public function save($params, $show_query = false) |
|
|
|
|
{ |
|
|
|
|
$id = parent::save($params, $show_query); |
|
|
|
|
if (!empty($id)) { |
|
|
|
|
event_system(LOG_PROMOTION_CREATE, LOG_PROMOTION_ID, $id, api_get_utc_datetime(), api_get_user_id()); |
|
|
|
@ -217,7 +227,8 @@ class Promotion extends Model { |
|
|
|
|
return $id; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
public function delete($id) { |
|
|
|
|
public function delete($id) |
|
|
|
|
{ |
|
|
|
|
if (parent::delete($id)) { |
|
|
|
|
SessionManager::clear_session_ref_promotion($id); |
|
|
|
|
event_system(LOG_PROMOTION_DELETE, LOG_PROMOTION_ID, $id, api_get_utc_datetime(), api_get_user_id()); |
|
|
|
@ -225,6 +236,4 @@ class Promotion extends Model { |
|
|
|
|
return false; |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
|