Controller.php
public function update_account_setting()
{
$id = $this->session->userdata('uid');
$config['upload_path'] = './uploads/';
$config['allowed_types'] = 'gif|jpg|jpeg|png';
$this->load->library('upload', $config);
$this->upload->initialize($config);
if(!$this->upload->do_upload('site_logo')){
$error = array('error' => $this->upload->display_errors());
}
else
{
$data = array('upload_data' => $this->upload->data());
$site_logo['site_logo'] = $data['upload_data']['file_name'];
$this->admin_model->update_account_setting($id,$site_logo);
}
if(!$this->upload->do_upload('site_favicon')){
$error = array('error' => $this->upload->display_errors());
//print_r($error);die;
}
else
{
$data = array('upload_data' => $this->upload->data());
$site_favicon['site_favicon'] = $data['upload_data']['file_name'];
$this->admin_model->update_account_setting($id,$site_favicon);
}
$data = array
(
'sitename'=>$this->input->post('sitename'),
'baseurl'=>$this->input->post('baseurl'),
'conatct_address'=>$this->input->post('conatct_address'),
'contact_number'=>$this->input->post('contact_number'),
'contact_email'=>$this->input->post('contact_email'),
'smtp_hostname'=>$this->input->post('smtp_hostname'),
'smtp_username'=>$this->input->post('smtp_username'),
'smtp_password'=>$this->input->post('smtp_password'),
'smtp_port'=>$this->input->post('smtp_port'),
'cod_enable'=>$this->input->post('cod_enable'),
'payu_merchant'=>$this->input->post('payu_merchant'),
'payu_salt'=>$this->input->post('payu_salt'),
'payu_action'=>$this->input->post('payu_action'),
);
$this->load->model('admin_model');
$data ['rest'] = $this->admin_model->update_account_setting($id,$data);
if(validation_errors() != false)
{
$this->session->set_flashdata('error_message','Data Unsuccessful Updated.');
redirect('admin/account_setting');
}
else
{
$this->session->set_flashdata('message_name','Data Updated.');
redirect('admin/account_setting');
}
}
Admin_Model;php
public function update_account_setting($id,$data)
{
$this->db->where('id',$id);
$statement = $this->db->update('site_settings',$data);
if($statement)
{
return 'true';
}
else
{
return 'false';
}
}
x
0 comments:
Post a Comment
Thanks