webERP Forum
Sales Graph Missing Period Names - Printable Version

+- webERP Forum (http://www.weberp.org/forum)
+-- Forum: webERP Discussion (/forumdisplay.php?fid=1)
+--- Forum: Problems / Bugs? (/forumdisplay.php?fid=8)
+--- Thread: Sales Graph Missing Period Names (/showthread.php?tid=7946)



Sales Graph Missing Period Names - VortecCPI - 11-30-2017 12:03 AM

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";


RE: Sales Graph Missing Period Names - falkoner - 11-30-2017 08:42 AM

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


RE: Sales Graph Missing Period Names - TurboPT - 01-08-2018 03:59 PM

Tim, I'll use your query with a minor modification: MONTHNAME instead of MONTH.
Change committed to SVN.


RE: Sales Graph Missing Period Names - falkoner - 01-08-2018 09:21 PM

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