2023-01-08 20:46:58 +00:00
|
|
|
<?php
|
|
|
|
defined('BASEPATH') OR exit('No direct script access allowed');
|
|
|
|
|
|
|
|
class Project extends CI_Controller {
|
|
|
|
|
|
|
|
public function __construct()
|
|
|
|
{
|
|
|
|
parent::__construct();
|
|
|
|
$this->load->model('Project_model');
|
|
|
|
$this->load->model('Commonsql_model');
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Index Page for this controller.
|
|
|
|
*
|
|
|
|
* Maps to the following URL
|
|
|
|
* http://example.com/index.php/welcome
|
|
|
|
* - or -
|
|
|
|
* http://example.com/index.php/welcome/index
|
|
|
|
* - or -
|
|
|
|
* Since this controller is set as the default controller in
|
|
|
|
* config/routes.php, it's displayed at http://example.com/
|
|
|
|
*
|
|
|
|
* So any other public methods not prefixed with an underscore will
|
|
|
|
* map to /index.php/welcome/<method_name>
|
|
|
|
* @see https://codeigniter.com/user_guide/general/urls.html
|
|
|
|
*/
|
|
|
|
public function project_list()
|
|
|
|
{
|
|
|
|
$data['pro']=$this->Project_model->list_pro();
|
2023-01-21 13:41:47 +00:00
|
|
|
$this->load->view('project/project_list',$data);
|
2023-01-08 20:46:58 +00:00
|
|
|
}
|
2023-01-21 13:41:47 +00:00
|
|
|
public function viewProject($id)
|
2023-01-08 20:46:58 +00:00
|
|
|
{
|
2023-01-21 13:41:47 +00:00
|
|
|
if($this->session->userdata('id')==""){redirect('');}
|
2023-01-08 20:46:58 +00:00
|
|
|
|
2023-01-21 13:41:47 +00:00
|
|
|
$data['viewProject']=$this->Project_model->viewProject($id);
|
|
|
|
//echo $this->db->last_query();exit;
|
|
|
|
$this->load->view('project/view_project',$data);
|
|
|
|
}
|
|
|
|
function add_project()
|
|
|
|
{
|
|
|
|
$data['dep']=$this->Project_model->get_dep();
|
|
|
|
$data['stu']=$this->Project_model->get_stu();
|
|
|
|
$data['sub']=$this->Project_model->get_sub();
|
|
|
|
$data['semester']=$this->Project_model->get_semester();
|
2023-01-08 20:46:58 +00:00
|
|
|
|
|
|
|
if($this->input->post('submit'))
|
|
|
|
{
|
2023-01-21 13:41:47 +00:00
|
|
|
|
2023-01-08 20:46:58 +00:00
|
|
|
$name=$this->input->post('projectName');
|
|
|
|
$date=$this->input->post('date');
|
2023-01-21 13:41:47 +00:00
|
|
|
//$pDate= implode("-", array_reverse(explode("-", $date)));
|
2023-01-08 20:46:58 +00:00
|
|
|
$student=$this->input->post('student');
|
2023-01-21 13:41:47 +00:00
|
|
|
$code=$this->input->post('code');
|
|
|
|
$semesterId=$this->input->post('semesterId');
|
2023-01-11 07:17:57 +00:00
|
|
|
$subject=$this->input->post('subject');
|
2023-01-08 20:46:58 +00:00
|
|
|
$department=$this->input->post('department');
|
2023-01-11 07:17:57 +00:00
|
|
|
$description=$this->input->post('description');
|
|
|
|
$drivelink=$this->input->post('drivelink');
|
|
|
|
$video=$this->input->post('vedio');
|
2023-01-21 13:41:47 +00:00
|
|
|
|
|
|
|
|
|
|
|
if (!is_dir('uploads/project')) {
|
|
|
|
mkdir('./uploads/project', 0777, TRUE);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
if(file_exists($_FILES['titleImage']['tmp_name']))
|
|
|
|
{
|
|
|
|
$temp_user_img=$_FILES['titleImage']['tmp_name'];
|
|
|
|
$user_img=str_replace(' ', '_', $_FILES["titleImage"]["name"]);
|
|
|
|
$allowed = array('png,jpeg,jpg');
|
|
|
|
$extension1 = pathinfo($user_img, PATHINFO_EXTENSION);
|
|
|
|
$user_img='title'.date('ymdhis').'.'.$extension1;
|
|
|
|
$targetPath='./uploads/project/';
|
|
|
|
$targetFile=$targetPath.$user_img;
|
|
|
|
move_uploaded_file($temp_user_img, $targetFile);
|
|
|
|
}
|
2023-01-08 20:46:58 +00:00
|
|
|
|
|
|
|
$table="project";
|
|
|
|
$values=array('projectName'=>$name,
|
|
|
|
'date'=>$date,
|
2023-01-21 13:41:47 +00:00
|
|
|
'studentId'=>$student,
|
|
|
|
'semesterId'=>$semesterId,
|
|
|
|
'departmentId'=>$department,
|
|
|
|
'subjectId'=>$subject,
|
|
|
|
'code'=>$code,
|
|
|
|
'image'=>$user_img,
|
2023-01-11 07:17:57 +00:00
|
|
|
'description'=>$description,
|
2023-01-21 13:41:47 +00:00
|
|
|
//'faculty'=>$faculty,
|
2023-01-08 20:46:58 +00:00
|
|
|
'drivelink'=>$drivelink,
|
2023-01-11 07:17:57 +00:00
|
|
|
'vedio'=>$video,
|
2023-01-08 20:46:58 +00:00
|
|
|
'createdOn'=>date('Y-m-d'),
|
|
|
|
'createdBy'=>1,
|
|
|
|
'status'=>1);
|
|
|
|
$result=$this->Commonsql_model->insert_table($table,$values);
|
|
|
|
|
2023-01-21 13:41:47 +00:00
|
|
|
$projectId=$this->db->insert_id();
|
|
|
|
//Image table insert
|
|
|
|
$title = $this->input->post('title');
|
|
|
|
|
|
|
|
foreach($title as $key=>$value)
|
|
|
|
{
|
|
|
|
if($_FILES['profileimage']['tmp_name'])
|
|
|
|
{
|
|
|
|
if (!is_dir('uploads/project')) {
|
|
|
|
mkdir('./uploads/project', 0777, TRUE);
|
|
|
|
}
|
|
|
|
$temp_vehicle_doc=$_FILES['profileimage']['tmp_name'][$key];
|
|
|
|
$projectImage=str_replace(' ', '_', $_FILES["profileimage"]["name"][$key]);
|
|
|
|
$extension1 = pathinfo($projectImage, PATHINFO_EXTENSION);
|
|
|
|
$pImage=$projectId.'.'.$projectImage;
|
|
|
|
$document='uploads/project/'.$pImage;
|
|
|
|
|
|
|
|
$targetPath = './uploads/project/';
|
|
|
|
$targetFile=$targetPath.$pImage;
|
|
|
|
|
|
|
|
|
|
|
|
if(move_uploaded_file($temp_vehicle_doc, $targetFile))
|
|
|
|
{
|
|
|
|
$tablename='projectdetail';
|
|
|
|
$data=array('projectId'=>$projectId,
|
|
|
|
'title'=>$title[$key],
|
|
|
|
'image'=>$pImage,
|
|
|
|
'status'=>1);
|
|
|
|
|
|
|
|
$product=$this->Commonsql_model->insert_table($tablename,$data);
|
|
|
|
//echo $this->db->last_query();
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
//exit;
|
|
|
|
if($result)
|
|
|
|
{
|
|
|
|
$this->session->set_userdata('suc','successfully added');
|
|
|
|
redirect('project');
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
$this->session->set_userdata('err','Please try again');
|
|
|
|
redirect('project');
|
|
|
|
}
|
2023-01-08 20:46:58 +00:00
|
|
|
}
|
2023-01-21 13:41:47 +00:00
|
|
|
$this->load->view('project/add_project',$data);
|
2023-01-08 20:46:58 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2023-01-24 10:05:16 +00:00
|
|
|
function editProject($id)
|
2023-01-08 20:46:58 +00:00
|
|
|
{
|
2023-01-24 10:05:16 +00:00
|
|
|
$data['dep']=$this->Project_model->get_dep();
|
|
|
|
$data['stu']=$this->Project_model->get_stu();
|
|
|
|
$data['sub']=$this->Project_model->get_sub();
|
|
|
|
$data['semester']=$this->Project_model->get_semester();
|
|
|
|
|
2023-01-08 20:46:58 +00:00
|
|
|
$data['pro']=$this->Project_model->get_pro($id);
|
2023-01-24 10:05:16 +00:00
|
|
|
|
|
|
|
$data['getMultipleImage']=$this->Project_model->getMultipleImage($id);
|
2023-01-08 20:46:58 +00:00
|
|
|
|
|
|
|
if($this->input->post('submit'))
|
|
|
|
{
|
|
|
|
$date=$this->input->post('date');
|
2023-01-24 10:05:16 +00:00
|
|
|
$projectName=$this->input->post('projectName');
|
|
|
|
$code=$this->input->post('code');
|
|
|
|
$studentId=$this->input->post('student');
|
|
|
|
$semesterId=$this->input->post('semesterId');
|
|
|
|
$subjectId=$this->input->post('subjectId');
|
|
|
|
$departmentId=$this->input->post('departmentId');
|
|
|
|
$titleImage=$this->input->post('titleImage');
|
|
|
|
$oldImage=$this->input->post('oldImage');
|
2023-01-11 07:17:57 +00:00
|
|
|
$description=$this->input->post('description');
|
|
|
|
$drivelink=$this->input->post('drivelink');
|
2023-01-24 10:05:16 +00:00
|
|
|
$video=$this->input->post('video');
|
|
|
|
|
|
|
|
if($titleImage=="" ){$newImage=$oldImage;}
|
|
|
|
if(file_exists($_FILES['titleImage']['tmp_name']))
|
|
|
|
{
|
|
|
|
$temp_user_img=$_FILES['titleImage']['tmp_name'];
|
|
|
|
$newImage=str_replace(' ', '_', $_FILES["titleImage"]["name"]);
|
|
|
|
$allowed = array('png,jpeg,jpg');
|
|
|
|
$extension1 = pathinfo($newImage, PATHINFO_EXTENSION);
|
|
|
|
$newImage='title'.date('ymdhis').'.'.$extension1;
|
|
|
|
$targetPath='./uploads/project/';
|
|
|
|
$targetFile=$targetPath.$newImage;
|
|
|
|
move_uploaded_file($temp_user_img, $targetFile);
|
|
|
|
}
|
2023-01-08 20:46:58 +00:00
|
|
|
|
|
|
|
$table="project";
|
|
|
|
$where=array("id"=>$id);
|
2023-01-24 10:05:16 +00:00
|
|
|
$values=array('projectName'=>$projectName,
|
2023-01-08 20:46:58 +00:00
|
|
|
'date'=>$date,
|
2023-01-24 10:05:16 +00:00
|
|
|
'code'=>$code,
|
|
|
|
'studentId'=>$studentId,
|
|
|
|
'semesterId'=>$semesterId,
|
|
|
|
'subjectId'=>$subjectId,
|
|
|
|
'departmentId'=>$departmentId,
|
|
|
|
'image'=>$newImage,
|
2023-01-11 07:17:57 +00:00
|
|
|
'description'=>$description,
|
2023-01-08 20:46:58 +00:00
|
|
|
'drivelink'=>$drivelink,
|
2023-01-11 07:17:57 +00:00
|
|
|
'vedio'=>$video,
|
2023-01-08 20:46:58 +00:00
|
|
|
'updatedOn'=>date('Y-m-d'),
|
2023-01-24 10:05:16 +00:00
|
|
|
'updatedBy'=>1);
|
2023-01-08 20:46:58 +00:00
|
|
|
|
|
|
|
$result=$this->Commonsql_model->updateTable($table,$where,$values);
|
2023-01-24 10:05:16 +00:00
|
|
|
|
|
|
|
//Image Multiple
|
|
|
|
$title = $this->input->post('title');
|
|
|
|
$profileimage = $this->input->post('profileimage');
|
|
|
|
$projectDetailId = $this->input->post('projectDetailName');
|
|
|
|
$oldImage = $this->input->post('profileimageOld');
|
|
|
|
//print_r ($projectDetailId);exit;
|
|
|
|
|
|
|
|
//Update old datas
|
|
|
|
foreach($title as $key=>$value)
|
|
|
|
{
|
|
|
|
|
|
|
|
if($projectDetailId[$key]!="")
|
|
|
|
{
|
|
|
|
|
|
|
|
if($_FILES['profileimage']['name'][$key])
|
|
|
|
{
|
|
|
|
$temp_file=$_FILES['profileimage']['tmp_name'][$key];
|
|
|
|
$business_doc=str_replace(' ', '_', $_FILES["profileimage"]["name"][$key]);
|
|
|
|
$extension1 = pathinfo($business_doc, PATHINFO_EXTENSION);
|
|
|
|
$newImage=$id.'.'.$business_doc;
|
|
|
|
$document='uploads/project/'.$newImage;
|
|
|
|
|
|
|
|
$targetPath = './uploads/project/';
|
|
|
|
$targetFile=$targetPath.$newImage;
|
|
|
|
|
|
|
|
|
|
|
|
if(move_uploaded_file($temp_file, $targetFile))
|
|
|
|
{ }
|
|
|
|
}
|
|
|
|
else{
|
|
|
|
$newImage=$oldImage[$key];
|
|
|
|
}
|
|
|
|
$tablename='projectdetail';
|
|
|
|
$data=array('title'=>$title[$key],
|
|
|
|
'image'=>$newImage);
|
|
|
|
$where=array('id'=>$projectDetailId[$key]);
|
|
|
|
$result=$this->Commonsql_model->updateTable($tablename,$where,$data);
|
|
|
|
//echo $this->db->last_query();
|
|
|
|
|
|
|
|
}
|
2023-01-25 12:47:55 +00:00
|
|
|
|
|
|
|
//Remove Existing One
|
|
|
|
$existingRow=$this->Project_model->getMultipleImage($id);
|
|
|
|
//echo $this->db->last_query();
|
|
|
|
if($existingRow->num_rows()>0)
|
2023-01-24 10:05:16 +00:00
|
|
|
{
|
2023-01-25 12:47:55 +00:00
|
|
|
//echo "test";exit;
|
|
|
|
$primaryId=array();
|
|
|
|
foreach($existingRow->result() as $list)
|
|
|
|
{
|
|
|
|
$primaryId[]=$list->id ;
|
|
|
|
}
|
2023-01-24 10:05:16 +00:00
|
|
|
}
|
2023-01-25 12:47:55 +00:00
|
|
|
//Remove Row
|
|
|
|
$diff=array_diff($primaryId,$projectDetailId);
|
|
|
|
//print_r ($diff);exit;
|
|
|
|
if($diff>0)
|
2023-01-24 10:05:16 +00:00
|
|
|
{
|
2023-01-25 12:47:55 +00:00
|
|
|
//echo "sdsds";exit;
|
|
|
|
foreach($diff as $value)
|
|
|
|
{
|
|
|
|
$where=array('id'=>$value);
|
|
|
|
$tablename="projectdetail";
|
|
|
|
$values=array('status'=>0);
|
|
|
|
if($projectDetailId[$key]!=""){
|
|
|
|
$result=$this->Commonsql_model->updateTable($tablename,$where,$values);}
|
|
|
|
//echo $this->db->last_query();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
//New Row Insertion
|
|
|
|
if($projectDetailId[$key]=="")
|
|
|
|
{
|
|
|
|
|
|
|
|
if($_FILES['profileimage']['tmp_name'])
|
|
|
|
{
|
|
|
|
$tempDocument=$_FILES['profileimage']['tmp_name'][$key];
|
|
|
|
$getImage=str_replace(' ', '_', $_FILES["profileimage"]["name"][$key]);
|
|
|
|
$extension1 = pathinfo($getImage, PATHINFO_EXTENSION);
|
|
|
|
$image=$id.'.'.$getImage;
|
|
|
|
//$document='uploads/subject/'.$business_document;
|
|
|
|
$targetPath = './uploads/project/';
|
|
|
|
$targetFile=$targetPath.$image;
|
|
|
|
|
|
|
|
|
|
|
|
if(move_uploaded_file($tempDocument, $targetFile))
|
|
|
|
{
|
|
|
|
$tablename='projectdetail';
|
|
|
|
$data=array('projectId'=>$id,
|
|
|
|
'title'=>$title[$key],
|
|
|
|
'image'=>$image,
|
|
|
|
'status'=>1);
|
|
|
|
|
|
|
|
$result=$this->Commonsql_model->insert_table($tablename,$data);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2023-01-24 10:05:16 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2023-01-08 20:46:58 +00:00
|
|
|
if($result)
|
2023-01-24 10:05:16 +00:00
|
|
|
{
|
|
|
|
$this->session->set_userdata('suc','successfully Updated');
|
|
|
|
redirect('project');
|
|
|
|
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
$this->session->set_userdata('err','Please try again');
|
|
|
|
redirect('project');
|
|
|
|
}
|
2023-01-08 20:46:58 +00:00
|
|
|
|
|
|
|
}
|
2023-01-24 10:05:16 +00:00
|
|
|
$this->load->view('project/edit_project',$data);
|
2023-01-08 20:46:58 +00:00
|
|
|
}
|
|
|
|
|
2023-01-21 13:41:47 +00:00
|
|
|
function deleteProject()
|
2023-01-08 20:46:58 +00:00
|
|
|
{
|
|
|
|
if($this->input->post('submit'))
|
|
|
|
{
|
2023-01-21 13:41:47 +00:00
|
|
|
$projectId=$this->input->post('projectId');
|
2023-01-08 20:46:58 +00:00
|
|
|
|
|
|
|
$table="project";
|
2023-01-21 13:41:47 +00:00
|
|
|
$where=array("id"=>$projectId);
|
|
|
|
$values=array('status'=>0);
|
2023-01-25 12:47:55 +00:00
|
|
|
$result=$this->Commonsql_model->updateTable($table,$where,$values);
|
|
|
|
|
2023-01-21 13:41:47 +00:00
|
|
|
$dTable="projectdetail";
|
|
|
|
$dWhere=array("projectId"=>$projectId);
|
|
|
|
$dValue=array('status'=>0);
|
|
|
|
|
2023-01-08 20:46:58 +00:00
|
|
|
$result=$this->Commonsql_model->updateTable($table,$where,$values);
|
2023-01-21 13:41:47 +00:00
|
|
|
|
|
|
|
$dResult=$this->Commonsql_model->updateTable($dTable,$dWhere,$dValue);
|
|
|
|
//echo $this->db->last_query();exit;
|
|
|
|
if($result && $dResult)
|
|
|
|
{
|
|
|
|
$this->session->set_userdata('suc','successfully deleted');
|
|
|
|
redirect('project');
|
|
|
|
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
$this->session->set_userdata('err','Please try again');
|
|
|
|
redirect('project');
|
|
|
|
}
|
2023-01-08 20:46:58 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}
|