Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function admin_moveup($id = null, $delta = null) {
- $this->ProductNeed->id = $id;
- if (!$this->ProductNeed->exists()) {
- throw new NotFoundException(__('Invalid id'));
- }
- if ($delta > 0) {
- $this->ProductNeed->moveUp($this->ProductNeed->id, abs($delta));
- } else {
- $this->Session->setFlash(
- 'Silahkan tentukan posisi nomor order terlebih dahulu'
- );
- }
- return $this->redirect(array('admin' => true, 'controller' => $this->params['controller'], 'action' => 'index'));
- }
- function admin_movedown($id = null, $delta = null) {
- $this->ProductNeed->id = $id;
- if (!$this->ProductNeed->exists()) {
- throw new NotFoundException(__('Invalid id'));
- }
- if ($delta > 0) {
- $this->ProductNeed->moveDown($this->ProductNeed->id, abs($delta));
- } else {
- $this->Session->setFlash(
- 'Silahkan tentukan posisi nomor order terlebih dahulu'
- );
- }
- return $this->redirect(array('admin' => true, 'controller' => $this->params['controller'], 'action' => 'index'));
- }
- <table class="table table-bordered table-striped">
- <thead>
- <tr>
- <th>No</th>
- <th>Name</th>
- <th>Order</th>
- <th>Action</th>
- </tr>
- </thead>
- <tbody>
- <?php
- if(!empty($data['rows'])) {
- $i = 0;
- foreach($data['rows'] as $key => $value) {
- $i++;
- ?>
- <tr id="row-<?php echo $i; ?>">
- <td><?php echo $i; ?></td>
- <td><?= $value ?></td>
- <td>
- <?php
- echo $this->Html->link(
- 'Up',
- '/admin/'.$this->params['controller'].'/moveup/'.$key.'/'.$i
- );
- ?>
- <?php
- echo $this->Html->link(
- 'Down',
- '/admin/'.$this->params['controller'].'/movedown/'.$key.'/'.$i
- );
- ?>
- </td>
- <td>
- <ul class="action">
- <li><a href="<?= Router::url('/admin/'.$this->params['controller'].'/edit/'.$key, true) ?>"><i class="glyphicon glyphicon-edit" data-toggle="tooltip" title="Ubah"></i></a></li>
- <li><a href="#deletemodal-<?= $i ?>" data-toggle="modal"><i class="glyphicon glyphicon-ban-circle" data-toggle="tooltip" title="Hapus"></i></a></li>
- </ul>
- <?= $html->modalBoxDelete($i, $key) ?>
- </td>
- </tr>
- <?php
- }
- } else {
- echo $html->noData(4);
- }
- ?>
- </tbody>
- </table>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement