Esempio n. 1
0
 function form_agregar()
 {
     $this->form_validation->set_rules('tipo', 'Tipo', 'trim|required');
     $this->form_validation->set_rules('nombre', 'Nombre', 'trim|required');
     $this->form_validation->set_rules('direccion', 'Dirección', 'trim|required');
     $this->form_validation->set_rules('sector_codigo', 'Sector', 'trim|required');
     $this->form_validation->set_rules('servicio_codigo', 'Servicio', 'trim|required');
     $respuesta = new stdClass();
     if ($this->form_validation->run() == TRUE) {
         $oficina = new Oficina();
         $oficina->tipo = $this->input->post('tipo');
         $oficina->nombre = $this->input->post('nombre');
         $oficina->direccion = $this->input->post('direccion');
         $oficina->horario = $this->input->post('horario');
         $oficina->telefonos = $this->input->post('telefonos');
         $oficina->fax = $this->input->post('fax');
         $oficina->sector_codigo = $this->input->post('sector_codigo');
         $oficina->servicio_codigo = $this->input->post('servicio_codigo');
         $oficina->lat = $this->input->post('lat');
         $oficina->lng = $this->input->post('lng');
         $oficina->director = $this->input->post('director');
         $oficina->movil = $this->input->post('movil');
         $oficina->save();
         $this->session->set_flashdata('message', 'Oficina creada exitosamente! :)');
         $respuesta->validacion = TRUE;
         $respuesta->redirect = site_url('backend/oficinas/');
     } else {
         $respuesta->validacion = FALSE;
         $respuesta->errores = validation_errors('<p class="error">', '</p>');
     }
     echo json_encode($respuesta);
 }