Compare commits

..

No commits in common. "d78de57b84f8d9b72c58a47cf2098dd40ed56d1f" and "318a40c22238a9c910b016d77249e439905a9193" have entirely different histories.

4 changed files with 28 additions and 58 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::$table_name . '/', 'image'); $path = upload_file($file, $this->model_сlass_name . '/', 'image');
if (!empty($path)) { if (!empty($path)) {
$field_value = $path; $field_value = $path;

View File

@ -1,11 +1,6 @@
<?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';
@ -18,33 +13,6 @@ 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-bowl-food"></i> <i class="fa-solid fa-bag-shopping"></i>
</div> </div>
<div class="info"> <div class="info">
<div class="label">New recipes</div> <div class="label">Total sales</div>
<div class="value"><?= $context['recipes_count'] ?></div> <div class="value">0$</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-message"></i> <i class="fa-solid fa-money-bill-trend-up"></i>
</div> </div>
<div class="info"> <div class="info">
<div class="label">New reviews</div> <div class="label">Profit</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-user-slash"></i> <i class="fa-solid fa-cart-shopping"></i>
</div> </div>
<div class="info"> <div class="info">
<div class="label">Banned users</div> <div class="label">Orders</div>
<div class="value"><?= $context['ban_count'] ?></div> <div class="value">0</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"><?= $context['user_count'] ?></div> <div class="value">0</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:recipe-new') ?>" class="btn btn-secondary hover-anim"> <a href="<?php the_permalink('admin:product-new') ?>" class="btn btn-secondary hover-anim">
<i class="fa-solid fa-plus"></i> New recipe <i class="fa-solid fa-plus"></i> New Product
</a> </a>
<form action="<?php the_permalink('admin:recipe-list') ?>" method="get"> <form action="<?php the_permalink('admin:product-list') ?>" method="get">
<div class="input-admin"> <div class="input-admin">
<input type="text" name="s" placeholder="Search for recipes"> <input type="text" name="s" placeholder="Search for products">
<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,24 +64,26 @@
</div> </div>
</section> </section>
<h2 class="title">Latest resipes</h2> <h2 class="title">Latest orders</h2>
<table class="admin-table"> <table class="admin-table">
<thead> <thead>
<tr> <tr>
<th>Title</th> <th>Order number</th>
<th>Price</th> <th>Method</th>
<th>Status</th> <th>Total price</th>
<th>Created At</th> <th>Buyer</th>
<th>Created at</th>
</tr> </tr>
</thead> </thead>
<tbody> <tbody>
<?php foreach ($context['latest_recipes'] as $recipe): ?> <?php foreach ($context['last_orders'] as $order): ?>
<tr> <tr>
<td><a href="<?php the_permalink('admin:recipe', [$recipe->get_id()]) ?>"><?= $recipe->field_title ?></a></td> <td><a href="<?php the_permalink('admin:order', [$order->get_id()]) ?>"><?php echo $order->field_order_number ?></a></td>
<td><?= $recipe->get_price() ?></td> <td><?php echo $order->field_method ?></td>
<td><?= $recipe->get_status() ?></td> <td><?php echo $order->get_total_price() ?></td>
<td><?= $recipe->field_created_at ?></td> <td><?php echo $order->get_buyer_username() ?></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,