Compare commits
3 Commits
318a40c222
...
d78de57b84
| Author | SHA1 | Date | |
|---|---|---|---|
| d78de57b84 | |||
| b66f2c6709 | |||
| b6970ebef7 |
@ -139,7 +139,7 @@ abstract class AdminSingleController extends AdminBaseController
|
||||
case 'image':
|
||||
$file = $_FILES[$field['model_field']];
|
||||
if (isset($file)) {
|
||||
$path = upload_file($file, $this->model_сlass_name . '/', 'image');
|
||||
$path = upload_file($file, $this->model_сlass_name::$table_name . '/', 'image');
|
||||
|
||||
if (!empty($path)) {
|
||||
$field_value = $path;
|
||||
|
||||
@ -1,6 +1,11 @@
|
||||
<?php
|
||||
namespace Lycoreco\Apps\Admin\Controllers;
|
||||
|
||||
use Lycoreco\Apps\Recipes\Models\IngredientModel;
|
||||
use Lycoreco\Apps\Recipes\Models\RecipeModel;
|
||||
use Lycoreco\Apps\Users\Models\BanlistModel;
|
||||
use Lycoreco\Apps\Users\Models\UserModel;
|
||||
|
||||
class AdminHomeController extends Abstract\AdminBaseController
|
||||
{
|
||||
protected $template_name = APPS_PATH . '/Admin/Templates/home.php';
|
||||
@ -13,6 +18,33 @@ class AdminHomeController extends Abstract\AdminBaseController
|
||||
|
||||
$datetime_month_ago = new \DateTime();
|
||||
$datetime_month_ago->modify("-1 month");
|
||||
$datetime_month_ago_text = $datetime_month_ago->format('Y-m-d H:i:s' . '\'');
|
||||
|
||||
$context['user_count'] = UserModel::count(array(
|
||||
[
|
||||
'name' => 'obj.register_at',
|
||||
'type' => '>=',
|
||||
'value' => $datetime_month_ago_text
|
||||
]
|
||||
));
|
||||
$context['recipes_count'] = RecipeModel::count(array(
|
||||
[
|
||||
'name' => 'obj.created_at',
|
||||
'type' => '>=',
|
||||
'value' => $datetime_month_ago_text
|
||||
]
|
||||
));
|
||||
$context['ban_count'] = BanlistModel::count(array(
|
||||
[
|
||||
'name' => 'obj.created_at',
|
||||
'type' => '>=',
|
||||
'value' => $datetime_month_ago_text
|
||||
]
|
||||
));
|
||||
$context['latest_recipes'] = RecipeModel::filter(
|
||||
array(),
|
||||
['-obj.created_at']
|
||||
);
|
||||
|
||||
|
||||
return $context;
|
||||
|
||||
@ -7,31 +7,31 @@
|
||||
<div id="dashboard-stats">
|
||||
<div class="dashboard-stats__item top-sales">
|
||||
<div class="icon">
|
||||
<i class="fa-solid fa-bag-shopping"></i>
|
||||
<i class="fa-solid fa-bowl-food"></i>
|
||||
</div>
|
||||
<div class="info">
|
||||
<div class="label">Total sales</div>
|
||||
<div class="value">0$</div>
|
||||
<div class="label">New recipes</div>
|
||||
<div class="value"><?= $context['recipes_count'] ?></div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="dashboard-stats__item profit">
|
||||
<div class="icon">
|
||||
<i class="fa-solid fa-money-bill-trend-up"></i>
|
||||
<i class="fa-solid fa-message"></i>
|
||||
</div>
|
||||
<div class="info">
|
||||
<div class="label">Profit</div>
|
||||
<div class="value">0$</div>
|
||||
<div class="label">New reviews</div>
|
||||
<div class="value">0</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="dashboard-stats__item orders">
|
||||
<div class="icon">
|
||||
<i class="fa-solid fa-cart-shopping"></i>
|
||||
<i class="fa-solid fa-user-slash"></i>
|
||||
</div>
|
||||
<div class="info">
|
||||
<div class="label">Orders</div>
|
||||
<div class="value">0</div>
|
||||
<div class="label">Banned users</div>
|
||||
<div class="value"><?= $context['ban_count'] ?></div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@ -41,7 +41,7 @@
|
||||
</div>
|
||||
<div class="info">
|
||||
<div class="label">New users</div>
|
||||
<div class="value">0</div>
|
||||
<div class="value"><?= $context['user_count'] ?></div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
@ -51,12 +51,12 @@
|
||||
<h2 class="title">Quick tools</h2>
|
||||
|
||||
<div id="quicktools">
|
||||
<a href="<?php the_permalink('admin:product-new') ?>" class="btn btn-secondary hover-anim">
|
||||
<i class="fa-solid fa-plus"></i> New Product
|
||||
<a href="<?php the_permalink('admin:recipe-new') ?>" class="btn btn-secondary hover-anim">
|
||||
<i class="fa-solid fa-plus"></i> New recipe
|
||||
</a>
|
||||
<form action="<?php the_permalink('admin:product-list') ?>" method="get">
|
||||
<form action="<?php the_permalink('admin:recipe-list') ?>" method="get">
|
||||
<div class="input-admin">
|
||||
<input type="text" name="s" placeholder="Search for products">
|
||||
<input type="text" name="s" placeholder="Search for recipes">
|
||||
<button class="hover-anim" type="submit"><i class="fa-solid fa-magnifying-glass"></i></button>
|
||||
</div>
|
||||
</form>
|
||||
@ -64,26 +64,24 @@
|
||||
</div>
|
||||
</section>
|
||||
|
||||
<h2 class="title">Latest orders</h2>
|
||||
<h2 class="title">Latest resipes</h2>
|
||||
|
||||
<table class="admin-table">
|
||||
<thead>
|
||||
<tr>
|
||||
<th>Order number</th>
|
||||
<th>Method</th>
|
||||
<th>Total price</th>
|
||||
<th>Buyer</th>
|
||||
<th>Created at</th>
|
||||
<th>Title</th>
|
||||
<th>Price</th>
|
||||
<th>Status</th>
|
||||
<th>Created At</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
<?php foreach ($context['last_orders'] as $order): ?>
|
||||
<?php foreach ($context['latest_recipes'] as $recipe): ?>
|
||||
<tr>
|
||||
<td><a href="<?php the_permalink('admin:order', [$order->get_id()]) ?>"><?php echo $order->field_order_number ?></a></td>
|
||||
<td><?php echo $order->field_method ?></td>
|
||||
<td><?php echo $order->get_total_price() ?></td>
|
||||
<td><?php echo $order->get_buyer_username() ?></td>
|
||||
<td><?php echo $order->field_created_at ?></td>
|
||||
<td><a href="<?php the_permalink('admin:recipe', [$recipe->get_id()]) ?>"><?= $recipe->field_title ?></a></td>
|
||||
<td><?= $recipe->get_price() ?></td>
|
||||
<td><?= $recipe->get_status() ?></td>
|
||||
<td><?= $recipe->field_created_at ?></td>
|
||||
</tr>
|
||||
<?php endforeach; ?>
|
||||
</tbody>
|
||||
|
||||
@ -344,7 +344,7 @@ abstract class BaseModel
|
||||
else
|
||||
return false;
|
||||
}
|
||||
static function count($fields, $search, $additional_fields = array())
|
||||
static function count($fields, $search = '', $additional_fields = array())
|
||||
{
|
||||
$filter_result = static::filter(
|
||||
$fields,
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user