Initial import
This commit is contained in:
@@ -0,0 +1,308 @@
|
||||
<style>
|
||||
.page-navbar {
|
||||
display: none;
|
||||
}
|
||||
|
||||
.header {
|
||||
display: none;
|
||||
}
|
||||
|
||||
.cms-table {
|
||||
margin: 45px 0 35px 0;
|
||||
}
|
||||
|
||||
.pagination {
|
||||
position: fixed;
|
||||
bottom: 0;
|
||||
left: 0;
|
||||
justify-content: left !important;
|
||||
background: #FFFFFF;
|
||||
padding: 15px;
|
||||
box-shadow: 0 -3px 10px rgba(0, 0, 0, 0.3);
|
||||
width: 100%;
|
||||
margin-left: 0 !important;
|
||||
}
|
||||
|
||||
.page-content {
|
||||
width: 100%;
|
||||
padding: 0 !important;
|
||||
}
|
||||
|
||||
.flex.top {
|
||||
position: fixed;
|
||||
top: 0;
|
||||
left: 0;
|
||||
background: #FFFFFF;
|
||||
box-shadow: 0 3px 10px rgba(0, 0, 0, 0.3);
|
||||
z-index: 10000;
|
||||
padding-left: 15px;
|
||||
margin-left: 0;
|
||||
width: 100%;
|
||||
}
|
||||
|
||||
.flex.top .top-title {
|
||||
padding-top: 15px !important;
|
||||
padding-bottom: 10px !important;
|
||||
width: 100%;
|
||||
white-space: nowrap;
|
||||
overflow-x: hidden;
|
||||
font-size: 16px;
|
||||
color: var(--base-background-dark);
|
||||
}
|
||||
|
||||
.inner-content {
|
||||
padding: 1px !important;
|
||||
position: relative;
|
||||
}
|
||||
|
||||
.filter-button {
|
||||
position: fixed;
|
||||
right: 15px;
|
||||
bottom: 70px;
|
||||
height: 50px !important;
|
||||
width: 50px !important;
|
||||
text-align: center;
|
||||
line-height: 60px;
|
||||
cursor: pointer;
|
||||
border-radius: 100%;
|
||||
border: 1px solid var(--base-background-dark);
|
||||
background: #FFFFFF;
|
||||
box-shadow: 0 0 10px rgba(0, 0, 0, 0.5);
|
||||
z-index: 100000;
|
||||
}
|
||||
|
||||
.filter-button:hover {
|
||||
background: var(--base-background-ultra-bright-clear);
|
||||
}
|
||||
|
||||
.filter-button .la {
|
||||
font-size: 25px;
|
||||
color: var(--base-background-dark);
|
||||
}
|
||||
|
||||
.breadcrumb {
|
||||
display: none;
|
||||
}
|
||||
</style>
|
||||
<?php
|
||||
/**
|
||||
* @var $this \yii\web\View
|
||||
*/
|
||||
|
||||
use app\models\History;
|
||||
use app\models\RegisterObjects;
|
||||
use app\services\Auth;
|
||||
use app\widgets\FormWidget;
|
||||
use app\widgets\services\Includes;
|
||||
use app\widgets\TableWidget;
|
||||
|
||||
$tab = $_GET['tab'] ?? 'main';
|
||||
|
||||
$_GET['tab'] = $tab;
|
||||
|
||||
$title = null;
|
||||
$expId = null;
|
||||
$partner_id = Auth::userPartner()->partner_id;
|
||||
|
||||
if (!empty($_GET['expId'])) {
|
||||
$exp = \app\models\Expositions::findOne($_GET['expId']);
|
||||
if ($exp) {
|
||||
$title = $exp->name;
|
||||
$expId = $exp->id;
|
||||
}
|
||||
}
|
||||
if(!$partner_id) exit;
|
||||
$specialCondition = [];
|
||||
|
||||
$specialCondition['partner_id'] = $partner_id;
|
||||
$specialCondition['lib_type'] = 1;
|
||||
|
||||
if(!empty($_GET['ref_num'])) {
|
||||
$specialCondition['ref_num'] = (int)$_GET['ref_num'];
|
||||
}
|
||||
|
||||
if(!empty($_GET['name'])) {
|
||||
$specialCondition['name'] = $_GET['name'];
|
||||
}
|
||||
|
||||
|
||||
$data = RegisterObjects::find()->where($specialCondition)->orderBy(['date_updated' => SORT_DESC]);
|
||||
|
||||
TableWidget::widget([
|
||||
//'advanced_filter' => $this->render('_advanced_filters/object'),
|
||||
'top' => [
|
||||
'title' => $title ? 'Експозиция: ' . $title : '',
|
||||
'data' => [
|
||||
//'index/dashboard' => 'Начало',
|
||||
//'web-portal/expositions' => 'Уебпортал',
|
||||
]
|
||||
],
|
||||
'actions' => [
|
||||
// 'edit' => 'Редакция на обект',
|
||||
// 'delete' => 'Изтриване на обект'
|
||||
],
|
||||
'th' => [
|
||||
//'ID' => 'c05 text-right',
|
||||
'Реф. №' => 'c05 text-right',
|
||||
'Добавяне в експозицията' => 'c1',
|
||||
'Изображение' => 'ct c1',
|
||||
'Наименование' => '',
|
||||
],
|
||||
'data' => $data->loop([
|
||||
//'id',
|
||||
'ref_num',
|
||||
function (RegisterObjects $model) use ($expId) {
|
||||
$button = $model->isAddedToExposition($expId);
|
||||
return '<div data-exposition-id="' . $expId . '" data-object-id="' . $model->id . '" class="flex flex-center">' . $button . '</div>';
|
||||
},
|
||||
function (RegisterObjects $model) {
|
||||
if ($model->mainImgFile) {
|
||||
return '<img src="' . $model->mainImgFile . '" style="height: 130px">';
|
||||
}
|
||||
},
|
||||
function (RegisterObjects $model) {
|
||||
if ($model->name)
|
||||
return $model->name;
|
||||
},
|
||||
/*function (RegisterObjects $model) {
|
||||
if ($model->city)
|
||||
return $model->city->place;
|
||||
},*/
|
||||
|
||||
|
||||
], $_GET['p'] ?? 1, 30)
|
||||
]);
|
||||
FormWidget::widget([
|
||||
'top' => [
|
||||
|
||||
],
|
||||
'tabs' => $tabs ?? [],
|
||||
'writeView' => empty($_GET['id']) ? "web-portal/tabs/main/register_objects_w" : "web-portal/tabs/" . Includes::tab($tab) . "/register_objects_w",
|
||||
'model' => RegisterObjects::class,
|
||||
'validation' => function ($p) use ($tab) {
|
||||
if ($tab == 'main') {
|
||||
if (empty($_GET['id'])) {
|
||||
//NEW OBJECT
|
||||
if (empty($p->{'sc_id'}))
|
||||
return ['sc_id' => 'Моля, изберете категория'];
|
||||
if (empty($p->{'sc_id'}))
|
||||
return ['ot_id' => 'Моля, изберете шаблон на обект'];
|
||||
} else {
|
||||
//UPDATE GENERAL DATA
|
||||
if (empty($p->{'name'}))
|
||||
return ['name' => 'Моля, въведете име на обекта'];
|
||||
if (empty($p->{'annotation'}))
|
||||
return ['annotation' => 'Моля, въведете анотация'];
|
||||
if (empty($p->{'description'}))
|
||||
return ['description' => 'Моля, въведете описание'];
|
||||
}
|
||||
} else if (Includes::inLocales($tab)) {
|
||||
if (empty($p->{$tab . '_name'}))
|
||||
return [$tab . '_name' => 'Моля, въведете име на обекта'];
|
||||
if (empty($p->{$tab . '_annotation'}))
|
||||
return [$tab . '_annotation' => 'Моля, въведете анотация'];
|
||||
if (empty($p->{$tab . '_description'}))
|
||||
return [$tab . '_description' => 'Моля, въведете описание'];
|
||||
}
|
||||
return null;
|
||||
},
|
||||
'postService' => function ($p, RegisterObjects $model) use ($tab) {
|
||||
$model->setPostDataToModel();
|
||||
$model->save();
|
||||
History::addNew($model->id, 'register_objects', Auth::userAdminGlobal()->getFullName() . ' - Глобален администратор', !empty($_GET['id']));
|
||||
if (empty($_GET['media_key_update'])) {
|
||||
Yii::$app->flash('success', isset($_GET['id']) ? 'Обекта е актуализиран успешно' : 'Обекта е създаден успешно');
|
||||
$model->smartRedirect();
|
||||
}
|
||||
}
|
||||
]);
|
||||
echo $this->render('_list_object_filter', ['expId' => $expId])
|
||||
?>
|
||||
<script>
|
||||
|
||||
function addExpObject(elem) {
|
||||
const exposition_id = elem.parentNode.dataset.expositionId;
|
||||
const object_id = elem.parentNode.dataset.objectId;
|
||||
elem.classList.add('disabled')
|
||||
request({
|
||||
url: '/remote/add-object-to-exposition/',
|
||||
post: {
|
||||
exposition_id,
|
||||
object_id
|
||||
},
|
||||
done: (e) => {
|
||||
if (e.error) {
|
||||
flash.error('Този обект вече е добавен, изберете друг', true);
|
||||
} else {
|
||||
flash.success('Обекта е добавен към експозицията', true);
|
||||
elem.parentNode.innerHTML = '<div onclick="removeExpObject(this)" class="btn-rem btn-ib"><i class="la la-remove"></i> Премахни</div>'
|
||||
}
|
||||
window.parent.loadExpositionObjects()
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
function removeExpObject(elem) {
|
||||
const exposition_id = elem.parentNode.dataset.expositionId;
|
||||
const object_id = elem.parentNode.dataset.objectId;
|
||||
elem.classList.add('disabled');
|
||||
request({
|
||||
url: '/remote/remove-object-from-exposition/',
|
||||
post: {
|
||||
exposition_id,
|
||||
object_id
|
||||
},
|
||||
done: (e) => {
|
||||
if (e.error) {
|
||||
} else {
|
||||
flash.success('Обекта е премахнат от експозицията', true);
|
||||
elem.parentNode.innerHTML = '<div onclick="addExpObject(this)" class="btn-ib btn-default"><i class="la la-plus-circle"></i> Добави</div>'
|
||||
window.parent.loadExpositionObjects()
|
||||
}
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
window.addEventListener('DOMContentLoaded', function () {
|
||||
const top = document.querySelector('.inner-content');
|
||||
const fbx = document.querySelector('.filter-box');
|
||||
const fb = one('filter-button', top);
|
||||
fb.innerHTML = '<i class="la la-search"></i>'
|
||||
fb.addEventListener('click', () => {
|
||||
if (fbx.classList.contains('open')) {
|
||||
fbx.classList.remove('open')
|
||||
fb.innerHTML = '<i class="la la-search"></i>';
|
||||
} else {
|
||||
fbx.classList.add('open')
|
||||
fb.innerHTML = '<i class="la la-remove"></i>';
|
||||
}
|
||||
})
|
||||
})
|
||||
|
||||
function filterExpObjects() {
|
||||
let expId = '<?= $_GET['expId'] ?? '' ?>';
|
||||
let p = '<?= $_GET['p'] ?? '1' ?>';
|
||||
let filter_object_ref_num = document.querySelector('#filter_object_ref_num')
|
||||
let filter_object_name = document.querySelector('#filter_object_name')
|
||||
let filters = [];
|
||||
|
||||
if (filter_object_name.value !== '')
|
||||
filters.push(`name=${filter_object_name.value}`)
|
||||
|
||||
if (filter_object_ref_num.value !== '')
|
||||
filters.push(`ref_num=${filter_object_ref_num.value}`)
|
||||
|
||||
let q = ''
|
||||
|
||||
if(filters.length > 0) {
|
||||
q = `&${filters.join('&')}`
|
||||
}
|
||||
|
||||
window.location.href = `?expId=${expId}&p=${p}${q}`
|
||||
}
|
||||
|
||||
function clearFilterExpObjects() {
|
||||
let expId = '<?= $_GET['expId'] ?? '' ?>';
|
||||
window.location.href = `?expId=${expId}`
|
||||
}
|
||||
</script>
|
||||
Reference in New Issue
Block a user