181 lines
4.8 KiB
JavaScript
181 lines
4.8 KiB
JavaScript
|
|
function showdescription(id,title,desc,minus,object)
|
||
|
|
{
|
||
|
|
if(!minus)minus=0;
|
||
|
|
var sum=17-minus;
|
||
|
|
document.getElementById("desc").style.display="inline";
|
||
|
|
document.getElementById("desc-title").innerHTML=title;
|
||
|
|
document.getElementById("desc-desc").innerHTML=desc;
|
||
|
|
posy=findPosY(object)+sum;
|
||
|
|
posx=findPosX(object);
|
||
|
|
moveDiv(document.getElementById("desc"),posy,posx);
|
||
|
|
}
|
||
|
|
function hidedescription()
|
||
|
|
{
|
||
|
|
document.getElementById("desc").style.display="none";
|
||
|
|
}
|
||
|
|
|
||
|
|
function mintajaxget(url,tag){
|
||
|
|
$('#'+tag).html('<img src="themes/default/images/loading.gif" border="0">');
|
||
|
|
$.ajax({
|
||
|
|
type : "POST",
|
||
|
|
url : url,
|
||
|
|
dataType : "html",
|
||
|
|
async : false,
|
||
|
|
success : function(data) {
|
||
|
|
$('#'+tag).html(data);
|
||
|
|
},
|
||
|
|
});
|
||
|
|
}
|
||
|
|
|
||
|
|
function mintajaxpost(url,tag,form)
|
||
|
|
{
|
||
|
|
var req=mint.Request();
|
||
|
|
req.OnSuccess=function(){$(tag).innerHTML=this.responseText;}
|
||
|
|
req.OnLoading=function(){$(tag).innerHTML='<img src="themes/default/images/loading.gif" border="0">';}
|
||
|
|
req.SendForm(form);
|
||
|
|
}
|
||
|
|
function moveDiv(obj, mvTop, mvLeft) {
|
||
|
|
obj.style.position = "absolute";
|
||
|
|
obj.style.top = mvTop;
|
||
|
|
obj.style.left = mvLeft;
|
||
|
|
}
|
||
|
|
function getPos(inputElement) {
|
||
|
|
var coords = new Object();
|
||
|
|
coords.x = 0;
|
||
|
|
coords.y = 0;
|
||
|
|
try {
|
||
|
|
targetElement = inputElement;
|
||
|
|
if(targetElement.x && targetElement.y) {
|
||
|
|
coords.x = targetElement.x;
|
||
|
|
coords.y = targetElement.y;
|
||
|
|
} else {
|
||
|
|
if(targetElement.offsetParent) {
|
||
|
|
coords.x += targetElement.offsetLeft;
|
||
|
|
coords.y += targetElement.offsetTop;
|
||
|
|
while(targetElement = targetElement.offsetParent) {
|
||
|
|
coords.x += targetElement.offsetLeft;
|
||
|
|
coords.y += targetElement.offsetTop;
|
||
|
|
}
|
||
|
|
} else {
|
||
|
|
//alert("Could not find any reference for coordinate positioning.");
|
||
|
|
}
|
||
|
|
}
|
||
|
|
return coords;
|
||
|
|
} catch(error) {
|
||
|
|
//alert(error.msg);
|
||
|
|
return coords;
|
||
|
|
}
|
||
|
|
}
|
||
|
|
|
||
|
|
function findPosX(obj)
|
||
|
|
{
|
||
|
|
var curleft = 0;
|
||
|
|
if(obj.offsetParent)
|
||
|
|
while(1)
|
||
|
|
{
|
||
|
|
curleft += obj.offsetLeft;
|
||
|
|
if(!obj.offsetParent)
|
||
|
|
break;
|
||
|
|
obj = obj.offsetParent;
|
||
|
|
}
|
||
|
|
else if(obj.x)
|
||
|
|
curleft += obj.x;
|
||
|
|
return curleft;
|
||
|
|
//return getPos(obj).x;
|
||
|
|
}
|
||
|
|
|
||
|
|
function findPosY(obj)
|
||
|
|
{
|
||
|
|
var curtop = 0;
|
||
|
|
if(obj.offsetParent)
|
||
|
|
while(1)
|
||
|
|
{
|
||
|
|
curtop += obj.offsetTop;
|
||
|
|
if(!obj.offsetParent)
|
||
|
|
break;
|
||
|
|
obj = obj.offsetParent;
|
||
|
|
}
|
||
|
|
else if(obj.y)
|
||
|
|
curtop += obj.y;
|
||
|
|
return curtop;
|
||
|
|
//return getPos(obj).y;
|
||
|
|
}
|
||
|
|
function showdiv(id,div,minusy,minusx)
|
||
|
|
{
|
||
|
|
document.getElementById(div).style.display="inline";
|
||
|
|
posy=findPosY(document.getElementById(id))-minusy;
|
||
|
|
posx=findPosX(document.getElementById(id))-minusx;
|
||
|
|
moveDiv(document.getElementById(div),posy,posx);
|
||
|
|
}
|
||
|
|
function hidediv(div)
|
||
|
|
{
|
||
|
|
document.getElementById(div).style.display="none";
|
||
|
|
}
|
||
|
|
function showprice(id,price,purchase_price,margin,order_by,sorder)
|
||
|
|
{
|
||
|
|
document.getElementById('price').value=price;
|
||
|
|
document.getElementById('purchase_price').value=purchase_price;
|
||
|
|
document.getElementById('margin').value=margin;
|
||
|
|
document.getElementById('product_id').value=id;
|
||
|
|
document.getElementById('order_by').value=order_by;
|
||
|
|
document.getElementById('sorder').value=sorder;
|
||
|
|
document.getElementById('price-block').style.display="block";
|
||
|
|
}
|
||
|
|
function getPrice(id,type)
|
||
|
|
{
|
||
|
|
var purchase_price=document.getElementById('purchase_price_'+id).value;
|
||
|
|
var margin_rate=document.getElementById('margin_rate_'+id).value;
|
||
|
|
var list_price;
|
||
|
|
|
||
|
|
list_price=parseFloat(purchase_price)/(1-parseFloat(margin_rate)/100);
|
||
|
|
|
||
|
|
if(!isNaN(list_price))document.getElementById('list_price_'+id).value=roundNumber(list_price,2);
|
||
|
|
|
||
|
|
}
|
||
|
|
function getPricePricebook()
|
||
|
|
{
|
||
|
|
var purchase_price=document.getElementById('purchase_price').value;
|
||
|
|
var margin_rate=document.getElementById('margin').value;
|
||
|
|
var list_price;
|
||
|
|
|
||
|
|
list_price=parseFloat(purchase_price)/(1-parseFloat(margin_rate)/100);
|
||
|
|
|
||
|
|
if(!isNaN(list_price))document.getElementById('price').value=roundNumber(list_price,2);
|
||
|
|
|
||
|
|
}
|
||
|
|
function CurrencyFormatted(amount)
|
||
|
|
{
|
||
|
|
var i = parseFloat(amount);
|
||
|
|
if(isNaN(i)) { i = 0.00; }
|
||
|
|
var minus = '';
|
||
|
|
if(i < 0) { minus = '-'; }
|
||
|
|
i = Math.abs(i);
|
||
|
|
i = parseInt((i + .005) * 100);
|
||
|
|
i = i / 100;
|
||
|
|
s = new String(i);
|
||
|
|
if(s.indexOf('.') < 0) { s += '.00'; }
|
||
|
|
if(s.indexOf('.') == (s.length - 2)) { s += '0'; }
|
||
|
|
s = minus + s;
|
||
|
|
return s;
|
||
|
|
}
|
||
|
|
function roundN(rnum,rlength)
|
||
|
|
{
|
||
|
|
var newnumber = Math.round(rnum*Math.pow(10,rlength))/Math.pow(10,rlength);
|
||
|
|
return newnumber;
|
||
|
|
}
|
||
|
|
function roundNumber(num, dec)
|
||
|
|
{
|
||
|
|
if(!isNaN(num))return CurrencyFormatted(roundN(parseFloat(num),dec));
|
||
|
|
else return "";
|
||
|
|
}
|
||
|
|
function ShowHideBlock(id)
|
||
|
|
{
|
||
|
|
if(document.getElementById(id).style.display=="block")
|
||
|
|
{
|
||
|
|
document.getElementById(id).style.display="none"
|
||
|
|
}
|
||
|
|
else
|
||
|
|
{
|
||
|
|
document.getElementById(id).style.display="block"
|
||
|
|
}
|
||
|
|
}
|