webERP Forum

Full Version: Sales Graph Missing Period Names
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Locale - USA

Main Menu > Sales > Sales Graphs

The periods are shown as numbers and I prefer them shown as dates.

Before:
[attachment=568]
[attachment=569]

After:
[attachment=572]
[attachment=571]

Code below:

//$GraphTitle .= ' ' . _('From Period') . ' ' . $_POST['FromPeriod'] . ' ' . _('to') . ' ' . $_POST['ToPeriod'] . "\n\r";

// Retrieve Period Date Names
$sql = "SELECT lastdate_in_period FROM periods WHERE periodno='" . $_POST['FromPeriod'] . "'";
$PeriodFromDate = MonthAndYearFromSQLDate(DB_fetch_row(DB_query($sql))[0]);
$sql = "SELECT lastdate_in_period FROM periods WHERE periodno='" . $_POST['ToPeriod'] . "'";
$PeriodToDate = MonthAndYearFromSQLDate(DB_fetch_row(DB_query($sql))[0]);
$GraphTitle .= ' ' . _('From Period') . ' ' . $PeriodFromDate . ' ' . _('to') . ' ' . $PeriodToDate . "\n\r";
You can do it all in one query with the following SQL:

$SQL = "SELECT Year(`lastdate_in_period`) AS year, MONTH(`lastdate_in_period`) AS month FROM `periods` WHERE `periodno`='".$_POST['FromPeriod']."' OR periodno='".$_POST['ToPeriod']."';

Thanks
Tim
Tim, I'll use your query with a minor modification: MONTHNAME instead of MONTH.
Change committed to SVN.
Thanks Paul, I didn't use MONTHNAME as postgres doesn't have that function and it was always one of Phil's "things" that we kept compatibility with other RDMS, however I don't think anyone will ever write the postgres code so I don't suppose it matters.

Tim
Reference URL's