root/c3crm/sugarcrm/trunk/echoFields.php

Revision 1059 (by hsr, 04/03/06 17:52:33)

report update

<?php header("Content-type: text/xml; charset:GBK"); ?>
<?php
echo "<?xml version=\"1.0\" encoding=\"GB2312\"?>";

 $GLOBALS['sugarEntry'] = true;
include_once('config.php');
require_once('log4php/LoggerManager.php');
require_once('include/database/PearDatabase.php');
//require_once('modules/Campaigns/Campaign.php');
require_once('include/utils.php');
//require_once('rico/util2.php');
require_once("gb2utf8/class.Chinese.php");
//require_once('modules/ACL/ACLController.php');
//require_once('modules/Campaigns/utils.php');

$GLOBALS['log'] = LoggerManager::getLogger('Report Designer');

$db = & PearDatabase::getInstance();

echo echoAllFields($db);

function echoAllFields($db)
{
	//$chineseArray = array();
	$shtml = "";
	$shtml .= "<response>";
	$query = "select a.name tname,a.zh_comment tzh_comment,b.name,b.zh_comment from tables_list a,tablefields b where a.name=b.tableid ";
	if (isset ($_REQUEST['tab'])){
	  $query .= " and b.tableid='".$_REQUEST['tab']."' ";
	}
	$result = $db->query($query);

	//$row = $db->fetchByAssoc($res);
	
	while($val = $db->fetchByAssoc($result,-1,false))
	{
		$shtml .= "<field>";
		
		$tablenameView = "";
		if (!isset($val['tzh_comment'])){
		  $tablenameView .= $val['tname'];
		}
		else {
		  $tablenameView .=$val['tzh_comment'];
		}
		
		//foreach (array_values($val) as $value)
		//{
			//$shtml .= $value";
		//}
		$shtml .= "<key>".$val['tname'].".";
		//$chineseArray[] = $val['zh_comment'];
		if (!isset($val['name'])){
		  $shtml .= "-";
		}
		else {
		  $shtml .=$val['name'];
		}
		
		$shtml .= "</key>";
		$shtml .= "<value>";
		$shtml .= $tablenameView.".";
		//$shtml .= $val['zh_comment'];
		if (!isset($val['zh_comment'])){
		  $shtml .= $val['name'];
		}
		else {
		  $shtml .=$val['zh_comment'];
		}
		$shtml .= "</value>";
		$shtml .= "</field>";
	}
	//return $content;
	$shtml .= "</response>";
	return $shtml;
}
?>
Note: See TracBrowser for help on using the browser.