<?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();
JHtml::addIncludePath(JPATH_COMPONENT.'/helpers/html');
$input = JFactory::getApplication()->input;
jimport('joomla.html.editor');
JHtml::_('bootstrap.tooltip');
jimport('joomla.form.helper');
JFormHelper::loadFieldClass('list');
JHtml::_('formbehavior.chosen', 'select');
JHtml::_('behavior.framework', true);
JHtml::_('behavior.formvalidator');
if (!class_exists('Vmconfig')) {
    include JPATH_ADMINISTRATOR.'/components/com_virtuemart/helpers/config.php';
}
Vmconfig::loadConfig();
if (!class_exists('MarketplaceHelper')) {
    include JPATH_ADMINISTRATOR.DIRECTORY_SEPARATOR.'components'.
    DIRECTORY_SEPARATOR.'com_marketplace'.DIRECTORY_SEPARATOR.
    'helpers'.DIRECTORY_SEPARATOR.'marketplace.php';
}
$mpHelp=new MarketplaceHelper();
$document = JFactory::getDocument();
$config = JFactory::getConfig();
$style = '
.pay_head {
    position: relative;
    top: 0;
    left: 0;
    background: #428BCA;
    margin: 0;
    padding: 10px;
    color: white;
    border-radius: 5px 5px 0px 0;
}

.pay-sell {
    width: 100px;
    margin: 0 5px 0 0 !important;
}

.comm_det_head {
    text-transform: capitalize;
    font-weight: bold;
}

.comm_det {
    margin: 8px 20px;
}
';
$document->addStyleDeclaration($style);
$jinput=JFactory::getApplication()->input;
$data=json_decode($jinput->get("data", null, "object"));
$id_sep = strrpos($data->pay_option_finals, '-', -1);
$payment_id = substr(
    $data->pay_option_finals, $id_sep+1, strlen($data->pay_option_finals)
);
$seller_id=$jinput->getInt("seller_id", 0);
$payment_method_model = VmModel::getModel("Paymentmethod");
$pay_details = $payment_method_model->getPayment($payment_id);
$user = JFactory::getUser($seller_id);
$form = '<h1 class="pay_head">'.JText::_('PAY_STANDARD_PAYMENT').'</h1>';
$form .= '<form method="post"  action="'.JURI::base().
    'index.php?option=com_marketplace&view=commisions&layout=success&tmpl=component"'.
    ' name="paytoseller" id="wk_pay">';
$form .= '<div class="comm_det">'.
    '<div class="comm_det_head">'.JText::_("PAYMENT_METHOD").'</div>'.
    '<div class="comm_det_val">'.$pay_details->payment_name.'</div>'.
    '</div>';
$form .= '<div class="comm_det">'.
    '<div class="comm_det_head">'.JText::_("PAYMENT_DETAIL").'</div>'.
    '<div class="comm_det_val">'.$data->business_email.'</div>'.
    '</div>';
$form .= '<div class="comm_det">'.
    '<div class="comm_det_head">'.JText::_("CUSTOMER_NAME").'</div>'.
    '<div class="comm_det_val">'.$user->username.'</div>'.
    '</div>';
$form .= '<div class="comm_det">'.
    '<div class="comm_det_head">'.JText::_("AMOUNT_REMAIN").'</div>'.
    '<div class="comm_det_val">'.$data->amount_remain.$this->currencySymbol.'</div>'.
    '</div>';
$form .= '<div class="comm_det">'.
    '<div class="comm_det_head"></div>'.
    '<div class="comm_det_val">'.'<input type="hidden" name="seller_id" value="'.
    $seller_id.
    '" ><input type="hidden" name="totalAmountToPay" value="'.
    $data->amount_remain.
    '" ><input type="hidden" name="pay_mode" value="'.
    $data->pay_option_finals.
    '" ><input type="hidden" name="commision_amount" value="'.
    $data->cm_amt.
    '" ><input class="pay-sell" type="number" name="amount" required="true" value="'.
    $data->commision_amount
    .'" step=".01">';
if ($data->amount_remain >0) { 
    $form.='<input type="submit" class="btn btn-success"  value="'. JText::_("PAY").'"/>';
}
$form .= '</div></div></div>';


$form.='</form>';
echo $form;
?>
<script type="text/javascript">
    
    function cancelpop(){
    
        window.parent.location.href="<?php echo JURI::root().'administrator/index.php?option=com_marketplace&view=commisions'?>"
    }
    
</script>

