Example #1
0
 static function formatAmount($amount, $currency = null, $round = true)
 {
     global $aecConfig;
     $amount = AECToolbox::correctAmount($amount, $round);
     $a = explode('.', $amount);
     if ($aecConfig->cfg['amount_use_comma']) {
         $amount = number_format($amount, $round ? 2 : strlen($a[1]), ',', '.');
     } else {
         $amount = number_format($amount, $round ? 2 : strlen($a[1]), '.', ',');
     }
     if (!empty($currency)) {
         if (!empty($aecConfig->cfg['amount_currency_symbol'])) {
             $currency = AECToolbox::getCurrencySymbol($currency);
         }
         if ($aecConfig->cfg['amount_currency_symbolfirst']) {
             $amount = $currency . ' ' . $amount;
         } else {
             $amount .= ' ' . $currency;
         }
     }
     return $amount;
 }
Example #2
0
 public function loadPaymentInfo()
 {
     $this->payment->freetrial = 0;
     $this->payment->amount = null;
     $this->payment->method_name = null;
     if (!empty($this->passthrough['task'])) {
         $task = $this->passthrough['task'];
     } else {
         $task = "";
     }
     if (empty($this->cart) && !empty($this->plan)) {
         if (!isset($this->recurring)) {
             $this->recurring = 0;
         }
         $terms = $this->plan->getTermsForUser($this->recurring, $this->metaUser);
         if (!empty($terms)) {
             if (is_object($terms->nextterm)) {
                 $this->payment->amount = $terms->nextterm->renderTotal();
                 if ($terms->nextterm->free && $terms->nextterm->get('type') == 'trial') {
                     $this->payment->freetrial = 1;
                 }
             }
         } else {
             $this->payment->amount = null;
         }
         $this->items->itemlist[] = array('item' => array('obj' => $this->plan), 'terms' => $terms);
     } elseif (!empty($this->cartobject->id) || $task == 'confirmCart') {
         $this->getCart();
         $this->payment->amount = $this->cartobject->getAmount($this->metaUser, 0, $this);
     } else {
         $this->payment->amount = $this->invoice->amount;
     }
     $this->payment->amount = AECToolbox::correctAmount($this->payment->amount);
     if (empty($this->payment->currency) && !empty($this->invoice->currency)) {
         $this->payment->currency = $this->invoice->currency;
     }
     // Amend ->payment
     if (!empty($this->payment->currency)) {
         $this->payment->currency_symbol = AECToolbox::getCurrencySymbol($this->payment->currency);
     } else {
         $this->payment->currency_symbol = '';
     }
     if (!empty($this->plan)) {
         $this->payment->amount_format = AECToolbox::formatAmountCustom($this, $this->plan);
     } else {
         if (!empty($this->payment->currency)) {
             $this->payment->amount_format = AECToolbox::formatAmount($this->payment->amount, $this->payment->currency);
         } else {
             $this->payment->amount_format = AECToolbox::formatAmount($this->payment->amount);
         }
     }
 }
Example #3
0
    static function stats($page, $stats)
    {
        global $aecConfig;
        HTML_myCommon::startCommon('aec-wrap-dots');
        HTML_myCommon::startForm();
        HTML_myCommon::getHeader('AEC_HEAD_STATS', 'stats');
        ?>
		<link rel="stylesheet" type="text/css" media="all" href="<?php 
        echo JURI::root();
        ?>
media/com_acctexp/css/admin.stats.css" />
			<script type="text/javascript" src="<?php 
        echo JURI::root(true) . '/media/com_acctexp';
        ?>
/js/stats/charts.js"></script>
			<script type="text/javascript" src="<?php 
        echo JURI::root(true) . '/media/com_acctexp';
        ?>
/js/stats/grouped_sales.js"></script>
			<script type="text/javascript">
				var	amount_format = d3.format(".2f"),
					amount_currency = "<?php 
        echo html_entity_decode(AECToolbox::getCurrencySymbol($aecConfig->cfg['standard_currency']), ENT_QUOTES, "UTF-8");
        ?>
",
					range_start=2007,
					range_end=2012,
					request_url="index.php?option=com_acctexp&task=statrequest",
					avg_sale = <?php 
        echo $stats['avg_sale'];
        ?>
,
					first_sale = "<?php 
        echo $stats['first_sale'];
        ?>
",
					group_names = ["<?php 
        echo implode('","', $stats['group_names']);
        ?>
"],
					plan_names = ["<?php 
        echo implode('","', $stats['plan_names']);
        ?>
"];
			</script>
		<form action="index.php" method="post" name="adminForm" id="adminForm">

		<ul class="nav nav-pills">
			<?php 
        $menus = array('overview' => "Overview", 'compare' => "Compare", 'sales' => "Sales Graph", 'all_time' => "All Time Sales");
        foreach ($menus as $menu => $menutext) {
            echo '<li' . ($page == $menu ? ' class="active"' : '') . '><a href="index.php?option=com_acctexp&task=stats&page=' . $menu . '">' . $menutext . '</a></li>';
        }
        ?>
		</ul>

		<div class="container-fluid">
		<div class="row">
		<div class="col-sm-12">
		<div class="col-sm-12">
		<table class="aecadminform">
		<tr><td>

		<?php 
        switch ($page) {
            case 'overview':
                ?>
				<section class="paper" id="chart">
					<div id="overview-day" class="overview-container">
						<h4><?php 
                echo gmdate('l, jS M Y');
                ?>
</h4>
						<div id="overview-day-this" class="chart-sunburst"></div>
						<div id="overview-day-hourly-graph" class="chart-rickshaw"></div>
					</div>
					<div id="overview-month" class="overview-container">
						<h4><?php 
                echo gmdate('F');
                ?>
</h4>
						<div id="overview-month-this" class="chart-sunburst"></div>
						<div id="overview-month-graph" class="chart-rickshaw"></div>
					</div>
					<div id="overview-year" class="overview-container">
						<h4><?php 
                echo gmdate('Y');
                ?>
</h4>
						<div id="overview-year-sun" class="chart-sunburst"></div>
						<div id="overview-year-cell" class="chart-cellular"></div>
					</div>
					<script type="text/javascript">
						var cf = d3.chart.factory()
							.source("sales")
							.canvas(200, 200, 10)
							.target("div#overview-day-this")
							.range(	"<?php 
                echo gmdate('Y-m-d') . ' 00:00:00';
                ?>
",
								"<?php 
                echo gmdate('Y-m-d') . ' 23:59:59';
                ?>
")
							.create("sunburst")
							.target("div#overview-day-hourly-graph")
							.create("rickshaw",{ unit:"hour" });

						cf.target("div#overview-month-this")
							.range(	"<?php 
                echo gmdate('Y-m-01') . ' 00:00:00';
                ?>
",
								"<?php 
                echo gmdate('Y-m-t') . ' 23:59:59';
                ?>
")
							.create("sunburst")
							.target("div#overview-month-graph")
							.create("rickshaw",{ unit:"day" });

						cf.canvas(200, 200, 10)
							.target("div#overview-year-sun")
							.range(	"<?php 
                echo gmdate('Y-01-01') . ' 00:00:00';
                ?>
",
								"<?php 
                echo gmdate('Y-m-d') . ' 23:59:59';
                ?>
")
							.create("sunburst", 200)
							.canvas(760, 160, 10)
							.target("div#overview-year-cell")
							.range(	"<?php 
                echo gmdate('Y-01-01') . ' 00:00:00';
                ?>
",
								"<?php 
                echo gmdate('Y-m-d') . ' 23:59:59';
                ?>
")
							.create("cellular");
					</script>
							</div>
							<?php 
                break;
            case 'compare':
                ?>
				<section class="paper" id="chart">
					<div id="compare-day" class="compare-container">
						<h4><?php 
                echo gmdate('l, jS M Y', gmdate("U") - 86400 * 7);
                ?>
 &rarr; <?php 
                echo gmdate('l, jS M Y');
                ?>
</h4>
						<div id="compare-day-last" class="chart-sunburst"></div>
						<div id="compare-day-compare" class="chart-rickshaw-bump"></div>
						<div id="compare-day-this" class="chart-sunburst"></div>
						<div id="compare-day-graph-last" class="chart-rickshaw-wide-slim"></div>
						<div id="compare-day-graph-this" class="chart-rickshaw-wide-slim"></div>
					</div>
					<div id="compare-week" class="compare-container">
						<h4>Week <?php 
                echo gmdate('W', gmdate("U") - 86400 * 7);
                ?>
 &rarr; Week <?php 
                echo gmdate('W');
                ?>
</h4>
						<div id="compare-week-last" class="chart-sunburst"></div>
						<div id="compare-week-compare" class="chart-rickshaw-bump"></div>
						<div id="compare-week-this" class="chart-sunburst"></div>
						<div id="compare-week-graph-last" class="chart-rickshaw-wide-slim"></div>
						<div id="compare-week-graph-this" class="chart-rickshaw-wide-slim"></div>
					</div>
					<div id="compare-month" class="compare-container">
						<h4><?php 
                echo gmdate('F', strtotime("last month", gmdate("U")));
                ?>
 &rarr; <?php 
                echo gmdate('F');
                ?>
</h4>
						<div id="compare-month-last" class="chart-sunburst"></div>
						<div id="compare-month-compare" class="chart-rickshaw-bump"></div>
						<div id="compare-month-this" class="chart-sunburst"></div>
						<div id="compare-month-graph-last" class="chart-rickshaw-wide-slim"></div>
						<div id="compare-month-graph-this" class="chart-rickshaw-wide-slim"></div>
					</div>
					<div id="compare-year" class="compare-container">
						<h4><?php 
                echo gmdate('Y', strtotime("last year", gmdate("U")));
                ?>
 &rarr; <?php 
                echo gmdate('Y');
                ?>
</h4>
						<div id="compare-year-last" class="chart-sunburst"></div>
						<div id="compare-year-compare" class="chart-rickshaw-bump"></div>
						<div id="compare-year-this" class="chart-sunburst"></div>
						<div id="compare-year-graph-last" class="chart-rickshaw-wide-slim"></div>
						<div id="compare-year-graph-this" class="chart-rickshaw-wide-slim"></div>
					</div>
					<script type="text/javascript">
						var cf = d3.chart.factory()
							.source("sales")
							.canvas(200, 200, 10);

						cf.target("div#compare-day-last")
							.range(	"<?php 
                echo gmdate('Y-m-d', gmdate("U") - 86400 * 7) . ' 00:00:00';
                ?>
",
								"<?php 
                echo gmdate('Y-m-d', gmdate("U") - 86400 * 7) . ' 23:59:59';
                ?>
")
							.create("sunburst")
							.target("div#compare-day-graph-last")
							.create("rickshaw",{ unit:"hour" })
							.target("div#compare-day-this")
							.range(	"<?php 
                echo gmdate('Y-m-d', gmdate("U")) . ' 00:00:00';
                ?>
",
								"<?php 
                echo gmdate('Y-m-d', gmdate("U")) . ' 23:59:59';
                ?>
")
							.create("sunburst")
							.target("div#compare-day-graph-this")
							.create("rickshaw",{ unit:"hour" })
							.target("div#compare-day-last")
							.range(	"<?php 
                echo gmdate('Y-m-d', gmdate("U") - 86400 * 7) . ' 00:00:00';
                ?>
",
								"<?php 
                echo gmdate('Y-m-d', gmdate("U")) . ' 23:59:59';
                ?>
")
							.target("div#compare-day-compare")
							.create("rickshaw",{ unit:"day", renderer:"line", axes_time:false });

						cf.target("div#compare-week-last")
							.range(	"<?php 
                echo gmdate('Y-m-d', (gmdate("N") == 7 ? gmdate("U") : strtotime("last Sunday", gmdate("U"))) - 86400 * 6) . ' 00:00:00';
                ?>
",
								"<?php 
                echo gmdate('Y-m-d', gmdate("N") == 7 ? gmdate("U") : strtotime("last Sunday", gmdate("U"))) . ' 23:59:59';
                ?>
")
							.create("sunburst")
							.target("div#compare-week-graph-last")
							.create("rickshaw",{ unit:"day" })
							.target("div#compare-week-this")
							.range(	"<?php 
                echo gmdate('Y-m-d', (gmdate("N") == 7 ? gmdate("U") : strtotime("last Sunday", gmdate("U"))) + 86400) . ' 00:00:00';
                ?>
",
								"<?php 
                echo gmdate('Y-m-d', (gmdate("N") == 7 ? gmdate("U") : strtotime("last Sunday", gmdate("U"))) + 86400 * 7) . ' 23:59:59';
                ?>
")
							.create("sunburst")
							.target("div#compare-week-graph-this")
							.create("rickshaw",{ unit:"day" })
							.range(	"<?php 
                echo gmdate('Y-m-d', (gmdate("N") == 7 ? gmdate("U") : strtotime("last Sunday", gmdate("U"))) - 86400 * 6) . ' 00:00:00';
                ?>
",
								"<?php 
                echo gmdate('Y-m-d', (gmdate("N") == 7 ? gmdate("U") : strtotime("last Sunday", gmdate("U"))) + 86400 * 7) . ' 23:59:59';
                ?>
")
							.target("div#compare-week-compare")
							.create("rickshaw",{ unit:"week", renderer:"line", axes_time:false });

						cf.target("div#compare-month-last")
							.range(	"<?php 
                echo gmdate('Y-m-01', strtotime("-1 month", gmdate("U"))) . ' 00:00:00';
                ?>
",
								"<?php 
                echo gmdate('Y-m-t', strtotime(gmdate('Y-m-01', gmdate("U"))) - 86400) . ' 23:59:59';
                ?>
")
							.create("sunburst")
							.target("div#compare-month-graph-last")
							.create("rickshaw",{ unit:"day" })
							.target("div#compare-month-this")
							.range(	"<?php 
                echo gmdate('Y-m-01') . ' 00:00:00';
                ?>
",
								"<?php 
                echo gmdate('Y-m-t') . ' 23:59:59';
                ?>
")
							.create("sunburst")
							.target("div#compare-month-graph-this")
							.create("rickshaw",{ unit:"day" })
							.range(	"<?php 
                echo gmdate('Y-m-01', strtotime("-1 month", gmdate("U"))) . ' 00:00:00';
                ?>
",
								"<?php 
                echo gmdate('Y-m-t') . ' 23:59:59';
                ?>
")
							.target("div#compare-month-compare")
							.create("rickshaw",{ unit:"month", renderer:"line", axes_time:false });

						cf.target("div#compare-year-last")
							.range(	"<?php 
                echo gmdate('Y-01-01', strtotime(gmdate('Y-01-01', gmdate("U"))) - 56400) . ' 00:00:00';
                ?>
",
								"<?php 
                echo gmdate('Y-m-t', strtotime(gmdate('Y-01-01', gmdate("U"))) - 56400) . ' 23:59:59';
                ?>
")
							.create("sunburst")
							.target("div#compare-year-graph-last")
							.create("rickshaw",{ unit:"week" })
							.target("div#compare-year-this")
							.range(	"<?php 
                echo gmdate('Y-01-01') . ' 00:00:00';
                ?>
",
								"<?php 
                echo gmdate('Y-m-d', mktime(0, 0, 0, 12, 32, gmdate('Y'))) . ' 23:59:59';
                ?>
")
							.create("sunburst")
							.target("div#compare-year-graph-this")
							.create("rickshaw",{ unit:"week" })
							.target("div#compare-year-last")
							.range(	"<?php 
                echo gmdate('Y-01-01', strtotime(gmdate('Y-01-01', gmdate("U"))) - 56400) . ' 00:00:00';
                ?>
",
								"<?php 
                echo gmdate('Y-m-d', mktime(0, 0, 0, 12, 32, gmdate('Y'))) . ' 23:59:59';
                ?>
")
							.target("div#compare-year-compare")
							.create("rickshaw",{ unit:"year", renderer:"line", axes_time:false });
					</script>
							</div>
							<?php 
                break;
            case 'users':
                break;
            case 'sales':
                ?>
				<section class="paper">
					<h4>Sales Graph</h4>
					<div id="sales-graph" class="overview-container">
						<div id="overview-sales-graph" class="chart-rickshaw-huge"></div>
						<div class="chart-controls-box">
							<div id="legend" class="chart-controls">
								<p><strong>hover</strong> to highlight, <strong>click</strong> to toggle, <strong>drag</strong> to sort groups</p>
							</div>
							<div id="renderer_form" class="toggler chart-controls">
								<input type="radio" name="renderer" id="area" value="area" checked="checked">
								<label for="area"><i class="graph-control-area"></i>area</label>
								<input type="radio" name="renderer" id="bar" value="bar">
								<label for="bar"><i class="graph-control-bar"></i>bar</label>
								<input type="radio" name="renderer" id="line" value="line">
								<label for="line"><i class="graph-control-line"></i>line</label>
								<input type="radio" name="renderer" id="scatter" value="scatterplot">
								<label for="scatter"><i class="graph-control-scatter"></i>scatter</label>
							</div>
							<div id="offset_form" class="chart-controls">
								<label for="value">
									<input type="radio" name="offset" id="value" value="value">
									<span><i class="graph-control-value"></i>value</span>
								</label>
								<label for="stack">
									<input type="radio" name="offset" id="stack" value="zero" checked="checked">
									<span><i class="graph-control-stack"></i>stack</span>
								</label>
								<label for="stream">
									<input type="radio" name="offset" id="stream" value="wiggle">
									<span><i class="graph-control-stream"></i>stream</span>
								</label>
								<label for="pct">
									<input type="radio" name="offset" id="pct" value="expand">
									<span><i class="graph-control-pct"></i>percent</span>
								</label>
							</div>
							<div id="unit_form" class="chart-controls">
								<label for="day">
									<input type="radio" name="unit" id="day" value="day" checked="checked">
									<span><i class="graph-control-day"></i>days</span>
								</label>
								<label for="week">
									<input type="radio" name="unit" id="week" value="week">
									<span><i class="graph-control-week"></i>weeks</span>
								</label>
								<label for="month">
									<input type="radio" name="unit" id="month" value="month">
									<span><i class="graph-control-bar"></i>months</span>
								</label>
								<label for="year">
									<input type="radio" name="unit" id="year" value="year">
									<span><i class="graph-control-year"></i>years</span>
								</label>
							</div>
							<div id="range_form" class="chart-controls">
								<label for="rangepicker">
									<span class="jqui-daterangepicker-text">Select Range:</span>
									<input class="jqui-daterangepicker" type="text" value="<?php 
                echo gmdate('Y-01-01') . " - " . gmdate('Y-m-d');
                ?>
"/>
									<span class="jqui-loading"></span>
								</label>
							</div>
						</div>
					</div>
					<script type="text/javascript">
						var cf = d3.chart.factory()
							.source("sales")
							.canvas(200, 200, 10)
							.target("div#overview-sales-graph")
							.range(	"<?php 
                echo gmdate('Y-01-01') . ' 00:00:00';
                ?>
",
								"<?php 
                echo gmdate('Y-m-d') . ' 23:59:59';
                ?>
")
							.create("rickshaw",{ unit:"day", renderer:"area", legend:true });
					</script>
							</div>
							<?php 
                break;
            case 'all_time':
                $start = date("Y", strtotime($stats['first_sale']));
                $end = date("Y");
                $years = $start - $end;
                ?>
				<section class="paper" id="chart">
					<div id="all-time-cells" class="all-time-container">
						<?php 
                for ($i = $start; $i <= $end; $i++) {
                    ?>
							<div id="all-time-<?php 
                    echo $i;
                    ?>
" class="all-time-container-full">
								<h4><?php 
                    echo $i;
                    ?>
</h4>
								<div id="all-time-year-<?php 
                    echo $i;
                    ?>
-sunburst" class="chart-sunburst"></div>
								<div id="all-time-year-<?php 
                    echo $i;
                    ?>
-cells" class="chart-cellular"></div>
								<div id="all-time-year-<?php 
                    echo $i;
                    ?>
-graph" class="chart-rickshaw-slim"></div>
							</div>
						<?php 
                }
                ?>
					</div>
					<div id="all-time-suns" class="all-time-container-full">
						<h4>All Time Total</h4>
						<div id="all-suns" class="chart-sunburstxl"></div>
					</div>
					<script type="text/javascript">
						var cf = d3.chart.factory()
							.source("sales")
							<?php 
                for ($i = $start; $i <= $end; $i++) {
                    ?>
							.canvas(200, 200, 10)
							.target("div#all-time-year-<?php 
                    echo $i;
                    ?>
-sunburst")
							.range(	"<?php 
                    echo $i . '-1-1 00:00:00';
                    ?>
",
								"<?php 
                    echo $i . '-12-31 23:59:59';
                    ?>
")
							.create("sunburst")
							.canvas(760, 160, 10)
							.target("div#all-time-year-<?php 
                    echo $i;
                    ?>
-cells")
							.range(	"<?php 
                    echo $i . '-1-1 00:00:00';
                    ?>
",
								"<?php 
                    echo $i . '-12-31 23:59:59';
                    ?>
")
							.create("cellular")
							.target("div#all-time-year-<?php 
                    echo $i;
                    ?>
-graph")
							.range(	"<?php 
                    echo $i . '-1-1 00:00:00';
                    ?>
",
								"<?php 
                    echo $i . '-12-31 23:59:59';
                    ?>
")
							.create("rickshaw",{ unit:"week" })
							<?php 
                }
                ?>
							.canvas(500, 500, 10)
							.target("div#all-suns")
							.range(	"<?php 
                echo gmdate('1960-01-01') . ' 00:00:00';
                ?>
",
								"<?php 
                echo gmdate('Y-m-d') . ' 23:59:59';
                ?>
")
							.create("sunburst");
					</script>
							</div>
							<?php 
                break;
        }
        ?>
		</td></tr>
		</table>
		</div>
		</div>
		</div>
		</div>

		<?php 
        HTML_myCommon::endCommon();
    }