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

72
simpla/RepairsAdmin.php Normal file
View File

@@ -0,0 +1,72 @@
<?php
/**
*
* @copyright 2026
* @author Alan Shan
*
*/
require_once('api/Simpla.php');
class RepairsAdmin extends Simpla
{
public function fetch()
{
// Обработка действий
if($this->request->method('post'))
{
// Действия с выбранными
$ids = $this->request->post('check');
if(is_array($ids))
switch($this->request->post('action'))
{
case 'disable':
{
$this->repairs->update_post($ids, array('visible'=>0));
break;
}
case 'enable':
{
$this->repairs->update_post($ids, array('visible'=>1));
break;
}
case 'delete':
{
foreach($ids as $id)
$this->repairs->delete_post($id);
break;
}
}
}
$filter = array();
$filter['page'] = max(1, $this->request->get('page', 'integer'));
$filter['limit'] = 20;
// Поиск
$keyword = $this->request->get('keyword', 'string');
if(!empty($keyword))
{
$filter['keyword'] = $keyword;
$this->design->assign('keyword', $keyword);
}
$posts_count = $this->repairs->count_posts($filter);
// Показать все страницы сразу
if($this->request->get('page') == 'all')
$filter['limit'] = $posts_count;
$posts = $this->repairs->get_posts($filter);
$this->design->assign('posts_count', $posts_count);
$this->design->assign('pages_count', ceil($posts_count/$filter['limit']));
$this->design->assign('current_page', $filter['page']);
$this->design->assign('posts', $posts);
return $this->design->fetch('repairs.tpl');
}
}