Skip to content

Commit

Permalink
[FIX] Product page.
Browse files Browse the repository at this point in the history
  • Loading branch information
Seiger committed Jan 4, 2024
1 parent 9d3ebef commit 5234d2f
Show file tree
Hide file tree
Showing 10 changed files with 130 additions and 97 deletions.
3 changes: 2 additions & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,8 @@
}
],
"require": {
"php": "^8"
"php": "^8",
"seiger/sgallery": "*"
},
"autoload": {
"psr-4": {
Expand Down
4 changes: 4 additions & 0 deletions lang/en/global.php
Original file line number Diff line number Diff line change
Expand Up @@ -51,4 +51,8 @@
'category_help' => 'Define the main category of the product. Used to form the main link and navigation chain.',
'catalog_root' => 'Catalog root',
'catalog_root_help' => 'Define the resource that will be used as the root of the product catalog by default.',
'to_list_products' => 'To the list of products',
'price_help' => 'The main price of the product is in the currency of the store.',
'categories' => 'Categories',
'categories_help' => 'List of categories in which the product should be displayed. Formed from the resource tree from the root, which is designated as a directory. If a subcategory is selected, the product will be displayed in all higher categories.',
];
4 changes: 4 additions & 0 deletions lang/ru/global.php
Original file line number Diff line number Diff line change
Expand Up @@ -51,4 +51,8 @@
'category_help' => 'Определите основную категорию продукта. Используется для формирования основной ссылки и цепочки навигации.',
'catalog_root' => 'Корень каталога',
'catalog_root_help' => 'Определите ресурс, который будет использоваться в качестве корня каталога товаров по умолчанию.',
'to_list_products' => 'К списоку товаров',
'price_help' => 'Основная стоимость товара в валюте магазина.',
'categories' => 'Категории',
'categories_help' => 'Список категорий в которых должен отображаться товар. Формируется из дерева ресурсов от корня, который обозначен как каталог. Если выбрана подкатегория - товар будет отображен во всех вышестоящих категориях.',
];
4 changes: 4 additions & 0 deletions lang/uk/global.php
Original file line number Diff line number Diff line change
Expand Up @@ -51,4 +51,8 @@
'category_help' => 'Визначте основну категорію товара. Використовується для формування основного посилання та ланцюжка навігації.',
'catalog_root' => 'Корінь каталогу',
'catalog_root_help' => 'Визначте ресурс, що буде використовуватись як корінь каталогу товарів типово.',
'to_list_products' => 'До списку товарів',
'price_help' => 'Основна ціна товару в валюті магазину.',
'categories' => 'Категорії',
'categories_help' => 'Список категорій, у яких повинен відображатися товар. Формується із дерева ресурсів від кореня, який позначено як каталог. Якщо обрано підкатегорію - товар буде відображено у всіх батьківських категоріях.',
];
1 change: 1 addition & 0 deletions module/sCommerceModule.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
break;
case "product":
$tabs = ['product'];
$data['categories'] = [];
break;
case "settings":
if (!evo()->hasPermission('settings')) {
Expand Down
38 changes: 38 additions & 0 deletions src/Controllers/sCommerceController.php
Original file line number Diff line number Diff line change
@@ -1,9 +1,12 @@
<?php namespace Seiger\sCommerce\Controllers;

use EvolutionCMS\Models\SiteContent;
use Seiger\sCommerce\Facades\sCommerce;

class sCommerceController
{
protected $categories = [];

/**
* Show tab page with sOffer files
*
Expand Down Expand Up @@ -132,6 +135,23 @@ public function langList(): array
return $lang;
}

/**
* List of categories and subcategories
*
* @return array
*/
public function listCategories(): array
{
$root = SiteContent::find(evo()->getConfig('scom_catalog_root', evo()->getConfig('site_start', 1)));
$this->categories[$root->id] = $root->pagetitle;
if ($root->hasChildren()) {
foreach ($root->children as $item) {
$this->categoryCrumb($item);
}
}
return $this->categories;
}

/**
* Price validation
*
Expand Down Expand Up @@ -219,4 +239,22 @@ public function view(string $tpl, array $data = [])
{
return \View::make('sCommerce::'.$tpl, $data);
}

/**
* Categories name as crumb
*
* @param $resource
* @param $crumb
* @return void
*/
protected function categoryCrumb($resource, $crumb = ''): void
{
$crumb = trim($crumb) ? $crumb . ' > ' . $resource->pagetitle : $resource->pagetitle;
$this->categories[$resource->id] = $crumb;
if ($resource->hasChildren()) {
foreach ($resource->children as $item) {
$this->categoryCrumb($item, $crumb);
}
}
}
}
3 changes: 3 additions & 0 deletions views/partials/style.blade.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,14 @@
#actions .btn-group .btn .fas, #_actions .btn-group .btn .fas, .sectionTrans .btn-group .btn .fa, .sectionTrans .btn-group .btn .fas{display:none;width:1em;font-size:1em;text-align:center;}
#copyright{position:fixed;bottom:0;right:0;}
#copyright img{width:35px;}
#preview.form-control{max-width:85px;background:#CECECF;}
input[type=checkbox], input[type=radio] {padding:0.5em;}
span[data-actual]::before{content:attr(data-actual);}
ul.select2-selection__rendered{margin-left:unset;}
.alertify .ajs-footer .ajs-buttons .ajs-button.ajs-ok {color:#fff;background-color:#d9534f;border-color:#d9534f;}
.badge.bg-seigerit{background-color:#0057B8 !important;color:#FFD700;font-size:85%;}
.hidden{display:none;}
.form-row .col{margin-right:20px;}
.tab-row-container{background:#CECECF;}
.tab-row .tab a{color:#0D0D0D;font-family:'Roboto';font-size:14px;font-weight:400;line-height:115%;text-transform:uppercase;padding:16px;}
.scom-conters{margin-bottom:24px;margin-top:8px;}
Expand Down
152 changes: 56 additions & 96 deletions views/productTab.blade.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
<div class="col">
<input type="checkbox" id="publishedcheck" class="form-checkbox form-control" name="publishedcheck" value="" onchange="documentDirty=true;" onclick="changestate(document.form.published);" @if(isset($product->published) && $product->published) checked @endif>
<input type="hidden" id="published" name="published" value="{{$product->published ?? 0}}" onchange="documentDirty=true;">
&emsp;<i class="fa fa-eye" data-tooltip="@lang('sCommerce::global.views')"> <b>{{$product->views ?? 0}}</b></i>
@if(evo()->getConfig('scom_rating_on', 1) == 1)&emsp;<i class="fa fa-eye" data-tooltip="@lang('sCommerce::global.views')"> <b>{{$product->views ?? 0}}</b></i>@endif
@if(evo()->getConfig('scom_rating_on', 1) == 1)&emsp;<i class="fa fa-star" data-tooltip="@lang('sCommerce::global.rating')"> <b>{{$product->rating ?? 0}}</b></i>@endif
@if(evo()->getConfig('scom_rating_on', 1) == 1)&emsp;<i class="fas fa-warehouse" data-tooltip="@lang('sCommerce::global.quantity')"> <b>{{$product->quantity ?? 0}}</b></i>@endif
</div>
Expand All @@ -35,33 +35,6 @@
</div>
</div>
</div>
<div class="row-col col-lg-3 col-md-6 col-12">
<div class="row form-row">
<div class="col-auto col-title">
<label for="parent" class="warning">@lang('sCommerce::global.category')</label>
<i class="fa fa-question-circle" data-tooltip="@lang('sCommerce::global.category_help')"></i>
</div>
<div class="col">
<div>
@php($parentlookup = false)
@if(($product->parent ?? evo()->getConfig('scom_catalog_root', 0)) == 0)
@php($parentname = evo()->getConfig('site_name'))
@else
@php($parentlookup = ($product->parent ?? evo()->getConfig('scom_catalog_root', 1)))
@endif
@if($parentlookup !== false && is_numeric($parentlookup))
@php($parentname = \EvolutionCMS\Models\SiteContent::withTrashed()->select('pagetitle')->find($parentlookup)->pagetitle)
@if(!$parentname)
@php(evo()->webAlertAndQuit($_lang["error_no_parent"]))
@endif
@endif
<i id="plock" class="fa fa-folder" onclick="enableParentSelection(!allowParentSelection);"></i>
<b id="parentName">{{$parentlookup}} ({{entities($parentname)}})</b>
<input type="hidden" name="parent" value="{{($product->parent ?? evo()->getConfig('scom_catalog_root', 1))}}" onchange="documentDirty=true;" />
</div>
</div>
</div>
</div>
<div class="row-col col-lg-3 col-md-6 col-12">
<div class="row form-row">
<div class="col-auto col-title">
Expand All @@ -73,112 +46,99 @@
</div>
</div>
</div>
<div class="row-col col-lg-3 col-md-6 col-12">
<div class="row-col col-lg-3 col-md-3 col-12">
<div class="row form-row">
<div class="col-auto col-title">
<label for="price" class="warning">@lang('sCommerce::global.price')</label>
<i class="fa fa-question-circle" data-tooltip="@lang('sCommerce::global.sku_help')"></i>
<div class="col-auto col-title-7">
<label for="alias" class="warning">@lang('global.resource_alias')</label>
<i class="fa fa-question-circle" data-tooltip="@lang('global.resource_alias_help')"></i>
</div>
<div class="col">
<input id="price" class="form-control" name="price_regular" value="{{$product->price_regular ?? ''}}" onblur="documentDirty=true;">
<div class="input-group col">
<input type="text" id="alias" class="form-control" name="alias" maxlength="255" value="{{$product->alias ?? ''}}" onchange="documentDirty=true;" spellcheck="true">
<a id="preview" href="{{$product->link ?? '/'}}" class="btn btn-outline-secondary form-control" type="button" target="_blank">@lang('global.preview')</a>
</div>
</div>
</div>
{{--@if(evo()->getConfig('sart_features_on', 1) == 1)
<div class="row-col col-lg-6 col-md-6 col-12">
<div class="row form-row">
<div class="col-auto col-title">
<label for="features" class="warning">@lang('sArticles::global.features')</label>
<i class="fa fa-question-circle" data-tooltip="@lang('sArticles::global.features_article_help')"></i>
</div>
<div class="col">
@php($product->feature = $product->features->pluck('fid')->toArray())
<select id="features" class="form-control select2" name="features[]" multiple onchange="documentDirty=true;">
@foreach($features as $feature)
<option value="{{$feature->fid}}" @if(in_array($feature->fid, $product->feature)) selected @endif>{{$feature->base}}</option>
@endforeach
</select>
</div>
</div>
</div>
@endif--}}
{{--<div class="row-col col-lg-6 col-md-6 col-12">
<div class="row-col col-lg-3 col-md-3 col-12">
<div class="row form-row">
<div class="col-auto col-title">
<label for="tags" class="warning">@lang('sArticles::global.main_tag_article')</label>
<i class="fa fa-question-circle" data-tooltip="@lang('sArticles::global.tags_article_help')"></i>
<label for="price" class="warning">@lang('sCommerce::global.price')</label>
<i class="fa fa-question-circle" data-tooltip="@lang('sCommerce::global.price_help')"></i>
</div>
<div class="col">
@php($product->tag = $product->tags()->pluck('tagid')->toArray())
<select id="type" class="form-control select2" name="tags[]" onchange="documentDirty=true;">
<option></option>
@foreach($tags as $tag)
<option value="{{$tag->tagid}}" @if($tag->tagid == $product->tag[0]) selected @endif>{{$tag->base}}</option>
@endforeach
</select>
<input id="price" class="form-control" name="price_regular" value="{{$product->price_regular ?? ''}}" onblur="documentDirty=true;">
</div>
</div>
</div>--}}
{{--<div class="row-col col-lg-6 col-md-6 col-12">
</div>
<div class="row-col col-lg-3 col-md-3 col-12">
<div class="row form-row">
<div class="col-auto col-title">
<label for="relevants" class="warning">@lang('sArticles::global.relevant_articles')</label>
<label for="parent" class="warning">@lang('sCommerce::global.category')</label>
<i class="fa fa-question-circle" data-tooltip="@lang('sCommerce::global.category_help')"></i>
</div>
<div class="col">
@php($productRelevants = data_is_json($product->relevants ?? '', true) ?: [])
<select id="relevants" class="form-control select2" name="relevants[]" multiple onchange="documentDirty=true;">
@foreach(sArticles::all(\Seiger\sArticles\sArticles::ALL_PAGES) as $item)
@if(($product->id ?? 0) != $item->id)
<option value="{{$item->id}}" @if(in_array($item->id, $productRelevants)) selected @endif>{{$item->pagetitle}}</option>
<div>
@php($parentlookup = false)
@if(($product->parent ?? evo()->getConfig('scom_catalog_root', 0)) == 0)
@php($parentname = evo()->getConfig('site_name'))
@else
@php($parentlookup = ($product->parent ?? evo()->getConfig('scom_catalog_root', 1)))
@endif
@if($parentlookup !== false && is_numeric($parentlookup))
@php($parentname = \EvolutionCMS\Models\SiteContent::withTrashed()->select('pagetitle')->find($parentlookup)->pagetitle)
@if(!$parentname)
@php(evo()->webAlertAndQuit($_lang["error_no_parent"]))
@endif
@endforeach
</select>
</div>
</div>
</div>--}}
<div class="row-col col-lg-6 col-md-6 col-12">
<div class="row form-row form-row-image">
<div class="col-auto col-title">
<label for="cover" class="warning">@lang('sArticles::global.image')</label>
<i class="fa fa-question-circle" data-tooltip="@lang('sArticles::global.image_help')"></i>
</div>
<div class="col">
<input type="text" id="cover" class="form-control" name="cover" value="{{$product->cover ?? ''}}" onchange="documentDirty=true;">
<input class="form-control" type="button" value="@lang('global.insert')" onclick="BrowseServer('cover')">
<div class="col-12">
<div id="image_for_cover" class="image_for_field" data-image="{{$product->coverSrc ?? ''}}" onclick="BrowseServer('cover')" style="background-image: url('{{$product->coverSrc ?? ''}}');"></div>
<script>document.getElementById('cover').addEventListener('change', evoRenderImageCheck, false);</script>
@endif
<i id="plock" class="fa fa-folder" onclick="enableParentSelection(!allowParentSelection);"></i>
<b id="parentName">{{$parentlookup}} ({{entities($parentname)}})</b>
<input type="hidden" name="parent" value="{{($product->parent ?? evo()->getConfig('scom_catalog_root', 1))}}" onchange="documentDirty=true;" />
</div>
</div>
</div>
</div>
<div class="row-col col-lg-6 col-md-6 col-12">
<div class="row form-row">
<div class="col-auto col-title-7">
<label for="alias" class="warning">@lang('global.resource_alias')</label>
<i class="fa fa-question-circle" data-tooltip="@lang('global.resource_alias_help')"></i>
<div class="col-auto col-title">
<label for="categories" class="warning">@lang('sCommerce::global.categories')</label>
<i class="fa fa-question-circle" data-tooltip="@lang('sCommerce::global.categories_help')"></i>
</div>
<div class="input-group col">
<input type="text" id="alias" class="form-control" name="alias" maxlength="255" value="{{$product->alias ?? ''}}" onchange="documentDirty=true;" spellcheck="true">
<a id="preview" href="{{$product->link ?? '/'}}" class="btn btn-outline-secondary form-control" type="button" target="_blank">@lang('global.preview')</a>
<div class="col">
<select id="categories" class="form-control select2" name="categories[]" multiple onchange="documentDirty=true;">
@foreach($sCommerceController->listCategories() as $key => $value)
<option value="{{$key}}" @if(in_array($key, $categories)) selected @endif>{{$value}}</option>
@endforeach
</select>
</div>
</div>
</div>
</div>
</form>
<div class="split my-3"></div>
@if($product->product)
<div class="row-col col-12">
<div class="row form-row">
<div class="col-auto col-title">
<label class="warning">@lang('sCommerce::global.gallery')</label>
<i class="fa fa-question-circle" data-tooltip="@lang('sCommerce::global.gallery_help')"></i>
</div>
<div class="col">
{!! sGallery::initialise('section', 'product', 'i') !!}
</div>
</div>
</div>
@endif

@push('scripts.bot')
<div id="actions">
<div class="btn-group">
<a id="Button5" class="btn btn-secondary" href="{!!$url!!}">
<i class="fa fa-times-circle"></i><span>@lang('sArticles::global.to_list_articles')</span>
<a id="Button5" class="btn btn-secondary" href="{!!$moduleUrl!!}">
<i class="fa fa-times-circle"></i><span>@lang('sCommerce::global.to_list_products')</span>
</a>
<a id="Button1" class="btn btn-success" href="javascript:void(0);" onclick="saveForm('#form');">
<i class="fa fa-floppy-o"></i>
<span>@lang('global.save')</span>
</a>
<a id="Button3" class="btn btn-danger" data-href="{{$url}}&get=articleDelete&i={{$product->id}}" data-delete="{{$product->id}}" data-name="{{$product->pagetitle}}">
<a id="Button3" class="btn btn-danger" data-href="{!!$moduleUrl!!}&get=productDelete&i={{$product->id}}" data-delete="{{$product->id}}" data-name="{{$product->pagetitle}}">
<i class="fa fa-trash"></i> <span>@lang('global.remove')</span>
</a>
</div>
Expand Down
Loading

0 comments on commit 5234d2f

Please sign in to comment.