0byt3m1n1
Path:
/
data
/
17
/
1
/
18
/
11
/
1670011
/
user
/
1801231
/
htdocs
/
marketting
/
system
/
application
/
models
/
[
Home
]
File: credits_model.php
<?php if (!defined('BASEPATH')) exit('No direct script access allowed'); /* | ------------------------------------------------------------------------- | COPYRIGHT NOTICE | Copyright 2008 JROX Technologies, Inc. All Rights Reserved. | ------------------------------------------------------------------------- | This script may be only used and modified in accordance to the license | agreement attached (license.txt) except where expressly noted within | commented areas of the code body. This copyright notice and the | comments above and below must remain intact at all times. By using this | code you agree to indemnify JROX Technologies, Inc, its corporate agents | and affiliates from any liability that might arise from its use. | | Selling the code for this program without prior written consent is | expressly forbidden and in violation of Domestic and International | copyright laws. | | ------------------------------------------------------------------------- | FILENAME - credits_model.php | ------------------------------------------------------------------------- | | This model handles the functions for managing the members credits | */ class Credits_Model extends Model { function _add_credit($id = '', $array = '') { $data = $this->db_validation_model->_clean_data($array); $data['member_id'] = $id; $data['date'] = _generate_timestamp(); //insert into db if (!$this->db->insert('members_credits', $data)) { show_error($this->lang->line('could_not_add_credit')); //log error log_message('error', 'Could not insert credit into members_credits table'); return false; } else { $credit_id = $this->db->insert_id(); //log success log_message('info', 'credit '. $credit_id . ' inserted into members_credits table'); } return $credit_id; } // ------------------------------------------------------------------------ function _update_credit($id = '', $array = '') { $data = $this->db_validation_model->_clean_data($array); $this->db->where('id', $id); if (!$this->db->update('members_credits', $data)) { show_error($this->lang->line('could_not_update_credit')); //log error log_message('error', 'Could not update credit into members_credits table'); return false; } else { //log success log_message('info', 'credit '. $id . ' updated in members_credits table'); } return true; } // ------------------------------------------------------------------------ function _get_total_credits($id = '') { $sql = 'SELECT SUM(amount) as credits FROM ' . $this->db->dbprefix('members_credits') . ' WHERE member_id = ' . $id . ' AND invoice_id = \'0\''; $query = $this->db->query($sql); if ($query->num_rows() > 0) { $credits = $query->row_array(); return $credits['credits']; } return false; } // ------------------------------------------------------------------------ function _get_member_credit_details($id = '') { $this->db->where('id', $id); $query = $this->db->get('members_credits'); if ($query->num_rows() > 0) { return $query->result_array(); } return false; } // ------------------------------------------------------------------------ function _delete_credit($id = '') { $this->db->where('id', $id); if ($query = $this->db->delete('members_credits')) { return true; } return false; } // ------------------------------------------------------------------------ function _get_member_credits($limit = 25, $offset = 0, $sort_column = '', $sort_order = '', $where_column = '', $where_value = '') { //get all the members from db for list view if (!$sort_order) $sort_order = $this->config->item('dbs_cre_order'); if (!$sort_column) $sort_column = $this->config->item('dbs_cre_column'); $this->db->where($where_column, $where_value); $this->db->order_by($sort_column, $sort_order); $query = $this->db->get('members_credits', $limit, $offset); if ($query->num_rows() > 0) { return $query->result_array(); } return false; } // ------------------------------------------------------------------------ } ?>