<?php

class Customer extends CI_Model
{
    public $customerid;
    public $lastname;
    public $firstname;
    public $dob;
    public $contactinfo;
    public $emailadd;
    public $address;
    public $editdate;
    public $creationdate;

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

        $this->load->database();
    }

    
    public function getCustomerByLimit($from, $to)
    {
        return $this->db->get("customer", $from, $to);
    }

    public function getAllCustomerOrderBy($col, $order)
    {
        return $this->db->order_by($col, $order)->get("customer");
    }


    public function addNewCustomer()
    {
        $data = array(
            "lastname" => $this->lastname,
            "firstname" => $this->firstname,
            "dob" => $this->dob,
            "contactinfo" => $this->contactinfo,
            "emailadd" => $this->emailadd,
            "address" => $this->address
        );

        $this->db->set($data);
        $this->db->set("editdate", "NOW()", FALSE);
        $success = $this->db->set("creationdate", "NOW()", FALSE)->insert("customer");

        if($success)
            return array("success"=>$success, "data" => $this->db->insert_id());
        else
            return array("success"=>$success, "data" => $this->db->error());
    }
}