obter tipo de mensagem flash function getFlashType() { if (isset($_SESSION['error_message'])) return 'danger'; if (isset($_SESSION['success_message'])) return 'success'; return 'info'; } // Validar email function isValidEmail($email) { return filter_var($email, FILTER_VALIDATE_EMAIL) !== false; } // Gerar hash de senha function hashPassword($password) { return password_hash($password, PASSWORD_DEFAULT); } // Verificar senha function verifyPassword($password, $hash) { return password_verify($password, $hash); } // Upload de arquivo function uploadFile($file, $uploadDir = 'uploads/', $allowedTypes = ['jpg', 'jpeg', 'png', 'gif']) { if (!isset($file['error']) || is_array($file['error'])) { return ['success' => false, 'message' => 'Erro no upload do arquivo']; } switch ($file['error']) { case UPLOAD_ERR_OK: break; case UPLOAD_ERR_NO_FILE: return ['success' => false, 'message' => 'Nenhum arquivo enviado']; case UPLOAD_ERR_INI_SIZE: case UPLOAD_ERR_FORM_SIZE: return ['success' => false, 'message' => 'Arquivo muito grande']; default: return ['success' => false, 'message' => 'Erro desconhecido']; } $extension = strtolower(pathinfo($file['name'], PATHINFO_EXTENSION)); if (!in_array($extension, $allowedTypes)) { return ['success' => false, 'message' => 'Tipo de arquivo não permitido']; } if ($file['size'] > 5242880) { // 5MB return ['success' => false, 'message' => 'Arquivo muito grande (máx 5MB)']; } if (!is_dir($uploadDir)) { mkdir($uploadDir, 0755, true); } $fileName = uniqid() . '.' . $extension; $filePath = $uploadDir . $fileName; if (!move_uploaded_file($file['tmp_name'], $filePath)) { return ['success' => false, 'message' => 'Erro ao salvar arquivo']; } return ['success' => true, 'filename' => $fileName, 'path' => $filePath]; } // Paginação function paginate($table, $page = 1, $perPage = 10, $where = '', $orderBy = 'id DESC') { $db = getDB(); $offset = ($page - 1) * $perPage; // Total de registros $countQuery = "SELECT COUNT(*) as total FROM $table" . ($where ? " WHERE $where" : ""); $total = $db->query($countQuery)->fetch()['total']; // Registros da página $query = "SELECT * FROM $table" . ($where ? " WHERE $where" : "") . " ORDER BY $orderBy LIMIT $perPage OFFSET $offset"; $stmt = $db->query($query); $data = $stmt->fetchAll(); return [ 'data' => $data, 'total' => $total, 'page' => $page, 'perPage' => $perPage, 'totalPages' => ceil($total / $perPage), 'hasNext' => $page < ceil($total / $perPage), 'hasPrev' => $page > 1 ]; } ?> Login - Dashboard Saotome

Saotome

Sistema de Gestão Empresarial

Credenciais de Teste:
Admin: admin@saotome.com / admin123
Gerente: maria@saotome.com / admin123
Operador: joao@saotome.com / admin123