123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165 |
- <?php
- /**
- *
- * PHP Pro Bid $Id$ F+up6fgKGS+K5hZbei9IEHRW6aVgjqCaD7k7bxWI26E=
- *
- * @link http://www.phpprobid.com
- * @copyright Copyright (c) 2014 Online Ventures Software LTD & CodeCube SRL
- * @license http://www.phpprobid.com/license Commercial License
- *
- * @version 7.0
- */
- /**
- * currencies table service class
- */
- namespace Ppb\Service\Table;
- use Ppb\Db\Table\Durations as DurationsTable;
- class Durations extends AbstractServiceTable
- {
- public function __construct()
- {
- parent::__construct();
- $this->setTable(
- new DurationsTable());
- }
- /**
- *
- * get all durations
- * to be used for the listing duration selector
- *
- * @param string $listingType
- * @return array
- */
- public function getMultiOptions($listingType = null)
- {
- $data = array();
- $translate = $this->getTranslate();
- $settings = $this->getSettings();
- if ($listingType == 'product' && $settings['enable_unlimited_duration']) {
- $data[0] = $translate->_('Unlimited');
- }
- $displayOptions = ($listingType == 'product' && $settings['enable_unlimited_duration'] && $settings['force_unlimited_duration']) ?
- false : true;
- if ($displayOptions) {
- $rows = $this->fetchAll()->toArray();
- foreach ((array)$rows as $row) {
- $data[(string)$row['days']] = $translate->_($row['description']);
- }
- }
- return $data;
- }
- /**
- *
- * get all table columns needed to generate the
- * durations management table in the admin area
- *
- * @return array
- */
- public function getColumns()
- {
- return array(
- array(
- 'label' => $this->_('Days'),
- 'class' => 'size-mini',
- 'element_id' => 'days',
- ),
- array(
- 'label' => $this->_('Description'),
- 'element_id' => 'description',
- ),
- array(
- 'label' => $this->_('Order ID'),
- 'class' => 'size-mini',
- 'element_id' => 'order_id',
- ),
- array(
- 'label' => $this->_('Delete'),
- 'class' => 'size-mini',
- 'element_id' => array(
- 'id', 'delete'
- ),
- ),
- );
- }
- /**
- *
- * get all form elements that are needed to generate the
- * durations management table in the admin area
- *
- * @return array
- */
- public function getElements()
- {
- return array(
- array(
- 'id' => 'id',
- 'element' => 'hidden',
- ),
- array(
- 'id' => 'days',
- 'element' => 'text',
- 'attributes' => array(
- 'class' => 'form-control input-mini',
- ),
- ),
- array(
- 'id' => 'description',
- 'element' => 'text',
- 'attributes' => array(
- 'class' => 'form-control input-medium',
- ),
- ),
- array(
- 'id' => 'order_id',
- 'element' => 'text',
- 'attributes' => array(
- 'class' => 'form-control input-mini',
- ),
- ),
- // array(
- // 'id' => 'selected',
- // 'element' => 'radio',
- // ),
- array(
- 'id' => 'delete',
- 'element' => 'checkbox',
- ),
- );
- }
- /**
- *
- * fetches all matched rows
- *
- * @param string|\Cube\Db\Select $where SQL where clause, or a select object
- * @param string|array $order
- * @param int $count
- * @param int $offset
- * @return array
- */
- public function fetchAll($where = null, $order = null, $count = null, $offset = null)
- {
- if ($order === null) {
- $order = 'order_id ASC, days ASC';
- }
- return parent::fetchAll($where, $order, $count, $offset);
- }
- }
|