Advertisement
Guest User

Untitled

a guest
Mar 5th, 2015
212
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.67 KB | None | 0 0
  1. function admin_moveup($id = null, $delta = null) {
  2. $this->ProductNeed->id = $id;
  3. if (!$this->ProductNeed->exists()) {
  4. throw new NotFoundException(__('Invalid id'));
  5. }
  6.  
  7. if ($delta > 0) {
  8. $this->ProductNeed->moveUp($this->ProductNeed->id, abs($delta));
  9. } else {
  10. $this->Session->setFlash(
  11. 'Silahkan tentukan posisi nomor order terlebih dahulu'
  12. );
  13. }
  14.  
  15. return $this->redirect(array('admin' => true, 'controller' => $this->params['controller'], 'action' => 'index'));
  16. }
  17.  
  18. function admin_movedown($id = null, $delta = null) {
  19. $this->ProductNeed->id = $id;
  20. if (!$this->ProductNeed->exists()) {
  21. throw new NotFoundException(__('Invalid id'));
  22. }
  23.  
  24. if ($delta > 0) {
  25. $this->ProductNeed->moveDown($this->ProductNeed->id, abs($delta));
  26. } else {
  27. $this->Session->setFlash(
  28. 'Silahkan tentukan posisi nomor order terlebih dahulu'
  29. );
  30. }
  31.  
  32. return $this->redirect(array('admin' => true, 'controller' => $this->params['controller'], 'action' => 'index'));
  33. }
  34.  
  35. <table class="table table-bordered table-striped">
  36. <thead>
  37. <tr>
  38. <th>No</th>
  39. <th>Name</th>
  40. <th>Order</th>
  41. <th>Action</th>
  42. </tr>
  43. </thead>
  44. <tbody>
  45. <?php
  46. if(!empty($data['rows'])) {
  47. $i = 0;
  48. foreach($data['rows'] as $key => $value) {
  49. $i++;
  50. ?>
  51. <tr id="row-<?php echo $i; ?>">
  52. <td><?php echo $i; ?></td>
  53.  
  54. <td><?= $value ?></td>
  55. <td>
  56. <?php
  57. echo $this->Html->link(
  58. 'Up',
  59. '/admin/'.$this->params['controller'].'/moveup/'.$key.'/'.$i
  60. );
  61. ?>
  62. <?php
  63. echo $this->Html->link(
  64. 'Down',
  65. '/admin/'.$this->params['controller'].'/movedown/'.$key.'/'.$i
  66. );
  67. ?>
  68. </td>
  69. <td>
  70. <ul class="action">
  71. <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>
  72. <li><a href="#deletemodal-<?= $i ?>" data-toggle="modal"><i class="glyphicon glyphicon-ban-circle" data-toggle="tooltip" title="Hapus"></i></a></li>
  73. </ul>
  74. <?= $html->modalBoxDelete($i, $key) ?>
  75. </td>
  76. </tr>
  77. <?php
  78. }
  79. } else {
  80. echo $html->noData(4);
  81. }
  82. ?>
  83. </tbody>
  84. </table>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement