<?php

use App\Models\Crud;

if (!function_exists('getSegment')) {
    function getSegment(int $number)
    {
        $request = \Config\Services::request();

        if ($request->uri->getTotalSegments() >= $number && $request->uri->getSegment($number)) {
            return $request->uri->getSegment($number);
        } else {
            return false;
        }
    }
}


if (!function_exists('RefID')) {
    function RefID($id, $prefix = 'ERR/L')
    {
        if ($prefix == 'ERR/SU') {
            $str = $prefix ."/". str_repeat("0", 3 - strlen($id)) . $id;
        } else {
            $str = $prefix ."/". str_repeat("0", 9 - strlen($id)) . $id;
        }

        return $str;
    }
}

if (!function_exists('CopyText')) {
    function CopyText($text)
    {
        if($text!='' && $text!=0){
            return '<a href="javascript:void(0);" style="font-size: 60%;line-height: 35px;color: red;margin-left: 15px;" 
        onclick="Copy(\'' . $text . '\')">Copy</a>';
        }

    }
}

?>