root/c3crm/sugarcrm/trunk/echoModuleFields.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/util.php');
//require_once('modules/ACL/ACLController.php');
//require_once('modules/Campaigns/utils.php');

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

$db = & PearDatabase::getInstance();
/*
$query = "select * from tablereportmodules";
$res = $db->query($query);

$row = $db->fetchByAssoc($res);

$redirect_URL = $row['id'];
echo $redirect_URL;
*/
echo echoTabAndFieldsList2($db);

function echoTabAndFieldsList2($db)
{
	$shtml = "";
	$shtml .= "<response>";
	$query = "select * from tables_list";
	if (isset($_REQUEST["tablestr"])){
	  $query .= " where name in (".$_REQUEST["tablestr"].")";
	}
	//echo $query;
	$result = $db->query($query);

	//$row = $db->fetchByAssoc($res);
	while($val = $db->fetchByAssoc($result,-1,false))
	{
		$shtml .= "<table>";
		$tablenameView = "";
		if (!isset($val['zh_comment'])){
		  $tablenameView .= $val['name'];
		}
		else {
		  $tablenameView .=$val['zh_comment'];
		}		
		//foreach (array_values($val) as $value)
		//{
			//$shtml .= $value";
		//}
		$shtml .= "<tablename>";
		//$shtml .= $val['name'];
		$shtml .= $tablenameView;
		$shtml .= "</tablename>";
		$shtml .= "<fields>";
		$shtml .= getAllFieldsByTableID($db,$val['name'],$tablenameView);
		$shtml .= "</fields>";
		$shtml .= "</table>";
	}
	//return $content;
	$shtml .= "</response>";
	return $shtml;
}
function getAllFieldsByTableID($db,$tableName,$tableZh_comment)
{
	$shtml = "";
	$query = "select * from tablefields where tableid='$tableName'";
	//echo $query;
	$resultFields = $db->query($query);

	//$row = $db->fetchByAssoc($res);
	while($val = $db->fetchByAssoc($resultFields,-1,false))
	{
		$shtml .= "<field>";
		$shtml .= "<key>".$tableName.".".$val['name']."</key>";
		$shtml .= "<value>".$tableZh_comment.".";
		//$shtml .= $tableName.".".$val['name'];
		if (!isset($val['zh_comment'])){
		  $shtml .= $val['name'];
		}
		else {
		  $shtml .=$val['zh_comment'];
		}
		$shtml .= "</value></field>";
	}
	//return $content;
	return $shtml;
}

?>
Note: See TracBrowser for help on using the browser.