function display($tpl = null) { global $mainframe, $option; $comquick2cartHelper = new comquick2cartHelper(); $mainframe = JFactory::getApplication(); $jinput = $mainframe->input; $option = $jinput->get('option'); //default layout is default $layout = $jinput->get('layout', 'default'); $this->setLayout($layout); // SEARCH TEXT BOX VALUE $search = $mainframe->getUserStateFromRequest($option . 'filter_search', 'filter_search', '', 'string'); $search = JString::strtolower($search); if ($search == null) { $search = ''; } $filter_order_Dir = $mainframe->getUserStateFromRequest('com_quick2cart.filter_order_Dir', 'filter_order_Dir', 'desc', 'word'); $filter_type = $mainframe->getUserStateFromRequest('com_quick2cart.filter_order', 'filter_order', 'saleqty', 'string'); //GET STORE DETAIL FOR FILTER $this->store_details = $comquick2cartHelper->getAllStoreDetails(); //STORE FILTER search_store $search_store = $mainframe->getUserStateFromRequest($option . 'search_store', 'search_store', 0, 'INTEGER'); $model = $this->getModel('salesreport'); $this->items = $model->getSalesReport(); //var_dump($this->items);die; //GET STORE DETAIL FOR FILTER $this->store_details = $comquick2cartHelper->getAllStoreDetails(); $total = $this->get('Total'); // use for pagination $this->total = $total; $pagination = $this->get('Pagination'); $this->pagination = $pagination; // from date FILTER $fromDate = $mainframe->getUserStateFromRequest($option . 'salesfromDate', 'salesfromDate', '', 'RAW'); // to date FILTER $toDate = $mainframe->getUserStateFromRequest($option . 'salestoDate', 'salestoDate', '', 'RAW'); $lists['salesfromDate'] = $fromDate; $lists['salestoDate'] = $toDate; $lists['order_Dir'] = $filter_order_Dir; $lists['order'] = $filter_type; $lists['search_store'] = $search_store; $lists['search'] = $search; $this->lists = $lists; $payee_name = $mainframe->getUserStateFromRequest('com_quick2cart', 'payee_name', '', 'string'); // $lists['payee_name']=$payee_name; $this->addToolbar(); // FOR DISPLAY SIDE FILTER if (JVERSION >= 3.0) { $this->sidebar = JHtmlSidebar::render(); } //var_dump($this->items);die; parent::display($tpl); }
/** * Gives sales reports csv export. * * @since 2.2.2 * @return null. */ public function csvexport() { $model = $this->getModel("salesreport"); $CSVData = $model->getCsvexportData(); $filename = "SalesReport_" . date("Y-m-d"); $csvDataString = null; $headColumn = array(); $headColumn[0] = JText::_('COM_QUICK2CART_SALESREPORT_STORE_ITEMID'); $headColumn[1] = JText::_('COM_QUICK2CART_SALESREPORT_PROD_NAME'); $headColumn[2] = JText::_('COM_QUICK2CART_SALESREPORT_STORE_NAME'); $headColumn[3] = JText::_('COM_QUICK2CART_SALESREPORT_STORE_ID'); $headColumn[4] = JText::_('COM_QUICK2CART_SALESREPORT_SALES_COUNT'); $headColumn[5] = JText::_('COM_QUICK2CART_SALESREPORT_AMOUNT'); $headColumn[6] = JText::_('COM_QUICK2CART_SALESREPORT_CREATED_BY'); $csvDataString .= implode(";", $headColumn); $csvDataString .= "\n"; header("Content-type: application/vnd.ms-excel"); header("Content-disposition: csv" . date("Y-m-d") . ".csv"); header("Content-disposition: filename=" . $filename . ".csv"); // Getting all store list $comquick2cartHelper = new comquick2cartHelper(); $store_details = $comquick2cartHelper->getAllStoreDetails(); $productHelper = new productHelper(); if (!empty($CSVData)) { foreach ($CSVData as $data) { $store_id = $data['store_id']; $csvrow = array(); $csvrow[0] = '"' . $data['item_id'] . '"'; $csvrow[1] = '"' . $data['item_name'] . '"'; $csvrow[2] = '""'; if (!empty($store_details[$store_id])) { $csvrow[2] = '"' . $store_details[$store_id]['title'] . '"'; } $csvrow[3] = '"' . $data['store_id'] . '"'; $csvrow[4] = '"' . $data['saleqty'] . '"'; // GETTING PRODUCT PRICE $prodAttDetails = $productHelper->getProdPriceWithDefltAttributePrice($data['item_id']); // CONSIDERING FIELD DISCOUNT, NOT COUPON DISCOUNT $discountPrice = $prodAttDetails['itemdetail']['discount_price']; $prodBasePrice = !empty($discountPrice) ? $discountPrice : $prodAttDetails['itemdetail']['price']; $prodPrice = $prodBasePrice + $prodAttDetails['attrDetail']['tot_att_price']; $prodPrice = strip_tags($comquick2cartHelper->getFromattedPrice($prodPrice)); $csvrow[5] = '"' . $prodPrice . '"'; $csvrow[6] = '""'; if (!empty($store_details[$store_id])) { $csvrow[6] = '"' . $store_details[$store_id]['firstname'] . '"'; } $csvDataString .= implode(";", $csvrow); $csvDataString .= "\n"; } } ob_clean(); echo $csvDataString . "\n"; jexit(); $link = 'index.php?option=com_quick2cart&view=salesreport'; $this->setRedirect($link); }
/** * Method to get a list of options for a list input. * * @return array An array of JHtml options. * * @since 11.4 */ protected function getOptions() { require_once JPATH_SITE . DS . 'components' . DS . 'com_quick2cart' . DS . 'helper.php'; $comquick2cartHelper = new comquick2cartHelper(); // Get all stores. $stores = $comquick2cartHelper->getAllStoreDetails(); $options = array(); //$options[] = JHtml::_('select.option', '', JText::_('QTC_SELET_STORE')); foreach ($stores as $key => $value) { $options[] = JHtml::_('select.option', $key, $value['title']); } // Merge any additional options in the XML definition. $options = array_merge(parent::getOptions(), $options); return $options; }
/** * Method to get a list of products. * * @return mixed An array of data items on success, false on failure. * * @since 1.6.1 */ public function getItems() { $items = parent::getItems(); $comquick2cartHelper = new comquick2cartHelper(); $quick2cartBackendProductsHelper = new quick2cartBackendProductsHelper(); $store_details = $comquick2cartHelper->getAllStoreDetails(); foreach ($items as $item) { // Get product category $catname = $comquick2cartHelper->getCatName($item->category); $item->category = !empty($catname) ? $catname : $item->category; // Get store name $item->store_name = ''; if (!empty($store_details[$item->store_id])) { $item->store_name = $store_details[$item->store_id]['title']; } // Get store owner $item->store_owner = ''; if (!empty($store_details[$item->store_id])) { $item->store_owner = $store_details[$item->store_id]['firstname']; } $item->edit_link = $quick2cartBackendProductsHelper->getProductLink($item->item_id, 'editLink'); $item->parent = $quick2cartBackendProductsHelper->getProductParentName($item->item_id); } return $items; }
/** * Display the view * * @param string $tpl The name of the template file to parse; automatically searches through the template paths. * * @return void */ public function display($tpl = null) { $this->state = $this->get('State'); $this->items = $this->get('Items'); $this->pagination = $this->get('Pagination'); $this->params = JComponentHelper::getParams('com_quick2cart'); $user = JFactory::getUser(); $this->logged_userid = $user->id; // Check for errors. $errors = $this->get('Errors'); if (count($errors)) { throw new Exception(implode("\n", $errors)); } $jinput = JFactory::getApplication()->input; $layout = $jinput->get('layout', 'default', 'STRING'); $option = $jinput->get('option', '', 'STRING'); $storeOwner = $jinput->get('qtcStoreOwner', 0, 'INTEGER'); $comquick2cartHelper = new comquick2cartHelper(); //$client='com_quick2cart'; //$client='*'; //$products = $model->getProducts($client); //Get all stores. $this->store_details = $comquick2cartHelper->getAllStoreDetails(); $this->categoryPage = 1; global $mainframe; $mainframe = JFactory::getApplication(); $model = $this->getModel('category'); //store_id is changed from STORE view $change_storeto = $mainframe->getUserStateFromRequest('$option.current_store', 'current_store', '', 'INTEGER'); $storeOwner = $jinput->get('qtcStoreOwner', 0, 'INTEGER'); // FOR STORE OWNER if (!empty($storeOwner)) { $storehelper = new storehelper(); $change_storeto = $storehelper->isVendorsStoreId($change_storeto); } $this->change_prod_cat = $mainframe->getUserStateFromRequest('prod_cat', 'prod_cat', '0', 'INTEGER'); //vm: #25029 $this->change_prod_cat = $jinput->get('prod_cat', 0, 'INTEGER'); // retrun store_id,role etc with order by role,store_id $this->store_role_list = $store_role_list = $comquick2cartHelper->getStoreIds(); $this->store_list = array(); foreach ($this->store_role_list as $store) { $this->store_list[] = $store['store_id']; } //$this->products = $model->getAllProducts(); $this->products = $this->items = $this->get('Items'); //$mainframe->setUserState('$option.current_store', '0'); // VM:commentted for store owner product view // when chage store,get latest storeid otherwise( on first load) set first storeid as default $this->store_id = $store_id = !empty($change_storeto) ? $change_storeto : ''; //$store_role_list[0]['store_id']; $pagination = $model->getPagination(); // ALL FETCH ALL CATEGORIES $this->cats = $comquick2cartHelper->getQ2cCatsJoomla($this->change_prod_cat); $this->pagination = $pagination; //Added by Sneha $filter_state = $mainframe->getUserStateFromRequest($option . 'search_list', 'search_list', '', 'string'); $lists['search_list'] = $filter_state; $this->assignRef('lists', $lists); //End added by Sneha $this->_setToolBar(); // Get toolbar path $this->toolbar_view_path = $comquick2cartHelper->getViewpath('vendor', 'toolbar'); if ($layout == 'my') { if (!$this->logged_userid) { $msg = JText::_('QTC_LOGIN'); $uri = JFactory::getApplication()->input->get('REQUEST_URI', '', 'server', 'string'); $url = base64_encode($uri); $mainframe->redirect(JRoute::_('index.php?option=com_users&view=login&return=' . $url), $msg); } // Creating status filter. $statuses = array(); $statuses[] = JHtml::_('select.option', '', JText::_('COM_QUICK2CART_SELONE')); $statuses[] = JHtml::_('select.option', 1, JText::_('COM_QUICK2CART_PUBLISH')); $statuses[] = JHtml::_('select.option', 0, JText::_('COM_QUICK2CART_UNPUBLISH')); $this->statuses = $statuses; // Setup toolbar $this->addTJtoolbar(); } $this->_prepareDocument(); parent::display($tpl); }