/** * KSSystem::getLdmApiData() * * @param mixed $func * @param mixed $action * @param mixed $params * @return */ public static function getLdmApiData($func, $action = null, $params = array()) { $model = KSSystem::getModel('account'); if (!empty($func) || !empty($model->_auth)) { $api_key = null; $user = $model->getUserFullInfo(); if (isset($user->api_key)) { $api_key = $user->api_key; } $link = LDM_API_PATCH . '?func=' . $func . '&api_key=' . $api_key; if (!empty($action)) { $link .= '&action=' . $action; } if (!empty($params)) { foreach ($params as $key => $param) { $param = str_replace(' ', '%20', $param); $link .= '&' . $key . '=' . $param; } } //echo $link; $data_json = file_get_contents($link); if (!empty($data_json)) { return $data_json; } } return false; }
public static function sendOrderMail($order_id, $admin = false) { self::onExecuteBefore(array(&$order_id, &$admin)); $db = JFactory::getDBO(); JRequest::setVar('id', $order_id); $model = KSSystem::getModel('orders'); $order = $model->getOrder(); $order->items = KSMOrders::getOrderItems($order_id); $query = $db->getQuery(true); $query->select('*')->from('#__ksenmart_shipping_fields')->where('shipping_id=' . $order->shipping_id)->where('position=' . $db->quote('address'))->where('published=1')->order('ordering'); $db->setQuery($query); $address_fields = $db->loadObjectList(); $address = array(); foreach ($address_fields as $address_field) { if ($address_field->system && isset($order->address_fields[$address_field->title])) { $value = $order->address_fields[$address_field->title]; } elseif (!$address_field->system && isset($order->address_fields[$address_field->id])) { $value = $order->address_fields[$address_field->id]; } else { $value = ''; } $title = $address_field->system ? JText::_('ksm_cart_shipping_field_' . $address_field->title) : $address_field->title; $address[] = $title . ' - ' . $value; } $order->address_fields = implode(', ', $address); $order->customer_name = ''; if (isset($order->customer_fields['name']) && !empty($order->customer_fields['name'])) { $order->customer_name .= $order->customer_fields['name']; } if (isset($order->customer_fields['last_name']) && !empty($order->customer_fields['last_name'])) { $order->customer_name .= $order->customer_fields['last_name'] . ' '; } if (isset($order->customer_fields['first_name']) && !empty($order->customer_fields['first_name'])) { $order->customer_name .= $order->customer_fields['first_name'] . ' '; } if (isset($order->customer_fields['middle_name']) && !empty($order->customer_fields['middle_name'])) { $order->customer_name .= $order->customer_fields['middle_name']; } $order->phone = isset($order->customer_fields['phone']) && !empty($order->customer_fields['phone']) ? $order->customer_fields['phone'] : ''; $mail = JFactory::getMailer(); $params = JComponentHelper::getParams('com_ksenmart'); $sender = array($params->get('shop_email'), $params->get('shop_name')); $content = KSSystem::loadTemplate(array('order' => $order), 'order', 'default', 'mail'); $mail->isHTML(true); $mail->setSender($sender); $mail->Subject = 'Новый заказ №' . $order_id; $mail->Body = $content; if (!$admin) { $mail->AddAddress($order->customer_fields['email'], $order->customer_fields['name']); } else { $mail->AddAddress($params->get('shop_email'), $params->get('shop_name')); } $mail->Send(); self::onExecuteAfter(); return true; }
public function display($tpl = null) { $_session = JFactory::getSession(); $model_account = KSSystem::getModel('account'); $controller = KSSystem::getController('account'); $this->title = JText::_('KM_CATALOG_YA_MARKET'); $model = $this->getModel('yamarket'); $app = JFactory::getApplication(); $this->document->addScript(JURI::base() . 'components/com_ksenmart/js/yamarket.js'); $this->document->addStyleSheet(JURI::base() . 'components/com_ksenmart/css/yamarket.css'); if (!$model_account->checkAuthorize()) { $app->redirect('index.php?option=com_ksenmart&view=account&layout=default_login'); } else { $uid = $model_account->getUserId(); if (!empty($uid) && $uid > 0) { $layout = $this->getLayout(); $params = $model->getUserParams($uid); if (empty($params->ya_site_id)) { $app->redirect('index.php?option=com_ksenmart', 'KM_YA_MARKET_ACCESS_DENIED'); exit; } $shop_info = $model->getUserShopInfo($params->ya_site_id); switch ($layout) { case 'stat-placement': $jinput = $app->input; $fromDate = $jinput->get('fromDate', date('Y-m-d'), 'string'); $toDate = $jinput->get('toDate', date('Y-m-d'), 'string'); $groupBy = $jinput->get('groupBy', 'daily', 'string'); $this->path->addItem(JText::_('KM_YA_MARKET'), 'index.php?option=com_ksenmart&view=yamarket'); $this->path->addItem(JText::_('KM_YA_HITS_FOR_PLACEMENTS')); $statistic = $model->getShopStatisticByPlacesFull($fromDate, $toDate, $groupBy); $groupByList = JHTML::_('select.genericlist', array('daily' => 'дням', 'weekly' => 'неделям', 'monthly' => 'месяцам'), 'groupBy', 'class="inputbox"', 'value', 'text', $groupBy); $this->assignRef('statistic', $statistic); $this->assignRef('fromDate', $fromDate); $this->assignRef('toDate', $toDate); $this->assignRef('groupByList', $groupByList); break; case 'clicks-report-search': $jinput = $app->input; $groupBy = $jinput->get('groupBy', '-1', 'string'); $this->path->addItem(JText::_('KM_YA_MARKET'), 'index.php?option=com_ksenmart&view=yamarket'); $this->path->addItem(JText::_('KM_YA_CLICKS_REPORT_SEARCH')); $offersStatistic = $model->getShopOffersStatistic($groupBy, true); $groupByList = JHTML::_('select.genericlist', array('-1' => 'вчера', '-7' => '7 дней', '-30' => '30 дней'), 'groupBy', 'class="inputbox"', 'value', 'text', $groupBy); $this->assignRef('offersStatistic', $offersStatistic); $this->assignRef('groupByList', $groupByList); break; default: $offers = $this->get('ShopOffers'); $balance = $this->get('ShopBalance'); $statistic = $this->get('ShopStatistic'); $statisticByPlaces = $this->get('ShopStatisticByPlaces'); $offersStatistic = $this->get('ShopOffersStatistic'); /*$test = $this->get('Test'); print_r($test);*/ $this->assignRef('params', $params); $this->assignRef('offers', $offers); $this->assignRef('balance', $balance); $this->assignRef('statistic', $statistic); $this->assignRef('statisticByPlaces', $statisticByPlaces); $this->assignRef('offersStatistic', $offersStatistic); $this->assignRef('shop_info', $shop_info); break; } } } parent::display($tpl); }