Location: PHPKode > projects > HikaShop > front/views/order/view.html.php
<?php
/**
 * @package		HikaShop for Joomla!
 * @version		1.4.3
 * @author		hikashop.com
 * @copyright	(C) 2010 HIKARI SOFTWARE. All rights reserved.
 * @license		GNU/GPLv3 http://www.gnu.org/licenses/gpl-3.0.html
 */
defined('_JEXEC') or die('Restricted access');
?>
<?php
class OrderViewOrder extends JView{
	var $ctrl= 'order';
	var $nameListing = 'ORDERS';
	var $nameForm = 'HIKASHOP_ORDER';
	var $icon = 'order';
	function display($tpl = null,$params=array()){
		$this->paramBase = HIKASHOP_COMPONENT.'.'.$this->getName();
		$function = $this->getLayout();
		$this->params = $params;		
		if(method_exists($this,$function)) $this->$function();
		parent::display($tpl);
	}
	function listing(){
		$app =& JFactory::getApplication();
		$pageInfo = null;
		$pageInfo->filter->order->value = $app->getUserStateFromRequest( $this->paramBase.".filter_order", 'filter_order',	'a.order_created','cmd' );
		$pageInfo->filter->order->dir	= $app->getUserStateFromRequest( $this->paramBase.".filter_order_Dir", 'filter_order_Dir',	'desc',	'word' );
		$pageInfo->search = $app->getUserStateFromRequest( $this->paramBase.".search", 'search', '', 'string' );
		$pageInfo->search = JString::strtolower( $pageInfo->search );
		$pageInfo->limit->value = $app->getUserStateFromRequest( $this->paramBase.'.list_limit', 'limit', $app->getCfg('list_limit'), 'int' );
		$pageInfo->limit->start = $app->getUserStateFromRequest( $this->paramBase.'.limitstart', 'limitstart', 0, 'int' );
		$database	=& JFactory::getDBO();
		$searchMap = array('a.order_id','a.order_status');
		$filters = array('a.order_user_id='.(int)hikashop::loadUser());
		$order = '';
		if(!empty($pageInfo->filter->order->value)){
			$order = ' ORDER BY '.$pageInfo->filter->order->value.' '.$pageInfo->filter->order->dir;
		}
		if(!empty($pageInfo->search)){
			$searchVal = '\'%'.$database->getEscaped(JString::strtolower( $pageInfo->search ),true).'%\'';
			$id = hikashop::decode($pageInfo->search);
			$filter = implode(" LIKE $searchVal OR ",$searchMap)." LIKE $searchVal";
			if(!empty($id)){
				$filter .= " OR a.order_id LIKE '%".$database->getEscaped($id,true).'%\'';
			}
			$filters[] =  $filter;
		}
		$query = 'FROM '.hikashop::table('order').' AS a WHERE '.implode(' AND ',$filters).$order;
		$database->setQuery('SELECT a.* '.$query,(int)$pageInfo->limit->start,(int)$pageInfo->limit->value);
		$rows = $database->loadObjectList();
		if(!empty($pageInfo->search)){
			$rows = hikashop::search($pageInfo->search,$rows,'order_id');
		}
		$database->setQuery('SELECT COUNT(*) '.$query);
		$pageInfo->elements->total = $database->loadResult();
		$pageInfo->elements->page = count($rows);
		$currencyClass = hikashop::get('class.currency');
		$this->assignRef('currencyHelper',$currencyClass);
		if($pageInfo->elements->page){
		}else{
			$app =& JFactory::getApplication();
			$app->enqueueMessage(JText::_('NO_ORDERS_FOUND'));
		}
		jimport('joomla.html.pagination');
		$pagination = new JPagination( $pageInfo->elements->total, $pageInfo->limit->start, $pageInfo->limit->value );
		$this->assignRef('pagination',$pagination);
		$this->assignRef('pageInfo',$pageInfo);
		$string='';
		jimport('joomla.html.parameter');
		$params = new JParameter($string);
		$params->set('show_quantity_field',-1);
		$config =& hikashop::config();
		if(hikashop::level(1) && $config->get('allow_payment_button',1)){
			$default_status = $config->get('order_created_status','created');
			foreach($rows as $k => $order){
				if($order->order_status==$default_status){
					$rows[$k]->show_payment_button = true;
				}
			}
		}
		$this->assignRef('params',$params);
		$this->assignRef('rows',$rows);
		$cart = hikashop::get('helper.cart');
		$this->assignRef('cart',$cart);
		$category = hikashop::get('type.categorysub');
		$category->type = 'status';
		$category->load(true);
		$this->assignRef('order_statuses',$category);
	}
	function show(){
		$type = 'order';
		$order =& $this->_order($type);
		$config =& hikashop::config();
		$download_time_limit = $config->get('download_time_limit',0);
		$this->assignRef('download_time_limit',$download_time_limit);
		$download_number_limit = $config->get('download_number_limit',0);
		$this->assignRef('download_number_limit',$download_number_limit);
		$order_status_download_ok=false;
		$order_status_for_download = $config->get('order_status_for_download','confirmed,shipped');
		if(in_array($order->order_status,explode(',',$order_status_for_download))){
			$order_status_download_ok=true;
		}
		$this->assignRef('order_status_download_ok',$order_status_download_ok);
		$this->assignRef('config',$config);
		JHTML::_('behavior.modal');
		$fields = array();
		$fieldsClass = hikashop::get('class.field');
		if(hikashop::level(2)){
			$fields['entry'] = $fieldsClass->getData('frontcomp','entry');
		}
		$this->assignRef('fields',$fields);
	}
	function invoice(){
		$type = 'invoice';
		$this->setLayout('show');
		$order =& $this->_order($type);
		$js = "window.addEvent('domready', function() {window.print();setTimeout(function(){try{	window.top.document.getElementById('sbox-window').close(); }catch(err){ window.top.SqueezeBox.close(); }}, 50);});";
		$doc =& JFactory::getDocument();
		$doc->addScriptDeclaration($js);
		JHTML::_('behavior.mootools');
	}
	function &_order($type){
		$order_id = hikashop::getCID('order_id');
		if(!empty($order_id)){
			$class = hikashop::get('class.order');
			$order = $class->loadFullOrder($order_id,($type=='order'?true:false));
		}
		if(empty($order)){
			$app =& JFactory::getApplication();
			$app->redirect(hikashop::completeLink('order&task=listing',false,true));
		}
		$config =& hikashop::config();
		$store = str_replace(array("\r\n","\n","\r"),array('<br/>','<br/>','<br/>'),$config->get('store_address',''));
		$this->assignRef('store_address',$store);
		$this->assignRef('element',$order);
		$this->assignRef('order',$order);
		$this->assignRef('invoice_type',$type);
		$display_type = 'frontcomp';
		$this->assignRef('display_type',$display_type);
		$currencyClass = hikashop::get('class.currency');
		$this->assignRef('currencyHelper',$currencyClass);
		$fieldsClass = hikashop::get('class.field');
		$this->assignRef('fieldsClass',$fieldsClass);
		return $order;
	}
}
Return current item: HikaShop