Initial import
This commit is contained in:
@@ -0,0 +1,105 @@
|
||||
<?php
|
||||
|
||||
use app\models\Categories;
|
||||
use app\models\History;
|
||||
use app\models\Partner;
|
||||
use app\services\Auth;
|
||||
use app\widgets\FormWidget;
|
||||
use app\widgets\services\Includes;
|
||||
use app\widgets\TableWidget;
|
||||
|
||||
$model = Categories::getModel();
|
||||
$tab = $_GET['tab'] ?? 'main';
|
||||
|
||||
|
||||
TableWidget::widget([
|
||||
'top' => [
|
||||
'title' => 'Категории',
|
||||
'data' => [
|
||||
'index/dashboard' => 'Начало'
|
||||
]
|
||||
],
|
||||
'actions' => [
|
||||
'new' => 'Нова категория',
|
||||
'edit' => 'Редакция на категория',
|
||||
'delete' => 'Изтриване на категория'
|
||||
],
|
||||
'th' => [
|
||||
'№' => 'c0 text-right',
|
||||
'Наименование на категория (bg)' => '',
|
||||
'Наименование на категория (en)' => '',
|
||||
],
|
||||
'data' => Categories::find()->where(['IS', 'parent_id', NULL])->orderBy(['id' => SORT_DESC])->loop([
|
||||
'id',
|
||||
function (Categories $model) {
|
||||
return '<a href="' . Yii::$app->setQueryString(['o' => 'w', 'id' => $model->id]) . '">' . $model->name . '</a>';
|
||||
},
|
||||
function (Categories $model) {
|
||||
return '<a href="' . Yii::$app->setQueryString(['o' => 'w', 'id' => $model->id]) . '">' . $model->ts_en_name . '</a>';
|
||||
},
|
||||
], $_GET['p'] ?? 1, 30)
|
||||
]);
|
||||
|
||||
FormWidget::widget([
|
||||
'top' => [
|
||||
'title' => 'Нова категория',
|
||||
'title_edit' => 'Редакция на категория',
|
||||
'data' => [
|
||||
'index/dashboard' => 'Начало',
|
||||
'nomenclature/categories' => 'Номенклатури - Категории'
|
||||
],
|
||||
],
|
||||
'tabs' => $tabs ?? [],
|
||||
'writeView' => empty($_GET['id']) && empty($_GET['type']) ? "nomenclature/tabs/main/categories_w" : "nomenclature/tabs/" . Includes::tab($tab) . "/categories_w",
|
||||
'model' => Categories::class,
|
||||
'validation' => function ($p) use ($tab) {
|
||||
if ($tab == 'main') {
|
||||
if (empty($p->{'name'}))
|
||||
return ["name" => 'Моля, въведете наименование на категорията'];
|
||||
if (empty($p->{'ts_en_name'}))
|
||||
return ["ts_en_name" => 'Моля, въведете наименование на категорията на английски'];
|
||||
|
||||
if (isset($p->{'sub'})) {
|
||||
foreach ($p->{'sub'} as $indexId => $value) {
|
||||
if (empty($p->{'sub'}{$indexId}{'name'}))
|
||||
return ["sub[$indexId][name]" => 'Моля, въведете наименование на подкатегорията'];
|
||||
if (empty($p->{'sub'}{$indexId}{'ts_en_name'}))
|
||||
return ["sub[$indexId][ts_en_name]" => 'Моля, въведете наименование на подкатегорията'];
|
||||
}
|
||||
}
|
||||
}
|
||||
return null;
|
||||
},
|
||||
'postService' => function ($p, Categories $model) {
|
||||
$model->setPostDataToModel();
|
||||
$model->save();
|
||||
if (!empty($p->{'sub'})) {
|
||||
$orderIndex = 0;
|
||||
if ($model->id) {
|
||||
$last = Categories::find()->where(['parent_id' => $model->id])->orderBy(['order_index' => SORT_DESC])->one();
|
||||
if ($last)
|
||||
$orderIndex = $last->order_index;
|
||||
}
|
||||
|
||||
foreach ($p->{'sub'} as $id => $name) {
|
||||
$catToUpdate = empty($_GET['id']) ? new Categories() : Categories::findOne($id);
|
||||
if ($catToUpdate) {
|
||||
$catToUpdate->name = $name['name'];
|
||||
$catToUpdate->ts_en_name = $name['ts_en_name'];
|
||||
$catToUpdate->parent_id = $model->id;
|
||||
if (empty($catToUpdate->id))
|
||||
$catToUpdate->order_index = $orderIndex;
|
||||
$catToUpdate->save();
|
||||
if (empty($name['object_types_list'])) {
|
||||
$catToUpdate->updateObjectTypes([]);
|
||||
} else {
|
||||
$catToUpdate->updateObjectTypes($name['object_types_list']);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
History::addNew($model->id, 'categories', Auth::userAdminGlobal()->getFullName() . ' - Глобален администратор', !empty($_GET['id']));
|
||||
Yii::$app->flash('success', isset($_GET['id']) ? 'Категорията е актуализирана успешно' : 'Категорията е създадена успешно');
|
||||
$model->smartRedirect();
|
||||
}
|
||||
]);
|
||||
@@ -0,0 +1,110 @@
|
||||
<?php
|
||||
|
||||
use app\models\Collections;
|
||||
use app\models\History;
|
||||
use app\services\Auth;
|
||||
use app\services\Formatter;
|
||||
use app\widgets\FormWidget;
|
||||
use app\widgets\services\Includes;
|
||||
use app\widgets\TableWidget;
|
||||
|
||||
$model = Collections::getModel();
|
||||
$tab = $_GET['tab'] ?? 'main';
|
||||
|
||||
$tabs = [
|
||||
'main' => '<i class="la la-database"></i> Основни данни',
|
||||
'ts_en' => '<i class="lg lg-en"></i> Превод английски',
|
||||
'media' => '<i class="la la-file-movie-o"></i> Медия файлове'
|
||||
];
|
||||
|
||||
|
||||
TableWidget::widget([
|
||||
'top' => [
|
||||
'title' => 'Колекции на обекти',
|
||||
'data' => [
|
||||
'index/dashboard' => 'Начало'
|
||||
]
|
||||
],
|
||||
'actions' => [
|
||||
'new' => 'Нова колекция',
|
||||
'edit' => 'Редакция на колекция',
|
||||
'delete' => 'Изтриване на колекция'
|
||||
],
|
||||
'th' => [
|
||||
'№' => 'c0 text-right',
|
||||
'Име на колекция' => '',
|
||||
'История' => 'c1 ct',
|
||||
'Добавена в избрани' => 'c1 ct',
|
||||
'Публикувана' => 'c1 ct',
|
||||
'Дата на публикуване' => 'c1 ct',
|
||||
],
|
||||
'data' => Collections::find()->where([])->orderBy(['id' => SORT_DESC])->loop([
|
||||
'id',
|
||||
function (Collections $model) {
|
||||
return '<a href="' . Yii::$app->setQueryString(['o' => 'w', 'id' => $model->id]) . '">' . $model->name . '</a>';
|
||||
},
|
||||
|
||||
function (Collections $model) {
|
||||
return '<i data-table="collections" data-id="' . $model->id . '" class="la la-history historyButton"></i>';
|
||||
},
|
||||
function (Collections $model) {
|
||||
return $model->statusSwitch('is_selected', null, ['Колекцията е добавена в избрани', 'Колекцията е махната от избрани']);
|
||||
},
|
||||
function (Collections $model) {
|
||||
return $model->statusSwitch('is_active', null, ['Колекцията е видима на сайта', 'Колекцията е свалена от сайта']);
|
||||
},
|
||||
function (Collections $model) {
|
||||
if ($model->publish_date)
|
||||
return Formatter::date($model->publish_date);
|
||||
},
|
||||
], $_GET['p'] ?? 1, 30)
|
||||
]);
|
||||
|
||||
FormWidget::widget([
|
||||
'top' => [
|
||||
'title' => 'Нова колекция',
|
||||
'title_edit' => 'Редакция на колекция',
|
||||
'data' => [
|
||||
'index/dashboard' => 'Начало',
|
||||
'nomenclature/collections' => 'Колекции на обекти'
|
||||
],
|
||||
],
|
||||
'tabs' => $tabs ?? [],
|
||||
'writeView' => "nomenclature/tabs/" . Includes::tab($tab) . "/collections_w",
|
||||
'model' => Collections::class,
|
||||
'validation' => function ($p) use ($tab) {
|
||||
if ($tab == 'main') {
|
||||
if (empty($p->{'name'}))
|
||||
return ["name" => 'Моля, въведете име на колекцията'];
|
||||
if (empty($p->{'ts_en_name'}))
|
||||
return ["ts_en_name" => 'Моля, въведете име на колекцията на английски'];
|
||||
if (empty($p->{'annotation'}))
|
||||
return ["annotation" => 'Моля, въведете анотация на колекцията'];
|
||||
if (empty($p->{'description'}))
|
||||
return ["description" => 'Моля, въведете описание на колекцията'];
|
||||
if (empty($p->{'partner_id'}))
|
||||
return ["partner_id" => 'Моля, изберете партноьор, който представя колекцията'];
|
||||
if (empty($p->{'info_center'}))
|
||||
return ["info_center" => 'Моля, попълнете име на информационен център'];
|
||||
if (empty($p->{'info_center_address'}))
|
||||
return ["info_center_address" => 'Моля, попълнете адрес на информационен център'];
|
||||
} else if (Includes::inLocales($tab)) {
|
||||
if (empty($p->{$tab . '_annotation'}))
|
||||
return [$tab . "_annotation" => 'Моля, въведете анотация на колекцията'];
|
||||
if (empty($p->{$tab . '_description'}))
|
||||
return [$tab . "_description" => 'Моля, въведете описание на колекцията'];
|
||||
if (empty($p->{$tab . '_info_center'}))
|
||||
return [$tab . "_info_center" => 'Моля, попълнете име на информационен център'];
|
||||
if (empty($p->{$tab . '_info_center_address'}))
|
||||
return [$tab . "_info_center_address" => 'Моля, попълнете адрес на информационен център'];
|
||||
}
|
||||
return null;
|
||||
},
|
||||
'postService' => function ($p, Collections $model) {
|
||||
$model->setPostDataToModel();
|
||||
$model->save();
|
||||
History::addNew($model->id, 'collections', Auth::userAdminGlobal()->getFullName() . ' - Глобален администратор', !empty($_GET['id']));
|
||||
Yii::$app->flash('success', isset($_GET['id']) ? 'Колекцията е актуализирана успешно' : 'Колекцията е създадена успешно');
|
||||
$model->smartRedirect();
|
||||
}
|
||||
]);
|
||||
@@ -0,0 +1,101 @@
|
||||
<?php
|
||||
|
||||
use app\models\Categories;
|
||||
use app\models\CommonFields;
|
||||
use app\models\History;
|
||||
use app\services\Auth;
|
||||
use app\widgets\FormWidget;
|
||||
use app\widgets\services\Includes;
|
||||
use app\widgets\TableWidget;
|
||||
|
||||
$model = CommonFields::getModel();
|
||||
$tab = $_GET['tab'] ?? 'main';
|
||||
|
||||
|
||||
TableWidget::widget([
|
||||
'top' => [
|
||||
'title' => 'Общи номенклатури',
|
||||
'data' => [
|
||||
'index/dashboard' => 'Начало',
|
||||
'nomenclature/categories' => 'Номенклатури',
|
||||
]
|
||||
],
|
||||
'actions' => [
|
||||
'new' => 'Ново поле',
|
||||
'edit' => 'Редакция на поле',
|
||||
'delete' => 'Изтриване на поле'
|
||||
],
|
||||
'th' => [
|
||||
'№' => 'c0 text-right',
|
||||
'Име на поле (bg)' => '',
|
||||
'Множествено избиране' => 'c1 ct',
|
||||
],
|
||||
'data' => CommonFields::find()->where(['IS', 'parent_id', NULL])->orderBy(['id' => SORT_DESC])->loop([
|
||||
'id',
|
||||
function (CommonFields $model) {
|
||||
return '<a href="' . Yii::$app->setQueryString(['o' => 'w', 'id' => $model->id]) . '">' . $model->name . '</a>';
|
||||
},
|
||||
function (CommonFields $model) {
|
||||
return $model->statusSwitch('multiple_filters', null, ['Добавена е възможност за многежествено избиране при филтриране', 'Премахната е възможност за многежествено избиране при филтриране']);
|
||||
},
|
||||
], $_GET['p'] ?? 1, 30)
|
||||
]);
|
||||
|
||||
FormWidget::widget([
|
||||
'top' => [
|
||||
'title' => 'Ново поле',
|
||||
'title_edit' => 'Редакция на поле',
|
||||
'data' => [
|
||||
'index/dashboard' => 'Начало',
|
||||
'nomenclature/categories' => 'Номенклатури',
|
||||
'nomenclature/common-fields' => 'Общи номенклатури',
|
||||
],
|
||||
],
|
||||
'tabs' => $tabs ?? [],
|
||||
'writeView' => empty($_GET['id']) && empty($_GET['type']) ? "nomenclature/tabs/main/common_fields_w" : "nomenclature/tabs/" . Includes::tab($tab) . "/common_fields_w",
|
||||
'model' => CommonFields::class,
|
||||
'validation' => function ($p) use ($tab) {
|
||||
if ($tab == 'main') {
|
||||
if (empty($p->{'name'}))
|
||||
return ["name" => 'Моля, въведете име на полето'];
|
||||
if (empty($p->{'ts_en_name'}))
|
||||
return ["ts_en_name" => 'Моля, въведете име на полето'];
|
||||
|
||||
if (isset($p->{'sub'})) {
|
||||
foreach ($p->{'sub'} as $indexId => $value) {
|
||||
if (empty($p->{'sub'}{$indexId}{'name'}))
|
||||
return ["sub[$indexId][name]" => 'Моля, въведете име на полето'];
|
||||
if (empty($p->{'sub'}{$indexId}{'ts_en_name'}))
|
||||
return ["sub[$indexId][ts_en_name]" => 'Моля, въведете име на полето'];
|
||||
}
|
||||
}
|
||||
}
|
||||
return null;
|
||||
},
|
||||
'postService' => function ($p, CommonFields $model) {
|
||||
$model->setPostDataToModel();
|
||||
$model->save();
|
||||
if (!empty($p->{'sub'})) {
|
||||
$orderIndex = 0;
|
||||
if ($model->id) {
|
||||
$last = CommonFields::find()->where(['parent_id' => $model->id])->orderBy(['order_index' => SORT_DESC])->one();
|
||||
if ($last)
|
||||
$orderIndex = $last->order_index;
|
||||
}
|
||||
foreach ($p->{'sub'} as $id => $name) {
|
||||
$catToUpdate = empty($_GET['id']) ? new CommonFields() : CommonFields::findOne($id);
|
||||
if ($catToUpdate) {
|
||||
$catToUpdate->name = $name['name'];
|
||||
$catToUpdate->ts_en_name = $name['ts_en_name'];
|
||||
$catToUpdate->parent_id = $model->id;
|
||||
if (empty($catToUpdate->id))
|
||||
$catToUpdate->order_index = $orderIndex;
|
||||
$catToUpdate->save();
|
||||
}
|
||||
}
|
||||
}
|
||||
History::addNew($model->id, 'common-fields', Auth::userAdminGlobal()->getFullName() . ' - Глобален администратор', !empty($_GET['id']));
|
||||
Yii::$app->flash('success', isset($_GET['id']) ? 'Номенклатурата е актуализирана успешно' : 'Номенклатурата е създадена успешно');
|
||||
$model->smartRedirect();
|
||||
}
|
||||
]);
|
||||
@@ -0,0 +1,147 @@
|
||||
<?php
|
||||
|
||||
use app\models\History;
|
||||
use app\models\ObjectTemplate;
|
||||
use app\models\ObjectTemplateField;
|
||||
use app\services\Auth;
|
||||
use app\widgets\FormWidget;
|
||||
use app\widgets\services\Includes;
|
||||
use app\widgets\TableWidget;
|
||||
|
||||
$model = ObjectTemplate::getModel();
|
||||
$tab = $_GET['tab'] ?? 'main';
|
||||
TableWidget::widget([
|
||||
'filter' => [
|
||||
[
|
||||
'heritage_type' => ['Вид наследсво', 'c3', ObjectTemplate::heritageTypes()],
|
||||
'name' => ['Наименование', 'c2'],
|
||||
],
|
||||
],
|
||||
'top' => [
|
||||
'title' => 'Видове обекти',
|
||||
'data' => [
|
||||
'index/dashboard' => 'Начало',
|
||||
'nomenclature/categories' => 'Номенклатури',
|
||||
]
|
||||
],
|
||||
'actions' => [
|
||||
'new' => 'Нов вид обект',
|
||||
'edit' => 'Редакция на вид обект',
|
||||
'delete' => 'Изтриване на вид обект'
|
||||
],
|
||||
'th' => [
|
||||
'№' => 'c0 text-right',
|
||||
'Наименование на вид обект' => '',
|
||||
'Вид наследсво' => '',
|
||||
'Категории' => '',
|
||||
'Полета' => ''
|
||||
],
|
||||
'data' => ObjectTemplate::find()->andWhere(Yii::$app->getFilterData('or'))->orderBy(['id' => SORT_DESC])->loop([
|
||||
'id',
|
||||
function (ObjectTemplate $model) {
|
||||
return '<a href="' . Yii::$app->setQueryString(['o' => 'w', 'id' => $model->id]) . '">' . $model->name . '</a>';
|
||||
},
|
||||
function (ObjectTemplate $model) {
|
||||
if ($model->heritage_type)
|
||||
return ObjectTemplate::heritageTypes($model->heritage_type);
|
||||
},
|
||||
function (ObjectTemplate $model) {
|
||||
return $model->categoryConcatList;
|
||||
},
|
||||
function (ObjectTemplate $model) {
|
||||
if (!empty($model->objectTemplateFields)) {
|
||||
$objectTemplateFields = [];
|
||||
foreach ($model->objectTemplateFields as $objectTemplateField)
|
||||
$objectTemplateFields[] = '<span style="margin: 1px !important; display: inline-block; font-size: 11px; background: var(--base-background-dark); color: #fff; padding: 2px 3px; border-radius: 4px">' . $objectTemplateField->name . '</span>';
|
||||
return implode(' ', $objectTemplateFields);
|
||||
}
|
||||
}
|
||||
], $_GET['p'] ?? 1, 30)
|
||||
]);
|
||||
|
||||
|
||||
FormWidget::widget([
|
||||
'top' => [
|
||||
'title' => 'Нов вид обект',
|
||||
'title_edit' => 'Редакция на вид обект',
|
||||
'data' => [
|
||||
'index/dashboard' => 'Начало',
|
||||
'nomenclature/categories' => 'Номенклатури',
|
||||
'nomenclature/object-templates' => 'Видове обекти'
|
||||
],
|
||||
],
|
||||
'tabs' => $tabs ?? [],
|
||||
'writeView' => empty($_GET['id']) && empty($_GET['type']) ? "nomenclature/tabs/main/object_templates_w" : "nomenclature/tabs/" . Includes::tab($tab) . "/object_templates_w",
|
||||
'model' => ObjectTemplate::class,
|
||||
'validation' => function ($p) use ($tab) {
|
||||
if ($tab == 'main') {
|
||||
if (empty($p->{'name'}))
|
||||
return ["name" => 'Моля, въведете наименованието на вида обект'];
|
||||
if (empty($p->{'ts_en_name'}))
|
||||
return ["ts_en_name" => 'Моля, въведете наименованието на вида обект на английски'];
|
||||
|
||||
if (empty($p->{'heritage_type'}))
|
||||
return ["heritage_type" => 'Моля, изберете вид наследство'];
|
||||
|
||||
if (ObjectTemplate::exists(['name' => $p->{'name'}]))
|
||||
return ["name" => 'Обект с това наименование вече съществува'];
|
||||
|
||||
if (ObjectTemplate::exists(['ts_en_name' => $p->{'ts_en_name'}]))
|
||||
return ["ts_en_name" => 'Обект с това наименование вече съществува'];
|
||||
|
||||
if (isset($p->{'sub'})) {
|
||||
foreach ($p->{'sub'} as $indexId => $value) {
|
||||
if (empty($p->{'sub'}{$indexId}{'name'}))
|
||||
return ["sub[$indexId][name]" => 'Моля, въведете наименование на полето'];
|
||||
if (empty($p->{'sub'}{$indexId}{'ts_en_name'}))
|
||||
return ["sub[$indexId][ts_en_name]" => 'Моля, въведете наименование на полето'];
|
||||
if (empty($p->{'sub'}{$indexId}{'user_interface_type'}))
|
||||
return ["sub[$indexId][user_interface_type]" => 'Моля, изберете тип на стойността'];
|
||||
}
|
||||
}
|
||||
}
|
||||
return null;
|
||||
},
|
||||
'postService' => function ($p, ObjectTemplate $model) {
|
||||
|
||||
$model->setPostDataToModel();
|
||||
$model->save();
|
||||
if (!empty($p->{'sub'})) {
|
||||
foreach ($p->{'sub'} as $id => $name) {
|
||||
$objectTemplateField = empty($_GET['id']) ? new ObjectTemplateField() : ObjectTemplateField::findOne($id);
|
||||
$objectTemplateField->ot_id = $model->id;
|
||||
$objectTemplateField->name = $name['name'];
|
||||
$objectTemplateField->ts_en_name = $name['ts_en_name'];
|
||||
$objectTemplateField->is_filter = empty($name['is_filter']) ? null : 1;
|
||||
$objectTemplateField->user_interface_type = $name['user_interface_type'];
|
||||
$userInterfaceTypeId = (int)$name['user_interface_type'];
|
||||
if ($userInterfaceTypeId != 0) {
|
||||
$objectTemplateField->common_field_id = $name['user_interface_type'];
|
||||
} else {
|
||||
$objectTemplateField->common_field_id = null;
|
||||
}
|
||||
//$objectTemplateField->data_type = $name['data_type'];
|
||||
if (empty($_GET['id']))
|
||||
$objectTemplateField->order_index = ObjectTemplateField::getNextOrderIndex($model->id);
|
||||
$objectTemplateField->save();
|
||||
if (empty($_GET['id']) && !empty($name['select_data'])) {
|
||||
foreach (json_decode($name['select_data']) as $stdObject) {
|
||||
$objectTemplateFieldOption = new ObjectTemplateField();
|
||||
if (isset($stdObject->{'bg'}))
|
||||
$objectTemplateFieldOption->name = $stdObject->{'bg'};
|
||||
if (isset($stdObject->{'en'}))
|
||||
$objectTemplateFieldOption->ts_en_name = $stdObject->{'en'};
|
||||
if ($objectTemplateFieldOption->name) {
|
||||
$objectTemplateFieldOption->parent_id = $objectTemplateField->id;
|
||||
$objectTemplateFieldOption->save();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
History::addNew($model->id, 'object_template', Auth::userAdminGlobal()->getFullName() . ' - Глобален администратор', !empty($_GET['id']));
|
||||
Yii::$app->flash('success', isset($_GET['id']) ? 'Вида обект е актуализирана успешно' : 'Вида обект е създадена успешно');
|
||||
$model->smartRedirect();
|
||||
}
|
||||
]);
|
||||
@@ -0,0 +1,282 @@
|
||||
<?php
|
||||
|
||||
use app\models\Categories;
|
||||
use app\models\CategoriesOt;
|
||||
use app\widgets\services\Includes;
|
||||
|
||||
/**
|
||||
* @var Categories $model
|
||||
*/
|
||||
$media_key = $model->getMediaKey();
|
||||
$min = 1;
|
||||
$max = 30;
|
||||
?>
|
||||
<div class="inner-content p10">
|
||||
<form autocomplete="off">
|
||||
<div class="flex top15 c8">
|
||||
<div class="row c6 right10">
|
||||
<label class="require">Наименование на категория (BG)</label>
|
||||
<input name="name" placeholder="Въведи наименование на основна категория"
|
||||
value="<?= $model->name ?>"/>
|
||||
</div>
|
||||
<div class="row c6">
|
||||
<label class="require">Наименование на категория (EN)</label>
|
||||
<input name="ts_en_name" placeholder="Въведи наименование на основна категория"
|
||||
value="<?= $model->ts_en_name ?>"/>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
||||
<div class="row c5 top15">
|
||||
<?php if ($model->id): ?>
|
||||
<div onclick="addSubCategory(this)" data-id="<?= $model->id ?>"
|
||||
class="btn-ib btn-default">
|
||||
<i class="la la-plus-circle"></i> Добавяне на подкатегория
|
||||
</div>
|
||||
<?php else: ?>
|
||||
<div onclick="addNewSubcategory()"
|
||||
class="btn-ib btn-default">
|
||||
<i class="la la-plus-circle"></i> Добавяне на подкатегория
|
||||
</div>
|
||||
<?php endif; ?>
|
||||
<div id="bDelete" data-model="app\models\Categories" onclick="checkDelete(this)"
|
||||
class="btn-ib btn-default ct disabled">
|
||||
<i class="la la-trash-o"></i> Изтриване на подкатегории <span id="delCount">(0)</span>
|
||||
</div>
|
||||
</div>
|
||||
<div class="c12 top15">
|
||||
<table class="cms-table">
|
||||
<thead>
|
||||
<tr>
|
||||
<th class="text-right">
|
||||
<input id="checkAll" onclick="checkAllCategories(this)" title="Избери всички"
|
||||
class="delete-checkbox" type="checkbox">
|
||||
No
|
||||
</th>
|
||||
<th>Подкатегория (BG)</th>
|
||||
<th>Подкатегория (EN)</th>
|
||||
<th class="c4">Видове обекти</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody id="sub-categories">
|
||||
<?php
|
||||
foreach ($model->subCategories as $i => $subCategory): ?>
|
||||
<tr class="sub-categories" draggable="true" data-index="<?= $subCategory->order_index ?>">
|
||||
<td class="text-right c1" style="width: 50px">
|
||||
<input onclick="checkSingle(this)" data-del="<?= $subCategory->id ?>"
|
||||
class="delete-checkbox"
|
||||
type="checkbox"
|
||||
style="top: calc(50% - 10px)">
|
||||
<span class="sub-number"><?= $i + 1 ?></span>
|
||||
</td>
|
||||
<td>
|
||||
<input type="text" name="sub[<?= $subCategory->id ?>][name]"
|
||||
value="<?= $subCategory->name ?>">
|
||||
</td>
|
||||
<td>
|
||||
<input type="text" name="sub[<?= $subCategory->id ?>][ts_en_name]"
|
||||
value="<?= $subCategory->ts_en_name ?>">
|
||||
</td>
|
||||
<td>
|
||||
<select style="display:none;" class="search-select-box" multiple
|
||||
name="sub[<?= $subCategory->id ?>][object_types_list][]">
|
||||
<option disabled value="">-- избери видове обекти --</option>
|
||||
<?php foreach ($subCategory->getObjectTemplateList() as $item): ?>
|
||||
<option <?= $item['selected'] ?>
|
||||
value="<?= $item['id'] ?>"><?= $item['name'] ?></option>
|
||||
<?php endforeach; ?>
|
||||
</select>
|
||||
</td>
|
||||
</tr>
|
||||
<?php endforeach; ?>
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
<div class="row c9 top15 flex">
|
||||
<?= Includes::formButtons('nomenclature/categories') ?>
|
||||
</div>
|
||||
</form>
|
||||
</div>
|
||||
<script src="/_public/assets/js/order.js"></script>
|
||||
<script src="/_public/assets/js/search-box.js"></script>
|
||||
<script>
|
||||
|
||||
var objectTypes = '';
|
||||
|
||||
try {
|
||||
objectTypes = '<?= json_encode(CategoriesOt::getObjectTemplateList(true)) ?>'
|
||||
} catch (e) {
|
||||
console.log(e);
|
||||
}
|
||||
|
||||
all('.search-select-box').forEach(el => {
|
||||
new SearchBox(el)
|
||||
})
|
||||
|
||||
orderItems('.sub-categories', '/update-category-indexes/', function () {
|
||||
var index = 0
|
||||
all('.sub-categories .sub-number').forEach(e => {
|
||||
e.innerText = ++index
|
||||
console.log(e.innerText)
|
||||
})
|
||||
});
|
||||
|
||||
function validateNumber(e, min, max) {
|
||||
if (e.value !== '') {
|
||||
if (e.value < min)
|
||||
e.value = min;
|
||||
if (e.value > max)
|
||||
e.value = max;
|
||||
}
|
||||
}
|
||||
|
||||
let sl = [];
|
||||
|
||||
function checkAllCategories(el) {
|
||||
sl = [];
|
||||
all('td [data-del]').forEach(e => {
|
||||
e.checked = el.checked === true;
|
||||
if (el.checked) {
|
||||
sl.push(e.dataset.del);
|
||||
e.parentNode.parentNode.addClass('checked');
|
||||
} else {
|
||||
e.parentNode.parentNode.removeClass('checked');
|
||||
}
|
||||
|
||||
})
|
||||
updateActionButtons();
|
||||
}
|
||||
|
||||
function checkSingle(e) {
|
||||
if (e.checked) {
|
||||
sl.push(e.dataset.del);
|
||||
e.parentNode.parentNode.addClass('checked');
|
||||
} else {
|
||||
one('#checkAll').checked = false;
|
||||
e.parentNode.parentNode.removeClass('checked');
|
||||
const f = sl.indexOf(e.dataset.del);
|
||||
sl.splice(f, 1);
|
||||
}
|
||||
updateActionButtons(e.dataset.del);
|
||||
}
|
||||
|
||||
function updateActionButtons() {
|
||||
const bDelete = one('#bDelete');
|
||||
const delCount = one('#delCount');
|
||||
const c = sl.length;
|
||||
if (delCount)
|
||||
delCount.innerText = '(' + c + ')';
|
||||
if (c > 0) {
|
||||
if (bDelete)
|
||||
bDelete.removeClass('disabled');
|
||||
} else {
|
||||
if (bDelete)
|
||||
bDelete.addClass('disabled');
|
||||
}
|
||||
}
|
||||
|
||||
function checkDelete(e) {
|
||||
const msg = 'Сигурни ли сте, че искате да изтриете ' + (sl.length > 1 ? 'тези ' + sl.length + ' записа?' : 'този запис?');
|
||||
modal.confirm(msg, () => {
|
||||
console.log(sl)
|
||||
all('tbody .delete-checkbox:checked').forEach(e => {
|
||||
e.parentNode.parentNode.remove();
|
||||
})
|
||||
|
||||
all('tbody .delete-checkbox').forEach((e, i) => {
|
||||
const number = e.parentNode.querySelector('span');
|
||||
number.innerHTML = (i + 1).toString()
|
||||
})
|
||||
const slValues = [];
|
||||
sl.forEach(v => {
|
||||
if (v) {
|
||||
slValues.push(v);
|
||||
}
|
||||
})
|
||||
if (slValues.length > 0) {
|
||||
request({
|
||||
url: window.location.href.split('?')[0] + '?o=d',
|
||||
post: {
|
||||
ids: JSON.stringify(sl),
|
||||
model: e.dataset.model
|
||||
},
|
||||
done: e => {
|
||||
window.location.reload();
|
||||
}
|
||||
})
|
||||
}
|
||||
sl = [];
|
||||
});
|
||||
}
|
||||
|
||||
function addSubCategory(e) {
|
||||
request({
|
||||
url: '/new-sub-category/',
|
||||
post: {
|
||||
parent_id: e.dataset.id
|
||||
},
|
||||
done: e => {
|
||||
//window.location.reload();
|
||||
if (e.id && e.success === true) {
|
||||
addNewSubcategory(e.id, e.orderIndex);
|
||||
flash.success(e.msg, true)
|
||||
}
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
function addNewSubcategory(id, orderIndex) {
|
||||
console.log(id, orderIndex);
|
||||
const tBody = one('#sub-categories');
|
||||
const tCount = tBody.querySelectorAll('tr').length
|
||||
const indexId = id ? id : 'index_' + (tCount + 1)
|
||||
const tr = document.createElement('tr')
|
||||
tr.className = 'sub-categories'
|
||||
tr.setAttribute('draggable', true)
|
||||
tr.setAttribute('data-index', orderIndex)
|
||||
console.log(tr)
|
||||
|
||||
tr.innerHTML = `
|
||||
<td class="text-right c1" style="width: 50px">
|
||||
<input onclick="checkSingle(this)"
|
||||
class="delete-checkbox"
|
||||
type="checkbox"
|
||||
data-del="${id}"
|
||||
style="top: calc(50% - 10px)">
|
||||
<span class="sub-number">${tCount + 1}</span>
|
||||
</td>
|
||||
<td>
|
||||
<input style="width: calc(100% - 20px); margin-left: 5px; height: 20px; padding: 5px"
|
||||
name="sub[${indexId}][name]"
|
||||
value="">
|
||||
</td>
|
||||
<td>
|
||||
<input style="width: calc(100% - 20px); margin-left: 5px; height: 20px; padding: 5px"
|
||||
name="sub[${indexId}][ts_en_name]"
|
||||
value="">
|
||||
</td>
|
||||
<td>
|
||||
<select style="display:none;" class="search-select-box" multiple name="sub[${indexId}][object_types_list][]">
|
||||
<option disabled value="">-- избери видове обекти --</option>
|
||||
${objectTypes}
|
||||
</select>
|
||||
</td>
|
||||
`
|
||||
|
||||
//console.log(tr);
|
||||
|
||||
tBody.appendChild(tr);
|
||||
new SearchBox(tr.querySelector('select'))
|
||||
orderItem(tr, function () {
|
||||
var index = 0
|
||||
all('.sub-categories .sub-number').forEach(e => {
|
||||
e.innerText = ++index
|
||||
console.log(e.innerText)
|
||||
})
|
||||
})
|
||||
|
||||
|
||||
}
|
||||
|
||||
</script>
|
||||
|
||||
@@ -0,0 +1,56 @@
|
||||
<?php
|
||||
use app\models\Collections;
|
||||
use app\models\Partner;
|
||||
use app\widgets\services\Includes;
|
||||
|
||||
/**
|
||||
* @var Collections $model
|
||||
*/
|
||||
|
||||
?>
|
||||
<div class="inner-content p10">
|
||||
<form autocomplete="off">
|
||||
<div class="flex top15 c9">
|
||||
<div class="row c6 right10">
|
||||
<label class="require">Наименование на колекция (BG)</label>
|
||||
<input name="name" placeholder="Въведи наименование на колекция"
|
||||
value="<?= $model->name ?>"/>
|
||||
</div>
|
||||
<div class="row c6">
|
||||
<label class="require">Наименование на колекция (EN)</label>
|
||||
<input name="ts_en_name" placeholder="Въведи наименование на колекция"
|
||||
value="<?= $model->ts_en_name ?>"/>
|
||||
</div>
|
||||
</div>
|
||||
<div class="row c9 top15">
|
||||
<label class="require">Анотация</label>
|
||||
<textarea class="ckEditor" name="annotation"><?= $model->{'annotation'} ?></textarea>
|
||||
</div>
|
||||
<div class="row c9 top15">
|
||||
<label class="require">Описание</label>
|
||||
<textarea class="ckEditor" name="description"><?= $model->{'description'} ?></textarea>
|
||||
</div>
|
||||
<div class="row c9 top15">
|
||||
<label class="require">Партньор</label>
|
||||
<select name="partner_id">
|
||||
<option selected disabled value="">-- Изберете партньор--</option>
|
||||
<?php foreach (Partner::partnerList() as $id => $name): ?>
|
||||
<option <?= $model->partner_id == $id ? 'selected': ''?> value="<?= $id ?>"><?= $name ?></option>
|
||||
<?php endforeach; ?>
|
||||
</select>
|
||||
</div>
|
||||
<div class="row c9 top15">
|
||||
<label class="require">Информационен център</label>
|
||||
<input name="info_center" placeholder="Въведи наименование на информационен център"
|
||||
value="<?= $model->info_center ?>"/>
|
||||
</div>
|
||||
<div class="row c9 top15">
|
||||
<label class="require">Информационен център адрес</label>
|
||||
<input name="info_center_address" placeholder="Въведи адрес на информационен център"
|
||||
value="<?= $model->info_center_address ?>"/>
|
||||
</div>
|
||||
<div class="row flex c9 top15">
|
||||
<?= Includes::formButtons('nomenclature/collections') ?>
|
||||
</div>
|
||||
</form>
|
||||
</div>
|
||||
+258
@@ -0,0 +1,258 @@
|
||||
<?php
|
||||
|
||||
use app\models\Categories;
|
||||
use app\models\CategoriesOt;
|
||||
use app\models\CommonFields;
|
||||
use app\widgets\services\Includes;
|
||||
|
||||
/**
|
||||
* @var CommonFields $model
|
||||
*/
|
||||
$media_key = $model->getMediaKey();
|
||||
$min = 1;
|
||||
$max = 30;
|
||||
?>
|
||||
<div class="inner-content p10">
|
||||
<form autocomplete="off">
|
||||
<div class="flex top15 c8">
|
||||
<div class="row c6 right10">
|
||||
<label class="require">Наименование на поле (BG)</label>
|
||||
<input name="name" placeholder="Въведи наименование поле"
|
||||
value="<?= $model->name ?>"/>
|
||||
</div>
|
||||
<div class="row c6">
|
||||
<label class="require">Наименование на поле (EN)</label>
|
||||
<input name="ts_en_name" placeholder="Въведи наименование на основна категория"
|
||||
value="<?= $model->ts_en_name ?>"/>
|
||||
</div>
|
||||
</div>
|
||||
<div class="row c5 top15">
|
||||
<?php if ($model->id): ?>
|
||||
<div onclick="addSubCategory(this)" data-id="<?= $model->id ?>"
|
||||
class="btn-ib btn-default">
|
||||
<i class="la la-plus-circle"></i> Добавяне на нова опция
|
||||
</div>
|
||||
<?php else: ?>
|
||||
<div onclick="addNewSubcategory()"
|
||||
class="btn-ib btn-default">
|
||||
<i class="la la-plus-circle"></i> Добавяне на нова опция
|
||||
</div>
|
||||
<?php endif; ?>
|
||||
<div id="bDelete" data-model="app\models\CommonFields" onclick="checkDelete(this)"
|
||||
class="btn-ib btn-default ct disabled">
|
||||
<i class="la la-trash-o"></i> Изтриване на опции <span id="delCount">(0)</span>
|
||||
</div>
|
||||
</div>
|
||||
<div class="c12 top15">
|
||||
<table class="cms-table">
|
||||
<thead>
|
||||
<tr>
|
||||
<th class="text-right">
|
||||
<input id="checkAll" onclick="checkAllCategories(this)" title="Избери всички"
|
||||
class="delete-checkbox" type="checkbox">
|
||||
No
|
||||
</th>
|
||||
<th>Наименование опция (BG)</th>
|
||||
<th>Наименование опция (EN)</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody id="sub-categories">
|
||||
<?php
|
||||
foreach ($model->options as $i => $subCategory): ?>
|
||||
<tr class="sub-categories" draggable="true" data-index="<?= $subCategory->order_index ?>">
|
||||
<td class="text-right c1" style="width: 50px">
|
||||
<input onclick="checkSingle(this)" data-del="<?= $subCategory->id ?>"
|
||||
class="delete-checkbox"
|
||||
type="checkbox"
|
||||
style="top: calc(50% - 10px)">
|
||||
<span class="sub-number"><?= $i + 1 ?></span>
|
||||
</td>
|
||||
<td>
|
||||
<input type="text" name="sub[<?= $subCategory->id ?>][name]"
|
||||
value="<?= $subCategory->name ?>">
|
||||
</td>
|
||||
<td>
|
||||
<input type="text" name="sub[<?= $subCategory->id ?>][ts_en_name]"
|
||||
value="<?= $subCategory->ts_en_name ?>">
|
||||
</td>
|
||||
</tr>
|
||||
<?php endforeach; ?>
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
<div class="row c9 top15 flex">
|
||||
<?= Includes::formButtons('nomenclature/common-fields') ?>
|
||||
</div>
|
||||
</form>
|
||||
</div>
|
||||
<script src="/_public/assets/js/order.js"></script>
|
||||
<script>
|
||||
|
||||
var objectTypes = '';
|
||||
|
||||
try {
|
||||
objectTypes = '<?= json_encode(CategoriesOt::getObjectTemplateList(true)) ?>'
|
||||
} catch (e) {
|
||||
console.log(e);
|
||||
}
|
||||
|
||||
all('.search-select-box').forEach(el => {
|
||||
new SearchBox(el)
|
||||
})
|
||||
|
||||
orderItems('.sub-categories', '/update-common-field-indexes/', function () {
|
||||
var index = 0
|
||||
all('.sub-categories .sub-number').forEach(e => {
|
||||
e.innerText = ++index
|
||||
console.log(e.innerText)
|
||||
})
|
||||
});
|
||||
|
||||
function validateNumber(e, min, max) {
|
||||
if (e.value !== '') {
|
||||
if (e.value < min)
|
||||
e.value = min;
|
||||
if (e.value > max)
|
||||
e.value = max;
|
||||
}
|
||||
}
|
||||
|
||||
let sl = [];
|
||||
|
||||
function checkAllCategories(el) {
|
||||
sl = [];
|
||||
all('td [data-del]').forEach(e => {
|
||||
e.checked = el.checked === true;
|
||||
if (el.checked) {
|
||||
sl.push(e.dataset.del);
|
||||
e.parentNode.parentNode.addClass('checked');
|
||||
} else {
|
||||
e.parentNode.parentNode.removeClass('checked');
|
||||
}
|
||||
|
||||
})
|
||||
updateActionButtons();
|
||||
}
|
||||
|
||||
function checkSingle(e) {
|
||||
if (e.checked) {
|
||||
sl.push(e.dataset.del);
|
||||
e.parentNode.parentNode.addClass('checked');
|
||||
} else {
|
||||
one('#checkAll').checked = false;
|
||||
e.parentNode.parentNode.removeClass('checked');
|
||||
const f = sl.indexOf(e.dataset.del);
|
||||
sl.splice(f, 1);
|
||||
}
|
||||
updateActionButtons(e.dataset.del);
|
||||
}
|
||||
|
||||
function updateActionButtons() {
|
||||
const bDelete = one('#bDelete');
|
||||
const delCount = one('#delCount');
|
||||
const c = sl.length;
|
||||
if (delCount)
|
||||
delCount.innerText = '(' + c + ')';
|
||||
if (c > 0) {
|
||||
if (bDelete)
|
||||
bDelete.removeClass('disabled');
|
||||
} else {
|
||||
if (bDelete)
|
||||
bDelete.addClass('disabled');
|
||||
}
|
||||
}
|
||||
|
||||
function checkDelete(e) {
|
||||
const msg = 'Сигурни ли сте, че искате да изтриете ' + (sl.length > 1 ? 'тези ' + sl.length + ' записа?' : 'този запис?');
|
||||
modal.confirm(msg, () => {
|
||||
console.log(sl)
|
||||
all('tbody .delete-checkbox:checked').forEach(e => {
|
||||
e.parentNode.parentNode.remove();
|
||||
})
|
||||
|
||||
all('tbody .delete-checkbox').forEach((e, i) => {
|
||||
const number = e.parentNode.querySelector('span');
|
||||
number.innerHTML = (i + 1).toString()
|
||||
})
|
||||
const slValues = [];
|
||||
sl.forEach(v => {
|
||||
if (v) {
|
||||
slValues.push(v);
|
||||
}
|
||||
})
|
||||
if (slValues.length > 0) {
|
||||
request({
|
||||
url: window.location.href.split('?')[0] + '?o=d',
|
||||
post: {
|
||||
ids: JSON.stringify(sl),
|
||||
model: e.dataset.model
|
||||
},
|
||||
done: e => {
|
||||
window.location.reload();
|
||||
}
|
||||
})
|
||||
}
|
||||
sl = [];
|
||||
});
|
||||
}
|
||||
|
||||
function addSubCategory(e) {
|
||||
request({
|
||||
url: '/new-common-field-option/',
|
||||
post: {
|
||||
parent_id: e.dataset.id
|
||||
},
|
||||
done: e => {
|
||||
//window.location.reload();
|
||||
if (e.id && e.success === true) {
|
||||
addNewSubcategory(e.id, e.orderIndex);
|
||||
flash.success(e.msg, true)
|
||||
}
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
function addNewSubcategory(id, orderIndex) {
|
||||
console.log(id, orderIndex);
|
||||
const tBody = one('#sub-categories');
|
||||
const tCount = tBody.querySelectorAll('tr').length
|
||||
const indexId = id ? id : 'index_' + (tCount + 1)
|
||||
const tr = document.createElement('tr')
|
||||
tr.className = 'sub-categories'
|
||||
tr.setAttribute('draggable', true)
|
||||
tr.setAttribute('data-index', orderIndex)
|
||||
console.log(tr)
|
||||
|
||||
tr.innerHTML = `
|
||||
<td class="text-right c1" style="width: 50px">
|
||||
<input onclick="checkSingle(this)"
|
||||
class="delete-checkbox"
|
||||
type="checkbox"
|
||||
data-del="${id}"
|
||||
style="top: calc(50% - 10px)">
|
||||
<span class="sub-number">${tCount + 1}</span>
|
||||
</td>
|
||||
<td>
|
||||
<input style="width: calc(100% - 20px); margin-left: 5px; height: 20px; padding: 5px"
|
||||
name="sub[${indexId}][name]"
|
||||
value="">
|
||||
</td>
|
||||
<td>
|
||||
<input style="width: calc(100% - 20px); margin-left: 5px; height: 20px; padding: 5px"
|
||||
name="sub[${indexId}][ts_en_name]"
|
||||
value="">
|
||||
</td>
|
||||
`
|
||||
tBody.appendChild(tr);
|
||||
orderItem(tr, function () {
|
||||
var index = 0
|
||||
all('.sub-categories .sub-number').forEach(e => {
|
||||
e.innerText = ++index
|
||||
})
|
||||
})
|
||||
|
||||
|
||||
}
|
||||
|
||||
</script>
|
||||
|
||||
+326
@@ -0,0 +1,326 @@
|
||||
<?php
|
||||
|
||||
use app\models\Categories;
|
||||
use app\models\ObjectTemplate;
|
||||
use app\models\ObjectTemplateField;
|
||||
use app\widgets\services\Includes;
|
||||
|
||||
/**
|
||||
* @var ObjectTemplate $model
|
||||
*/
|
||||
|
||||
|
||||
?>
|
||||
<div class="inner-content p10">
|
||||
<form autocomplete="off">
|
||||
<div class="flex top15 c11">
|
||||
<div class="row c6 right10">
|
||||
<label class="require">Наименование на вид обект (BG)</label>
|
||||
<input name="name" placeholder="Въведи наименование на вида обект"
|
||||
value="<?= $model->name ?>"/>
|
||||
</div>
|
||||
<div class="row c6">
|
||||
<label class="require">Наименование на вид обект (EN)</label>
|
||||
<input name="ts_en_name" placeholder="Въведи наименование на вида обект"
|
||||
value="<?= $model->ts_en_name ?>"/>
|
||||
</div>
|
||||
</div>
|
||||
<div class="flex top15 c11">
|
||||
<div class="row c6 right10">
|
||||
<label class="require">Вид наследсво</label>
|
||||
<select name="heritage_type">
|
||||
<option selected disabled value="">-- Избери вид наследвство --</option>
|
||||
<?php foreach (ObjectTemplate::heritageTypes() as $id => $type): ?>
|
||||
<option <?= $id == $model->heritage_type ? 'selected' : '' ?> value="<?= $id ?>">
|
||||
<?= $type ?>
|
||||
</option>
|
||||
<?php endforeach; ?>
|
||||
</select>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="row c5 top15">
|
||||
<?php if ($model->id): ?>
|
||||
<div onclick="addSub(this)" data-id="<?= $model->id ?>"
|
||||
class="btn-ib btn-default">
|
||||
<i class="la la-plus-circle"></i> Добавяне на динамично поле
|
||||
</div>
|
||||
<?php else: ?>
|
||||
<div onclick="addNewSub()"
|
||||
class="btn-ib btn-default">
|
||||
<i class="la la-plus-circle"></i> Добавяне на динамично поле
|
||||
</div>
|
||||
<?php endif; ?>
|
||||
<div id="bDelete" data-model="app\models\ObjectTemplateField" onclick="checkDelete(this)"
|
||||
class="btn-ib btn-default ct disabled">
|
||||
<i class="la la-trash-o"></i> Изтриване на динамични полета<span id="delCount">(0)</span>
|
||||
</div>
|
||||
</div>
|
||||
<div class="c11 top15">
|
||||
<table class="cms-table">
|
||||
<thead>
|
||||
<tr>
|
||||
<th class="text-right">
|
||||
<input id="checkAll" onclick="checkAllObjectTypes(this)" title="Избери всички"
|
||||
class="delete-checkbox" type="checkbox">
|
||||
No
|
||||
</th>
|
||||
<th class="c3">Наименование на поле (BG)</th>
|
||||
<th class="c3">Наименование на поле (EN)</th>
|
||||
<!--<th>Тип на данните</th>-->
|
||||
<th>Потребителски интерфейс</th>
|
||||
<th style="width: 70px">За филтър</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody id="dynamic-fields">
|
||||
<?php foreach ($model->objectTemplateFields as $i => $dynamicField): ?>
|
||||
<?php $fieldOptions = $dynamicField->fieldOptions ?>
|
||||
<tr class="dynamic-fields" draggable="true" data-index="<?= $dynamicField->order_index ?>">
|
||||
<td class="text-right c1" style="width: 50px">
|
||||
<input onclick="checkSingle(this)" data-del="<?= $dynamicField->id ?>"
|
||||
class="delete-checkbox"
|
||||
type="checkbox"
|
||||
style="top: calc(50% - 10px)">
|
||||
<span class="sub-number"><?= $i + 1 ?></span>
|
||||
</td>
|
||||
<td>
|
||||
<input style="width: calc(100% - 20px); margin-left: 5px; height: 20px; padding: 5px"
|
||||
name="sub[<?= $dynamicField->id ?>][name]"
|
||||
value="<?= $dynamicField->name ?>">
|
||||
</td>
|
||||
<td>
|
||||
<input style="width: calc(100% - 20px); margin-left: 5px; height: 20px; padding: 5px"
|
||||
name="sub[<?= $dynamicField->id ?>][ts_en_name]"
|
||||
value="<?= $dynamicField->ts_en_name ?>">
|
||||
</td>
|
||||
<td class="value-type">
|
||||
<?= ObjectTemplateField::userInterfaceType($dynamicField->user_interface_type, true, $dynamicField->id) ?>
|
||||
<?php if ($dynamicField->user_interface_type == 'list' || $dynamicField->user_interface_type == 'list_simple'): ?>
|
||||
<input data-id="<?= $dynamicField->id ?>"
|
||||
name="sub[<?= $dynamicField->id ?>][select_data]" type="hidden"
|
||||
value='<?= $dynamicField->fieldOptionsAsJson($fieldOptions) ?>'>
|
||||
<table class="inner-td-table" data-table="sub[<?= $dynamicField->id ?>][select_data]">
|
||||
<thead>
|
||||
<tr>
|
||||
|
||||
<?php if ($dynamicField->user_interface_type == 'list'): ?>
|
||||
<td>стойност (bg)</td>
|
||||
<td>стойност (en)</td>
|
||||
<?php else: ?>
|
||||
<td>стойност</td>
|
||||
<?php endif; ?>
|
||||
<td></td>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody data-id="<?= $dynamicField->id ?>">
|
||||
<?php if (!empty($fieldOptions)): ?>
|
||||
<?php foreach ($fieldOptions as $index => $option): ?>
|
||||
<tr data-option-id="<?= $option->id ?>" class="added-row"
|
||||
data-index="<?= $index ?>"
|
||||
data-table="sub[<?= $dynamicField->id ?>][select_data]">
|
||||
<td><input class="update-bg" value="<?= $option->name ?>"></td>
|
||||
<?php if ($dynamicField->user_interface_type == 'list'): ?>
|
||||
<td><input class="update-en" value="<?= $option->ts_en_name ?>">
|
||||
</td><?php endif; ?>
|
||||
<td class="remove"><i class="la la-remove"></i></td>
|
||||
</tr>
|
||||
<?php endforeach; ?>
|
||||
<?php endif; ?>
|
||||
<tr data-table="sub[<?= $dynamicField->id ?>][select_data]">
|
||||
<td><input class="add-bg"></td>
|
||||
<?php if ($dynamicField->user_interface_type == 'list'): ?>
|
||||
<td><input class="add-en"></td><?php endif; ?>
|
||||
<td class="add-row"><i class="la la-plus-circle"></i></td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
<?php endif; ?>
|
||||
</td>
|
||||
<td class="ct">
|
||||
<input <?= $dynamicField->is_filter ? 'checked' : '' ?> type="checkbox" value="1" name="sub[<?= $dynamicField->id ?>][is_filter]">
|
||||
</td>
|
||||
</tr>
|
||||
<?php endforeach; ?>
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
<div class="row c9 top15 flex">
|
||||
<?= Includes::formButtons('nomenclature/object-templates') ?>
|
||||
</div>
|
||||
</form>
|
||||
</div>
|
||||
<script src="/_public/assets/js/order.js"></script>
|
||||
<script src="/_public/assets/js/inner-table-items.js"></script>
|
||||
|
||||
<script>
|
||||
const innerTableItems = new InnerTableItems()
|
||||
innerTableItems.setUpdateUrl('/update-dynamic-type-values/')
|
||||
|
||||
orderItems('.dynamic-fields', '/update-dynamic-fields-indexes/', function () {
|
||||
var index = 0
|
||||
all('.dynamic-fields .sub-number').forEach(e => {
|
||||
e.innerText = ++index
|
||||
console.log(e.innerText)
|
||||
})
|
||||
});
|
||||
|
||||
let sl = [];
|
||||
|
||||
function checkAllObjectTypes(el) {
|
||||
console.log(el);
|
||||
sl = [];
|
||||
all('td [data-del]').forEach(e => {
|
||||
e.checked = el.checked === true;
|
||||
if (el.checked) {
|
||||
sl.push(e.dataset.del);
|
||||
e.parentNode.parentNode.addClass('checked');
|
||||
} else {
|
||||
e.parentNode.parentNode.removeClass('checked');
|
||||
}
|
||||
|
||||
})
|
||||
if (sl.length === 0)
|
||||
el.checked = false;
|
||||
updateActionButtons();
|
||||
}
|
||||
|
||||
function checkSingle(e) {
|
||||
if (e.checked) {
|
||||
sl.push(e.dataset.del);
|
||||
e.parentNode.parentNode.addClass('checked');
|
||||
} else {
|
||||
one('#checkAll').checked = false;
|
||||
e.parentNode.parentNode.removeClass('checked');
|
||||
const f = sl.indexOf(e.dataset.del);
|
||||
sl.splice(f, 1);
|
||||
}
|
||||
updateActionButtons(e.dataset.del);
|
||||
}
|
||||
|
||||
function updateActionButtons() {
|
||||
const bDelete = one('#bDelete');
|
||||
const delCount = one('#delCount');
|
||||
const c = sl.length;
|
||||
if (delCount)
|
||||
delCount.innerText = '(' + c + ')';
|
||||
if (c > 0) {
|
||||
if (bDelete)
|
||||
bDelete.removeClass('disabled');
|
||||
} else {
|
||||
if (bDelete)
|
||||
bDelete.addClass('disabled');
|
||||
}
|
||||
}
|
||||
|
||||
function checkDelete(e) {
|
||||
const msg = 'Сигурни ли сте, че искате да изтриете ' + (sl.length > 1 ? 'тези ' + sl.length + ' записа?' : 'този запис?');
|
||||
modal.confirm(msg, () => {
|
||||
console.log(sl)
|
||||
all('tbody .delete-checkbox:checked').forEach(e => {
|
||||
e.parentNode.parentNode.remove();
|
||||
})
|
||||
|
||||
all('tbody .delete-checkbox').forEach((e, i) => {
|
||||
const number = e.parentNode.querySelector('span');
|
||||
number.innerHTML = (i + 1).toString()
|
||||
})
|
||||
const slValues = [];
|
||||
sl.forEach(v => {
|
||||
if (v) {
|
||||
slValues.push(v);
|
||||
}
|
||||
})
|
||||
if (slValues.length > 0) {
|
||||
request({
|
||||
url: window.location.href.split('?')[0] + '?o=d',
|
||||
post: {
|
||||
ids: JSON.stringify(sl),
|
||||
model: e.dataset.model,
|
||||
noFlash: true
|
||||
},
|
||||
done: r => {
|
||||
all('.delete-checkbox', e => {
|
||||
e.checked = false;
|
||||
})
|
||||
updateActionButtons();
|
||||
flash.success(r.message)
|
||||
}
|
||||
})
|
||||
}
|
||||
sl = [];
|
||||
});
|
||||
}
|
||||
|
||||
function addSub(e) {
|
||||
request({
|
||||
url: '/new-dynamic-field/',
|
||||
post: {
|
||||
ot_id: e.dataset.id
|
||||
},
|
||||
done: e => {
|
||||
if (e.id && e.success === true) {
|
||||
addNewSub(e.id, e.orderIndex);
|
||||
flash.success(e.msg, true)
|
||||
}
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
function addNewSub(id, orderIndex) {
|
||||
const tBody = one('#dynamic-fields');
|
||||
const tCount = tBody.querySelectorAll('tr').length
|
||||
const indexId = id ? id : 'index_' + (tCount + 1)
|
||||
const tr = document.createElement('tr')
|
||||
tr.className = 'dynamic-fields'
|
||||
tr.setAttribute('draggable', true)
|
||||
tr.setAttribute('data-index', orderIndex)
|
||||
const
|
||||
select = document.createElement('select'),
|
||||
selectDataType = document.createElement('select')
|
||||
select.className = 'type-value-selector'
|
||||
select.setAttribute('name', `sub[${indexId}][user_interface_type]`)
|
||||
select.setAttribute('onchange', 'innerTableItems.setChangeToSelect(this)')
|
||||
select.innerHTML = '<?= ObjectTemplateField::userInterfaceType(null, true, null, true) ?>'
|
||||
select.setAttribute('data-id', id)
|
||||
|
||||
selectDataType.setAttribute('name', `sub[${indexId}][data_type]`)
|
||||
selectDataType.setAttribute('onchange', 'innerTableItems.setChangeDataType(this)')
|
||||
selectDataType.innerHTML = '<?= ObjectTemplateField::dataType(null, null, true, true) ?>'
|
||||
selectDataType.setAttribute('data-id', id)
|
||||
|
||||
tr.innerHTML = `
|
||||
<td class="text-right c1" style="width: 50px">
|
||||
<input onclick="checkSingle(this)"
|
||||
class="delete-checkbox"
|
||||
type="checkbox"
|
||||
data-del="${id}"
|
||||
style="top: calc(50% - 10px)">
|
||||
<span class="sub-number">${orderIndex || tCount + 1}</span>
|
||||
</td>
|
||||
<td>
|
||||
<input style="width: calc(100% - 20px); margin-left: 5px; height: 20px; padding: 5px"
|
||||
name="sub[${indexId}][name]"
|
||||
value="">
|
||||
</td>
|
||||
<td>
|
||||
<input style="width: calc(100% - 20px); margin-left: 5px; height: 20px; padding: 5px"
|
||||
name="sub[${indexId}][ts_en_name]"
|
||||
value="">
|
||||
</td>
|
||||
<td>${select.outerHTML}</td>
|
||||
<td class="ct">
|
||||
<input type="checkbox" value="1" name="sub[${indexId}][is_filter]">
|
||||
</td>
|
||||
`
|
||||
|
||||
tBody.appendChild(tr);
|
||||
orderItem(tr, function () {
|
||||
var index = 0
|
||||
all('.dynamic-fields .sub-number').forEach(e => {
|
||||
e.innerText = ++index
|
||||
})
|
||||
})
|
||||
}
|
||||
|
||||
</script>
|
||||
|
||||
@@ -0,0 +1,55 @@
|
||||
<?php
|
||||
|
||||
use app\models\Collections;
|
||||
use app\widgets\FileWidget;
|
||||
|
||||
/**
|
||||
* @var $model Collections
|
||||
*/
|
||||
$media_key = $model->getMediaKey();
|
||||
|
||||
?>
|
||||
|
||||
<form autocomplete="off">
|
||||
<div class="inner-content p10">
|
||||
<div class="row info-table c5 top15">
|
||||
<?php if ($model->name): ?>
|
||||
<div class="row-flex">
|
||||
<div>Име на колекцията:</div>
|
||||
<div class="txt-no-transform"><?= $model->name ?></div>
|
||||
</div>
|
||||
<?php endif; ?>
|
||||
</div>
|
||||
<div class="row c9 top15">
|
||||
<label>Заглавно изображение</label>
|
||||
<?= FileWidget::widget([
|
||||
'media_type' => 'image',
|
||||
'object_key' => 'title_collection_image',
|
||||
'media_key' => $media_key,
|
||||
'files' => $model->getFiles('thumb'),
|
||||
'actions' => [
|
||||
'add' => 'Добавяне на изображение',
|
||||
'edit' => 'Редакция на изображенито',
|
||||
'delete' => 'Премахване на изображението'
|
||||
],
|
||||
'single_file' => true,
|
||||
'resolutions' => ['16:11', '4:3', '1:1'],
|
||||
'max_file_size' => 2,
|
||||
'error_message' => 'Файловете по-големи от 2МБ, не бяха добавени'
|
||||
]) ?>
|
||||
</div>
|
||||
</div>
|
||||
</form>
|
||||
|
||||
<script src="/_public/assets/js/order.js"></script>
|
||||
<script src="/_public/assets/js/file-img.js"></script>
|
||||
<script src="/_public/plugins/cropperJs/cropper.min.js"></script>
|
||||
<?php if (!$model->media_key): ?>
|
||||
<script>
|
||||
const media_key = '<?= $media_key ?>';
|
||||
request({
|
||||
url: window.location.href + '&media_key_update=1',
|
||||
post: {media_key: media_key}
|
||||
})
|
||||
</script>
|
||||
<?php endif; ?>
|
||||
@@ -0,0 +1,40 @@
|
||||
<?php
|
||||
|
||||
use app\models\Collections;
|
||||
use app\widgets\services\Includes;
|
||||
|
||||
/**
|
||||
* @var Collections $model
|
||||
*/
|
||||
$ts = $_GET['tab'];
|
||||
|
||||
?>
|
||||
<div class="inner-content p10">
|
||||
<?php if (empty($model->id)): ?>
|
||||
<p style="color: darkorange; font-weight: bold">* Формата ще бъде активна след попълването на "Основни
|
||||
данни"</p>
|
||||
<?php endif; ?>
|
||||
<form autocomplete="off" class="<?= empty($model->id) ? 'disabled' : '' ?>">
|
||||
<div class="row c9 top15">
|
||||
<label class="require">Анотация</label>
|
||||
<textarea class="ckEditor" name="<?= $ts ?>_annotation"><?= $model->{$ts . '_annotation'} ?></textarea>
|
||||
</div>
|
||||
<div class="row c9 top15">
|
||||
<label class="require">Описание</label>
|
||||
<textarea class="ckEditor" name="<?= $ts ?>_description"><?= $model->{$ts . '_description'} ?></textarea>
|
||||
</div>
|
||||
<div class="row c9 top15">
|
||||
<label class="require">Информационен център</label>
|
||||
<input name="<?= $ts ?>_info_center" placeholder="Въведи наименование на информационен център"
|
||||
value="<?= $model->{$ts . '_info_center'} ?>"/>
|
||||
</div>
|
||||
<div class="row c9 top15">
|
||||
<label class="require">Информационен център адрес</label>
|
||||
<input name="<?= $ts ?>_info_center_address" placeholder="Въведи адрес на информационен център"
|
||||
value="<?= $model->{$ts.'_info_center_address'} ?>"/>
|
||||
</div>
|
||||
<div class="row flex c9 top15">
|
||||
<?= Includes::formButtons('nomenclature/collections') ?>
|
||||
</div>
|
||||
</form>
|
||||
</div>
|
||||
Reference in New Issue
Block a user