OfflinePaymentMethods.php 3.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138
  1. <?php
  2. /**
  3. *
  4. * PHP Pro Bid $Id$ 0oDe+Zef8vL5fyBqxJEnOiPBfY9UEmH0Sbc+tVIAfLh/zdvoA4ImlSkW8rjG9fJOwSmRzljRHHkuTlsdfwkkdA==
  5. *
  6. * @link http://www.phpprobid.com
  7. * @copyright Copyright (c) 2014 Online Ventures Software LTD & CodeCube SRL
  8. * @license http://www.phpprobid.com/license Commercial License
  9. *
  10. * @version 7.0
  11. */
  12. /**
  13. * offline payment methods table service class
  14. */
  15. namespace Ppb\Service\Table;
  16. use Ppb\Db\Table\OfflinePaymentMethods as MethodsTable;
  17. class OfflinePaymentMethods extends AbstractServiceTable
  18. {
  19. public function __construct()
  20. {
  21. parent::__construct();
  22. $this->setTable(
  23. new MethodsTable());
  24. }
  25. /**
  26. *
  27. * get all payment methods
  28. * to be used for the listing duration selector
  29. *
  30. * @return array
  31. */
  32. public function getMultiOptions()
  33. {
  34. $data = array();
  35. $translate = $this->getTranslate();
  36. $rows = $this->_table->fetchAll();
  37. foreach ($rows as $row) {
  38. $data[(string) $row['id']] = $translate->_($row['name']);
  39. }
  40. return $data;
  41. }
  42. /**
  43. *
  44. * get all table columns needed to generate the
  45. * offline payment methods management table in the admin area
  46. *
  47. * @return array
  48. */
  49. public function getColumns()
  50. {
  51. return array(
  52. array(
  53. 'label' => $this->_('Name'),
  54. 'element_id' => 'name',
  55. ),
  56. array(
  57. 'label' => $this->_('Order ID'),
  58. 'class' => 'size-mini',
  59. 'element_id' => 'order_id',
  60. ),
  61. array(
  62. 'label' => $this->_('Delete'),
  63. 'class' => 'size-mini',
  64. 'element_id' => array(
  65. 'id', 'delete'
  66. ),
  67. ),
  68. );
  69. }
  70. /**
  71. *
  72. * get all form elements that are needed to generate the
  73. * offline payment methods management table in the admin area
  74. *
  75. * @return array
  76. */
  77. public function getElements()
  78. {
  79. return array(
  80. array(
  81. 'id' => 'id',
  82. 'element' => 'hidden',
  83. ),
  84. array(
  85. 'id' => 'name',
  86. 'element' => 'text',
  87. 'attributes' => array(
  88. 'class' => 'form-control input-large',
  89. ),
  90. ),
  91. array(
  92. 'id' => 'order_id',
  93. 'element' => 'text',
  94. 'attributes' => array(
  95. 'class' => 'form-control input-mini',
  96. ),
  97. ),
  98. array(
  99. 'id' => 'delete',
  100. 'element' => 'checkbox',
  101. ),
  102. );
  103. }
  104. /**
  105. *
  106. * fetches all matched rows
  107. *
  108. * @param string|\Cube\Db\Select $where SQL where clause, or a select object
  109. * @param string|array $order
  110. * @param int $count
  111. * @param int $offset
  112. * @return array
  113. */
  114. public function fetchAll($where = null, $order = null, $count = null, $offset = null)
  115. {
  116. if ($order === null) {
  117. $order = 'order_id ASC, name ASC';
  118. }
  119. return parent::fetchAll($where, $order, $count, $offset);
  120. }
  121. }