<?php

namespace Hubleto\App\Community\Settings\Models;

use Hubleto\Framework\Db\Column\Varchar;
use Hubleto\Framework\Db\Column\Image;
use Hubleto\Framework\Db\Column\Color;

class Company extends \Hubleto\Erp\Model
{
  public string $table = 'companies';
  public string $recordManagerClass = RecordManagers\Company::class;
  public ?string $lookupSqlValue = '{%TABLE%}.name';

  public function describeColumns(): array
  {
    return array_merge(parent::describeColumns(), [
      'name' => (new Varchar($this, $this->translate('Company')))->setRequired()->setIcon(self::COLUMN_NAME_DEFAULT_ICON),
      'registration_id' => (new Varchar($this, $this->translate('Registration ID'))),
      'business_register' => (new Varchar($this, $this->translate('Business register'))),
      'tax_id' => (new Varchar($this, $this->translate('Tax ID'))),
      'vat_id' => (new Varchar($this, $this->translate('VAT ID'))),
      'street_1' => (new Varchar($this, $this->translate('Street, line 1'))),
      'street_2' => (new Varchar($this, $this->translate('Street, line 2'))),
      'zip' => (new Varchar($this, $this->translate('ZIP'))),
      'city' => (new Varchar($this, $this->translate('City'))),
      'region' => (new Varchar($this, $this->translate('Region'))),
      'country' => (new Varchar($this, $this->translate('Country'))),
      'logo' => (new Image($this, $this->translate('Logo'))),
      'brand_color_primary' => (new Color($this, $this->translate('Brand color - primary'))),
      'brand_color_secondary' => (new Color($this, $this->translate('Brand color - secondary'))),
    ]);
  }

  public function describeTable(): \Hubleto\Framework\Description\Table
  {
    $description = parent::describeTable();

    $description->ui['title'] = '';
    $description->ui['addButtonText'] = $this->translate('Add company');
    $description->ui['showHeader'] = true;
    $description->ui['showFulltextSearch'] = true;
    $description->ui['showFooter'] = false;

    return $description;
  }

}
