LusoAloja Posted January 1, 2016 Share Posted January 1, 2016 I finally figured out a way to remove the validation and make use of the $totalyears variable - makes the code much neater too. <?php if (!defined("WHMCS")) die("This file cannot be accessed directly"); function income_overview_bars($vars) { global $_ADMINLANG,$chart; $title = 'Income Overview for '.date("Y"); $args = array(); $args['colors'] = '#3070CF,#F9D88C,#779500,#E8C2D4,#CBEAAD'; $args['chartarea'] = '80,40,85%,70%'; $args['xlabel'] = 'Month of Year'; $args['ylabel'] = 'Default Currency'; $content = $chart->drawChart('Column',chartdata_annual_overview_bars(),$args,'300px'); return array( 'title' => $title, 'content' => $content ); } function chartdata_annual_overview_bars() { $totalyears = 4; for($i = 0; $i <= $totalyears-1; $i++) { $chartyear[$i] = date("Y",strtotime("-$i year")); } $chartdata = array(); $chartdata['cols'][] = array('label'=>'Days Range','type'=>'string'); for($i = $totalyears-1; $i >=0 ; $i--) { $chartdata['cols'][] = array('label'=>$chartyear[$i],'type'=>'number'); } $months = array('Jan','Feb','Mar','Apr','May','Jun','Jul','Aug','Sep','Oct','Nov','Dec'); for ( $counter = 1; $counter <= 12; $counter += 1) { $month = $months[$counter-1]; $counter = str_pad($counter, 2, "0", STR_PAD_LEFT); for($i = $totalyears-1; $i >=0 ; $i--) { $monthbal[$i] = get_query_val("tblaccounts","SUM((amountin-fees-amountout)/rate)","date LIKE '".$chartyear[$i]."-$counter-%'"); } $chartdata['rows'][] = array('c'=>array(array('v'=>$month),array('v'=>$monthbal[$totalyears-1],'f'=>formatCurrency($monthbal[$totalyears-1])),array('v'=>$monthbal[$totalyears-2],'f'=>formatCurrency($monthbal[$totalyears-2])),array('v'=>$monthbal[$totalyears-3],'f'=>formatCurrency($monthbal[$totalyears-3])),array('v'=>$monthbal[$totalyears-4],'f'=>formatCurrency($monthbal[$totalyears-4])),array('v'=>$monthbal[$totalyears-5],'f'=>formatCurrency($monthbal[$totalyears-5])))); } return $chartdata; } add_hook("AdminHomeWidgets",1,"income_overview_bars"); ?> Any idea why do not work with version 6.2? 0 Quote Link to comment Share on other sites More sharing options...
brian! Posted January 1, 2016 Share Posted January 1, 2016 Any idea why do not work with version 6.2? they work fine on my v6 dev using v6.2 0 Quote Link to comment Share on other sites More sharing options...
Patty Posted October 3, 2017 Share Posted October 3, 2017 Still working fine on v7.2.3 Just the mouse over effect showing the amounts is not working. 0 Quote Link to comment Share on other sites More sharing options...
MikeDVB Posted October 3, 2017 Author Share Posted October 3, 2017 I'll see what I can do :). 1 Quote Link to comment Share on other sites More sharing options...
brian! Posted October 3, 2017 Share Posted October 3, 2017 21 minutes ago, Patty said: Just the mouse over effect showing the amounts is not working. the reverse version seems to be working fine if the widget is only using 1 year, but fails if using more than that... the normal version seems to display fine for multiple years. if @MikeDVB can figure out the issue, so much the better - if not, i'll take a look at the weekend and rewrite the widget for v7. 1 Quote Link to comment Share on other sites More sharing options...
Patty Posted October 3, 2017 Share Posted October 3, 2017 You guys are the best! TIA! 0 Quote Link to comment Share on other sites More sharing options...
kaufenpreis Posted October 25, 2017 Share Posted October 25, 2017 I also missed old bar-style widgets. Thanks Mike! 0 Quote Link to comment Share on other sites More sharing options...
edvancombr Posted October 27, 2018 Share Posted October 27, 2018 On 4/1/2015 at 7:22 PM, brian! said: I finally figured out a way to remove the validation and make use of the $totalyears variable - makes the code much neater too. <?php if (!defined("WHMCS")) die("This file cannot be accessed directly"); function income_overview_bars($vars) { global $_ADMINLANG,$chart; $title = 'Income Overview for '.date("Y"); $args = array(); $args['colors'] = '#3070CF,#F9D88C,#779500,#E8C2D4,#CBEAAD'; $args['chartarea'] = '80,40,85%,70%'; $args['xlabel'] = 'Month of Year'; $args['ylabel'] = 'Default Currency'; $content = $chart->drawChart('Column',chartdata_annual_overview_bars(),$args,'300px'); return array( 'title' => $title, 'content' => $content ); } function chartdata_annual_overview_bars() { $totalyears = 4; for($i = 0; $i <= $totalyears-1; $i++) { $chartyear[$i] = date("Y",strtotime("-$i year")); } $chartdata = array(); $chartdata['cols'][] = array('label'=>'Days Range','type'=>'string'); for($i = $totalyears-1; $i >=0 ; $i--) { $chartdata['cols'][] = array('label'=>$chartyear[$i],'type'=>'number'); } $months = array('Jan','Feb','Mar','Apr','May','Jun','Jul','Aug','Sep','Oct','Nov','Dec'); for ( $counter = 1; $counter <= 12; $counter += 1) { $month = $months[$counter-1]; $counter = str_pad($counter, 2, "0", STR_PAD_LEFT); for($i = $totalyears-1; $i >=0 ; $i--) { $monthbal[$i] = get_query_val("tblaccounts","SUM((amountin-fees-amountout)/rate)","date LIKE '".$chartyear[$i]."-$counter-%'"); } $chartdata['rows'][] = array('c'=>array(array('v'=>$month),array('v'=>$monthbal[$totalyears-1],'f'=>formatCurrency($monthbal[$totalyears-1])),array('v'=>$monthbal[$totalyears-2],'f'=>formatCurrency($monthbal[$totalyears-2])),array('v'=>$monthbal[$totalyears-3],'f'=>formatCurrency($monthbal[$totalyears-3])),array('v'=>$monthbal[$totalyears-4],'f'=>formatCurrency($monthbal[$totalyears-4])),array('v'=>$monthbal[$totalyears-5],'f'=>formatCurrency($monthbal[$totalyears-5])))); } return $chartdata; } add_hook("AdminHomeWidgets",1,"income_overview_bars"); ?> Hello how are you? Did you even test these widgets in the latest stable release? 0 Quote Link to comment Share on other sites More sharing options...
brian! Posted October 27, 2018 Share Posted October 27, 2018 13 hours ago, edvancombr said: Did you even test these widgets in the latest stable release? they wouldn't work in v7.6+ and would have to be rewritten - give me a poke when v7.7 comes out and i'll take a closer look. 0 Quote Link to comment Share on other sites More sharing options...
edvancombr Posted October 28, 2018 Share Posted October 28, 2018 21 hours ago, brian! said: they wouldn't work in v7.6+ and would have to be rewritten - give me a poke when v7.7 comes out and i'll take a closer look. Thank you! 0 Quote Link to comment Share on other sites More sharing options...
stormy Posted November 7, 2018 Share Posted November 7, 2018 I really miss these widgets! 😞 0 Quote Link to comment Share on other sites More sharing options...
edvancombr Posted January 23, 2019 Share Posted January 23, 2019 On 10/27/2018 at 12:18 PM, brian! said: they wouldn't work in v7.6+ and would have to be rewritten - give me a poke when v7.7 comes out and i'll take a closer look. As you requested, going on to remember. Thank you! 0 Quote Link to comment Share on other sites More sharing options...
brian! Posted January 23, 2019 Share Posted January 23, 2019 57 minutes ago, edvancombr said: As you requested, going on to remember. Thank you! patience my friend, i've only just setup the v7.7 dev - but i've bookmarked this page and will take a look at this at the weekend. 0 Quote Link to comment Share on other sites More sharing options...
edvancombr Posted January 23, 2019 Share Posted January 23, 2019 3 hours ago, brian! said: patience my friend, i've only just setup the v7.7 dev - but i've bookmarked this page and will take a look at this at the weekend. Thanks 0 Quote Link to comment Share on other sites More sharing options...
ISH Posted January 28, 2019 Share Posted January 28, 2019 I really miss these widgets! in v7.7 😢 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.