new form layout and other tpl fixes

This commit is contained in:
Dennis Eichhorn 2021-04-18 22:29:46 +02:00
parent 153047203a
commit fcecebe479
3 changed files with 1043 additions and 4 deletions

View File

@ -25,6 +25,7 @@ use phpOMS\Message\RequestAbstract;
use phpOMS\Message\ResponseAbstract;
use phpOMS\Stdlib\Base\SmartDateTime;
use phpOMS\Views\View;
use phpOMS\Localization\ISO3166NameEnum;
/**
* ClientManagement class.
@ -54,10 +55,9 @@ final class BackendController extends Controller
$view->setTemplate('/Modules/ClientManagement/Theme/Backend/client-list');
$view->addData('nav', $this->app->moduleManager->get('Navigation')->createNavigationMid(1003102001, $request, $response));
$client = ClientMapper
::with('notes', models: null)
$client = ClientMapper::with('notes', models: null)
::with('contactElements', models: null)
::with('type', 'backend_image', models: [Media::class]) // @todo: it would be nicer if I coult say files:type or files/type and remove the models parameter?
//::with('type', 'backend_image', models: [Media::class]) // @todo: it would be nicer if I coult say files:type or files/type and remove the models parameter? @todo: uncommented for now because the type is also part of client and therefore bug. that's the problem with a mix of black/whitelisting in the datamapper with the "with" feature. make it whitelist only for belongsTo, ownsMany, hasOne, ....
::getAfterPivot(0, null, 25);
$view->addData('client', $client);
@ -163,4 +163,161 @@ final class BackendController extends Controller
return $view;
}
/**
* Routing end-point for application behaviour.
*
* @param RequestAbstract $request Request
* @param ResponseAbstract $response Response
* @param mixed $data Generic data
*
* @return RenderableInterface
*
* @since 1.0.0
* @codeCoverageIgnore
*/
public function viewClientAnalysis(RequestAbstract $request, ResponseAbstract $response, $data = null) : RenderableInterface
{
$head = $response->get('Content')->getData('head');
$head->addAsset(AssetType::CSS, 'Resources/chartjs/Chartjs/chart.css');
$head->addAsset(AssetType::JSLATE, 'Resources/chartjs/Chartjs/chart.js');
$head->addAsset(AssetType::JSLATE, 'Modules/ClientManagement/Controller.js', ['type' => 'module']);
$view = new View($this->app->l11nManager, $request, $response);
$view->setTemplate('/Modules/ClientManagement/Theme/Backend/client-analysis');
$view->addData('nav', $this->app->moduleManager->get('Navigation')->createNavigationMid(1001602001, $request, $response));
//
$monthlySalesCosts = [];
for ($i = 1; $i < 13; ++$i) {
$monthlySalesCosts[] = [
'net_sales' => $sales = \mt_rand(1200000000, 2000000000),
'net_costs' => (int) ($sales * \mt_rand(25, 55) / 100),
'year' => 2020,
'month' => $i,
];
}
$view->addData('monthlySalesCosts', $monthlySalesCosts);
//
$salesCustomer = [];
for ($i = 1; $i < 13; ++$i) {
$salesCustomer[] = [
'net_sales' => $sales = \mt_rand(1200000000, 2000000000),
'customers' => \mt_rand(200, 400),
'year' => 2020,
'month' => $i,
];
}
$view->addData('salesCustomer', $salesCustomer);
//
$customerRetention = [];
for ($i = 1; $i < 10; ++$i) {
$customerRetention[] = [
'customers' => \mt_rand(200, 400),
'year' => \date('y') - 9 + $i,
];
}
$view->addData('customerRetention', $customerRetention);
//
$customerRegion = [
'Europe' => (int) (\mt_rand(200, 400) / 4),
'America' => (int) (\mt_rand(200, 400) / 4),
'Asia' => (int) (\mt_rand(200, 400) / 4),
'Africa' => (int) (\mt_rand(200, 400) / 4),
'CIS' => (int) (\mt_rand(200, 400) / 4),
'Other' => (int) (\mt_rand(200, 400) / 4),
];
$view->addData('customerRegion', $customerRegion);
//
$customersRep = [];
for ($i = 1; $i < 13; ++$i) {
$customersRep['Rep ' . $i] = [
'customers' => (int) (\mt_rand(200, 400) / 12),
];
}
\uasort($customersRep, function($a, $b) { return $b['customers'] <=> $a['customers']; });
$view->addData('customersRep', $customersRep);
//
$customersCountry = [];
for ($i = 1; $i < 13; ++$i) {
$country = ISO3166NameEnum::getRandom();
$customersCountry[\substr($country, 0, 20)] = [
'customers' => (int) (\mt_rand(200, 400) / 12),
];
}
\uasort($customersCountry, function($a, $b) { return $b['customers'] <=> $a['customers']; });
$view->addData('customersCountry', $customersCountry);
//
$customerGroups = [];
for ($i = 1; $i < 7; ++$i) {
$customerGroups['Group ' . $i] = [
'customers' => (int) (\mt_rand(200, 400) / 12),
];
}
$view->addData('customerGroups', $customerGroups);
//
$salesRegion = [
'Europe' => (int) (\mt_rand(1200000000, 2000000000) / 4),
'America' => (int) (\mt_rand(1200000000, 2000000000) / 4),
'Asia' => (int) (\mt_rand(1200000000, 2000000000) / 4),
'Africa' => (int) (\mt_rand(1200000000, 2000000000) / 4),
'CIS' => (int) (\mt_rand(1200000000, 2000000000) / 4),
'Other' => (int) (\mt_rand(1200000000, 2000000000) / 4),
];
$view->addData('salesRegion', $salesRegion);
//
$salesRep = [];
for ($i = 1; $i < 13; ++$i) {
$salesRep['Rep ' . $i] = [
'net_sales' => (int) (\mt_rand(1200000000, 2000000000) / 12),
];
}
\uasort($salesRep, function($a, $b) { return $b['net_sales'] <=> $a['net_sales']; });
$view->addData('salesRep', $salesRep);
//
$salesCountry = [];
for ($i = 1; $i < 13; ++$i) {
$country = ISO3166NameEnum::getRandom();
$salesCountry[\substr($country, 0, 20)] = [
'net_sales' => (int) (\mt_rand(1200000000, 2000000000) / 12),
];
}
\uasort($salesCountry, function($a, $b) { return $b['net_sales'] <=> $a['net_sales']; });
$view->addData('salesCountry', $salesCountry);
//
$salesGroups = [];
for ($i = 1; $i < 7; ++$i) {
$salesGroups['Group ' . $i] = [
'net_sales' => (int) (\mt_rand(1200000000, 2000000000) / 12),
];
}
$view->addData('salesGroups', $salesGroups);
return $view;
}
}

View File

@ -0,0 +1,882 @@
<?php
/**
* Orange Management
*
* PHP Version 8.0
*
* @package Modules\ClientManagement
* @copyright Dennis Eichhorn
* @license OMS License 1.0
* @version 1.0.0
* @link https://orange-management.org
*/
declare(strict_types=1);
use phpOMS\Localization\Money;
/* @todo: single month/quarter/fiscal year/calendar year */
/* @todo: time range (<= 12 month = monthly view; else annual view/comparison) */
/**
* @var \phpOMS\Views\View $this
*/
echo $this->getData('nav')->render();
?>
<div class="tabview tab-2">
<div class="box">
<ul class="tab-links">
<li><label for="c-tab-1"><?= $this->getHtml('Analysis'); ?></label></li>
<li><label for="c-tab-2"><?= $this->getHtml('Customers'); ?></label></li>
<li><label for="c-tab-3"><?= $this->getHtml('NewCustomers'); ?></label></li>
<li><label for="c-tab-4"><?= $this->getHtml('LostCustomers'); ?></label></li>
<li><label for="c-tab-5"><?= $this->getHtml('Margins'); ?></label></li>
</ul>
</div>
<div class="tab-content">
<input type="radio" id="c-tab-1" name="tabular-2"<?= $this->request->uri->fragment === 'c-tab-1' ? ' checked' : ''; ?>>
<div class="tab">
<div class="row">
<div class="col-xs-12 col-lg-6">
<section class="portlet">
<div class="portlet-head"><?= $this->getHtml('Filter'); ?></div>
<form>
<div class="portlet-body">
<table class="layout wf-100">
<tr><td><label for="iId"><?= $this->getHtml('Client'); ?></label>
<tr><td><input type="text" id="iName1" name="name1" required>
</table>
</div>
</form>
</section>
</div>
</div>
</div>
<input type="radio" id="c-tab-2" name="tabular-2"<?= $this->request->uri->fragment === 'c-tab-2' ? ' checked' : ''; ?>>
<div class="tab">
<div class="row">
<div class="col-xs-12 col-lg-6">
<section class="portlet">
<div class="portlet-head">
Sales / Customers
<?php include __DIR__ . '/../../../../Web/Backend/Themes/popup-export-data.tpl.php'; ?>
</div>
<?php $salesCustomer = $this->getData('salesCustomer'); ?>
<div class="portlet-body">
<canvas id="sales-region" data-chart='{
"type": "bar",
"data": {
"labels": [
<?php
$temp = [];
foreach ($salesCustomer as $monthly) {
$temp[] = $monthly['month'] . '/' . \substr((string) $monthly['year'], -2);
}
?>
<?= '"' . \implode('", "', $temp) . '"'; ?>
],
"datasets": [
{
"label": "<?= $this->getHtml('Customers'); ?>",
"type": "line",
"data": [
<?php
$temp = [];
foreach ($salesCustomer as $monthly) {
$temp[] = ((int) $monthly['customers']);
}
?>
<?= \implode(',', $temp); ?>
],
"yAxisID": "axis-2",
"fill": false,
"borderColor": "rgb(255, 99, 132)",
"backgroundColor": "rgb(255, 99, 132)",
"tension": 0.0
},
{
"label": "<?= $this->getHtml('Sales'); ?>",
"type": "bar",
"data": [
<?php
$temp = [];
foreach ($salesCustomer as $monthly) {
$temp[] = ((int) $monthly['net_sales']) / 1000;
}
?>
<?= \implode(',', $temp); ?>
],
"yAxisID": "axis-1",
"fill": false,
"borderColor": "rgb(54, 162, 235)",
"backgroundColor": "rgb(54, 162, 235)",
"tension": 0.0
}
]
},
"options": {
"title": {
"display": false,
"text": "Sales / Customers"
},
"scales": {
"yAxes": [
{
"id": "axis-1",
"display": true,
"position": "left"
},
{
"id": "axis-2",
"display": true,
"position": "right",
"scaleLabel": {
"display": true,
"labelString": "<?= $this->getHtml('Customers'); ?>"
},
"gridLines": {
"display": false
}
}
]
}
}
}'></canvas>
<div class="more-container">
<input id="more-customer-sales" type="checkbox">
<label for="more-customer-sales">
<span>Data</span>
<i class="fa fa-chevron-right expand"></i>
</label>
<div>
<table class="default">
<thead>
<tr>
<td>Month
<td>Sales
<td>Customer count
<tbody>
<?php
$sum1 = 0;
$sum2 = 0;
foreach ($salesCustomer as $values) :
$sum1 += ((int) $values['net_sales']) / 1000;
$sum2 += ((int) $values['customers']);
?>
<tr>
<td><?= $values['month'] . '/' . \substr((string) $values['year'], -2) ?>
<td><?= (new Money(((int) $values['net_sales']) / 1000))->getCurrency(); ?>
<td><?= ((int) $values['customers']); ?>
<?php endforeach; ?>
<tr>
<td>Total
<td><?= (new Money($sum1))->getCurrency(); ?>
<td><?= (int) ($sum2 / 12); ?>
</table>
</div>
</div>
</div>
</section>
</div>
<div class="col-xs-12 col-lg-6">
<section class="portlet">
<?php $customerRetention = $this->getData('customerRetention'); ?>
<div class="portlet-body">
<canvas id="sales-region" data-chart='{
"type": "bar",
"data": {
"labels": [
<?php
$temp = [];
foreach ($customerRetention as $monthly) {
$temp[] = (string) $monthly['year'];
}
?>
<?= '"' . \implode('", "', $temp) . '"'; ?>
],
"datasets": [
{
"label": "<?= $this->getHtml('Retention'); ?>",
"type": "line",
"data": [
<?php
$temp = [];
foreach ($customerRetention as $monthly) {
$temp[] = ((int) $monthly['customers']);
}
?>
<?= \implode(',', $temp); ?>
],
"yAxisID": "axis-1",
"fill": false,
"borderColor": "rgb(54, 162, 235)",
"backgroundColor": "rgb(54, 162, 235)",
"tension": 0.0
}
]
},
"options": {
"title": {
"display": true,
"text": "Customer retention"
},
"scales": {
"yAxes": [
{
"id": "axis-1",
"display": true,
"position": "left"
}
]
}
}
}'></canvas>
<table class="default">
<thead>
<tr>
<td>Year
<td>Retention
<tbody>
<?php
$sum1 = 0;
foreach ($customerRetention as $values) :
$sum1 += ((int) $values['customers']);
?>
<tr>
<td><?= \substr((string) $values['year'], -2) ?>
<td><?= ((int) $values['customers']); ?>
<?php endforeach; ?>
<tr>
<td>Avg.
<td><?= $sum1 / 12; ?>
</table>
</div>
</section>
</div>
<div class="col-xs-12 col-lg-6">
<section class="portlet">
<?php $customerRegion = $this->getData('customerRegion'); ?>
<div class="portlet-body">
<canvas id="sales-region" data-chart='{
"type": "pie",
"data": {
"labels": [
"Europe", "America", "Asia", "Africa", "CIS", "Other"
],
"datasets": [{
"data": [
<?= (int) ($customerRegion['Europe'] ?? 0); ?>,
<?= (int) ($customerRegion['America'] ?? 0); ?>,
<?= (int) ($customerRegion['Asia'] ?? 0); ?>,
<?= (int) ($customerRegion['Africa'] ?? 0); ?>,
<?= (int) ($customerRegion['CIS'] ?? 0); ?>,
<?= (int) ($customerRegion['Other'] ?? 0); ?>
],
"backgroundColor": [
"rgb(255, 99, 132)",
"rgb(255, 159, 64)",
"rgb(255, 205, 86)",
"rgb(75, 192, 192)",
"rgb(54, 162, 235)",
"rgb(153, 102, 255)"
]
}]
},
"options": {
"title": {
"display": true,
"text": "Customers per region"
}
}
}'></canvas>
<table class="default">
<thead>
<tr>
<td>Region
<td>Customer count
<tbody>
<?php
$sum = 0;
foreach ($customerRegion as $region => $values) : $sum += $values; ?>
<tr>
<td><?= $region; ?>
<td><?= $values; ?>
<?php endforeach; ?>
<tr>
<td>Total
<td><?= $sum; ?>
</table>
</div>
</section>
</div>
<div class="col-xs-12 col-lg-6">
<section class="portlet">
<?php $customersRep = $this->getData('customersRep'); ?>
<div class="portlet-body">
<canvas id="sales-region" data-chart='{
"type": "horizontalBar",
"data": {
"labels": [
<?php
$temp = [];
foreach ($customersRep as $name => $rep) {
$temp[] = $name;
}
?>
<?= '"' . \implode('", "', $temp) . '"'; ?>
],
"datasets": [
{
"label": "<?= $this->getHtml('Customers'); ?>",
"type": "horizontalBar",
"data": [
<?php
$temp = [];
foreach ($customersRep as $values) {
$temp[] = ((int) $values['customers']);
}
?>
<?= \implode(',', $temp); ?>
],
"fill": false,
"borderColor": "rgb(54, 162, 235)",
"backgroundColor": "rgb(54, 162, 235)",
"tension": 0.0
}
]
},
"options": {
"title": {
"display": true,
"text": "Customers per rep"
}
}
}'></canvas>
<table class="default">
<thead>
<tr>
<td>Rep
<td>Customer count
<tbody>
<?php
$sum = 0;
foreach ($customersRep as $rep => $values) : $sum += $values['customers']; ?>
<tr>
<td><?= $rep; ?>
<td><?= $values['customers']; ?>
<?php endforeach; ?>
<tr>
<td>Total
<td><?= $sum; ?>
</table>
</div>
</section>
</div>
<div class="col-xs-12 col-lg-6">
<section class="portlet">
<?php $customersCountry = $this->getData('customersCountry'); ?>
<div class="portlet-body">
<canvas id="sales-region" data-chart='{
"type": "horizontalBar",
"data": {
"labels": [
<?php
$temp = [];
foreach ($customersCountry as $name => $country) {
$temp[] = $name;
}
?>
<?= '"' . \implode('", "', $temp) . '"'; ?>
],
"datasets": [
{
"label": "<?= $this->getHtml('Customers'); ?>",
"type": "horizontalBar",
"data": [
<?php
$temp = [];
foreach ($customersCountry as $values) {
$temp[] = ((int) $values['customers']);
}
?>
<?= \implode(',', $temp); ?>
],
"fill": false,
"borderColor": "rgb(54, 162, 235)",
"backgroundColor": "rgb(54, 162, 235)",
"tension": 0.0
}
]
},
"options": {
"title": {
"display": true,
"text": "Customers per country"
}
}
}'></canvas>
<table class="default">
<thead>
<tr>
<td>Country
<td>Customer count
<tbody>
<?php
$sum = 0;
foreach ($customersCountry as $country => $values) : $sum += $values['customers']; ?>
<tr>
<td><?= $country; ?>
<td><?= $values['customers']; ?>
<?php endforeach; ?>
<tr>
<td>Total
<td><?= $sum; ?>
</table>
</div>
</section>
</div>
<div class="col-xs-12 col-lg-6">
<section class="portlet">
<?php $customerGroups = $this->getData('customerGroups'); ?>
<div class="portlet-body">
<canvas id="sales-region" data-chart='{
"type": "pie",
"data": {
"labels": [
<?php
$temp = [];
foreach ($customerGroups as $name => $groups) {
$temp[] = $name;
}
?>
<?= '"' . \implode('", "', $temp) . '"'; ?>
],
"datasets": [{
"data": [
<?php
$temp = [];
foreach ($customerGroups as $values) {
$temp[] = ((int) $values['customers']);
}
?>
<?= \implode(',', $temp); ?>
],
"backgroundColor": [
"rgb(255, 99, 132)",
"rgb(255, 159, 64)",
"rgb(255, 205, 86)",
"rgb(75, 192, 192)",
"rgb(54, 162, 235)",
"rgb(153, 102, 255)"
]
}]
},
"options": {
"title": {
"display": true,
"text": "Customers per group"
}
}
}'></canvas>
<table class="default">
<thead>
<tr>
<td>Groups
<td>Customer count
<tbody>
<?php
$sum = 0;
foreach ($customerGroups as $groups => $values) : $sum += $values['customers']; ?>
<tr>
<td><?= $groups; ?>
<td><?= $values['customers']; ?>
<?php endforeach; ?>
<tr>
<td>Total
<td><?= $sum; ?>
</table>
</div>
</section>
</div>
<div class="col-xs-12 col-lg-6">
<section class="portlet">
<?php $salesRegion = $this->getData('salesRegion'); ?>
<div class="portlet-body">
<canvas id="sales-region" data-chart='{
"type": "pie",
"data": {
"labels": [
"Europe", "America", "Asia", "Africa", "CIS", "Other"
],
"datasets": [{
"data": [
<?= (int) ($salesRegion['Europe'] ?? 0); ?>,
<?= (int) ($salesRegion['America'] ?? 0); ?>,
<?= (int) ($salesRegion['Asia'] ?? 0); ?>,
<?= (int) ($salesRegion['Africa'] ?? 0); ?>,
<?= (int) ($salesRegion['CIS'] ?? 0); ?>,
<?= (int) ($salesRegion['Other'] ?? 0); ?>
],
"backgroundColor": [
"rgb(255, 99, 132)",
"rgb(255, 159, 64)",
"rgb(255, 205, 86)",
"rgb(75, 192, 192)",
"rgb(54, 162, 235)",
"rgb(153, 102, 255)"
]
}]
},
"options": {
"title": {
"display": true,
"text": "Sales per region"
}
}
}'></canvas>
</div>
</section>
</div>
<div class="col-xs-12 col-lg-6">
<section class="portlet">
<?php $salesCountry = $this->getData('salesCountry'); ?>
<div class="portlet-body">
<canvas id="sales-region" data-chart='{
"type": "horizontalBar",
"data": {
"labels": [
<?php
$temp = [];
foreach ($salesCountry as $name => $country) {
$temp[] = $name;
}
?>
<?= '"' . \implode('", "', $temp) . '"'; ?>
],
"datasets": [
{
"label": "<?= $this->getHtml('Sales'); ?>",
"type": "horizontalBar",
"data": [
<?php
$temp = [];
foreach ($salesCountry as $values) {
$temp[] = ((int) $values['net_sales']);
}
?>
<?= \implode(',', $temp); ?>
],
"fill": false,
"borderColor": "rgb(54, 162, 235)",
"backgroundColor": "rgb(54, 162, 235)",
"tension": 0.0
}
]
},
"options": {
"title": {
"display": true,
"text": "Sales per country"
}
}
}'></canvas>
</div>
</section>
</div>
<div class="col-xs-12 col-lg-6">
<section class="portlet">
<?php $salesGroups = $this->getData('salesGroups'); ?>
<div class="portlet-body">
<canvas id="sales-region" data-chart='{
"type": "pie",
"data": {
"labels": [
<?php
$temp = [];
foreach ($salesGroups as $name => $groups) {
$temp[] = $name;
}
?>
<?= '"' . \implode('", "', $temp) . '"'; ?>
],
"datasets": [{
"data": [
<?php
$temp = [];
foreach ($salesGroups as $values) {
$temp[] = ((int) $values['net_sales']) / 1000;
}
?>
<?= \implode(',', $temp); ?>
],
"backgroundColor": [
"rgb(255, 99, 132)",
"rgb(255, 159, 64)",
"rgb(255, 205, 86)",
"rgb(75, 192, 192)",
"rgb(54, 162, 235)",
"rgb(153, 102, 255)"
]
}]
},
"options": {
"title": {
"display": true,
"text": "Sales per group"
}
}
}'></canvas>
</div>
</section>
</div>
</div>
</div>
<input type="radio" id="c-tab-3" name="tabular-2"<?= $this->request->uri->fragment === 'c-tab-3' ? ' checked' : ''; ?>>
<div class="tab">
<div class="row">
<div class="col-xs-12 col-lg-6">
<section class="portlet">
<div class="portlet-head">New customers</div>
<div class="portlet-body">
Shows new customers and their sales
</div>
</section>
</div>
<div class="col-xs-12 col-lg-6">
<section class="portlet">
<div class="portlet-head">New customers per region</div>
<div class="portlet-body">
</div>
</section>
</div>
<div class="col-xs-12 col-lg-6">
<section class="portlet">
<div class="portlet-head">New customers per sales rep</div>
<div class="portlet-body">
</div>
</section>
</div>
<div class="col-xs-12 col-lg-6">
<section class="portlet">
<div class="portlet-head">New customers per sales group</div>
<div class="portlet-body">
</div>
</section>
</div>
<div class="col-xs-12 col-lg-6">
<section class="portlet">
<div class="portlet-head">New customers per customer group</div>
<div class="portlet-body">
</div>
</section>
</div>
<div class="col-xs-12 col-lg-6">
<section class="portlet">
<div class="portlet-head">New customers sales per customer group</div>
<div class="portlet-body">
</div>
</section>
</div>
</div>
</div>
<input type="radio" id="c-tab-4" name="tabular-2"<?= $this->request->uri->fragment === 'c-tab-4' ? ' checked' : ''; ?>>
<div class="tab">
<div class="row">
<div class="col-xs-12 col-lg-6">
<section class="portlet">
<div class="portlet-head">Lost customers</div>
<div class="portlet-body">
Shows lost customers and their sales
</div>
</section>
</div>
<div class="col-xs-12 col-lg-6">
<section class="portlet">
<div class="portlet-head">Lost customers per region</div>
<div class="portlet-body">
</div>
</section>
</div>
<div class="col-xs-12 col-lg-6">
<section class="portlet">
<div class="portlet-head">Lost customers per sales rep</div>
<div class="portlet-body">
</div>
</section>
</div>
<div class="col-xs-12 col-lg-6">
<section class="portlet">
<div class="portlet-head">Lost customers per sales group</div>
<div class="portlet-body">
</div>
</section>
</div>
<div class="col-xs-12 col-lg-6">
<section class="portlet">
<div class="portlet-head">Lost customers per customer group</div>
<div class="portlet-body">
</div>
</section>
</div>
<div class="col-xs-12 col-lg-6">
<section class="portlet">
<div class="portlet-head">Lost customers sales per customer group</div>
<div class="portlet-body">
</div>
</section>
</div>
</div>
</div>
<input type="radio" id="c-tab-5" name="tabular-2"<?= $this->request->uri->fragment === 'c-tab-5' ? ' checked' : ''; ?>>
<div class="tab">
<div class="row">
<div class="col-xs-12 col-lg-6">
<section class="portlet">
<?php $monthlySalesCosts = $this->getData('monthlySalesCosts'); ?>
<div class="portlet-body">
<canvas id="sales-region" data-chart='{
"type": "bar",
"data": {
"labels": [
<?php
$temp = [];
foreach ($monthlySalesCosts as $monthly) {
$temp[] = $monthly['month'] . '/' . \substr((string) $monthly['year'], -2);
}
?>
<?= '"' . \implode('", "', $temp) . '"'; ?>
],
"datasets": [
{
"label": "<?= $this->getHtml('Margin'); ?>",
"type": "line",
"data": [
<?php
$temp = [];
foreach ($monthlySalesCosts as $monthly) {
$temp[] = \round(((((int) $monthly['net_sales']) - ((int) $monthly['net_costs'])) / ((int) $monthly['net_sales'])) * 100, 2);
}
?>
<?= \implode(',', $temp); ?>
],
"yAxisID": "axis-2",
"fill": false,
"borderColor": "rgb(255, 99, 132)",
"backgroundColor": "rgb(255, 99, 132)",
"tension": 0.0
},
{
"label": "<?= $this->getHtml('Sales'); ?>",
"type": "bar",
"data": [
<?php
$temp = [];
foreach ($monthlySalesCosts as $monthly) {
$temp[] = ((int) $monthly['net_sales']) / 1000;
}
?>
<?= \implode(',', $temp); ?>
],
"yAxisID": "axis-1",
"backgroundColor": "rgb(54, 162, 235)"
}
]
},
"options": {
"title": {
"display": true,
"text": "Sales / Margin"
},
"scales": {
"yAxes": [
{
"id": "axis-1",
"display": true,
"position": "left"
},
{
"id": "axis-2",
"display": true,
"position": "right",
"scaleLabel": {
"display": true,
"labelString": "<?= $this->getHtml('Margin'); ?> %"
},
"gridLines": {
"display": false
},
"beginAtZero": true,
"ticks": {
"min": 0,
"max": 100,
"stepSize": 10
}
}
]
}
}
}'></canvas>
</div>
</section>
</div>
<div class="col-xs-12 col-lg-6">
<section class="portlet">
<div class="portlet-head">Margins per region</div>
<div class="portlet-body">
</div>
</section>
</div>
<div class="col-xs-12 col-lg-6">
<section class="portlet">
<div class="portlet-head">Margins per sales rep</div>
<div class="portlet-body">
</div>
</section>
</div>
<div class="col-xs-12 col-lg-6">
<section class="portlet">
<div class="portlet-head">Margins per sales group</div>
<div class="portlet-body">
</div>
</section>
</div>
<div class="col-xs-12 col-lg-6">
<section class="portlet">
<div class="portlet-head">Margins per customer group</div>
<div class="portlet-body">
</div>
</section>
</div>
</div>
</div>
</div>
</div>

View File

@ -23,7 +23,7 @@ echo $this->getData('nav')->render(); ?>
<div class="col-xs-12">
<section class="portlet">
<div class="portlet-head"><?= $this->getHtml('Clients'); ?><i class="fa fa-download floatRight download btn"></i></div>
<table id="iSalesClientList" class="default">
<table id="iSalesClientList" class="default sticky">
<thead>
<tr>
<td>