<?php
class Customersmodel extends CI_Model
{
    var $id;
    var $name = "";
    var $url = "";
    var $bsn_phone = "";
    var $account_manager = "";
    var $technician = "";
    var $contact_person = "";
    var $contact_phone = "";
    var $opt_crossindusry = 0;
    var $opt_discounts = 0;
    var $opt_cashback = 0;
    var $opt_localredemption = 0;
    var $client_extid = "";
    var $consumer_secret = "";
    var $consumer_key = "";
    var $addedby = "";
    var $addedon;
    var $record_state = 0;

    function __construct()
    {
        parent::__construct();
    }

    function get($condition = "")
    {
        if (!empty($condition))
            $this->db->where($condition);
        return $this->db->get('customers');
    }

    function update($data, $condition)
    {
        return $this->db->update('customers', $data, $condition);
    }

    function insert($clientid, $secret, $key)
    {
        $this->name = $this->input->post("contact_person");
        $this->url = $this->input->post("url");
        $this->bsn_phone = $this->input->post("contact_person");
        $this->account_manager = $this->input->post("account_manager");
        $this->technician = $this->input->post("technician");
        $this->contact_person = $this->input->post("contact_person");
        $this->contact_phone = $this->input->post("contact_phone");
        $this->opt_crossindusry = $this->input->post("crossindustry");
        $this->opt_discounts = $this->input->post("discount");
        $this->opt_cashback = $this->input->post("cashback");
        $this->opt_localredemption = $this->input->post("localredemption");
        $this->client_extid = $clientid;
        $this->consumer_secret = $secret;
        $this->consumer_key = $key;
        $this->addedby = $this->session->userdata('username');
        $this->addedon = date('Y-m-d H:i:s');
        $this->record_state = 0;

        return $this->db->insert('customers', $this);
    }
}
