Post Reply 
 
Thread Rating:
  • 0 Votes - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Sales Graph Missing Period Names
11-30-2017, 12:03 AM (This post was last modified: 11-30-2017 12:17 AM by VortecCPI.)
Post: #1
Sales Graph Missing Period Names
Locale - USA

Main Menu > Sales > Sales Graphs

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

Before:
   
   

After:
   
   

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

https://www.linkedin.com/in/eclipsepaulbecker
Visit this user's website Find all posts by this user
Quote this message in a reply
11-30-2017, 08:42 AM
Post: #2
RE: Sales Graph Missing Period Names
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
Visit this user's website Find all posts by this user
Quote this message in a reply
01-08-2018, 03:59 PM (This post was last modified: 01-08-2018 03:59 PM by TurboPT.)
Post: #3
RE: Sales Graph Missing Period Names
Tim, I'll use your query with a minor modification: MONTHNAME instead of MONTH.
Change committed to SVN.
Find all posts by this user
Quote this message in a reply
01-08-2018, 09:21 PM
Post: #4
RE: Sales Graph Missing Period Names
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
Visit this user's website Find all posts by this user
Quote this message in a reply
Post Reply 


Forum Jump:


User(s) browsing this thread: 1 Guest(s)