template fixes + bug fixes + style fixes

This commit is contained in:
Dennis Eichhorn 2024-04-02 21:40:48 +00:00
parent b647e9f515
commit a88de95ce8
10 changed files with 247 additions and 167 deletions

View File

@ -17,6 +17,9 @@ namespace Modules\Organization\Controller;
use Model\Setting; use Model\Setting;
use Model\SettingMapper; use Model\SettingMapper;
use Modules\Admin\Models\AddressMapper; use Modules\Admin\Models\AddressMapper;
use Modules\Admin\Models\Contact;
use Modules\Admin\Models\ContactMapper;
use Modules\Admin\Models\ContactType;
use Modules\Admin\Models\SettingsEnum as ModelsSettingsEnum; use Modules\Admin\Models\SettingsEnum as ModelsSettingsEnum;
use Modules\Media\Models\PathSettings; use Modules\Media\Models\PathSettings;
use Modules\Organization\Models\Department; use Modules\Organization\Models\Department;
@ -731,7 +734,7 @@ final class ApiController extends Controller
/** @var \Modules\Organization\Models\Unit[] $units */ /** @var \Modules\Organization\Models\Unit[] $units */
$units = UnitMapper::getAll() $units = UnitMapper::getAll()
->where('name', '%' . ($request->getDataString('search') ?? '') . '%', 'LIKE') ->where('name', '%' . ($request->getDataString('search') ?? '') . '%', 'LIKE')
->execute(); ->executeGetArray();
$response->header->set('Content-Type', MimeType::M_JSON, true); $response->header->set('Content-Type', MimeType::M_JSON, true);
$response->set( $response->set(
@ -758,7 +761,7 @@ final class ApiController extends Controller
/** @var \Modules\Organization\Models\Department[] $departments */ /** @var \Modules\Organization\Models\Department[] $departments */
$departments = DepartmentMapper::getAll() $departments = DepartmentMapper::getAll()
->where('name', '%' . ($request->getDataString('search') ?? '') . '%', 'LIKE') ->where('name', '%' . ($request->getDataString('search') ?? '') . '%', 'LIKE')
->execute(); ->executeGetArray();
$response->header->set('Content-Type', MimeType::M_JSON, true); $response->header->set('Content-Type', MimeType::M_JSON, true);
$response->set( $response->set(
@ -785,7 +788,7 @@ final class ApiController extends Controller
/** @var \Modules\Organization\Models\Position[] $positions */ /** @var \Modules\Organization\Models\Position[] $positions */
$positions = PositionMapper::getAll() $positions = PositionMapper::getAll()
->where('name', '%' . ($request->getDataString('search') ?? '') . '%', 'LIKE') ->where('name', '%' . ($request->getDataString('search') ?? '') . '%', 'LIKE')
->execute(); ->executeGetArray();
$response->header->set('Content-Type', MimeType::M_JSON, true); $response->header->set('Content-Type', MimeType::M_JSON, true);
$response->set( $response->set(
@ -793,4 +796,81 @@ final class ApiController extends Controller
\array_values($positions) \array_values($positions)
); );
} }
/**
* Routing end-point for application behavior.
*
* @param RequestAbstract $request Request
* @param ResponseAbstract $response Response
* @param array $data Generic data
*
* @return void
*
* @api
*
* @since 1.0.0
*/
public function apiUnitContactCreate(RequestAbstract $request, ResponseAbstract $response, array $data = []) : void
{
if (!empty($val = $this->validateUnitContactCreate($request))) {
$response->header->status = RequestStatusCode::R_400;
$this->createInvalidCreateResponse($request, $response, $val);
return;
}
$contact = $this->createUnitContactFromRequest($request);
$this->createModel($request->header->account, $contact, ContactMapper::class, 'unit_contact', $request->getOrigin());
$this->createModelRelation(
$request->header->account,
(int) $request->getData('unit'),
$contact->id,
UnitMapper::class, 'contacts', '', $request->getOrigin()
);
$this->createStandardCreateResponse($request, $response, $contact);
}
/**
* Validate contact element create request
*
* @param RequestAbstract $request Request
*
* @return array<string, bool>
*
* @since 1.0.0
*/
public function validateUnitContactCreate(RequestAbstract $request) : array
{
$val = [];
if (($val['unit'] = !$request->hasData('unit'))
|| ($val['type'] = !\is_numeric($request->getData('type')))
|| ($val['content'] = !$request->hasData('content'))
) {
return $val;
}
return [];
}
/**
* Method to create a account element from request.
*
* @param RequestAbstract $request Request
*
* @return Contact
*
* @since 1.0.0
*/
public function createUnitContactFromRequest(RequestAbstract $request) : Contact
{
/** @var Contact $element */
$element = new Contact();
$element->type = ContactType::tryFromValue($request->getDataInt('type')) ?? ContactType::EMAIL;
$element->subtype = $request->getDataInt('subtype') ?? 0;
$element->content = $request->getDataString('content') ?? '';
return $element;
}
} }

View File

@ -62,9 +62,9 @@ final class BackendController extends Controller
->limit(25); ->limit(25);
if ($request->getData('ptype') === 'p') { if ($request->getData('ptype') === 'p') {
$view->data['units'] = $mapper->where('id', $request->getDataInt('id') ?? 0, '<')->execute(); $view->data['units'] = $mapper->where('id', $request->getDataInt('offset') ?? 0, '<')->execute();
} elseif ($request->getData('ptype') === 'n') { } elseif ($request->getData('ptype') === 'n') {
$view->data['units'] = $mapper->where('id', $request->getDataInt('id') ?? 0, '>')->execute(); $view->data['units'] = $mapper->where('id', $request->getDataInt('offset') ?? 0, '>')->execute();
} else { } else {
$view->data['units'] = $mapper->where('id', 0, '>')->execute(); $view->data['units'] = $mapper->where('id', 0, '>')->execute();
} }
@ -94,18 +94,21 @@ final class BackendController extends Controller
$selectorView = new \Modules\Organization\Theme\Backend\Components\UnitTagSelector\UnitTagSelectorView($this->app->l11nManager, $request, $response); $selectorView = new \Modules\Organization\Theme\Backend\Components\UnitTagSelector\UnitTagSelectorView($this->app->l11nManager, $request, $response);
$view->data['unit-selector'] = $selectorView; $view->data['unit-selector'] = $selectorView;
$unit = UnitMapper::get() $view->data['unit'] = UnitMapper::get()
->with('parent') ->with('parent')
->with('mainAddress') ->with('mainAddress')
->with('address')
->with('contacts')
->with('image') ->with('image')
->where('id', (int) $request->getData('id')) ->where('id', (int) $request->getData('id'))
->execute(); ->execute();
$view->data['unit'] = $unit;
$editor = new \Modules\Editor\Theme\Backend\Components\Editor\BaseView($this->app->l11nManager, $request, $response); $editor = new \Modules\Editor\Theme\Backend\Components\Editor\BaseView($this->app->l11nManager, $request, $response);
$view->data['editor'] = $editor; $view->data['editor'] = $editor;
$view->data['address-component'] = new \Modules\Admin\Theme\Backend\Components\AddressEditor\AddressView($this->app->l11nManager, $request, $response);
$view->data['contact-component'] = new \Modules\Admin\Theme\Backend\Components\ContactEditor\ContactView($this->app->l11nManager, $request, $response);
return $view; return $view;
} }
@ -130,17 +133,17 @@ final class BackendController extends Controller
$view->setTemplate('/Modules/Organization/Theme/Backend/organigram'); $view->setTemplate('/Modules/Organization/Theme/Backend/organigram');
/** @var Unit[] $units */ /** @var Unit[] $units */
$units = UnitMapper::getAll()->with('parent')->execute(); $units = UnitMapper::getAll()->with('parent')->executeGetArray();
$unitTree = $this->createOrgTree($units); $unitTree = $this->createOrgTree($units);
$view->data['unitTree'] = $unitTree; $view->data['unitTree'] = $unitTree;
/** @var Department[] $departments */ /** @var Department[] $departments */
$departments = DepartmentMapper::getAll()->with('parent')->with('unit')->execute(); $departments = DepartmentMapper::getAll()->with('parent')->with('unit')->executeGetArray();
$depTree = $this->createOrgTree($departments); $depTree = $this->createOrgTree($departments);
$view->data['departmentTree'] = $depTree; $view->data['departmentTree'] = $depTree;
/** @var Position[] $positions */ /** @var Position[] $positions */
$positions = PositionMapper::getAll()->with('parent')->with('unit')->with('department')->execute(); $positions = PositionMapper::getAll()->with('parent')->with('unit')->with('department')->executeGetArray();
$posTree = $this->createOrgTree($positions); $posTree = $this->createOrgTree($positions);
$view->data['positionTree'] = $posTree; $view->data['positionTree'] = $posTree;
@ -233,9 +236,9 @@ final class BackendController extends Controller
$mapper = DepartmentMapper::getAll()->with('parent')->with('unit')->limit($pageLimit + 1); $mapper = DepartmentMapper::getAll()->with('parent')->with('unit')->limit($pageLimit + 1);
if ($request->getData('ptype') === 'p') { if ($request->getData('ptype') === 'p') {
$mapper->where('id', $request->getDataInt('id') ?? 0, '<'); $mapper->where('id', $request->getDataInt('offset') ?? 0, '<');
} elseif ($request->getData('ptype') === 'n') { } elseif ($request->getData('ptype') === 'n') {
$mapper->where('id', $request->getDataInt('id') ?? 0, '>'); $mapper->where('id', $request->getDataInt('offset') ?? 0, '>');
} else { } else {
$mapper->where('id', 0, '>'); $mapper->where('id', 0, '>');
} }
@ -337,11 +340,11 @@ final class BackendController extends Controller
$view->data['nav'] = $this->app->moduleManager->get('Navigation')->createNavigationMid(1004705001, $request, $response); $view->data['nav'] = $this->app->moduleManager->get('Navigation')->createNavigationMid(1004705001, $request, $response);
if ($request->getData('ptype') === 'p') { if ($request->getData('ptype') === 'p') {
$view->data['positions'] = PositionMapper::getAll()->with('parent')->with('department')->where('id', $request->getDataInt('id') ?? 0, '<')->limit(25)->execute(); $view->data['positions'] = PositionMapper::getAll()->with('parent')->with('department')->where('id', $request->getDataInt('offset') ?? 0, '<')->limit(25)->executeGetArray();
} elseif ($request->getData('ptype') === 'n') { } elseif ($request->getData('ptype') === 'n') {
$view->data['positions'] = PositionMapper::getAll()->with('parent')->with('department')->where('id', $request->getDataInt('id') ?? 0, '>')->limit(25)->execute(); $view->data['positions'] = PositionMapper::getAll()->with('parent')->with('department')->where('id', $request->getDataInt('offset') ?? 0, '>')->limit(25)->executeGetArray();
} else { } else {
$view->data['positions'] = PositionMapper::getAll()->with('parent')->with('department')->where('id', 0, '>')->limit(25)->execute(); $view->data['positions'] = PositionMapper::getAll()->with('parent')->with('department')->where('id', 0, '>')->limit(25)->executeGetArray();
} }
return $view; return $view;

View File

@ -1,40 +0,0 @@
<?php
/**
* Jingga
*
* PHP Version 8.2
*
* @package Modules\Organization\Models
* @copyright Dennis Eichhorn
* @license OMS License 2.0
* @version 1.0.0
* @link https://jingga.app
*/
declare(strict_types=1);
namespace Modules\Organization\Models;
use phpOMS\Stdlib\Base\Enum;
/**
* Attribute value type enum.
*
* @package Modules\Organization\Models
* @license OMS License 2.0
* @link https://jingga.app
* @since 1.0.0
*/
abstract class AttributeValueType extends Enum
{
public const _INT = 1;
public const _STRING = 2;
public const _FLOAT = 3;
public const _DATETIME = 4;
public const _BOOL = 5;
public const _FLOAT_INT = 6;
}

View File

@ -14,6 +14,8 @@ declare(strict_types=1);
namespace Modules\Organization\Models; namespace Modules\Organization\Models;
use Modules\Admin\Models\Contact;
use Modules\Admin\Models\NullContact;
use Modules\Media\Models\Media; use Modules\Media\Models\Media;
use Modules\Media\Models\NullMedia; use Modules\Media\Models\NullMedia;
use phpOMS\Stdlib\Base\Address; use phpOMS\Stdlib\Base\Address;
@ -109,15 +111,23 @@ class Unit implements \JsonSerializable
} }
/** /**
* Get addresses. * Get the main contact element by type
* *
* @return array * @param int $type Contact element type
*
* @return Contact
* *
* @since 1.0.0 * @since 1.0.0
*/ */
public function getAddresses() : array public function getContactByType(int $type) : Contact
{ {
return $this->address; foreach ($this->contacts as $element) {
if ($element->type === $type) {
return $element;
}
}
return new NullContact();
} }
/** /**

View File

@ -35,4 +35,6 @@ return ['Organization' => [
'Unit' => 'Einheit', 'Unit' => 'Einheit',
'UnitLogo' => 'Einheit-Logo', 'UnitLogo' => 'Einheit-Logo',
'Units' => 'Einheiten', 'Units' => 'Einheiten',
'Profile' => 'Profil',
'Addresses' => 'Addressen',
]]; ]];

View File

@ -35,4 +35,6 @@ return ['Organization' => [
'Unit' => 'Unit', 'Unit' => 'Unit',
'UnitLogo' => 'Unit Logo', 'UnitLogo' => 'Unit Logo',
'Units' => 'Units', 'Units' => 'Units',
'Profile' => 'Profile',
'Addresses' => 'Addresses',
]]; ]];

View File

@ -22,7 +22,7 @@ $departments = $this->data['departments'] ?? [];
$previous = empty($departments) $previous = empty($departments)
? 'organization/department/list' ? 'organization/department/list'
: 'organization/department/list?{?}&id=' . \reset($departments)->id . '&ptype=p'; : 'organization/department/list?{?}&offset=' . \reset($departments)->id . '&ptype=p';
$next = empty($departments) $next = empty($departments)
? 'organization/department/list' ? 'organization/department/list'
: 'organization/department/list?{?}&id=' : 'organization/department/list?{?}&id='

View File

@ -20,8 +20,8 @@ use phpOMS\Uri\UriFactory;
*/ */
$positions = $this->data['positions'] ?? []; $positions = $this->data['positions'] ?? [];
$previous = empty($positions) ? 'organization/position/list' : '{/base}/organization/position/list?{?}&id=' . \reset($positions)->id . '&ptype=p'; $previous = empty($positions) ? 'organization/position/list' : '{/base}/organization/position/list?{?}&offset=' . \reset($positions)->id . '&ptype=p';
$next = empty($positions) ? 'organization/position/list' : '{/base}/organization/position/list?{?}&id=' . \end($positions)->id . '&ptype=n'; $next = empty($positions) ? 'organization/position/list' : '{/base}/organization/position/list?{?}&offset=' . \end($positions)->id . '&ptype=n';
echo $this->data['nav']->render(); ?> echo $this->data['nav']->render(); ?>

View File

@ -20,8 +20,8 @@ use phpOMS\Uri\UriFactory;
*/ */
$units = $this->data['units'] ?? []; $units = $this->data['units'] ?? [];
$previous = empty($units) ? 'organization/unit/list' : '{/base}/organization/unit/list?{?}&id=' . \reset($units)->id . '&ptype=p'; $previous = empty($units) ? 'organization/unit/list' : '{/base}/organization/unit/list?{?}&offset=' . \reset($units)->id . '&ptype=p';
$next = empty($units) ? 'organization/unit/list' : '{/base}/organization/unit/list?{?}&id=' . \end($units)->id . '&ptype=n'; $next = empty($units) ? 'organization/unit/list' : '{/base}/organization/unit/list?{?}&offset=' . \end($units)->id . '&ptype=n';
echo $this->data['nav']->render(); ?> echo $this->data['nav']->render(); ?>

View File

@ -12,6 +12,7 @@
*/ */
declare(strict_types=1); declare(strict_types=1);
use Modules\Organization\Models\NullUnit;
use Modules\Organization\Models\Status; use Modules\Organization\Models\Status;
use phpOMS\Localization\ISO3166NameEnum; use phpOMS\Localization\ISO3166NameEnum;
use phpOMS\Localization\ISO3166TwoEnum; use phpOMS\Localization\ISO3166TwoEnum;
@ -21,122 +22,144 @@ use phpOMS\Uri\UriFactory;
* @var \phpOMS\Views\View $this * @var \phpOMS\Views\View $this
* @var \Modules\Organization\Models\Unit $unit; * @var \Modules\Organization\Models\Unit $unit;
*/ */
$unit = $this->data['unit']; $unit = $this->data['unit'] ?? new NullUnit();
$isNew = $unit->id === 0;
$countryCodes = ISO3166TwoEnum::getConstants(); $countryCodes = ISO3166TwoEnum::getConstants();
$countries = ISO3166NameEnum::getConstants(); $countries = ISO3166NameEnum::getConstants();
echo $this->data['nav']->render(); ?> echo $this->data['nav']->render(); ?>
<form id="iUnitUploadForm" action="<?= UriFactory::build('{/api}organization/unit/image?id={?id}&csrf={$CSRF}'); ?>" method="post"><input class="preview" data-action='[{"listener": "change", "key": 1, "action": [{"key": 1, "type": "form.submit", "selector": "#iUnitUploadForm"}]}]' id="iUnitUpload" name="unitImage" type="file" accept="image/png,image/gif,image/jpeg" style="display: none;"></form> <div class="tabview tab-2">
<?php if (!$isNew) : ?>
<div class="row"> <div class="box">
<div class="col-xs-12 col-md-6"> <ul class="tab-links">
<div class="portlet"> <li><label for="c-tab-1"><?= $this->getHtml('Profile'); ?></label>
<form id="iUnit" action="<?= UriFactory::build('{/api}organization/unit?csrf={$CSRF}'); ?>" method="post"> <li><label for="c-tab-2"><?= $this->getHtml('Addresses'); ?></label>
<div class="portlet-head row middle-xs"> </ul>
<div class="col-xs-0">
<a id="iUnitUploadButton" href="#upload" data-action='[{"listener": "click", "key": 1, "action": [{"key": 1, "type": "event.prevent"}, {"key": 2, "type": "dom.click", "selector": "#iUnitUpload"}]}]'>
<img id="preview-unitImage" class="profile-image preview"
alt="<?= $this->getHtml('Logo'); ?>"
itemprop="logo" loading="lazy"
src="<?=
$unit->image->id === 0 ?
UriFactory::build('Modules/Organization/Theme/Backend/img/org_default.png') :
UriFactory::build($unit->image->getPath()); ?>"
width="40x">
</a>
</div>
<div><?= $this->getHtml('Unit'); ?></div>
</div>
<div class="portlet-body">
<div class="form-group">
<label for="iName"><?= $this->getHtml('Name'); ?></label>
<input type="text" name="name" id="iName" value="<?= $this->printHtml($unit->name); ?>">
</div>
<div class="form-group">
<label for="iParent"><?= $this->getHtml('Parent'); ?></label>
<?= $this->getData('unit-selector')->render('iParent', 'parent', false); ?>
</div>
<div class="form-group">
<label for="iStatus"><?= $this->getHtml('Status'); ?></label>
<select name="status" id="iStatus">
<option value="<?= Status::ACTIVE; ?>"<?= $unit->status === Status::ACTIVE ? ' selected' : ''; ?>><?= $this->getHtml('Active'); ?>
<option value="<?= Status::INACTIVE; ?>"<?= $unit->status === Status::INACTIVE ? ' selected' : ''; ?>><?= $this->getHtml('Inactive'); ?>
</select>
</div>
<div class="form-group">
<?= $this->getData('editor')->render('unit-editor'); ?>
</div>
<?= $this->getData('editor')->getData('text')->render(
'unit-editor',
'description',
'iUnit',
$unit->descriptionRaw,
$unit->description
); ?>
</div>
<div class="portlet-foot">
<input id="iUnitId" name="id" type="hidden" value="<?= (int) $unit->id; ?>">
<input id="iSubmit" name="submit" type="submit" value="<?= $this->getHtml('Save', '0', '0'); ?>">
</div>
</form>
</div>
</div> </div>
<?php endif; ?>
<div class="tab-content">
<input type="radio" id="c-tab-1" name="tabular-2"<?= $isNew || $this->request->uri->fragment === 'c-tab-1' ? ' checked' : ''; ?>>
<div class="tab">
<form id="iUnitUploadForm" action="<?= UriFactory::build('{/api}organization/unit/image?id={?id}&csrf={$CSRF}'); ?>" method="post"><input class="preview" data-action='[{"listener": "change", "key": 1, "action": [{"key": 1, "type": "form.submit", "selector": "#iUnitUploadForm"}]}]' id="iUnitUpload" name="unitImage" type="file" accept="image/png,image/gif,image/jpeg" style="display: none;"></form>
<div class="row">
<div class="col-xs-12 col-md-6">
<div class="portlet">
<form id="iUnit" action="<?= UriFactory::build('{/api}organization/unit?csrf={$CSRF}'); ?>" method="post">
<div class="portlet-head row middle-xs">
<div class="col-xs-0">
<a id="iUnitUploadButton" href="#upload" data-action='[{"listener": "click", "key": 1, "action": [{"key": 1, "type": "event.prevent"}, {"key": 2, "type": "dom.click", "selector": "#iUnitUpload"}]}]'>
<img id="preview-unitImage" class="profile-image preview"
alt="<?= $this->getHtml('Logo'); ?>"
itemprop="logo" loading="lazy"
src="<?=
$unit->image->id === 0 ?
UriFactory::build('Modules/Organization/Theme/Backend/img/org_default.png') :
UriFactory::build($unit->image->getPath()); ?>"
width="40x">
</a>
</div>
<div><?= $this->getHtml('Unit'); ?></div>
</div>
<div class="portlet-body">
<div class="form-group">
<label for="iName"><?= $this->getHtml('Name'); ?></label>
<input type="text" name="name" id="iName" value="<?= $this->printHtml($unit->name); ?>">
</div>
<div class="col-xs-12 col-md-6"> <div class="form-group">
<div class="portlet"> <label for="iParent"><?= $this->getHtml('Parent'); ?></label>
<div class="portlet-head"><?= $this->getHtml('MainAddress'); ?></div> <?= $this->getData('unit-selector')->render('iParent', 'parent', false); ?>
<form id="iUnitMainAdress" action="<?= UriFactory::build('{/api}organization/unit/address/main?csrf={$CSRF}'); ?>" method="post"> </div>
<div class="portlet-body">
<div class="form-group">
<label for="iLegalName"><?= $this->getHtml('LegalName'); ?></label>
<input type="text" name="legal" id="iLegalName" value="<?= $this->printHtml($unit->mainAddress->name); ?>">
</div>
<div class="form-group"> <div class="form-group">
<label for="iAddress"><?= $this->getHtml('Address'); ?></label> <label for="iStatus"><?= $this->getHtml('Status'); ?></label>
<input type="text" name="address" id="iAddress" value="<?= $this->printHtml($unit->mainAddress->address); ?>"> <select name="status" id="iStatus">
</div> <option value="<?= Status::ACTIVE; ?>"<?= $unit->status === Status::ACTIVE ? ' selected' : ''; ?>><?= $this->getHtml('Active'); ?>
<option value="<?= Status::INACTIVE; ?>"<?= $unit->status === Status::INACTIVE ? ' selected' : ''; ?>><?= $this->getHtml('Inactive'); ?>
</select>
</div>
<div class="form-group"> <div class="form-group">
<label for="iPostal"><?= $this->getHtml('Postal'); ?></label> <?= $this->getData('editor')->render('unit-editor'); ?>
<input type="text" name="postal" id="iPostal" value="<?= $this->printHtml($unit->mainAddress->postal); ?>"> </div>
</div>
<div class="form-group"> <?= $this->getData('editor')->getData('text')->render(
<label for="iCity"><?= $this->getHtml('City'); ?></label> 'unit-editor',
<input type="text" name="city" id="iCity" value="<?= $this->printHtml($unit->mainAddress->city); ?>"> 'description',
</div> 'iUnit',
$unit->descriptionRaw,
<div class="form-group"> $unit->description
<label for="iCountry"><?= $this->getHtml('Country'); ?></label> ); ?>
<select id="iCountry" name="country"> </div>
<?php <div class="portlet-foot">
$selected = false; <input id="iUnitId" name="id" type="hidden" value="<?= (int) $unit->id; ?>">
foreach ($countryCodes as $code3 => $code2) : <input id="iSubmit" name="submit" type="submit" value="<?= $this->getHtml('Save', '0', '0'); ?>">
if ($code2 === $unit->mainAddress->country) { </div>
$selected = true; </form>
}
?>
<option value="<?= $this->printHtml($code2); ?>"<?= $code2 === $unit->mainAddress->country ? ' selected' : ''; ?>>
<?= $this->printHtml($countries[$code3]); ?>
</option>
<?php endforeach; ?>
</select>
</div> </div>
</div> </div>
<div class="portlet-foot">
<input id="iUnitId" name="id" type="hidden" value="<?= (int) $unit->id; ?>"> <div class="col-xs-12 col-md-6">
<input id="iSubmit" name="submit" type="submit" value="<?= $this->getHtml('Save', '0', '0'); ?>"> <div class="portlet">
<div class="portlet-head"><?= $this->getHtml('MainAddress'); ?></div>
<form id="iUnitMainAdress" action="<?= UriFactory::build('{/api}organization/unit/address/main?csrf={$CSRF}'); ?>" method="post">
<div class="portlet-body">
<div class="form-group">
<label for="iLegalName"><?= $this->getHtml('LegalName'); ?></label>
<input type="text" name="legal" id="iLegalName" value="<?= $this->printHtml($unit->mainAddress->name); ?>">
</div>
<div class="form-group">
<label for="iAddress"><?= $this->getHtml('Address'); ?></label>
<input type="text" name="address" id="iAddress" value="<?= $this->printHtml($unit->mainAddress->address); ?>">
</div>
<div class="form-group">
<label for="iPostal"><?= $this->getHtml('Postal'); ?></label>
<input type="text" name="postal" id="iPostal" value="<?= $this->printHtml($unit->mainAddress->postal); ?>">
</div>
<div class="form-group">
<label for="iCity"><?= $this->getHtml('City'); ?></label>
<input type="text" name="city" id="iCity" value="<?= $this->printHtml($unit->mainAddress->city); ?>">
</div>
<div class="form-group">
<label for="iCountry"><?= $this->getHtml('Country'); ?></label>
<select id="iCountry" name="country">
<?php
$selected = false;
foreach ($countryCodes as $code3 => $code2) :
if ($code2 === $unit->mainAddress->country) {
$selected = true;
}
?>
<option value="<?= $this->printHtml($code2); ?>"<?= $code2 === $unit->mainAddress->country ? ' selected' : ''; ?>>
<?= $this->printHtml($countries[$code3]); ?>
</option>
<?php endforeach; ?>
</select>
</div>
</div>
<div class="portlet-foot">
<input id="iUnitId" name="id" type="hidden" value="<?= (int) $unit->id; ?>">
<input id="iSubmit" name="submit" type="submit" value="<?= $this->getHtml('Save', '0', '0'); ?>">
</div>
</form>
</div>
</div> </div>
</form> </div>
<?= $this->getData('unit-selector')->getData('unit-selector-popup')->render(); ?>
</div> </div>
<?php if (!$isNew) : ?>
<input type="radio" id="c-tab-2" name="tabular-2"<?= $this->request->uri->fragment === 'c-tab-2' ? ' checked' : ''; ?>>
<div class="tab">
<?= $this->data['contact-component']->render('unit-contact', 'contacts', $unit->contacts); ?>
<?= $this->data['address-component']->render('unit-address', 'addresses', $unit->address); ?>
</div>
<?php endif; ?>
</div> </div>
</div> </div>
<?= $this->getData('unit-selector')->getData('unit-selector-popup')->render(); ?>