0

我有一个从数据库中检索数据并将分页设置为每页显示 7 条记录的函数。目前检索到的数据可以在任何一天开始,但我想做的是每页检索到的数据必须始终从周四开始,到周五结束

下面是我的控制器功能

public function index()
{
    //Count all records
    $shopID= $this->uri->segment(2);
    $this->db->where('BDP_COST_CENTRE_NUMBER', $shopID);
    $this->data['shops_performances'] = $this->performance_m->get_data();
    $count = (count($this->data['shops_performances']));
    //Set up pagination
    $perpage = 7;
    if ($count > $perpage)
    {
        $config['base_url'] = 'http://bwr/index.php/daily_shop_performance/' . $shopID . '/';
        $config['total_rows'] = $count;
        $config['per_page'] = $perpage;
        $config['uri_segment'] = 3;
        $this->pagination->initialize($config);
        $this->data['pagination']=$this->pagination->create_links();
        $offset = $this->uri->segment(3);
    } else {
        $this->data['pagination']='';
        $offset = 0;
    }
    $shopID= $this->uri->segment(2);
    $this->db->where('BDP_COST_CENTRE_NUMBER', $shopID);
    $this->db->limit($perpage, $offset);
    $this->data['shops_performances'] = $this->performance_m->get_data();
    $this->data['subview'] = 'page/performance_page';
    $this->load->view('_layout_main', $this->data);
}

模型中的函数get_data如下

public function get_data($id)
{
    $this->db->select('*');
    $this->db->from('WHOUSE1.DLY_BWR_MAN_PERFORMANCE');
    $this->db->order_by('BDP_DATE DESC');
    $this->db->join('WHOUSE1.DATE_DIM', 'WHOUSE1.DATE_DIM.DATE_KEY = WHOUSE1.DLY_BWR_MAN_PERFORMANCE.BDP_DATE');
    $query = $this->db->get()->result_array();
    return $query;      
}

我的观点如下

<table class="table table-striped">
<thead>
    <tr>
        <th>Week Day</th>
        <th>Date</th>
        <th>Takings</th>
        <th>Payout</th>
        <th>Actual Slippage</th>
        <th>Edit</th>
    </tr>
</thead>
<tbody>

<?php if(count($shops_performances)): foreach($shops_performances as $shops_performance): ?>
  <tr>
        <td><?= $shops_performance['DAY_OF_WEEK_DDD']; ?></td>
        <td><?= $shops_performance['BDP_DATE']; ?></td>
        <td><?= $shops_performance['BDP_TAKE']; ?></td>
        <td><?= $shops_performance['BDP_PAYOUT']; ?></td>
        <td><?= $shops_performance['BDP_ACTUAL_SLIPPAGE']?></td>
        <td><?php echo btn_edit('daily_shop_performance/edit/' . $shops_performance['BDP_ID']); ?></td>
</tr>
   <?php endforeach; ?>
<?php else: ?>
    <tr>
        <td colspan="5">We could not find any record.</td>
    </tr>
<?php endif; ?> 
</tbody>
</table>

我想对工作日列进行排序

任何想法将不胜感激。谢谢你。

4

0 回答 0