From 739a1e7e08d7c48295501980cfb58293ac981b4b Mon Sep 17 00:00:00 2001
From: Woraprat <73052317+aeworaprat@users.noreply.github.com>
Date: Tue, 14 Mar 2023 16:40:11 +0700
Subject: [PATCH] update project

---
 html/exhi/application/controllers/Login.php   |  2 +-
 html/exhi/application/controllers/Project.php | 23 ++++++++++++++-----
 html/exhi/application/models/tag/M_tag.php    |  8 +++++++
 html/exhi/application/models/user/M_user.php  |  8 ++++++-
 4 files changed, 33 insertions(+), 8 deletions(-)

diff --git a/html/exhi/application/controllers/Login.php b/html/exhi/application/controllers/Login.php
index 07da077..ff30440 100644
--- a/html/exhi/application/controllers/Login.php
+++ b/html/exhi/application/controllers/Login.php
@@ -18,7 +18,7 @@ class Login extends Exhibition_Controller
 
 	public function show_login()
 	{
-		// $this->output('login/v_login');
+		$this->output('login/v_login');
 	}
 
 	public function show_login_fail()
diff --git a/html/exhi/application/controllers/Project.php b/html/exhi/application/controllers/Project.php
index 0b90600..52b7749 100644
--- a/html/exhi/application/controllers/Project.php
+++ b/html/exhi/application/controllers/Project.php
@@ -42,9 +42,9 @@ class Project extends Exhibition_Controller {
 		$data['clusters'] =  $this->cluster->get_all()->result();
 		$data['teams'] =  $this->team->get_all()->result();
 		$data['companies'] =  $this->company->get_all()->result();
-		$data['tags'] =  $this->tag->get_all()->result();
+		$data['tags'] =  $this->tag->get_all_project()->result();
 		$data['instructors'] =  $this->instructor->get_all()->result();
-		$data['users'] =  $this->user->get_user_project($_SESSION['email'])->result();
+		$data['users'] =  $this->user->get_user_project_admin()->result();
 		$this->output_admin('project/v_project_create', $data);
 	}
 
@@ -58,7 +58,7 @@ class Project extends Exhibition_Controller {
 		$data['clusters'] =  $this->cluster->get_all()->result();
 		$data['teams'] =  $this->team->get_all()->result();
 		$data['companies'] =  $this->company->get_all()->result();
-		$data['tags'] =  $this->tag->get_all()->result();
+		$data['tags'] =  $this->tag->get_all_project()->result();
 		$data['instructors'] =  $this->instructor->get_all()->result();
 		$data['users'] =  $this->user->get_user_project($_SESSION['email'])->result();
 		$this->output_user('project/v_project_create_user', $data);
@@ -77,7 +77,7 @@ class Project extends Exhibition_Controller {
 		$data['project_tag'] =  $this->project_tag->get_project_tag_by_id($id)->result();
 		$data['teams'] =  $this->team->get_all()->result();
 		$data['companies'] =  $this->company->get_all()->result();
-		$data['tags'] =  $this->tag->get_all()->result();
+		$data['tags'] =  $this->tag->get_all_project()->result();
 		$data['instructors'] =  $this->instructor->get_all()->result();
 		$this->output_admin('project/v_project_edit', $data);
 	}
@@ -95,12 +95,12 @@ class Project extends Exhibition_Controller {
 		$data['project_tag'] =  $this->project_tag->get_project_tag_by_id($id)->result();
 		$data['teams'] =  $this->team->get_all()->result();
 		$data['companies'] =  $this->company->get_all()->result();
-		$data['tags'] =  $this->tag->get_all()->result();
+		$data['tags'] =  $this->tag->get_all_project()->result();
 		$data['instructors'] =  $this->instructor->get_all()->result();
 		$this->output_user('project/v_project_edit_user', $data);
 	}
 
-	public function get_project_detail_member(){
+	public function get_project_detail_member_user(){
 		$id = $this->input->post('id');
 		$this->load->model('detail/M_detail','detail');
 		$this->load->model('member/M_member','member');
@@ -111,6 +111,17 @@ class Project extends Exhibition_Controller {
 		echo json_encode($data);
 	}
 
+	public function get_project_detail_member(){
+		$id = $this->input->post('id');
+		$this->load->model('detail/M_detail','detail');
+		$this->load->model('member/M_member','member');
+		$this->load->model('user/M_user','user');
+		$data['users'] =  $this->user->get_user_project_admin()->result();
+		$data['detail'] = $this->detail->get_detail_by_project_id($id)->result();
+		$data['member'] = $this->member->get_member_by_project_id($id)->result();
+		echo json_encode($data);
+	}
+
 	public function change_status(){
 		$data['message'] = true ;
 		$id = $this->input->post('id');
diff --git a/html/exhi/application/models/tag/M_tag.php b/html/exhi/application/models/tag/M_tag.php
index 383f0b3..978fd20 100644
--- a/html/exhi/application/models/tag/M_tag.php
+++ b/html/exhi/application/models/tag/M_tag.php
@@ -20,6 +20,14 @@ class M_tag extends Da_tag
         return $query;
 	}
 
+	public function get_all_project()
+	{
+		$sql = "SELECT * FROM {$this->db_name}.tag
+		Where is_delete = 0 and status = 1";
+        $query = $this->db->query($sql);
+        return $query;
+	}
+
 	public function get_tag_by_id($id)
 	{
 		$sql = "SELECT * FROM {$this->db_name}.tag
diff --git a/html/exhi/application/models/user/M_user.php b/html/exhi/application/models/user/M_user.php
index f5bf5db..5474616 100644
--- a/html/exhi/application/models/user/M_user.php
+++ b/html/exhi/application/models/user/M_user.php
@@ -45,12 +45,18 @@ class M_user extends Da_user
 	}
 
 	public function get_user_project($email){
-		$sql = "SELECT * FROM {$this->db_name}.user
+		$sql = "SELECT user_id, student_id, prefix, first_name, last_name, email FROM {$this->db_name}.user
 		Where email like '".substr($email,0,2)."%'";
         $query = $this->db->query($sql);
         return $query;
 	}
 
+	public function get_user_project_admin(){
+		$sql = "SELECT user_id, student_id, prefix, first_name, last_name, email FROM {$this->db_name}.user";
+        $query = $this->db->query($sql);
+        return $query;
+	}
+
 
 
 }
-- 
GitLab