예제 #1
0
파일: tools.php 프로젝트: annggeel/tienda
 /**
  * Gets an item for displaying (as opposed to saving, which requires a JTable object)
  * using the query from the model and the tbl's unique identifier
  *
  * @return database->loadObject() record
  */
 public function getItem($pk = null, $refresh = false, $emptyState = true)
 {
     parent::getItem($emptyState);
     // adding this in the model so we don't have to have if statemnets all over the views and controllers'
     if (version_compare(JVERSION, '1.6.0', 'ge')) {
         if (!empty($this->_item->extension_id)) {
             $this->_item->id = $this->_item->extension_id;
         }
     }
     return $this->_item;
 }
예제 #2
0
 public function getItem($pk = null, $refresh = false, $emptyState = true)
 {
     if ($item = parent::getItem($pk, $refresh, $emptyState)) {
         // Convert the params field to an array.
         if (version_compare(JVERSION, '1.6.0', 'ge')) {
             $formdata = new JRegistry();
             $formdata->loadString($item->params);
             $item->data = $formdata->toArray('data');
         }
     }
     return $item;
 }
예제 #3
0
 public function getItem($pk = null, $refresh = false, $emptyState = true)
 {
     Tienda::load('TiendaHelperSubscription', 'helpers.subscription');
     if ($item = parent::getItem($pk, $refresh, $emptyState)) {
         $item->link = 'index.php?option=com_tienda&view=subscriptions&task=edit&id=' . $item->subscription_id;
         $item->link_view = 'index.php?option=com_tienda&view=subscriptions&task=view&id=' . $item->subscription_id;
         $item->history = TiendaHelperSubscription::getHistory($item->subscription_id);
         Tienda::load('TiendaQuery', 'library.query');
         $q = new TiendaQuery();
         $q->select('order_hash');
         $q->from('#__tienda_orders');
         $q->where('order_id = ' . $item->order_id);
         $db = JFactory::getDbo();
         $db->setQuery($q);
         $item->order_hash = $db->loadResult();
     }
     $dispatcher = JDispatcher::getInstance();
     $dispatcher->trigger('onPrepare' . $this->getTable()->get('_suffix'), array(&$item));
     return $item;
 }
예제 #4
0
 public function getItem($pk = null, $refresh = false, $emptyState = true)
 {
     if ($item = parent::getItem($pk, $refresh, $emptyState)) {
         $item->productfile_path = $this->correctPath($item->productfile_path);
     }
     return $item;
 }
예제 #5
0
 /**
  * Get the item with the related attributes (if $getEav is true)
  * @param	boolean	$emptyState
  * @param	boolean	$getEav
  */
 public function getItem($refresh = true, $getEav = true, $emptyState = true)
 {
     $this->_getEav = $getEav;
     $this->_getEavOptions = array();
     return parent::getItem(null, $refresh, $emptyState);
 }
예제 #6
0
파일: orders.php 프로젝트: annggeel/tienda
 public function getItem($pk = null, $refresh = false, $emptyState = true)
 {
     if (empty($this->_item)) {
         Tienda::load('TiendaHelperBase', 'helpers._base');
         JModel::addIncludePath(JPATH_ADMINISTRATOR . '/components/com_tienda/models');
         $amigos = TiendaHelperBase::getInstance('Amigos');
         $currency_helper = TiendaHelperBase::getInstance('Currency');
         if ($item = parent::getItem($pk, $refresh, $emptyState)) {
             // get the orderinfo
             $item->orderinfo = JTable::getInstance('OrderInfo', 'TiendaTable');
             $item->orderinfo->load(array('order_id' => $item->order_id));
             //retrieve the order's items
             $model = JModel::getInstance('OrderItems', 'TiendaModel');
             $model->setState('filter_orderid', $item->order_id);
             $model->setState('order', 'tbl.orderitem_name');
             $model->setState('direction', 'ASC');
             $item->orderitems = $model->getList($refresh);
             foreach ($item->orderitems as $orderitem) {
                 $model = JModel::getInstance('OrderItemAttributes', 'TiendaModel');
                 $model->setState('filter_orderitemid', $orderitem->orderitem_id);
                 $attributes = $model->getList();
                 $attributes_names = array();
                 $attributes_codes = array();
                 foreach ($attributes as $attribute) {
                     // store a csv of the attrib names
                     $attributes_names[] = JText::_($attribute->orderitemattribute_name);
                     if ($attribute->orderitemattribute_code) {
                         $attributes_codes[] = JText::_($attribute->orderitemattribute_code);
                     }
                 }
                 $orderitem->attributes_names = implode(', ', $attributes_names);
                 $orderitem->attributes_codes = implode(', ', $attributes_codes);
                 // adjust the price
                 $orderitem->orderitem_price = $orderitem->orderitem_price + floatval($orderitem->orderitem_attributes_price);
             }
             //retrieve the order's history
             $model = JModel::getInstance('OrderHistory', 'TiendaModel');
             $model->setState('filter_orderid', $item->order_id);
             $model->setState('order', 'tbl.date_added');
             $model->setState('direction', 'ASC');
             $item->orderhistory = $model->getList($refresh);
             $item->link_view = 'index.php?option=com_tienda&view=orders&task=view&id=' . $item->order_id;
             //retrieve the order's payments
             $model = JModel::getInstance('OrderPayments', 'TiendaModel');
             $model->setState('filter_orderid', $item->order_id);
             $model->setState('order', 'tbl.created_date');
             $model->setState('direction', 'ASC');
             $item->orderpayments = $model->getList($refresh);
             //retrieve the order's shippings
             $model = JModel::getInstance('OrderShippings', 'TiendaModel');
             $model->setState('filter_orderid', $item->order_id);
             $model->setState('order', 'tbl.created_date');
             $model->setState('direction', 'ASC');
             $item->ordershippings = $model->getList($refresh);
             //retrieve the order's taxclasses
             $model = JModel::getInstance('OrderTaxClasses', 'TiendaModel');
             $model->setState('filter_orderid', $item->order_id);
             $model->setState('order', 'tbl.ordertaxclass_description');
             $model->setState('direction', 'ASC');
             $item->ordertaxclasses = $model->getList($refresh);
             // retrieve the order's taxrates
             $model = JModel::getInstance('OrderTaxRates', 'TiendaModel');
             $model->setState('filter_orderid', $item->order_id);
             $model->setState('order', 'tbl.ordertaxclass_id, tbl.ordertaxrate_level');
             $item->ordertaxrates = $model->getList($refresh);
             // retrieve the order's currency
             // this loads the currency, using the FK is it is the same of the
             // currency used in the order, or the DSCParameter currency of the order otherwise
             $order_currency = new DSCParameter($item->order_currency);
             $order_currency = $order_currency->toArray();
             //$model = JModel::getInstance( 'Currencies', 'TiendaModel' );
             //$model->setId($item->currency_id);
             $item->currency = $currency_helper->load($item->currency_id);
             // if the order currency is not the same as it was during the order
             if (!empty($item->currency) && !empty($order_currency['currency_code']) && $item->currency->currency_code != $order_currency['currency_code']) {
                 // overwrite it with the original one
                 foreach (@$order_currency as $k => $v) {
                     $item->currency->{$k} = $v;
                 }
             }
             // has a commission?
             if ($amigos->isInstalled()) {
                 $item->commissions = $amigos->getCommissions($item->order_id);
             }
         }
         $this->_item = $item;
     }
     $dispatcher = JDispatcher::getInstance();
     $dispatcher->trigger('onPrepare' . $this->getTable()->get('_suffix'), array(&$this->_item));
     return $this->_item;
 }