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 save($params)
	{
		$result = array();
		$result['success'] = true;
		
		if(empty($params['allow_work']))
		{
			$result['success'] = false;
			$result['title'] = 'Error';
			$result['content'] = JText::_("Error");
			return $result;
		}
		unset($params['allow_work']);
		
		
		
		//oseExit($params);
		$db = oseDB::instance();
		$post = JRequest::get('post');
		$msc_id = $params['msc_id'];
		$member_id = $params['member_id'];
		
		if(empty($msc_id))
		{
			$result['success'] = false;
			$result['title'] = 'Error';
			$result['content'] = JText::_("Join History: No Membership ");
		}
		
		$history = oseRegistry::call('member')->getInstance('History');
		$updated = $history->record($msc_id,$member_id,'join');
		if(!$updated)
		{
			$result['success'] = false;
			$result['title'] = 'Error';
			$result['content'] = JText::_(" Fail Record Member's Footprint! ");
		}
		
		// Order problem for system add
		$hisParams = oseJSON::encode(array('order_id' => $params['order_id']));
		
		$query = " UPDATE `#__osemsc_member_history`"
				." SET params = ".$db->Quote($hisParams)
				." WHERE id = {$updated}"
				;
		$db->setQuery($query);
		//oseExit($db->_sql);
		if(!oseDB::query())
		{
			$result['success'] = false;
			$result['title'] = 'Error';
			$result['content'] = JText::_('Error Join.Order.2');
		}
		
		
		return $result;
		
	}
Beispiel #3
0
	public static function save($params) {
		$result = array();
		$result['success'] = true;
		if (empty($params['allow_work'])) {
			$result['success'] = false;
			$result['title'] = 'Error';
			$result['content'] = JText::_('Error Join.Order.1');
			return $result;
		}
		unset($params['allow_work']);
		if ($params['join_from'] != 'payment') {
			$result['success'] = true;
			$result['title'] = JText::_('Done');
			$result['content'] = JText::_('Done Join.Order');
			return $result;
		}
		$db = oseDB::instance();
		$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');
		$member = oseRegistry::call('member');
		$member->instance($member_id);
		$memParams = $member->getMemberInfo($msc_id, 'obj')->memParams;
		if (empty($memParams)) {
			$memParams = new stdClass();
		} else {
			$memParams = oseJSON::decode($memParams);
		}
		$memParams->order_id = $order_id;
		$memParams->payment_mode = $curOrder->payment_mode;
		$memParams->order_item_id = $order_item_id;
		// Order problem for system add
		$memParams = oseJSON::encode($memParams);
		$query = " UPDATE `#__osemsc_member`" . " SET `params` = " . $db->Quote($memParams) . " WHERE msc_id = {$msc_id} AND member_id = {$member_id}";
		$memConfig = oseMscConfig::getConfig('register', 'obj');
		$db->setQuery($query);
		if (!oseDB::query()) {
			$result['success'] = false;
			$result['title'] = 'Error';
			$result['content'] = JText::_('Error Join.Order.2');
		}
		// User activation function;
		$params = JComponentHelper::getParams('com_users');
		$useractivation = $params->get('useractivation');
		if (oseObject::getValue($memConfig, 'disabled_non_paid', false) == true) {
			if ($useractivation == 0) {
				$query = " UPDATE `#__users` SET `block` = 0 where `id` = " . $member_id;
				$db->setQuery($query);
				$db->query();
			}
		}
		return $result;
	}
Beispiel #4
0
 function getUsers()
 {
     $model = $this->getModel('members');
     $result = $model->getUsers();
     if ($result['total'] < 1) {
         $result['total'] = 0;
     }
     $result = oseJSON::encode($result);
     oseExit($result);
 }
Beispiel #5
0
 function getEndDateList()
 {
     $model = $this->getModel('memlist');
     $result = $model->getEndDateList();
     if (count($result['results']) < 1) {
         $result['total'] = 0;
     }
     $result = oseJSON::encode($result);
     oseExit($result);
 }
Beispiel #6
0
	public function getMemlist() {
		$model = $this->getModel('memlist');
		$result = $model->getMemlist();
		if ($result['total'] < 1) {
			$result['total'] = 0;
		}
		$result = oseJSON::encode($result);
		echo $result;
		exit;
	}
Beispiel #7
0
 function getOptions()
 {
     $model = $this->getModel('daily');
     $result = $model->getOptions();
     if (count($result['results']) < 1) {
         $result['total'] = 0;
     }
     $result = oseJSON::encode($result);
     oseExit($result);
 }
Beispiel #8
0
 public static function save($params)
 {
     $result = array();
     $result['success'] = true;
     //oseExit($params);
     if (empty($params['allow_work'])) {
         $result['success'] = false;
         $result['title'] = 'Error';
         $result['content'] = JText::_('Error Join.Idev');
         return $result;
     }
     unset($params['allow_work']);
     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->idev_enable)) {
         return $result;
     }
     if (empty($oseMscConfig->idev_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);
     $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 = $curOrderParams->first_ip;
     try {
         $ch = curl_init();
         curl_setopt($ch, CURLOPT_URL, $oseMscConfig->idev_url . "/sale.php?profile=72198&idev_saleamt={$curOrder->payment_price}&idev_ordernum={$order_id}&ip_address={$memParams->first_ip}");
         curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
         curl_exec($ch);
         curl_close($ch);
         return $result;
     } catch (Exception $e) {
         return $result;
     }
 }
Beispiel #9
0
 function getDefMsgtoNonmembers($content_type, $content_id, $com_type = null)
 {
     $db = oseDB::instance();
     $controllingMSC = self::getControllingMsc($content_type, $content_id, $com_type);
     if (!empty($controllingMSC)) {
         $controllingMSC = $controllingMSC[0];
         $query = " SELECT `params` FROM `#__osemsc_ext` WHERE `type` = 'msc' AND `id` = " . (int) $controllingMSC->id;
         $db->setQuery($query);
         $result = $db->loadResult();
         $result = oseJSON::decode($result);
         return oseObject::getValue($result, 'restrict');
     } else {
         return false;
     }
 }
Beispiel #10
0
	function registerCode() {
		$regCode = JRequest::getString('regCode');
		$mainframe = &JFactory::getApplication();
		$return = array();
		if (empty($regCode)) {
			$return['results'] = 'ERROR';
			$return['text'] = "Registration code is empty";
			echo oseJSON::encode($return);
			exit;
		}
		$user = &JFactory::getUser();
		if ($user->guest) {
			$return['results'] = 'ERROR';
			$return['text'] = "Guest users are not allowed to register codes.";
			echo oseJSON::encode($return);
			exit;
		}
		$model = $this->getModel('addons');
		$items = $model->hasMembership($user->id, 1);
		if (empty($items)) {
			$return['results'] = 'ERROR';
			$Itemid = JRequest::getInt("Itemid");
			$red = str_replace("&amp;", "&", JRoute::_("index.php?option=com_osemsc&view=register&Itemid=" . $Itemid));
			$return['text'] = "Please <a href ='" . $red . "'>subscribe a membership</a> before you register your device.";
			echo oseJSON::encode($return);
			exit;
		}
		if ($user->id) {
			$results = $model->registerCode($regCode, $user->id);
			if ($results == "success") {
				$return['results'] = 'SUCCESS';
				$return['text'] = "Congratulations! Your device is regsitered.";
				echo oseJSON::encode($return);
				exit;
			} elseif ($results == "registered") {
				$return['results'] = 'SUCCESS';
				$return['text'] = "Your device is already regsitered.";
				echo oseJSON::encode($return);
				exit;
			} else {
				$return['results'] = 'ERROR';
				$return['text'] = "Device registration failed, please contact administrators for this issue.";
				echo oseJSON::encode($return);
				exit;
			}
		}
	}
Beispiel #11
0
 function getStore()
 {
     $db = oseDB::instance();
     $query = "SELECT * FROM `#__osemsc_fields` WHERE `published` = '1' ORDER BY `ordering`";
     $db->setQuery($query);
     $objs = $db->loadObjectList();
     $arrays = array();
     $arrays[] = array('name' => 'id', 'type' => 'int', 'mapping' => 'id');
     $arrays[] = array('name' => 'member_id', 'type' => 'int', 'mapping' => 'member_id');
     $arrays[] = array('name' => 'username', 'type' => 'string', 'mapping' => 'username');
     $arrays[] = array('name' => 'name', 'type' => 'string', 'string' => 'name');
     foreach ($objs as $obj) {
         $arrays[] = array('name' => 'field' . $obj->id, 'type' => 'string', 'mapping' => 'field' . $obj->id);
     }
     $list = oseJSON::encode($arrays);
     return $list;
 }
Beispiel #12
0
 public static function save($params)
 {
     $result = array();
     $result['success'] = true;
     //oseExit($params);
     if (empty($params['allow_work'])) {
         $result['success'] = false;
         $result['title'] = 'Error';
         $result['content'] = JText::_('Error Join.Order.1');
         return $result;
     }
     unset($params['allow_work']);
     if ($params['join_from'] != 'payment') {
         $result['success'] = true;
         $result['title'] = JText::_('Done');
         $result['content'] = JText::_('Done Join.Order');
         return $result;
     }
     $db = oseDB::instance();
     //$post = JRequest::get('post');
     $msc_id = $params['msc_id'];
     $member_id = $params['member_id'];
     $order_id = $params['order_id'];
     $where = array();
     $where[] = "order_id = {$order_id}";
     $payment = oseRegistry::call('payment');
     $curOrder = $payment->getOrder($where, 'obj');
     $member = oseRegistry::call('member');
     $member->instance($member_id);
     $memParams = $member->getMemberInfo($msc_id, 'obj')->memParams;
     $memParams = oseJSON::decode($memParams);
     $memParams->order_id = $order_id;
     $memParams->payment_mode = $curOrder->payment_mode;
     // Order problem for system add
     $memParams = oseJSON::encode($memParams);
     $query = " UPDATE `#__osemsc_member`" . " SET params = " . $db->Quote($memParams) . " 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;
 }
Beispiel #13
0
	public function getModMemlist() {
		$search = JRequest::getString('search', null);
		$start = JRequest::getInt('start', 0);
		$limit = JRequest::getInt('limit', 20);
		if (JOOMLA16 || JOOMLA17) {
			$module = JModuleHelper::getModule('osememlist');
			$params = oseJSON::decode($module->params);
			$msc_id = $params->msc;
			$status = $params->status;
		} else {
			$module = JModuleHelper::getModule('osememlist');
			$params = new JParameter($module->params);
			$msc_id = $params->get('msc');
			$status = $params->get('status');
		}
		$db = oseDB::instance();
		$where = array();
		$where[] = ' m.msc_id = ' . $msc_id;
		if (isset($status) && $status != 'all') {
			$where[] = ' m.status = ' . $status;
		}
		if (!empty($search)) {
			$searchQuery = $db->Quote('%' . $search . '%');
			$where[] = "m.username LIKE {$searchQuery} OR m.name LIKE {$searchQuery} OR m.email LIKE {$searchQuery}";
		}
		$where = oseDB::implodeWhere($where);
		$query = " SELECT COUNT(*) " . " FROM `#__osemsc_member_view` AS m " . " INNER JOIN `#__osemsc_billinginfo` AS b ON m.member_id = b.user_id" . $where;
		$db->setQuery($query);
		$total = $db->loadResult();
		$query = " SELECT * " . " FROM `#__osemsc_member_view` AS m " . " INNER JOIN `#__osemsc_billinginfo` AS b ON m.member_id = b.user_id" . $where;
		$db->setQuery($query, $start, $limit);
		$items = oseDB::loadList();
		$result = array();
		$result['total'] = $total;
		$result['results'] = $items;
		return $result;
	}
Beispiel #14
0
	private static function activateInAutomaticMode($msc_id,$member_id,$orderInfo,$ext)
	{
		$db = oseDB::instance();
		
		$result = array();
		$result['success'] = true;
		
		
		$orderParams = oseJSON::decode($orderInfo->params);
		
		$start_date = oseHTML::getDateTime();
		$start_date = $db->Quote($start_date);
		
		$recurrence_num = $orderParams->p3;
		$recurrence_unit = $orderParams->t3;
		
		$expired_date = " DATE_ADD({$start_date},INTERVAL {$recurrence_num} {$recurrence_unit}) ";
		
		$query = " UPDATE `#__osemsc_member` "
				." SET  expired_date = {$expired_date}"
				." WHERE member_id = {$member_id} AND msc_id = {$msc_id} "
				;
		$db->setQuery($query);
		//oseExit($db->_sql);
		
		if(!oseDB::query())
		{
			$result['success'] = false;
			$result['title'] = 'Error';
			$result['content'] = JText::_(' Fail Updated Member\'s Recurrence ');
			
			return $result;
		}
		
		$query = " SELECT expired_date FROM `#__osemsc_member` "
				." WHERE member_id = {$member_id} AND msc_id = {$msc_id} "
				;
		$db->setQuery($query);
		$end_date = $db->loadResult();
		$end_date = $db->Quote($end_date);
		$expired_date = " DATE_ADD({$end_date},INTERVAL 1 DAY) ";
		
		if(oseObject::getValue($orderParams,'recurrence_times',0) > 1)
		{
			
		}
		else
		{
			$query = " UPDATE `#__osemsc_member` "
					." SET  expired_date = {$expired_date}"
					." WHERE member_id = {$member_id} AND msc_id = {$msc_id} "
					;
			$db->setQuery($query);
			//oseExit($db->_sql);
			
			if(!oseDB::query())
			{
				$result['success'] = false;
				$result['title'] = 'Error';
				$result['content'] = JText::_(' Fail Updated Member\'s Recurrence ');
				
				return $result;
			}
		}
			
		
		return $result;
	}
Beispiel #15
0
 function getCouponHistory()
 {
     $db = oseDB::instance();
     $id = JRequest::getInt('id', 0);
     $start = JRequest::getInt('start', 0);
     $limit = JRequest::getInt('limit', 25);
     $paid = JRequest::getInt('paid', -1);
     $where = array();
     $where[] = ' c.`coupon_id` = ' . $db->Quote($id);
     if ($paid >= 0) {
         $where[] = ' c.`paid` = ' . $db->Quote($paid);
     }
     $where = oseDB::implodeWhere($where);
     $query = " SELECT count(*) FROM `#__osemsc_coupon_user` AS c" . $where;
     $db->setQuery($query);
     $total = $db->loadResult();
     $query = " SELECT c.* FROM `#__osemsc_coupon_user` AS c" . $where;
     $db->setQuery($query, $start, $limit);
     $items = $db->loadObjectlist();
     foreach ($items as $item) {
         $user_id = $item->user_id;
         $query = " SELECT username FROM `#__users`" . " WHERE `id` = '{$user_id}'";
         $db->setQuery($query);
         $username = $db->loadResult();
         $item->username = empty($username) ? 'Guest' : $username;
     }
     $result = array();
     $result['total'] = $total;
     $result['results'] = $items;
     $result = oseJSON::encode($result);
     oseExit($result);
 }
 function updateMembership($msc_id, $user_id, $order_id, $payment_mode)
 {
     $db = oseDB::instance();
     $params['order_id'] = $order_id;
     $params['payment_mode'] = $payment_mode;
     $params = oseJSON::encode($params);
     $query = " UPDATE `#__osemsc_member` SET `params`='{$params}' WHERE `msc_id` = '{$msc_id}' AND `member_id` = '{$user_id}'";
     $db->setQuery($query);
     if (oseDB::query()) {
         return true;
     } else {
         return false;
     }
 }
	private static function saveOS($params) {
		$result = array();
		$member_id = $params['member_id'];
		$payment_method = $params['payment_method'];
		JRequest::setVar('member_id', $member_id);
		if (empty($member_id)) {
			$result['success'] = false;
			$result['title'] = 'Error';
			$result['content'] = JText::_('Error1');
			return $result;
		}
		$params = array();
		$paymentCart = $cart = oseRegistry::call('payment')->getInstance('Cart');
		$paymentCart->refreshCartItems($paymentCart->get('items'), $paymentCart->get('currency'));
		$osePaymentCurrency = $paymentCart->get('currency');
		$payment_mode = $paymentCart->getParams('payment_mode');
		$subtotal = $paymentCart->getSubtotal();
		if (empty($payment_mode)) {
			$payment_mode = oseMscPublic::savePaymentMode();
		}
		$items = $paymentCart->get('items');
		$oneItem = $items[0];
		$payment = oseRegistry::call('payment');
		$keys = array_keys($items);
		$order_number = $payment->generateOrderNumber($member_id);
		$params['entry_type'] = 'msc_list';
		$params['payment_price'] = $paymentCart->get('total');
		$params['payment_currency'] = $osePaymentCurrency;
		$params['order_number'] = $order_number;
		$params['create_date'] = oseHTML::getDateTime();
		$params['payment_serial_number'] = substr($order_number, 0, 20);
		$params['payment_method'] = $payment_method;
		$params['payment_mode'] = $payment_mode;
		$params['payment_from'] = 'system_reg';
		$params['params'] = array();
		$params['params']['start_date'] = oseObject::getValue($oneItem, 'start_date', null);
		$params['params']['expired_date'] = oseObject::getValue($oneItem, 'expired_date', null);
		$params['params']['total'] = $paymentCart->get('total');
		$params['params']['next_total'] = $paymentCart->get('next_total');
		$params['params']['discount'] = $paymentCart->get('discount');
		$params['params']['subtotal'] = $subtotal;
		$params['params']['coupon_user_id'] = $paymentCart->getParams('coupon_user_id');
		$params['params']['gross_tax'] = $paymentCart->getTaxParams('amount');
		$params['params']['next_gross_tax'] = $paymentCart->getTaxParams('next_amount');
		$params['params']['vat_number'] = $paymentCart->getTaxParams('vat_number');
		$params['params']['timestamp'] = uniqid("{$member_id}_", true);
		$params['params']['returnUrl'] = $paymentCart->getParams('returnUrl');
		if ($payment_mode == 'a') {
			$params['params']['has_trial'] = oseObject::getValue($oneItem, 'has_trial', 0);
		} else {
			$params['params']['has_trial'] = 0;
		}
		$sisow_issuerid = JRequest::getVar('sisow_issuerid');
		if ($sisow_issuerid) {
			$params['params']['sisow_issuerid'] = $sisow_issuerid;
		}
		$sisow_payment = JRequest::getVar('sisow_payment');
		if ($sisow_payment) {
			$params['params']['sisow_payment'] = $sisow_payment;
		}
		$params['params']['a1'] = $paymentCart->get('total');
		$params['params']['p1'] = oseObject::getValue($oneItem, 'p1', 0);
		$params['params']['t1'] = oseObject::getValue($oneItem, 't1');
		$params['params']['a3'] = $paymentCart->get('next_total');
		$params['params']['p3'] = oseObject::getValue($oneItem, 'p3', 0);
		$params['params']['t3'] = oseObject::getValue($oneItem, 't3');
		$params['params'] = oseJSON::encode($params['params']);
		$list = oseMscAddon::getAddonList('register_order', false, 1, 'obj');
		foreach ($list as $addon) {
			$action_name = 'register_order.' . $addon->name . '.add';
			$params = oseMscAddon::runAction($action_name, $params);
		}
		$paymentOrder = $payment->getInstance('Order');
		$updated = $paymentOrder->generateOrder('', $member_id, $params);
		if ($updated) {
			$order_id = $updated;
			$result['order_id'] = $order_id;
			JRequest::setVar('order_id', $order_id);
		} else {
			$result['success'] = false;
			$result['title'] = 'Error';
			$result['content'] = JText::_('Error2');
			return $result;
		}
		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');
				$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');
			if (oseObject::getValue($item, 'eternal')) {
				$itemParams['payment_mode'] = 'm';
			} else {
				$itemParams['payment_mode'] = $payment_mode;
			}
			$price = oseObject::getValue($item, 'a3');
			if ($payment_mode == 'a') {
				if (oseObject::getValue($item, 'has_trial')) {
					$price = oseObject::getValue($item, 'a1');
				}
			}
			$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();
			$price_params = $payment->generateOrderParams($msc_id, $price, $payment_mode, $msc_option);
			$price_params['start_date'] = oseObject::getValue($item, 'start_date', null);
			$price_params['expired_date'] = oseObject::getValue($item, 'expired_date', null);
			$price_params['recurrence_mode'] = oseObject::getValue($item, 'recurrence_mode', 'period');
			$itemParams['params'] = oseJSON::encode($price_params);
			$paymentInfos = oseMscAddon::getExtInfo($msc_id, 'payment', 'obj');
			$paymentInfo = oseObject::getValue($paymentInfos, $msc_option);
			$updated = $paymentOrder->generateOrderItem($order_id, oseObject::getValue($item, 'entry_id'), $itemParams);
		}
		if ($updated) {
			$result['success'] = true;
			$result['title'] = JText::_('Done');
			$result['content'] = JText::_('Done');
		} else {
			$result['success'] = false;
			$result['title'] = 'Error';
			$result['content'] = JText::_('Order Generate Error');
		}
		$emailConfig = oseMscConfig::getConfig('email', 'obj');
		if (!empty($emailConfig->order_notification)) {
			$db = oseDB::instance();
			$where = array();
			$where[] = '`order_id` = ' . $db->Quote($order_id);
			$orderInfo = $paymentOrder->getOrder($where, 'obj');
			$memEmail = oseRegistry::call('member')->getInstance('Email');
			$receipt = $memEmail->getOrderNotification($orderInfo);//print_r($receipt);exit;
			$memEmail->sendToAdminGroup($receipt, $emailConfig->admin_group);
		}
		return $result;
	}
Beispiel #18
0
	private function jvsave($member_id, $post) {
		$mainframe = JFactory :: getApplication();
		$option = JRequest :: getCmd('option');
		// Initialize some variables
		$msg = "";
		$me = & JFactory :: getUser();
		$MailFrom = $mainframe->getCfg('mailfrom');
		$FromName = $mainframe->getCfg('fromname');
		$SiteName = $mainframe->getCfg('sitename');
		// Create a new JUser object
		$user = new JUser($member_id);
		$original_gid = $user->get('gid');
		if (!$user->bind($post)) {
			$result = array ();
			$result['success'] = false;
			$result['title'] = 'Error';
			$result['content'] = JText :: _('Failed Updating Member Information');
			$result = oseJSON :: encode($result);
			oseExit($result);
		}
		// Are we dealing with a new user which we need to create?
		$isNew = ($user->get('id') < 1);
		if (!$isNew) {
			// if group has been changed and where original group was a Super Admin
			if ($user->get('gid') != $original_gid && $original_gid == 25) {
				// count number of active super admins
				$query = 'SELECT COUNT( id )' .				' FROM #__users' .				' WHERE gid = 25' .				' AND block = 0';
				$this->db->setQuery($query);
				$count = $this->db->loadResult();
				if ($count <= 1) {
					$result = array ();
					$result['success'] = false;
					$result['title'] = 'Error';
					$result['content'] = JText :: _('Failed Updating Member Information');
					$result = oseJSON :: encode($result);
					oseExit($result);
				}
			}
		}
		/*
			 * Lets save the JUser object
			 */
		if (!$user->save()) {
			$result = array ();
			$result['success'] = false;
			$result['title'] = 'Error';
			$result['content'] = $user->getError();
			$result = oseJSON :: encode($result);
			oseExit($result);
		}
		// For new users, email username and password
		// Capture the new user id
		if ($isNew) {
			$newUserId = $user->get('id');
		} else {
			$newUserId = null;
		}
		return $newUserId;
	}
Beispiel #19
0
	function login($username, $password) {
		$app = JFactory::getApplication();
		// Populate the data array:
		$data = array();
		$data['return'] = base64_decode(JRequest::getVar('return', '', 'POST', 'BASE64'));
		// Set the return URL if empty.
		if (empty($data['return'])) {
			$data['return'] = 'index.php?option=com_users&view=profile';
		}
		// Get the log in options.
		$options = array();
		$options['remember'] = JRequest::getBool('remember', false);
		$options['return'] = $data['return'];
		// Get the log in credentials.
		$credentials = array();
		$credentials['username'] = $username;
		$credentials['password'] = $password;
		// Perform the log in.
		$error = $app->login($credentials, $options);
		if (JOOMLA16 || JOOMLA17) {
			$plugin = JPluginHelper::getPlugin('user', 'oseuser');
			if (!empty($plugin)) {
				$pluginParams = oseJSON::decode($plugin->params);
				$loginRedirect = $pluginParams->loginRedirect;
				$redmenuid = $pluginParams->redmenuid;
				$sefroutemethod = $pluginParams->sefroutemethod;
			} else {
				$loginRedirect = false;
			}
		} else {
			$plugin = JPluginHelper::getPlugin('user', 'oseuser');
			if (!empty($plugin)) {
				$pluginParams = new JParameter($plugin->params);
				$loginRedirect = $pluginParams->get('loginRedirect');
				$redmenuid = $pluginParams->get('redmenuid');
				$sefroutemethod = $pluginParams->get('sefroutemethod');
			} else {
				$loginRedirect = false;
			}
		}
		$user = JFactory::getUser();
		$db = JFactory::getDBO();
		$query = " SELECT a.menuid" . " FROM `#__menu` as m" . " LEFT JOIN `#__osemsc_acl` as a ON a.menuid = m.id" . " LEFT JOIN `#__osemsc_member` as b ON b.msc_id = a.id"
				. " WHERE b.member_id={$user->id} AND b.status = 1 ORDER BY a.menuid DESC LIMIT 1";
		$db->setQuery($query);
		$menu = $db->loadObject();
		if (!empty($menu)) {
			$redmenuid = $menu->menuid;
		}
		if ($loginRedirect && !empty($redmenuid)) {
			$db = JFactory::getDBO();
			$query = "SELECT * FROM `#__menu` WHERE `id` = " . (int) $redmenuid;
			$db->setQuery($query);
			$menu = $db->loadObject();
			switch ($sefroutemethod) {
			default:
			case 0:
				$return = ($menu->link == 'index.php?Itemid=') ? 'index.php' : $menu->link . "&Itemid=" . $menu->id;
				break;
			case 1:
				$return = ($menu->link == 'index.php?Itemid=') ? JRoute::_(JURI::root() . 'index.php') : JRoute::_($menu->link . "&Itemid=" . $menu->id);
				break;
			case 2:
				$return = JRoute::_($menu->alias);
				break;
			}
		} else {
			$session = JFactory::getSession();
			$return = $session->get('oseReturnUrl', base64_encode(JURI::root() . 'index.php?option=com_osemsc&view=login'));
			$return = base64_decode($return);
		}
		$result = array();
		// Check if the log in succeeded.
		$user_id = intval(JUserHelper::getUserId($username));
		$user = JFactory::getUser($user_id);
		if ($user->get('block')) {
			$result['success'] = false;
			$result['title'] = JText::_('Error');
			$result['content'] = JText::_('LOGIN_DENIED_YOUR_ACCOUNT_HAS_EITHER_BEEN_BLOCKED_OR_YOU_HAVE_NOT_ACTIVATED_IT_YET');
			$result['returnUrl'] = $return;
			return $result;
		}
		if ($error) {
			if (!JError::isError($error)) {
				$result['success'] = true;
				$result['returnUrl'] = $return;
				return $result;
			} else {
				$errors = JError::getErrors();
				$result['success'] = false;
				$result['title'] = JText::_('Error');
				$result['content'] = JText::_('PLEASE_MAKE_SURE_YOUR_ACCOUNT_AND_PASSWORD_IS_CORRECT');//implode("<br />",JError::getErrors());//'Make sure your account and password is correct';//Error ::getError();
				$result['returnUrl'] = $return;
				return $result;
			}
		} else {
			$result['success'] = false;
			$result['title'] = JText::_('Error');
			$result['content'] = JText::_('PLEASE_MAKE_SURE_YOUR_ACCOUNT_AND_PASSWORD_IS_CORRECT');//implode("<br />",JError::getErrors());//'Make sure your account and password is correct';//Error ::getError();
			$result['returnUrl'] = $return;
			return $result;
		}
	}
Beispiel #20
0
	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;
	    }
	}
Beispiel #21
0
 function generateOrder($msc_id, $msc_option = null)
 {
     $vals = array();
     $params = array();
     $subtotal = 0.0;
     $order_number = $this->generateOrderNumber($this->user_id);
     $params['entry_type'] = 'msc_list';
     $params['payment_price'] = 0.0;
     $params['payment_currency'] = 'USD';
     $params['order_number'] = $order_number;
     $params['create_date'] = oseHTML2::getDateTime();
     //date("Y-m-d H:i:s");
     $params['payment_serial_number'] = substr($order_number, 0, 20);
     $params['payment_method'] = 'free';
     $params['payment_mode'] = 'm';
     $entry_type = 'msc';
     $db = oseDB::instance();
     $query = "SELECT * FROM `#__osemsc_ext`" . " WHERE `type` = 'payment' AND `id` = '{$msc_id}'";
     $db->setQuery($query);
     $planPayment = oseDB::loadItem('obj');
     $options = oseJSON::decode($planPayment->params, true);
     $paymentInfo = oseGetValue($options, $lc->entry_option, array());
     $price = 0.0;
     $pVals = array();
     $pVals['recurrence_mode'] = 'period';
     $pVals['a3'] = $price;
     $pVals['p3'] = oseGetValue($paymentInfo, 'p3');
     $pVals['t3'] = oseGetValue($paymentInfo, 't3');
     $pVals['msc_option'] = $msc_option;
     $pVals['recurrence_mode'] = 'fixed';
     $pVals['start_date'] = oseHtml2::getDateTime();
     $pVals['expired_date'] = oseGetValue($this, 'expired_date', oseHtml2::getDateTime());
     $pVals['isLicensee'] = 1;
     // set licensee true
     $this->set('isLicensee', true);
     $pVals['eternal'] = oseGetValue($paymentInfo, 'eternal');
     $params['params'] = $pVals;
     $params['params']['total'] = $price;
     $params['params']['discount'] = $price;
     $params['params']['subtotal'] = $price;
     $params['params']['next_subtotal'] = $price;
     $params['params'] = oseJSON::encode($params['params']);
     $updated = oseDB::insert('#__osemsc_order', $params);
     if ($updated) {
         $order_id = $updated;
         $this->order_id = $order_id;
     } else {
         $result['success'] = false;
         $result['title'] = $result['status'] = 'Error';
         $result['content'] = $result['result'] = JText::_('Error');
         return $result;
     }
     $itemParams = array();
     $itemParams['entry_type'] = $entry_type;
     $itemParams['payment_price'] = $price;
     $itemParams['payment_currency'] = 'USD';
     $itemParams['create_date'] = oseHTML2::getDateTime();
     //date("Y-m-d H:i:s");
     $itemParams['payment_mode'] = 'm';
     $itemParams['params'] = oseJSON::encode($pVals);
     $updated = oseDB::insert('#__osemsc_order_item', $itemParams);
     if ($updated) {
         $this->order_item_id = $updated;
         $result['success'] = true;
         $result['title'] = $result['status'] = JText::_('Done');
         $result['content'] = $result['result'] = JText::_('Done');
     } else {
         $result['success'] = false;
         $result['title'] = $result['status'] = 'Error';
         $result['content'] = $result['result'] = JText::_('Order Generate Error');
     }
     return $result;
 }
Beispiel #22
0
 function remove()
 {
     $model = $this->getModel('profile');
     $updated = $model->remove();
     $result = array();
     if ($updated) {
         $result['success'] = true;
         $result['title'] = JText::_('DONE');
         $result['content'] = JText::_('SUCCESSFULLY');
     } else {
         $result['success'] = false;
         $result['title'] = JText::_('ERROR');
         $result['content'] = JText::_('ERROR');
     }
     $result = oseJSON::encode($result);
     oseExit($result);
 }
Beispiel #23
0
	function generateOrder($member_id, $payment_method, $orderPaymentInfo) {
		return oseRegistry::call('msc')->runAddonAction('register.payment.save', array('member_id' => $member_id, 'payment_method' => $payment_method), true, false);
		$result = array();
		if (empty($member_id)) {
			$result['success'] = false;
			$result['title'] = 'Error';
			$result['content'] = JText::_('Error');
			return $result;
		}
		$paymentOrder = oseRegistry::call('payment')->getInstance('Order');
		$params = array();
		$items = $orderPaymentInfo['items'];
		unset($orderPaymentInfo['items']);
		$order_number = $paymentOrder->generateOrderNumber($member_id);
		$orderPaymentInfo['order_number'] = $order_number;
		$orderPaymentInfo['entry_type'] = 'msc_list';
		$orderPaymentInfo['create_date'] = oseHTML::getDateTime();//date("Y-m-d H:i:s");
		$orderPaymentInfo['payment_serial_number'] = substr($orderPaymentInfo['order_number'], 0, 20);
		$orderPaymentInfo['payment_method'] = 'system';
		$orderPaymentInfo['payment_from'] = 'system_admin';
		$orderPaymentInfo['payment_mode'] = 'm';
		oseObject::setParams($orderPaymentInfo, array('time_stamp' => uniqid("{$member_id}_", true)));
		// Extra Order Params Updating Function
		$list = oseMscAddon::getAddonList('register_order', true, 1, 'obj');
		foreach ($list as $addon) {
			$action_name = 'register_order.' . $addon->name . '.add';
			//echo $action_name;
			$params = oseMscAddon::runAction($action_name, $orderPaymentInfo['params'], true, false);
		}
		// generate Order
		$updated = $paymentOrder->generateOrder('', $member_id, $orderPaymentInfo);
		if (!$updated) {
			$result['success'] = false;
			$result['title'] = 'Error';
			$result['content'] = JText::_('Error');
			return $result;
		}
		// generate orer item
		// in the backend, only manual payment
		$order_id = $result['order_id'] = $updated;
		$payment_mode = 'm';
		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');
				$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');
			if (oseObject::getValue($item, 'eternal')) {
				$itemParams['payment_mode'] = 'm';
			} else {
				$itemParams['payment_mode'] = 'm';
			}
			$price = oseObject::getValue($item, 'a3');
			if ($payment_mode == 'a') {
				if (oseObject::getValue($item, 'has_trial')) {
					$price = oseObject::getValue($item, 'a1');
				}
			}
			$itemParams['entry_type'] = oseObject::getValue($item, 'entry_type');
			$itemParams['payment_price'] = 0;//oseObject::getValue($item,'first_raw_price');
			$itemParams['payment_currency'] = $orderPaymentInfo['payment_currency'];
			$itemParams['create_date'] = oseHTML::getDateTime();//date("Y-m-d H:i:s");
			$price_params = $paymentOrder->generateOrderParams($msc_id, $price, $payment_mode, $msc_option);
			$price_params['start_date'] = oseObject::getValue($item, 'start_date', null);
			$price_params['expired_date'] = oseObject::getValue($item, 'expired_date', null);
			$itemParams['params'] = oseJSON::encode($price_params);
			$paymentInfos = oseMscAddon::getExtInfo($msc_id, 'payment', 'obj');
			$paymentInfo = oseObject::getValue($paymentInfos, $msc_option);
			$updated = $paymentOrder->generateOrderItem($order_id, oseObject::getValue($item, 'entry_id'), $itemParams);
		}
		if ($updated) {
			$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;
	}
	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;
	}
Beispiel #25
0
 function save()
 {
     $post = array();
     $email = oseRegistry::call('member')->getInstance('Email');
     $id = JRequest::getInt('id', 0);
     $body = JRequest::getString('ebody', '', 'post', JREQUEST_ALLOWRAW);
     $subject = JRequest::getString('subject', null);
     $type = JRequest::getString('type', 'email');
     $msc_id = JRequest::getInt('msc_id', 0);
     $post['id'] = $id;
     $post['body'] = $body;
     $post['subject'] = $subject;
     $post['type'] = $type;
     $post['msc_id'] = $msc_id;
     $post['params'] = oseJSON::encode($email->buildEmailParams($type));
     return $email->save($post);
 }
Beispiel #26
0
 private static function joinInAutomaticMode($msc_id, $member_id, $orderInfo)
 {
     $db = oseDB::instance();
     $result = array();
     $result['success'] = true;
     $orderParams = oseJSON::decode($orderInfo->params);
     $start_date = oseHTML::getDateTime();
     $start_date = $db->Quote($start_date);
     if ($orderParams->has_trial) {
         $recurrence_num = $orderParams->p1 + 1;
         $recurrence_unit = $orderParams->t1;
     } else {
         $recurrence_num = $orderParams->p3 + 1;
         $recurrence_unit = $orderParams->t3;
     }
     $expired_date = " DATE_ADD({$start_date},INTERVAL {$recurrence_num} {$recurrence_unit}) ";
     $query = " UPDATE `#__osemsc_member` " . " SET  start_date = {$start_date} , expired_date = {$expired_date}" . " WHERE member_id = {$member_id} AND msc_id = {$msc_id} ";
     $db->setQuery($query);
     if (!oseDB::query()) {
         $result['success'] = false;
         $result['title'] = 'Error';
         $result['content'] = JText::_(' Fail Updated Member\'s Recurrence ');
         return $result;
     }
     return $result;
 }
Beispiel #27
0
 function loadEmailTemplate()
 {
     $model = $this->getModel('emails');
     $updated = $model->loadEmailTemplate();
     if ($updated) {
         $result['success'] = true;
         $result['status'] = JText::_('DONE');
         $result['result'] = JText::_('SAMPLE_TEMPLATES_ARE_LOADED_SUCCESSFULLY');
     } else {
         $result['success'] = false;
         $result['status'] = JText::_('ERROR');
         $result['result'] = JText::_('FAILED_LOADING_SAMPLE_TEMPLATES');
     }
     echo oseJSON::encode($result);
     exit;
 }
Beispiel #28
0
 function getOptions()
 {
     $db = oseDB::instance();
     $msc_id = JRequest::getInt('msc_id', 0);
     $date = JRequest::getVar('date', 0);
     $query = "SELECT title FROM `#__osemsc_acl` WHERE `id` = " . (int) $msc_id;
     $db->setQuery($query);
     $title = $db->loadResult();
     $msc = oseRegistry::call('msc');
     $opts = $msc->runAddonAction('panel.payment.getOptions');
     $options = $opts['results'];
     $items = array();
     $item = array();
     foreach ($options as $option) {
         $item['option_id'] = $option['id'];
         $item['option_name'] = $option['optionname'];
         $item['msc'] = $title;
         $query = " SELECT * FROM `#__osemsc_member` AS mem" . " WHERE `msc_id` = '{$msc_id}' AND DATE(`start_date`) = '{$date}' AND `status` = 1";
         $db->setQuery($query);
         $mems = $db->loadObjectList();
         $newMem = 0;
         foreach ($mems as $mem) {
             $params = oseJSON::decode($mem->params);
             $query = "SELECT params FROM `#__osemsc_order_item` WHERE `order_item_id` = '{$params->order_item_id}'";
             $db->setQuery($query);
             $order_params = oseJSON::decode($db->loadResult());
             if ($order_params->msc_option == $item['option_id']) {
                 $newMem++;
             }
         }
         $item['newmem'] = $newMem;
         $query = " SELECT * FROM `#__osemsc_member` AS mem" . " WHERE `msc_id` = '{$msc_id}' AND DATE(`expired_date`) = '{$date}' AND `status` = 0";
         $db->setQuery($query);
         $mems = $db->loadObjectList();
         $expMem = 0;
         foreach ($mems as $mem) {
             $params = oseJSON::decode($mem->params);
             $query = "SELECT params FROM `#__osemsc_order_item` WHERE `order_item_id` = '{$params->order_item_id}'";
             $db->setQuery($query);
             $order_params = oseJSON::decode($db->loadResult());
             if ($order_params->msc_option == $item['option_id']) {
                 $expMem++;
             }
         }
         $item['expmem'] = $expMem;
         $ratio = round($item['expmem'] / $item['newmem'] * 100, 2);
         $item['ratio'] = $ratio . '%';
         $query = " SELECT ord.payment_price, ord.payment_currency, ooi.params, ord.params as order_params FROM `#__osemsc_order` AS ord" . " INNER JOIN `#__osemsc_order_item` AS ooi" . " ON ord.`order_id` = ooi.`order_id`" . " WHERE ord.`order_status` = 'confirmed' AND ooi.`entry_id` = '{$msc_id}' AND DATE(ord.`create_date`) = '{$date}'";
         $db->setQuery($query);
         $objs = $db->loadObjectList();
         $arr = array();
         $arr2 = array();
         foreach ($objs as $obj) {
             $params = oseJSON::decode($obj->params);
             if ($params->msc_option == $item['option_id']) {
                 $arr[$obj->payment_currency] += $obj->payment_price;
                 $orderParams = oseJSON::decode($obj->order_params);
                 $arr2[$obj->payment_currency] += $orderParams->gross_tax;
             }
         }
         $profit = null;
         foreach ($arr as $key => $value) {
             if (empty($value)) {
                 continue;
             } else {
                 $profit .= $value . ' ' . $key . '   ,';
             }
         }
         $profit = trim($profit, ",");
         $item['profits'] = $profit;
         $tax = null;
         foreach ($arr2 as $key => $value) {
             if (empty($value)) {
                 continue;
             } else {
                 $tax .= $value . ' ' . $key . '   ,';
             }
         }
         $tax = trim($tax, ",");
         $item['tax'] = $tax;
         $items[] = $item;
     }
     //print_r($items);exit;
     $result = array();
     $result['total'] = count($items);
     $result['results'] = $items;
     return $result;
 }
 function returnMessages($status, $messages)
 {
     $result = array();
     if ($status == true) {
         $result['success'] = true;
         $result['status'] = 'Done';
         $result['result'] = $messages;
     } else {
         $result['success'] = false;
         $result['status'] = 'Error';
         $result['result'] = $messages;
     }
     $result = oseJSON::encode($result);
     oseExit($result);
 }
Beispiel #30
0
 function updateMemberExpiryDate()
 {
     $result = array();
     $id = JRequest::getInt('id');
     $expired_date = JRequest::getString('expired_date');
     $db = oseDB::instance();
     $query = " SELECT * FROM `#__osemsc_order_fix`" . " WHERE `id` = '{$id}'";
     $db->SetQuery($query);
     $item = oseDB::loadItem('obj');
     $query = " SELECT * FROM `#__osemsc_member`" . " WHERE `id` = '{$item->member_id}'";
     $db->SetQuery($query);
     $member = oseDB::loadItem('obj');
     $eDate = explode(' ', $member->expired_date);
     $expired_date = $expired_date . ' ' . $eDate[1];
     // update member table params
     $mVals = array();
     $mVals['id'] = $item->member_id;
     $mVals['expired_date'] = $expired_date;
     oseDB::update("#__osemsc_member", 'id', $mVals);
     $result['success'] = true;
     $result['title'] = JText::_('SUCCESS');
     $result['content'] = JText::_('SUCCESS');
     $result = oseJSON::encode($result);
     oseExit($result);
 }