<?php

namespace EasyRestaurantManager\Services;
class ReservationHelper
{
    public static function easyRestaurantManagerSeatPosition($index, $totalSeats) {
        $sideSeats = ceil($totalSeats / 4); // Number of seats per side
        $side = floor($index / $sideSeats); // Determine side (0: Top, 1: Right, 2: Bottom, 3: Left)
        $position = $index % $sideSeats; // Position on the side
        $spacing = 100 / ($sideSeats + 1); // Space between seats
    
        $style = '';
        // Top side
        if ($side == 0) {
            $style = "top: -10px; left: " . (($position + 1) * $spacing) . "%; transform: translateX(-50%);";
        }
        // Right side
        else if ($side == 1) {
            $style = "right: -10px; top: " . (($position + 1) * $spacing) . "%; transform: translateY(-50%);";
        }
        // Bottom side
        else if ($side == 2) {
            $style = "bottom: -10px; left: " . (($position + 1) * $spacing) . "%; transform: translateX(-50%);";
        }
        // Left side
        else {
            $style = "left: -10px; top: " . (($position + 1) * $spacing) . "%; transform: translateY(-50%);";
        }
    
        return $style;
    }

    public static function parsePlaceholders($content, $data) {
        foreach ($data as $key => $value) {
            $placeholder = '{' . $key . '}';
            $content = str_replace($placeholder, $value, $content);
        }
        return $content;
    }
    
}