File: /var/www/html/taxicamera/old/application/controllers/admin/Changeprofile.php
<?php
defined('BASEPATH') OR exit('No direct script access allowed');
class Changeprofile extends MY_Controller {
public function __construct() {
parent::__construct();
//$this->redirect_guest();
$this->load->model('admin/mchangeprofile');
$this->load->library('imageupload');
if($this->session->userdata('admin') != 1)
{
redirect('admin');
}
}
private function _load_view($data) {
$this->load->view('admin/layouts/index',$data);
}
/*
author: soma
purpose: change password
date: 27-9-2019
*/
public function index()
{
$user_id=$this->session->userdata('user_data');
$result = array();
$result['user'] = $this->mchangeprofile->get_profile($user_id);
$result['content']='admin/changeprofile';
$this->_load_view($result);
}
/*
author: soma
purpose: Update profile
date: 27-9-2019
*/
public function update_profile()
{
//pr($_FILES);
$result = array();
$data = array();
$user_id = $this->input->post('user_id');
$old_profile_photo = $this->input->post('old_profile_photo');
$data = array(
'first_name' => $this->input->post( 'first_name' ),
'middle_name' => $this->input->post( 'middle_name' ),
'last_name' => $this->input->post( 'last_name' ),
'dob' => $this->input->post( 'dob' ),
'abn' => $this->input->post( 'abn' ),
'landline_no' => $this->input->post( 'landline_no' ),
'mobile' => $this->input->post( 'mobile' ),
//'email' => $this->input->post( 'email' ),
'flat_no' => $this->input->post( 'flat_no' ),
'street_no' => $this->input->post( 'street_no' ),
'street_name' => $this->input->post( 'street_name' ),
'suburb' => $this->input->post( 'suburb' ),
'state' => $this->input->post( 'state' ),
'pin' => $this->input->post( 'pin' ),
'updated_by' => $this->session->userdata('user_data'),
'updated_ts' => date('Y-m-d H:i:s'),
);
if(!empty($_FILES['profile_photo']['name'])){
$image_profile = '/public/upload_image/profile_photo/';
$file_image_profile = $this->imageupload->image_upload2($image_profile,'profile_photo');
//pr($file_image_profile);
if($file_image_profile['status']==0){
$this->session->set_flashdata('success_msg','');
$this->session->set_flashdata('error_msg',$file_image_profile['result']);
redirect('admin/changeprofile');
}
else{
$data['profile_photo'] = $file_image_profile['result'];
}
}
else{
$data['profile_photo'] = $old_profile_photo;
}
$result = $this->mchangeprofile->update_profile($data,$user_id);
if($result)
{
$this->session->set_flashdata('success_msg','Profile successfully updated!');
redirect('admin/changeprofile');
}else{
$this->session->set_flashdata('error_msg','Oops!Something went wrong...');
redirect('admin/changeprofile');
}
}
}