|
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 : /proc/self/root/var/www/symphony-solusi.co.id/public_html/application/models/ |
Upload File : |
<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
class Project_m extends MY_Model {
protected $_table_name = 'project';
protected $_primary_key = 'id';
protected $_order_by = 'id';
private $website_project_ordering = NULL;
function __construct() {
parent::__construct();
//get website product ordering
$this->db->select('website_product_ordering')->from('configuration')->where('id_configuration', 1);
$this->website_product_ordering = $this->db->get()->row()->website_product_ordering;
}
public $rules = array(
array(
'field' => 'project_name',
'label' => 'project_name',
'rules' => 'trim|required|callback__cek_existing_project_name'
),
array(
'field' => 'project_type',
'label' => 'Project type',
'rules' => 'required'
),
array(
'field' => 'category_product',
'label' => 'Category',
'rules' => 'trim'
),
array(
'field' => 'glass_material',
'label' => 'Glass Material',
'rules' => 'trim'
),
array(
'field' => 'city',
'label' => 'City',
'rules' => 'trim'
),
array(
'field' => 'project_status',
'label' => 'Project Status',
'rules' => 'trim'
),
array(
'field' => 'priority',
'label' => 'Priority',
'rules' => 'trim'
)
);
//ADMIN WEBSITE
//pagination included
function get_all_project($limit, $start) {
$this->db->select('*');
$this->db->from('project');
$this->db->order_by('priority', 'ASC');
$this->db->limit($limit, $start);
$query = $this->db->get();
return $query->result();
}
//pagination included
function get_all_project_search_project($keyword) {
$this->db->select('*');
$this->db->from('project');
$this->db->like('project.category_product', $keyword);
$this->db->order_by('priority', 'DESC');
$query = $this->db->get();
return $query->result();
}
public function record_count() {
return $this->db->get('project')->num_rows();
}
public function record_count_search_product($keyword) {
$this->db->select('*');
$this->db->from('project');
$this->db->like('project.project_name', $keyword);
$query = $this->db->get();
return $query->num_rows();
}
public function get_new() {
$project = new stdClass();
$project->project_name = '';
$project->id = '';
$project->project_type = '';
$project->category_product= '';
$project->glass_material = '';
$project->city = '';
$project->project_status = '';
$project->priority = '';
return $project;
}
//function add new project
function add_project($data) {
$this->db->insert('project', $data);
return $this->db->insert_id();
}
//function edit product
function edit_project($id, $data) {
$this->db->where('id', $id);
$this->db->update('project', $data);
}
function selected_project($chosen_project_id)
{
$this->db->select('*');
$this->db->from('project');
$this->db->where('id', $chosen_project_id);
$query = $this->db->get();
return $query->row();
}
public function cek_existing_project_name($str, $project_current_id) {
$this->db->select('id');
$this->db->from('project');
$this->db->where('project_name', $str);
if ($project_current_id != NULL) {
$this->db->where('id !=', $project_current_id);
}
$query = $this->db->get();
return $query->num_rows();
}
//Public Page
public function get_project() {
$this->db->select('*');
$this->db->from('project');
$this->db->join('categories', 'categories.id_categories = project.category_id');
$this->db->order_by('category', 'asc');
$query = $this->db->get();
return $query->result();
}
//Public Page
public function get_project_by_id($id) {
$this->db->select('*');
$this->db->from('project');
$this->db->join('categories', 'categories.id_categories = project.category_id');
$this->db->where('id', $id);
$query = $this->db->get();
//check if product id already exist in database, to prevent display error
if($query->num_rows() > 0) {
return $query->row();
} else {
show_404();
}
}
//function count if existing record exist
public function count_exist($id) {
$this->db->select('*');
$this->db->from('project');
$this->db->where('id', $id);
$query = $this->db->get();
return $query->num_rows();
}
}
?>