tables.phtml 6.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141
  1. <?php
  2. /**
  3. * @version 7.10 [rev.7.10.01]
  4. */
  5. if (method_exists($service, 'getBreadcrumbs')) { ?>
  6. <?php $breadcrumbs = $service->getBreadcrumbs($parentId); ?>
  7. <ul class="breadcrumb">
  8. <li><a class="home" href="<?php echo $this->url(array('parent_id' => 0), null, true); ?>">
  9. <i class="fa fa-home"></i>
  10. </a> <span></span>
  11. </li>
  12. <?php foreach ((array)$breadcrumbs as $id => $name) { ?>
  13. <li>
  14. <a href="<?php echo $this->url(array('parent_id' => $id), null, true); ?>"><?php echo $name; ?></a>
  15. </li>
  16. <?php } ?>
  17. </ul>
  18. <?php } ?>
  19. <form method="<?php echo $this->form->getMethod(); ?>" action="<?php echo $this->form->getAction(); ?>"
  20. class="form-horizontal">
  21. <?php
  22. if ($this->form->hasElement('parent_id')) {
  23. $this->form->getElement('parent_id')->setValue($parentId);
  24. }
  25. echo $this->form->hiddenElements;
  26. ?>
  27. <div class="table-responsive">
  28. <table class="table table-striped table-hover">
  29. <thead>
  30. <tr>
  31. <?php foreach ($this->columns as $column) { ?>
  32. <th<?php echo (isset($column['class'])) ? ' class="' . $column['class'] . '"' : ''; ?>><?php echo $this->_($column['label']); ?></th>
  33. <?php } ?>
  34. </tr>
  35. </thead>
  36. <tbody>
  37. <!-- list table data -->
  38. <?php
  39. $checkboxCounter = 0;
  40. $formData = (array)$this->form->getData();
  41. $countFormData = count($formData);
  42. foreach ($formData as $data) {
  43. if (is_array($data)) {
  44. ?>
  45. <tr>
  46. <?php foreach ($this->columns as $column) { ?>
  47. <td<?php echo (isset($column['class'])) ? ' class="' . $column['class'] . '"' : ''; ?>>
  48. <?php foreach ((array)$column['element_id'] as $elementId) {
  49. /** @var \Cube\Form\Element $element */
  50. $element = $this->form->getElement($elementId);
  51. if (in_array($elementId, array('delete'))) {
  52. $element->setMultiOptions(array($data['id'] => null));
  53. }
  54. if (isset($data[$elementId])) {
  55. $element->setData($data[$elementId]);
  56. }
  57. $element->setBrackets('[' . $checkboxCounter . ']');
  58. echo $element;
  59. }
  60. if (isset($column['children'])) {
  61. ?>
  62. <a class="btn btn-default"
  63. href="<?php echo $this->url(array($column['children']['key'] => $data[$column['children']['value']]),
  64. null, true); ?>">
  65. <i class="fa fa-sitemap"></i>
  66. </a>
  67. <?php
  68. }
  69. if (isset($column['popup']) && $inAdmin) {
  70. ?>
  71. <a class="btn btn-default jq-popup-form"
  72. href="<?php echo $this->url(array('action' => $column['popup']['action'], 'id' => $data['id'])); ?>"
  73. title="<?php echo $this->_('Edit Options'); ?>">
  74. <i class="fa fa-th-list"></i>
  75. </a>
  76. <?php
  77. $userId = (!empty($data['user_id'])) ? $data['user_id'] : null;
  78. if ($userId) { ?>
  79. <div>
  80. <small>
  81. <?php
  82. $link = $this->url(array('controller' => 'users', 'action' => 'browse', 'view' => 'site', 'id' => $userId));
  83. echo sprintf(
  84. $this->_('Store Category - Owner: %s'),
  85. '<a href="' . $link . '">' . $this->userDetails($data['user_id'])->getUser()->username . '</a>'); ?>
  86. </small>
  87. </div>
  88. <?php } ?>
  89. <?php } ?>
  90. </td>
  91. <?php } ?>
  92. </tr>
  93. <?php
  94. $checkboxCounter++;
  95. }
  96. }
  97. if ($this->insertRows > 0) {
  98. ?>
  99. <!-- add new row(s) to the table -->
  100. <tr>
  101. <th colspan="<?php echo count($this->columns); ?>"><?php echo $this->translate('Insert New Data'); ?></th>
  102. </tr>
  103. <?php for ($i = 0; $i < $this->insertRows; $i++) { ?>
  104. <tr>
  105. <?php foreach ($this->columns as $column) { ?>
  106. <td<?php echo (isset($column['class'])) ? ' class="' . $column['class'] . '"' : ''; ?>>
  107. <?php foreach ((array)$column['element_id'] as $elementId) {
  108. $element = $this->form->getElement($elementId);
  109. if ($element->getType() != 'checkbox') {
  110. echo $element->setBrackets('[' . $checkboxCounter . ']')->setData(array())->render();
  111. }
  112. } ?>
  113. </td>
  114. <?php } ?>
  115. </tr>
  116. <?php
  117. $checkboxCounter++;
  118. }
  119. } ?>
  120. <?php if ($countFormData > 0 || $this->insertRows > 0) { ?>
  121. <tr>
  122. <td colspan="<?php echo count($this->columns); ?>"><?php echo $this->form->getElement(\App\Form\Tables::BTN_SUBMIT)->render(); ?></td>
  123. </tr>
  124. <?php } ?>
  125. </tbody>
  126. </table>
  127. </div>
  128. </form>