| Current Path : /var/www/html/modules/mod_userpoints2paypal/tmpl/ |
| Current File : /var/www/html/modules/mod_userpoints2paypal/tmpl/default.php |
<?php
/*
* @package Joomla 3
* @module Nordmograph - Userpoints 2 Paypal
* @copyright Copyright (C) Adrien Roussel https://www.nordmograph.com/extensions
* @license http://www.gnu.org/copyleft/gpl.html GNU/GPL
*/
defined('_JEXEC') or die('=;)');
$doc = JFactory::getDocument();
$user = JFactory::getUser();
$juri = JURI::base();
$uri = JFactory::getUri();
$app = JFactory::getApplication();
$pointsys = $params->get('pointsys',0);
$minreq = $params->get('minreq',100);
$pointsname = $params->get('pointsname','points');
$currency_code = $params->get('currency_code','USD');
$ratio = $params->get('ratio',0.01);
$decim = $params->get('decim',2);
$validpointsamount = $app->input->post->getInt('pointsamount');
$validmoneyamount = $app->input->post->get('total');
$paypalemail = $app->input->post->get( 'paypal_useremail','' , 'string' );
$Itemid = $app->input->post->getInt('Itemid','');
echo '<div>';
echo '<div class="well">
<img src="'.$juri.'modules/mod_userpoints2paypal/img/header.png" width="182" height="62" alt="img" />
<div>'.JText::_('UPTS2PPL_INTRO').'<br /><br /></div>';
echo '<div>'.JText::_('UPTS2PPL_YOUR').': <span class="badge">'.$userpoints.'</span></div>';
echo '</div>';
if($userpoints<$minreq)
{
if($user->id ==0)
{
echo '<div class="alert alert-warning">';
echo JText::_('UPTS2PPL_YOUNEEDTO').' '.$pointsname.' '.JText::_('UPTS2PPL_4PPLCASH');
echo '</div>';
}
else
{
echo '<div>';
echo JText::_('UPTS2PPL_NOTENOUGHYET1').' '.$pointsname.' '.JText::_('UPTS2PPL_NOTENOUGHYET2');
echo '<br /><br />';
echo '<div><table class="table">';
echo '<tr>';
echo '<td>'.JText::_('UPTS2PPL_CURRENT').'</td>';
echo '<td>'.JText::_('UPTS2PPL_REQUIRED').'</td>';
echo '<td>'.JText::_('UPTS2PPL_MISSING').'</td>';
echo '</tr>';
if (!$userpoints)
$userpoints = 0;
echo '<tr>';
echo '<td>'.$userpoints.'</td>';
echo '<td>'.$minreq.'</td>';
echo '<td>'.($minreq - $userpoints).'</td>';
echo '</tr>';
echo '</table></div>';
echo '</div>';
}
}
elseif($userpoints>=$minreq)
{
echo '<script language = "Javascript">
function echeck(str) {
var at="@"
var dot="."
var lat=str.indexOf(at)
var lstr=str.length
var ldot=str.indexOf(dot)
var emailID=document.frm.paypal_useremail
if (str.indexOf(at)==-1){
emailID.style.backgroundColor = "#ff9999"
// alert("'.JText::_('UPTS2PPL_INVALIDEMAIL').'")
swal("'.JText::_('JNo').'","'.JText::_('UPTS2PPL_INVALIDEMAIL').'","error");
return false
}
if (str.indexOf(at)==-1 || str.indexOf(at)==0 || str.indexOf(at)==lstr){
emailID.style.backgroundColor = "#ff9999"
// alert("'.JText::_('UPTS2PPL_INVALIDEMAIL').'")
swal("'.JText::_('JNo').'","'.JText::_('UPTS2PPL_INVALIDEMAIL').'","error");
return false
}
if (str.indexOf(dot)==-1 || str.indexOf(dot)==0 || str.indexOf(dot)==lstr){
emailID.style.backgroundColor = "#ff9999"
//alert("'.JText::_('UPTS2PPL_INVALIDEMAIL').'")
swal("'.JText::_('JNo').'","'.JText::_('UPTS2PPL_INVALIDEMAIL').'","error");
return false
}
if (str.indexOf(at,(lat+1))!=-1){
emailID.style.backgroundColor = "#ff9999"
//alert("'.JText::_('UPTS2PPL_INVALIDEMAIL').'")
swal("'.JText::_('JNo').'","'.JText::_('UPTS2PPL_INVALIDEMAIL').'","error");
return false
}
if (str.substring(lat-1,lat)==dot || str.substring(lat+1,lat+2)==dot){
emailID.style.backgroundColor = "#ff9999"
//alert("'.JText::_('UPTS2PPL_INVALIDEMAIL').'")
swal("'.JText::_('JNo').'","'.JText::_('UPTS2PPL_INVALIDEMAIL').'","error");
return false
}
if (str.indexOf(dot,(lat+2))==-1){
emailID.style.backgroundColor = "#ff9999"
//alert("'.JText::_('UPTS2PPL_INVALIDEMAIL').'")
swal("'.JText::_('JNo').'","'.JText::_('UPTS2PPL_INVALIDEMAIL').'","error");
return false
}
if (str.indexOf(" ")!=-1){
emailID.style.backgroundColor = "#ff9999"
//alert("'.JText::_('UPTS2PPL_INVALIDEMAIL').'")
swal("'.JText::_('JNo').'","'.JText::_('UPTS2PPL_INVALIDEMAIL').'","error");
return false
}
return true
}
function ValidateForm(){
var emailID=document.frm.paypal_useremail;
var pointsamount=document.frm.pointsamount;
var loading=document.frm.loading;
if ((pointsamount.value<'.$minreq.')||(pointsamount.value>'.$userpoints.'))
{
pointsamount.style.backgroundColor = "#ff6666";
//alert("'.JText::_('UPTS2PPL_AMNTNOTALLOWED').'");
swal("'.JText::_('JNo').'","'.JText::_('UPTS2PPL_AMNTNOTALLOWED').'","error");
pointsamount.focus();
return false;
}
if ( Number.isNaN(pointsamount) )
{
pointsamount.style.backgroundColor = "#ff6666";
//alert("'.JText::_('UPTS2PPL_AMNTNO;TALLOWED').'");
swal("'.JText::_('JNo').'","'.JText::_('UPTS2PPL_AMNTNOTALLOWED').'","error");
pointsamount.focus()
return false;
}
if ((emailID.value==null)||(emailID.value==""))
{
emailID.style.backgroundColor = "#ff9999";
//alert("'.JText::_('UPTS2PPL_INVALIDEMAIL').'");
swal("'.JText::_('JNo').'","'.JText::_('UPTS2PPL_INVALIDEMAIL').'","error");
emailID.focus();
emailID.style.backgroundColor = "#ffffff";
return false;
}
if (echeck(emailID.value)==false)
{
emailID.style.backgroundColor = "#ff9999";
emailID.value="";
emailID.focus();
emailID.style.backgroundColor = "#ffffff";
return false;
}
emailID.style.backgroundColor = "#ffffff";
swal({
title: "'.JText::_('UPTS2PPL_CONFIRMPOINTSDEDUCTION').'",
text: pointsamount.value + " '.ucfirst($pointsname).' '.JText::_('UPTS2PPL_AREGOINGTO').' " + emailID.value ,
type: "warning",
showCancelButton: true,
cancelButtonColor: "#d33",
confirmButtonColor: "green",
confirmButtonText: "'.JText::_('JYes').'",
closeOnConfirm: true
},
function() {
loading.style.display = "";
frm.submit();
}
);
return false;
}
</script>';
echo '<SCRIPT language="javascript" >
function calculate(){
var pointsamount = Number(document.getElementById("pointsamount").value);
pointsamount = pointsamount.toString().replace(/[^\d.-]/g, "");
document.getElementById("pointsamount").value = pointsamount;
if((document.getElementById("pointsamount").value>'.$userpoints.')||(document.getElementById("pointsamount").value<'.$minreq.')){
var total = "'.JText::_('UPTS2PPL_NOTALLOWED').'";
document.getElementById("total").value = total;
document.getElementById("total").style.color = "red";
document.getElementById("pointsamount").style.backgroundColor = "#ff9999"
}
else{
var total = Number(pointsamount *'.$ratio.');
document.getElementById("total").value = total.toFixed('.$decim.');
document.getElementById("total").style.color = "#000000";
document.getElementById("pointsamount").style.backgroundColor = "#ffffff"
}
}
</SCRIPT>';
echo '<div>';
echo '<form name="frm" onSubmit="return ValidateForm()" method="post" >';
echo '<table class="table table-condensed">';
echo '<tr><td>';
echo '<label for="pointsamount">'.ucfirst($pointsname).' '.JText::_('UPTS2PPL_TOCONVERT').'</label> ';
echo '<input type="text" name="pointsamount" id="pointsamount"
onkeyup="javascript:calculate()" value="'.$minreq.'" class="form-control"/>';
echo '</td></tr>';
echo '<tr><td>';
echo '<label>'.$currency_code.' '.JText::_('UPTS2PPL_AMOUNT').':</label>';
echo '<input style="border:0;background-color:transparent; " type="text" name="total" id="total"
readonly size="10" value="'.number_format( $minreq*$ratio , $decim ).'" class="form-control"/>';
echo '</td></tr>';
echo '<tr><td>';
echo '<label for="paypal_useremail">'.JText::_('UPTS2PPL_YOURPPLEMAIL').'</label> ';
echo ' <input type="text" name="paypal_useremail" id="paypal_useremail" size="20" value="" class="form-control"
placeholder="'.JText::_('UPTS2PPL_YOURPPLEMAIL').'" />';
echo '</td></tr>';
echo '<tr><td style="color:#D3D3D3;text-align:right;">';
echo JText::_('UPTS2PPL_PPLFEE');
echo '</td></tr>';
echo '</table>';
$allowreceivecopy = $params->get('allowreceivecopy',1);
if ($allowreceivecopy)
{
echo '<div class="checkbox">
<label><input type="checkbox" name="receivecopy" id="receivecopy" class="checkbox" checked />'.JText::_('UPTS2PPL_RECEIVECOPY').'</label>
</div>';
}
echo '<button type="submit" class="btn btn-large btn-block btn-primary"
>'.JText::_('UPTS2PPL_SENDPAYMENTREQ').'</button>';
echo ' <img src="'.$juri.'modules/mod_userpoints2paypal/img/loader.gif" alt="" width="24" height="24" border="0" name = "loading" id= "loading" style="display: none;" />';
echo '</form>';
echo '</div>';
}
echo '</div>';