profile crud:suseendhiran

This commit is contained in:
suseendhiran17 2023-05-11 10:51:57 +05:30
parent 3c3092887b
commit 48645035d2
5 changed files with 48 additions and 57 deletions

View File

@ -77,20 +77,21 @@ class Admin_controller extends BaseController
}
public function user_edit($user_id = null)
public function user_edit($user_id = null , $check = null)
{
if($this->request->getmethod() == 'post')
{
//update member details
$UserData = $this->request->getVar();
$user_id = $this->request->getVar('id');
$this->UserModel->where('id', $user_id )->set($UserData)->update();
if ($this->request->getVar('profile_check') == 'profile_edit') {
return redirect()->to(base_url()."admin_profile/".md5($user_id));
}
return redirect()->to(base_url()."users_list");
}
$userdata['userdata']=$this->dModel->getLoggedInUserData(session()->get('logged_user'));
$data['country']=$this->cModel->fetch_country();
@ -100,6 +101,9 @@ class Admin_controller extends BaseController
->join('city', 'users.city = city.id', 'left')
->where('md5(users.id)', $user_id )
->find();
if ($check != null) {
$data['check'] = 'profile_edit';
}
//print_r($data);die();
echo view('layout/header',$userdata);
@ -131,19 +135,6 @@ class Admin_controller extends BaseController
public function admin_profile($user_id = null)
{
if($this->request->getmethod() == 'post')
{
//update member details
$UserData = $this->request->getVar();
$user_id = $this->request->getVar('id');
$this->UserModel->where('id', $user_id )->set($UserData)->update();
return redirect()->to(base_url()."users_list");
}
$userdata['userdata']=$this->dModel->getLoggedInUserData(session()->get('logged_user'));
$data['userList'] = $this->UserModel->select('users.* , country.name as country_name , state.name as state_name ,city.name as city_name')
@ -165,43 +156,23 @@ class Admin_controller extends BaseController
if($this->request->getmethod() == 'post')
{
$action = $this->request->getVar();
// print_r($action);die();
$id = $this->request->getVar('id');
//file upload confic
$user_image['upload_path'] = base_url().'public/assets/images/users/';
$user_image['allowed_types'] = 'jpg|png|jpeg';
$user_image['max_size'] = 80000;
//upload
print_r($this->request->getFile('profile'));die();
// $this->load->library('upload', $user_image);
// $this->upload->initialize($user_image);
if ($this->request->getPost('profile'))
{
$uploadPath = base_url().'public/assets/images/users/';
$fileName = $this->request->getPost('profile')->move($uploadPath);
if ($fileName)
{
// Store the file name into the database
$data = [
'filename' => $fileName
];
echo $fileName;
// Do whatever you need with the data
}
// $error = array('error' => $this->upload->display_errors());
// print_r($error);die();
// echo false;
// }
// else
// {
// $upload_user_image = $this->upload->data();
// $action['profile'] = $upload_user_image['file_name'];
// $userData = $this->UserModel->where('id', $id )->set($action)->update();
// echo true;
}
if(isset($_FILES["image_file"]["name"]))
{
$config['upload_path'] = base_url()."/public/assets/images/users";
$config['allowed_types'] = 'jpg|jpeg|png|gif';
print_r($config);die();
$this->load->library('upload', $config);
if(!$this->upload->do_upload('image_file'))
{
echo $this->upload->display_errors();
}
else
{
$data = $this->upload->data();
echo '<img src="'.base_url().'upload/'.$data["file_name"].'" width="300" height="225" class="img-thumbnail" />';
}
}
}
}

View File

@ -263,6 +263,12 @@ $(document).ready(function(){
<span>My Account</span>
</a>
<!-- item-->
<a href="<?= base_url()."admin_profile/". md5($userdata->id); ?>" class="dropdown-item notify-item">
<i class="ri-account-circle-line"></i>
<span>Change Password</span>
</a>
<!-- item-->
<a href="javascript:void(0);" class="dropdown-item notify-item">
<i class="ri-settings-3-line"></i>

View File

@ -59,11 +59,20 @@ body {
}
</style>
</br></br>
<div class="page-title-box page-title-box-alt" style="margin-top:-50px">
<h4 class="page-title">Profile</h4>
<div class="page-title-right">
<ol class="breadcrumb m-0">
<li class="breadcrumb-item"><a href="<?= base_url() ?>user_edit/<?= md5($userList[0]['id']) ?>/profile_edit">
<button type="button" class="btn btn-primary waves-effect waves-light">Edit</button>
</a></li>
</ol>
</div>
</div>
<div class="row">
<div class="col-lg-12 col-xl-12">
<div class="card text-center">
<div class="card-body">
<form id="form" data-parsley-validate class="form-horizontal form-label-left" method="post" action="" enctype="multipart/form-data">
<input id="id" name="id" value="<?= $userList[0]['id'] ?>" type="hidden" />
<?php if ($userList[0]['profile'] == NULL) { ?>
@ -91,13 +100,14 @@ body {
</form>
<h4 class="mt-3 mb-0"><?= $userList[0]['name'] ?></h4>
<div class="text-left mt-3">
<div class="table-responsive">
<div class="table-responsive">
<table class="table table-borderless table-sm">
<tbody>
<tr>
<th scope="row">Name :</th>
<td class="text-muted"><?= $userList[0]['name'] ?></td>
<td id="name" class="text-muted"><?= $userList[0]['name'] ?></td>
</tr>
<tr>
<th scope="row">Mobile :</th>
@ -119,7 +129,8 @@ body {
</div> <!-- end card-box -->
</div> <!-- end col-->
</div>
<script>
<script>
// The handler is executed at most once per element per event type => one()
$(".profilepic").one('click',function() {
$("#file_profile").trigger("click");
@ -132,7 +143,7 @@ $("#file_profile").change(function(){
});
});
$(document).on('change','#file_profile',function(){
$(document).on('change','#file_profile',function(e){
var data = $("#form").serialize();
$.ajax({
type: "post",

View File

@ -30,6 +30,7 @@
<?php if(isset($userList)){ ?>
<input type="hidden" required name="id" value="<?= $userList[0]['id']; ?>" >
<?php } ?>
<?php if(!$check){ ?>
<div class="form-group row">
<label for="inputEmail3" class="col-4 col-form-label">Role<span class="text-danger">*</span></label>
<div class="col-7">
@ -43,6 +44,8 @@
<!-- <input type="text" required class="form-control" name="role" value="<?php if(isset($userList)){echo $userList[0]['role'];} ?>" placeholder="Member Name"> -->
</div>
</div>
<?php } ?>
<input type="hidden" name="profile_check" value="<?php if(isset($check)){echo $check;} ?>">
<div class="form-group row">
<label for="inputEmail3" class="col-4 col-form-label">Name<span class="text-danger">*</span></label>

View File