function aObjeto($array) { $object = new stdClass(); foreach ($array as $key => $value) { if (is_array($value)) { $value = aObjeto($value); } $object->{$key} = $value; } return $object; }
public function obtenerFranquiciatarios() { try { $resultado = $this->db->query('FranquiciatarioObtenerFranquiciatarios')->result_array(); if ($resultado) { return aObjeto($resultado); } else { return FALSE; } } catch (Exception $e) { return FALSE; log_message('error', 'Error -> FranquiciaModel->obtener()', $e->getMessage()); } }
public function obtener($idCategoria) { try { $resultado = $this->db->query("CategoriaObtener '{$idCategoria}'")->row(); if ($resultado) { return aObjeto($resultado); } else { return FALSE; } } catch (Exception $e) { log_message('error', $e); return FALSE; } }
public function obtener($IdSucursal) { try { $resultado = $this->db->query("SucursalObtener '{$IdSucursal}'")->row(); if ($resultado) { return aObjeto($resultado); } else { return FALSE; } } catch (Exception $e) { return FALSE; log_message('error', 'Error -> SucursalModel->obtener()', $e->getMessage()); } }
public function editarFranquicia() { $data_franquicia = aObjeto(array('IdFranquicia' => $this->input->post('IdFranquicia'), 'Clave' => $this->input->post('Clave'), 'Nombre' => $this->input->post('Nombre'), 'IdFranquiciatario' => $this->input->post('IdFranquiciatario'))); if ($this->input->post('clave_anterior') != $data_franquicia->Clave) { if (!$this->franquicia->existe($data_franquicia->Clave)) { if ($this->franquicia->editar($data_franquicia)) { echo json_encode(array('estatus' => TRUE, 'mensaje' => 'La franquicia se edito correctamente')); } else { echo json_encode(array('estatus' => FALSE, 'mensaje' => 'Ocurrió un problema al editar la franquicia')); } } else { echo json_encode(array('estatus' => FALSE, 'mensaje' => 'La Clave ya existe, verifíquelo')); } } else { if ($this->franquicia->editar($data_franquicia)) { echo json_encode(array('estatus' => TRUE, 'mensaje' => 'La franquicia se edito correctamente')); } else { echo json_encode(array('estatus' => FALSE, 'mensaje' => 'Ocurrió un problema al editar la franquicia')); } } }
public function editarSucursal() { $data_sucursal = aObjeto(array('IdSucursal' => $this->input->post('IdSucursal'), 'Clave' => $this->input->post('Clave'), 'Nombre' => $this->input->post('Nombre'), 'Direccion' => $this->input->post('Direccion'), 'IdFranquicia' => $this->input->post('IdFranquicia'))); if ($this->input->post('clave_anterior') != $data_sucursal->Clave) { if (!$this->sucursal->existe($data_sucursal->Clave)) { if ($this->sucursal->editar($data_sucursal)) { echo json_encode(array('estatus' => TRUE, 'mensaje' => 'La sucursal se editó correctamente')); } else { echo json_encode(array('estatus' => FALSE, 'mensaje' => 'Hubo un problema al agregar la sucursal')); } } else { echo json_encode(array('estatus' => FALSE, 'mensaje' => 'La clave ya existe, verifíquelo')); } } else { if ($this->sucursal->editar($data_sucursal)) { echo json_encode(array('estatus' => TRUE, 'mensaje' => 'La sucursal se editó correctamente')); } else { echo json_encode(array('estatus' => FALSE, 'mensaje' => 'Hubo un problema al agregar la sucursal')); } } }
public function agregarEmpleado() { //DATOS DE PERSONA $data_persona = aObjeto(array('IdPersona' => guid(), 'Nombre' => $this->input->post('nombre'), 'Apellidos' => $this->input->post('apellidos'), 'Telefono' => $this->input->post('telefono'), 'Direccion' => $this->input->post('direccion'), 'Celular' => $this->input->post('celular'))); $data_empleado = aObjeto(array('IdEmpleado' => guid(), 'Clave' => $this->input->post('codigo'), 'FechaNacimiento' => $this->input->post('fecha_nacimiento'), 'Mail' => $this->input->post('email'), 'SueldoHora' => $this->input->post('salario_hora'), 'TiempoComida' => $this->input->post('tiempo_comida'), 'HoraEntrada' => $this->input->post('hora_entrada'), 'HoraSalida' => $this->input->post('hora_salida'), 'IdSucursal' => 'NULL', 'IdPersona' => $data_persona->IdPersona)); if (!$this->empleado->existe($data_empleado->Clave)) { if ($this->persona->agregar($data_persona)) { if ($this->empleado->agregar($data_empleado)) { $data = $this->input->post('foto'); $nombre_foto = img64aNombre($data_empleado->IdEmpleado, $data); if ($nombre_foto != 'default.png') { almacenarImagenFile($nombre_foto, img64adata($data)); } if ($this->empleado->actualizarFoto($data_empleado->IdEmpleado, $nombre_foto)) { echo json_encode(TRUE); } } else { echo json_encode(FALSE); } } else { echo json_encode(FALSE); } } else { echo json_encode(FALSE); } }
public function obtener($IdEmpleado) { try { $resultado = $this->db->query("EmpleadoObtener '{$IdEmpleado}'")->row(); if ($resultado) { return aObjeto($resultado); } else { return FALSE; } } catch (Exception $e) { log_message('error', 'Error -> EmpleadoModel->obtener() ' . $e->getMessage()); return FALSE; } }
public function obtener($id) { $resultado = $this->db->query("FamiliaObtener '{$id}'")->row(); return aObjeto($resultado); }