Доработка раздела пользователей в Simpla

Когда постоянных покупателей становится много, появляется задача по их сегментации.

В моём случае потребовалось:

  • отобразить сумму покупок
  • реализовать сортировку по сумме покупок

/api/Users.php

switch ($filter['sort'])
{
    ...
    case 'top_price':
        $order = 'o.total_price DESC';
        break;
}
...
$query = $this->db->placehold("SELECT
    u.id, u.email, u.name, u.password, u.address, u.phone, u.group_id, u.enabled, u.last_ip, u.created, g.discount, g.name as group_name, o.total_price FROM __users u
    LEFT JOIN __groups g ON u.group_id=g.id 
    LEFT JOIN (SELECT
                SUM(total_price) total_price, user_id FROM __orders
                WHERE paid = 1 AND closed = 1 AND user_id <> 0 group by user_id) o
    ON o.user_id = u.id
    WHERE 1 $group_id_filter $keyword_filter $name_empty_filter ORDER BY $order $sql_limit");

/simpla/design/html/users.tpl

{if $sort!='name'}<a href="{url sort=name}">имени</a>{else}имени{/if} или
{if $sort!='top_price'}<a href="{url sort=top_price}">сумме покупок</a>{else}сумме покупок{/if} или
...
<div class="price cell">
    {if $user->total_price}{$user->total_price} {$currency->sign}{/if}
</div>
<div class="user_group cell">
    {$groups[$user->group_id]->name}
</div>

/simpla/design/css/style.css

#list .user_group {
    width:150px;
    text-align: right;
    color: #707070;
}
#list .price {
    width:65px;
    text-align: left;
    color: #707070;
}
2 комментария
Richardlousa

<a href=https://srpskainfo.com>XXX PORN</a>

KIRASank

To determine internal swelling is difficult enough, therefore, consequently, they influence the body for a long time, which threatens the normal fetus. Fluids are dangerous because they break blood circulation. Similar situation leads to worsening feeding and the breath baby, formed hypoxia.
Fighting such a pathology should be done with the help of correction feeding and special procedures so that water does not stay tissues. If expectant mother is resting, then under the feet preferably put a cushion or pillow to improve the blood circulation of tired legs. Prohibited long time to sit or stand, as this leads to stagnation in the body. It is recommended that the knee-elbow position several times a day in order to increase blood flow.
[url=http://pregnancyplus.info/how-to-relieve-breast-pain-during-pregnancy-useful-tips]how to relieve breast pain during pregnancy[/url]

Ваш комментарий
адрес не будет опубликован

ХТМЛ не работает

Ctrl + Enter
Популярное