stuntnmore Posted May 16, 2014 Share Posted May 16, 2014 Im trying to show charts within a tpl file within a custom admin page in whmcs This is what i have tried {php} $counter = mysql_query("SELECT COUNT(*) AS id FROM tblclients WHERE status='Active'"); $num = mysql_fetch_array($counter); $count = $num["id"]; $this->assign('clienttotal',$count); $counter2 = mysql_query("SELECT COUNT(*) AS id FROM tbldomains WHERE status='Active'"); $num2 = mysql_fetch_array($counter2); $count2 = $num2["id"]; $this->assign('domaintotal',$count2); $counter3 = mysql_query("SELECT COUNT(*) AS id FROM tblhosting WHERE domainstatus='Active'"); $num3 = mysql_fetch_array($counter3); $count3 = $num3["id"]; $this->assign('hostingtotal',$count3); {/php} {php} $reportdata["monthspagination"] = true; $reportdata["tableheadings"] = array( "Date", "Completed Orders", "New Invoices", "Paid Invoices", "Opened Tickets", "Ticket Replies", "Cancellation Requests", ); $reportvalues = array(); $query = "SELECT date_format(date, '%e'),COUNT(id) FROM tblorders WHERE date LIKE '" . $year . "-" . $month . "-%' AND status='Active' GROUP BY date_format(date, '%e') ORDER BY date ASC"; $result = full_query($query); while ($data = mysql_fetch_array($result)) { $reportvalues['orders_active'][$data[0]] = $data[1]; } $query = "SELECT date_format(date, '%e'),COUNT(id) FROM tblinvoices WHERE date LIKE '" . $year . "-" . $month . "-%' GROUP BY date_format(date, '%e') ORDER BY date ASC"; $result = full_query($query); while ($data = mysql_fetch_array($result)) { $reportvalues['invoices_new'][$data[0]] = $data[1]; } $query = "SELECT date_format(datepaid, '%e'),COUNT(id) FROM tblinvoices WHERE datepaid LIKE '" . $year . "-" . $month . "-%' GROUP BY date_format(datepaid, '%e') ORDER BY datepaid ASC"; $result = full_query($query); while ($data = mysql_fetch_array($result)) { $reportvalues['invoices_paid'][$data[0]] = $data[1]; } $query = "SELECT date_format(date, '%e'),COUNT(id) FROM tbltickets WHERE date LIKE '" . $year . "-" . $month . "-%' GROUP BY date_format(date, '%e') ORDER BY date ASC"; $result = full_query($query); while ($data = mysql_fetch_array($result)) { $reportvalues['tickets_new'][$data[0]] = $data[1]; } $query = "SELECT date_format(date, '%e'),COUNT(id) FROM tblticketreplies WHERE date LIKE '" . $year . "-" . $month . "-%' AND admin!='' GROUP BY date_format(date, '%e') ORDER BY date ASC"; $result = full_query($query); while ($data = mysql_fetch_array($result)) { $reportvalues['tickets_staff_replies'][$data[0]] = $data[1]; } $query = "SELECT date_format(date, '%e'),COUNT(id) FROM tblcancelrequests WHERE date LIKE '" . $year . "-" . $month . "-%' GROUP BY date_format(date, '%e') ORDER BY date ASC"; $result = full_query($query); while ($data = mysql_fetch_array($result)) { $reportvalues['cancellations_new'][$data[0]] = $data[1]; } for ($day = 1; $day <= 31; $day++) { $date = date("Y-m-d", mktime(0, 0, 0, $month, $day, $year)); $daytext = date("l", mktime(0, 0, 0, $month, $day, $year)); $neworders = isset($reportvalues['orders_active'][$day]) ? $reportvalues['orders_active'][$day] : '0'; $newinvoices = isset($reportvalues['invoices_new'][$day]) ? $reportvalues['invoices_new'][$day] : '0'; $paidinvoices = isset($reportvalues['invoices_paid'][$day]) ? $reportvalues['invoices_paid'][$day] : '0'; $newtickets = isset($reportvalues['tickets_new'][$day]) ? $reportvalues['tickets_new'][$day] : '0'; $ticketreplies = isset($reportvalues['tickets_staff_replies'][$day]) ? $reportvalues['tickets_staff_replies'][$day] : '0'; $cancellations = isset($reportvalues['cancellations_new'][$day]) ? $reportvalues['cancellations_new'][$day] : '0'; $reportdata["tablevalues"][] = array( $daytext.' '.fromMySQLDate($date), $neworders, $newinvoices, $paidinvoices, $newtickets, $ticketreplies, $cancellations, ); $chartdata['rows'][] = array( 'c'=>array( array('v' => fromMySQLDate($date)), array('v' => (int)$neworders), array('v' => (int)$newinvoices), array('v' => (int)$paidinvoices), array('v' => (int)$newtickets), array('v' => (int)$ticketreplies), array('v' => (int)$cancellations) ) ); } $chartdata['cols'][] = array('label'=>'Day','type'=>'string'); $chartdata['cols'][] = array('label'=>'Completed Orders','type'=>'number'); $chartdata['cols'][] = array('label'=>'New Invoices','type'=>'number'); $chartdata['cols'][] = array('label'=>'Paid Invoices','type'=>'number'); $chartdata['cols'][] = array('label'=>'Opened Tickets','type'=>'number'); $chartdata['cols'][] = array('label'=>'Ticket Replies','type'=>'number'); $chartdata['cols'][] = array('label'=>'Cancellation Requests','type'=>'number'); $args = array(); $args['legendpos'] = 'right'; $reportdata["headertext"] = $chart->drawChart('Area',$chartdata,$args,'400px'); {/php} Everything is correct but i recieve an error when trying to execute, Fatal error: Call to a member function drawChart() on a non-object in 217 0 Quote Link to comment Share on other sites More sharing options...
stuntnmore Posted May 22, 2014 Author Share Posted May 22, 2014 Any luck with this? 0 Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.