<?php
/**
 * @package DJ-Catalog2
 * @copyright Copyright (C) DJ-Extensions.com, All rights reserved.
 * @license http://www.gnu.org/licenses GNU/GPL
 * @author url: http://dj-extensions.com
 * @author email contact@dj-extensions.com
 *
 */
defined('_JEXEC') or die('Restricted access');

//Joomla\CMS\HTML\HTMLHelper::_('formbehavior.chosen', '.djc2-admin-stats select:not("#filters_user")');

?>

<div id="djc2_admin_stats<?php echo $module->id;?>"
	class="djc2-admin-stats">
	<form method="post">

		<div class="row row-fluid">
			<div class="col-md-2 offset8">   
		        <?php echo $form->renderField('period','params'); ?>
		        <?php echo $form->renderField('date_from','params'); ?>
		        <?php echo $form->renderField('date_to','params'); ?>
		    </div>
			<div class="col-md-2">   
		        <?php echo $form->renderField('sum_by','params'); ?>
		    </div>
		</div>

		<div class="row row-fluid">
			<div class="col-md-12">
				<legend><?php echo JText::_('MOD_DJCATALOG2_ADMIN_STATS_FILTERS'); ?></legend>
			</div>
		</div>

		<div class="row row-fluid">
			<div class="col-md-2"><?php echo $form->renderField('cat','filters'); ?></div>
	        <div class="col-md-4"><?php echo $form->renderField('product','filters'); ?></div>
	        <div class="col-md-2"><?php echo $form->renderField('customer_group','filters'); ?></div>
	        <div class="col-md-2"><?php echo $form->renderField('user','filters'); ?></div>
	        <div class="col-md-2"><?php echo $form->renderField('coupon','filters'); ?></div>
		</div>

		<div class="row row-fluid">
			<div class="pull-right">
				<button type="submit" class="btn btn-primary "><?php echo JText::_('MOD_DJCATALOG2_ADMIN_STATS_SHOW_BTN'); ?></button>
			</div>
		</div>

	</form>

	<div class="row row-fluid">

		<div class="col-md-12">
			<canvas id="summary_profit_bar_canvas" height="300"></canvas>
			<script>
			var chart = new Chart('summary_profit_bar_canvas', {
				type: 'bar',
				data: {
					labels: ["<?php echo implode('","', array_keys($chartData)) ?>"],
					datasets: [
					{
						label: "<?php echo JText::_('MOD_DJCATALOG2_ADMIN_STATS_CHART_PROFIT_BAR') ?>",
						fill: true,
						lineTension: 0.1,
						backgroundColor: "rgba(54, 162, 235, 0.2)",
						borderColor: "rgba(54, 162, 235, 1)",
						pointRadius: 1,
						pointHoverRadius: 5,
						pointHitRadius: 10,
						data: [<?php echo implode(',', $chartData) ?>],
					}
					]
				},
				options: {
					maintainAspectRatio: false
				}
			});
		</script>
		</div>
	</div>
	<div class="row row-fluid">
		<div class="col-md-12">
			<canvas id="summary_profit_line_canvas" height="300"></canvas>
			<script>
			var chart = new Chart('summary_profit_line_canvas', {
				type: 'line',
				data: {
					labels: ["<?php echo implode('","', array_keys($chartData)) ?>"],
					datasets: [
					{
						label: "<?php echo JText::_('MOD_DJCATALOG2_ADMIN_STATS_CHART_PROFIT_LINE') ?>",
						fill: true,
						lineTension: 0.1,
						backgroundColor: "rgba(54, 162, 235, 0.2)",
						borderColor: "rgba(54, 162, 235, 1)",
						pointRadius: 1,
						pointHoverRadius: 5,
						pointHitRadius: 10,
						data: [<?php echo implode(',', $chartData) ?>],
					}
					]
				},
				options: {
					maintainAspectRatio: false
				}
			});
		</script>
		</div>

	</div>

</div>
