Как изменить цвет определенных строк по значению запроса, полученного из базы данных - PullRequest
0 голосов
/ 13 октября 2018

Я работаю в стандартной системе, система может предупредить пользователя, когда количество предметов ниже минимального количества, и выделить этот предмет в таблице предметов.Этот код, как я получаю данные элемента из базы данных.

   <?php
use Cake\ORM\TableRegistry;
$query=TableRegistry::get('Cuts')->find('all', array('conditions' => array('total < minimum_number')));
?>
<div class="cuts index large-9 medium-8 columns content">
    <h3><?= __('All Cuts') ?></h3>
    <table class="table table-striped table-bordered table-hover dataTable no-footer dtr-inline">
        <thead>
            <tr>
                <th scope="col"><?= $this->Paginator->sort('SKU') ?></th>
                <th scope="col"><?= $this->Paginator->sort('name') ?></th>
                <th scope="col"><?= $this->Paginator->sort('colour_id') ?></th>
                <th scope="col"><?= $this->Paginator->sort('collection_id') ?></th>
                <th scope="col"><?= $this->Paginator->sort('category_id') ?></th>
                <th scope="col"><?= $this->Paginator->sort('total') ?></th>
                <th scope="col"><?= $this->Paginator->sort('minimum_number') ?></th>
                <th scope="col"><?= $this->Paginator->sort('status') ?></th>
                <th scope="col" class="actions"><?= __('Actions') ?></th>
            </tr>
        </thead>
        <tbody>
            <?php foreach ($cuts as $cut): ?>
            <tr>
                <td><?= h($cut->SKU) ?></td>
                <td><?= h($cut->name) ?></td>
                <td><?= $cut->has('colour') ? $this->Html->link($cut->colour->name, ['controller' => 'Colours', 'action' => 'view', $cut->colour->id]) : '' ?></td>
                <td><?= $cut->has('collection') ? $this->Html->link($cut->collection->name, ['controller' => 'Collections', 'action' => 'view', $cut->collection->id]) : '' ?></td>
                <td><?= $cut->has('category') ? $this->Html->link($cut->category->name, ['controller' => 'Categories', 'action' => 'view', $cut->category->id]) : '' ?></td>
                <td><?= $this->Number->format($cut->total) ?></td>
                <td><?= $this->Number->format($cut->minimum_number) ?></td>
                <td><?= h($cut->status) ?></td>
                <td class="actions">
                    <?= $this->Html->link(__('View'), ['action' => 'view', $cut->id]) ?>
                    <?= $this->Html->link(__('Edit'), ['action' => 'edit', $cut->id]) ?>
                    <?= $this->Form->postLink(__('Delete'), ['action' => 'delete', $cut->id], ['confirm' => __('Are you sure you want to delete Cut {0}?', $cut->name)]) ?>
                </td>
            </tr>
            <?php endforeach; ?>
        </tbody>
    </table>

Понятия не имею, что делать, кто-нибудь может мне помочь?очень ценю это!

1 Ответ

0 голосов
/ 14 октября 2018

пример:

<tr <?php if($cut->total < 2): ?> class="higlight" <?php endif; ?>

Добавьте свою логику в , если утверждение

Добро пожаловать на сайт PullRequest, где вы можете задавать вопросы и получать ответы от других членов сообщества.
...