admin for Repairs Section

This commit is contained in:
Alan
2026-02-15 18:25:30 +03:00
parent 3942076805
commit 446351622f
11 changed files with 880 additions and 5 deletions

View File

@@ -116,7 +116,8 @@ $(function() {
'articles_categories' => 'Категории статей',
'marka' => 'Марка авто',
'model' => 'Модель авто'
'model' => 'Модель авто',
'repairs' => 'Автосервис'
]}
{foreach $perms as $p=>$name}

View File

@@ -0,0 +1,46 @@
{literal}
<link href="/js/file2/file.css?v=2" media="all" rel="stylesheet" type="text/css" />
<script src="/js/file2/uploader.js"></script>
<script src="/js/file2/file.js?v=21"></script>
<div class="clearfix" style="clear: both;"></div>
<hr />
<span class="btn fileinput-btn btn-info button_green" style="display: inline-block;" id="art-files-input"><i class="fa fa-plus"> Добавить файл</i>
<input type="file" multiple name="file"></span>
<div class="well2" style="margin-top: 10px;width: 90%;">
<div class="sx-form-images" style="margin-top: 20px;">
{/literal}
{foreach from=$repair_photos item=ph}
<div class="sx-form-preview" style="" data-id="{$ph->id}">
<img src="{$ph->img}" style3="width: 120px">
<div class="sx-move-photo">
<img src="/images/move.png">
</div>
<div class="sx-remove-photo">
<button type="button" class="btn btn-danger btn-xs sx-form-image-remove" data-id="{$ph->id}"><b>X</b></button>
</div>
</div>
{/foreach}
{literal}
</div>
<div class="clearfix" style="clear:both"></div>
</div>
<script>
$(function(){
var sxFile = new sxFormFile();
{/literal}
sxFile.init({$post->id}, '/simpla/ajax/file_action.php');
{literal}
})
</script>
{/literal}

View File

@@ -0,0 +1,153 @@
{* Вкладки *}
{capture name=tabs}
<li><a href="index.php?module=BlogAdmin">Блог</a></li>
<li><a href="index.php?module=ArticlesAdmin">Примеры работ</a></li>
<li><a href="index.php?module=ArticleCategoriesAdmin">Категории примеров работ</a></li>
<li><a href="{url module=ActionsAdmin id=null page=null}">Акции</a></li>
<li><a href="{url module=MarkasAdmin id=null page=null}">Марки и модели</a></li>
<li class="active"><a href="{url module=RepairsAdmin id=null page=null}">Автосервис</a></li>
{/capture}
{* Title *}
{$meta_title='Автосервис' scope=parent}
{* Поиск *}
{if $posts || $keyword}
<form method="get">
<div id="search">
<input type="hidden" name="module" value='BlogAdmin'>
<input class="search" type="text" name="keyword" value="{$keyword|escape}" />
<input class="search_button" type="submit" value=""/>
</div>
</form>
{/if}
{* Заголовок *}
<div id="header">
{if $keyword && $posts_count}
<h1>{$posts_count|plural:'Нашлась':'Нашлись':'Нашлись'} {$posts_count} {$posts_count|plural:'запись':'записей':'записи'}</h1>
{elseif $posts_count}
<h1>{$posts_count} {$posts_count|plural:'запись':'записей':'записи'} в акциях</h1>
{else}
<h1>Нет записей</h1>
{/if}
<a class="add" href="{url module=RepairsPostAdmin return=$smarty.server.REQUEST_URI}">Добавить запись</a>
</div>
{if $posts}
<div id="main_list">
<!-- Листалка страниц -->
{include file='pagination.tpl'}
<!-- Листалка страниц (The End) -->
<form id="form_list" method="post">
<input type="hidden" name="session_id" value="{$smarty.session.id}">
<div id="list">
{foreach $posts as $post}
<div class="{if !$post->visible}invisible{/if} row">
<input type="hidden" name="positions[{$post->id}]" value="{$post->position}">
<div class="checkbox cell">
<input type="checkbox" name="check[]" value="{$post->id}" />
</div>
<div class="name cell">
<a href="{url module=RepairsPostAdmin id=$post->id return=$smarty.server.REQUEST_URI}">{$post->name|escape}</a>
<br>
{$post->date|date}
</div>
<div class="icons cell">
<a class="preview" title="Предпросмотр в новом окне" href="../repairs/{$post->url}" target="_blank"></a>
<a class="enable" title="Активна" href="#"></a>
<a class="delete" title="Удалить" href="#"></a>
</div>
<div class="clear"></div>
</div>
{/foreach}
</div>
<div id="action">
<label id="check_all" class="dash_link">Выбрать все</label>
<span id="select">
<select name="action">
<option value="enable">Сделать видимыми</option>
<option value="disable">Сделать невидимыми</option>
<option value="delete">Удалить</option>
</select>
</span>
<input id="apply_action" class="button_green" type="submit" value="Применить">
</div>
</form>
<!-- Листалка страниц -->
{include file='pagination.tpl'}
<!-- Листалка страниц (The End) -->
</div>
{/if}
{* On document load *}
{literal}
<script>
$(function() {
// Раскраска строк
function colorize()
{
$("#list div.row:even").addClass('even');
$("#list div.row:odd").removeClass('even');
}
// Раскрасить строки сразу
colorize();
// Выделить все
$("#check_all").click(function() {
$('#list input[type="checkbox"][name*="check"]').attr('checked', 1-$('#list input[type="checkbox"][name*="check"]').attr('checked'));
});
// Удалить
$("a.delete").click(function() {
$('#list input[type="checkbox"][name*="check"]').attr('checked', false);
$(this).closest(".row").find('input[type="checkbox"][name*="check"]').attr('checked', true);
$(this).closest("form").find('select[name="action"] option[value=delete]').attr('selected', true);
$(this).closest("form").submit();
});
// Скрыт/Видим
$("a.enable").click(function() {
var icon = $(this);
var line = icon.closest(".row");
var id = line.find('input[type="checkbox"][name*="check"]').val();
var state = line.hasClass('invisible')?1:0;
icon.addClass('loading_icon');
$.ajax({
type: 'POST',
url: 'ajax/update_object.php',
data: {'object': 'repairs', 'id': id, 'values': {'visible': state}, 'session_id': '{/literal}{$smarty.session.id}{literal}'},
success: function(data){
icon.removeClass('loading_icon');
if(state)
line.removeClass('invisible');
else
line.addClass('invisible');
},
dataType: 'json'
});
return false;
});
// Подтверждение удаления
$("form").submit(function() {
if($('select[name="action"]').val()=='delete' && !confirm('Подтвердите удаление'))
return false;
});
});
</script>
{/literal}

View File

@@ -0,0 +1,212 @@
{capture name=tabs}
<li class="active"><a href="{url module=RepairsAdmin id=null page=null}">Автосервис</a></li>
{/capture}
{if $post->id}
{$meta_title = $post->name scope=parent}
{else}
{$meta_title = 'Новая услуга автосервиса' scope=parent}
{/if}
{* Подключаем Tiny MCE *}
{include file='tinymce_init.tpl'}
{* On document load *}
{literal}
<script src="design/js/jquery/datepicker/jquery.ui.datepicker-ru.js"></script>
<script>
$(function() {
$('input[name="date"]').datepicker({
regional:'ru'
});
// Автозаполнение мета-тегов
meta_title_touched = true;
meta_keywords_touched = true;
meta_description_touched = true;
url_touched = true;
update = {/literal}{if $post->url}true;{else}false;{/if}{literal}
if($('input[name="meta_title"]').val() == generate_meta_title() || $('input[name="meta_title"]').val() == '')
meta_title_touched = false;
if($('input[name="meta_keywords"]').val() == generate_meta_keywords() || $('input[name="meta_keywords"]').val() == '')
meta_keywords_touched = false;
if($('textarea[name="meta_description"]').val() == generate_meta_description() || $('textarea[name="meta_description"]').val() == '')
meta_description_touched = false;
if($('input[name="url"]').val() == generate_url() || $('input[name="url"]').val() == '')
url_touched = false;
$('input[name="meta_title"]').change(function() { meta_title_touched = true; });
$('input[name="meta_keywords"]').change(function() { meta_keywords_touched = true; });
$('textarea[name="meta_description"]').change(function() { meta_description_touched = true; });
$('input[name="url"]').change(function() { url_touched = true; });
$('input[name="name"]').keyup(function() { set_meta(); });
$('select[name="brand_id"]').change(function() { set_meta(); });
$('select[name="categories[]"]').change(function() { set_meta(); });
});
function set_meta()
{
if(!meta_title_touched && !update)
// $('input[name="meta_title"]').val(generate_meta_title());
if(!meta_keywords_touched && !update)
// $('input[name="meta_keywords"]').val(generate_meta_keywords());
if(!meta_description_touched && !update)
{
descr = $('textarea[name="meta_description"]');
descr.val(generate_meta_description());
descr.scrollTop(descr.outerHeight());
}
if(!url_touched && !update)
$('input[name="url"]').val(generate_url());
}
function generate_meta_title()
{
name = $('input[name="name"]').val();
return name;
}
function generate_meta_keywords()
{
name = $('input[name="name"]').val();
return name;
}
function generate_meta_description()
{
if(typeof(tinyMCE.get("annotation")) =='object')
{
description = tinyMCE.get("annotation").getContent().replace(/(<([^>]+)>)/ig," ").replace(/(\&nbsp;)/ig," ").replace(/^\s+|\s+$/g, '').substr(0, 512);
return description;
}
else
return $('textarea[name=annotation]').val().replace(/(<([^>]+)>)/ig," ").replace(/(\&nbsp;)/ig," ").replace(/^\s+|\s+$/g, '').substr(0, 512);
}
function generate_url()
{
url = $('input[name="name"]').val();
url = url.replace(/[\s]+/gi, '-');
url = translit(url);
url = url.replace(/[^0-9a-z_\-]+/gi, '').toLowerCase();
return url;
}
function translit(str)
{
var ru=("А-а-Б-б-В-в-Ґ-ґ-Г-г-Д-д-Е-е-Ё-ё-Є-є-Ж-ж-З-з-И-и-І-і-Ї-ї-Й-й-К-к-Л-л-М-м-Н-н-О-о-П-п-Р-р-С-с-Т-т-У-у-Ф-ф-Х-х-Ц-ц-Ч-ч-Ш-ш-Щ-щ-Ъ-ъ-Ы-ы-Ь-ь-Э-э-Ю-ю-Я-я").split("-")
var en=("A-a-B-b-V-v-G-g-G-g-D-d-E-e-E-e-E-e-ZH-zh-Z-z-I-i-I-i-I-i-J-j-K-k-L-l-M-m-N-n-O-o-P-p-R-r-S-s-T-t-U-u-F-f-H-h-TS-ts-CH-ch-SH-sh-SCH-sch-'-'-Y-y-'-'-E-e-YU-yu-YA-ya").split("-")
var res = '';
for(var i=0, l=str.length; i<l; i++)
{
var s = str.charAt(i), n = ru.indexOf(s);
if(n >= 0) { res += en[n]; }
else { res += s; }
}
return res;
}
</script>
{/literal}
{if $message_success}
<!-- Системное сообщение -->
<div class="message message_success">
<span>{if $message_success == 'added'}Запись добавлена{elseif $message_success == 'updated'}Запись обновлена{/if}</span>
<a class="link" target="_blank" href="../blog/{$post->url}">Открыть запись на сайте</a>
{if $smarty.get.return}
<a class="button" href="{$smarty.get.return}">Вернуться</a>
{/if}
</div>
<!-- Системное сообщение (The End)-->
{/if}
{if $message_error}
<!-- Системное сообщение -->
<div class="message message_error">
<span>{if $message_error == 'url_exists'}Запись с таким адресом уже существует{/if}</span>
<a class="button" href="">Вернуться</a>
</div>
<!-- Системное сообщение (The End)-->
{/if}
<!-- Основная форма -->
<form method=post id=product enctype="multipart/form-data">
<input type=hidden name="session_id" value="{$smarty.session.id}">
<div id="name">
<input class="name" name=name type="text" value="{$post->name|escape}"/>
<input name=id type="hidden" value="{$post->id|escape}"/>
<div class="checkbox">
<input name=visible value='1' type="checkbox" id="active_checkbox" {if $post->visible}checked{/if}/> <label for="active_checkbox">Активна</label>
</div>
</div>
<!-- Левая колонка свойств товара -->
<div id="column_left">
<!-- Параметры страницы -->
<div class="block">
<ul>
<li><label class=property>Дата</label><input type=text name=date value='{$post->date|date}'></li>
</ul>
</div>
<div class="block layer">
<!-- Параметры страницы (The End)-->
<h2>Параметры страницы</h2>
<!-- Параметры страницы -->
<ul>
<li><label class=property>Адрес</label><div class="page_url"> /repairs/</div><input name="url" class="page_url" type="text" value="{$post->url|escape}" /></li>
<li><label class=property>Заголовок</label><input name="meta_title" type="text" value="{$post->meta_title|escape}" /></li>
<li><label class=property>Ключевые слова</label><input name="meta_keywords" type="text" value="{$post->meta_keywords|escape}" /></li>
<li><label class=property>Описание</label><textarea name="meta_description" />{$post->meta_description|escape}</textarea></li>
</ul>
</div>
<!-- Параметры страницы (The End)-->
</div>
<!-- Левая колонка свойств товара (The End)-->
<!-- Правая колонка свойств товара -->
<div id="column_right">
<!-- Изображение категории -->
<div class="block layer images">
<h2>Изображение</h2>
<input class='upload_image' name=image type=file>
<input type=hidden name="delete_image" value="">
{if $post->image}
<ul>
<li>
<a href='#' class="delete"><img src='design/images/cross-circle-frame.png'></a>
<img src="{$post->image|resizepost:100:100}" alt="" />
</li>
</ul>
{/if}
</div>
</div>
<!-- Правая колонка свойств товара (The End)-->
<!-- Описагние товара -->
<div class="block layer">
<h2>Краткое описание</h2>
<textarea name="annotation" class='editor_small'>{$post->annotation|escape}</textarea>
</div>
<div class="block">
<h2>Полное описание</h2>
<textarea name="body" class='editor_large'>{$post->text|escape}</textarea>
</div>
<!-- Описание товара (The End)-->
<input class="button_green button_save" type="submit" name="" value="Сохранить" />
{if $post->id}{include file="repair_photo.tpl"}{/if}
</form>
<!-- Основная форма (The End) -->