📄 cakeimg.php
字号:
<?php
function get_count( $FIELD, $FIELD_VALUE )
{
$COUNT = 0;
$connection = openconnection( );
$query = "select count(*) from HRMS,USER where USER.USER_ID=HRMS.USER_ID and {$FIELD}='{$FIELD_VALUE}'";
$cursor = exequery( $connection, $query );
if ( $ROW = mysql_fetch_array( $cursor ) )
{
$COUNT = $ROW[0];
}
return $COUNT;
}
function birthday_count( $AGE_START, $AGE_END )
{
if ( $AGE_START == "" && $AGE_END == "" )
{
$STR .= " and (BIRTHDAY='1900-01-01 00:00:00' or BIRTHDAY='0000-00-00 00:00:00')";
}
else
{
if ( $AGE_START != "" )
{
$STR .= " and DATE_FORMAT(BIRTHDAY,'%Y%m%d')<=DATE_SUB(DATE_FORMAT(CURRENT_DATE(),'%Y%m%d'),INTERVAL {$AGE_START} YEAR)";
}
if ( $AGE_END != "" )
{
$STR .= " and DATE_FORMAT(BIRTHDAY,'%Y%m%d')>DATE_SUB(DATE_FORMAT(CURRENT_DATE(),'%Y%m%d'),INTERVAL {$AGE_END}+1 YEAR)";
}
$STR .= " and BIRTHDAY!='1900-01-01 00:00:00' and BIRTHDAY!='0000-00-00 00:00:00'";
}
$COUNT = 0;
$connection = openconnection( );
$query = "select count(*) from HRMS,USER where USER.USER_ID=HRMS.USER_ID".$STR;
$cursor = exequery( $connection, $query );
if ( $ROW = mysql_fetch_array( $cursor ) )
{
$COUNT = $ROW[0];
}
return $COUNT;
}
include( "inc/conn.php" );
include( "inc/jpgraph/jpgraph.php" );
include( "inc/jpgraph/jpgraph_pie.php" );
include( "inc/jpgraph/jpgraph_pie3d.php" );
if ( $MODULE == 1 )
{
$datLst = array(
birthday_count( "", "25" ),
birthday_count( "26", "30" ),
birthday_count( "31", "35" ),
birthday_count( "36", "40" ),
birthday_count( "41", "45" ),
birthday_count( "46", "50" ),
birthday_count( "51", "55" ),
birthday_count( "56", "60" ),
birthday_count( "61", "" ),
birthday_count( "", "" )
);
$labLst = array( "25岁以下 (%d%%)", "26-30岁 (%d%%)", "31-35岁 (%d%%)", "36-40岁 (%d%%)", "41-45岁 (%d%%)", "46-50岁 (%d%%)", "51-55岁 (%d%%)", "56-60岁 (%d%%)", "60岁以上 (%d%%)", "未知 (%d%%)" );
$MODULENAME = "按年龄统计(共".array_sum( $datLst )."人)";
}
else if ( $MODULE == 2 )
{
$datLst = array(
get_count( "EDUCATION", "9" ),
get_count( "EDUCATION", "8" ),
get_count( "EDUCATION", "7" ),
get_count( "EDUCATION", "6" ),
get_count( "EDUCATION", "5" ),
get_count( "EDUCATION", "4" ),
get_count( "EDUCATION", "3" ),
get_count( "EDUCATION", "2" ),
get_count( "EDUCATION", "1" ),
get_count( "EDUCATION", "" )
);
$labLst = array( "博士后 (%d%%)", "博士 (%d%%)", "硕士 (%d%%)", "大本 (%d%%)", "大专 (%d%%)", "中专 (%d%%)", "高中 (%d%%)", "初中 (%d%%)", "小学 (%d%%)", "未知 (%d%%)" );
$MODULENAME = "按学历统计(共".array_sum( $datLst )."人)";
}
else if ( $MODULE == 3 )
{
$datLst = array(
get_count( "SEX", "0" ),
get_count( "SEX", "1" )
);
$labLst = array( "男 (%d%%)", "女 (%d%%)" );
$MODULENAME = "按性别统计(共".array_sum( $datLst )."人)";
}
else if ( $MODULE == 4 )
{
$datLst = array(
get_count( "POLITICS", "3" ),
get_count( "POLITICS", "4" ),
get_count( "POLITICS", "2" ),
get_count( "POLITICS", "1" ),
get_count( "POLITICS", "" )
);
$labLst = array( "党员 (%d%%)", "预备党员 (%d%%)", "团员 (%d%%)", "群众 (%d%%)", "未知 (%d%%)" );
$MODULENAME = "按政治面貌统计(共".array_sum( $datLst )."人)";
}
$graph = new piegraph( 500, 300, "auto" );
$graph->title->set( $MODULENAME );
$graph->title->setfont( FF_SIMSUN, FS_BOLD, 18 );
$graph->title->setcolor( "darkblue" );
$graph->legend->setfont( FF_SIMSUN, FS_NORMAL, 10 );
$p1 = new pieplot3d( $datLst );
$p1->settheme( "td" );
$p1->setcenter( 0.4 );
$p1->setangle( 60 );
$p1->setlabeltype( PIE_VALUE_ADJPER );
$p1->value->setfont( FF_SIMSUN, FS_NORMAL, 10 );
$p1->setlegends( $labLst );
$graph->add( $p1 );
$graph->stroke( );
echo "\r\n\r\n";
?>
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -