public static function add($params) { $result = array(); $result['success'] = true; if(empty($params)) { $result['success'] = false; $result['title'] = 'Error'; $result['content'] = JText::_('Error Register_Order.PAP'); return $result; } //unset($params['allow_work']); if(!empty($_COOKIE['oseAffiliate'])) { $orderParams = oseJson::decode($params['params']); $oseAffiliate = oseJSON::decode($_COOKIE['oseAffiliate']); $orderParams->oseaffiliateID = $oseAffiliate->oafid; $orderParams->osebannerID = $oseAffiliate->obid; $orderParams->first_ip = oseMscPublic::getIP(); //$orderParams->first_ip = oseMscPublic::getIP(); $params['params'] = oseJson::encode($orderParams); return $params; } else { return $params; } }
public static function add($params) { $result = array(); $result['success'] = true; if(empty($params)) { $result['success'] = false; $result['title'] = 'Error'; $result['content'] = JText::_('Error Register_Order.PAP'); return $result; } //unset($params['allow_work']); if(!empty($_COOKIE['PAPVisitorId'])) { $orderParams = oseJson::decode($params['params']); $orderParams->pap_visitorid = $_COOKIE['PAPVisitorId']; $orderParams->first_ip = oseMscPublic::getIP(); $params['params'] = oseJson::encode($orderParams); return $params; } else { return $params; } }
function display($tpl = null) { $tmpl = JRequest::getVar('tmpl'); if (empty($tmpl)) { JRequest::setVar('tmpl', 'component'); } $user = JFactory::getUser(); if (!oseMscPublic::isUserAdmin($user)) { $app = JFactory::getApplication('ADMIN'); $app->redirect('index.php', 'You do not has access to this page'); } $model = $this->getModel(); $model->checkViewExists(); $this->loadViewJs(); $this->loadGridJs(); $OSESoftHelper = new OSESoftHelper(); $footer = $OSESoftHelper->renderOSETM(); $this->assignRef('footer', $footer); $preview_menus = $OSESoftHelper->getPreviewMenus(); $this->assignRef('preview_menus', $preview_menus); $this->assignRef('OSESoftHelper', $OSESoftHelper); $title = JText::_('OSE Membership™ Configuration'); $this->assignRef('title', $title); parent::display($tpl); }
protected function validateJuser_username($val) { $user = JFactory::getUser(); if($user->guest) { return oseMscPublic::uniqueUserName($val, 0); } else { return oseMscPublic::uniqueUserName($val, $user->id); } }
public static function add($params) { $result = array(); $result['success'] = true; if (empty($params)) { $result['success'] = false; $result['title'] = 'Error'; $result['content'] = JText::_('Error Register_Order.Idev'); return $result; } $orderParams = oseJson::decode($params['params']); $orderParams->first_ip = oseMscPublic::getIP(); $params['params'] = oseJson::encode($orderParams); return $params; }
function display($tpl = null) { $app = JFactory::getApplication('SITE'); $config = oseMscConfig::getConfig('register', 'obj'); $items = oseMscPublic::getCartItems(); $this->checkUser(); $this->assignRef('item', $items[0]); $model = $this->getModel('payment'); $items = $model->getMemberships(); $com = OSECPU_PATH_JS . '/com_ose_cpu/extjs'; $msc = oseRegistry::call('msc'); $regForm = empty($config->register_form) ? null : $config->register_form; if (!empty($config->payment_system)) { $this->setLayout($config->payment_system); } $tpl = $regForm; $this->prepareDocument(); parent::display($tpl); }
function onAfterDispatch() { $app = JFactory::getApplication('SITE'); if ($app->isAdmin()) { return; } $document = JFactory::getDocument(); if (!JFile::exists(JPATH_SITE . DS . 'components' . DS . 'com_osemsc' . DS . 'init.php')) { return false; } else { require_once(JPATH_SITE . DS . 'components' . DS . 'com_osemsc' . DS . 'init.php'); require_once(JPATH_SITE . DS . 'components' . DS . 'com_osemsc' . DS . 'helpers' . DS . 'oseMscPublic.php'); } $config = oseMscConfig::getConfig('thirdparty', 'obj'); $account = oseObject::getValue($config, 'gag_account'); $standard_type = oseObject::getValue($config, 'gag_domain_mode'); $domain = oseObject::getValue($config, 'gag_domain'); $order_id = JRequest::getCmd('orderID', null); $code = oseMscPublic::htmlTrack($account, $standard_type, $domain, $order_id); $document->addScriptDeclaration($code); }
function display($tpl = null) { $tpl = null; $this->set('_layout', 'default'); oseHTML::initCss(); $com = OSECPU_PATH_JS . '/com_ose_cpu/extjs'; oseHTML::initScript(); oseHTML::script($com . '/ose/app.msg.js', '1.5'); oseHTML::script($com . '/grid/expander.js', '1.5'); oseHTML::script(OSEMSC_F_URL . '/libraries/init.js', '1.5'); $config = oseMscConfig::getConfig('global', 'obj'); oseHTML::stylesheet(OSEMSC_F_URL . '/assets/css/' . $config->frontend_style . '.css', (JOOMLA16) ? '1.6' : '1.5'); $user = JFactory::getUser(); $app = JFactory::getApplication('SITE'); $session = JFactory::getSession(); $db = oseDB::instance(); $order_id = JRequest::getInt('order_id'); $payment = oseRegistry::call('payment'); $where = array(); $where[] = "`order_id` = " . $db->quote($order_id); $order = $payment->getOrder($where, 'obj'); $orderInfoParams = oseJson::decode($order->params); $redirectUrl = urldecode($orderInfoParams->returnUrl); $config = oseMscConfig::getConfig('thirdparty', 'obj'); $account = oseObject::getValue($config, 'gag_account'); $standard_type = oseObject::getValue($config, 'gag_domain_mode'); $domain = oseObject::getValue($config, 'gag_domain'); $htmlTrack = oseMscPublic::htmlTrack($account, $standard_type, $domain, $order_id); $code = oseMscPublic::ajaxOrderTrack($account, $order_id); if (empty($code)) { $code = false; } else { $code = implode("", $code); } $document = JFactory::getDocument(); $document->addScriptDeclaration('var redirectUrl = "' . $redirectUrl . '";'); $document->addScriptDeclaration($htmlTrack); $document->addScriptDeclaration($code); $this->assignRef('orderInfo', $order); $this->prepareDocument(); parent::display($tpl); }
function display($tpl = null) { $user = oseMscPublic::getUser(); $mainframe = JFactory::getApplication(); $params = clone ($mainframe->getParams('com_osemsc')); $msc_id = $params->get('msc'); $status = $params->get('status', 'all'); if (empty($msc_id)) { $mainframe->redirect('index.php', 'Please choose a membership to show'); } oseHTML::stylesheet(OSEMSC_F_URL . '/assets/css/msc5backend.css', '1.5'); $com = OSECPU_PATH_JS . '/com_ose_cpu/extjs'; oseHTML::script($com . '/grid/SearchField.js'); $document = JFactory::getDocument(); $document->addScriptDeclaration('var osememlist_msc_id = ' . $msc_id . '; var osememlist_status = \'' . $status . '\';'); $this->prepareDocument(); if (!empty($tpl)) { parent::display($tpl); } else { parent::display(); } }
function ajaxOrderTrack($account, $order_id) { $db = JFactory::getDBO(); $where = array('`order_id`=' . $db->Quote($order_id)); $code = array(); if (!JFile::exists(JPATH_SITE . DS . 'components' . DS . 'com_osemsc' . DS . 'init.php')) { return false; } else { require_once(JPATH_SITE . DS . 'components' . DS . 'com_osemsc' . DS . 'init.php'); } $db = oseDB::instance(); $pOrder = oseRegistry::call('payment')->getInstance('Order'); $orderInfo = $pOrder->getOrder($where, 'obj'); $orderInfoParams = oseJson::decode($orderInfo->params); // transaction $code[] = 'var pageTracker = _gat._getTracker("' . $account . '");'; $code[] = "pageTracker._addTrans("; $code[] = "'{$orderInfo->order_id}',"; $code[] = "'{$orderInfo->order_number}',"; $code[] = "'{$orderInfo->payment_price}',"; $code[] = "'{$orderInfoParams->gross_tax}',"; $code[] = "'0',"; $code[] = "'',"; $code[] = "'', "; $code[] = "'' "; $code[] = ");"; // product $msc = oseRegistry::call('msc'); $orderItems = $pOrder->getOrderItems($orderInfo->order_id, 'obj'); foreach ($orderItems as $orderItem) { $curOrderItemParams = oseJson::decode($orderItem->params); $msc_id = $orderItem->entry_id; $node = $msc->getInfo($msc_id, 'obj'); $paymentInfos = $msc->getExtInfo($msc_id, 'payment'); foreach ($paymentInfos as $key => $paymentInfo) { if ($key != $curOrderItemParams->msc_option) { unset($paymentInfos[$key]); } } $cart = oseMscPublic::getCart(); $osePaymentCurrency = $cart->get('currency'); $items = $cart->get('items'); $options = oseMscPublic::generatePriceOption($node, $paymentInfos, $osePaymentCurrency); $option = $options[0]; $code[] = "pageTracker._addItem("; $code[] = "'{$orderItem->order_id}',"; $code[] = "'{$orderItem->entry_type}_{$orderItem->entry_id}',"; $code[] = "'{$node->title}-{$option['title']}',"; $code[] = "'{$orderItem->entry_type}',"; $code[] = "'{$orderItem->payment_price}',"; $code[] = "'1'"; $code[] = ");"; } $code[] = "pageTracker._trackTrans();"; return $code; }
public static function save($params) { if(!class_exists('oseMscPublic')) { require_once(OSEMSC_F_HELPER.DS.'oseMscPublic.php'); } $result = array(); $result['success'] = true; //oseExit($params); if(empty($params['allow_work'])) { $result['success'] = false; $result['title'] = 'Error'; $result['content'] = JText::_('Error Join.PAP'); return $result; } unset($params['allow_work']); /* Offline payments should be counted as well; removed from v 6.0.5 if( $params['join_from'] != 'payment') { $result['success'] = true; $result['title'] = JText::_('Done'); $result['content'] = JText::_('Done Join.Order'); return $result; } */ $oseMscConfig = oseRegistry::call('msc')->getConfig('thirdparty','obj'); if(empty($oseMscConfig->pap_enable)) { return $result; } if(empty($oseMscConfig->pap_url)) { return $result; } $db = oseDB::instance(); //$post = JRequest::get('post'); $msc_id = $params['msc_id']; $member_id = $params['member_id']; $order_id = $params['order_id']; $order_item_id = $params['order_item_id']; $where = array(); $where[] = "order_id = {$order_id}"; $payment = oseRegistry::call('payment'); $curOrder = $payment->getOrder($where,'obj'); $curOrderParams = oseJson::decode($curOrder->params); $recurrence_times = ($curOrderParams->has_trial)?$curOrderParams->recurrence_times+1:$curOrderParams->recurrence_times; $member = oseRegistry::call('member'); $member->instance($member_id); $userInfo = $member->getUserInfo('obj'); $memParams = $member->getMemberInfo($msc_id,'obj')->memParams; $memParams = oseJSON::decode($memParams); $memParams->first_ip = oseObject::getValue($curOrderParams,'first_ip');; if(empty($curOrderParams->pap_visitorid)) { return $result; //$memParams->pap_visitorid = 'paypal'; } else { $memParams->pap_visitorid = $curOrderParams->pap_visitorid; //$memParams->pap_visitorid = $_COOKIE['PAPVisitorId']; } $memParams_encode = oseJSON::encode($memParams); $query = " UPDATE `#__osemsc_member`" ." SET params = ".$db->Quote($memParams_encode) ." WHERE msc_id = {$msc_id} AND member_id = {$member_id}" ; $db->setQuery($query); //oseExit($db->_sql); if(!oseDB::query()) { $result['success'] = false; $result['title'] = 'Error'; $result['content'] = JText::_('Error Join.Order.2'); return $result; } try { require_once(OSEMSC_B_LIB.DS.'PapApi.class.php'); $saleTracker = new Pap_Api_SaleTracker($oseMscConfig->pap_url.'/scripts/sale.php'); $saleTracker->setAccountId(oseObject::getValue($oseMscConfig,'pap_account_id','default1')); $saleTracker->setVisitorId($memParams->pap_visitorid); $sale1 = $saleTracker->createSale(); $msc = oseRegistry::call('msc'); $where = array(); $where[] = "`order_item_id` = '{$order_item_id}'"; $curOrderItem = $payment->getInstance('Order')->getOrderItem($where,'obj'); $curOrderItemParams = oseJson::decode($curOrderItem->params); $node = $msc->getInfo($msc_id,'obj'); $paymentInfos = $msc->getExtInfo($msc_id,'payment'); foreach($paymentInfos as $key => $paymentInfo) { if($key != $curOrderItemParams->msc_option) { unset($paymentInfos[$key]); } } $cart = oseMscPublic::getCart(); $osePaymentCurrency = $cart->get('currency'); $items = $cart->get('items'); $options = oseMscPublic::generatePriceOption($node,$paymentInfos,$osePaymentCurrency); $sale1->setTotalCost($curOrder->payment_price); $sale1->setOrderID($order_id); $sale1->setProductID("{$node->title}-{$options[0]['title']}"); $sale1->setData1($userInfo->email); $sale1->setData2($userInfo->jname); $sale1->setData3($memParams->first_ip); $sale1->setData4($curOrder->payment_serial_number); $sale1->setData5("{$curOrder->order_id}-{$node->title}-{$options[0]['title']}-#recurrence:{$recurrence_times}"); $saleTracker->register(); //$memParams->pap_affiliate_id = $sale1->getAffiliateId(); //$memParams->pap_campaign_id = $sale1->getCampaignId(); //$memParams->pap_banner_id = $sale1->getBannerId(); // Order problem for system add return $result; } catch (Exception $e) { return $result; } }
function joinMsc($member_id, $paymentInfo) { $result = oseMscPublic::generateOrder($member_id, 'system_admin', $paymentInfo); if (!$result['success']) { return $result; } $orderInfo = oseRegistry::call('payment')->getInstance('Order')->getOrder(array("`order_id`='{$result['order_id']}'"), 'obj'); return oseMscPublic::processPayment($orderInfo); /* //$db = oseDB::instance(); $member = oseRegistry::call('member'); $result = array(); $result['success'] = true; $result['title'] = 'Done'; $result['content'] = 'Added successfully!'; foreach($member_ids as $member_id) { $member->instance($member_id); $isMember = $member->isSpecificMember($msc_id); $user = JFactory::getUser(); $params = array(); $params['member_id'] = $user->id; $params['payment_method'] = 'system_admin'; oseRegistry::call('msc')->runAddonAction('member.billinginfo.save'); oseRegistry::call('msc')->runAddonAction('register.payment.save',$params); if(!$member->joinMsc($msc_id)) { $result['success'] = false; $result['title'] = 'Error'; $result['content'] = 'Fail adding user!'; return $result; } else { // is Member, renew... else join. // $db = oseDB::instance(); $msc_option = JRequest::getCmd('msc_option',null); $payment = oseRegistry::call('payment'); $orderParams = array(); //$price_params = $order->generateOrderParams($msc_id,); $orderParams['payment_price'] = 0; $orderParams['order_number'] = $payment->generateOrderNumber($member_id); $orderParams['create_date'] = oseHTML::getDateTime();;//date("Y-m-d H:i:s"); $extPayments = oseMscAddon::getExtInfo($msc_id,'payment'); $extPayment = $extPayments[$msc_option]; if (strtolower(oseObject::getValue($extPayment,'payment_mode'))== 'b') { $orderParams['payment_mode'] = 'm'; $price_params = $payment->generateOrderParams($msc_id,0,'m',$msc_option); } else { $orderParams['payment_mode'] = oseObject::getValue($extPayment,'payment_mode'); $price_params = $payment->generateOrderParams($msc_id,0,oseObject::getValue($extPayment,'payment_mode'),$msc_option); } //$orderParams['payment_mode'] = 'm'; $orderParams['payment_from'] = 'system_admin'; $orderParams['payment_method'] = 'osemsc'; $orderParams['order_status'] = 'confirmed'; //$params['payment_from_order_id'] = $order_number; $orderParams['params'] = oseJSON::encode($price_params); $order_id = $payment->generateOrder($msc_id,$member_id,$orderParams); if(!$order_id) { $result['success'] = false; $result['title'] = 'Error'; $result['content'] = 'Fail adding user!'; return $result; } else { //self::addVmOrder($msc_id,$member_id,$orderParams,$orderParams['order_number']); //$db = oseDB::instance();oseExit($db->_sql); } $params = array(); $params['msc_id'] = $msc_id; $params['member_id'] = $member_id; $params['join_from'] = 'payment'; $params['order_id'] = $order_id; $params['allow_work'] = true; $params['master'] = true; //oseExit($isMember); if(!$isMember) {//oseExit('join'); $list = oseMscAddon::getAddonList('join',true,1,'obj'); foreach($list as $addon) { $action_name = 'join.'.$addon->name.'.save'; $result = oseMscAddon::runAction('join.'.$addon->name.'.save',$params); if(!$result['success']) { $this->cancelMsc(array($member_id),$msc_id); return $result; } } } else { $list = oseMscAddon::getAddonList('renew',true,1,'obj'); foreach($list as $addon) { $action_name = 'renew.'.$addon->name.'.activate'; $result = oseMscAddon::runAction($action_name,$params); if(!$result['success']) { $this->cancelMsc(array($member_id),$msc_id); return $result; } } } } } return $result; */ }
public static function save( $params ) { $result = array(); $db = oseDB::instance(); if(!oseMscPublic::isTable('#__oselic_cs_company')) { $result['success'] = true; $result['title'] = 'Error'; $result['content'] = JText::_("Error"); return $result; } $post = JRequest::get('post'); $msc_id = $params['msc_id']; $member_id = $params['member_id']; JRequest::setVar('member_id',$member_id); $result = array(); if(empty($member_id)) { $result['success'] = false; $result['title'] = 'Error'; $result['content'] = JText :: _('Error'); return $result; } $company = array(); foreach($post as $key => $value) { if(strstr($key,'company_')) { $billKey = preg_replace('/company_/','',$key,1); $company[$billKey] = $value; } } //oseExit($company); $query = " SELECT company_id FROM `#__oselic_cs_company` WHERE user_id='{$member_id}'"; $db->setQuery($query); $num = $db->loadResult(); if (empty ($num)) { $keys = array_keys($company); $keys = implode('`,`',$keys); $fields = $db->getTableFields('#__oselic_cs_company'); foreach($company as $key => $value) { if(!isset($fields['#__oselic_cs_company'][$key])) { /* $query = "ALTER TABLE `#__osemsc_billinginfo` ADD `{$key}` TEXT NULL DEFAULT NULL"; $db->setQuery($query); if (!$db->query()) { return false; } */ unset($company[$key]); } } foreach($company as $key => $value) { $company[$key] = $db->Quote($value); } $values = implode(',',$company); $queryKey = empty($keys)?'':",`{$keys}`"; $queryValue = empty($values)?'':",{$values}"; $query = "INSERT INTO `#__oselic_cs_company` (`user_id` {$queryKey}) VALUES ('{$member_id}' {$queryValue});"; } else { foreach($company as $key => $value) { $company[$key] = "`{$key}`=".$db->Quote($value); } $values = implode(',',$company); $query = " UPDATE `#__oselic_cs_company` SET {$values}" ." WHERE `company_id` ={$company_id}" ; } //echo $query;exit; $db->setQuery($query); if (!oseDB::query()) { $result['success'] = false; $result['title'] = 'Error'; $result['content'] = JText::_('Fail Saving Company Info.'); } else { $licExtInfo = oseRegistry::call('msc')->getExtInfo($msc_id,'lic','obj'); $lic_id = $licExtInfo->lic_id; if(!empty($licExtInfo->enable_cs)) { $lic = oseRegistry::call('lic')->getInstance($lic_id); $licInfo = $lic->getLicenseInfo($lic_id,'obj'); if($licInfo->cs_mode == 'institution') { $query = " UPDATE `#__osemsc_billinginfo`" ." SET company = ". $db->Quote($post['company_company']) ." WHERE user_id = {$member_id}" ; $db->setQuery($query); if(!oseDB::query()) { $result['success'] = false; $result['title'] = 'Error'; $result['content'] = JText::_('Fail Saving Company Info.'); return $result; } } } $result['success'] = true; $result['title'] = 'Done'; $result['content'] = JText::_('Saved Company Info.'); } return $result; }
public static function save() { $result = array(); $post = JRequest::get('post'); $member_id = JRequest::getInt('member_id'); $mailing = array(); foreach ($post as $key => $value) { if (strstr($key, 'mailing_')) { $mailingKey = preg_replace('/mailing_/', '', $key, 1); $mailing[$mailingKey] = $value; } } if (empty($mailing)) { $result['success'] = true; $result['title'] = JText::_('Done'); $result['content'] = JText::_('Nothing need to save!'); } //oseExit($billinfo); $db = oseDB::instance(); //$member_id = JRequest::getInt('member_id',0); $query = " SELECT count(*) FROM `#__osemsc_mailing` WHERE user_id='{$member_id}'"; $db->setQuery($query); $num = $db->loadResult(); //oseExit($db->_sql); if (empty($num)) { $keys = array_keys($mailing); $keys = '`' . implode('`,`', $keys) . '`'; $fields = $db->getTableFields('#__osemsc_mailing'); foreach ($mailing as $key => $value) { $my = JFactory::getUser(); if (oseMscPublic::isUserAdmin($my)) { if (!isset($fields['#__osemsc_mailing'][$key])) { $query = "ALTER TABLE `#__osemsc_mailing` ADD `{$key}` TEXT NULL DEFAULT NULL"; $db->setQuery($query); if (!oseDB::query()) { $result['success'] = false; $result['title'] = JText::_('Error'); $result['content'] = JText::_('Fail Saving Mailing Info.'); } } } } $values = array(); foreach ($mailing as $key => $value) { $values[] = $db->Quote($value); } $values = implode(',', $values); $query = "INSERT INTO `#__osemsc_mailing` (`user_id`,{$keys}) VALUES ('{$member_id}',{$values});"; } else { foreach ($mailing as $key => $value) { $values[] = "`{$key}`=" . $db->Quote($value); } $values = implode(',', $values); $query = " UPDATE `#__osemsc_mailing` SET {$values}" . " WHERE `user_id` ={$member_id}"; } //echo $query;exit; $db->setQuery($query); if (!oseDB::query()) { $result['success'] = false; $result['title'] = JText::_('Error'); $result['content'] = JText::_('Failed Saving Mailing Info.'); } else { $result['success'] = true; $result['title'] = JText::_('Done'); $result['content'] = JText::_('Saved User\'s Mailing Info.'); } return $result; }
public static function getOptions() { $msc_id = JRequest::getInt('msc_id', 0); $msc = oseRegistry::call('msc'); $node = $msc->getInfo($msc_id, 'obj'); $paymentInfos = $msc->getExtInfo($msc_id, 'payment'); $cart = oseMscPublic::getCart(); $osePaymentCurrency = $cart->get('currency'); $option = oseMscPublic::generatePriceOption($node, $paymentInfos, $osePaymentCurrency); $options = array(); $options = array_merge($options, $option); /* $session =& JFactory::getSession(); $osePaymentCurrency = $session->get('osePaymentCurrency',oseRegistry::call('msc')->getConfig('currency','obj')->primary_currency); $oseMscPayment = $session->get('oseMscPayment',array('msc_id'=>0,'msc_option'=>0)); $option = array(); if(!empty($oseMscPayment['msc_option'])) { $paymentInfo = oseObject::getValue($paymentInfos,$oseMscPayment['msc_option']); $node = oseRegistry::call('payment')->getInstance('View')->getPriceStandard($node,$paymentInfo,$osePaymentCurrency); $optionPrice = oseObject::getValue($node,'standard_price').' for every '.oseObject::getValue($node,'standard_recurrence') ; if(oseObject::getValue($paymentInfo,'has_trial')) { $node = oseRegistry::call('payment')->getInstance('View')->getPriceTrial($node,$paymentInfo,$osePaymentCurrency); $optionPrice .= ' ('.oseObject::getValue($node,'trial_price').' in first '.oseObject::getValue($node,'trial_recurrence').')'; } $option[] = array('id'=>oseObject::getValue($paymentInfo,'id'),'text'=>$optionPrice); } else { foreach($paymentInfos as $paymentInfo) { $node = oseRegistry::call('payment')->getInstance('View')->getPriceStandard($node,$paymentInfo,$osePaymentCurrency); $optionPrice = oseObject::getValue($node,'standard_price').' for every '.oseObject::getValue($node,'standard_recurrence') ; if(oseObject::getValue($paymentInfo,'has_trial')) { $node = oseRegistry::call('payment')->getInstance('View')->getPriceTrial($node,$paymentInfo,$osePaymentCurrency); $optionPrice .= ' ('.oseObject::getValue($node,'trial_price').' in first '.oseObject::getValue($node,'trial_recurrence').')'; } $option[] = array('id'=>oseObject::getValue($paymentInfo,'id'),'text'=>$optionPrice); } } */ $combo = array(); $combo['total'] = count($options); $combo['results'] = $options; $combo = oseJson::encode($combo); oseExit($combo); }
protected function generateRegInfoJs() { $initMscPayment = array('msc_id' => 0, 'msc_option' => null); $cart = oseMscPublic::getCart(); ; $user = JFactory::getUser(); $member = oseRegistry::call('member'); $member->instance($user->id); $item = $member->getBillingInfo(); foreach ($item as $k => $v) { $item['bill_' . $k] = $v; } $cartItems = $cart->get('items'); $cartItem = $cartItems[0]; $item['msc_option'] = $cartItem['msc_option']; $output .= "\r\n"; $output .= "var getRegInfo = function() {return " . oseJson::encode($item) . "};"; return $output; }
function getSelectedMsc() { $cart = oseMscPublic::getCart(); $items = $cart->get('items'); if (!is_array($items)) { $items = array($items); } $result = array(); $result['total'] = count($items); $result['results'] = array_values($items); return $result; //$result = oseJson::encode(array("result"=>$result)); //oseExit($result); }
function getBillingInfo() { $initMscPayment = array('msc_id' => 0, 'msc_option' => null); $cart = oseMscPublic::getCart(); ; $user = JFactory::getUser(); $member = oseRegistry::call('member'); $member->instance($user->id); $item = $member->getBillingInfo(); $cartItems = $cart->get('items'); $cartItem = $cartItems[0]; $item['msc_option'] = $cartItem['msc_option']; return $item; }
function getSubTotal() { $cart = oseMscPublic::getCart(); $subtotal = $cart->get('currency') . ' ' . $cart->get('subtotal'); $result = array(); $result['success'] = true; $result['content'] = array('subtotal' => $subtotal); $result = oseJson::encode($result); oseExit($result); }
$msc_option = $orderItemParams->msc_option; $query = "SELECT params FROM `#__osemsc_ext` WHERE `type` = 'paymentAdv' AND `id` = ".$msc_id; $db->setQuery($query); $ext = $db->loadResult(); $params = oseJson :: decode($ext); if(isset($params->$msc_option->installment) && !empty($params->$msc_option->installment)) { $InstallmentCount = $params->$msc_option->installment; } //settings for garanti require_once(OSEMSC_F_HELPER . DS . 'oseMscPublic.php'); $cart = oseMscPublic::getCart(); if(isset($cart->cart['params']['garanti_taksit']) && $cart->cart['params']['garanti_taksit'] && isset($cart->cart['params']['garanti_vade']) && $cart->cart['params']['garanti_vade']) { $InstallmentCount = $cart->cart['params']['garanti_taksit']; $vade = $cart->cart['params']['garanti_vade']; //$Amount = $cart->cart['total']*100; $Amount = $Amount * $vade/100 + $Amount; $Amount = round($Amount); //echo $Amount; die; } $server = str_replace('/components/com_osemsc/ipn','',JURI :: base());
function formValidate() { $user = JFactory :: getUser(); $username = JRequest :: getString('username', null); $result = array (); $updated = oseMscPublic :: uniqueUserName($username, $user->id); if ($updated['success']) { $result['result'] = $updated['success']; } else { $result['result'] = JText :: _('This username has been registered by other user.'); } return $result; }
function _changeStatusOrder($order_id, $status, $sendmessage = 1){ $mainframe =& JFactory::getApplication(); $lang = &JSFactory::getLang(); $jshopConfig = &JSFactory::getConfig(); JPluginHelper::importPlugin('jshoppingorder'); $dispatcher =& JDispatcher::getInstance(); $dispatcher->trigger( 'onBeforeChangeOrderStatus', array(&$order_id, &$status, &$sendmessage) ); $order = &JTable::getInstance('order', 'jshop'); $order->load($order_id); $order->order_status = $status; $order->store(); ////////////////////////////////////////////////////////////////////////// // OSE added ////////////////////////////////////////////////////////////////////////// //2=>Confirmed, 1=>Pending, 4=>Refunded if ($status == "2" || $status == "1" || $status == "4") { require_once(JPATH_SITE.DS.'components'.DS.'com_osemsc'.DS.'init.php'); require_once(JPATH_SITE.DS.'components'.DS.'com_osemsc'.DS.'helpers'.DS.'oseMscPublic.php'); $db = &JFactory::getDBO(); $jquery = "SELECT user_id FROM `#__jshopping_orders` WHERE `order_id` = '" . $db->getEscaped($order_id) . "'"; $db->setQuery($jquery); $user_id = $db->loadResult(); $jquery = "SELECT a.product_id, b.category_id FROM `#__jshopping_order_item` as a, `#__jshopping_products_to_categories` as b WHERE a.`order_id` = '" . $db->getEscaped($order_id) . "' AND a.`product_id` = b.`product_id`"; $db->setQuery($jquery); $results = $db->loadObjectList(); $cart = oseMscPublic::getCart(); foreach ($results as $result) { ////////////////////////////////////////////////// $product_id = $result->product_id; $jquery = "SELECT * FROM `#__osemsc_ext` WHERE `type` = 'jshopping'"; $db->setQuery($jquery); $db->query(); $rows = $db->loadObjectList(); foreach ($rows as $row) { $msc_data = oseJson::decode($row->params); $left_var = ""; $right_var = ""; if ($msc_data->category_id > 0) { $left_var = $result->category_id; $right_var = $msc_data->category_id; } else { $left_var = $result->product_id; $right_var = $msc_data->product_id; } if ($left_var == $right_var) { $msc_id = $row->id; $query = "SELECT currency_code FROM `#__jshopping_orders` WHERE `order_id` = ".(int)$order_id; $db->setQuery($query); $currency = $db->loadResult(); if ($status == "2") { $member= oseRegistry :: call('member'); $member->instance($user_id, 'member_id'); // get current item $cart->updateParams('payment_mode','m'); $paymentInfo = oseRegistry::call('msc')->getPaymentMscInfo($msc_id,$currency,0); $nItem = array('entry_id'=>$msc_id,'entry_type'=>'msc','msc_option'=>oseObject::getValue($paymentInfo,'msc_option')); $cart->addItem($nItem['entry_id'],$nItem['entry_type'],$nItem); $cart->update(); // join msc oseRegistry::call('msc')->runAddonAction('register.payment.save',array('member_id'=>$user_id,'payment_method'=>'none'), true, false); $msc_order_id = JRequest::getInt('order_id',0); oseRegistry::call('payment')->getInstance('Order')->confirmOrder($msc_order_id, array()); } else { $msc_id= $row->id; $member= oseRegistry :: call('member'); $member->instance($user_id, 'member_id'); $params = $member->getAddonParams($msc_id,$user_id,0,$params = array()); $updated= $msc->runAddonAction('member.msc.cancelMsc', $params); } } } } } ////////////////////////////////////////////////////////////////////////// $vendorinfo = $order->getVendorInfo(); $order_status = &JTable::getInstance('orderStatus', 'jshop'); $order_status->load($status); if ($order->order_created && in_array($status, $jshopConfig->payment_status_return_product_in_stock)){ $order->changeProductQTYinStock("+"); } $order_history = &JTable::getInstance('orderHistory', 'jshop'); $order_history->order_id = $order->order_id; $order_history->order_status_id = $status; $order_history->status_date_added = date("Y-m-d H:i:s"); $order_history->customer_notify = 1; $order_history->comments = $restext; $order_history->store(); if (!$sendmessage) return 1; $name = $lang->get("name"); $view_name = "order"; $view_config = array("template_path"=>JPATH_COMPONENT."/templates/".$jshopConfig->template."/".$view_name); $view = &$this->getView($view_name, 'html', '', $view_config); $view->setLayout("statusorder"); $view->assign('order', $order); $view->assign('order_status', $order_status->$name); $view->assign('vendorinfo', $vendorinfo); $message = $view->loadTemplate(); $vendors_send_message = ($jshopConfig->vendor_order_message_type==1 || ($order->vendor_type==1 && $jshopConfig->vendor_order_message_type==2)); $vendor_send_order = ($jshopConfig->vendor_order_message_type==2 && $order->vendor_type == 0 && $order->vendor_id); $admin_send_order = 1; if ($jshopConfig->admin_not_send_email_order_vendor_order && $vendor_send_order) $admin_send_order = 0; $mailfrom = $mainframe->getCfg( 'mailfrom' ); $fromname = $mainframe->getCfg( 'fromname' ); //message client $subject = sprintf(_JSHOP_ORDER_STATUS_CHANGE_SUBJECT, $order->order_number); JUtility::sendMail($mailfrom, $fromname, $order->email, $subject, $message); //message admin if ($admin_send_order){ JUtility::sendMail($mailfrom, $fromname, $jshopConfig->contact_email, _JSHOP_ORDER_STATUS_CHANGE_TITLE, $message); } //message vendors if ($vendors_send_message){ $listVendors = $order->getVendors(); foreach($listVendors as $k=>$datavendor){ JUtility::sendMail($mailfrom, $fromname, $datavendor->email, _JSHOP_ORDER_STATUS_CHANGE_TITLE, $message); } } //message vendor if ($vendor_send_order){ $vendor = &JTable::getInstance('vendor', 'jshop'); $vendor->load($order->vendor_id); JUtility::sendMail($mailfrom, $fromname, $vendor->email, _JSHOP_ORDER_STATUS_CHANGE_TITLE, $message); } $dispatcher->trigger( 'onAfterChangeOrderStatus', array(&$order_id, &$status, &$sendmessage) ); return 1; }
private static function saveOS( $params ) { $result = array(); $post = JRequest::get('post'); $member_id = $params['member_id']; $payment_method = $params['payment_method']; //oseExit($params); JRequest::setVar('member_id',$member_id); if(empty($member_id)) { $result['success'] = false; $result['title'] = 'Error'; $result['content'] = JText :: _('Error'); return $result; } $params = array(); $paymentCart = oseMscPublic::getCart(); $subtotal = $paymentCart->getSubtotal(); $items = $paymentCart->get('items'); $osePaymentCurrency = $paymentCart->get('currency'); $payment = oseRegistry::call('payment'); $keys = array_keys($items); $payment_mode = $paymentCart->getParams('payment_mode'); $order_number = $payment->generateOrderNumber( $member_id ); $params['entry_type'] = 'msc_list'; $params['payment_price'] = $subtotal; $params['payment_currency'] = $osePaymentCurrency; $params['order_number'] = $order_number; $params['create_date'] = oseHTML::getDateTime();//date("Y-m-d H:i:s"); $params['payment_serial_number'] = substr($order_number,0,20); $params['payment_method'] = $payment_method; $params['payment_mode'] = $payment_mode; //$paymentOrder->__construct('#__osemsc_order_item'); $params['params'] = array(); foreach($items as $item) { $entry_type = oseObject::getValue($item,'entry_type'); switch($entry_type) { case('license'): $license_id = oseObject::getValue($item,'entry_id'); $license = oseRegistry::call('lic')->getInstance(0); $licenseInfo = $license->getKeyInfo($license_id,'obj'); //oseExit($item); $licenseInfoParams = oseJson::decode($licenseInfo->params); $msc_id = $licenseInfoParams->msc_id; break; case('msc'): $msc_id = oseObject::getValue($item,'entry_id'); break; } $msc_option = oseObject::getValue($item,'msc_option'); $paymentInfos = oseRegistry::call('msc')->getExtInfo($msc_id,'payment','obj'); $paymentInfo = oseObject::getValue($paymentInfos,$msc_option); $price = $paymentInfo->a3; if($payment_mode == 'a') { if($paymentInfo->has_trial) { $price = $paymentInfo->a1; } } $price = $payment->pricing($price,$msc_id,$osePaymentCurrency); $params['params'] = $payment->generateOrderParams($msc_id,$price,$payment_mode,$msc_option); } //oseExit($params['params']); $params['params']['total'] = $paymentCart->get('total'); $params['params']['discount'] = $paymentCart->get('discount'); $params['params']['subtotal'] = $subtotal; $params['params']['next_subtotal'] = $paymentCart->get('next_subtotal'); $params['params'] = oseJSON::encode($params['params']); //$config = oseRegistry::call('msc')->getConfig('payment','obj'); //$params['payment_from'] = $config->payment_system; $paymentOrder = $payment->getInstance('Order'); $updated = $paymentOrder->generateOrder('', $member_id, $params); if($updated) { $order_id = $updated; JRequest::setVar('order_id',$order_id); } else { $result['success'] = false; $result['title'] = 'Error'; $result['content'] = JText :: _('Error'); return $result; } //$paymentOrder->__construct('#__osemsc_order_item'); foreach($items as $item) { $itemParams = array(); $entry_type = oseObject::getValue($item,'entry_type'); switch($entry_type) { case('license'): $license_id = oseObject::getValue($item,'entry_id'); $license = oseRegistry::call('lic')->getInstance(0); $licenseInfo = $license->getKeyInfo($license_id,'obj'); //oseExit($item); $licenseInfoParams = oseJson::decode($licenseInfo->params); $msc_id = $licenseInfoParams->msc_id; break; case('msc'): $msc_id = oseObject::getValue($item,'entry_id'); break; } $msc_option = oseObject::getValue($item,'msc_option'); $paymentInfos = oseRegistry::call('msc')->getExtInfo($msc_id,'payment','obj'); $paymentInfo = oseObject::getValue($paymentInfos,$msc_option); $price = $paymentInfo->a3; if($payment_mode == 'a') { if($paymentInfo->has_trial) { $price = $paymentInfo->a1; } } $price = $payment->pricing($price,$msc_id,$osePaymentCurrency); $itemParams['entry_type'] = oseObject::getValue($item,'entry_type'); $itemParams['payment_price'] = oseObject::getValue($item,'first_raw_price'); $itemParams['payment_currency'] = $osePaymentCurrency; $itemParams['create_date'] = oseHTML::getDateTime();//date("Y-m-d H:i:s"); $price_params = $payment->generateOrderParams($msc_id,$price,$payment_mode,$msc_option); //$itemParams['msc_id'] = $msc_id; $itemParams['params'] = oseJSON::encode($price_params); $paymentInfos = oseMscAddon::getExtInfo($msc_id,'payment','obj'); $paymentInfo = oseObject::getValue($paymentInfos,$msc_option); if ( $paymentInfo->payment_mode == $payment_mode || $paymentInfo->payment_mode == 'b') { $itemParams['payment_mode'] = $payment_mode; } else { $itemParams['payment_mode'] = $paymentInfo->payment_mode; } $updated = $paymentOrder->generateOrderItem($order_id,oseObject::getValue($item,'entry_id'), $itemParams); } //$paymentOrder->__construct('#__osemsc_order'); if($updated) { /* $vmorder=self::AddVmOrder($msc_id,$params,$order_number,$paymentInfo); if(!$vmorder['success']) { return $vmorder; } */ $result['success'] = true; $result['title'] = JText :: _('Done'); $result['content'] = JText :: _('Done'); } else { $result['success'] = false; $result['title'] = 'Error'; $result['content'] = JText :: _('Order Generate Error'); } return $result; }
function createOrder() { $result = array(); $result['success'] = true; $result['title'] = JText::_('DONE'); $result['content'] = JText::_('DONE'); $post = JRequest::get('post'); $msc_id = $post['msc_id']; $msc_option = $post['msc_option']; $user_id = $post['user_id']; $cart = oseMscPublic::getCart(); // get current item $cCart = $cart->cart; $cart->init(); $cart->__construct(); $cart->updateParams('payment_mode', 'm'); $paymentInfo = oseRegistry::call('msc')->getPaymentMscInfo($msc_id, $cart->get('currency'), 0); $nItem = array('entry_id' => $msc_id, 'entry_type' => 'msc', 'msc_option' => $msc_option); $cart->addItem($nItem['entry_id'], $nItem['entry_type'], $nItem); $cart->update(); oseMscAddon::runAction('register.payment.save', array('member_id' => $user_id, 'payment_method' => 'none'), true, false); return $result; }
public static function renew($params) { if(!class_exists('oseMscPublic')) { require_once(OSEMSC_F_HELPER.DS.'oseMscPublic.php'); } $result = array(); $result['success'] = true; if(empty($params['allow_work'])) { $result['success'] = false; $result['title'] = 'Error'; $result['content'] = JText::_('Error Renew.Order'); return $result; } //unset($params['allow_work']); $oseMscConfig = oseRegistry::call('msc')->getConfig('thirdparty','obj'); $db = oseDB::instance(); //$post = JRequest::get('post'); $msc_id = $params['msc_id']; $member_id = $params['member_id']; $order_id = $params['order_id']; $order_item_id = $params['order_item_id']; $where = array(); $where[] = "order_id = {$order_id}"; $payment = oseRegistry::call('payment'); $curOrder = $payment->getOrder($where,'obj'); $curOrderParams = oseJson::decode($curOrder->params); $recurrence_times = ($curOrderParams->has_trial)?oseObject::getValue($curOrderParams,'recurrence_times',0)+1:oseObject::getValue($curOrderParams,'recurrence_times',0); if(oseObject::GetValue($config, 'oseaffiliate_enabled',true)) { if(empty($curOrderParams->oseaffiliateID) || empty($curOrderParams->osebannerID)) { return true; } else { //$memParams->oseaffiliateID = $curOrderParams->oseaffiliateID; //$memParams->osebannerID = $curOrderParams->osebannerID; } $file = JPATH_ADMINISTRATOR.DS.'com_ose_affiliates'.DS.'helpers'.DS.'oseaffiliates_helper.php'; if ( JFile::exists($file) ) { require_once($file); } else { return false; } $msc = oseRegistry::call('msc'); $where = array(); $where[] = "`order_item_id` = '{$order_item_id}'"; $curOrderItem = $payment->getInstance('Order')->getOrderItem($where,'obj'); $curOrderItemParams = oseJson::decode($curOrderItem->params); $node = $msc->getInfo($msc_id,'obj'); $paymentInfos = $msc->getExtInfo($msc_id,'payment'); foreach($paymentInfos as $key => $paymentInfo) { if($key != $curOrderItemParams->msc_option) { unset($paymentInfos[$key]); } } $osePaymentCurrency = $curOrder->payment_currency; $options = oseMscPublic::generatePriceOption($node,$paymentInfos,$osePaymentCurrency); $product = "{$node->title}-{$options[0]['title']}"; $helper = new oseAffiliatesHelper(); $helper->setTotalCost($curOrder->payment_price); $helper->setOrderId($order_id); $helper->setProduct($product); $helper->setCurrency($osePaymentCurrency); $helper->setAffiliateId($curOrderParams->oseaffiliateID); $helper->setBannerId($curOrderParams->osebannerID); if(!$helper->createSale()) { return false; } } return $result; }
public static function save() { $result = array(); $result['success'] = true; $result['title'] = JText::_('Done'); $result['content'] = JText::_('Saved User Billing Info.'); $post = JRequest::get('post'); $user = oseMscPublic::getUser(); $member_id = $user->id; if(!empty($post['juser_firstname'])) { $post['bill_firstname'] = $post['juser_firstname']; } if(!empty($post['juser_lastname'])) { $post['bill_lastname'] = $post['juser_lastname']; } $billinfo = array(); foreach($post as $key => $value) { if(strstr($key,'bill_')) { $billKey = str_replace('bill_','',$key); $billinfo[$billKey] = $value; } } if(empty($billinfo)) { $result['success'] = true; $result['title'] = JText::_('Done'); $result['content'] = JText::_('Nothing need to save!'); } //oseExit($billinfo); $db = oseDB::instance(); //$member_id = JRequest::getInt('member_id',0); $query = " SELECT count(*) FROM `#__osemsc_billinginfo` WHERE user_id='{$member_id}'"; $db->setQuery($query); $num = $db->loadResult(); $fields = $db->getTableFields('#__osemsc_billinginfo'); foreach($billinfo as $key => $value) { $my = JFactory::getUser(); if(!isset($fields['#__osemsc_billinginfo'][$key])) { if(oseMscPublic::isUserAdmin($my)) { $query = "ALTER TABLE `#__osemsc_billinginfo` ADD `{$key}` TEXT NULL DEFAULT NULL"; $db->setQuery($query); if (!oseDB::query()) { $result['success'] = false; $result['title'] = JText::_('Error'); $result['content'] = JText::_('Fail Saving Joomla User Info.'); } } else { //unset($billinfo[$key]); } } } if (empty ($num)) { $keys = array_keys($billinfo); $keys = '`'.implode('`,`',$keys).'`'; /* foreach($billinfo as $key => $value) { $billinfo[$key] = $db->Quote($value); } $values = implode(',',$billinfo); if (empty($values)) { $result['success'] = true; $result['title'] = JText::_('Done'); $result['content'] = JText::_('Nothing need to save!'); } $query = "INSERT INTO `#__osemsc_billinginfo` (`user_id`,{$keys}) VALUES ('{$member_id}',{$values});"; $db->setQuery($query); */ $billinfo['user_id'] = $user->id; if (!oseDB::insert('#__osemsc_billinginfo',$billinfo)) { $result['success'] = false; $result['title'] = JText::_('Error'); $result['content'] = JText::_('Fail Saving Joomla User Info.'); } } else { if(count($billinfo) > 0) { /* foreach($billinfo as $key => $value) { $billinfo[$key] = "`{$key}`=".$db->Quote($value); } $values = implode(',',$billinfo); $query = " UPDATE `#__osemsc_billinginfo` SET {$values}" ." WHERE `user_id` ={$member_id}" ; $db->setQuery($query); */ $billinfo['user_id'] = $user->id; if (!oseDB::update('#__osemsc_billinginfo','user_id',$billinfo)) { $result['success'] = false; $result['title'] = JText::_('Error'); $result['content'] = JText::_('Fail Saving Joomla User Info.'); } } } //echo $query;exit; return $result; }
function getBillingInfo() { $user = oseMscPublic::getUser(); $item = array(); $cart = oseMscPublic::getCart(); $cartItems = $cart->get('items'); if (!$user->guest) { $member = oseRegistry::call('member'); $member->instance($user->id); $item = $member->getBillingInfo(); } else { $item['id'] = 1; $item['city'] = ''; } if (oseMscPublic::getRegisterForm() == 'onestep') { $cartItem = empty($cartItems[0]) ? array() : $cartItems[0]; $item['msc_id'] = oseObject::getValue($cartItem, 'entry_id', 0); $item['ose_currency'] = $cart->get('currency'); if (!empty($item['msc_id'])) { $item['msc_option'] = $cartItem['msc_option']; } else { $options = $this->getAllOptions(); if (!empty($options)) { $item['msc_id'] = $options[0]['msc_id']; $item['msc_option'] = $options[0]['id']; } } } else { $item['ose_currency'] = $cart->get('currency'); if ($cart->get('total') <= 0) { $item['total'] = 'free'; } else { $item['total'] = 'nonfree'; } } return $item; }
public static function save( $params ) { //$post = JRequest::get('post'); $member_id = $params['member_id']; if(empty($member_id)) { $result['success'] = false; $result['title'] = 'Error'; $result['content'] = JText :: _('Error'); return $result; } $post = JRequest::get('post'); $bill = array(); foreach($post as $key => $value) { if(strstr($key,'bill_')) { $billKey = preg_replace('/bill_/','',$key,1); $bill[$billKey] = $value; } } $bill['firstname'] = $post['juser_firstname']; $bill['lastname'] = $post['juser_lastname']; //oseExit($billinfo); $db = oseDB::instance(); $query = " SELECT count(*) FROM `#__osemsc_billinginfo` WHERE user_id='{$member_id}'"; $db->setQuery($query); $num = $db->loadResult(); //oseExit($db->_sql); if (empty ($num)) { $keys = array_keys($bill); $keys = '`'.implode('`,`',$keys).'`'; $fields = $db->getTableFields('#__osemsc_billinginfo'); foreach($bill as $key => $value) { $my = JFactory::getUser(); if(oseMscPublic::isUserAdmin($my)) { if(!isset($fields['#__osemsc_billinginfo'][$key])) { $query = "ALTER TABLE `#__osemsc_billinginfo` ADD `{$key}` TEXT NULL DEFAULT NULL"; $db->setQuery($query); if (!oseDB::query()) { $result['success'] = false; $result['title'] = JText::_('Error'); $result['content'] = JText::_('Fail Saving Joomla User Info.'); } } } else { if($key == 'vat_number') { if(!isset($fields['#__osemsc_billinginfo']['vat_number'])) { $query = "ALTER TABLE `#__osemsc_billinginfo` ADD `{$key}` TEXT NULL DEFAULT NULL"; $db->setQuery($query); if (!oseDB::query()) { $result['success'] = false; $result['title'] = JText::_('Error'); $result['content'] = JText::_('Fail Saving Joomla User Info.'); } } } } } $values = array(); foreach($bill as $key => $value) { $values[] = $db->Quote($value); } $values = implode(',',$values); $query = "INSERT INTO `#__osemsc_billinginfo` (`user_id`,{$keys}) VALUES ('{$member_id}',{$values});"; } else { foreach($bill as $key => $value) { $values[] = "`{$key}`=".$db->Quote($value); } $values = implode(',',$values); $query = " UPDATE `#__osemsc_billinginfo` SET {$values}" ." WHERE `user_id` ={$member_id}" ; } //echo $query;exit; $db->setQuery($query); if (!oseDB::query()) { $result['success'] = false; $result['title'] = JText::_('Error'); $result['content'] = JText::_('Fail Saving Joomla User Info.'); } else { $result['success'] = true; $result['title'] = JText::_('Done'); $result['content'] = JText::_('Saved User Billing Info.'); } return $result; }
protected function generateMscIdOption() { $list = oseMscPublic::getList(); $result = array(); if (!empty($list)) { $cart = oseMscPublic::getCart(); $options = array(); $msc = oseRegistry::call('msc'); foreach ($list as $key => $entry) { $msc_id = oseObject::getValue($entry, 'id'); $node = $msc->getInfo($msc_id, 'obj'); $paymentInfos = $msc->getExtInfo($msc_id, 'payment'); $osePaymentCurrency = $cart->get('currency'); $option = oseMscPublic::generatePriceOption($node, $paymentInfos, $osePaymentCurrency); $options = array_merge($options, $option); } $mscList = array('total' => count($list), 'results' => $list); $mscOptions = array('total' => count($options), 'results' => $options); $result = array(); $result['mscList'] = $mscList; $result['mscOptions'] = $mscOptions; } else { $result['mscList'] = array(); $result['mscOptions'] = array(); } return $result; }
public static function getPaymentMode() { $msc_id = JRequest::getInt('msc_id',0); $msc_option = JRequest::getCmd('msc_option',null); $msc = oseRegistry::call('msc'); $ext = $msc->getExtInfo($msc_id,'payment'); $extAdv = $msc->getExtInfo($msc_id,'paymentAdv'); $items = array(); if(oseObject::getValue($ext[$msc_option],'payment_mode','b') == 'a') { $items[] = array('id'=>1,'value'=>'a','text'=> JText::_('AUTOMATIC_RENEWING')); } elseif(oseObject::getValue($ext[$msc_option],'payment_mode','b') == 'm') { $items[] = array('id'=>1,'value'=>'m','text'=> JText::_('MANUAL_RENEWING')); } else { if(oseObject::getValue($extAdv[$msc_option],'payment_mode','b') != 'b') { $itemValue = oseObject::getValue($extAdv[$msc_option],'payment_mode'); if($itemValue == 'm') { $itemText = JText::_('MANUAL_RENEWING'); } else { $itemText = JText::_('AUTOMATIC_RENEWING'); } $items[] = array('id'=>1,'value'=>$itemValue,'text'=> $itemText); } else { $items[] = array('id'=>1,'value'=>'a','text'=> JText::_('AUTOMATIC_RENEWING')); $items[] = array('id'=>2,'value'=>'m','text'=> JText::_('MANUAL_RENEWING')); } } $config = oseMscPublic::getConfig('global', 'obj'); if($config->payment_mode == 'a') { $items = array(); $items[] = array('id'=>1,'value'=>'a','text'=> JText::_('AUTOMATIC_RENEWING')); } elseif($config->payment_mode == 'm') { $items = array(); $items[] = array('id'=>1,'value'=>'m','text'=> JText::_('MANUAL_RENEWING')); } $result = array(); if(empty($items)) { $result['total'] = 0; $result['results'] = array(); } else { $result['total'] = count($items); $result['results'] = $items; } return $result; }