Universal Data Exporter PHP Support Product Page

This topic is locked
This topic was archived by Teodor Kuduschiev on 6/1/2022 1:22:35 PM

Fatal error: Cannot access empty property in C:\New_Dev\ScriptLibrary\JSON.php on line 678

Reported 30 Jul 2009 22:52:54
4
have this problem
30 Jul 2009 22:52:54 brad baker posted:

<?php
// Initialize the Alternate Color counter
$ac_sw1 = 0;
?><?php require_once('../../../Connections/erplxf.php'); ?><?php
if (!function_exists("GetSQLValueString")) {
function GetSQLValueString($theValue, $theType, $theDefinedValue = "", $theNotDefinedValue = "") 
{
  $theValue = get_magic_quotes_gpc() ? stripslashes($theValue) : $theValue;

  $theValue = function_exists("mysql_real_escape_string") ? mysql_real_escape_string($theValue) : mysql_escape_string($theValue);

  switch ($theType) {
    case "text":
      $theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";
      break;    
    case "long":
    case "int":
      $theValue = ($theValue != "") ? intval($theValue) : "NULL";
      break;
    case "double":
      $theValue = ($theValue != "") ? "'" . doubleval($theValue) . "'" : "NULL";
      break;
    case "date":
      $theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";
      break;
    case "defined":
      $theValue = ($theValue != "") ? $theDefinedValue : $theNotDefinedValue;
      break;
  }
  return $theValue;
}
}

$comp_contract_sql = "-1";
if (isset($_GET['comp'])) {
  $comp_contract_sql = $_GET['comp'];
}
$cust_contract_sql = "-1";
if (isset($_GET['cust'])) {
  $cust_contract_sql = $_GET['cust'];
}
mysql_select_db($database_erplxf, $erplxf);
$query_contract_sql = sprintf("SELECT sum(ICOND) as CONDCODE, a.ITEM, a.IDESC, a.IDSCE, eix.IXITEM, a.TTL as TTL, sum(a.MTL) as MTL, sum(a.LBR) as LBR, sum(a.OVH) as OVHL, silv01.AVGSP as CUSTAVGP, silv02.AVGSP as PNAVGP,silv01.PRVYRSOLD as PRVYR, sum(LISTED) as LISTED,  sum(PVATLIST) as PVATLIST, sum(CTNQTY) as CTNQTY, sum(LISTPRICE) as LISTPRICE, sum(LISTPRIMINDISC) as LISTPRIMINDISC, sum(PVATLISTPRI) as PVATLISTPRI FROM( 
SELECT iim.ICOND, espv01.ITEM, espv01.CUSTOMER, iim.IDESC, cmf.CFTLVL + cmf.CFPLVL as TTL, 0 as MTL, 0 as LBR, 0 as OVH, espv01.PFCT1 as LISTED, ((espv01.PFCT1 - (cmf.CFTLVL + cmf.CFPLVL))/espv01.PFCT1)*100  as PVATLIST, IMCQTY as CTNQTY, lp.PFCT1 as LISTPRICE, lp.PFCT1*.58 as LISTPRIMINDISC, (((lp.PFCT1*.58) - (cmf.CFTLVL + cmf.CFPLVL))/(lp.PFCT1*.58))*100  as PVATLISTPRI, iim.IDSCE
FROM espv01 
Inner Join cmf ON espv01.ITEM = cmf.CFPROD AND cmf.CFCSET =  '2' AND cmf.CFCBKT =  '0' AND cmf.CFFAC=%s*10 AND espv01.SPID =  'SP' AND espv01.PCOMP=%s 
Inner Join iim ON espv01.ITEM = iim.IPROD 
Left Join espv01 lp on lp.ITEM = espv01.ITEM and lp.PMETH = 0 and lp.SPID='SP' and lp.PCOMP=1 
WHERE espv01.CUSTOMER =  %s and espv01.PMETH=1 and espv01.PCOMP=1 and espv01.SPID='SP'  
UNION 
SELECT 0 as ICOND, espv01.ITEM, espv01.CUSTOMER, iim.IDESC, 0 as TTL, cmf.CFTLVL + cmf.CFPLVL as MTL, 0 as LBR, 0 as OVH, 0 as LISTED, 0 as PVATLIST, 0 as CTNQTY, 0 as LISTPRICE, 0 as LISTPRIMINDISC, 0  as PVATLISTPRI , iim.IDSCE
FROM espv01 
Inner Join cmf ON espv01.ITEM = cmf.CFPROD AND cmf.CFCSET =  '2' AND cmf.CFCBKT =  '1' AND cmf.CFFAC=%s*10 AND espv01.SPID =  'SP' AND espv01.PCOMP=%s 
Inner Join iim ON espv01.ITEM = iim.IPROD 
WHERE espv01.CUSTOMER =  %s and espv01.PMETH=1 and espv01.PCOMP=1 and espv01.SPID='SP'  
UNION 
SELECT 0 as ICOND, espv01.ITEM, espv01.CUSTOMER, iim.IDESC, 0 as TTL, 0 as MTL, cmf.CFTLVL + cmf.CFPLVL as LBR, 0 as OVH, 0 as LISTED, 0 as PVATLIST, 0 as CTNQTY, 0 as LISTPRICE, 0 as LISTPRIMINDISC, 0  as PVATLISTPRI, iim.IDSCE
FROM espv01 
Inner Join cmf ON espv01.ITEM = cmf.CFPROD AND cmf.CFCSET =  '2' AND cmf.CFCBKT =  '2' AND cmf.CFFAC=%s*10 AND espv01.SPID =  'SP' AND espv01.PCOMP=%s 
Inner Join iim ON espv01.ITEM = iim.IPROD 
WHERE espv01.CUSTOMER =  %s and espv01.PMETH=1 and espv01.PCOMP=1 and espv01.SPID='SP'  
UNION 
SELECT 0 as ICOND, espv01.ITEM, espv01.CUSTOMER, iim.IDESC, 0 as TTL, 0 as MTL, 0 as LBR, cmf.CFTLVL + cmf.CFPLVL as OVH, 0 as LISTED, 0 as PVATLIST, 0 as CTNQTY, 0 as LISTPRICE, 0 as LISTPRIMINDISC, 0  as PVATLISTPRI, iim.IDSCE
FROM espv01 
Inner Join cmf ON espv01.ITEM = cmf.CFPROD AND cmf.CFCSET =  '2' AND cmf.CFCBKT =  '3' AND cmf.CFFAC=%s*10 AND espv01.SPID =  'SP' AND espv01.PCOMP=%s 
Inner Join iim ON espv01.ITEM = iim.IPROD 
WHERE espv01.CUSTOMER =  %s and espv01.PMETH=1 and espv01.PCOMP=1 and espv01.SPID='SP'  ) a 
LEFT JOIN silv01 on a.ITEM=silv01.ILPROD and a.CUSTOMER=silv01.ILCUST 
LEFT JOIN silv02 on a.ITEM=silv02.ILPROD and silv02.ILCOMP=1 
LEFT JOIN eix on a.ITEM = eix.IXPROD and a.CUSTOMER = eix.IXCUST
GROUP BY a.ITEM 
ORDER BY a.ITEM", GetSQLValueString($comp_contract_sql, "int"),GetSQLValueString($comp_contract_sql, "int"),GetSQLValueString($cust_contract_sql, "int"),GetSQLValueString($comp_contract_sql, "int"),GetSQLValueString($comp_contract_sql, "int"),GetSQLValueString($cust_contract_sql, "int"),GetSQLValueString($comp_contract_sql, "int"),GetSQLValueString($comp_contract_sql, "int"),GetSQLValueString($cust_contract_sql, "int"),GetSQLValueString($comp_contract_sql, "int"),GetSQLValueString($comp_contract_sql, "int"),GetSQLValueString($cust_contract_sql, "int"));
$contract_sql = mysql_query($query_contract_sql, $erplxf) or die(mysql_error());
$row_contract_sql = mysql_fetch_assoc($contract_sql);
$totalRows_contract_sql = mysql_num_rows($contract_sql);
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Untitled Document</title>
<script src="../../../ScriptLibrary/json2.js" type="text/javascript"></script>
<script src="../../../ScriptLibrary/gridExport.js" type="text/javascript"></script>
<script>
function updateValues()
{
  var tbl = document.getElementById('contract');
  var lastRow = tbl.rows.length -1;
  var cost=0;
for (i=1;i<=lastRow;i++)
{

document.contractpricing["perch1_"+i].value=(((parseFloat(document.contractpricing["PERCHG1"].value)/100)+1)*parseFloat(document.contractpricing["curcontprice_"+i].value));
document.getElementById("perch1txt_"+i).innerHTML=((parseFloat(parseFloat(document.contractpricing["PERCHG1"].value)/100)+1)*parseFloat(document.contractpricing["curcontprice_"+i].value)).toFixed(2);

document.contractpricing["perch2_"+i].value=(((parseFloat(document.contractpricing["PERCHG2"].value)/100)+1)*parseFloat(document.contractpricing["curcontprice_"+i].value));
document.getElementById("perch2txt_"+i).innerHTML=((parseFloat(parseFloat(document.contractpricing["PERCHG2"].value)/100)+1)*parseFloat(document.contractpricing["curcontprice_"+i].value)).toFixed(2);


document.contractpricing["pvch1_"+i].value=(parseFloat(document.contractpricing["ttl_"+i].value)/(1-(parseFloat(document.contractpricing["PVCHG1"].value)/100)));
document.getElementById("pvch1txt_"+i).innerHTML=(parseFloat(document.contractpricing["ttl_"+i].value)/(1-(parseFloat(document.contractpricing["PVCHG1"].value)/100))).toFixed(2);

document.contractpricing["pvch2_"+i].value=(parseFloat(document.contractpricing["ttl_"+i].value)/(1-(parseFloat(document.contractpricing["PVCHG2"].value)/100)));
document.getElementById("pvch2txt_"+i).innerHTML=(parseFloat(document.contractpricing["ttl_"+i].value)/(1-(parseFloat(document.contractpricing["PVCHG2"].value)/100))).toFixed(2);


document.getElementById("per1hdr").innerHTML=parseFloat(document.contractpricing["PERCHG1"].value) + '% Inc';
document.getElementById("per2hdr").innerHTML=parseFloat(document.contractpricing["PERCHG2"].value) + '% Inc';

document.getElementById("pv1hdr").innerHTML=parseFloat(document.contractpricing["PVCHG1"].value) + '% PV';
document.getElementById("pv2hdr").innerHTML=parseFloat(document.contractpricing["PVCHG2"].value) + '% PV';


cost += parseFloat(document.contractpricing["ttl_"+i].value)*parseFloat(document.contractpricing["qtyprvyr_"+i].value);
document.contractpricing["extcost"].value = cost;
}
}

function updatePV()
{
  var tbl = document.getElementById('contract');
  var lastRow = tbl.rows.length -1;
  var cost=0;
for (i=1;i<=lastRow;i++)
{

cost += parseFloat(document.contractpricing["newprc_"+i].value)*parseFloat(document.contractpricing["qtyprvyr_"+i].value);
document.contractpricing["extsale"].value = cost;
}
}

function generateJSON(tableID, exportType, action, styleArr) { //v 1.11
	var table = document.getElementById(tableID);
	var rowNodes = table.getElementsByTagName("tr");
	
	var toJSONTable = new Object();
	toJSONTable.page = 1;
	toJSONTable.total = rowNodes.length;
	var rowsArr = new Array();	
	var hiddenArr = new Array();	
	toJSONTable.colCount = 0;
	for (i = 0; i < rowNodes.length; i++)
	{	
		var maxCols = 0;
		var rowObj = new Object();
		rowObj.id = (i +1);	
		var cellNodes = rowNodes.item(i).getElementsByTagName("td");
		if (cellNodes.length > 0)
		{
			cellsArr = new Array();
			for (j = 0; j < cellNodes.length; j++)
			{
				if (isGrid(tableID))
				{
					if (cellNodes.item(j).style.display != "none")
					{
						hiddenArr[j] = false;
						maxCols++;	
						cellsArr.push(cellNodes.item(j).innerHTML);
					}
					else
					{
						hiddenArr[j] = true;
					}
				}
				else 
				{
					maxCols++;	
					cellsArr.push(cellNodes.item(j).innerHTML);
				}						
			}
			if (maxCols > toJSONTable.colCount)
			{
				toJSONTable.colCount = maxCols;
			}
			rowObj.cell = cellsArr;
			rowsArr.push(rowObj);
		}
	}
	toJSONTable.rows = rowsArr;	
	if (isGrid(tableID))
	{
		var heds =  $('#' + tableID).parent().siblings(".hDiv").get(0);
		var headerNodes = heds.getElementsByTagName("th");
		var heArray = new Array();
		for (i = 0; i < headerNodes.length; i++)
		{
			if (headerNodes.item(i).style.display != "none")
			{
				heArray.push(headerNodes.item(i).innerHTML);
			}			
		}
		toJSONTable.headers = heArray;		
	}
	else 
	{
		var headerNodes =  table.getElementsByTagName("th");	
		if (headerNodes.length > 0) 
		{
			var headerArr = new Array();
			for (i = 0; i < headerNodes.length; i++)
			{
				headerArr.push(headerNodes.item(i).innerHTML);
			}
			toJSONTable.headers = headerArr;			
		}
		else 
		{
			toJSONTable.headers = new Array();
		}
	}
	var myForm = document.createElement("form"); 
	var hidden = document.createElement("input"); 
	var hidden2 = document.createElement("input"); 
	var hidden3 = document.createElement("input"); 
	hidden.setAttribute('type', 'hidden'); 
	hidden.setAttribute('value', JSON.stringify(toJSONTable) ); 
	hidden.setAttribute('name', "JSONstring"); 
	hidden2.setAttribute('type', 'hidden'); 
	hidden2.setAttribute('value', exportType ); 
	hidden2.setAttribute('name', "exportType");
	hidden3.setAttribute('type', 'hidden'); 
	hidden3.setAttribute('value', JSON.stringify(styleArr) ); 
	hidden3.setAttribute('name', "markup"); 		
	myForm.appendChild(hidden);
	myForm.appendChild(hidden2);
	myForm.appendChild(hidden3);
	myForm.setAttribute('name','dynaForm'); 
	myForm.setAttribute('id','dynaForm'); 
	myForm.method = "POST"; 
	myForm.action = action; 
	myForm.target = "_self"; 
	document.body.appendChild(myForm);	
	myForm.submit(); 
}
</script>
</head>

<body onload="updateValues();">
<form id="contractpricing" name="contractpricing" method="post" action="">
<table width="100%" border="1" id="contract">
  <tr>
    <th scope="col"><div align="left">Con Code</div></th>
    <th scope="col"><div align="left">Item No</div></th>
    <th scope="col"><div align="left">Cust Item No</div></th>
    <th scope="col"><div align="left">Desc 1</div></th>
    <th scope="col"><div align="left">Desc 2</div></th>
    <th scope="col"><div align="left">MTL</div></th>
    <th scope="col"><div align="left">LBR</div></th>
    <th scope="col"><div align="left">OVH</div></th>
    <th scope="col"><div align="left">List Price</div></th>
    <th scope="col"><div align="left">List Min 42% Disc</div></th>
    <th scope="col"><div align="left">Current Price</div></th>
    <th scope="col"><div align="left">PV at Current</div></th>
    <th scope="col"><div align="left">Sold Prv Yr</div></th>
    <th scope="col"><div align="left">Cust Avg Buy Price</div></th>
    <th scope="col"><div align="left">PN Avg Buy Price</div></th>
    <th scope="col"><div align="left">Ctn Qty</div></th>
    <th scope="col"><pre id="per1hdr" align="left">$ by %</pre>
      <input name="PERCHG1" type="text" id="PERCHG1" size="3" value="1" onchange="updateValues();" /></th>
    <th scope="col"><pre id="per2hdr"  align="left">$ by %</pre>
      <input name="PERCHG2" type="text" id="PERCHG2" size="3" value="2" onchange="updateValues();" /></th>        
        <th scope="col"><pre id="pv1hdr" align="left">$ by PV</pre>
      <input name="PVCHG1" type="text" id="PVCHG1" size="3" value="40" onchange="updateValues();" /></th>
    <th scope="col"><pre id="pv2hdr"  align="left">$ by PV</pre>
      <input name="PVCHG2" type="text" id="PVCHG2" size="3" value="45" onchange="updateValues();" /></th>    
    <th scope="col"><div align="left">New Price</div></th>                     
  </tr>
<?php 
	$ctr=0; do { $ctr++;
?>	

  <tr bgcolor="<?php echo ($ac_sw1++%2==0)?"#FFFFFF":"#CCCCCC"; ?>" onmouseout="this.style.backgroundColor=''" onmouseover="this.style.backgroundColor='#FFFF00'">
    <td><div align="center"><input type="hidden" name="concode_<? echo $ctr;?>" value="<?php echo trim($row_contract_sql['CONDCODE']); ?>"/><?php echo trim($row_contract_sql['CONDCODE']); ?></div></td>    
    <td><input type="hidden" name="pn_<? echo $ctr;?>" value="<?php echo trim($row_contract_sql['ITEM']); ?>" /><?php echo '\''.trim($row_contract_sql['ITEM']); ?></td>
    <td><input type="hidden" name="cstpn_<? echo $ctr;?>" value="<?php echo trim($row_contract_sql['IXITEM']); ?>" /><?php echo '\''.trim($row_contract_sql['IXITEM']); ?></td>
    <td><input type="hidden" name="desc_<? echo $ctr;?>" value="<?php echo trim($row_contract_sql['IDESC']); ?>"/><?php echo trim($row_contract_sql['IDESC']); ?></td>
    <td><input type="hidden" name="desc2_<? echo $ctr;?>" value="<?php echo trim($row_contract_sql['IDSCE']); ?>"/><?php echo trim($row_contract_sql['IDSCE']); ?></td>
    <td><input type="hidden" name="ttl_<? echo $ctr;?>" value="<?php echo $row_contract_sql['TTL']; ?>"/><input type="hidden" name="mtl_<? echo $ctr;?>" value="<?php echo number_format($row_contract_sql['MTL'],2); ?>"/><?php echo number_format($row_contract_sql['MTL'],2); ?></td>
    <td><input type="hidden" name="lbr_<? echo $ctr;?>" value="<?php echo number_format($row_contract_sql['LBR'],2); ?>"/><?php echo number_format($row_contract_sql['LBR'],2); ?></td>
    <td><input type="hidden" name="ovh_<? echo $ctr;?>" value="<?php echo number_format($row_contract_sql['OVHL'],2); ?>"/><?php echo number_format($row_contract_sql['OVHL'],2); ?></td>
    <td><input type="hidden" name="listprice_<? echo $ctr;?>" value="<?php echo number_format($row_contract_sql['LISTPRICE'],2); ?>"/><?php echo number_format($row_contract_sql['LISTPRICE'],2); ?></td>
    <td><input type="hidden" name="listpricedisc_<? echo $ctr;?>" value="<?php echo number_format($row_contract_sql['LISTPRIMINDISC'],2); ?>"/><?php echo number_format($row_contract_sql['LISTPRIMINDISC'],2); ?></td>
    <td><input type="hidden" name="curcontprice_<? echo $ctr;?>" value="<?php echo $row_contract_sql['LISTED']; ?>"/><?php echo number_format($row_contract_sql['LISTED'],2); ?></td>
    <td><input type="hidden" name="pv@list_<? echo $ctr;?>" value="<?php echo number_format($row_contract_sql['PVATLIST'],2); ?>"/><?php echo number_format($row_contract_sql['PVATLIST'],2); ?></td>
    <td><input type="hidden" name="qtyprvyr_<? echo $ctr;?>" value="<?php if ($row_contract_sql['PRVYR']>0){ echo number_format($row_contract_sql['PRVYR'],0);} else {echo "1";} ?>"/><?php echo number_format($row_contract_sql['PRVYR'],0); ?></td>
    <td><input type="hidden" name="avgcustpay_<? echo $ctr;?>" value="<?php echo number_format($row_contract_sql['CUSTAVGP'],2); ?>"/><?php echo number_format($row_contract_sql['CUSTAVGP'],2); ?></td>
    <td><input type="hidden" name="avgpnpay_<? echo $ctr;?>" value="<?php echo number_format($row_contract_sql['PNAVGP'],2); ?>"/><?php echo number_format($row_contract_sql['PNAVGP'],2); ?></td>
    <td><input type="hidden" name="ctnqty_<? echo $ctr;?>" value="<?php echo number_format($row_contract_sql['CTNQTY'],0); ?>"/><?php echo number_format($row_contract_sql['CTNQTY'],0); ?></td>
 <td><input type="hidden" name="perch1_<? echo $ctr;?>" value="0"/><pre id="perch1txt_<? echo $ctr;?>"></pre></td>
 <td><input type="hidden" name="perch2_<? echo $ctr;?>" value="0"/><pre id="perch2txt_<? echo $ctr;?>"></pre></td>
 <td><input type="hidden" name="pvch1_<? echo $ctr;?>" value="0"/><pre id="pvch1txt_<? echo $ctr;?>"></pre></td>
 <td><input type="hidden" name="pvch2_<? echo $ctr;?>" value="0"/><pre id="pvch2txt_<? echo $ctr;?>"></pre></td>
 <td><input name="newprc_<? echo $ctr;?>" type="text" onchange="updatePV();" value="0" size="10" />&nbsp;</td>
<?php
       } while ($row_contract_sql = mysql_fetch_assoc($contract_sql)); 
?>
  </tr>
  <input type="hidden" name="ctr" value="<? echo $ctr;?>" />
</table>
  <input type="hidden" name="extcost" value="0" />
  <input type="hidden" name="extsale" value="0" />
</form>
<a href="#" onclick="generateJSON('contract','Excel','../../../ScriptLibrary/udeJSON.php',[true,'helvetica',12,'#FFFFFF','#000066',false,false,'helvetica',12,'#000000',false,false,'#66FFFF',0.5,'#000000',20,true,'output',false,,true,'#FFFFFF'])">Export to Xls</a>
</body>
</html>
<?php
mysql_free_result($contract_sql);
?>



Edited by - brad baker on 30 Jul 2009  22:54:20

Replies

Replied 31 Jul 2009 09:24:04
31 Jul 2009 09:24:04 Teodor Kuduschiev replied:
Could you please ZIP the file ../ScriptLibrary\JSON.php and send it to
Replied 10 Aug 2009 19:55:00
10 Aug 2009 19:55:00 brad baker replied:
any update?
Replied 11 Aug 2009 09:29:12
11 Aug 2009 09:29:12 Teodor Kuduschiev replied:
Hello Brad,
We are still working on the problem. I'll inform you as soon as we find out where is the problem.
Replied 24 Mar 2010 12:12:53
24 Mar 2010 12:12:53 Dan Ove Tuven replied:
Did you solve this? I've got the same message on linux/php 5.2.5.
Replied 25 Mar 2010 00:45:20
25 Mar 2010 00:45:20 Dan Ove Tuven replied:
Seems like new version 1.1.3 released today did the trick!
Thanks! []
Replied 25 Mar 2010 10:25:52
25 Mar 2010 10:25:52 Miroslav Zografski replied:
Hello Dan,

Thanks for the feedback,

Regards,
Replied 07 Aug 2014 02:50:36
07 Aug 2014 02:50:36 包 四維 replied:
hi everybody
I have this problem too
but I use the latest version 1.1.5

my remote side(Apache 2.4.9、PHP 5.3.28、MySQL 5.6.17)
www.littlebau.com/sample_new/index.html
you can click the butoon named:"pdf"、"csv"、"xls"、"xml"

and the error appear = >
Cannot access empty property in /home/littleb1/public_html/sample_new/ScriptLibrary/JSON.php on line 678
hot to solve or fix ? thanks~
This reply was removed on 6/1/2022 1:22:27 PM.
See the changelog

Reply to this topic