Skip to content

Resolving the fix for daterange https://github.com/jdorn/php-reports/iss... #145

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 5 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions classes/headers/ChartHeader.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ class ChartHeader extends HeaderBase {
),
'type'=>array(
'type'=>'enum',
'values'=>array('LineChart','GeoChart','AnnotatedTimeLine','BarChart','ColumnChart','Timeline'),
'values'=>array('LineChart','GeoChart','AnnotatedTimeLine','BarChart','ColumnChart','Timeline','AreaChart'),
'default'=>'LineChart'
),
'title'=>array(
Expand All @@ -19,7 +19,7 @@ class ChartHeader extends HeaderBase {
),
'width'=>array(
'type'=>'string',
'default'=>'100%'
'default'=>'50%'
),
'height'=>array(
'type'=>'string',
Expand Down
10 changes: 5 additions & 5 deletions classes/headers/VariableHeader.php
Original file line number Diff line number Diff line change
Expand Up @@ -188,15 +188,15 @@ public static function afterParse(&$report) {

$report->options['Variables'][$var] = $params;
}

//if the type is daterange, parse start and end with strtotime
if($params['type'] === 'daterange' && $report->macros[$params['name']][0] && $report->macros[$params['name']][1]) {
$start = date_create($report->macros[$params['name']][0]);
if($params['type'] === 'daterange' && $report->macros[$params['name']]['start'] && $report->macros[$params['name']]['end']) {
$start = date_create($report->macros[$params['name']]['start']);
if(!$start) throw new Exception($params['display']." must have a valid start date.");
date_time_set($start,0,0,0);
$report->macros[$params['name']]['start'] = date_format($start,$params['format']);

$end = date_create($report->macros[$params['name']][1]);
$end = date_create($report->macros[$params['name']]['end']);
if(!$end) throw new Exception($params['display']." must have a valid end date.");
date_time_set($end,23,59,59);
$report->macros[$params['name']]['end'] = date_format($end,$params['format']);
Expand Down
4 changes: 2 additions & 2 deletions classes/report_types/AdoReportType.php
Original file line number Diff line number Diff line change
Expand Up @@ -107,13 +107,13 @@ public static function run(&$report) {
if(is_array($value)) {
$first = true;
foreach($value as $key2=>$value2) {
$value[$key2] = mysql_real_escape_string(trim($value2));
$value[$key2] = mysql_escape_string(trim($value2));
$first = false;
}
$macros[$key] = $value;
}
else {
$macros[$key] = mysql_real_escape_string($value);
$macros[$key] = mysql_escape_string($value);
}

if($value === 'ALL') $macros[$key.'_all'] = true;
Expand Down
4 changes: 0 additions & 4 deletions classes/report_types/MysqlReportType.php
Original file line number Diff line number Diff line change
Expand Up @@ -91,10 +91,6 @@ public static function getVariableOptions($params, &$report) {
if(isset($params['where'])) {
$query .= ' WHERE '.$params['where'];
}

if(isset($params['order']) && in_array($params['order'], array('ASC', 'DESC')) ) {
$query .= ' ORDER BY '.$params['column'].' '.$params['order'];
}

$result = mysql_query($query, $report->conn);

Expand Down
69 changes: 55 additions & 14 deletions config/config.php.sample → config/config.php
Original file line number Diff line number Diff line change
@@ -1,11 +1,16 @@
<?php
return array(

//Confugure whether to use Login System or not for PHPReports
//Assign 1 to enable, assign 0 for disable. Default it is '0' (Disabled)
'loginEnable' => 1,

//the root directory of all your reports
//reports can be organized in subdirectories
'reportDir' => 'sample_reports',
'reportDir' => 'reports',

//the root directory of all dashboards
'dashboardDir' => 'sample_dashboards',
'dashboardDir' => 'dashboards',

//the directory where things will be cached
//this is relative to the project root by default, but can be set to an absolute path too
Expand Down Expand Up @@ -56,24 +61,53 @@
//email settings
'mail_settings' => array(
//set 'enabled' to true to enable the 'email this report' functionality
'enabled'=>false,
'enabled'=>true,

'from'=>'reports@yourdomain.com',
'from'=>'sreekanthreddy.vasavi@gmail.com',

//php's mail function
'method'=>'mail'
// 'method'=>'mail'

//sendmail
/*
'method'=>'sendmail',
'command'=>'/usr/sbin/sendmail -bs' //optional
*/

// 'method'=>'sendmail',
// 'command'=>'/usr/sbin/sendmail -bs' //optional


//smtp
/*

'method'=>'smtp',
'server'=>'smtp.gmail.com',
'port'=>'587', //optional (default 25)

'username'=>'', //optional
'password'=>'', //optional
'encryption'=>'tls' //optional (either 'ssl' or 'tls')

),

//email settings
'mail_scheduler' => array(
//set 'enabled' to true to enable the 'email this report' functionality
'enabled'=>true,

'from'=>'reports@reports.adrtr.net',

//php's mail function
// 'method'=>'mail'

//sendmail

// 'method'=>'sendmail',
// 'command'=>'/usr/sbin/sendmail -bs' //optional


//smtp

'method'=>'smtp',
'server'=>'smtp.yourdomain.com',
'server'=>'localhost',
'port'=>'25', //optional (default 25)
/*
'username'=>'youremailusername', //optional
'password'=>'yoursmtppassword', //optional
'encryption'=>'ssl' //optional (either 'ssl' or 'tls')
Expand All @@ -93,11 +127,18 @@
),

'mysql'=>array(
'host'=>'localhost',
'user'=>'root',
'host'=>'',
'user'=>'',
'pass'=>'',
'database'=>'test'
'database'=>'',
),
'mysql1'=>array(
'host'=>'',
'user'=>'',
'pass'=>'',
'database'=>'test',
),


'mongo'=>array(
'host'=>'localhost',
Expand Down
35 changes: 35 additions & 0 deletions includes/config.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
<?php



/**
* These are the database login details
*/
define("HOST", "localhost"); // The host you want to connect to.
define("USER", "root"); // The database username.
define("PASSWORD", ""); // The database password.
define("DATABASE", "test"); // The database name.

/**
* Who can register and what the default role will be
* Values for who can register under a standard setup can be:
* any == anybody can register (default)
* admin == members must be registered by an administrator
* root == only the root user can register members
*
* Values for default role can be any valid role, but it's hard to see why
* the default 'member' value should be changed under the standard setup.
* However, additional roles can be added and so there's nothing stopping
* anyone from defining a different default.
*/
define("CAN_REGISTER", "admin");
define("DEFAULT_ROLE", "member");

/**
* Is this a secure connection? The default is FALSE, but the use of an
* HTTPS connection for logging in is recommended.
*
* If you are using an HTTPS connection, change this to TRUE
*/
define("SECURE", FALSE); // For development purposes only!!!!

9 changes: 9 additions & 0 deletions includes/db_connect.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
<?php

include_once 'config.php';

$mysqli = new mysqli(HOST, USER, PASSWORD, DATABASE);
if ($mysqli->connect_error) {
header("Location: ../error.php?err=Unable to connect to MySQL");
exit();
}
Loading