Code:
function artist_exposeds_edit()
{
$id = $this->uri->segment(3); //segment iz URLja
if (int_str($id))
{
$data['title'] = "Uredi na tapeti";
$this->db->limit(1, 0);
$this->db->where('artist_exposed_id', $id);
$query = $this->db->get('artist_exposed');
$data['row'] = $query->row();
$data['query'] = $this->db->get('personal_card');
//$this->db->where('arrangement_id', $id);
//$data['query'] = $this->db->get('arrangement_departure');
if ($query->num_rows() > 0)
{
$this->load->library('validation');
$rules['title'] = "required";
$rules['slug'] = "required";
$rules['description'] = "required";
$this->validation->set_rules($rules);
$fields['title'] = "Naslov";
$fields['slug'] = "Slug - SEO URL";
$fields['description'] = "Opis";
$this->validation->set_fields($fields);
$this->validation->set_error_delimiters('<div class="warning">', '</div>');
if ($this->validation->run() == FALSE)
{
$this->load->view('admin/artist_exposeds_edit', $data);
}
else
{
$data_update = array(
'title' => $this->input->post('title') ,
'slug' => $this->input->post('slug') ,
'description' => $this->input->post('description') ,
'creation_date' => date('Y-m-d'),
'personal_card_personal_card_id' => $this->input->post('personal_card_selected')
);
$this->db->where('artist_exposed_id', $this->input->post('artist_exposed_id'));
$this->db->update('artist_exposed', $data_update);
if(@$this->input->post('title_photo_checked'))
{
$config['upload_path'] = './uploads/';
$config['allowed_types'] = 'gif|jpg|png';
$config['max_size'] = '100';
$config['max_width'] = '1024';
$config['max_height'] = '768';
$this->load->library('upload', $config);
$field_name = "title_photo";
if (!$this->upload->do_upload($field_name))
{
$data['error'] = $this->upload->display_errors('<div class="warning">', '</div>');
$this->load->view('admin/artist_exposeds_edit', $data);
}
else
{
$uploads = $this->upload->data();
$data_update = array(
'title_photo' => $uploads['orig_name']
);
$this->db->where('artist_exposed_id', $this->input->post('artist_exposed_id'));
$this->db->update('artist_exposed', $data_update);
}
}
//redirect
redirect('admin/artist_exposeds', 'refresh');
}
}
else
{
show_error('Stran ne obstaja');
}
}
else
{
show_error('Stran ne obstaja');
}
}
Code:
if (!$this->upload->do_upload($field_name))
{
$data['error'] = $this->upload->display_errors('<div class="warning">', '</div>');
$this->load->view('admin/artist_exposeds_edit', $data);
}