Initial import
This commit is contained in:
@@ -0,0 +1,14 @@
|
||||
<?php
|
||||
namespace app\models;
|
||||
|
||||
/**
|
||||
* Class AboutProject
|
||||
* @package app\models
|
||||
* @property $id
|
||||
* @property $text_bg
|
||||
* @property $text_en
|
||||
* @property $media_key
|
||||
*/
|
||||
class AboutProject extends _Base {
|
||||
|
||||
}
|
||||
@@ -0,0 +1,80 @@
|
||||
<?php
|
||||
|
||||
namespace app\models;
|
||||
|
||||
/**
|
||||
* Class Articles
|
||||
* @package app\models
|
||||
* @property $id
|
||||
* @property $key
|
||||
* @property $art_table
|
||||
* @property News $news;
|
||||
* @property Events $events;
|
||||
* @property Campaigns $campaigns;
|
||||
* @property $title
|
||||
* @property $title_en
|
||||
* @property $is_active
|
||||
* @property $publish_date
|
||||
*/
|
||||
class Articles extends _Base
|
||||
{
|
||||
public function getNews()
|
||||
{
|
||||
return $this->hasOne(News::class, ['article_key' => 'key']);
|
||||
}
|
||||
|
||||
public function getEvents()
|
||||
{
|
||||
return $this->hasOne(Events::class, ['article_key' => 'key']);
|
||||
}
|
||||
|
||||
public function getCampaigns()
|
||||
{
|
||||
return $this->hasOne(Campaigns::class, ['article_key' => 'key']);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param News | Events | Campaigns | \yii\db\ActiveRecord $model
|
||||
*/
|
||||
public static function updateArticle($model)
|
||||
{
|
||||
$articleUpdate = [
|
||||
'title' => 'title',
|
||||
'title_en' => 'ts_en_title',
|
||||
'is_active' => 'is_active',
|
||||
'publish_date' => 'publish_date',
|
||||
'partner_id' => 'partner_id',
|
||||
'on_partner_page' => 'on_partner_page',
|
||||
'partner_page_selected' => 'partner_page_selected'
|
||||
];
|
||||
|
||||
|
||||
if (empty($model->article_key)) {
|
||||
$article = new Articles();
|
||||
switch (true) {
|
||||
case $model instanceof News:
|
||||
$article->key = "news_$model->id";
|
||||
$article->art_table = "news";
|
||||
break;
|
||||
case $model instanceof Events:
|
||||
$article->key = "events_$model->id";
|
||||
$article->art_table = "events";
|
||||
break;
|
||||
case $model instanceof Campaigns:
|
||||
$article->key = "campaigns_$model->id";
|
||||
$article->art_table = "campaigns";
|
||||
break;
|
||||
}
|
||||
foreach ($articleUpdate as $a => $m) $article->{$a} = $model->{$m};
|
||||
$article->save();
|
||||
$model->article_key = $article->key;
|
||||
$model->save();
|
||||
} else {
|
||||
$article = Articles::find()->where(['key' => $model->article_key])->one();
|
||||
if ($article) {
|
||||
foreach ($articleUpdate as $a => $m) $article->{$a} = $model->{$m};
|
||||
$article->save();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,31 @@
|
||||
<?php
|
||||
|
||||
namespace app\models;
|
||||
use app\models\register\Partner;
|
||||
|
||||
/**
|
||||
* Class Campaigns
|
||||
* @package app\models
|
||||
* @property $location
|
||||
* @property $title
|
||||
* @property $text
|
||||
* @property $text_short
|
||||
* @property $ts_en_location
|
||||
* @property $ts_en_title
|
||||
* @property $ts_en_text
|
||||
* @property $ts_en_text_short
|
||||
* @property $media_key
|
||||
* @property $stream_url
|
||||
* @property $stream_access
|
||||
* @property $partner_id
|
||||
* @property Partner $partner
|
||||
* @property $event_dates
|
||||
* @property $is_for_publish
|
||||
* @property $article_key
|
||||
*/
|
||||
class Campaigns extends _Base
|
||||
{
|
||||
public function getPartner() {
|
||||
return $this->hasOne(Partner::class, ['id' => 'partner_id']);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,96 @@
|
||||
<?php
|
||||
|
||||
|
||||
namespace app\models;
|
||||
|
||||
|
||||
/**
|
||||
* Class Categories
|
||||
* @package app\models
|
||||
* @property $id
|
||||
* @property $name
|
||||
* @property $ts_en_name
|
||||
* @property $parent_id
|
||||
* @property Categories $mainCategory
|
||||
* @property Categories[] $subCategories
|
||||
* @property int $subCategoriesCount
|
||||
* @property int $order_index
|
||||
* @property CategoriesOt[] $categoriesOt
|
||||
* @property $rr_category_id
|
||||
* @property $rr_sub_category_id
|
||||
*
|
||||
*/
|
||||
class Categories extends _Base
|
||||
{
|
||||
public function getSubCategories()
|
||||
{
|
||||
return $this->hasMany(self::class, ['parent_id' => 'id'])->orderBy(['order_index' => SORT_ASC])->all();
|
||||
}
|
||||
|
||||
public function getSubCategoriesByTemplate($templateIds)
|
||||
{
|
||||
return $this->hasMany(self::class, ['parent_id' => 'id'])
|
||||
->leftJoin('categories_ot', 'categories_ot.sc_id = categories.id')
|
||||
->where(['IN', 'ot_id', $templateIds])
|
||||
->orderBy(['order_index' => SORT_ASC])->all();
|
||||
}
|
||||
|
||||
|
||||
public function getSubCategoriesCount()
|
||||
{
|
||||
return $this->hasMany(self::class, ['parent_id' => 'id'])->count();
|
||||
}
|
||||
|
||||
public function getMainCategory()
|
||||
{
|
||||
return $this->hasOne(self::class, ['id' => 'parent_id']);
|
||||
}
|
||||
|
||||
public function getCategoriesOt()
|
||||
{
|
||||
return $this->hasMany(CategoriesOt::class, ['sc_id' => 'id']);
|
||||
}
|
||||
|
||||
public function getObjectTemplateList()
|
||||
{
|
||||
$selected = [];
|
||||
foreach ($this->categoriesOt as $categoriesOt) {
|
||||
$selected[] = $categoriesOt->ot_id;
|
||||
}
|
||||
$objectTypes = [];
|
||||
foreach (ObjectTemplate::find()->all() as $objectTemplate) {
|
||||
$objectTypes[] = [
|
||||
'id' => $objectTemplate->id,
|
||||
'name' => $objectTemplate->name,
|
||||
'selected' => in_array($objectTemplate->id, $selected) ? 'selected' : ''
|
||||
];
|
||||
}
|
||||
return $objectTypes;
|
||||
}
|
||||
|
||||
public function updateObjectTypes($ids) {
|
||||
|
||||
$related = CategoriesOt::find()->where(['sc_id' => $this->id])->all();
|
||||
$remain = [];
|
||||
foreach ($related as $cto) {
|
||||
if(in_array($cto->id, $ids)) {
|
||||
$remain[] = $cto->id;
|
||||
} else {
|
||||
$cto->delete();
|
||||
}
|
||||
}
|
||||
foreach ($ids as $id) {
|
||||
if(!in_array($id, $remain)) {
|
||||
$newCto = new CategoriesOt();
|
||||
$newCto->sc_id = $this->id;
|
||||
$newCto->ot_id = $id;
|
||||
$newCto->save();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static function getNextOrderIndex($parent_id) {
|
||||
$last = self::find()->where(['parent_id' => $parent_id])->orderBy(['order_index' => SORT_DESC])->one();
|
||||
return $last && $last->order_index ? $last->order_index + 1 : 1;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,41 @@
|
||||
<?php
|
||||
|
||||
|
||||
namespace app\models;
|
||||
|
||||
/**
|
||||
* Class CategoriesOt
|
||||
* @package app\models
|
||||
* @property $sc_id
|
||||
* @property $ot_id
|
||||
* @property ObjectTemplate $objectTemplate
|
||||
* @property Categories $category
|
||||
*/
|
||||
class CategoriesOt extends _Base
|
||||
{
|
||||
public function getObjectTemplate()
|
||||
{
|
||||
return $this->hasOne(ObjectTemplate::class, ['id' => 'ot_id']);
|
||||
}
|
||||
|
||||
public function getCategory()
|
||||
{
|
||||
return $this->hasOne(Categories::class, ['id' => 'sc_id']);
|
||||
}
|
||||
|
||||
public static function getObjectTemplateList($html = false)
|
||||
{
|
||||
$objectTypes = [];
|
||||
$options = '';
|
||||
foreach (ObjectTemplate::find()->all() as $objectType) {
|
||||
$objectTypes[] = [
|
||||
'id' => $objectType->id,
|
||||
'name' => $objectType->name
|
||||
];
|
||||
$options .= '<option value="' . $objectType->id . '">' . $objectType->name . '</option>';
|
||||
}
|
||||
if($html)
|
||||
return $options;
|
||||
return $objectTypes;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,31 @@
|
||||
<?php
|
||||
namespace app\models;
|
||||
|
||||
/**
|
||||
* Class CmsRights
|
||||
* @package app\models
|
||||
* @property int $id
|
||||
* @property string $name
|
||||
*/
|
||||
class CmsRights extends _Base
|
||||
{
|
||||
|
||||
/**
|
||||
* @param CmsRoles $model
|
||||
* @return string
|
||||
*/
|
||||
public static function getHtmlList(CmsRoles $model)
|
||||
{
|
||||
list($checkedList, $checkList) = ["", ""];
|
||||
foreach (self::find()->where(['is_active' => 1])->all() as $item) {
|
||||
if (in_array($item->id, $model->getRightsIds()))
|
||||
$checkedList .= '<label data-name="'.$item->name.'"><input checked name="rights[]" type="checkbox" value="' . $item->id . '">' . $item->name . '</label>';
|
||||
|
||||
}
|
||||
foreach (self::find()->where(['is_active' => 1])->all() as $item) {
|
||||
if (!in_array($item->id, $model->getRightsIds()))
|
||||
$checkList .= '<label data-name="'.$item->name.'"><input name="rights[]" type="checkbox" value="' . $item->id . '">' . $item->name . '</label>';
|
||||
}
|
||||
return '<div style="width: 100%; background: #f8f8f8; margin: 3px 0; padding: 3px 0; border: 1px solid var(--base-background-ultra-bright )">' .$checkedList.'</div>' . $checkList;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,74 @@
|
||||
<?php
|
||||
|
||||
|
||||
namespace app\models;
|
||||
|
||||
/**
|
||||
* Class CmsRoles
|
||||
* @package app\models
|
||||
* @property string $name
|
||||
* @property string $description
|
||||
* @property int $user_type_id;
|
||||
* @property \app\models\CmsRr[] $roleRights
|
||||
*/
|
||||
class CmsRoles extends _Base
|
||||
{
|
||||
public function getRoleRights()
|
||||
{
|
||||
return $this->hasMany(CmsRr::class, ['role_id' => 'id'])->innerJoinWith('right')->where(['is_active' => 1])->all();
|
||||
}
|
||||
|
||||
public function getRightsIds()
|
||||
{
|
||||
$rightsIds = [];
|
||||
foreach ($this->roleRights as $roleRight) {
|
||||
$rightsIds[] = $roleRight->right_id;
|
||||
}
|
||||
return $rightsIds;
|
||||
}
|
||||
|
||||
public function updateRights($rightsIds)
|
||||
{
|
||||
list($create_list, $delete_list) = [[], []];
|
||||
|
||||
//Delete OLD
|
||||
foreach ($this->getRightsIds() as $rightId) {
|
||||
if (!in_array($rightId, $rightsIds))
|
||||
$delete_list[] = $rightId;
|
||||
}
|
||||
$deleteCmsRr = CmsRr::find()->where(['role_id' => $this->id])->andWhere(['IN', 'right_id', $delete_list])->all();
|
||||
foreach ($deleteCmsRr as $cmsRrModel)
|
||||
$cmsRrModel->delete();
|
||||
|
||||
//Create new
|
||||
foreach ($rightsIds as $currentId) {
|
||||
if (!in_array($currentId, $this->getRightsIds()))
|
||||
$create_list[] = $currentId;
|
||||
}
|
||||
|
||||
foreach ($create_list as $rightId){
|
||||
$cmsRrModel = new CmsRr();
|
||||
$cmsRrModel->role_id = $this->id;
|
||||
$cmsRrModel->right_id = $rightId;
|
||||
$cmsRrModel->save();
|
||||
}
|
||||
}
|
||||
|
||||
public static function roleList($role_id = null) {
|
||||
$data = [];
|
||||
foreach (self::find()->all() as $item) {
|
||||
$data[$item->id] = $item->name;
|
||||
}
|
||||
if($role_id) {
|
||||
return $data[$role_id] ?? null;
|
||||
}
|
||||
return $data;
|
||||
}
|
||||
|
||||
|
||||
public static function roleUserTypes() {
|
||||
return [
|
||||
1 => 'Партньори'
|
||||
];
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,21 @@
|
||||
<?php
|
||||
namespace app\models;
|
||||
|
||||
/**
|
||||
* Class CmsRr
|
||||
* @package app\models
|
||||
* @property \app\models\CmsRoles $role
|
||||
* @property \app\models\CmsRights $right
|
||||
* @property int $role_id
|
||||
* @property int $right_id
|
||||
*/
|
||||
class CmsRr extends _Base
|
||||
{
|
||||
public function getRole() {
|
||||
return $this->hasOne(CmsRoles::class, ['id' => 'role_id']);
|
||||
}
|
||||
|
||||
public function getRight() {
|
||||
return $this->hasOne(CmsRights::class, ['id' => 'right_id']);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,26 @@
|
||||
<?php
|
||||
|
||||
|
||||
namespace app\models;
|
||||
|
||||
/**
|
||||
* Class Collections
|
||||
* @package app\models
|
||||
* @property $id
|
||||
* @property $name
|
||||
* @property $annotation
|
||||
* @property $description
|
||||
* @property $info_center
|
||||
* @property $info_center_address
|
||||
* @property $ts_en_name
|
||||
* @property $ts_en_annotation
|
||||
* @property $ts_en_description
|
||||
* @property $ts_en_info_center
|
||||
* @property $ts_en_info_center_address
|
||||
* @property $media_key
|
||||
* @property $publish_date
|
||||
*/
|
||||
class Collections extends _Base
|
||||
{
|
||||
|
||||
}
|
||||
@@ -0,0 +1,17 @@
|
||||
<?php
|
||||
namespace app\models;
|
||||
|
||||
/**
|
||||
* Class CollectionsObjects
|
||||
* @package app\models
|
||||
* @property $id
|
||||
* @property $object_id
|
||||
* @property $collection_id
|
||||
* @property $category_id
|
||||
* @property Collections $collection
|
||||
*/
|
||||
class CollectionsObjects extends _Base {
|
||||
public function getCollection() {
|
||||
return $this->hasOne(Collections::class, ['id' => 'collection_id']);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,22 @@
|
||||
<?php
|
||||
|
||||
|
||||
namespace app\models;
|
||||
|
||||
/**
|
||||
* Class CommonFields
|
||||
* @package app\models
|
||||
* @property int $id
|
||||
* @property int $parent_id
|
||||
* @property int $order_index
|
||||
* @property string $name
|
||||
* @property string $ts_en_name
|
||||
* @property CommonFields[] $options
|
||||
* @property boolean $multiple_filters
|
||||
*/
|
||||
class CommonFields extends _Base
|
||||
{
|
||||
public function getOptions() {
|
||||
return $this->hasMany(CommonFields::class, ['parent_id' => 'id'])->orderBy(['order_index' => SORT_ASC])->all();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,21 @@
|
||||
<?php
|
||||
|
||||
|
||||
namespace app\models;
|
||||
|
||||
/**
|
||||
* Class Contacts
|
||||
* @package app\models
|
||||
* @property $phone
|
||||
* @property $email
|
||||
* @property $website
|
||||
* @property $address
|
||||
* @property $address_en
|
||||
* @property $managing_authority
|
||||
* @property $managing_authority_en
|
||||
* @property $page_id
|
||||
*/
|
||||
class Contacts extends _Base
|
||||
{
|
||||
|
||||
}
|
||||
@@ -0,0 +1,22 @@
|
||||
<?php
|
||||
|
||||
|
||||
namespace app\models;
|
||||
|
||||
/**
|
||||
* Class DocsCms
|
||||
* @package app\models
|
||||
* @property $id
|
||||
* @property $document_key
|
||||
* @property $name
|
||||
* @property $name_en
|
||||
* @property $file_name
|
||||
* @property $file_name_en
|
||||
* @property $extension
|
||||
* @property $extension_en
|
||||
* @property $document_type
|
||||
*/
|
||||
class DocsCms extends _Base
|
||||
{
|
||||
|
||||
}
|
||||
@@ -0,0 +1,112 @@
|
||||
<?php
|
||||
|
||||
namespace app\models;
|
||||
|
||||
use app\models\register\Partner;
|
||||
|
||||
/**
|
||||
* Class Events
|
||||
* @package app\models
|
||||
* @property $type
|
||||
* @property $location
|
||||
* @property $title
|
||||
* @property $text
|
||||
* @property $text_short
|
||||
* @property $ts_en_location
|
||||
* @property $ts_en_title
|
||||
* @property $ts_en_text
|
||||
* @property $ts_en_text_short
|
||||
* @property $media_key
|
||||
* @property $stream_url
|
||||
* @property $stream_access
|
||||
* @property $stream_purchase_type
|
||||
* @property $stream_price
|
||||
* @property $partner_id
|
||||
* @property Partner $partner
|
||||
* @property $event_dates
|
||||
* @property $is_for_publish
|
||||
* @property $max_visitors
|
||||
* @property $daily_open_time
|
||||
* @property $price_objects
|
||||
* @property $article_key
|
||||
* @property $event_first_date
|
||||
* @property $event_last_date
|
||||
*/
|
||||
class Events extends _Base
|
||||
{
|
||||
public function getPartner()
|
||||
{
|
||||
return $this->hasOne(Partner::class, ['id' => 'partner_id']);
|
||||
}
|
||||
|
||||
public static function eventTypes($type = null)
|
||||
{
|
||||
$types = [
|
||||
'simple' => 'Обикновено събитие',
|
||||
'online' => 'Дигитално събитие',
|
||||
'booking' => 'Събитие на място с резервация'
|
||||
];
|
||||
if ($type) {
|
||||
if (!empty($types[$type])) {
|
||||
return mb_strtolower($types[$type]) ?? null;
|
||||
} else {
|
||||
header('Location: /');
|
||||
}
|
||||
}
|
||||
return $types;
|
||||
}
|
||||
|
||||
public function getEventType($text = false)
|
||||
{
|
||||
$type = $this->type ?? ($_GET['type'] ?? null);
|
||||
$types = ['simple', 'online', 'booking'];
|
||||
if (!in_array($type, $types))
|
||||
header('Location: /');
|
||||
if ($text)
|
||||
$type = self::eventTypes($type);
|
||||
return $type;
|
||||
}
|
||||
|
||||
|
||||
public static function getModel()
|
||||
{
|
||||
if (!empty($_GET['id'])) {
|
||||
return self::findOne($_GET['id']);
|
||||
} else {
|
||||
return new Events();
|
||||
}
|
||||
}
|
||||
|
||||
public function get_stream_purchase_type()
|
||||
{
|
||||
return $this->stream_purchase_type ?? 'individual_price';
|
||||
}
|
||||
|
||||
public function get_stream_access()
|
||||
{
|
||||
return $this->stream_access ?? 1;
|
||||
}
|
||||
|
||||
public function getPrice_objects()
|
||||
{
|
||||
return $this->hasMany(PriceObject::class, ['event_id' => 'id']);
|
||||
}
|
||||
|
||||
public function setFirstLast()
|
||||
{
|
||||
if ($this->event_dates) {
|
||||
$dates = explode(',', $this->event_dates);
|
||||
sort($dates);
|
||||
$this->event_first_date = $dates[0];
|
||||
$this->event_last_date = $dates[sizeof($dates) - 1];
|
||||
}
|
||||
}
|
||||
|
||||
public static function getList() {
|
||||
$list = [];
|
||||
foreach(self::find()->all() as $item) {
|
||||
$list[$item->id] = $item->title;
|
||||
}
|
||||
return $list;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,20 @@
|
||||
<?php
|
||||
|
||||
|
||||
namespace app\models;
|
||||
|
||||
/**
|
||||
* Class ExplorerObjects
|
||||
* @package app\models
|
||||
* @property $id
|
||||
* @property $tour_object_id
|
||||
* @property $points
|
||||
* @property $media_key
|
||||
* @property $tourObject
|
||||
*/
|
||||
class ExplorerObjects extends _Base
|
||||
{
|
||||
public function getTourObject() {
|
||||
return $this->hasOne(TourObjects::class, ['id' => 'tour_object_id']);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,77 @@
|
||||
<?php
|
||||
|
||||
|
||||
namespace app\models;
|
||||
|
||||
use yii\base\BaseObject;
|
||||
|
||||
/**
|
||||
* Class Expositions
|
||||
* @package app\models
|
||||
* @property $id
|
||||
* @property $name
|
||||
* @property $annotation
|
||||
* @property $description
|
||||
* @property $info_center
|
||||
* @property $info_center_address
|
||||
* @property $ts_en_name
|
||||
* @property $ts_en_annotation
|
||||
* @property $ts_en_description
|
||||
* @property $ts_en_info_center
|
||||
* @property $ts_en_info_center_address
|
||||
* @property $media_key
|
||||
* @property $publish_date
|
||||
* @property $category_id
|
||||
* @property $partner_id
|
||||
* @property $is_for_publish
|
||||
* @property \app\models\ExpositionsTagsExpositions[] $expositionsTags
|
||||
* @property \app\models\ExpositionsObjects[] $objectList
|
||||
*/
|
||||
class Expositions extends _Base
|
||||
{
|
||||
public function getExpositionsTags() {
|
||||
return $this->hasMany(ExpositionsTagsExpositions::class, ['exposition_id' => 'id']);
|
||||
}
|
||||
|
||||
public function getObjectList() {
|
||||
return $this->hasMany(ExpositionsObjects::class, ['exposition_id' => 'id']);
|
||||
}
|
||||
|
||||
public function getTagList() {
|
||||
$selected = [];
|
||||
foreach ($this->expositionsTags as $expositionsTag) {
|
||||
$selected[] = $expositionsTag->exposition_tag_id;
|
||||
}
|
||||
$tags = [];
|
||||
foreach (ExpositionsTags::find()->all() as $objectTemplate) {
|
||||
$tags[] = [
|
||||
'id' => $objectTemplate->id,
|
||||
'name' => $objectTemplate->name,
|
||||
'selected' => in_array($objectTemplate->id, $selected) ? 'selected' : ''
|
||||
];
|
||||
}
|
||||
return $tags;
|
||||
}
|
||||
|
||||
public function updateExpositionTags($tag_list = []) {
|
||||
$related = ExpositionsTagsExpositions::find()->where(['exposition_id' => $this->id])->all();
|
||||
$remain = [];
|
||||
foreach ($related as $etx) {
|
||||
if(in_array($etx->id, $tag_list)) {
|
||||
$remain[] = $etx->id;
|
||||
} else {
|
||||
$etx->delete();
|
||||
}
|
||||
}
|
||||
foreach ($tag_list as $id) {
|
||||
if(!in_array($id, $remain)) {
|
||||
$new = new ExpositionsTagsExpositions();
|
||||
$new->exposition_id = $this->id;
|
||||
$new->exposition_tag_id = $id;
|
||||
$new->save();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
@@ -0,0 +1,31 @@
|
||||
<?php
|
||||
|
||||
namespace app\models;
|
||||
|
||||
/**
|
||||
* Class ExpositionsCategories
|
||||
* @package app\models
|
||||
* @property $id
|
||||
* @property $name
|
||||
* @property $name_en
|
||||
*/
|
||||
class ExpositionsCategories extends _Base
|
||||
{
|
||||
public function getExpositions()
|
||||
{
|
||||
return $this->hasMany(Expositions::class, ['category_id' => 'id']);
|
||||
}
|
||||
|
||||
public static function dropDownList($id = null)
|
||||
{
|
||||
$list = [];
|
||||
foreach (self::find()->all() as $category) {
|
||||
$list[] = (object)[
|
||||
'id' => $category->id,
|
||||
'name' => $category->name,
|
||||
'selected' => $category->id == $id ? 'selected' : ''
|
||||
];
|
||||
}
|
||||
return $list;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,15 @@
|
||||
<?php
|
||||
namespace app\models;
|
||||
|
||||
/**
|
||||
* Class ExpositionsObjects
|
||||
* @package app\models
|
||||
* @property $exposition_id
|
||||
* @property $object_id
|
||||
* @property \app\models\RegisterObjects $object
|
||||
*/
|
||||
class ExpositionsObjects extends _Base {
|
||||
public function getObject() {
|
||||
return $this->hasOne(RegisterObjects::class, ['id' => 'object_id']);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,35 @@
|
||||
<?php
|
||||
|
||||
namespace app\models;
|
||||
|
||||
/**
|
||||
* Class ExpositionsCategories
|
||||
* @package app\models
|
||||
* @property $id
|
||||
* @property $name
|
||||
* @property $name_en
|
||||
* @property $partner_id
|
||||
*/
|
||||
class ExpositionsTags extends _Base
|
||||
{
|
||||
|
||||
/*
|
||||
public function getExpositions()
|
||||
{
|
||||
return $this->hasMany(Expositions::class, ['category_id' => 'id']);
|
||||
}
|
||||
|
||||
public static function dropDownList($id = null)
|
||||
{
|
||||
$list = [];
|
||||
foreach (self::find()->all() as $category) {
|
||||
$list[] = (object)[
|
||||
'id' => $category->id,
|
||||
'name' => $category->name,
|
||||
'selected' => $category->id == $id ? 'selected' : ''
|
||||
];
|
||||
}
|
||||
return $list;
|
||||
}
|
||||
*/
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
<?php
|
||||
namespace app\models;
|
||||
/**
|
||||
* Class ExpositionsTagsExpositions
|
||||
* @package app\models
|
||||
* @property $exposition_id
|
||||
* @property $exposition_tag_id
|
||||
*/
|
||||
class ExpositionsTagsExpositions extends _Base {
|
||||
|
||||
}
|
||||
@@ -0,0 +1,83 @@
|
||||
<?php
|
||||
|
||||
|
||||
namespace app\models;
|
||||
|
||||
/**
|
||||
* Class FileImage
|
||||
* @package app\models
|
||||
* @property $id
|
||||
* @property string $media_key
|
||||
* @property string $object_key
|
||||
* @property string $file_name
|
||||
* @property string $file_type
|
||||
* @property string $file_extension
|
||||
* @property string $file_size
|
||||
* @property string $date_time
|
||||
* @property string $resolutions
|
||||
* @property array $resolutionArray
|
||||
* @property int $order_index
|
||||
* @property boolean $has_article
|
||||
*/
|
||||
class FileCms extends _Base
|
||||
{
|
||||
public static function remove($id)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
public function getResolutionArray()
|
||||
{
|
||||
if ($this->resolutions) {
|
||||
$res = $this->resolutions;
|
||||
$res = ltrim($res, '"');
|
||||
$res = rtrim($res, '"');
|
||||
$res = str_replace('\"', '"', $res);
|
||||
return json_decode($res);
|
||||
}
|
||||
return [];
|
||||
}
|
||||
|
||||
public function deleteResolution($rez)
|
||||
{
|
||||
if ($rez) {
|
||||
$resolutions = $this->resolutionArray;
|
||||
$key = array_search($rez, $resolutions);
|
||||
if (false !== $key) {
|
||||
unset($resolutions[$key]);
|
||||
}
|
||||
$this->resolutions = json_encode($resolutions);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @return array['id', 'src']
|
||||
*/
|
||||
public function getImageData($ready = null)
|
||||
{
|
||||
$imageTypes = ['image/jpeg', 'image/png'];
|
||||
if (in_array($this->file_type, $imageTypes)) {
|
||||
$crops = [];
|
||||
|
||||
//if(!empty($this->resolutionArray)) {
|
||||
foreach ($this->resolutionArray as $rez) {
|
||||
$file = '/_files/ready/' . $this->media_key . '/' . $this->object_key . '/' . $rez . '/' . $this->file_name;
|
||||
if (file_exists($_SERVER['DOCUMENT_ROOT'] . $file))
|
||||
$crops[$rez] = $file;
|
||||
}
|
||||
//}
|
||||
return [
|
||||
'id' => $this->id,
|
||||
'src_raw' => '/_files/raw/' . $this->media_key . '/' . $this->object_key . '/' . $this->file_name,
|
||||
'src' => $ready ? '/_files/ready/' . $this->media_key . '/' . $this->object_key . '/' . $ready . '/' . $this->file_name : null,
|
||||
'file_name' => $this->file_name,
|
||||
'crops' => array_keys($crops),
|
||||
'crop_files' => $crops,
|
||||
'type' => $this->file_type,
|
||||
'extension' => $this->file_extension,
|
||||
'size' => number_format($this->file_size / 1024 / 1024, 2, '.', '') . 'M'
|
||||
];
|
||||
}
|
||||
return null;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,16 @@
|
||||
<?php
|
||||
|
||||
|
||||
namespace app\models;
|
||||
/**
|
||||
* Class Help
|
||||
* @package app\models
|
||||
* @property $id
|
||||
* @property $key
|
||||
* @property $title
|
||||
* @property $text
|
||||
*/
|
||||
class Help extends _Base
|
||||
{
|
||||
|
||||
}
|
||||
@@ -0,0 +1,31 @@
|
||||
<?php
|
||||
|
||||
namespace app\models;
|
||||
|
||||
/**
|
||||
* Class History
|
||||
* @package app\models
|
||||
* @property int $action
|
||||
* @property string $user
|
||||
* @property string $table_name
|
||||
* @property int $history_id
|
||||
* @property string $date_time
|
||||
* @property string $date
|
||||
*/
|
||||
class History extends _Base
|
||||
{
|
||||
public static function addNew($id, $table, $user, $edit = false)
|
||||
{
|
||||
$history = new History();
|
||||
$history->history_id = $id;
|
||||
$history->action = $edit == true ? 2 : 1;
|
||||
$history->table_name = $table;
|
||||
$history->user = $user;
|
||||
$history->date_time = date('Y-m-d H:i:s');
|
||||
$history->save();
|
||||
}
|
||||
|
||||
public function getDate() {
|
||||
return date('d.m.Y', strtotime($this->date_time));
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,16 @@
|
||||
<?php
|
||||
namespace app\models;
|
||||
|
||||
/**
|
||||
* Class Inquiries
|
||||
* @package app\models
|
||||
* @property $id
|
||||
* @property $name
|
||||
* @property $email
|
||||
* @property $operation
|
||||
* @property $error
|
||||
* @property $date_time
|
||||
*/
|
||||
class Inquiries extends _Base {
|
||||
|
||||
}
|
||||
@@ -0,0 +1,19 @@
|
||||
<?php
|
||||
|
||||
|
||||
namespace app\models;
|
||||
|
||||
/**
|
||||
* Class JoinToUs
|
||||
* @package app\models
|
||||
* @property $id
|
||||
* @property $name
|
||||
* @property $name_en
|
||||
* @property $text
|
||||
* @property $text_en
|
||||
* @property $external_link
|
||||
*/
|
||||
class JoinToUs extends _Base
|
||||
{
|
||||
|
||||
}
|
||||
@@ -0,0 +1,46 @@
|
||||
<?php
|
||||
|
||||
|
||||
namespace app\models;
|
||||
|
||||
/**
|
||||
* Class Library
|
||||
* @package app\models
|
||||
*
|
||||
* @property $object_id;
|
||||
* @property $lib_variant
|
||||
* @property $lib_format
|
||||
* @property $lib_identifier_isbn_print
|
||||
* @property $lib_identifier_isbn_online
|
||||
* @property $lib_identifier_issn_print
|
||||
* @property $lib_identifier_issn_online
|
||||
* @property $lib_identifier_doi
|
||||
* @property $lib_identifier_ismn
|
||||
* @property $lib_identifier_isan
|
||||
* @property $lib_author_compiler
|
||||
* @property $lib_author_translator
|
||||
* @property $lib_author_editor
|
||||
* @property $lib_author_reviewer
|
||||
* @property $lib_author_ilustrator
|
||||
* @property $lib_language
|
||||
* @property $lib_title_information
|
||||
* @property $lib_title_parallel
|
||||
* @property $lib_edition
|
||||
* @property $lib_publication_place
|
||||
* @property $lib_publication_date
|
||||
* @property $lib_publisher_name
|
||||
* @property $lib_series
|
||||
* @property $lib_url
|
||||
* @property $lib_article_source
|
||||
* @property $lib_article_pages
|
||||
* @property $lib_volume_source
|
||||
* @property $lib_periodical_dimensions
|
||||
* @property $lib_pages
|
||||
* @property $lib_citation_apa
|
||||
* @property $lib_citation_harvard
|
||||
*/
|
||||
|
||||
class Library extends _Base
|
||||
{
|
||||
|
||||
}
|
||||
@@ -0,0 +1,15 @@
|
||||
<?php
|
||||
|
||||
|
||||
namespace app\models;
|
||||
|
||||
/**
|
||||
* Class LibraryLog
|
||||
* @package app\models
|
||||
* @property $id
|
||||
* @property string $log
|
||||
*/
|
||||
class LibraryLog extends _Base
|
||||
{
|
||||
|
||||
}
|
||||
@@ -0,0 +1,38 @@
|
||||
<?php
|
||||
|
||||
|
||||
namespace app\models;
|
||||
|
||||
/**
|
||||
* Class Navigation
|
||||
* @package app\models
|
||||
* @property string $menu_type
|
||||
* @property string $name
|
||||
* @property string $ts_en_name
|
||||
* @property int $order_index
|
||||
* @property int $page_id
|
||||
* @property $url
|
||||
* @property $relation_type
|
||||
* @property $is_active
|
||||
* @property $in_submenu
|
||||
* [relations]
|
||||
* @property Pages $page
|
||||
*/
|
||||
class Navigation extends _Base
|
||||
{
|
||||
public function getPage() {
|
||||
return $this->hasOne(Pages::class, ['id' => 'page_id']);
|
||||
}
|
||||
|
||||
public function isRelationType($type) {
|
||||
$currentType = $this->relation_type ?? 'inner_page';
|
||||
$this->relation_type = $currentType;
|
||||
return $type == $currentType ? 'checked' : '';
|
||||
}
|
||||
public function isRelationTypeFor($type) {
|
||||
if($type != $this->relation_type) {
|
||||
return 'readonly class="disabled"';
|
||||
}
|
||||
return '';
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,28 @@
|
||||
<?php
|
||||
|
||||
namespace app\models;
|
||||
use app\models\register\Partner;
|
||||
|
||||
/**
|
||||
* Class News
|
||||
* @package app\models
|
||||
* @property $title
|
||||
* @property $text
|
||||
* @property $text_short
|
||||
* @property $ts_en_title
|
||||
* @property $ts_en_text
|
||||
* @property $ts_en_text_short
|
||||
* @property $media_key
|
||||
* @property $stream_url
|
||||
* @property $stream_access
|
||||
* @property $partner_id
|
||||
* @property Partner $partner
|
||||
* @property $is_for_publish
|
||||
* @property $article_key
|
||||
*/
|
||||
class News extends Articles
|
||||
{
|
||||
public function getPartner() {
|
||||
return $this->hasOne(Partner::class, ['id' => 'partner_id']);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,91 @@
|
||||
<?php
|
||||
|
||||
namespace app\models;
|
||||
|
||||
/**
|
||||
* Class ObjectTemplate
|
||||
* @package app\models
|
||||
* @property $id
|
||||
* @property $heritage_type
|
||||
* @property $name
|
||||
* @property $ts_en_name
|
||||
* @property $rr_ot_id
|
||||
* [Relations]
|
||||
* @property ObjectTemplateField[] $objectTemplateFields
|
||||
* @property CategoriesOt[] $categoryOts
|
||||
* @property array $categoryIds
|
||||
* @property string $categoryConcatList
|
||||
*/
|
||||
class ObjectTemplate extends _Base
|
||||
{
|
||||
|
||||
public function getCategoryOts()
|
||||
{
|
||||
return $this->hasMany(CategoriesOt::class, ['ot_id' => 'id']);
|
||||
}
|
||||
|
||||
public function getCategoryConcatList()
|
||||
{
|
||||
$categories = [];
|
||||
$index = 1;
|
||||
foreach ($this->categoryOts as $categoriesOt) {
|
||||
$main = $categoriesOt->category->mainCategory->name;
|
||||
$sub = $categoriesOt->category->name;
|
||||
$categories[] = '<div style="display: flex; background: #FFFFFF; padding: 3px; margin: 2px"><div>' . $index . '.</div><div>' . $main . ' - ' . $sub . '</div></div>';
|
||||
$index++;
|
||||
}
|
||||
return implode('', $categories);
|
||||
}
|
||||
|
||||
public function getCategoryIds()
|
||||
{
|
||||
$ids = [];
|
||||
foreach ($this->categoryOts as $cOt) {
|
||||
$ids[] = $cOt->sc_id;
|
||||
}
|
||||
return $ids;
|
||||
}
|
||||
|
||||
public function getObjectTemplateFields()
|
||||
{
|
||||
return $this->hasMany(ObjectTemplateField::class, ['ot_id' => 'id'])->orderBy(['order_index' => SORT_ASC])->all();
|
||||
}
|
||||
|
||||
public static function heritageTypes($id = null)
|
||||
{
|
||||
$types = [
|
||||
1 => 'Недвижимо наследсвто',
|
||||
2 => 'Движимо материално наследство',
|
||||
3 => 'Движимо нематериално наследство',
|
||||
4 => 'Природно наследство',
|
||||
];
|
||||
if ($id)
|
||||
return $types[$id];
|
||||
return $types;
|
||||
}
|
||||
|
||||
public static function heritageTypesByCategory()
|
||||
{
|
||||
$subCategoryId = null;
|
||||
if (!empty($_GET['q'])) {
|
||||
$f = explode('|', $_GET['q']);
|
||||
foreach ($f as $fkv) {
|
||||
$filter = explode(':', $fkv);
|
||||
if ($filter[0] == 'sc_id' && !empty($filter[1]))
|
||||
$subCategoryId = $filter[1];
|
||||
}
|
||||
}
|
||||
if ($subCategoryId) {
|
||||
$heritage_types = [];
|
||||
$CategoriesOts = CategoriesOt::find()->where(['sc_id' => $subCategoryId])->all();
|
||||
foreach ($CategoriesOts as $CategoriesOt) {
|
||||
$htId = $CategoriesOt->objectTemplate->heritage_type;
|
||||
if (!isset($heritage_type[$htId])) {
|
||||
$heritage_types[$htId] = self::heritageTypes($htId);
|
||||
}
|
||||
}
|
||||
return $heritage_types;
|
||||
}
|
||||
return self::heritageTypes();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,121 @@
|
||||
<?php
|
||||
|
||||
|
||||
namespace app\models;
|
||||
|
||||
/**
|
||||
* Class ObjectTemplateField
|
||||
* @package app\models
|
||||
* @property $ot_id
|
||||
* @property $parent_id
|
||||
* @property $rr_otf_id
|
||||
* @property $rr_otf_option_id
|
||||
* @property $name
|
||||
* @property $ts_en_name
|
||||
* @property $user_interface_type
|
||||
* @property $common_field_id
|
||||
* @property $data_type
|
||||
* @property $order_index
|
||||
* @property $is_filter
|
||||
* [Relations]
|
||||
* @property ObjectTemplate $objectTemplate
|
||||
* @property ObjectTemplateField[] $fieldOptions
|
||||
* @property CommonFields $commonField
|
||||
*/
|
||||
class ObjectTemplateField extends _Base
|
||||
{
|
||||
public function getObjectTemplate()
|
||||
{
|
||||
return $this->hasOne(ObjectTemplate::class, ['id' => 'ot_id']);
|
||||
}
|
||||
|
||||
public function getCommonField() {
|
||||
return $this->hasOne(CommonFields::class, ['id' => 'common_field_id']);
|
||||
}
|
||||
|
||||
public function getFieldOptions()
|
||||
{
|
||||
return $this->hasMany(ObjectTemplateField::class, ['parent_id' => 'id']);
|
||||
}
|
||||
|
||||
public function fieldOptionsAsJson($fieldOptions)
|
||||
{
|
||||
if (!empty($fieldOptions)) {
|
||||
$data = [];
|
||||
/** @var \app\models\ObjectTemplateField $fieldOption */
|
||||
foreach ($fieldOptions as $fieldOption) {
|
||||
$data[] = [
|
||||
'id' => $fieldOption->id,
|
||||
'bg' => $fieldOption->name,
|
||||
'en' => $fieldOption->ts_en_name
|
||||
];
|
||||
}
|
||||
return json_encode($data);
|
||||
}
|
||||
|
||||
return '[]';
|
||||
}
|
||||
|
||||
public static function dataType($id, $value = null, $html = true, $optionOnly = false)
|
||||
{
|
||||
$types = [
|
||||
'string' => 'текстов низ',
|
||||
'int' => 'числова стойност',
|
||||
];
|
||||
|
||||
if ($html) {
|
||||
$select = !$optionOnly ? '<select name="sub[' . $id . '][data_type]">' : '';
|
||||
foreach ($types as $key => $val) {
|
||||
$select .= '<option ' . ($value == $key ? 'selected' : '') . ' value="' . $key . '">' . $val . '</option>';
|
||||
}
|
||||
$select .= !$optionOnly ? '</select>' : '';
|
||||
return $select;
|
||||
}
|
||||
if ($value) return $types[$value];
|
||||
|
||||
return $types;
|
||||
}
|
||||
|
||||
public static function userInterfaceType($value = null, $html = true, $id = null, $optionOnly = null)
|
||||
{
|
||||
$types = [
|
||||
'year' => 'Запис на година',
|
||||
'date' => 'Запис на дата',
|
||||
'geo_coordinates' => 'Географски кординати',
|
||||
'map'=>'Запис на локация по карта',
|
||||
'settlements_data' => 'Избор от списък с градове и села',
|
||||
'input_simple' => 'Поле (без превод)',
|
||||
'input' => 'Поле (двуезично)',
|
||||
'text' => 'Текст (двуезично)',
|
||||
'text_redactor' => 'Текст с редактор (двуезично)',
|
||||
'list_simple' => 'Избор с опции (без превод)',
|
||||
'list' => 'Избор с опции (двуезично)'
|
||||
];
|
||||
|
||||
foreach (CommonFields::find()->where(['IS', 'parent_id', NULL])->all() as $commonField) {
|
||||
$types[$commonField->id] = "(Общи номенклатури) ". $commonField->name;
|
||||
}
|
||||
|
||||
$select = $optionOnly ? '' : '<select data-id="' . $id . '" class="type-value-selector" name="sub[' . $id . '][user_interface_type]">';
|
||||
$select .= '<option selected disabled value="">-- Избери тип --</option>';
|
||||
foreach ($types as $key => $text) {
|
||||
$selected = $value && $value == $key ? 'selected' : '';
|
||||
$select .= '<option ' . $selected . ' value="' . $key . '">' . $text . '</option>';
|
||||
}
|
||||
$select .= $optionOnly ? '' : '</select>';
|
||||
|
||||
if ($html)
|
||||
return $select;
|
||||
if ($value)
|
||||
return $types[$value];
|
||||
|
||||
return $types;
|
||||
}
|
||||
|
||||
|
||||
public static function getNextOrderIndex($ot_id)
|
||||
{
|
||||
$last = self::find()->where(['ot_id' => $ot_id])->orderBy(['order_index' => SORT_DESC])->one();
|
||||
return $last && $last->order_index ? $last->order_index + 1 : 1;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,165 @@
|
||||
<?php
|
||||
|
||||
|
||||
namespace app\models;
|
||||
|
||||
use yii\base\BaseObject;
|
||||
|
||||
/**
|
||||
* Class Objects
|
||||
* @package app\models
|
||||
* @property int $sc_id
|
||||
* @property int $ot_id
|
||||
* @property int $partner_id
|
||||
* @property string $name
|
||||
* @property string $annotation
|
||||
* @property string $description
|
||||
* [RELATIONS]
|
||||
* @property ObjectTemplate $objectTemplate
|
||||
* @property Categories $subCategory
|
||||
* @property ObjectsField[] $objectFields
|
||||
* @property Partner $partner
|
||||
* @property \app\models\History $history
|
||||
* @property \app\models\CollectionsObjects[] $collections
|
||||
* @property string $collectionConcatList
|
||||
*/
|
||||
class Objects extends _Base
|
||||
{
|
||||
public function getHistory()
|
||||
{
|
||||
return $this->hasMany(History::class, ['history_id' => 'id'])->where(['table_name' => 'objects', 'action' => 1])->one();
|
||||
}
|
||||
|
||||
public function getObjectTemplate()
|
||||
{
|
||||
return $this->hasOne(ObjectTemplate::class, ['id' => 'ot_id']);
|
||||
}
|
||||
|
||||
public function getPartner()
|
||||
{
|
||||
return $this->hasOne(Partner::class, ['id' => 'partner_id']);
|
||||
}
|
||||
|
||||
public function getSubCategory()
|
||||
{
|
||||
return $this->hasOne(Categories::class, ['id' => 'sc_id']);
|
||||
}
|
||||
|
||||
public function getObjectFields()
|
||||
{
|
||||
return $this->hasMany(ObjectsField::class, ['object_id' => 'id'])
|
||||
->joinWith('objectTemplateField')
|
||||
->orderBy(['order_index' => SORT_ASC])
|
||||
->all();
|
||||
}
|
||||
|
||||
public function setObjectFields($p)
|
||||
{
|
||||
if ($this->ot_id) {
|
||||
if (empty($_GET['id'])) {
|
||||
foreach ($this->objectTemplate->objectTemplateFields as $templateField) {
|
||||
$objectField = new ObjectsField();
|
||||
$objectField->object_id = $this->id;
|
||||
$objectField->object_tf_id = $templateField->id;
|
||||
$objectField->save();
|
||||
}
|
||||
} else {
|
||||
if (empty($p->{'new_object_fields'})) {
|
||||
$obf = $p->{'obf'};
|
||||
$idsToUpdate = (array_keys($obf));
|
||||
$objectFields = ObjectsField::find()->where(['IN', 'id', $idsToUpdate])->all();
|
||||
foreach ($objectFields as $objectField) {
|
||||
if (!empty($obf{$objectField->id}{'option_tf_id'})) $objectField->option_tf_id = $obf{$objectField->id}{'option_tf_id'};
|
||||
if (!empty($obf{$objectField->id}{'value'})) $objectField->value = $obf{$objectField->id}{'value'};
|
||||
if (!empty($obf{$objectField->id}{'value_en'})) $objectField->value_en = $obf{$objectField->id}{'value_en'};
|
||||
if (!empty($obf{$objectField->id}{'date'})) $objectField->date = $obf{$objectField->id}{'date'};
|
||||
if (!empty($obf{$objectField->id}{'geo_lon'})) $objectField->geo_lon = $obf{$objectField->id}{'geo_lon'};
|
||||
if (!empty($obf{$objectField->id}{'geo_lat'})) $objectField->geo_lat = $obf{$objectField->id}{'geo_lat'};
|
||||
if (!empty($obf{$objectField->id}{'settlement_id'})) $objectField->settlement_id = $obf{$objectField->id}{'settlement_id'};
|
||||
if (!empty($obf{$objectField->id}{'common_field_id'})) $objectField->common_field_id = $obf{$objectField->id}{'common_field_id'};
|
||||
|
||||
$objectField->save();
|
||||
}
|
||||
} else {
|
||||
foreach ($this->newTemplateFields() as $id => $field) {
|
||||
$newObjectField = new ObjectsField();
|
||||
$newObjectField->object_tf_id = $id;
|
||||
$newObjectField->object_id = $this->id;
|
||||
$newObjectField->save();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public function newTemplateFields()
|
||||
{
|
||||
$objectFieldIds = [];
|
||||
$missing = [];
|
||||
foreach ($this->objectFields as $field) $objectFieldIds[] = $field->object_tf_id;
|
||||
foreach ($this->objectTemplate->objectTemplateFields as $templateField) {
|
||||
if (!in_array($templateField->id, $objectFieldIds)) {
|
||||
$userInterface = ObjectTemplateField::userInterfaceType($templateField->user_interface_type, false);
|
||||
$missing[$templateField->id] = [
|
||||
'name' => $templateField->name,
|
||||
'type' => $userInterface
|
||||
];
|
||||
}
|
||||
}
|
||||
return $missing;
|
||||
}
|
||||
|
||||
public function setCollections($p)
|
||||
{
|
||||
$ids = $p->{'collections'} ?? [];
|
||||
|
||||
$related = CollectionsObjects::find()->where(['object_id' => $this->id])->all();
|
||||
$remain = [];
|
||||
foreach ($related as $cto) {
|
||||
if(in_array($cto->id, $ids)) {
|
||||
$remain[] = $cto->id;
|
||||
} else {
|
||||
$cto->delete();
|
||||
}
|
||||
}
|
||||
foreach ($ids as $id) {
|
||||
if(!in_array($id, $remain)) {
|
||||
$newCto = new CollectionsObjects();
|
||||
$newCto->object_id = $this->id;
|
||||
$newCto->collection_id = $id;
|
||||
$newCto->category_id = $this->subCategory->id;
|
||||
$newCto->save();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public function getCollections()
|
||||
{
|
||||
return $this->hasMany(CollectionsObjects::class, ['object_id' => 'id']);
|
||||
}
|
||||
|
||||
public function getCollectionsSelectList()
|
||||
{
|
||||
$ids = [];
|
||||
foreach ($this->collections as $collection) {
|
||||
$ids[] = $collection->collection_id;
|
||||
}
|
||||
$list = [];
|
||||
foreach (Collections::find()->all() as $item) {
|
||||
$list[$item->id] = [
|
||||
'name' => $item->name,
|
||||
'selected' => in_array($item->id, $ids)
|
||||
];
|
||||
}
|
||||
return $list;
|
||||
}
|
||||
|
||||
public function getCollectionConcatList() {
|
||||
$collections = [];
|
||||
foreach ($this->collections as $collection) {
|
||||
$collections[] = $collection->collection->name;
|
||||
}
|
||||
return implode(', ', $collections);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,153 @@
|
||||
<?php
|
||||
|
||||
namespace app\models;
|
||||
|
||||
/**
|
||||
* Class ObjectsField
|
||||
* @package app\models
|
||||
* @property $object_id
|
||||
* @property $object_tf_id
|
||||
* @property $option_tf_id
|
||||
* @property $value
|
||||
* @property $value_en
|
||||
* @property $date
|
||||
* @property $geo_lon
|
||||
* @property $geo_lat
|
||||
* @property $settlement_id
|
||||
* @property $common_field_id
|
||||
* [RELATION]
|
||||
* @property Objects $object
|
||||
* @property ObjectTemplateField $objectTemplateField
|
||||
* @property ObjectTemplateField $optionTemplateField
|
||||
*/
|
||||
class ObjectsField extends _Base
|
||||
{
|
||||
public function getObject()
|
||||
{
|
||||
return $this->hasOne(Objects::class, ['id' => 'object_id']);
|
||||
}
|
||||
|
||||
public function getObjectTemplateField()
|
||||
{
|
||||
return $this->hasOne(ObjectTemplateField::class, ['id' => 'object_tf_id']);
|
||||
}
|
||||
|
||||
public function getOptionTemplateField()
|
||||
{
|
||||
return $this->hasOne(ObjectTemplateField::class, ['id' => 'option_tf_id']);
|
||||
}
|
||||
|
||||
public function getUserInterface()
|
||||
{
|
||||
$objectTemplateField = $this->objectTemplateField;
|
||||
if ($objectTemplateField) {
|
||||
switch ($objectTemplateField->user_interface_type) {
|
||||
case 'input_simple':
|
||||
return '<div class="flex row"><div class="c6 right10"><label>' . $objectTemplateField->name . '</label><input name="obf['.$this->id.'][value]" value="'.$this->value.'"></div></div>';
|
||||
case 'input':
|
||||
return '
|
||||
<label>' . $objectTemplateField->name . '</label>
|
||||
<div class="flex row row-panel">
|
||||
<div class="c6 right10"><label>[bg]</label><input name="obf['.$this->id.'][value]" value="'.$this->value.'"></div>
|
||||
<div class="c6"><label>[en]</label><input name="obf['.$this->id.'][value_en]" value="'.$this->value.'"></div>
|
||||
</div>';
|
||||
case 'list':
|
||||
case 'list_simple':
|
||||
$html = '<div class="flex row">';
|
||||
$html .= '<div class="c6 right10">';
|
||||
$html .= '<label>' . $objectTemplateField->name . '</label>';
|
||||
$html .= '<select name="obf['.$this->id.'][option_tf_id]">';
|
||||
$html .= '<option value="">-- Избери ' . mb_strtolower($objectTemplateField->name) . ' --</option>';
|
||||
foreach ($objectTemplateField->fieldOptions as $option) {
|
||||
$html .= '<option '.($option->id == $this->option_tf_id ? 'selected' : '').' value="' . $option->id . '">' . $option->name . '</option>';
|
||||
}
|
||||
$html .= '</select>';
|
||||
$html .= '</div>';
|
||||
$html .= '</div>';
|
||||
return $html;
|
||||
|
||||
case 'language':
|
||||
$html = '<div class="flex row">';
|
||||
$html .= '<div class="c6 right10">';
|
||||
$html .= '<label>' . $objectTemplateField->name . '</label>';
|
||||
$html .= '<select name="obf['.$this->id.'][language_id]">';
|
||||
$html .= '<option value="">-- Избери ' . mb_strtolower($objectTemplateField->name) . ' --</option>';
|
||||
$html .= '<option value="1">Български</option>';
|
||||
$html .= '<option value="2">Английски</option>';
|
||||
$html .= '<option value="3">Руски</option>';
|
||||
$html .= '</select>';
|
||||
$html .= '</div>';
|
||||
$html .= '</div>';
|
||||
return $html;
|
||||
case 'text':
|
||||
$html = '<label>' . $objectTemplateField->name . '</label>';
|
||||
$html .= '<div class="flex row row-panel">';
|
||||
$html .= '<div class="c6 right10">';
|
||||
$html .= '<label>[bg]</label>';
|
||||
$html .= '<textarea name="obf[' . $this->id . '][value]">'.$this->value.'</textarea>';
|
||||
$html .= '</div>';
|
||||
$html .= '<div class="c6">';
|
||||
$html .= '<label>[en]</label>';
|
||||
$html .= '<textarea name="obf[' . $this->id . '][value_en]">'.$this->value_en.'</textarea>';
|
||||
$html .= '</div>';
|
||||
$html .= '</div>';
|
||||
return $html;
|
||||
case 'text_redactor':
|
||||
$html = '<label>' . $objectTemplateField->name . '</label>';
|
||||
$html .= '<div class="flex row row-panel">';
|
||||
$html .= '<div class="c6 right10">';
|
||||
$html .= '<label>[bg]</label>';
|
||||
$html .= '<textarea class="ckEditor" name="obf[' . $this->id . '][value]">'.$this->value.'</textarea>';
|
||||
$html .= '</div>';
|
||||
$html .= '<div class="c6">';
|
||||
$html .= '<label>[en]</label>';
|
||||
$html .= '<textarea class="ckEditor" name="obf[' . $this->id . '][value_en]">'.$this->value_en.'</textarea>';
|
||||
$html .= '</div>';
|
||||
$html .= '</div>';
|
||||
return $html;
|
||||
case 'year':
|
||||
return '<div class="flex row"><div class="c6 right10"><label>' . $objectTemplateField->name . '</label><input data-format="integer" data-max="'.date('Y').'" name="obf[' . $this->id . '][value]" value="'.$this->value.'"></div></div>';
|
||||
case 'date':
|
||||
return '<div class="flex row"><div class="c6 right10"><label>' . $objectTemplateField->name . '</label><input type="hidden" data-format="date" name="obf[' . $this->id . '][date]" value="'.$this->date.'"></div></div>';
|
||||
case 'geo_coordinates':
|
||||
return '
|
||||
<label>' . $objectTemplateField->name . '</label>
|
||||
<div class="flex row row-panel">
|
||||
<div class="c6 right10"><label>Географска дължина [lon]</label><input data-format="double" name="obf['.$this->id.'][geo_lon]" value="'.$this->geo_lon.'"></div>
|
||||
<div class="c6"><label>Географска ширина [lat]</label><input data-format="double" name="obf['.$this->id.'][geo_lat]" value="'.$this->geo_lat.'"></div>
|
||||
</div>';
|
||||
case 'map':
|
||||
return
|
||||
'<div class="row">
|
||||
<div class="c8 right10" style="position: relative">
|
||||
<label>' . $objectTemplateField->name . '</label><input placeholder="Избери ' . $objectTemplateField->name . '" class="sbr" data-sbr-name="obf[' . $this->id . '][settlement_id]" data-sbr-value="' . $this->settlement_id . '"><i style="position: absolute; right: 5px; top: 33px; font-size: 23px; ; color: var(--base-background-dark)" class="la la-map-marked"></i>
|
||||
</div>
|
||||
<div class="c12 top15"><div class="map" style="width: 100%; height: 350px; background: #cccccc"></div></div>
|
||||
</div>';
|
||||
case 'settlements_data':
|
||||
return '<div class="flex row"><div class="c6 right10" style="position: relative"><label>' . $objectTemplateField->name . '</label><input placeholder="Избери '.$objectTemplateField->name.'" class="sbr" data-sbr-name="obf[' . $this->id . '][settlement_id]" data-sbr-value="'.$this->settlement_id.'"><i style="position: absolute; right: 5px; top: 33px; font-size: 23px; ; color: var(--base-background-dark)" class="la la-map-marked"></i></div></div>';
|
||||
|
||||
default:
|
||||
//return '';
|
||||
}
|
||||
|
||||
if($objectTemplateField->common_field_id) {
|
||||
$html = '<div class="flex row">';
|
||||
$html .= '<div class="c6 right10">';
|
||||
$html .= '<label>' . $objectTemplateField->name . '</label>';
|
||||
$html .= '<select name="obf['.$this->id.'][common_field_id]">';
|
||||
$html .= '<option value="">-- Избери ' . mb_strtolower($objectTemplateField->name) . ' --</option>';
|
||||
|
||||
foreach ($objectTemplateField->commonField->options as $option) {
|
||||
$html .= '<option '.($option->id == $this->common_field_id ? 'selected' : '').' value="'.$option->id.'">'.$option->name.'</option>';
|
||||
}
|
||||
|
||||
$html .= '</select>';
|
||||
$html .= '</div>';
|
||||
$html .= '</div>';
|
||||
return $html;
|
||||
}
|
||||
return '';
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,107 @@
|
||||
<?php
|
||||
|
||||
|
||||
namespace app\models;
|
||||
|
||||
use app\models\parsed\CartModel;
|
||||
use app\services\Cart;
|
||||
|
||||
/**
|
||||
* Class Order
|
||||
* @package app\models
|
||||
* @property $id
|
||||
* @property $user_id
|
||||
* @property $order_date
|
||||
* @property $total_price
|
||||
* @property $user_email
|
||||
* @property $user_name
|
||||
* @property \app\models\UserPublic $user
|
||||
* @property \app\models\OrderPayment $payment
|
||||
* @property \app\models\OrderBooking[] $booking
|
||||
*/
|
||||
class Order extends _Base
|
||||
{
|
||||
public function getUser()
|
||||
{
|
||||
return $this->hasOne(UserPublic::class, ['id' => 'user_id']);
|
||||
}
|
||||
|
||||
public static function record($data, $user)
|
||||
{
|
||||
$cart_data = json_decode($data['cart_data']);
|
||||
$invoice_data = json_decode($data['invoice_data']);
|
||||
if (sizeof($cart_data) == 0) {
|
||||
header('Location: /');
|
||||
exit;
|
||||
}
|
||||
$order = new Order();
|
||||
$order->user_id = $user->id;
|
||||
$order->order_date = date('Y-m-d H:i:s');
|
||||
|
||||
$order->save();
|
||||
$totalPrice = 0;
|
||||
|
||||
foreach ($cart_data as $cartElement) {
|
||||
$cartObject = Cart::decodeKey($cartElement);
|
||||
//Order Booking
|
||||
|
||||
if ($cartObject->model == OrderBooking::class) {
|
||||
$booking = OrderBooking::findOne($cartObject->id);
|
||||
if ($booking) {
|
||||
$booking->order_id = $order->id;
|
||||
$booking->save();
|
||||
$totalPrice += $booking->single_price;
|
||||
}
|
||||
} else {
|
||||
|
||||
/** @var RegisterObjects|\app\models\register\Collections|Subscriptions $modelClass */
|
||||
$modelClass = $cartObject->model;
|
||||
$model = $modelClass::findOne($cartObject->id);
|
||||
if ($model) {
|
||||
$cartModel = $model->setCart(new CartModel());
|
||||
$product = new OrderProduct();
|
||||
$product->name_bg = $cartModel->name_bg;
|
||||
$product->name_en = $cartModel->name_en;
|
||||
$product->text_bg = $cartModel->text_bg;
|
||||
$product->text_en = $cartModel->text_en;
|
||||
$product->order_id = $order->id;
|
||||
$product->price = $cartModel->price;
|
||||
$product->model_class = $modelClass;
|
||||
$product->model_id = $model->id;
|
||||
$product->save();
|
||||
$totalPrice += $cartModel->price;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
OrderInvoice::record($invoice_data, $order->id);
|
||||
$order->total_price = $totalPrice;
|
||||
$order->save();
|
||||
return $order;
|
||||
}
|
||||
|
||||
public function getDescription()
|
||||
{
|
||||
return 'HeritageBG order';
|
||||
}
|
||||
|
||||
public function getPayment()
|
||||
{
|
||||
return $this->hasOne(OrderPayment::class, ['order_id' => 'id']);
|
||||
}
|
||||
|
||||
public function getBooking()
|
||||
{
|
||||
return $this->hasMany(OrderBooking::class, ['order_id' => 'id']);
|
||||
}
|
||||
|
||||
public function statusStr()
|
||||
{
|
||||
$lg = \Yii::$app->language;
|
||||
if($this->payment && $this->payment->status == 'PAID') {
|
||||
return $lg == 'en' ? 'Paid' : 'Платено';
|
||||
}
|
||||
return $lg == 'en' ? 'Payment pending' : 'В очакване на плащане';
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,93 @@
|
||||
<?php
|
||||
|
||||
|
||||
namespace app\models;
|
||||
|
||||
use app\models\parsed\CartInterface;
|
||||
use app\models\parsed\CartModel;
|
||||
use app\services\Cart;
|
||||
use app\services\Formatter;
|
||||
use app\services\JWT;
|
||||
use Prophecy\Comparator\Factory;
|
||||
|
||||
/**
|
||||
* Class OrderBooking
|
||||
* @package app\models
|
||||
* @property $id
|
||||
* @property $datetime
|
||||
* @property $name_bg
|
||||
* @property $name_en
|
||||
* @property $description_bg
|
||||
* @property $description_en
|
||||
* @property $single_price
|
||||
* @property $tickets_count
|
||||
* @property $validated_count
|
||||
* @property $last_validation_time
|
||||
* @property $event_id
|
||||
* @property $ticket_id
|
||||
* @property \app\models\PriceObject $ticketType
|
||||
* @property $order_id
|
||||
* @property $cart_key
|
||||
* @property \app\models\Events $event
|
||||
* @property \app\models\Order $order
|
||||
*/
|
||||
class OrderBooking extends _Base
|
||||
{
|
||||
|
||||
public function getOrder() {
|
||||
return $this->hasOne(Order::class, ['id' => 'order_id']);
|
||||
}
|
||||
public function getEvent()
|
||||
{
|
||||
return $this->hasOne(Events::class, ['id' => 'event_id']);
|
||||
}
|
||||
|
||||
public function getTicketType()
|
||||
{
|
||||
return $this->hasOne(PriceObject::class, ['id' => 'ticket_id']);
|
||||
}
|
||||
|
||||
public function formatedHtmlDate()
|
||||
{
|
||||
if ($this->datetime)
|
||||
$datetime = date_create($this->datetime);
|
||||
return $datetime->format('d.m.Y H:i');
|
||||
}
|
||||
|
||||
public function getHashedId()
|
||||
{
|
||||
return 'qrnasledstvo_'.base64_encode('nasledsto-ticket_' . $this->id);
|
||||
}
|
||||
|
||||
public static function getBookingByHashId($hashId)
|
||||
{
|
||||
$idStr = base64_decode($hashId);
|
||||
$exp = explode('_', $idStr);
|
||||
$id = $exp[1] ?? null;
|
||||
if ($id) {
|
||||
$booking = OrderBooking::findOne($id);
|
||||
if ($booking)
|
||||
return $booking;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public function responseData()
|
||||
{
|
||||
|
||||
$lg = \Yii::$app->language;
|
||||
return [
|
||||
'id' => $this->id,
|
||||
'ticket_type' => $this->{'name_' . $lg},
|
||||
'event' => $this->event->title(),
|
||||
'event_img' => $this->event->image('16:11'),
|
||||
'single_price' => $this->single_price,
|
||||
'datetime' => $this->formatedHtmlDate(),
|
||||
'hashed_id' => $this->getHashedId(),
|
||||
'tickets_count' => $this->tickets_count,
|
||||
'validated' => $this->validated_count ?? 0,
|
||||
'to_validate' => $this->tickets_count - $this->validated_count,
|
||||
'last_validation_time' => date('d.m.Y H:i:s')
|
||||
];
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,69 @@
|
||||
<?php
|
||||
|
||||
|
||||
namespace app\models;
|
||||
|
||||
/**
|
||||
* Class OrderInvoice
|
||||
* @package app\models
|
||||
* @property $id;
|
||||
* @property $order_id
|
||||
* @property $invoice_data_type
|
||||
* @property $first_name
|
||||
* @property $last_name
|
||||
* @property $country
|
||||
* @property $post_code
|
||||
* @property $city
|
||||
* @property $address
|
||||
* @property $company_name
|
||||
* @property $eik
|
||||
* @property $mol
|
||||
* @property $is_by_vat
|
||||
*/
|
||||
class OrderInvoice extends _Base
|
||||
{
|
||||
public static function record($data, $order_id)
|
||||
{
|
||||
$invoice = new OrderInvoice();
|
||||
|
||||
$invoice->order_id = $order_id;
|
||||
|
||||
if (!empty($data->{'invoice_data_type'}))
|
||||
$invoice->invoice_data_type = $data->{'invoice_data_type'};
|
||||
|
||||
if (!empty($data->{'first_name'}))
|
||||
$invoice->first_name = $data->{'first_name'};
|
||||
|
||||
if (!empty($data->{'last_name'}))
|
||||
$invoice->last_name = $data->{'last_name'};
|
||||
|
||||
if (!empty($data->{'country'}))
|
||||
$invoice->country = $data->{'country'};
|
||||
|
||||
if (!empty($data->{'post_code'}))
|
||||
$invoice->post_code = $data->{'post_code'};
|
||||
|
||||
if (!empty($data->{'city'}))
|
||||
$invoice->city = $data->{'city'};
|
||||
|
||||
if (!empty($data->{'address'}))
|
||||
$invoice->address = $data->{'address'};
|
||||
|
||||
if (!empty($data->{'company_name'}))
|
||||
$invoice->company_name = $data->{'company_name'};
|
||||
|
||||
if (!empty($data->{'eik'}))
|
||||
$invoice->eik = $data->{'eik'};
|
||||
|
||||
if (!empty($data->{'mol'}))
|
||||
$invoice->mol = $data->{'mol'};
|
||||
|
||||
|
||||
if (!empty($data->{'is_by_vat'}))
|
||||
$invoice->is_by_vat = $data->{'is_by_vat'};
|
||||
|
||||
$invoice->save();
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,24 @@
|
||||
<?php
|
||||
|
||||
|
||||
namespace app\models;
|
||||
|
||||
/**
|
||||
* Class OrderPayment
|
||||
* @package app\models
|
||||
* @property $id
|
||||
* @property $order_id
|
||||
* @property $payment_method
|
||||
* @property $client_email
|
||||
* @property $amount
|
||||
* @property $status
|
||||
* @property $response_message
|
||||
* @property $response_time
|
||||
* @property Order $order
|
||||
*/
|
||||
class OrderPayment extends _Base
|
||||
{
|
||||
public function getOrder() {
|
||||
return $this->hasOne(Order::class, ['id' => 'order_id']);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,14 @@
|
||||
<?php
|
||||
namespace app\models;
|
||||
|
||||
/**
|
||||
* Class OrderPaymentNotification
|
||||
* @package app\models
|
||||
* @property $id;
|
||||
* @property $message
|
||||
* @property $date
|
||||
*/
|
||||
class OrderPaymentNotification extends _Base
|
||||
{
|
||||
|
||||
}
|
||||
@@ -0,0 +1,25 @@
|
||||
<?php
|
||||
|
||||
|
||||
namespace app\models;
|
||||
|
||||
/**
|
||||
* Class OrderModel
|
||||
* @package app\models
|
||||
* @property $id
|
||||
* @property $order_id
|
||||
* @property $name_bg
|
||||
* @property $name_en
|
||||
* @property $text_bg
|
||||
* @property $text_en
|
||||
* @property $price
|
||||
* @property $model_class
|
||||
* @property $model_id
|
||||
* @property \app\models\Order $order
|
||||
*/
|
||||
class OrderProduct extends _Base
|
||||
{
|
||||
public function getOrder() {
|
||||
return $this->hasOne(Order::class, ['id' => 'order_id']);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,38 @@
|
||||
<?php
|
||||
|
||||
|
||||
namespace app\models;
|
||||
|
||||
/**
|
||||
* Class Pages
|
||||
* @package app\models
|
||||
* @property $name
|
||||
* @property $name_en
|
||||
* @property $text
|
||||
* @property $text_en
|
||||
* @property $slug
|
||||
* @property $slug_en
|
||||
* @property $id
|
||||
* @property $media_key
|
||||
* @property \app\models\Contacts $contact
|
||||
* @property $price
|
||||
* @property $months
|
||||
*/
|
||||
class Pages extends _Base
|
||||
{
|
||||
public static function getList($id = null)
|
||||
{
|
||||
$pages = [];
|
||||
foreach (self::find()->all() as $page) {
|
||||
if ($page->slug && $page->slug_en)
|
||||
$pages[$page->id] = $page->name;
|
||||
}
|
||||
if ($id && !empty($pages[$id]))
|
||||
return $pages[$id];
|
||||
return $pages;
|
||||
}
|
||||
|
||||
public function getContact() {
|
||||
return $this->hasOne(Contacts::class, ['page_id' => 'id']);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,20 @@
|
||||
<?php
|
||||
namespace app\models;
|
||||
|
||||
/**
|
||||
* Class Partner
|
||||
* @package app\models
|
||||
* @property int $id
|
||||
* @property string $name
|
||||
* @property string $key
|
||||
*/
|
||||
class Partner extends _Base
|
||||
{
|
||||
public static function partnerList() {
|
||||
$partnerList = [];
|
||||
foreach (self::find()->all() as $partner) {
|
||||
$partnerList[$partner->id] = $partner->name;
|
||||
}
|
||||
return $partnerList;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,100 @@
|
||||
<?php
|
||||
|
||||
|
||||
namespace app\models;
|
||||
|
||||
/**
|
||||
* Class Positions
|
||||
* @package app\models
|
||||
* @property $id
|
||||
* @property $group_name
|
||||
* @property $class_name
|
||||
* @property $group_id
|
||||
* @property $position_article_key
|
||||
* @property $event_id
|
||||
* @property $campaign_id
|
||||
* @property Positions[] $positions
|
||||
* @property int $positionsCount
|
||||
* @property News $news;
|
||||
* @property Events $event
|
||||
* @property Campaigns $campaign
|
||||
* @property string $article
|
||||
* @property Articles $articleModel
|
||||
* @property int $order_index
|
||||
*/
|
||||
class Positions extends _Base
|
||||
{
|
||||
public static function getArticleTypeIds()
|
||||
{
|
||||
return ['news_id', 'event_id', 'campaign_id'];
|
||||
}
|
||||
|
||||
public function getPositions()
|
||||
{
|
||||
return $this->hasMany(Positions::class, ['group_id' => 'id'])->orderBy(['order_index' => SORT_ASC])->all();
|
||||
}
|
||||
|
||||
public function getPositionsCount()
|
||||
{
|
||||
return $this->hasMany(Positions::class, ['group_id' => 'id'])->count();
|
||||
}
|
||||
|
||||
public function getArticleModel()
|
||||
{
|
||||
return $this->hasOne(Articles::class, ['key' => 'position_article_key']);
|
||||
}
|
||||
|
||||
public function getArticle()
|
||||
{
|
||||
if ($this->position_article_key) {
|
||||
$articleModel = $this->articleModel;
|
||||
$table = explode('_', $this->position_article_key);
|
||||
|
||||
switch ($table[0]) {
|
||||
case 'news':
|
||||
$src = $articleModel->news->getSrcOfSingleImage('title_news_image', 'thumb');
|
||||
return $this->articleTableRowPreview(
|
||||
'Новина: (№ ' . $articleModel->news->id . ')',
|
||||
$articleModel->news->title,
|
||||
$src
|
||||
);
|
||||
case 'events':
|
||||
$src = $articleModel->events->getSrcOfSingleImage('title_event_image', 'thumb');
|
||||
return $this->articleTableRowPreview(
|
||||
'Събитие: (№ ' . $articleModel->events->id . ')',
|
||||
$articleModel->events->title,
|
||||
$src
|
||||
);
|
||||
case 'campaigns':
|
||||
$src = $articleModel->campaigns->getSrcOfSingleImage('title_campaigns_image', 'thumb');
|
||||
return $this->articleTableRowPreview(
|
||||
'Кампания: (№ ' . $articleModel->campaigns->id . ')',
|
||||
$articleModel->campaigns->title,
|
||||
$src
|
||||
);
|
||||
}
|
||||
}
|
||||
return '<span style="color: var(--base-background)">Няма закачен материал</span>';
|
||||
}
|
||||
|
||||
private function articleTableRowPreview($type, $title, $src_img)
|
||||
{
|
||||
$html = '<div class="flex">';
|
||||
if ($src_img) {
|
||||
$html .= '<img src="' . $src_img . '" style="height: 50px; display:block">';
|
||||
}
|
||||
$html .= '<div style="margin-left: 5px">';
|
||||
$html .= '<div style="font-weight: bold; color: var(--base-background-dark)">' . $type . '</div>';
|
||||
$html .= '<div>' . $title . '</div>';
|
||||
$html .= '</div>';
|
||||
$html .= '</div>';
|
||||
return $html;
|
||||
}
|
||||
|
||||
public function getNextOrderIndex()
|
||||
{
|
||||
$size = sizeof($this->positions);
|
||||
$last = $this->positions[$size - 1];
|
||||
return $last->order_index + 1;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,16 @@
|
||||
<?php
|
||||
namespace app\models;
|
||||
|
||||
/**
|
||||
* Class PriceObject
|
||||
* @package app\models
|
||||
* @property $id
|
||||
* @property $text_bg
|
||||
* @property $text_en
|
||||
* @property $price
|
||||
* @property $event_id
|
||||
*/
|
||||
class PriceObject extends _Base
|
||||
{
|
||||
|
||||
}
|
||||
@@ -0,0 +1,40 @@
|
||||
<?php
|
||||
|
||||
|
||||
namespace app\models;
|
||||
|
||||
/**
|
||||
* Class Projects
|
||||
* @package app\models
|
||||
* @property $id
|
||||
* @property $title
|
||||
* @property $text
|
||||
* @property $text_short
|
||||
* @property $text_contract
|
||||
* @property $ts_en_tile
|
||||
* @property $ts_en_text
|
||||
* @property $ts_en_text_short
|
||||
* @property $ts_en_contract
|
||||
* @property $period
|
||||
* @property $website
|
||||
* @property $publications
|
||||
* @property $media_key
|
||||
* @property $document_key
|
||||
* @property $projectPartners
|
||||
* @property $is_for_publish
|
||||
*/
|
||||
class Projects extends _Base
|
||||
{
|
||||
public function getProjectPartners() {
|
||||
return $this->hasMany(ProjectsPartner::class, ['project_id' => 'id']);
|
||||
}
|
||||
|
||||
public function partnersIds() {
|
||||
$ids = [];
|
||||
/** @var \app\models\ProjectsPartner $partner */
|
||||
foreach ($this->projectPartners as $partner) {
|
||||
$ids[] = $partner->partner_id;
|
||||
}
|
||||
return $ids;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,47 @@
|
||||
<?php
|
||||
namespace app\models;
|
||||
|
||||
use yii\base\BaseObject;
|
||||
|
||||
/**
|
||||
* Class ProjectsPartner
|
||||
* @package app\models
|
||||
* @property $id
|
||||
* @property $project_id
|
||||
* @property $partner_id
|
||||
*/
|
||||
class ProjectsPartner extends _Base {
|
||||
|
||||
public static function updateRecords($ids, $data) {
|
||||
|
||||
$related = self::find()->where([$data[1] => $data[2]])->all();
|
||||
$remain = [];
|
||||
foreach ($related as $cto) {
|
||||
if(in_array($cto->id, $ids)) {
|
||||
$remain[] = $cto->id;
|
||||
} else {
|
||||
$cto->delete();
|
||||
}
|
||||
}
|
||||
foreach ($ids as $id) {
|
||||
if(!in_array($id, $remain)) {
|
||||
$newCto = new self();
|
||||
$newCto->{$data[1]} = $data[2];
|
||||
$newCto->{$data[0]} = $id;
|
||||
$newCto->save();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static function appendPartner($partner_id, $project_id) {
|
||||
|
||||
$related = self::find()->where(['partner_id' => $partner_id, 'project_id' => $project_id])->one();
|
||||
|
||||
if(!$related) {
|
||||
$newCto = new self();
|
||||
$newCto->partner_id = $partner_id;
|
||||
$newCto->project_id = $project_id;
|
||||
$newCto->save();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,25 @@
|
||||
<?php
|
||||
|
||||
|
||||
namespace app\models;
|
||||
|
||||
/**
|
||||
* Class QrValidators
|
||||
* @package app\models
|
||||
* @property $user_id
|
||||
* @property $partner_id
|
||||
* @property \app\models\register\Partner $partner
|
||||
* @property \app\models\UserPublic $user
|
||||
*/
|
||||
class QrValidators extends _Base
|
||||
{
|
||||
public function getPartner()
|
||||
{
|
||||
return $this->hasOne(Partner::class, ['id' => 'partner']);
|
||||
}
|
||||
|
||||
public function getUser()
|
||||
{
|
||||
return $this->hasOne(UserPublic::class, ['id' => 'user_id']);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,29 @@
|
||||
<?php
|
||||
|
||||
|
||||
namespace app\models;
|
||||
|
||||
use app\models\register\Fields;
|
||||
use app\models\register\FieldsValues;
|
||||
|
||||
/**
|
||||
* Class RegisterObjectFields
|
||||
* @package app\models
|
||||
* @property $object_id
|
||||
* @property $ref_num
|
||||
* @property $field_id
|
||||
* @property $value_id
|
||||
* @property $value_text
|
||||
* @property Fields $field
|
||||
* @property FieldsValues $fieldValue
|
||||
*/
|
||||
class RegisterObjectFields extends _Base
|
||||
{
|
||||
public function getField() {
|
||||
return $this->hasOne(Fields::class, ['id' => 'field_id']);
|
||||
}
|
||||
|
||||
public function getFieldValue() {
|
||||
return $this->hasOne(FieldsValues::class, ['id' => 'value_id']);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,23 @@
|
||||
<?php
|
||||
|
||||
|
||||
namespace app\models;
|
||||
|
||||
/**
|
||||
* Class RegisterObjectFields
|
||||
* @package app\models
|
||||
* @property $file_url
|
||||
* @property $streaming_url
|
||||
* @property $file_content_type
|
||||
* @property $extension
|
||||
* @property $size
|
||||
* @property $file_ref_num
|
||||
* @property $object_id
|
||||
* @property $video_thumbnail
|
||||
* @property $video_title
|
||||
* @property $video_duration
|
||||
*/
|
||||
class RegisterObjectFiles extends _Base
|
||||
{
|
||||
|
||||
}
|
||||
@@ -0,0 +1,180 @@
|
||||
<?php
|
||||
|
||||
|
||||
namespace app\models;
|
||||
|
||||
use app\models\register\CityList;
|
||||
use app\models\register\ObjectTags;
|
||||
use app\models\register\Partner as RegisterPartner;
|
||||
use app\models\register\CollectionsObjects;
|
||||
|
||||
/**
|
||||
* Class RegisterObjects
|
||||
* @package app\models
|
||||
* @property $ref_num
|
||||
* @property $city_id
|
||||
* @property $lib_type
|
||||
* @property $is_payable
|
||||
* @property $price
|
||||
* @property $infocenter_email
|
||||
* @property $infocenter_website
|
||||
* @property $administrative_latitude
|
||||
* @property $administrative_longitude
|
||||
* @property $partner_id
|
||||
* @property $created_year
|
||||
* @property $created_by
|
||||
* @property $object_thumbnail_url
|
||||
* @property $name
|
||||
* @property $annotation
|
||||
* @property $description
|
||||
* @property $short_description
|
||||
* @property $location_description
|
||||
* @property $admistrative_address
|
||||
* @property $temporary_address
|
||||
* @property $infocenter_name
|
||||
* @property $infocenter_address
|
||||
* @property $ts_en_name
|
||||
* @property $ts_en_annotation
|
||||
* @property $ts_en_description
|
||||
* @property $ts_en_short_description
|
||||
* @property $ts_en_location_description
|
||||
* @property $ts_en_admistrative_address
|
||||
* @property $ts_en_temporary_address
|
||||
* @property $ts_en_infocenter_name
|
||||
* @property $ts_en_infocenter_address
|
||||
* @property \app\models\RegisterObjectFields[] $registerObjectFields
|
||||
* @property \app\models\RegisterObjectFiles[] $registerObjectFiles
|
||||
* @property $date_added
|
||||
* @property $date_updated
|
||||
* @property $publish_date
|
||||
* @property $is_active
|
||||
* @property $mainImgFile
|
||||
* @property RegisterPartner $partner
|
||||
* @property CityList $city
|
||||
* @property \app\models\register\CollectionsObjects $collectionsObject
|
||||
* @property ObjectTags[] $tags
|
||||
* @property RegisterObjectFiles $pdf
|
||||
* @property Library $library
|
||||
*/
|
||||
class RegisterObjects extends _Base
|
||||
{
|
||||
|
||||
public function getExpositions()
|
||||
{
|
||||
return $this->hasMany(ExpositionsObjects::class, ['object_id' => 'id']);
|
||||
}
|
||||
|
||||
public function isInExposition($exposition_id)
|
||||
{
|
||||
if ($exposition_id) {
|
||||
$exists = $this->hasMany(ExpositionsObjects::class, ['object_id' => 'id'])->where(['exposition_id' => $exposition_id])->exists();
|
||||
return $exists;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public function getRegisterObjectFields()
|
||||
{
|
||||
return $this->hasMany(RegisterObjectFields::class, ['object_id' => 'id']);
|
||||
}
|
||||
|
||||
public function getRegisterObjectFiles()
|
||||
{
|
||||
return $this->hasMany(RegisterObjectFiles::class, ['object_id' => 'id']);
|
||||
}
|
||||
|
||||
public function getMainImgFile()
|
||||
{
|
||||
if ($this->object_thumbnail_url)
|
||||
return $this->object_thumbnail_url;
|
||||
|
||||
/** @var \app\models\RegisterObjectFiles $file */
|
||||
$file = $this->hasMany(RegisterObjectFiles::class, ['object_id' => 'id'])
|
||||
->where(['is_thumbnail' => 1])
|
||||
->orWhere(['extension' => 'jpg'])
|
||||
->orWhere(['extension' => 'jpeg'])
|
||||
->orWhere(['extension' => 'png'])
|
||||
->one();
|
||||
if ($file) return $file->file_url;
|
||||
}
|
||||
|
||||
public function getPartner()
|
||||
{
|
||||
return $this->hasOne(RegisterPartner::class, ['id' => 'partner_id']);
|
||||
}
|
||||
|
||||
public function getCity()
|
||||
{
|
||||
return $this->hasOne(CityList::class, ['id' => 'city_id']);
|
||||
}
|
||||
|
||||
public function getCollectionsObject()
|
||||
{
|
||||
return $this->hasMany(CollectionsObjects::class, ['object_id' => 'ref_num']);
|
||||
}
|
||||
|
||||
public function getCollectionsListStr()
|
||||
{
|
||||
$collections = [];
|
||||
/** @var CollectionsObjects $collectionObject */
|
||||
foreach ($this->collectionsObject as $collectionObject) {
|
||||
if ($collectionObject->collection)
|
||||
$collections[] = $collectionObject->collection->name;
|
||||
}
|
||||
return implode(',', $collections);
|
||||
}
|
||||
|
||||
public function getUrl()
|
||||
{
|
||||
return '/admin-global/web-portal/objects-register/?o=w&id=' . $this->id;
|
||||
}
|
||||
|
||||
public function isAddedToExposition($id)
|
||||
{
|
||||
if ($this->isInExposition($id))
|
||||
return '<div onclick="removeExpObject(this)" class="btn-rem btn-ib"><i class="la la-remove"></i> Премахни</div>';
|
||||
return '<div onclick="addExpObject(this)" class="btn-ib btn-default"><i class="la la-plus-circle"></i> Добави</div>';
|
||||
}
|
||||
|
||||
public function getTags()
|
||||
{
|
||||
return $this->hasMany(ObjectTags::class, ['object_id' => 'ref_num']);
|
||||
}
|
||||
|
||||
public function getTagsList($separator = '<br>')
|
||||
{
|
||||
$tags = [];
|
||||
foreach ($this->tags as $objectTag) {
|
||||
if ($objectTag->tag)
|
||||
$tags[] = $objectTag->tag->text;
|
||||
}
|
||||
return implode($separator, $tags);
|
||||
}
|
||||
|
||||
public function getPdf()
|
||||
{
|
||||
return $this->hasMany(RegisterObjectFiles::class, ['object_id' => 'id'])
|
||||
->where(['file_content_type' => 1, 'extension' => 'pdf'])
|
||||
->one();
|
||||
}
|
||||
|
||||
public function getLibrary()
|
||||
{
|
||||
return $this->hasOne(Library::class, ['object_id' => 'id']);
|
||||
}
|
||||
|
||||
|
||||
public static function languageList()
|
||||
{
|
||||
return [1 => 'Български',
|
||||
2 => 'Английски',
|
||||
3 => 'Немски',
|
||||
4 => 'Испански',
|
||||
5 => 'Португалски',
|
||||
6 => 'Португалски',
|
||||
7 => 'Турски',
|
||||
8 => 'Румънски',
|
||||
9 => 'Румънски'
|
||||
];
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,24 @@
|
||||
<?php
|
||||
|
||||
namespace app\models;
|
||||
|
||||
/**
|
||||
* Class SeoManagement
|
||||
* @package app\models
|
||||
* @property $id
|
||||
* @property $title
|
||||
* @property $title_en
|
||||
* @property $key_words
|
||||
* @property $key_words_en
|
||||
* @property $text
|
||||
* @property $text_en
|
||||
* @property $page_id
|
||||
* @property \app\models\Pages $page
|
||||
*/
|
||||
class SeoManagement extends _Base
|
||||
{
|
||||
public function getPage()
|
||||
{
|
||||
return $this->hasOne(Pages::class, ['id' => 'page_id']);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,21 @@
|
||||
<?php
|
||||
|
||||
|
||||
namespace app\models;
|
||||
|
||||
/**
|
||||
* Class Slides
|
||||
* @package app\models
|
||||
* @property string $title
|
||||
* @property string $text
|
||||
* @property string $ts_en_title
|
||||
* @property string $ts_en_text
|
||||
* @property string $media_key
|
||||
* @property integer $order_index
|
||||
* @property $relation
|
||||
* @property $ts_en_relation
|
||||
*/
|
||||
class Slides extends _Base
|
||||
{
|
||||
|
||||
}
|
||||
@@ -0,0 +1,24 @@
|
||||
<?php
|
||||
|
||||
|
||||
namespace app\models;
|
||||
|
||||
/**
|
||||
* Class Subscriptions
|
||||
* @package app\models
|
||||
* @property $price
|
||||
* @property $name
|
||||
* @property $name_en
|
||||
* @property $text
|
||||
* @property $text_en
|
||||
*/
|
||||
class Subscriptions extends _Base
|
||||
{
|
||||
public static function getList() {
|
||||
$list = [];
|
||||
foreach (self::find()->all() as $item) {
|
||||
$list[$item->id] = $item->name;
|
||||
}
|
||||
return $list;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,18 @@
|
||||
<?php
|
||||
namespace app\models;
|
||||
|
||||
|
||||
/**
|
||||
* Class TourStories
|
||||
* @package app\models\register
|
||||
* @property $id
|
||||
* @property $name
|
||||
* @property $name_en
|
||||
* @property $text
|
||||
* @property $text_en
|
||||
* @property $longitude
|
||||
* @property $latitude
|
||||
*/
|
||||
class TourObjects extends _Base
|
||||
{
|
||||
}
|
||||
@@ -0,0 +1,16 @@
|
||||
<?php
|
||||
|
||||
|
||||
namespace app\models;
|
||||
|
||||
/**
|
||||
* Class Translation
|
||||
* @package app\models
|
||||
* @property $id
|
||||
* @property $name
|
||||
* @property $name_en
|
||||
*/
|
||||
class Translation extends _Base
|
||||
{
|
||||
|
||||
}
|
||||
@@ -0,0 +1,45 @@
|
||||
<?php
|
||||
|
||||
|
||||
namespace app\models;
|
||||
|
||||
/**
|
||||
* Class Translation
|
||||
* @package app\models
|
||||
* @property $id
|
||||
* @property $name
|
||||
* @property $name_en
|
||||
*/
|
||||
class Ts extends _Base
|
||||
{
|
||||
public static function tableName() {
|
||||
return 'translation';
|
||||
}
|
||||
private static function retrieve($ids) {
|
||||
$phrases = [];
|
||||
foreach (self::find()->where(['IN', 'id', $ids])->all() as $ts) {
|
||||
switch (\Yii::$app->language){
|
||||
default:
|
||||
$phrases[$ts->id] = $ts->name;
|
||||
break;
|
||||
case 'en':
|
||||
$phrases[$ts->id] = $ts->name_en;
|
||||
break;
|
||||
}
|
||||
}
|
||||
return $phrases;
|
||||
}
|
||||
|
||||
public static function set($ids) {
|
||||
\Yii::$app->params['ts'] = self::retrieve($ids);
|
||||
}
|
||||
|
||||
public static function get($id) {
|
||||
if(!empty(\Yii::$app->params['ts'])) {
|
||||
if(!empty(\Yii::$app->params['ts'][$id])){
|
||||
return \Yii::$app->params['ts'][$id];
|
||||
}
|
||||
}
|
||||
return "id:$id";
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,81 @@
|
||||
<?php
|
||||
namespace app\models;
|
||||
|
||||
/**
|
||||
* Class UserAdminCms
|
||||
* @package app\models
|
||||
* @property string $email_login
|
||||
* @property $phone;
|
||||
* @property string $first_name
|
||||
* @property string $last_name
|
||||
* @property UserAdminCmsR[] $userRights
|
||||
* @property CmsRoles $cmsRole
|
||||
*/
|
||||
class UserAdminCms extends _Base
|
||||
{
|
||||
|
||||
public function getUserRights()
|
||||
{
|
||||
return $this->hasMany(UserAdminCmsR::class, ['user_id' => 'id']);
|
||||
}
|
||||
|
||||
public function getCmsRole() {
|
||||
return $this->hasOne(CmsRoles::class, ['id' => 'role_id']);
|
||||
}
|
||||
|
||||
|
||||
public function getRightsIds()
|
||||
{
|
||||
$rightsIds = [];
|
||||
foreach ($this->userRights as $userRight) {
|
||||
$rightsIds[] = $userRight->right_id;
|
||||
}
|
||||
return $rightsIds;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @param UserAdminCms $model
|
||||
* @return string
|
||||
*/
|
||||
public static function getRightList(UserAdminCms $model)
|
||||
{
|
||||
list($checkedList, $checkList) = ["", ""];
|
||||
foreach (CmsRights::find()->all() as $item) {
|
||||
if (in_array($item->id, $model->getRightsIds()))
|
||||
$checkedList .= '<label data-name="' . $item->name . '"><input checked name="rights[]" type="checkbox" value="' . $item->id . '">' . $item->name . '</label>';
|
||||
}
|
||||
foreach (CmsRights::find()->all() as $item) {
|
||||
if (!in_array($item->id, $model->getRightsIds()))
|
||||
$checkList .= '<label data-name="' . $item->name . '"><input name="rights[]" type="checkbox" value="' . $item->id . '">' . $item->name . '</label>';
|
||||
}
|
||||
return '<div style="width: 100%; background: #f8f8f8; margin: 3px 0; padding: 3px 0; border: 1px solid var(--base-background-ultra-bright )">' . $checkedList . '</div>' . $checkList;
|
||||
}
|
||||
|
||||
public function updateRights($rightsIds)
|
||||
{
|
||||
list($create_list, $delete_list) = [[], []];
|
||||
|
||||
//Delete OLD
|
||||
foreach ($this->getRightsIds() as $rightId) {
|
||||
if (!in_array($rightId, $rightsIds))
|
||||
$delete_list[] = $rightId;
|
||||
}
|
||||
$deleteUserCmsR = UserAdminCmsR::find()->where(['user_id' => $this->id])->andWhere(['IN', 'right_id', $delete_list])->all();
|
||||
foreach ($deleteUserCmsR as $cmsUserRModel)
|
||||
$cmsUserRModel->delete();
|
||||
|
||||
//Create new
|
||||
foreach ($rightsIds as $currentId) {
|
||||
if (!in_array($currentId, $this->getRightsIds()))
|
||||
$create_list[] = $currentId;
|
||||
}
|
||||
|
||||
foreach ($create_list as $rightId){
|
||||
$cmsUserRModel = new UserAdminCmsR();
|
||||
$cmsUserRModel->user_id = $this->id;
|
||||
$cmsUserRModel->right_id = $rightId;
|
||||
$cmsUserRModel->save();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,13 @@
|
||||
<?php
|
||||
namespace app\models;
|
||||
|
||||
/**
|
||||
* Class UserAdminCmsR
|
||||
* @package app\models
|
||||
* @property int $user_id
|
||||
* @property int $right_id
|
||||
*/
|
||||
class UserAdminCmsR extends _Base
|
||||
{
|
||||
|
||||
}
|
||||
@@ -0,0 +1,39 @@
|
||||
<?php
|
||||
namespace app\models;
|
||||
|
||||
use app\services\Auth;
|
||||
|
||||
/**
|
||||
* Class UserAdminGlobal
|
||||
* @package app\models
|
||||
* @property int $id
|
||||
* @property string $email_login
|
||||
* @property string $phone
|
||||
* @property string $first_name
|
||||
* @property string $last_name
|
||||
* @property string $open_id
|
||||
*
|
||||
*/
|
||||
class UserAdminGlobal extends _Base {
|
||||
|
||||
|
||||
public static function prepareRegisterUser($userinfo) {
|
||||
$admin = UserAdminGlobal::find()->where(['open_id' => $userinfo->sub])->one();
|
||||
if(!$admin) {
|
||||
$admin = new UserAdminGlobal();
|
||||
}
|
||||
$admin->open_id = $userinfo->sub;
|
||||
$admin->email_login = $userinfo->email ?? null;
|
||||
$admin->first_name = $userinfo->given_name ?? null;
|
||||
$admin->last_name = $userinfo->family_name ?? null;
|
||||
$admin->is_active = 1;
|
||||
$admin->save();
|
||||
if(!empty($_SESSION['admin-global-page'])) {
|
||||
$default = $_SESSION['admin-global-page'];
|
||||
unset($_SESSION['admin-global-page']);
|
||||
}
|
||||
Auth::userAdminGlobalLogin($admin->id);
|
||||
header('Location: /admin-global/index/dashboard');
|
||||
exit;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,18 @@
|
||||
<?php
|
||||
namespace app\models;
|
||||
|
||||
/**
|
||||
* Class UserExplorerObjects
|
||||
* @package app\models
|
||||
* @property $explorer_object_id
|
||||
* @property $user_id
|
||||
* @property $date_visit
|
||||
* @property $explorerObject
|
||||
*/
|
||||
class UserExplorerObjects extends _Base
|
||||
{
|
||||
public function getExploreObject()
|
||||
{
|
||||
return $this->hasOne(ExplorerObjects::class, ['id' => 'explorer_object_id']);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,17 @@
|
||||
<?php
|
||||
|
||||
|
||||
namespace app\models;
|
||||
|
||||
/**
|
||||
* Class UserFavorites
|
||||
* @package app\models
|
||||
* @property $id
|
||||
* @property $fid
|
||||
* @property $table
|
||||
* @property $user_id
|
||||
*/
|
||||
class UserFavorites extends _Base
|
||||
{
|
||||
|
||||
}
|
||||
@@ -0,0 +1,145 @@
|
||||
<?php
|
||||
|
||||
namespace app\models;
|
||||
|
||||
use app\models\register\Partner;
|
||||
use app\services\Auth;
|
||||
use yii\base\BaseObject;
|
||||
|
||||
/**
|
||||
* Class UserAdminCms
|
||||
* @package app\models
|
||||
* @property string $email_login
|
||||
* @property $phone;
|
||||
* @property string $first_name
|
||||
* @property string $middle_name
|
||||
* @property string $last_name
|
||||
* @property string $science_degree
|
||||
* @property string $presentation
|
||||
* @property UserPartnerR[] $userRights
|
||||
* @property CmsRoles $cmsRole
|
||||
* @property int $parent_id
|
||||
* @property int $partner_id
|
||||
* @property Partner $partner
|
||||
* @property int $role_id
|
||||
* @property string $position
|
||||
* @property string $open_id
|
||||
*/
|
||||
class UserPartner extends _Base
|
||||
{
|
||||
|
||||
public function getPartner()
|
||||
{
|
||||
return $this->hasOne(Partner::class, ['id' => 'partner_id']);
|
||||
}
|
||||
|
||||
public function getUserRights()
|
||||
{
|
||||
return $this->hasMany(UserPartnerR::class, ['user_id' => 'id']);
|
||||
}
|
||||
|
||||
public function getCmsRole()
|
||||
{
|
||||
return $this->hasOne(CmsRoles::class, ['id' => 'role_id']);
|
||||
}
|
||||
|
||||
public function getRightsIds($id = null)
|
||||
{
|
||||
$rightsIds = [];
|
||||
foreach ($this->userRights as $userRight) {
|
||||
if($userRight->right && !in_array($userRight->right_id, $rightsIds))
|
||||
$rightsIds[] = $userRight->right_id;
|
||||
}
|
||||
if ($id) {
|
||||
return in_array($id, $rightsIds);
|
||||
} else {
|
||||
return $rightsIds;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public static function getRightList(UserPartner $model, $readOnly = null)
|
||||
{
|
||||
list($checkedList, $checkList, $readOnlyList) = ["", "", ""];
|
||||
|
||||
foreach (CmsRights::find()->where(['is_active' => 1])->all() as $item) {
|
||||
if (in_array($item->id, $model->getRightsIds())) {
|
||||
$checkedList .= '<label data-name="' . $item->name . '"><input checked name="rights[]" type="checkbox" value="' . $item->id . '">' . $item->name . '</label>';
|
||||
$readOnlyList .= '<div>' . $item->name . '</div>';
|
||||
}
|
||||
}
|
||||
foreach (CmsRights::find()->where(['is_active' => 1])->all() as $item) {
|
||||
if (!in_array($item->id, $model->getRightsIds()))
|
||||
$checkList .= '<label data-name="' . $item->name . '"><input name="rights[]" type="checkbox" value="' . $item->id . '">' . $item->name . '</label>';
|
||||
}
|
||||
|
||||
if ($readOnly)
|
||||
return $readOnlyList;
|
||||
|
||||
return '<div style="width: 100%; background: #f8f8f8; margin: 3px 0; padding: 3px 0; border: 1px solid var(--base-background-ultra-bright)">' . $checkedList . '</div>' . $checkList;
|
||||
}
|
||||
|
||||
public function updateRights($rightsIds)
|
||||
{
|
||||
list($create_list, $delete_list) = [[], []];
|
||||
|
||||
//Delete OLD
|
||||
foreach ($this->getRightsIds() as $rightId) {
|
||||
if (!in_array($rightId, $rightsIds))
|
||||
$delete_list[] = $rightId;
|
||||
}
|
||||
$deleteUserCmsR = UserPartnerR::find()->where(['user_id' => $this->id])->andWhere(['IN', 'right_id', $delete_list])->all();
|
||||
foreach ($deleteUserCmsR as $cmsUserRModel)
|
||||
$cmsUserRModel->delete();
|
||||
|
||||
//Create new
|
||||
foreach ($rightsIds as $currentId) {
|
||||
if (!in_array($currentId, $this->getRightsIds()))
|
||||
$create_list[] = $currentId;
|
||||
}
|
||||
|
||||
foreach ($create_list as $rightId) {
|
||||
$cmsUserRModel = new UserPartnerR();
|
||||
$cmsUserRModel->user_id = $this->id;
|
||||
$cmsUserRModel->right_id = $rightId;
|
||||
$cmsUserRModel->save();
|
||||
}
|
||||
}
|
||||
|
||||
public static function prepareRegisterUser($userinfo, $role_id)
|
||||
{
|
||||
$userPartner = UserPartner::find()->where(['open_id' => $userinfo->sub])->one();
|
||||
if (!$userPartner) {
|
||||
$userPartner = new UserPartner();
|
||||
}
|
||||
$role = CmsRoles::findOne($role_id);
|
||||
if (!$role)
|
||||
die('Role with ID:' . $role_id . ' is missing');
|
||||
$userPartner->open_id = $userinfo->sub;
|
||||
$userPartner->email_login = $userinfo->email ?? null;
|
||||
$userPartner->first_name = $userinfo->given_name ?? null;
|
||||
$userPartner->last_name = $userinfo->family_name ?? null;
|
||||
$userPartner->partner_id = $userinfo->partner_id;
|
||||
$userPartner->role_id = $role->id;
|
||||
$userPartner->save();
|
||||
$rights = [];
|
||||
|
||||
if ($role_id == 1)
|
||||
$rights = [1, 2, 4, 5];
|
||||
if ($role_id == 2)
|
||||
$rights = [1, 2];
|
||||
|
||||
foreach ($rights as $rightId) {
|
||||
$upr = new UserPartnerR();
|
||||
$upr->user_id = $userPartner->id;
|
||||
$upr->right_id = $rightId;
|
||||
$upr->save();
|
||||
}
|
||||
|
||||
Auth::userPartnerLogin($userPartner->id);
|
||||
header('Location: /partner/index/dashboard/');
|
||||
exit;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,16 @@
|
||||
<?php
|
||||
namespace app\models;
|
||||
|
||||
/**
|
||||
* Class UserPartnerR
|
||||
* @package app\models
|
||||
* @property int $user_id
|
||||
* @property int $right_id
|
||||
* @property \app\models\CmsRights $right
|
||||
*/
|
||||
class UserPartnerR extends _Base
|
||||
{
|
||||
public function getRight() {
|
||||
return $this->hasOne(CmsRights::class, ['id' => 'right_id']);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,26 @@
|
||||
<?php
|
||||
|
||||
|
||||
namespace app\models;
|
||||
|
||||
/**
|
||||
* Class UserPublic
|
||||
* @package app\models
|
||||
* @property $id
|
||||
* @property $full_name
|
||||
* @property $email
|
||||
* @property $password
|
||||
* @property $password_hash
|
||||
* @property $club_card
|
||||
*/
|
||||
class UserPublic extends _Base
|
||||
{
|
||||
public function setPasswordHash($password) {
|
||||
$this->password_hash = password_hash($password, PASSWORD_DEFAULT);
|
||||
}
|
||||
|
||||
public function getExplorerObjectsSumPoints() {
|
||||
return $this->hasMany(UserExplorerObjects::class, ['user_id' => 'id'])
|
||||
->joinWith('exploreObject')->sum('points');
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,30 @@
|
||||
<?php
|
||||
namespace app\models;
|
||||
|
||||
/**
|
||||
* Class UserSession
|
||||
* @package app\models
|
||||
* @property $id
|
||||
* @property $user_type
|
||||
* @property $result
|
||||
* @property $session_type
|
||||
* @property $sub
|
||||
* @property $date_logged
|
||||
*/
|
||||
class UserSession extends _Base {
|
||||
|
||||
public static function log($session_type, $user_type, $sub) {
|
||||
$userSession = UserSession::find()->where(['sub' => $sub])->one();
|
||||
if($userSession) {
|
||||
$userSession->date_logged = date('Y-m-d H:i:s');
|
||||
$userSession->save();
|
||||
} else {
|
||||
$userSession = new UserSession();
|
||||
$userSession->sub = $sub;
|
||||
$userSession->session_type = $session_type;
|
||||
$userSession->user_type = $user_type;
|
||||
$userSession->date_logged = date('Y-m-d H:i:s');
|
||||
$userSession->save();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,228 @@
|
||||
<?php
|
||||
|
||||
|
||||
namespace app\models;
|
||||
|
||||
use app\services\Auth;
|
||||
use app\services\JWT;
|
||||
|
||||
/**
|
||||
* Class _Base
|
||||
* @package app\models
|
||||
* @property $id
|
||||
* @property $first_name;
|
||||
* @property $last_name;
|
||||
* @property $media_key
|
||||
* @property $document_key
|
||||
* @property $publish_date
|
||||
* @property string $password
|
||||
* @property boolean $is_active
|
||||
*/
|
||||
class _Base extends \yii\db\ActiveRecord
|
||||
{
|
||||
//CUSTOM FUNCTIONS
|
||||
public function storePassword($password)
|
||||
{
|
||||
$this->password = password_hash($password, PASSWORD_DEFAULT);
|
||||
}
|
||||
|
||||
public function verifyPassword($password)
|
||||
{
|
||||
return password_verify($password, $this->password);
|
||||
}
|
||||
|
||||
public function ftDate($field, $format = 'd.m.Y')
|
||||
{
|
||||
if ($this->{$field})
|
||||
return date($format, strtotime($this->{$field}));
|
||||
return '';
|
||||
}
|
||||
|
||||
|
||||
public static function recordExists($key, $name)
|
||||
{
|
||||
$result = self::find()->where([$key => $name]);
|
||||
if (isset($_GET['id'])) {
|
||||
$result = $result->andWhere(['!=', 'id', $_GET['id']]);
|
||||
}
|
||||
return $result->exists();
|
||||
}
|
||||
|
||||
public static function exists($data, $ignoreId = true)
|
||||
{
|
||||
$result = self::find()->where($data);
|
||||
if (!empty($_GET['id']) && $ignoreId) {
|
||||
$result = $result->andWhere(['!=', 'id', $_GET['id']]);
|
||||
}
|
||||
return $result->exists();
|
||||
}
|
||||
|
||||
public function statusSwitch($key, $color = null, $messages = null, $disabled = null, $updateArticleTable = null)
|
||||
{
|
||||
if (!$messages)
|
||||
$messages = ['Статусът е включен', 'Статусът беше изключен'];
|
||||
if ($this->hasProperty($key)) {
|
||||
$checked = $this->{$key} == 1 ? "checked" : "";
|
||||
return
|
||||
'<label class="switch ' . ($disabled == 'disabled' ? ' disabled ' : '') . '" ' . ($color ? 'style="--switch-color: ' . $color . '"' : "") . '>
|
||||
<input type="checkbox" onchange="updateStatus(this)"
|
||||
data-status="' . $this->{$key} . '" ' . $checked . '
|
||||
data-article-table="' . $updateArticleTable . '"
|
||||
data-key="' . $key . '" data-model="' . get_class($this) . '"
|
||||
data-id="' . $this->id . '"
|
||||
data-yes="' . ($messages[0] ?? "") . '"
|
||||
data-no="' . ($messages[1] ?? "") . '"/>
|
||||
<span class="slider round"></span>
|
||||
</label>';
|
||||
}
|
||||
return '';
|
||||
}
|
||||
|
||||
public function getFullName()
|
||||
{
|
||||
return $this->first_name . ' ' . $this->last_name;
|
||||
}
|
||||
|
||||
|
||||
public function uploadSingleImage($postName, $path)
|
||||
{
|
||||
if (!empty($_FILES[$postName])) {
|
||||
if ($this->id) {
|
||||
$id = $this->id;
|
||||
} else {
|
||||
$last = self::find()->orderBy(['id' => SORT_DESC])->one();
|
||||
$id = $last ? ($last->id + 1) : 1;
|
||||
}
|
||||
$imgName = str_replace('/', '_', $path) . '_' . $id . '.jpg';
|
||||
$oldPath = $_FILES[$postName]['tmp_name'];
|
||||
$newPath = $_SERVER['DOCUMENT_ROOT'] . "/_uploads/$path/" . $imgName;
|
||||
move_uploaded_file($oldPath, $newPath);
|
||||
}
|
||||
}
|
||||
|
||||
public function getSingleImageSrc($path)
|
||||
{
|
||||
$imgName = str_replace('/', '_', $path) . '_' . $this->id . '.jpg';
|
||||
$file = $_SERVER['DOCUMENT_ROOT'] . "/_uploads/$path/" . $imgName;
|
||||
if (file_exists($file)) {
|
||||
$src = "/_uploads/$path/" . $imgName;
|
||||
return JWT::encode(['secure_img' => $src], JWT::SECRET_KEY);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
|
||||
public function getFiles($ready = null)
|
||||
{
|
||||
$images = $this->hasMany(FileCms::class, ['media_key' => 'media_key']);
|
||||
$data = [];
|
||||
|
||||
|
||||
/**
|
||||
* @var $image \app\models\FileCms;
|
||||
*/
|
||||
foreach ($images->all() as $image) {
|
||||
$data[$image->object_key][$image->order_index] = $image->getImageData($ready);
|
||||
}
|
||||
foreach ($data as $object_key => $files) {
|
||||
ksort($files);
|
||||
$data[$object_key] = $files;
|
||||
}
|
||||
return $data;
|
||||
}
|
||||
|
||||
public function getMediaKey()
|
||||
{
|
||||
if (empty($this->media_key)) {
|
||||
return uniqid() . 'm' . time() . 'k' . rand(1, 1000);
|
||||
} else {
|
||||
return $this->media_key;
|
||||
}
|
||||
}
|
||||
|
||||
public function getDocumentKey()
|
||||
{
|
||||
if (empty($this->document_key)) {
|
||||
return uniqid() . 'd' . time() . 'k' . rand(1, 1000);
|
||||
} else {
|
||||
return $this->document_key;
|
||||
}
|
||||
}
|
||||
|
||||
public function getPublishDate()
|
||||
{
|
||||
if (empty($this->publish_date)) {
|
||||
return date('Y-m-d');
|
||||
} else {
|
||||
return $this->publish_date;
|
||||
}
|
||||
}
|
||||
|
||||
public function formatDate($date, $format = 'd.m.Y')
|
||||
{
|
||||
if ($date) return date($format, strtotime($date));
|
||||
}
|
||||
|
||||
/**
|
||||
* @param $object_key
|
||||
* @param $rez
|
||||
* @return string|null
|
||||
*/
|
||||
public function getSrcOfSingleImage($object_key, $rez)
|
||||
{
|
||||
if ($this->media_key) {
|
||||
/** @var \app\models\FileCms $image */
|
||||
$image = $this->hasOne(FileCms::class, ['media_key' => 'media_key'])
|
||||
->where(['object_key' => $object_key])->one();
|
||||
|
||||
if ($image) {
|
||||
$src = '/_files/ready/' . $this->media_key . '/' . $image->object_key . '/' . $rez . '/' . $image->file_name;
|
||||
if (file_exists($_SERVER['DOCUMENT_ROOT'] . $src)) {
|
||||
return $src;
|
||||
}
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param $object_key
|
||||
* @param $rez
|
||||
* @return array
|
||||
*/
|
||||
public function getSrcOfMultipleImages($object_key, $rez)
|
||||
{
|
||||
$srcArr = [];
|
||||
if ($this->media_key) {
|
||||
$images = $this->hasMany(FileCms::class, ['media_key' => 'media_key'])
|
||||
->where(['object_key' => $object_key])->all();
|
||||
|
||||
|
||||
/** @var \app\models\FileCms $image */
|
||||
foreach ($images as $image) {
|
||||
if ($image) {
|
||||
$src = '/_files/ready/' . $this->media_key . '/' . $image->object_key . '/' . $rez . '/' . $image->file_name;
|
||||
if (file_exists($_SERVER['DOCUMENT_ROOT'] . $src)) {
|
||||
$srcArr[] = $src;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return $srcArr;
|
||||
}
|
||||
|
||||
public static function getModel()
|
||||
{
|
||||
if (!empty($_GET['id'])) {
|
||||
return self::findOne($_GET['id']);
|
||||
} else {
|
||||
return new self();
|
||||
}
|
||||
}
|
||||
|
||||
public function isSelected($ids, $id)
|
||||
{
|
||||
return in_array($id, $ids) ? 'selected' : '';
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,24 @@
|
||||
<?php
|
||||
|
||||
|
||||
namespace app\models\register;
|
||||
|
||||
/**
|
||||
* Class CityList
|
||||
* @package app\models\register
|
||||
* @property $place
|
||||
* @property CityOblast $cityOblast
|
||||
* @property string $type
|
||||
* @property string $name
|
||||
*/
|
||||
class CityList extends _BaseRegister
|
||||
{
|
||||
public function getPlace()
|
||||
{
|
||||
return $this->type . ' '.$this->name. ', обл. ' . $this->cityOblast->name;
|
||||
}
|
||||
|
||||
public function getCityOblast() {
|
||||
return $this->hasOne(CityOblast::class, ['oblast' => 'oblast']);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,14 @@
|
||||
<?php
|
||||
|
||||
|
||||
namespace app\models\register;
|
||||
|
||||
/**
|
||||
* Class CityOblast
|
||||
* @package app\models\register
|
||||
* @property $name
|
||||
*/
|
||||
class CityOblast extends _BaseRegister
|
||||
{
|
||||
|
||||
}
|
||||
@@ -0,0 +1,10 @@
|
||||
<?php
|
||||
|
||||
|
||||
namespace app\models\register;
|
||||
|
||||
|
||||
class CityObshtina extends _BaseRegister
|
||||
{
|
||||
|
||||
}
|
||||
@@ -0,0 +1,65 @@
|
||||
<?php
|
||||
|
||||
|
||||
namespace app\models\register;
|
||||
|
||||
/**
|
||||
* Class Collection
|
||||
* @package app\models\register
|
||||
* @property $id
|
||||
* @property $type
|
||||
* @property $name
|
||||
* @property $name_en
|
||||
* @property $annotation
|
||||
* @property $annotation_en
|
||||
* @property $description
|
||||
* @property $description_en
|
||||
* @property $thumbnail
|
||||
* @property $partner_id
|
||||
* @property $published
|
||||
* @property $active
|
||||
* @property $deleted
|
||||
* @property $added_on
|
||||
* @property $added_by
|
||||
* @property $modified_on
|
||||
* @property $modified_by
|
||||
* @property $is_payable
|
||||
* @property $price
|
||||
*/
|
||||
class Collections extends _BaseRegister
|
||||
{
|
||||
public function getPartner()
|
||||
{
|
||||
return $this->hasOne(Partner::class, ['id' => 'partner_id']);
|
||||
}
|
||||
|
||||
public static function getDropDownData($partner_id = null)
|
||||
{
|
||||
|
||||
$data = [];
|
||||
|
||||
$collections = self::find()->where(['deleted' => 0, 'active'=> 1, 'published' => 1]);
|
||||
|
||||
if($partner_id) {
|
||||
$collections = $collections->andWhere(['partner_id' => $partner_id]);
|
||||
}
|
||||
|
||||
foreach ($collections->all() as $collection) {
|
||||
$data[$collection->id] = $collection->name;
|
||||
}
|
||||
return $data;
|
||||
}
|
||||
|
||||
public static function getPaidDropDownData()
|
||||
{
|
||||
|
||||
$data = [];
|
||||
|
||||
$collections = self::find()->where(['deleted' => 0, 'active'=> 1, 'published' => 1, 'is_payable' => 1]);
|
||||
|
||||
foreach ($collections->all() as $collection) {
|
||||
$data[$collection->id] = $collection->name;
|
||||
}
|
||||
return $data;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,21 @@
|
||||
<?php
|
||||
|
||||
|
||||
namespace app\models\register;
|
||||
|
||||
/**
|
||||
* Class CollectionsObjects
|
||||
* @package app\models\register
|
||||
* @property $id
|
||||
* @property $collection_id
|
||||
* @property $object_id
|
||||
* @property $added_on
|
||||
* @property $added_by
|
||||
* @property \app\models\register\Collections $collection
|
||||
*/
|
||||
class CollectionsObjects extends _BaseRegister
|
||||
{
|
||||
public function getCollection() {
|
||||
return $this->hasOne(Collections::class, ['id' => 'collection_id']);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
<?php
|
||||
namespace app\models\register;
|
||||
|
||||
/**
|
||||
* Class Fields
|
||||
* @package app\models\register
|
||||
* @property $name
|
||||
*/
|
||||
class Fields extends _BaseRegister {
|
||||
|
||||
}
|
||||
@@ -0,0 +1,14 @@
|
||||
<?php
|
||||
|
||||
|
||||
namespace app\models\register;
|
||||
|
||||
/**
|
||||
* Class FieldsValues
|
||||
* @package app\models\register
|
||||
* @property $name
|
||||
*/
|
||||
class FieldsValues extends _BaseRegister
|
||||
{
|
||||
|
||||
}
|
||||
@@ -0,0 +1,26 @@
|
||||
<?php
|
||||
|
||||
|
||||
namespace app\models\register;
|
||||
|
||||
/**
|
||||
* Class ObjectTags
|
||||
* @package app\models\register
|
||||
* @property $id
|
||||
* @property $object_id
|
||||
* @property $tag_id
|
||||
* @property $description
|
||||
* @property $active
|
||||
* @property $deleted
|
||||
* @property $added_on
|
||||
* @property $added_by
|
||||
* @property $modified_on
|
||||
* @property $modified_by
|
||||
* @property \app\models\register\Tags $tag
|
||||
*/
|
||||
class ObjectTags extends _BaseRegister
|
||||
{
|
||||
public function getTag() {
|
||||
return $this->hasOne(Tags::class, ['id' => 'tag_id']);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,56 @@
|
||||
<?php
|
||||
|
||||
|
||||
namespace app\models\register;
|
||||
|
||||
use app\models\ExpositionsTags;
|
||||
use app\models\QrValidators;
|
||||
use app\models\UserPublic;
|
||||
|
||||
/**
|
||||
* Class Partner
|
||||
* @package app\models\register
|
||||
*
|
||||
* @property $id
|
||||
* @property $type
|
||||
* @property $name_short
|
||||
* @property $name
|
||||
* @property $phone
|
||||
* @property $email
|
||||
* @property $website
|
||||
* @property $contact_person
|
||||
* @property $description
|
||||
* @property $active
|
||||
* @property $deleted
|
||||
* @property QrValidators[] $qrValidators
|
||||
*/
|
||||
class Partner extends _BaseRegister
|
||||
{
|
||||
public static function partnerList() {
|
||||
$partnerList = [];
|
||||
foreach (self::find()->all() as $partner) {
|
||||
$partnerList[$partner->id] = $partner->name;
|
||||
}
|
||||
return $partnerList;
|
||||
}
|
||||
|
||||
public function getQrValidators() {
|
||||
return $this->hasMany(QrValidators::class, ['partner_id' => 'id']);
|
||||
}
|
||||
|
||||
public function userPublicList() {
|
||||
$selected = [];
|
||||
foreach ($this->qrValidators as $qrValidator) {
|
||||
$selected[] = $qrValidator->user_id;
|
||||
}
|
||||
$users = [];
|
||||
foreach (UserPublic::find()->all() as $publicUser) {
|
||||
$users[] = [
|
||||
'id' => $publicUser->id,
|
||||
'name' => $publicUser->email,
|
||||
'selected' => in_array($publicUser->id, $selected) ? 'selected' : ''
|
||||
];
|
||||
}
|
||||
return $users;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,35 @@
|
||||
<?php
|
||||
|
||||
|
||||
namespace app\models\register;
|
||||
|
||||
/**
|
||||
* Class PhplistUserUser
|
||||
* @package app\models\register
|
||||
* @property $id
|
||||
* @property $email
|
||||
* @property $htmlemail
|
||||
* @property $modified
|
||||
* @property $entered
|
||||
* @property $uniqid
|
||||
*/
|
||||
class PhplistUserUser extends _BasePhpList
|
||||
{
|
||||
|
||||
public static function add($email) {
|
||||
|
||||
$phpListUser = PhplistUserUser::find()->where(['email' => $email])->one();
|
||||
|
||||
if(!$phpListUser) {
|
||||
$phpListUser = new PhplistUserUser();
|
||||
$phpListUser->email = $email;
|
||||
$phpListUser->htmlemail = 1;
|
||||
$phpListUser->entered = date('Y-m-d H:i:s');
|
||||
$phpListUser->uniqid = uniqid();
|
||||
} else {
|
||||
$phpListUser->modified = date('Y-m-d H:i:s');
|
||||
}
|
||||
$phpListUser->save();
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,25 @@
|
||||
<?php
|
||||
|
||||
|
||||
namespace app\models\register;
|
||||
|
||||
/**
|
||||
* Class Tags
|
||||
* @package app\models\register
|
||||
* @property $id
|
||||
* @property $parent_id
|
||||
* @property $level
|
||||
* @property $text
|
||||
* @property $text_en
|
||||
* @property $active
|
||||
* @property $deleted
|
||||
* @property $added_on
|
||||
* @property $added_by
|
||||
* @property $modified_on
|
||||
* @property $modified_byq
|
||||
*/
|
||||
|
||||
class Tags extends _BaseRegister
|
||||
{
|
||||
|
||||
}
|
||||
@@ -0,0 +1,15 @@
|
||||
<?php
|
||||
|
||||
|
||||
namespace app\models\register;
|
||||
|
||||
|
||||
use app\models\_Base;
|
||||
|
||||
class _BasePhpList extends _Base
|
||||
{
|
||||
public static function getDb()
|
||||
{
|
||||
return \Yii::$app->get('db_phplist');
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,15 @@
|
||||
<?php
|
||||
|
||||
|
||||
namespace app\models\register;
|
||||
|
||||
|
||||
use app\models\_Base;
|
||||
|
||||
class _BaseRegister extends _Base
|
||||
{
|
||||
public static function getDb()
|
||||
{
|
||||
return \Yii::$app->get('db_register');
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,39 @@
|
||||
<?php
|
||||
|
||||
namespace app\models\settlement;
|
||||
|
||||
use yii\db\ActiveRecord;
|
||||
|
||||
/**
|
||||
* Class Oblast
|
||||
* @package app\models\settlement
|
||||
* @property $id
|
||||
* @property $ekatte
|
||||
* @property $t_v_m
|
||||
* @property $name
|
||||
* @property $oblast
|
||||
* @property $obstina
|
||||
* @property $kmetstvo
|
||||
* @property $kind
|
||||
* @property $category
|
||||
* @property $altitude
|
||||
* @property $document
|
||||
* @property $abc
|
||||
* @property Oblast $relOblast
|
||||
* @property Obstina $relObstina
|
||||
*
|
||||
*/
|
||||
class Ekatte extends ActiveRecord {
|
||||
|
||||
public static function getDb()
|
||||
{
|
||||
return \Yii::$app->get('db_settlements'); // TODO: Change the autogenerated stub
|
||||
}
|
||||
|
||||
public function getRelOblast() {
|
||||
return $this->hasOne(Oblast::class, ['oblast' => 'oblast']);
|
||||
}
|
||||
public function getRelObstina() {
|
||||
return $this->hasOne(Obstina::class, ['obstina' => 'obstina']);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,26 @@
|
||||
<?php
|
||||
|
||||
namespace app\models\settlement;
|
||||
|
||||
use yii\db\ActiveRecord;
|
||||
|
||||
/**
|
||||
* Class Oblast
|
||||
* @package app\models\settlement
|
||||
* @property $id
|
||||
|
||||
* @property $oblast
|
||||
* @property $ekatte
|
||||
* @property $name
|
||||
* @property $region
|
||||
* @property $document
|
||||
* @property $abc
|
||||
*
|
||||
*/
|
||||
class Oblast extends ActiveRecord {
|
||||
|
||||
public static function getDb()
|
||||
{
|
||||
return \Yii::$app->get('db_settlements'); // TODO: Change the autogenerated stub
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,26 @@
|
||||
<?php
|
||||
|
||||
namespace app\models\settlement;
|
||||
|
||||
use yii\db\ActiveRecord;
|
||||
|
||||
/**
|
||||
* Class Oblast
|
||||
* @package app\models\settlement
|
||||
* @property $id
|
||||
|
||||
* @property $obstina
|
||||
* @property $ekatte
|
||||
* @property $name
|
||||
* @property $category
|
||||
* @property $document
|
||||
* @property $abc
|
||||
*
|
||||
*/
|
||||
class Obstina extends ActiveRecord {
|
||||
|
||||
public static function getDb()
|
||||
{
|
||||
return \Yii::$app->get('db_settlements'); // TODO: Change the autogenerated stub
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user