Compare commits

...

2 Commits

Author SHA1 Message Date
b66f2c6709 Added information on dashboard 2025-06-28 00:10:15 +02:00
b6970ebef7 Fixed path issue during upload image by model 2025-06-27 22:44:05 +02:00
4 changed files with 58 additions and 28 deletions

View File

@ -139,7 +139,7 @@ abstract class AdminSingleController extends AdminBaseController
case 'image': case 'image':
$file = $_FILES[$field['model_field']]; $file = $_FILES[$field['model_field']];
if (isset($file)) { 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)) { if (!empty($path)) {
$field_value = $path; $field_value = $path;

View File

@ -1,6 +1,11 @@
<?php <?php
namespace Lycoreco\Apps\Admin\Controllers; 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 class AdminHomeController extends Abstract\AdminBaseController
{ {
protected $template_name = APPS_PATH . '/Admin/Templates/home.php'; 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 = new \DateTime();
$datetime_month_ago->modify("-1 month"); $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; return $context;

View File

@ -7,31 +7,31 @@
<div id="dashboard-stats"> <div id="dashboard-stats">
<div class="dashboard-stats__item top-sales"> <div class="dashboard-stats__item top-sales">
<div class="icon"> <div class="icon">
<i class="fa-solid fa-bag-shopping"></i> <i class="fa-solid fa-bowl-food"></i>
</div> </div>
<div class="info"> <div class="info">
<div class="label">Total sales</div> <div class="label">New recipes</div>
<div class="value">0$</div> <div class="value"><?= $context['recipes_count'] ?></div>
</div> </div>
</div> </div>
<div class="dashboard-stats__item profit"> <div class="dashboard-stats__item profit">
<div class="icon"> <div class="icon">
<i class="fa-solid fa-money-bill-trend-up"></i> <i class="fa-solid fa-message"></i>
</div> </div>
<div class="info"> <div class="info">
<div class="label">Profit</div> <div class="label">New reviews</div>
<div class="value">0$</div> <div class="value">0</div>
</div> </div>
</div> </div>
<div class="dashboard-stats__item orders"> <div class="dashboard-stats__item orders">
<div class="icon"> <div class="icon">
<i class="fa-solid fa-cart-shopping"></i> <i class="fa-solid fa-user-slash"></i>
</div> </div>
<div class="info"> <div class="info">
<div class="label">Orders</div> <div class="label">Banned users</div>
<div class="value">0</div> <div class="value"><?= $context['ban_count'] ?></div>
</div> </div>
</div> </div>
@ -41,7 +41,7 @@
</div> </div>
<div class="info"> <div class="info">
<div class="label">New users</div> <div class="label">New users</div>
<div class="value">0</div> <div class="value"><?= $context['user_count'] ?></div>
</div> </div>
</div> </div>
</div> </div>
@ -51,12 +51,12 @@
<h2 class="title">Quick tools</h2> <h2 class="title">Quick tools</h2>
<div id="quicktools"> <div id="quicktools">
<a href="<?php the_permalink('admin:product-new') ?>" class="btn btn-secondary hover-anim"> <a href="<?php the_permalink('admin:recipe-new') ?>" class="btn btn-secondary hover-anim">
<i class="fa-solid fa-plus"></i> New Product <i class="fa-solid fa-plus"></i> New recipe
</a> </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"> <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> <button class="hover-anim" type="submit"><i class="fa-solid fa-magnifying-glass"></i></button>
</div> </div>
</form> </form>
@ -64,26 +64,24 @@
</div> </div>
</section> </section>
<h2 class="title">Latest orders</h2> <h2 class="title">Latest resipes</h2>
<table class="admin-table"> <table class="admin-table">
<thead> <thead>
<tr> <tr>
<th>Order number</th> <th>Title</th>
<th>Method</th> <th>Price</th>
<th>Total price</th> <th>Status</th>
<th>Buyer</th> <th>Created At</th>
<th>Created at</th>
</tr> </tr>
</thead> </thead>
<tbody> <tbody>
<?php foreach ($context['last_orders'] as $order): ?> <?php foreach ($context['latest_recipes'] as $recipe): ?>
<tr> <tr>
<td><a href="<?php the_permalink('admin:order', [$order->get_id()]) ?>"><?php echo $order->field_order_number ?></a></td> <td><a href="<?php the_permalink('admin:recipe', [$recipe->get_id()]) ?>"><?= $recipe->field_title ?></a></td>
<td><?php echo $order->field_method ?></td> <td><?= $recipe->get_price() ?></td>
<td><?php echo $order->get_total_price() ?></td> <td><?= $recipe->get_status() ?></td>
<td><?php echo $order->get_buyer_username() ?></td> <td><?= $recipe->field_created_at ?></td>
<td><?php echo $order->field_created_at ?></td>
</tr> </tr>
<?php endforeach; ?> <?php endforeach; ?>
</tbody> </tbody>

View File

@ -344,7 +344,7 @@ abstract class BaseModel
else else
return false; return false;
} }
static function count($fields, $search, $additional_fields = array()) static function count($fields, $search = '', $additional_fields = array())
{ {
$filter_result = static::filter( $filter_result = static::filter(
$fields, $fields,