<?php

namespace GriffinForms\Admin\App\Html\Widgets\LeftSidebar;

final class FolderMenu extends \GriffinForms\Admin\App\Html\Widgets\LeftSidebar\Format
{
    public function getHtml()
    {
        echo '<div id="griffinforms-app-leftsidebar-formeditmenu" class="align-self-start" data-gf-visibility="context" data-gf-context="form-select">';
        $this->getMenuItemsList();
        echo '</div>';
    }

    private function getMenuItemsList()
    {
        echo '<div class="ms-2">';
        $this->folderList();
        echo '</div>';
    }

    private function folderList()
    {
        $folders = $this->sql->getItems('folder', array('id', 'name', 'icon'));
        foreach ($folders as $folder) {
            $img_src = $this->config->getRootUrl() . 'admin/images/folder//' . absint($folder->icon) . '.png';
            $this->imgMenuItem($img_src, $folder->id, $folder->name);
        }
    }

    private function layoutMenuItem()
    {
        $this->imgMenuItem('space_dashboard', 'layout', __('Layout', 'griffinforms-form-builder'));
    }

    private function nameMenuItem()
    {
        $this->imgMenuItem('page_info', 'name', __('Name', 'griffinforms-form-builder'));
    }

    private function limitsMenuItem()
    {
        $this->imgMenuItem('fence', 'limits', __('Limits', 'griffinforms-form-builder'));
    }

    private function accessMenuItem()
    {
        $this->imgMenuItem('key', 'access', __('Access', 'griffinforms-form-builder'));
    }

    private function afterSubmitMenuItem()
    {
        $this->imgMenuItem('send', 'submitaction', __('Submit Action', 'griffinforms-form-builder'));
    }

    private function submissionsMenuItem()
    {
        $badge = '<span class="ms-2 badge bg-danger">New</span>';
        $this->imgMenuItem('home_storage', 'submissions', __('Submissions', 'griffinforms-form-builder'), $badge);
    }
}