public function postLogon() { $values = Request::all(); $employee = fil_employee::where('emp_email', $values['email'])->first(); if ($employee != null) { if (Hash::check($values['password'], $employee->emp_password)) { Session::put('id', $employee->emp_id); Session::put('user', $employee->emp_first_name . ' ' . $employee->emp_last_name); Session::put('type', $employee->emp_job); Session::put('logged', true); $success = true; $data = '<p class="fadeIn animated" style="color: green">Bienvenido <b>' . Session::get('user') . '</b></p>'; } else { $success = false; $data = '<p class="fadeIn animated" style="color: red">Contraseña incorrecta</p>'; } } else { $success = false; $data = '<p class="fadeIn animated" style="color: red">Usuario incorrecto</p>'; } $response = Response::json(array('success' => $success, 'data' => $data)); return $response; }
public function postUpdateProfile() { $values = Request::all(); if ($values['emp_first_name'] == '' || $values['emp_first_name'] == null) { return Response::json(array('success' => false, 'data' => 'Campo Nombre requerido')); } if ($values['emp_last_name'] == '' || $values['emp_last_name'] == null) { return Response::json(array('success' => false, 'data' => 'Campo Apellido requerido')); } if ($values['emp_address'] == '' || $values['emp_address'] == null) { return Response::json(array('success' => false, 'data' => 'Campo Dirección requerido')); } if ($values['emp_phone_number'] == '' || $values['emp_phone_number'] == null) { return Response::json(array('success' => false, 'data' => 'Campo Número Fijo requerido')); } if ($values['emp_email'] == '' || $values['emp_email'] == null) { return Response::json(array('success' => false, 'data' => 'Campo Correo/Usuario requerido')); } if ($values['emp_password_change'] == 'true') { if ($values['emp_password'] == '' || $values['emp_password'] == null) { return Response::json(array('success' => false, 'data' => 'campo Contraseña anterior requerido')); } if ($values['emp_new_password'] == '' || $values['emp_new_password'] == null) { return Response::json(array('success' => false, 'data' => 'Campo nueva contraseña requerido')); } if ($values['emp_rep_password'] == '' || $values['emp_rep_password'] == null) { return Response::json(array('success' => false, 'data' => 'Campo confirmar contraseña requerido')); } } $data = fil_employee::find($values['id']); if ($data == null) { return Response::json(array('success' => false, 'data' => 'No se ha encontrado el empleado a actualizar')); } $data->emp_first_name = $values['emp_first_name']; $data->emp_last_name = $values['emp_last_name']; $data->emp_address = $values['emp_address']; $data->emp_phone_number = $values['emp_phone_number']; $data->emp_cellphone_number = $values['emp_cellphone_number']; $data->emp_email = $values['emp_email']; if ($values['emp_password_change'] == 'true') { if (Hash::check($values['emp_password'], $data->emp_password)) { if ($values['emp_new_password'] == $values['emp_rep_password']) { $data->emp_password = Hash::make($values['emp_new_password']); } else { return Response::json(array('success' => false, 'data' => 'las contraseñas no coinciden, verifique que las contraseñas coincidan')); } } else { return Response::json(array('success' => false, 'data' => 'Contraseña anterior errónea, por favor ingrese la contraseña correcta')); } } $response = null; if ($data->save()) { $response = Response::json(array('success' => true, 'data' => 'Empleado actualizado con exito')); } else { $response = Response::json(array('success' => false, 'data' => 'Ocurrió un error al guardar el empleado')); } return $response; }
public function postGetByEmployee() { $id = Request::input('id'); $data = fil_employee::find($id)->customers; if ($data == null) { return Response::json(array('success' => false, 'data' => 'Error al leer clientes')); } else { $finalArray = []; foreach ($data as $value) { $tempRow['cus_id'] = $value->cus_id; $tempRow['cus_name'] = $value->cus_contact_first_name . ' ' . $value->cus_contact_last_name; $tempRow['cus_enterprise'] = 'Nombre Comercial: ' . $value->cus_commercial_name . '<br>Actividad o Giro: ' . $value->cus_business_activity; $tempRow['cus_contact'] = 'Puesto: ' . $value->cus_job . '<br>Teléfono Fijo: ' . $value->cus_phone_number . ' ,Extensión:' . $value->cus_phone_extension . '<br>Teléfono Celular: ' . $value->cus_cellphone_number . '<br>Correo: ' . $value->cus_email . '<br>Dirección: ' . $value->cus_address; $finalArray[] = $tempRow; } return Response::json(array('success' => true, 'data' => $finalArray)); } }