262 lines
7.5 KiB
PHP
262 lines
7.5 KiB
PHP
<script type="text/javascript" src="/libraries/ckeditor/ckeditor.js"></script>
|
|
<script type="text/javascript" src="/libraries/ckeditor/adapters/jquery.js"></script>
|
|
<script type="text/javascript" src="/libraries/jquery/sortable/sortable.js"></script>
|
|
|
|
<?php
|
|
global $gdb;
|
|
|
|
/** @var array|null $item */
|
|
/** @var array $products */
|
|
/** @var array $provinces */
|
|
|
|
$item = $this -> item ?? [];
|
|
$products = $this -> products ?? [];
|
|
$provinces = $this -> provinces ?? [];
|
|
|
|
/** Województwa */
|
|
$province_values = [ 0 => '--- wybierz województwo ---' ];
|
|
if (is_array($provinces)) {
|
|
foreach ($provinces as $p) {
|
|
$province_values[(int)$p['id']] = $p['name'];
|
|
}
|
|
}
|
|
|
|
/** Typ salonu */
|
|
$salon_type_values = [
|
|
'sales' => 'SALON SPRZEDAŻY',
|
|
'partner' => 'SALON PARTNERSKI',
|
|
];
|
|
|
|
/** Produkty */
|
|
$selected_products = $item['products'] ?? [];
|
|
if (!is_array($selected_products)) $selected_products = [];
|
|
|
|
ob_start();
|
|
?>
|
|
|
|
<div id="settings-tabs">
|
|
<ul class="resp-tabs-list settings-tabs">
|
|
<li><i class="fa fa-map-marker"></i>Dane salonu</li>
|
|
<li><i class="fa fa-phone"></i>Kontakt</li>
|
|
<li><i class="fa fa-cubes"></i>Produkty</li>
|
|
<li><i class="fa fa-wrench"></i>Ustawienia</li>
|
|
</ul>
|
|
|
|
<div class="resp-tabs-container settings-tabs">
|
|
|
|
<!-- TAB 1: Dane salonu -->
|
|
<div>
|
|
<?= \Html::select([
|
|
'label' => 'Województwo',
|
|
'name' => 'province_id',
|
|
'id' => 'province_id',
|
|
'values' => $province_values,
|
|
'value' => (int)($item['province_id'] ?? 0),
|
|
]);?>
|
|
|
|
<?= \Html::select([
|
|
'label' => 'Typ salonu',
|
|
'name' => 'salon_type',
|
|
'id' => 'salon_type',
|
|
'values' => $salon_type_values,
|
|
'value' => ($item['salon_type'] ?? 'sales'),
|
|
]);?>
|
|
|
|
<?= \Html::input([
|
|
'label' => 'Nazwa salonu',
|
|
'name' => 'salon_name',
|
|
'id' => 'salon_name',
|
|
'value' => ($item['salon_name'] ?? ''),
|
|
'inline' => true
|
|
]);?>
|
|
|
|
<?= \Html::input([
|
|
'label' => 'Miasto',
|
|
'name' => 'city',
|
|
'id' => 'city',
|
|
'value' => ($item['city'] ?? ''),
|
|
'inline' => true
|
|
]);?>
|
|
|
|
<?= \Html::textarea([
|
|
'label' => 'Adres',
|
|
'name' => 'address',
|
|
'id' => 'address',
|
|
'value' => ($item['address'] ?? ''),
|
|
'inline' => true
|
|
]);?>
|
|
|
|
<?= \Html::input([
|
|
'label' => 'Koordynaty (lat, lng)',
|
|
'name' => 'coords',
|
|
'id' => 'coords',
|
|
'value' => ($item['coords'] ?? ''),
|
|
'inline' => true,
|
|
'desc' => 'Np. 50.07576365941408, 21.973886126521034'
|
|
]);?>
|
|
|
|
<?= \Html::textarea([
|
|
'label' => 'Godziny otwarcia',
|
|
'name' => 'opening_hours',
|
|
'id' => 'opening_hours',
|
|
'value' => ($item['opening_hours'] ?? ''),
|
|
'inline' => true,
|
|
'desc' => 'Np. Pn-Pt: 8-17 | Sob: 9-13 | Nd: nieczynne'
|
|
]);?>
|
|
|
|
<?= \Html::input_icon([
|
|
'label' => 'Baner (obrazek salonu)',
|
|
'name' => 'banner_image',
|
|
'id' => 'banner_image',
|
|
'value' => ($item['banner_image'] ?? ''),
|
|
'icon_content' => 'przeglądaj',
|
|
'inline' => true,
|
|
'icon_js' => "window.open('/libraries/filemanager-9.14.1/dialog.php?type=1&popup=1&field_id=banner_image&akey=c3cb2537d25c0efc9e573d059d79c3b8','mywindow','location=1,status=1,scrollbars=1,width=1100,height=700');"
|
|
]);?>
|
|
</div>
|
|
|
|
<!-- TAB 2: Kontakt -->
|
|
<div>
|
|
<?php
|
|
$phones_txt = '';
|
|
if (!empty($item['phones']) && is_array($item['phones'])) $phones_txt = implode("\n", $item['phones']);
|
|
|
|
$emails_txt = '';
|
|
if (!empty($item['emails']) && is_array($item['emails'])) $emails_txt = implode("\n", $item['emails']);
|
|
?>
|
|
|
|
<?= \Html::textarea([
|
|
'label' => 'Telefony (1 numer = 1 linia)',
|
|
'name' => 'phones',
|
|
'id' => 'phones',
|
|
'value' => $phones_txt,
|
|
'inline' => true
|
|
]);?>
|
|
|
|
<?= \Html::textarea([
|
|
'label' => 'E-maile (1 email = 1 linia)',
|
|
'name' => 'emails',
|
|
'id' => 'emails',
|
|
'value' => $emails_txt,
|
|
'inline' => true
|
|
]);?>
|
|
|
|
<?= \Html::input([
|
|
'label' => 'Tekst przycisku',
|
|
'name' => 'button_label',
|
|
'id' => 'button_label',
|
|
'value' => ($item['button_label'] ?? 'SKONTAKTUJ SIĘ Z NAMI'),
|
|
'inline' => true
|
|
]);?>
|
|
|
|
<?= \Html::input([
|
|
'label' => 'Link przycisku (URL)',
|
|
'name' => 'button_url',
|
|
'id' => 'button_url',
|
|
'value' => ($item['button_url'] ?? ''),
|
|
'inline' => true,
|
|
'desc' => 'Np. https://twojadomena.pl/kontakt'
|
|
]);?>
|
|
</div>
|
|
|
|
<!-- TAB 3: Produkty -->
|
|
<div>
|
|
<div class="title">Dostępne produkty</div>
|
|
|
|
<?php if (is_array($products) && count($products)): ?>
|
|
<div style="display:flex; flex-wrap:wrap; gap:14px;">
|
|
<?php foreach ($products as $p): ?>
|
|
<?php
|
|
$pid = (int)$p['id'];
|
|
$checked = in_array($pid, $selected_products) ? 'checked' : '';
|
|
?>
|
|
<label style="display:flex; align-items:center; gap:20px; padding:10px 12px; border:1px solid #ddd; border-radius:6px; cursor:pointer;">
|
|
<input type="checkbox" name="products[]" value="<?= $pid; ?>" <?= $checked; ?> />
|
|
<div style="display:flex; flex-direction:column; align-items:center; gap:10px;">
|
|
<span style="text-align: center;"><?= $p['name']; ?></span>
|
|
<img src="/<?= ltrim($p['icon'], '/'); ?>" alt="" style="width:36px; height:36px; object-fit:contain;" />
|
|
</div>
|
|
</label>
|
|
<?php endforeach; ?>
|
|
</div>
|
|
<?php else: ?>
|
|
<div class="alert alert-warning">Brak produktów w pp_contacts_maps_products.</div>
|
|
<?php endif; ?>
|
|
</div>
|
|
|
|
<!-- TAB 4: Ustawienia -->
|
|
<div>
|
|
<?= \Html::input_switch([
|
|
'label' => 'Aktywny',
|
|
'name' => 'is_active',
|
|
'checked' => (!isset($item['is_active']) || (int)$item['is_active'] === 1) ? true : false
|
|
]);?>
|
|
|
|
<?= \Html::input([
|
|
'label' => 'Sortowanie',
|
|
'name' => 'sort',
|
|
'id' => 'sort',
|
|
'value' => (int)($item['sort'] ?? 0),
|
|
]);?>
|
|
</div>
|
|
|
|
<script type="text/javascript">
|
|
$( function() {
|
|
$( '#address, #opening_hours' ).ckeditor( {
|
|
toolbar : 'MyTool',
|
|
height:'200',
|
|
});
|
|
});
|
|
</script>
|
|
</div>
|
|
</div>
|
|
|
|
<?php
|
|
$out = ob_get_clean();
|
|
|
|
$grid = new \gridEdit;
|
|
$grid -> id = 'contacts-maps-edit';
|
|
$grid -> gdb_opt = $gdb;
|
|
$grid -> include_plugins = true;
|
|
$grid -> title = 'Edycja autora';
|
|
$grid -> title = $id ? 'Edycja salonu' : 'Dodaj salon';
|
|
|
|
$grid->fields = [
|
|
[
|
|
'db' => 'id',
|
|
'type' => 'hidden',
|
|
'value' => $this->item['id']
|
|
]
|
|
];
|
|
|
|
$grid -> external_code = $out;
|
|
$grid -> actions = [
|
|
'save' => [ 'url' => '/admin/contacts_maps/save/', 'back_url' => '/admin/contacts_maps/view_list/' ],
|
|
'cancel' => [ 'url' => '/admin/contacts_maps/view_list/' ]
|
|
];
|
|
|
|
$grid -> persist_edit = true;
|
|
$grid -> id_param = 'id';
|
|
echo $grid -> draw();
|
|
?>
|
|
<script type="text/javascript">
|
|
$(function ()
|
|
{
|
|
disable_menu();
|
|
|
|
$( '#settings-tabs' ).easyResponsiveTabs({
|
|
width: 'auto',
|
|
fit: true,
|
|
tabidentify: 'settings-tabs',
|
|
type: 'vertical'
|
|
});
|
|
|
|
$('#languages-main').easyResponsiveTabs({
|
|
width: 'auto',
|
|
fit: true,
|
|
tabidentify: 'languages-main'
|
|
});
|
|
|
|
});
|
|
</script>
|
|
<script>CKEDITOR.dtd.$removeEmpty['span'] = false;</script>
|