function save($check_notify = FALSE) { if (empty($this->id)) { unset($_POST['aor_conditions_id']); unset($_POST['aor_fields_id']); } parent::save($check_notify); require_once 'modules/AOR_Fields/AOR_Field.php'; $condition = new AOR_Field(); $condition->save_lines($_POST, $this, 'aor_fields_'); require_once 'modules/AOR_Conditions/AOR_Condition.php'; $condition = new AOR_Condition(); $condition->save_lines($_POST, $this, 'aor_conditions_'); require_once 'modules/AOR_Charts/AOR_Chart.php'; $chart = new AOR_Chart(); $chart->save_lines($_POST, $this, 'aor_chart_'); }
function save($check_notify = FALSE) { // TODO: process of saveing the fields and conditions is too long so we will have to make some optimization on save_lines functions set_time_limit(3600); if (empty($this->id)) { unset($_POST['aor_conditions_id']); unset($_POST['aor_fields_id']); } parent::save($check_notify); require_once 'modules/AOR_Fields/AOR_Field.php'; $field = new AOR_Field(); $field->save_lines($_POST, $this, 'aor_fields_'); require_once 'modules/AOR_Conditions/AOR_Condition.php'; $condition = new AOR_Condition(); $condition->save_lines($_POST, $this, 'aor_conditions_'); require_once 'modules/AOR_Charts/AOR_Chart.php'; $chart = new AOR_Chart(); $chart->save_lines($_POST, $this, 'aor_chart_'); }
public function testbuildChartHTML() { $this->markTestSkipped('Skipping testing chart HTML'); $aorChart = new AOR_Chart(); //preset the required objects and properties $aorChart->x_field = 'x'; $aorChart->y_field = 'y'; $fields = array(); $fields['x'] = json_decode('{"label": "x"}'); $fields['y'] = json_decode('{"label": "y"}'); $reportData = array(array('xx' => 10, 'yy' => 10), array('xx' => 20, 'yy' => 20)); $aorChart->type = 'bar'; //test with type CHART_TYPE_PCHART and verify it returns expected results $expected = "<img id='_img' src='data:image/png;base64,'><script>\nSUGAR.util.doWhen(\"typeof addImage != 'undefined'\", function(){\n addImage('_img','_img_map','index.php?module=AOR_Charts&action=getImageMap&to_pdf=1&imageMapId=0');\n});\n</script>"; $result = $aorChart->buildChartHTML($reportData, $fields); $this->assertSame($expected, $result); //test with type CHART_TYPE_CHARTJS verify it returns expected results $expected = "<h3></h3><canvas id='chart' width='400' height='400'></canvas> <script>\n \$(document).ready(function(){\n SUGAR.util.doWhen(\"typeof Chart != 'undefined'\", function(){\n var data = {\"labels\":[\"10 [a]\",\"20 [e]\"],\"datasets\":[{\"fillColor\":\"rgba(151,187,205,0.2)\",\"strokeColor\":\"rgba(151,187,205,1)\",\"pointColor\":\"rgba(151,187,205,1)\",\"pointStrokeColor\":\"#fff\",\"pointHighlightFill\":\"#fff\",\"pointHighlightStroke\":\"rgba(151,187,205,1)4\",\"data\":[10,20]}]};\n var ctx = document.getElementById(\"chart\").getContext(\"2d\");\n console.log('Creating new chart');\n var config = [];\n var chart = new Chart(ctx).Bar(data, config);\n var legend = chart.generateLegend();\n \$('#chart').after(legend);\n });\n });\n </script>"; $result = $aorChart->buildChartHTML($reportData, $fields, 0, AOR_Report::CHART_TYPE_CHARTJS); $this->assertSame($expected, $result); }