https://t.me/RX1948
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/kanvakanva.com/public_html/application/models/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

Current File : //var/www/kanvakanva.com/public_html/application/models/Reward_customer_m.php
<?php  if ( ! defined('BASEPATH')) exit('No direct script access allowed');

class Reward_customer_m extends MY_Model {
	
	protected $_table_name = 'reward_customer';
	protected $_primary_key = 'id_reward_customer'; 
	protected $_order_by = 'id_reward_customer';

	public $rules = array(  
    array(
        'field'   => 'point',
        'label'   => 'point',
        'rules'   => 'trim|required'
  ),  
  );

	function __construct() {
		parent::__construct();	
	}	
	
	//pagination included
	function get_all_reward($limit, $start) {
		$this->db->select("a.*,if(a.id_products is not null, concat('Free Products: ',b.title), 'Discount') as title");
		$this->db->from('reward_customer a');
        $this->db->join('products b','a.id_products=b.id_products','left');
		$this->db->order_by('a.id_reward_customer', 'ASC');
		$this->db->limit($limit, $start);
		$query = $this->db->get();		
		return $query->result();
	}

	//function to display new reward, where all fields are empty
	public function get_new() {
		$reward = new stdClass();
		$reward->id_products = '';	
		$reward->min_buy = '';	
		$reward->discount = '';	
		$reward->point = '';
		return $reward;
	}

	//get all reward 
	function get_reward() {
		$this->db->select("a.*,if(a.id_products is not null, concat('Free Products: ',b.title), 'Discount') as title");
		$this->db->from('reward_customer a');
        $this->db->join('products b','a.id_products=b.id_products','left');
		$this->db->order_by('a.id_reward_customer', 'ASC');
		$query = $this->db->get();		
		return $query->result();
	}
	
	//function add new reward
	function add_reward($data) {
		$this->db->insert('reward_customer', $data);	
		return $this->db->insert_id();	 
	}
	
	//function edit reward
	function edit_reward($id, $data) {
		$this->db->where('id_reward_customer', $id);
		$this->db->update('reward_customer', $data);	
	}
	
	//function count all record for reward
	public function record_count() {
        return $this->db->get('reward_customer')->num_rows();
    }

    //function count if existing record exist
	public function count_exist($id) {
        $this->db->select("a.*,if(a.id_products is not null, concat('Free Products: ',b.title), 'Discount') as title");
		$this->db->from('reward_customer a');
        $this->db->join('products b','a.id_products=b.id_products','left');
        $this->db->where('a.id_reward_customer', $id);
        $query = $this->db->get();		
		return $query->num_rows();
    }

	//cek if reward title already exist
	public function cek_existing_reward_title($str, $reward_id) {

		$this->db->select('id_reward_customer');
		$this->db->from('reward_customer');
		$this->db->where('title', $str);

		if ($reward_id != NULL) {
			$this->db->where('id_reward_customer !=', $reward_id);	
		} 
		$query = $this->db->get();
		return $query->num_rows();
	}	

    //load product not already exist in list reward
    function get_products($id_products=""){
        $where = "";
        if($id_products != ''){
            $where = " or id_products='$id_products'";
        }

        $this->db->select("id_products,title");
        $this->db->from("products");
        $this->db->where("(id_products not in (select id_products from reward_customer where id_products is not null) $where)");
        $this->db->where('products.product_status', '1');
        $this->db->order_by("title");
        $query = $this->db->get();		
		return $query->result();
    }

    function get_edit($id){
        $this->db->select("a.*,if(a.id_products is not null, concat('Free Products: ',b.title), 'Discount') as title");
		$this->db->from('reward_customer a');
        $this->db->join('products b','a.id_products=b.id_products','left');
        $this->db->where('a.id_reward_customer', $id);
        $query = $this->db->get();		
		return $query->row();
    }
}

https://t.me/RX1948 - 2025