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 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() { $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; }
private function updateCoupon($item,$coupon_number = null) { $db = oseDB::instance(); $user = oseMscPublic::getUser(); $coupon_id = oseObject::getValue($item,'id',0); $where = array(); if($user->guest) { $where[] = "coupon_number = '{$coupon_number}'"; } else { $where[] = "user_id = '{$user->id}'"; } $where[] = "`coupon_id` = '{$coupon_id}'"; $where[] = "`paid` = 0"; $where = oseDB::implodeWhere($where); $query = " SELECT * FROM `#__osemsc_coupon_user`" . $where ." ORDER BY `id` DESC" ; $db->setQuery($query); $obj = oseDB::loadItem('obj'); $array = array(); if(empty($obj)) { $array['coupon_id'] = $coupon_id; $array['user_id'] = $user->id; $array['msc_id'] = 0; $array['coupon_number'] = $coupon_number; $updated = oseDB::insert('#__osemsc_coupon_user',$array); $coupon_user_id = $updated; if(!$updated) { return false; } if(oseObject::getValue($item,'amount_infinity') == 0) { $couponParams = oseJson::decode($item->params); $couponParams->amount_left--; $couponParams = oseJson::encode($couponParams); $array = array(); $array['id'] = $coupon_id; $array['params'] = $couponParams; //oseExit($couponParams); $updated = oseDB::update('#__osemsc_coupon','id',$array); if(!$updated) { return false; } } } else { $array['id'] = $obj->id; $array['coupon_id'] = $coupon_id; $array['user_id'] = $user->id; $array['msc_id'] = 0; $coupon_user_id = $obj->id; $updated = oseDB::update('#__osemsc_coupon_user','id',$array); } if($updated) { $updated = $coupon_user_id; } return $updated; }
function display($tpl = null) { $user = oseMscPublic::getUser(); $app = JFactory::getApplication('SITE'); $cart = oseMscPublic::getCart(); $osePaymentCurrency = $cart->get('currency'); // Add Detect if ($this->isMobile) { $this->setLayout('mobile'); JRequest::setVar('tmpl', 'component'); } else { $this->loadMultiSelect(); $this->loadFileUpload(); } $model = $this->getModel('register'); $msc_id = JRequest::getInt('msc_id', 0); $msc_option = JRequest::getCmd('msc_option', null); if (!empty($msc_id)) { if (empty($msc_option)) { $msc = oseRegistry::call('msc'); $paymentInfos = $msc->getExtInfo($msc_id, 'payment'); foreach ($paymentInfos as $paymentInfo) { $msc_option = oseObject::getValue($paymentInfo, 'id'); break; } $model->addToCart($msc_id, $msc_option); } else { $model->addToCart($msc_id, $msc_option); } } $config = oseMscConfig::getConfig('register', 'obj'); if (!$isMobile) { if (!empty($config->register_form) && $config->register_form != 'default') { $layout = JRequest::getCmd("layout"); if (empty($layout)) { $layout = 'default'; } $this->setLayout($layout); switch ($layout) { case ('onestep'): default: $headerObjs = $this->getAddons('registerOS_header'); $bodyObjs = $this->getAddons('registerOS_body'); $footerObjs = $this->getAddons('registerOS_footer'); if ($user->guest) { $tpl = ''; $headerObjs = $this->filter($headerObjs, array('welcome'), false); } else { $tpl = 'payment'; $headerObjs = $this->filter($headerObjs, array('login'), false); $bodyObjs = $this->filter($bodyObjs, array('juser', 'juser_e', 'mailing', 'jomsocial'), false); } $this->loadAddons($headerObjs, 'registerOS'); $this->loadAddons($bodyObjs, 'registerOS'); $this->loadAddons($footerObjs, 'registerOS'); $this->assignRef('registerOS_header', $headerObjs); $this->assignRef('registerOS_body', $bodyObjs); $this->assignRef('registerOS_footer', $footerObjs); $this->assignRef('enable_fblogin', $config->enable_fblogin); $this->assignRef('facebookapiid', $config->facebookapiid); break; } } else { $this->setLayout('cart'); $tpl = "default"; $headerObjs = $this->getAddons('registerOS_header'); $bodyObjs = $this->getAddons('registerOS_body'); $footerObjs = $this->getAddons('registerOS_footer'); if ($user->guest) { $tpl = 'default'; } else { $tpl = 'payment'; $headerObjs = $this->filter($headerObjs, array('login'), false); $bodyObjs = $this->filter($bodyObjs, array('juser', 'juser_e'), false); } $this->loadAddons($headerObjs, 'registerOS'); $this->loadAddons($bodyObjs, 'registerOS'); $this->loadAddons($footerObjs, 'registerOS'); $this->assignRef('registerOS_header', $headerObjs); $this->assignRef('registerOS_body', $bodyObjs); $this->assignRef('registerOS_footer', $footerObjs); } } $profiles = $this->getProfileList(); $document = JFactory::getDocument(); $document->addScriptDeclaration('var oseGetProfileFields = function() {return ' . oseJson::encode($profiles) . '};'); $this->prepareDocument(); $this->addTemplatePath(JPATH_SITE . DS . 'ose' . DS . 'msc' . DS . 'views' . DS . 'register' . DS . 'tmpl'); if (!empty($tpl)) { parent::display($tpl); } else { parent::display(); } }
private function toPaymentOS() { $model = $this->getModel('register'); $post = JRequest::get('POST'); $post['payment_method'] = $payment_method = oseMscPublic::getPaymentMethod(); $cart = oseMscPublic::getCart(); $items = $cart->get('items'); $item = $items[0]; $payment_mode = $cart->getParams('payment_mode'); $msc_id = oseMscPublic::getEntryMscID($item); $allow_to_join = $this->checkJoiningControl($msc_id); if ($allow_to_join == false) { $result['success'] = false; $result['title'] = JText::_('Error'); $result['content'] = JText::_('Permission denied, this membership is for members only!'); $result = oseJson::encode($result); oseExit($result); } $msc_option = JRequest::getCmd('msc_option', null); if (empty($payment_mode)) { $result['success'] = false; $result['title'] = JText::_('Error!'); $result['content'] = JText::_('Fail Paying...'); return $result; } if (empty($msc_id)) { $result['success'] = false; $result['title'] = JText::_('Error!'); $result['content'] = JText::_('Fail Paying...'); return $result; } $list = oseMscAddon::getAddonList('registerOS_body', false, 1, 'obj'); $list = oseMscPublic::filter($list, array('juser'), false); foreach ($list as $addon) { $action_name = oseMscAddon::getActionName($addon, 'formValidate', 'register'); $updated = oseMscAddon::runAction($action_name, array('inner' => true)); if (!$updated['success']) { return $updated; } } $user = oseMscPublic::getUser(); $params['member_id'] = $user->id; $params['payment_method'] = $payment_method; oseRegistry::call('msc')->runAddonAction('member.billinginfo.save'); oseRegistry::call('msc')->runAddonAction('register.profile.save', $params); $order = oseRegistry::call('msc')->runAddonAction('register.payment.save', $params); $order_id = $order['order_id']; if ($order_id) { $updated = $model->processPayment($order_id, $post, $msc_option); $result = $updated; if (is_array($result)) { $result['order_id'] = $order_id; } } else { $result['success'] = false; $result['title'] = JText::_('Error!'); $result['content'] = JText::_('Fail Creating Order...'); } return $result; }