| Current Path : /home/digilove/public_html/components/com_marketplace/models/ |
| Current File : /home/digilove/public_html/components/com_marketplace/models/mypayments.php |
<?php
/**
* Marketplace - Component Marketplace
* ******************************************************************
*
* PHP version 7.0
*
* @category Component
* @package Joomla
* @author WebKul software private limited <support@webkul.com>
* @copyright 2010 WebKul software private limited
* @license http://www.gnu.org/licenses/gpl-2.0.html GNU/GPL
* @version GIT:5.2
* @filesource http://store.webkul.com
* @link Technical Support: webkul.uvdesk.com
* ******************************************************************
*/
// no direct access
defined('_JEXEC') or die('Restricted access');
jimport('joomla.application.component.modellist');
if (!class_exists('MarketplaceModelOrderhistory')) {
/**
* Marketplace Model Mypayments class
*
* @category Component
* @package Joomla
* @author WebKul software private limited <support@webkul.com>
* @license http://www.gnu.org/licenses/gpl-2.0.html GNU/GPL
* @link Technical Support: webkul.uvdesk.com
*/
class MarketplaceModelMypayments extends JModelLegacy
{
/**
* __construct function
*/
public function __construct()
{
parent::__construct();
}
/**
* Get Commissions function
*
* @param integer $user Seller Id
*
* @return void
*/
function getCommissions($user)
{
$query=$this->_db->getQuery(true);
$query->select('*')
->from($this->_db->quoteName('#__marketplace_commision'))
->where($this->_db->quoteName('seller_id').'='.$user);
$this->_db->setQuery($query);
try{
return $this->_db->loadObjectList();
}
catch(Exception $e){
JFactory::getApplication()->enqueueMessage(
$e->getMessage(),
'error'
);
return false;
}
}
/**
* Update Commission function
*
* @param integer $amount_remain Amount Remain
* @param integer $amount_recieved Amount Recieved
* @param integer $amount_paid Amount paid
* @param integer $vendor_currency_id Currency Id
* @param integer $tot Total
* @param object $userdetails User Object
*
* @return void
*/
function updateCommission(
$amount_remain,
$amount_recieved,
$amount_paid,
$vendor_currency_id,
$tot,
$userdetails
) {
$query=$this->_db->getQuery(true);
// settings fields value
$fields=array(
$this->_db->quoteName('amount_remain')."=".$amount_remain."",
$this->_db->quoteName('amount_recieved')."=".$amount_recieved."",
$this->_db->quoteName('amount_remain')."=".$amount_paid."",
$this->_db->quoteName('currency')."=".$vendor_currency_id."",
$this->_db->quoteName('total_sales')."=".$tot.""
);
// conditions
$condition=array(
$this->_db->quoteName('seller_id')."=".$userdetails->id.""
);
// update query
$query->update(
$this->_db->quoteName('#__marketplace_commision')
)
->set($fields)
->where($condition);
$this->_db->setQuery($query);
try{
$this->_db->execute();
}
catch(Exception $e){
JFactory::getApplication()->enqueueMessage(
$e->getMessage(),
'error'
);
}
}
/**
* Undocumented function
*
* @param integer $id Seller Id
* @param date $startdate Start date
* @param date $enddate End Date
* @param integer $lazy_limit Lazy Load Limit
* @param integer $lazy_start Lazy Load Start
* @param integer $tot Total
*
* @return void
*/
function getMpPayment($id,$startdate,$enddate,$lazy_limit,$lazy_start,$tot=0)
{
$db=$this->_db;
$query=$this->_db->getQuery(true);
$query->select("a.*")
->select($this->_db->quoteName('b.currency_symbol'))
->from($this->_db->quoteName('#__marketplace_payments', 'a'))
->join(
"LEFT",
$this->_db->quoteName('#__virtuemart_currencies', 'b')
." ON (".$this->_db->quoteName('a.currency')."=".
$this->_db->quoteName('b.virtuemart_currency_id').")"
);
$query->where($this->_db->quoteName('a.seller_id')."=".$db->quote($id));
if ($startdate==$enddate) {
$query->where(
"date(".$this->_db->quoteName('a.date').
')='.$db->quote($startdate)
);
} else {
$query->where(
$this->_db->quoteName('a.date')." BETWEEN '".
$startdate."' AND DATE_ADD('".$enddate."', INTERVAL 1 DAY)"
);
}
$query->order($this->_db->quoteName('a.date').' desc');
$this->_db->setQuery($query);
try{
return $this->_db->loadObjectList();
}
catch(Exception $e){
JFactory::getApplication()->enqueueMessage(
$e->getMessage(),
'error'
);
return false;
}
}
/**
* Get Mp Payment Total function
*
* @param integer $id Seller Id
* @param date $startdate Start date
* @param date $enddate End Date
* @param integer $tot Total
*
* @return void
*/
function getMpPaymentTotal($id,$startdate,$enddate,$tot=0)
{
$query=$this->_db->getQuery(true);
$query->select("a.*")
->select($this->_db->quoteName('b.currency_symbol'))
->from($this->_db->quoteName('#__marketplace_payments', 'a'))
->join(
"LEFT",
$this->_db->quoteName('#__virtuemart_currencies', 'b').
" ON (".$this->_db->quoteName('a.currency')."=".
$this->_db->quoteName('b.virtuemart_currency_id').")"
)
->where(
$this->_db->quoteName('a.seller_id')."=".$id.
" AND a.date BETWEEN '".$startdate."' AND '".$enddate."'"
)
->order($this->_db->quoteName('a.date').' desc');
$this->_db->setQuery($query);
try{
return count($this->_db->loadObjectList());
}
catch(Exception $e){
JFactory::getApplication()->enqueueMessage(
$e->getMessage(),
'error'
);
return false;
}
}
/**
* Get Total Payment function
*
* @param Integer $id Seller Id
*
* @return void
*/
function getTotalPayment($id)
{
$query=$this->_db->getQuery(true);
$query->select("a.*")
->select($this->_db->quoteName('b.currency_symbol'))
->from($this->_db->quoteName('#__marketplace_payments', 'a'))
->join(
"LEFT",
$this->_db->quoteName('#__virtuemart_currencies', 'b').
" ON (".$this->_db->quoteName('a.currency')."=".
$this->_db->quoteName('b.virtuemart_currency_id').")"
)
->where($this->_db->quoteName('a.seller_id')."=".$id)
->order($this->_db->quoteName('a.date').' desc');
$this->_db->setQuery($query);
try{
return $this->_db->loadObjectList();
}
catch(Exception $e){
JFactory::getApplication()->enqueueMessage(
$e->getMessage(),
'error'
);
return false;
}
}
/**
* Get Currency Details function
*
* @param Integer $id Seller Id
*
* @return void
*/
function getCurrencyDetails($id)
{
$currModel=VmModel::getModel('currency');
$query=$this->_db->getQuery(true);
$query->select("a.*")
->select($this->_db->quoteName('b.currency_symbol'))
->select($this->_db->quoteName('b.virtuemart_currency_id'))
->from($this->_db->quoteName('#__marketplace_commision', 'a'))
->join(
'LEFT',
$this->_db->quoteName('#__virtuemart_currencies', 'b').
' ON('.$this->_db->quoteName('a.currency').'='.
$this->_db->quoteName('b.virtuemart_currency_id').')'
)
->where($this->_db->quoteName('a.seller_id')."=".$id."");
$this->_db->setQuery($query);
try{
return $this->_db->loadObject();
}
catch(Exception $e){
JFactory::getApplication()->enqueueMessage(
$e->getMessage(),
'error'
);
return false;
}
}
/**
* Get Total Order function
*
* @return void
*/
function getTotalOrder()
{
$db=$this->_db;
$userdetails=JFactory::getUser();
$query=$db->getQuery(true);
$query->select(array('a.*'))
->from($db->quoteName('#__marketplace_orderlist')." AS a")
->where('virtuemart_seller_id='.$userdetails->id);
try{
$db->setQuery($query);
return $db->loadObjectList();
}
catch(Exception $e){
JFactory::getApplication()->enqueueMessage(
$e->getMessage(),
'error'
);
}
}
}
}