<?php

namespace ModulesGarden\HostingQuotaNotifications\App\Libs\GroupConfiguration;

use \ModulesGarden\HostingQuotaNotifications\App\Helper\Models\EmailTemplates;
use ModulesGarden\HostingQuotaNotifications\App\Libs\Cron\Notifications\Actions\OpenTicket;
use \ModulesGarden\HostingQuotaNotifications\App\Libs\TicketTemplates;
/**
 * Description of Formatter
 *
 * @author Artur Pilch <artur.pi@modulesgarden.com>
 */
class Formatter
{
    public static function formatRow($conf, $data, $lang, $replaceIdToNames)
    {
        $unserializeConf = unserialize($conf);
        if(!$replaceIdToNames)
        {
            return $unserializeConf;
        }
        $out    =   [];
        foreach ($unserializeConf as $key => $value)
        {
            $out[$key] = isset($data[$key][$value]) ? $data[$key][$value] : $value;
            $out[$key] = $lang->absoluteT('steps', $out[$key]);
        }
        $out['ticket_status'] = $out['ticket_status'] ? : OpenTicket::STATUS_OPEN;

        return $out;
    }
    
    public static function mergeFormatAndBase($conf, $step)
    {
        unset($conf['configuration']);
        return array_merge($conf, $step);
    }
    
    public static function getReplaceData()
    {
        return [
            'email_template'  => EmailTemplates::getEmailTemplatesIdAsKeyAndNameAsValue(),
            'ticket_template' => TicketTemplates\Manage::getTicketTemplatesAsKeyIdAndNameAsValue(),
        ];
    }
    
    
}
