|
Server : Apache/2.4.18 (Ubuntu) System : Linux canvaswebdesign 3.13.0-71-generic #114-Ubuntu SMP Tue Dec 1 02:34:22 UTC 2015 x86_64 User : oppastar ( 1041) PHP Version : 7.0.33-0ubuntu0.16.04.15 Disable Function : pcntl_alarm,pcntl_fork,pcntl_waitpid,pcntl_wait,pcntl_wifexited,pcntl_wifstopped,pcntl_wifsignaled,pcntl_wifcontinued,pcntl_wexitstatus,pcntl_wtermsig,pcntl_wstopsig,pcntl_signal,pcntl_signal_dispatch,pcntl_get_last_error,pcntl_strerror,pcntl_sigprocmask,pcntl_sigwaitinfo,pcntl_sigtimedwait,pcntl_exec,pcntl_getpriority,pcntl_setpriority, Directory : /var/www/mesinpolesshinemate.com/application/models/ |
Upload File : |
<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
class Reseller_m extends MY_Model {
protected $_table_name = 'resellers';
protected $_primary_key = 'id_resellers';
protected $_order_by = 'id_resellers';
public $admin_rules = array(
'reseller_name' => array(
'field'=>'reseller_name',
'label'=>'reseller_name',
'rules'=>'trim|required|callback_cek_reseller_name'),
'global_discount' => array(
'field'=>'global_discount',
'label'=>'global_discount',
'rules'=>'trim')
);
function __construct() {
parent::__construct();
}
//get reseller by id reseller
function get_reseller($id_reseller) {
$this->db->select('name, email, phone');
$this->db->from('resellers');
$this->db->where('id_resellers', $id_reseller);
$query = $this->db->get();
return $query->row();
}
//update reseller profile
function update_profile($id, $data) {
$this->db->where('id_resellers', $id);
$this->db->update('resellers', $data);
}
//get shipping
function get_shipping($id_reseller) {
$this->db->select('*');
$this->db->from('resellers');
$this->db->where('id_resellers', $id_reseller);
$query = $this->db->get();
return $query->row();
}
//update shipping
function update_shipping($id, $data) {
$this->db->where('id_resellers', $id);
$this->db->update('resellers', $data);
}
//function to return a new user
public function get_new() {
$user = new stdClass();
$user->reseller_name = '';
$user->global_discount = '';
$user->voucher_valid = '';
$user->pointrewards_valid = '';
$user->active = '';
return $user;
}
//function count all record for resellers
public function record_count() {
return $this->db->get('resellers')->num_rows();
}
//get all reseller with pagination included
function get_all_resellers($limit, $start) {
$this->db->select('*');
$this->db->from('resellers');
$this->db->limit($limit, $start);
$query = $this->db->get();
return $query->result();
}
//count existing email
function cek_existing_reseller($reseller_name, $reseller_id) {
$this->db->select('id_resellers');
$this->db->from('resellers');
$this->db->where('reseller_name', $reseller_name);
if ($reseller_id != NULL) {
$this->db->where('id_resellers !=', $reseller_id);
}
$query = $this->db->get();
return $query->num_rows();
}
}