private function save() { $id = $this->input->post('id'); if (empty($id)) { $id = null; } $this->_validations_save(); $this->_validations_messages(); $userLogged = $this->session->userdata('logged_user'); $alerta = array('id' => $id, 'usuario_id' => $this->input->post('usuario_id'), 'boton_id' => $this->input->post('boton_id'), 'lat' => parent::getValue($this->input->post('lat')), 'lng' => parent::getValue($this->input->post('lng')), 'fecha_hora' => parent::getValue($this->input->post('fecha_hora')), 'fecha_hora_server' => parent::getValue($this->input->post('fecha_hora_server')), 'locationProvider' => parent::getValue($this->input->post('locationProvider')), 'accuracy' => parent::getValue($this->input->post('accuracy')), 'atendido' => $this->input->post('atendido'), 'borrado' => $this->input->post('borrado')); $data['alerta'] = $alerta; if ($this->form_validation->run() == FALSE) { if (!empty($id)) { $data['title'] = 'Edición de la alerta'; } $data['title'] = 'Alta de la alerta'; $this->load->template('alertas/alertas_form_view.php', $data); } else { $lastIdInserted = $this->alertas_model->save($alerta); if ($lastIdInserted >= 0) { if (empty($id)) { $this->session->set_flashdata('msg', 'El alerta fue agregada correctamente'); } else { $this->session->set_flashdata('msg', 'El alerta fue editada correctamente'); } redirect('alertas'); } else { $data['error'] = "Error al grabar la información"; $this->load->template('/alertas/alertas_form_view.php', $data); } } }