<?php
include_once "inc/getBasic.inc.php";
include_once "inc/getData.inc.php";
include_once "inc/postJson.inc.php";
$_REQUEST['code']=$_REQUEST['code']?$_REQUEST['code']:'sh';
$_REQUEST['hsgt']=$_REQUEST['hsgt']?$_REQUEST['hsgt']:'north_money';
$_REQUEST['stacked']=$_REQUEST['stacked']?$_REQUEST['stacked']:'1';
$_REQUEST['t_start']=$_REQUEST['t_start']?$_REQUEST['t_start']:'2015-06-01';
$_REQUEST['t_end']=$_REQUEST['t_end']?$_REQUEST['t_end']:date('Y-m-d');
$title="股指VS沪深港通资金流向";

$unit = '亿元';   # Without a unit on PE
$data=getIndexData(codetocode($_REQUEST['code']),date('Ymd',strtotime($_REQUEST['t_start'])),date('Ymd',strtotime($_REQUEST['t_end'])));
$data2 = getMoneyFlowData($_REQUEST['hsgt'], date('Ymd',strtotime($_REQUEST['t_start'])),date('Ymd',strtotime($_REQUEST['t_end'])), $_REQUEST['stacked']);

#var_dump($data2['data']);
$subtext_ext = "Max: ".$data2['data_max'];
$subtext_ext .= ", Min: ".$data2['data_min'];
$subtext_ext .= ", Average: ".$data2['data_avg'];
$subtext_ext .= ", Recent: ".$data2['data_last'];
$legend=array(codeToName($_REQUEST['code']),hsgtConv($_REQUEST['hsgt']));
include_once "html/head.php";
?>
<form name="main" id="main" method="get">
    <div style="width:100%;text-align:center">
        指数代码:
        <select name='code' id='code'>
            <option value='sh'>上证指数</option>
            <option value='sz'>深圳成指</option>
            <option value='zx'>中小板指</option>
            <option value='cy'>创业板指</option>
        </select>&nbsp;
        资金选择：
        <select name="hsgt" id="hsgt">
            <option value="ggt_ss">港股通（上海）</option>
            <option value="ggt_sz">港股通（深圳）</option>
            <option value="hgt">沪股通</option>
            <option value="sgt">深股通</option>
            <option value="north_money">北向资金</option>
            <option value="south_money">南向资金</option>
        </select>
        数据累积：
        <select name="stacked" id="stacked">
            <option value="-1">每日值</option>
            <option value="1">累积值</option>
        </select>
        <script>
            $("#code").val('<?=$_REQUEST['code']?>');
            $("#hsgt").val('<?=$_REQUEST['hsgt']?>');
            $("#stacked").val('<?=$_REQUEST['stacked']?>');
        </script>
开始时间: <input type='date' name='t_start' id='t_start' width='30px' value='<?=$_REQUEST['t_start']?>' >
结束时间: <input type='date' name='t_end' id='t_end' width='30px' value='<?=$_REQUEST['t_end']?>' >
<input type='submit' value="给我查!">
<div >&nbsp;</div>

</div> </form>
<div >&nbsp;</div>
<div id="container" style="margin:0 auto;height: 400px;width: 1000px"></div>
<script type="text/javascript">
    var data1 = <?php echo json_encode($data['data']); ?>;
    var data2 =<?php echo json_encode($data2['data']); ?>;
    var legend = <?php echo json_encode($legend);?>;
    var unit ='<?php echo $unit; ?>';
    var headtxt = '<?php echo codeToName($_REQUEST['code']).'VS'.hsgtConv($_REQUEST['hsgt']); ?>';
    var subtxt = '<?php echo $subtext_ext; ?>';
</script>
<script type="text/javascript" src="js/chartmoneyflow.js?version=3.141"></script>
<?php include_once "html/footer.php"; ?>

