function getRegionList($country_id) { $db = $this->getDbo(); $data = $db->loadObjectList(); //print"<pre>"; print_r($data); require_once JPATH_SITE . '/components/com_tjfields/helpers/geo.php'; $tjGeoHelper = TjGeoHelper::getInstance('TjGeoHelper'); $rows = $tjGeoHelper->getRegionList($country_id, 'com_quick2cart'); return $rows; }
/** * Export order payment stats into a csv file. * * @return void * * @since 3.0 */ public function payment_csvexport() { $db = JFactory::getDBO(); $lang = JFactory::getLanguage(); $lang->load('com_quick2cart', JPATH_SITE); $query = $db->getQuery(true); $query->select("i.id, i.name, i.email, i.user_info_id,i.cdate, i.transaction_id, i.processor, i.order_tax, i.order_tax_details"); $query->select("i.order_shipping, i.order_shipping_details, i.amount, i.status, i.ip_address"); $query->from('#__kart_orders AS i'); $db->setQuery($query); $results = $db->loadObjectList(); $csvDataString .= implode(";", $headColumn); $csvDataString .= "\n"; $csvData = null; $csvData .= " Order_Id, Order_Date, User_Name, User_IP, Order_Tax, Order_Tax_details, Order_Shipping, Order_Shipping_details"; $csvData .= ", Order_Amount, Order_Status, Payment_Gateway, Cart_Items, billing_email, billing_first_name, billing_last_name, billing_phone"; $csvData .= ", billing_address, billing_city, billing_state, billing_country_name, billing_postal_code, shipping_email"; $csvData .= ", shipping_first_name, shipping_last_name, shipping_phone"; $csvData .= ", shipping_address, shipping_city, shipping_state, shipping_country_name, shipping_postal_code"; $csvData .= "\n"; $filename = "Orders_" . date("Y-m-d_H-i", time()); header("Content-type: application/vnd.ms-excel"); header("Content-disposition: csv" . date("Y-m") . ".csv"); header("Content-disposition: filename=" . $filename . ".csv"); // Get geo manager obj require_once JPATH_SITE . '/components/com_tjfields/helpers/geo.php'; $tjGeoHelper = TjGeoHelper::getInstance('TjGeoHelper'); foreach ($results as $result) { if ($result->id) { $order_tax_details = str_replace(",", ";", $result->order_tax_details); $order_shipping_details = addslashes(str_replace(",", ";", $result->order_shipping_details)); $csvData .= '"' . $result->id . '"' . ',' . '"' . $result->cdate . '"'; $csvData .= ',' . '"' . JFactory::getUser($result->user_info_id)->username . '"'; $csvData .= ',' . '"' . $result->ip_address . '"' . ',' . '"' . $result->order_tax . '"'; $csvData .= ',' . $order_tax_details . ',' . '"' . $result->order_shipping . '"'; $csvData .= ',' . $order_shipping_details . ',' . '"' . $result->amount . '"' . ','; switch ($result->status) { case 'C': $orderstatus = JText::_('QTC_CONFR'); break; case 'RF': $orderstatus = JText::_('QTC_REFUN'); break; case 'S': $orderstatus = JText::_('QTC_SHIP'); break; case 'P': $orderstatus = JText::_('QTC_PENDIN'); break; } $query = "SELECT count(order_item_id) FROM #__kart_order_item WHERE order_id =" . $result->id; $db->setQuery($query); $cart_items = $db->loadResult(); $csvData .= '"' . $orderstatus . '"' . ',' . '"' . $result->processor . '"' . ',' . '"' . $cart_items . '"' . ','; // Getting billind detail $query = $db->getQuery(true); $query->select("ou.*"); $query->from('#__kart_users as ou'); $query->where("ou.address_type='BT' AND ou.user_id =" . $result->user_info_id); $query->where("ou.order_id=" . $result->id); $query->order("id DESC"); $db->setQuery($query); $billin = $db->loadObject(); if ($billin) { // Getting country and region names from their codes. if (is_numeric($billin->country_code)) { $billin->country_code = $tjGeoHelper->getCountryNameFromId($billin->country_code); } if (is_numeric($billin->state_code)) { $billin->state_code = $tjGeoHelper->getRegionNameFromId($billin->state_code); } $csvData .= '"' . $billin->user_email . '"'; $csvData .= ',' . '"' . $billin->firstname . '"'; $csvData .= ',' . '"' . $billin->lastname . '"'; $csvData .= ',' . '"' . $billin->phone . '"'; $csvData .= ',' . '"' . $billin->address . '"'; $csvData .= ',' . '"' . $billin->city . '"'; $csvData .= ',' . '"' . $billin->state_code . '"'; $csvData .= ',' . '"' . $billin->country_code . '"'; $csvData .= ',' . '"' . $billin->zipcode . '"' . ','; } $query = $db->getQuery(true); $query->select("ou.*"); $query->from('#__kart_users as ou'); $query->where("ou.address_type='ST' AND ou.user_id =" . $result->user_info_id); $query->where("ou.order_id=" . $result->id); $query->order("id DESC"); $db->setQuery($query); $shipping = $db->loadObject(); if ($shipping) { // Getting country and region names from their codes. if (is_numeric($shipping->country_code)) { $shipping->country_code = $tjGeoHelper->getCountryNameFromId($shipping->country_code); } if (is_numeric($shipping->state_code)) { $shipping->state_code = $tjGeoHelper->getRegionNameFromId($shipping->state_code); } $csvData .= '"' . $shipping->user_email . '"'; $csvData .= ',' . '"' . $shipping->firstname . '"'; $csvData .= ',' . '"' . $shipping->lastname . '"'; $csvData .= ',' . '"' . $shipping->phone . '"' . ','; $csvData .= '"' . $shipping->address . '"'; $csvData .= ',' . '"' . $shipping->city . '"'; $csvData .= ',' . '"' . $shipping->state_code . '"'; $csvData .= ',' . '"' . $shipping->country_code . '"'; $csvData .= ',' . '"' . $shipping->zipcode . '"' . ','; } print $csvData .= "\n"; } } ob_clean(); print $csvData; exit; }
function getCustomers($store_id) { $db = JFactory::getDBO(); $query = $this->buildCustomer($store_id); if (!empty($query)) { $this->_data = $this->_getList($query, $this->getState('limitstart'), $this->getState('limit')); require_once JPATH_SITE . '/components/com_tjfields/helpers/geo.php'; $tjGeoHelper = TjGeoHelper::getInstance('TjGeoHelper'); foreach ($this->_data as $item) { $item->countryName = ''; $item->countryName = $tjGeoHelper->getCountryNameFromId($item->country_code); } return $this->_data; } else { return; } }
/** * Get list of regions from given country * * @param int $country_id Country id * * @return array */ public function getRegionList($country_id) { require_once JPATH_SITE . '/components/com_tjfields/helpers/geo.php'; $tjGeoHelper = TjGeoHelper::getInstance('TjGeoHelper'); $rows = $tjGeoHelper->getRegionList($country_id, 'com_quick2cart'); return $rows; }
function getuserState($country_id) { if (!empty($country_id)) { /*$db = JFactory::getDBO(); $query="SELECT r.id,r.region FROM #__tj_region AS r LEFT JOIN #__tj_country as c ON r.country_id=c.id where c.id=" . $country_id; $db->setQuery($query); $rows = $db->loadAssocList();*/ require_once JPATH_SITE . '/components/com_tjfields/helpers/geo.php'; $tjGeoHelper = TjGeoHelper::getInstance('TjGeoHelper'); $rows = (array) $tjGeoHelper->getRegionList($country_id, 'com_quick2cart'); return $rows; } }
/** * Method to add country name, region name. * * @param string &$orderlist orderlist * * @since 2.2 * * @return null */ public function addCountryRegionNames(&$orderlist) { require_once JPATH_SITE . '/components/com_tjfields/helpers/geo.php'; $tjGeoHelper = TjGeoHelper::getInstance('TjGeoHelper'); if (!empty($orderlist['order_info'])) { foreach ($orderlist['order_info'] as $key => $info) { // If country code contain text. $countryName = $info->country_code; if (is_numeric($info->country_code)) { $countryName = $tjGeoHelper->getCountryNameFromId($info->country_code); } if ($countryName) { // Generate new field $orderlist['order_info'][$key]->country_name = $countryName; } // Get Region code. $stateName = $info->state_code; if (is_numeric($info->state_code)) { $stateName = $tjGeoHelper->getRegionNameFromId($info->state_code); } if ($stateName) { // Generate new field $orderlist['order_info'][$key]->state_name = $stateName; } } } return $orderlist; }