Hello Everyone,
I am having issues trying to display a grid on my page. I am not sure what I am doing wrong. I know the code is not very clean and efficient, I am just learning php and dojo. I want to display 2 graphs on a page and a grid that I had created before. The two graphs are working just fine. So I just added the grid code to this new dashboard display. See code attached:
<!DOCTYPE html>
<html >
<head>
<meta http-equiv="Content-Type" content="text/html" charset="UTF-8">
<body class="Wetland">
<center><img src="./images/lacrn.jpg"></center>
<center
<?php
$studynum = $_GET['studynum'];
$datestamp = date("l, F d, Y H:i" ,time());
$datestampnotime = date("l, F d, Y");
echo "<center><h1>US-LA CRN OpenClinica Dashboard</h1></center>";
echo "<center><h2>Data for Study: $studynum</h2></center>";
echo "<center><h4>Data Current as of: $datestampnotime</h4></center>";
//connect to database
$db = pg_connect('host=localhost dbname=dash_xc user=postgres password=postgres') or die('Sorry, could not connect to database server');
//total number of participants
$query1 = "select ar from data_review.dash_pivot_metadata m, data_review.dash_pivot_history d
where d.date_imported = '$studynum' and m.sequences=d.sequences and d.sequences in (3)";
//number of participants in neoadjuvant chemoterapy
$query2 = "select ar from data_review.dash_pivot_metadata m, data_review.dash_pivot_history d
where d.date_imported = '$studynum' and m.sequences=d.sequences and d.sequences in (4)";
//number of participants in surgery
$query3 = "select ar from data_review.dash_pivot_metadata m, data_review.dash_pivot_history d
where d.date_imported = '$studynum' and m.sequences=d.sequences and d.sequences in (5)";
//number of participants off study
$query4 = "select ar from data_review.dash_pivot_metadata m, data_review.dash_pivot_history d
where d.date_imported = '$studynum' and m.sequences=d.sequences and d.sequences in (33)";
//number of participants expected
$query5 = "select ar from data_review.dash_pivot_metadata m, data_review.dash_pivot_history d
where d.date_imported = '$studynum' and m.sequences=d.sequences and d.sequences in (7)";
//number of participants unassigned
$query6="select ar from data_review.dash_pivot_metadata m, data_review.dash_pivot_history d
where d.date_imported = '$studynum' and m.sequences=d.sequences and d.sequences in (6)";
$result1 = pg_query($query1) or die ('Could not find total');
$res1= pg_fetch_array($result1);
$totalp = $res1[0];
//$totalp=json_encode($totalp);
//echo ($totalp);
$result2 =pg_query($query2) or die ('Could not find neo chemoterapy');
$res2 = pg_fetch_array($result2);
$chemop = $res2[0];
//$chemop= json_encode($chemop);
$result3 = pg_query($query3) or die ('Could not find surgery');
$res3 = pg_fetch_array($result3);
$surgeryp = $res3[0];
//$surgeryp = json_encode($surgeryp);
$result4 = pg_query($query4) or die ('Could not find off study');
$res4 = pg_fetch_array($result4);
$offp = $res4[0];
//$offp = json_encode($offp);
//print_r($offp);
$result5 = pg_query($query5) or die ('Could not find expected');
$res5 = pg_fetch_array($result5);
$expectp = $res5[0];
//$expectp = json_encode($expectp);
//print_r($expectp);
$result6 = pg_query($query6) or die ('Could not find unassigned');
$res6 = pg_fetch_array($result6);
$unassignp = $res6[0];
//$unassignp= json_encode($unassignp);
//print_r($unassignp);
?>
<link rel="stylesheet" type="text/css"
href="./dijit/themes/claro/claro.css" />
<link rel="stylesheet" type="text/css"
href="./dojox/grid/resources/Grid.css" />
<link rel="stylesheet" type="text/css"
href="./dojox/grid/resources/claroGrid.css" />
<script>dojoConfig = {parseOnLoad: true}</script>
<script src="//ajax.googleapis.com/ajax/libs/dojo/1.8.1/dojo/dojo.js"
data-dojo-config="async: true"></script>
<script type="text/javascript"
src="./dojo/dojo.js" charset="utf-8"
djConfig="parseOnLoad:true,locale:'en-us',extraLocale: ['es-es','pt-br']"></script>
<script type="text/javascript">
dojo.require("dojox.grid.DataGrid");
dojo.require("dojo.data.ItemFileReadStore");
</script>
<?php
// $studynum = $_GET['studynum'].'%';
if (empty($studynum))
$studynum = "";
else
$studynum = $_GET['studynum'];
?>
<script type="text/javascript">
dojo.ready(function() {
var query99 = {
items: [
<?php require_once 'c:/webroot/lacrndb3.php';
fquery99($studynum); ?>
]
};
var dataStore =
new dojo.data.ItemFileReadStore(
{ data:query99}
);
var grid = dijit.byId("query99");
grid.setStore(dataStore);
});
</script>
<script>
require([
// Require the basic chart class
"dojox/charting/Chart",
// Require the theme of our choosing
"dojox/charting/themes/MiamiNice",
// Charting plugins:
// We want to plot Columns
"dojox/charting/plot2d/Columns",
// We want to plot StackedColumns
"dojox/charting/plot2d/StackedColumns",
// We want to use Markers
"dojox/charting/plot2d/Markers",
// We'll use default x/y axes
"dojox/charting/axis2d/Default",
//we'll use Legend
"dojox/charting/widget/SelectableLegend",
// Wait until the DOM is ready
"dojo/domReady!"
],
function(Chart, theme) {
// Define the data
var total= <?php print_r ($totalp); ?>;
//alert(total);
var chemo = <?php echo ($chemop); ?>;
//alert(chemo);
var surgery = <?php echo ($surgeryp); ?>;
//alert(surgery);
var offstudy = <?php echo ($offp); ?>;
//alert(offstudy);
var expected = <?php echo ($expectp); ?>;
//alert(expected);
var unassigned = <?php echo ($unassignp); ?>;
//alert(unassigned);
// Create the chart within it's "holding" node
var chart = new Chart("chartNode");
var chart2 = new Chart("chartNode2");
// Set the theme
chart.setTheme(theme);
chart2.setTheme(theme);
// Add the only/default plot
chart.addPlot("default", {
type: "Columns",
markers: true,
shadows: {dx:2, dy:2, dw:2},
gap: 2
});
chart2.addPlot("default", {
type: "Columns",
markers: true,
shadows: {dx:2, dy:2, dw:2},
gap: 2
});
// Add axes
chart.addAxis("x", {title:"Arms", titleOrientation: "away", minorLabels: false, labels:[{value:0, text:""}, {value:1, text:"NeoAdj Chemo"}, {value:2, text:"Surgery"},{value:3, text: "Unassigned"}, {value:4, text:"Off Study"}, {value:5, text:"Total (Actual)"}, {value:6, text:"Total (Expected)"}], rotation:-45});
chart.addAxis("y", {title: "Participants", vertical: true, includeZero: true, ticks:true, majorLabels:true, minorLabels: false });
chart2.addAxis("x", {title:"Arms", titleOrientation: "away", minorLabels: false, labels:[{value:0, text:""}, {value:1, text:"NeoAdj Chemo"}, {value:2, text:"Surgery"},{value:3, text: "Unassigned"}, {value:4, text:"Off Study"}, {value:5, text:"Total (Actual)"}, {value:6, text:"Total (Expected)"}], rotation:-90});
chart2.addAxis("y", {title: "CRFs", vertical: true, includeZero: true, ticks:true, majorLabels:true, minorLabels: false });
// Add the series of data for graph1-Participants
chart.addSeries("NeoAdj Chemo", [chemo,0,0,0,0,0], {stroke:"#FF0099", fill:"#FEA9F3"});
chart.addSeries("Surgery", [0,surgery,0,0,0,0], {stroke:"#FFFF00", fill:"#FFFF33"});
chart.addSeries("Unassigned", [0,0,unassigned,0,0,0], {stroke:"#FF0000", fill:"#CC6600"});
chart.addSeries("Off-Study", [0,0,0,offstudy,0,0], {stroke: "black", fill:"gray"});
chart.addSeries("Total (Actual)",[0,0,0,0,total,0], {stroke:"black", fill:"black"});
chart.addSeries("Total (Expected)", [0,0,0,0,0,expected], {stroke: "black", fill:"blue"});
//Add the series of data for graph2-CRFs
chart2.addSeries("NeoAdj Chemo", [chemo,0,0,0,0,0], {stroke:"#FF0099", fill:"#FEA9F3"});
chart2.addSeries("Surgery ", [0,surgery,0,0,0,0], {stroke:"#FFFF00", fill:"#FFFF33"});
chart2.addSeries("Unassigned ", [0,0,unassigned,0,0,0], {stroke:"#FF0000", fill:"#CC6600"});
chart2.addSeries("Off-Study ", [0,0,0,offstudy,0,0], {stroke: "black", fill:"gray"});
chart2.addSeries("Total(Actual)",[0,0,0,0,total,0], {stroke:"black", fill:"black"});
chart2.addSeries("Total(Expected)", [0,0,0,0,0,expected], {stroke: "black", fill:"blue"});
// Render the chart!
chart.render();
chart2.render();
var legend1 = new dojox.charting.widget.SelectableLegend({chart: chart, horizontal:true}, "legend1");
var legend2 = new dojox.charting.widget.SelectableLegend({chart: chart2, horizontal:true}, "legend2");
});
</script>
<table BORDER="2" BORDERCOLOR="#336699" CELLPADDING="2" CELLSPACING="2" WIDTH="100%">
<tr>
<td>
<div id="chartNode" style="float:left">
</div>
<div id="legend1"></div>
</td>
<td>
<div id="chartNode2" style="float:left">
</div>
<div id="legend2"></div>
</td>
</tr>
</table>
<center>
<table border ="2" width="100%">
<tr>
<td> "Testing"</td>
</tr>
</table>
</center>
<center>
<FORM name="lacrn1" action="lacrnv3.php" method="get">
<SELECT name="studynum">
<?php require_once 'c:/webroot/lacrndb3.php';
studylist();
?>
</SELECT>
<INPUT TYPE="submit" value="Submit">
</FORM>
<form><input type="button" value="Down Load the CSV File" onClick="window.location.href='http://lacrn-trn.ccsainc.com:8000/hello.php'"></form>
<table border="0" cellspacing="20px">
<tr><td>
<style>
p {text-indent:30px;}
</style>
<br><h3><!--Subjects Enrolled to Unassigned Arm--></h3>
<div style="width: 1150px; height: 768px">
<table id="query99" dojoType="dojox.grid.DataGrid" escapeHTMLInData="false" canSort="function(){return false}">
<thead>
<tr>
<th field="Parameter" width="550px">Parameter</th>
<th field="ar" width="80"><center><a href="https://lacrn-ar.ccsainc.com:8801/dash_ar.php">AR</a></center></th>
<th field="br" width="80"><center><a href="https://lacrn-br.ccsainc.com:8801/dash.php">BR</center></th>
<th field="cl" width="80"><center><a href="https://lacrn-cl.ccsainc.com:8801/dash.php">CL</center></th>
<th field="mxjal" width="80"><center><a href="https://lacrn-mx-jal.ccsainc.com:8801/dash.php">MX-JAL</center></th>
<th field="mxson" width="80"><center><a href="https://lacrn-mx-son.ccsainc.com:8801/dash.php">MX-SON</center></th>
<th field="uy" width="80"><center><a href="https://lacrn-uy.ccsainc.com:8801/dash.php">UY</center></th>
<th field="total" width="100"><center>TOTAL</center></th>
</tr>
</thead>
</table>
</div>
</table>
</center>
<script type="text/javascript">
dojo.require("dojox.grid.DataGrid");
dojo.require("dojo.data.ItemFileReadStore");
</script>
<?php
// $studynum = $_GET['studynum'].'%';
if (empty($studynum))
$studynum = "";
else
$studynum = $_GET['studynum'];
?>
<script type="text/javascript">
dojo.ready(function() {
var query99 = {
items: [
<?php require_once 'c:/webroot/lacrndb3.php';
fquery99($studynum); ?>
]
};
var dataStore =
new dojo.data.ItemFileReadStore(
{ data:query99}
);
var grid = dijit.byId("query99");
grid.setStore(dataStore);
});
</script>
</body>
</html>