Exemple #1
0
	/**
	 * Render the view
	 */
	function display($tpl = null){

		if (!class_exists('VmHTML'))
			require(VMPATH_ADMIN . DS . 'helpers' . DS . 'html.php');
		if (!class_exists('CurrencyDisplay'))
			require(VMPATH_ADMIN . DS . 'helpers' . DS . 'currencydisplay.php');


		$model		= VmModel::getModel();

		vRequest::setvar('task','');

		$this->SetViewTitle('REPORT');

		$myCurrencyDisplay = CurrencyDisplay::getInstance();

		//update order items button
		/*$q = 'SELECT * FROM #__virtuemart_order_items WHERE `product_discountedPriceWithoutTax` IS NULL ';
		$db = JFactory::getDBO();
		$db->setQuery($q);
		$res = $db->loadRow();
		if($res) {
			JToolBarHelper::custom('updateOrderItems', 'new', 'new', vmText::_('COM_VIRTUEMART_REPORT_UPDATEORDERITEMS'),false);
			vmError('COM_VIRTUEMART_REPORT_UPDATEORDERITEMS_WARN');
		}*/

		$this->addStandardDefaultViewLists($model);
		$revenueBasic = $model->getRevenue();

		if($revenueBasic){
			$totalReport['revenueTotal_brutto']= $totalReport['revenueTotal_netto']= $totalReport['number_of_ordersTotal'] = $totalReport['itemsSoldTotal'] = 0 ;
			foreach($revenueBasic as &$j){
				vmdebug('VirtuemartViewReport revenue',$j);
				$totalReport['revenueTotal_netto'] += $j['order_subtotal_netto'];
				$totalReport['revenueTotal_brutto'] += $j['order_subtotal_brutto'];
				$totalReport['number_of_ordersTotal'] += $j['count_order_id'];
				$j['order_subtotal_netto'] = $myCurrencyDisplay->priceDisplay($j['order_subtotal_netto']);
				$j['order_subtotal_brutto'] = $myCurrencyDisplay->priceDisplay($j['order_subtotal_brutto']);
				//$j['product_quantity'] = $model->getItemsByRevenue($j);
				$totalReport['itemsSoldTotal'] +=$j['product_quantity'];
			}
			$totalReport['revenueTotal_netto'] = $myCurrencyDisplay->priceDisplay($totalReport['revenueTotal_netto']);
			$totalReport['revenueTotal_brutto'] = $myCurrencyDisplay->priceDisplay($totalReport['revenueTotal_brutto']);
			// if ( 'product_quantity'==vRequest::getCmd('filter_order')) {
				// foreach ($revenueBasic as $key => $row) {
					// $created_on[] =$row['created_on'];
					// $intervals[] =$row['intervals'];
					// $itemsSold[] =$row['product_quantity'];
					// $number_of_orders[] =$row['count_order_id'];
					// $revenue[] =$row['revenue'];

				// }
				// if (vRequest::getCmd('filter_order_Dir') == 'desc') array_multisort($itemsSold, SORT_DESC,$revenueBasic);
				// else array_multisort($itemsSold, SORT_ASC,$revenueBasic);
			// }
		}
		$this->assignRef('report', $revenueBasic);
		$this->assignRef('totalReport', $totalReport);

		//$itemsSold = $model->getItemsSold($revenueBasic);
		//$this->assignRef('itemsSold', $itemsSold);
		// I tihnk is to use in a different layout such as product solds
		// PATRICK K.
		// $productList = $model->getOrderItems();
		// $this->assignRef('productList', $productList);

		$orderstatusM =VmModel::getModel('orderstatus');
		$this->lists['select_date'] = $model->renderDateSelectList();
		$orderstates = vRequest::getVar ('order_status_code', array('C','S'));
		$this->lists['state_list'] = $orderstatusM->renderOSList($orderstates,'order_status_code',TRUE);
		$this->lists['intervals'] = $model->renderIntervalsList();
		$this->assignRef('from_period', $model->from_period);
		$this->assignRef('until_period', $model->until_period);

		$pagination = $model->getPagination();
		$this->assignRef('pagination', $pagination);

		parent::display($tpl);
	}
Exemple #2
0
    function display($tpl = null)
    {
        if (!class_exists('VmImage')) {
            require VMPATH_ADMIN . DS . 'helpers' . DS . 'image.php';
        }
        tsmConfig::loadJLang('com_tsmart_orders', TRUE);
        if (JFactory::getApplication()->isSite()) {
            $bar = JToolBar::getInstance('toolbar');
            $bar->appendButton('Link', 'back', 'com_tsmart_LEAVE', 'index.php?option=com_tsmart&manage=0');
        }
        $layout = $this->getLayout();
        if ($this->manager('report')) {
            vmSetStartTime('report');
            $model = tmsModel::getModel('tsmart');
            $nbrCustomers = $model->getTotalCustomers();
            $this->nbrCustomers = $nbrCustomers;
            $nbrActiveProducts = $model->getTotalActiveProducts();
            $this->nbrActiveProducts = $nbrActiveProducts;
            $nbrInActiveProducts = $model->getTotalInActiveProducts();
            $this->nbrInActiveProducts = $nbrInActiveProducts;
            $nbrFeaturedProducts = $model->getTotalFeaturedProducts();
            $this->nbrFeaturedProducts = $nbrFeaturedProducts;
            $ordersByStatus = $model->getTotalOrdersByStatus();
            $this->ordersByStatus = $ordersByStatus;
            $recentOrders = $model->getRecentOrders();
            if (!class_exists('CurrencyDisplay')) {
                require VMPATH_ADMIN . DS . 'helpers' . DS . 'currencydisplay.php';
            }
            /* Apply currency This must be done per order since it's vendor specific */
            $_currencies = array();
            // Save the currency data during this loop for performance reasons
            foreach ($recentOrders as $tsmart_order_id => $order) {
                //This is really interesting for multi-X, but I avoid to support it now already, lets stay it in the code
                if (!array_key_exists('v' . $order->tsmart_vendor_id, $_currencies)) {
                    $_currencies['v' . $order->tsmart_vendor_id] = CurrencyDisplay::getInstance('', $order->tsmart_vendor_id);
                }
                $order->order_total = $_currencies['v' . $order->tsmart_vendor_id]->priceDisplay($order->order_total);
            }
            $this->recentOrders = $recentOrders;
            $recentCustomers = $model->getRecentCustomers();
            $this->recentCustomers = $recentCustomers;
            $reportModel = tmsModel::getModel('report');
            vRequest::setvar('task', '');
            $myCurrencyDisplay = CurrencyDisplay::getInstance();
            $revenueBasic = $reportModel->getRevenue(60, true);
            $this->report = $revenueBasic['report'];
            vmJsApi::addJScript("jsapi", "//google.com/jsapi", false, false, '');
            vmJsApi::addJScript('vm.stats_chart', $revenueBasic['js'], false, true);
            vmTime('Created report', 'report');
        }
        //if($layout=='default'){
        $j = 'jQuery("#feed").ready(function(){
				var datas = "";
				vmSiteurl = "' . JURI::root() . '"
				jQuery.ajax({
						type: "GET",
						async: true,
						cache: false,
						dataType: "json",
						url: vmSiteurl + "index.php?option=com_tsmart&view=tsmart&task=feed",
						data: datas,
						dataType: "html"
					})
					.done(function( data ) {
						jQuery("#feed").append(data);
					});
				})';
        vmJsApi::addJScript('getFeed', $j, false, true);
        //}
        self::showACLPref($this);
        parent::display($tpl);
    }
Exemple #3
0
	function display($tpl = null) {

		if (!class_exists('VmImage'))
			require(VMPATH_ADMIN . DS . 'helpers' . DS . 'image.php');
		VmConfig::loadJLang('com_virtuemart_orders',TRUE);

		$model = VmModel::getModel('virtuemart');

		$nbrCustomers = $model->getTotalCustomers();
		$this->nbrCustomers=$nbrCustomers;

		$nbrActiveProducts = $model->getTotalActiveProducts();
		$this->nbrActiveProducts= $nbrActiveProducts;
		$nbrInActiveProducts = $model->getTotalInActiveProducts();
		$this->nbrInActiveProducts= $nbrInActiveProducts;
		$nbrFeaturedProducts = $model->getTotalFeaturedProducts();
		$this->nbrFeaturedProducts= $nbrFeaturedProducts;

		$ordersByStatus = $model->getTotalOrdersByStatus();
		$this->ordersByStatus= $ordersByStatus;

		$recentOrders = $model->getRecentOrders();
			if(!class_exists('CurrencyDisplay'))require(VMPATH_ADMIN.DS.'helpers'.DS.'currencydisplay.php');

			/* Apply currency This must be done per order since it's vendor specific */
			$_currencies = array(); // Save the currency data during this loop for performance reasons
			foreach ($recentOrders as $virtuemart_order_id => $order) {

				//This is really interesting for multi-X, but I avoid to support it now already, lets stay it in the code
				if (!array_key_exists('v'.$order->virtuemart_vendor_id, $_currencies)) {
					$_currencies['v'.$order->virtuemart_vendor_id] = CurrencyDisplay::getInstance('',$order->virtuemart_vendor_id);
				}
				$order->order_total = $_currencies['v'.$order->virtuemart_vendor_id]->priceDisplay($order->order_total);
			}
		$this->recentOrders= $recentOrders;
		$recentCustomers = $model->getRecentCustomers();
		$this->recentCustomers=$recentCustomers;

		if (!class_exists('vmRSS')) require(VMPATH_ADMIN.'/helpers/vmrss.php');

		$this->extensionsFeed = vmRSS::getExtensionsRssFeed();

		$virtuemartFeed = vmRSS::getVirtueMartRssFeed();
		$this->virtuemartFeed=$virtuemartFeed;

		if(JFactory::getApplication()->isSite()){
			$bar = JToolBar::getInstance('toolbar');
			$bar->appendButton('Link', 'back', 'COM_VIRTUEMART_LEAVE', 'index.php?option=com_virtuemart&manage=0');
		}

		if($this->manager('report')){
			vmSetStartTime('report');
			$reportModel		= VmModel::getModel('report');
			vRequest::setvar('task','');
			$myCurrencyDisplay = CurrencyDisplay::getInstance();
			$revenueBasic = $reportModel->getRevenue(60,true);
			$this->report = $revenueBasic['report'];

			vmJsApi::addJScript( "jsapi","//google.com/jsapi",false,false,'' );
			vmJsApi::addJScript('vm.stats_chart',$revenueBasic['js'],false);
			vmTime('Created report','report');
		}

		parent::display($tpl);
	}