This commit is contained in:
Dennis Eichhorn 2023-05-31 15:59:17 +00:00
parent b695336a7a
commit cb4224bca4
6 changed files with 585 additions and 166 deletions

View File

@ -1,10 +1,8 @@
import { Autoloader } from '../../jsOMS/Autoloader.js';
import { NotificationMessage } from '../../jsOMS/Message/Notification/NotificationMessage.js';
import { NotificationType } from '../../jsOMS/Message/Notification/NotificationType.js';
Autoloader.defineNamespace('jsOMS.Modules');
jsOMS.Modules.SupplierManager = class {
jsOMS.Modules.SupplierManagement = class {
/**
* @constructor
*
@ -17,24 +15,31 @@ jsOMS.Modules.SupplierManager = class {
bind (id)
{
const e = typeof id === 'undefined' ? document.getElementsByTagName('canvas') : [document.getElementById(id)],
length = e.length;
const charts = typeof id === 'undefined' ? document.getElementsByTagName('canvas') : [document.getElementById(id)];
let length = charts.length;
for (let i = 0; i < length; ++i) {
if (e[i].getAttribute('data-chart') === null
&& e[i].getAttribute('data-chart') !== 'undefined'
if (charts[i].getAttribute('data-chart') === null
&& charts[i].getAttribute('data-chart') !== 'undefined'
) {
continue;
}
this.bindElement(e[i]);
this.bindChart(charts[i]);
}
const maps = typeof id === 'undefined' ? document.getElementsByClassName('map') : [document.getElementById(id)];
length = maps.length;
for (let i = 0; i < length; ++i) {
this.bindMap(maps[i]);
}
};
bindElement (chart)
bindChart (chart)
{
if (typeof chart === 'undefined' || !chart) {
jsOMS.Log.Logger.instance.error('Invalid chart: ' + chart, 'SupplierManagementController');
jsOMS.Log.Logger.instance.error('Invalid chart: ' + chart, 'SupplierManagement');
return;
}
@ -44,6 +49,42 @@ jsOMS.Modules.SupplierManager = class {
const myChart = new Chart(chart.getContext('2d'), data);
};
bindMap (map)
{
if (typeof map === 'undefined' || !map) {
jsOMS.Log.Logger.instance.error('Invalid map: ' + map, 'SupplierManagement');
return;
}
const mapObj = new OpenLayers.Map(map.getAttribute('id'), {
controls: [
new OpenLayers.Control.Navigation(
{
zoomBoxEnabled: true,
zoomWheelEnabled: false
}
),
new OpenLayers.Control.Zoom(),
new OpenLayers.Control.Attribution()
]
});
mapObj.addLayer(new OpenLayers.Layer.OSM());
const fromProjection = new OpenLayers.Projection("EPSG:4326"); // Transform from WGS 1984
const toProjection = new OpenLayers.Projection("EPSG:900913"); // to Spherical Mercator Projection
const position = new OpenLayers.LonLat(map.getAttribute('data-lon'), map.getAttribute('data-lat')).transform(fromProjection, toProjection);
const zoom = 12;
const markers = new OpenLayers.Layer.Markers("Markers");
mapObj.addLayer(markers);
markers.addMarker(new OpenLayers.Marker(position));
mapObj.setCenter(position, zoom);
};
};
window.omsApp.moduleManager.get('SupplierManager').bind();
window.omsApp.moduleManager.get('SupplierManagement').bind();

View File

@ -15,12 +15,15 @@ declare(strict_types=1);
namespace Modules\SupplierManagement\Controller;
use Modules\Billing\Models\PurchaseBillMapper;
use Modules\Media\Models\MediaMapper;
use Modules\Media\Models\MediaTypeMapper;
use Modules\SupplierManagement\Models\SupplierAttributeTypeL11nMapper;
use Modules\SupplierManagement\Models\SupplierAttributeTypeMapper;
use Modules\SupplierManagement\Models\SupplierAttributeValueMapper;
use Modules\SupplierManagement\Models\SupplierMapper;
use phpOMS\Asset\AssetType;
use phpOMS\Contract\RenderableInterface;
use phpOMS\DataStorage\Database\Query\Builder;
use phpOMS\DataStorage\Database\Query\OrderType;
use phpOMS\Localization\Money;
use phpOMS\Message\RequestAbstract;
@ -196,11 +199,11 @@ final class BackendController extends Controller
*/
public function viewSupplierManagementSupplierProfile(RequestAbstract $request, ResponseAbstract $response, mixed $data = null) : RenderableInterface
{
/** @var \phpOMS\Model\Html\Head $head */
$head = $response->get('Content')->head;
$head = $response->data['Content']->head;
$head->addAsset(AssetType::CSS, 'Resources/chartjs/Chartjs/chart.css');
$head->addAsset(AssetType::JSLATE, 'Resources/chartjs/Chartjs/chart.js');
$head->addAsset(AssetType::JSLATE, 'Modules/SupplierManagement/Controller.js', ['type' => 'module']);
$head->addAsset(AssetType::JSLATE, 'Resources/OpenLayers/OpenLayers.js');
$head->addAsset(AssetType::JSLATE, 'Modules/ClientManagement/Controller.js', ['type' => 'module']);
$view = new View($this->app->l11nManager, $request, $response);
$view->setTemplate('/Modules/SupplierManagement/Theme/Backend/supplier-profile');
@ -218,6 +221,34 @@ final class BackendController extends Controller
$view->data['supplier'] = $supplier;
// Get item profile image
// It might not be part of the 5 newest item files from above
// @todo: It would be nice to have something like this as a default method in the model e.g.
// ItemManagement::getRelations()->with('types')->where(...);
// This should return the relations and NOT the model itself
$query = new Builder($this->app->dbPool->get());
$results = $query->selectAs(SupplierMapper::HAS_MANY['files']['external'], 'file')
->from(SupplierMapper::TABLE)
->leftJoin(SupplierMapper::HAS_MANY['files']['table'])
->on(SupplierMapper::HAS_MANY['files']['table'] . '.' . SupplierMapper::HAS_MANY['files']['self'], '=', SupplierMapper::TABLE . '.' . SupplierMapper::PRIMARYFIELD)
->leftJoin(MediaMapper::TABLE)
->on(SupplierMapper::HAS_MANY['files']['table'] . '.' . SupplierMapper::HAS_MANY['files']['external'], '=', MediaMapper::TABLE . '.' . MediaMapper::PRIMARYFIELD)
->leftJoin(MediaMapper::HAS_MANY['types']['table'])
->on(MediaMapper::TABLE . '.' . MediaMapper::PRIMARYFIELD, '=', MediaMapper::HAS_MANY['types']['table'] . '.' . MediaMapper::HAS_MANY['types']['self'])
->leftJoin(MediaTypeMapper::TABLE)
->on(MediaMapper::HAS_MANY['types']['table'] . '.' . MediaMapper::HAS_MANY['types']['external'], '=', MediaTypeMapper::TABLE . '.' . MediaTypeMapper::PRIMARYFIELD)
->where(SupplierMapper::HAS_MANY['files']['self'], '=', $supplier->id)
->where(MediaTypeMapper::TABLE . '.' . MediaTypeMapper::getColumnByMember('name'), '=', 'supplier_profile_image');
$clientImage = MediaMapper::get()
->with('types')
->where('id', $results)
->limit(1)
->execute();
$view->data['clientImage'] = $clientImage;
// stats
if ($this->app->moduleManager->isActive('Billing')) {
$ytd = PurchaseBillMapper::getPurchaseBySupplierId($supplier->id, new SmartDateTime('Y-01-01'), new SmartDateTime('now'));

View File

@ -27,7 +27,6 @@ echo $this->data['nav']->render(); ?>
<table id="iPurchaseSupplierList" class="default sticky">
<thead>
<tr>
<td>
<td><?= $this->getHtml('ID', '0', '0'); ?>
<label for="iPurchaseSupplierList-sort-1">
<input type="radio" name="iPurchaseSupplierList-sort" id="iPurchaseSupplierList-sort-1">
@ -102,15 +101,11 @@ echo $this->data['nav']->render(); ?>
</label>
<tbody>
<?php $count = 0; foreach ($suppliers as $key => $value) : ++$count;
$url = UriFactory::build('{/base}/purchase/supplier/profile?{?}&id=' . $value->id);
$image = $value->getFileByTypeName('supplier_profile_image'); ?>
$url = UriFactory::build('{/base}/purchase/supplier/profile?{?}&id=' . $value->id);
?>
<tr data-href="<?= $url; ?>">
<td><a href="<?= $url; ?>"><img alt="<?= $this->getHtml('IMG_alt_supplier'); ?>" width="30" loading="lazy" class="item-image"
src="<?= $image->id === 0 ?
UriFactory::build('Web/Backend/img/user_default_' . \mt_rand(1, 6) .'.png') :
UriFactory::build('{/base}/' . $image->getPath()); ?>"></a>
<td data-label="<?= $this->getHtml('ID', '0', '0'); ?>"><a href="<?= $url; ?>"><?= $this->printHtml($value->number); ?></a>
<td data-label="<?= $this->getHtml('Name'); ?>"><a href="<?= $url; ?>"><?= $this->printHtml($value->profile->account->name1); ?> <?= $this->printHtml($value->profile->account->name2); ?></a>
<td data-label="<?= $this->getHtml('Name'); ?>"><a href="<?= $url; ?>"><?= $this->printHtml($value->account->name1); ?> <?= $this->printHtml($value->account->name2); ?></a>
<td data-label="<?= $this->getHtml('City'); ?>"><a href="<?= $url; ?>"><?= $this->printHtml($value->mainAddress->city); ?></a>
<td data-label="<?= $this->getHtml('Zip'); ?>"><a href="<?= $url; ?>"><?= $this->printHtml($value->mainAddress->postal); ?></a>
<td data-label="<?= $this->getHtml('Address'); ?>"><a href="<?= $url; ?>"><?= $this->printHtml($value->mainAddress->address); ?></a>

View File

@ -0,0 +1,194 @@
<?php
/**
* Karaka
*
* PHP Version 8.1
*
* @package Modules\Billing
* @copyright Dennis Eichhorn
* @license OMS License 2.0
* @version 1.0.0
* @link https://jingga.app
*/
declare(strict_types=1);
use phpOMS\Uri\UriFactory;
$bills = $this->data['newestInvoices'] ?? [];
?>
<div class="row">
<div class="col-xs-12">
<div class="portlet">
<div class="portlet-head"><?= $this->getHtml('Bills'); ?><i class="lni lni-download download btn end-xs"></i></div>
<table id="billList" class="default">
<thead>
<tr>
<td><label class="checkbox" for="iBillSelect-">
<input type="checkbox" id="iBillSelect-" name="billselect">
<span class="checkmark"></span>
</label>
<td><?= $this->getHtml('ID', '0', '0'); ?>
<label for="billList-sort-1">
<input type="radio" name="billList-sort" id="billList-sort-1">
<i class="sort-asc fa fa-chevron-up"></i>
</label>
<label for="billList-sort-2">
<input type="radio" name="billList-sort" id="billList-sort-2">
<i class="sort-desc fa fa-chevron-down"></i>
</label>
<label>
<i class="filter fa fa-filter"></i>
</label>
<td><?= $this->getHtml('Type'); ?>
<label for="billList-sort-3">
<input type="radio" name="billList-sort" id="billList-sort-3">
<i class="sort-asc fa fa-chevron-up"></i>
</label>
<label for="billList-sort-4">
<input type="radio" name="billList-sort" id="billList-sort-4">
<i class="sort-desc fa fa-chevron-down"></i>
</label>
<label>
<i class="filter fa fa-filter"></i>
</label>
<td><?= $this->getHtml('ClientID'); ?>
<label for="billList-sort-5">
<input type="radio" name="billList-sort" id="billList-sort-5">
<i class="sort-asc fa fa-chevron-up"></i>
</label>
<label for="billList-sort-6">
<input type="radio" name="billList-sort" id="billList-sort-6">
<i class="sort-desc fa fa-chevron-down"></i>
</label>
<label>
<i class="filter fa fa-filter"></i>
</label>
<td class="wf-100"><?= $this->getHtml('Client'); ?>
<label for="billList-sort-7">
<input type="radio" name="billList-sort" id="billList-sort-7">
<i class="sort-asc fa fa-chevron-up"></i>
</label>
<label for="billList-sort-8">
<input type="radio" name="billList-sort" id="billList-sort-8">
<i class="sort-desc fa fa-chevron-down"></i>
</label>
<label>
<i class="filter fa fa-filter"></i>
</label>
<td class="wf-100"><?= $this->getHtml('Address'); ?>
<label for="billList-sort-9">
<input type="radio" name="billList-sort" id="billList-sort-9">
<i class="sort-asc fa fa-chevron-up"></i>
</label>
<label for="billList-sort-10">
<input type="radio" name="billList-sort" id="billList-sort-10">
<i class="sort-desc fa fa-chevron-down"></i>
</label>
<label>
<i class="filter fa fa-filter"></i>
</label>
<td class="wf-100"><?= $this->getHtml('Postal'); ?>
<label for="billList-sort-11">
<input type="radio" name="billList-sort" id="billList-sort-11">
<i class="sort-asc fa fa-chevron-up"></i>
</label>
<label for="billList-sort-12">
<input type="radio" name="billList-sort" id="billList-sort-12">
<i class="sort-desc fa fa-chevron-down"></i>
</label>
<label>
<i class="filter fa fa-filter"></i>
</label>
<td class="wf-100"><?= $this->getHtml('City'); ?>
<label for="billList-sort-13">
<input type="radio" name="billList-sort" id="billList-sort-13">
<i class="sort-asc fa fa-chevron-up"></i>
</label>
<label for="billList-sort-14">
<input type="radio" name="billList-sort" id="billList-sort-14">
<i class="sort-desc fa fa-chevron-down"></i>
</label>
<label>
<i class="filter fa fa-filter"></i>
</label>
<td class="wf-100"><?= $this->getHtml('Country'); ?>
<label for="billList-sort-15">
<input type="radio" name="billList-sort" id="billList-sort-15">
<i class="sort-asc fa fa-chevron-up"></i>
</label>
<label for="billList-sort-16">
<input type="radio" name="billList-sort" id="billList-sort-16">
<i class="sort-desc fa fa-chevron-down"></i>
</label>
<label>
<i class="filter fa fa-filter"></i>
</label>
<td><?= $this->getHtml('Net'); ?>
<label for="billList-sort-7">
<input type="radio" name="billList-sort" id="billList-sort-7">
<i class="sort-asc fa fa-chevron-up"></i>
</label>
<label for="billList-sort-18">
<input type="radio" name="billList-sort" id="billList-sort-18">
<i class="sort-desc fa fa-chevron-down"></i>
</label>
<label>
<i class="filter fa fa-filter"></i>
</label>
<td><?= $this->getHtml('Profit'); ?>
<label for="billList-sort-21">
<input type="radio" name="billList-sort" id="billList-sort-21">
<i class="sort-asc fa fa-chevron-up"></i>
</label>
<label for="billList-sort-22">
<input type="radio" name="billList-sort" id="billList-sort-22">
<i class="sort-desc fa fa-chevron-down"></i>
</label>
<label>
<i class="filter fa fa-filter"></i>
</label>
<td><?= $this->getHtml('Created'); ?>
<label for="billList-sort-23">
<input type="radio" name="billList-sort" id="billList-sort-23">
<i class="sort-asc fa fa-chevron-up"></i>
</label>
<label for="billList-sort-24">
<input type="radio" name="billList-sort" id="billList-sort-24">
<i class="sort-desc fa fa-chevron-down"></i>
</label>
<label>
<i class="filter fa fa-filter"></i>
</label>
<tbody>
<?php $count = 0;
/** @var \Modules\Billing\Models\Bill $value */
foreach ($bills as $key => $value) :
++$count;
$url = UriFactory::build('{/base}/purchase/bill?{?}&id=' . $value->id);
?>
<tr data-href="<?= $url; ?>">
<td><label class="checkbox" for="iBillSelect-<?= $key; ?>">
<input type="checkbox" id="iBillSelect-<?= $key; ?>" name="billselect">
<span class="checkmark"></span>
</label>
<td><a href="<?= $url; ?>"><?= $value->getNumber(); ?></a>
<td><a href="<?= $url; ?>"><?= $value->type->getL11n(); ?></a>
<td><a href="<?= $url; ?>"><?= $value->client->number; ?></a>
<td><a href="<?= $url; ?>"><?= $this->printHtml($value->billTo); ?></a>
<td><a href="<?= $url; ?>"><?= $value->billAddress; ?></a>
<td><a href="<?= $url; ?>"><?= $value->billZip; ?></a>
<td><a href="<?= $url; ?>"><?= $value->billCity; ?></a>
<td><a href="<?= $url; ?>"><?= $value->billCountry; ?></a>
<td><a href="<?= $url; ?>"><?= $this->getCurrency($value->netSales); ?></a>
<td><a href="<?= $url; ?>"><?= $this->getCurrency($value->netProfit); ?></a>
<td><a href="<?= $url; ?>"><?= $value->createdAt->format('Y-m-d'); ?></a>
<?php endforeach; ?>
<?php if ($count === 0) : ?>
<tr><td colspan="12" class="empty"><?= $this->getHtml('Empty', '0', '0'); ?>
<?php endif; ?>
</table>
</div>
</div>
</div>

View File

@ -0,0 +1,160 @@
<?php
/**
* Karaka
*
* PHP Version 8.1
*
* @package Modules\ItemManagement
* @copyright Dennis Eichhorn
* @license OMS License 2.0
* @version 1.0.0
* @link https://jingga.app
*/
declare(strict_types=1);
use phpOMS\Uri\UriFactory;
/** @var \phpOMS\Views\View $this */
$items = $this->data['items'] ?? [];
?>
<div class="row">
<div class="col-xs-12">
<section class="portlet">
<div class="portlet-head"><?= $this->getHtml('Items'); ?><i class="lni lni-download download btn end-xs"></i></div>
<table id="iPurchaseItemList" class="default">
<thead>
<tr>
<td><label class="checkbox" for="iPurchaseItemSelect-">
<input type="checkbox" id="iPurchaseItemSelect-" name="itemselect">
<span class="checkmark"></span>
</label>
<td><?= $this->getHtml('ID', '0', '0'); ?>
<label for="iPurchaseItemList-sort-1">
<input type="radio" name="iPurchaseItemList-sort" id="iPurchaseItemList-sort-1">
<i class="sort-asc fa fa-chevron-up"></i>
</label>
<label for="iPurchaseItemList-sort-2">
<input type="radio" name="iPurchaseItemList-sort" id="iPurchaseItemList-sort-2">
<i class="sort-desc fa fa-chevron-down"></i>
</label>
<label>
<i class="filter fa fa-filter"></i>
</label>
<td class="wf-100"><?= $this->getHtml('Name'); ?>
<label for="iPurchaseItemList-sort-3">
<input type="radio" name="iPurchaseItemList-sort" id="iPurchaseItemList-sort-3">
<i class="sort-asc fa fa-chevron-up"></i>
</label>
<label for="iPurchaseItemList-sort-4">
<input type="radio" name="iPurchaseItemList-sort" id="iPurchaseItemList-sort-4">
<i class="sort-desc fa fa-chevron-down"></i>
</label>
<label>
<i class="filter fa fa-filter"></i>
</label>
<td><?= $this->getHtml('Quantity'); ?>
<label for="iPurchaseItemList-sort-5">
<input type="radio" name="iPurchaseItemList-sort" id="iPurchaseItemList-sort-5">
<i class="sort-asc fa fa-chevron-up"></i>
</label>
<label for="iPurchaseItemList-sort-6">
<input type="radio" name="iPurchaseItemList-sort" id="iPurchaseItemList-sort-6">
<i class="sort-desc fa fa-chevron-down"></i>
</label>
<label>
<i class="filter fa fa-filter"></i>
</label>
<td><?= $this->getHtml('UnitPrice'); ?>
<label for="iPurchaseItemList-sort-7">
<input type="radio" name="iPurchaseItemList-sort" id="iPurchaseItemList-sort-7">
<i class="sort-asc fa fa-chevron-up"></i>
</label>
<label for="iPurchaseItemList-sort-8">
<input type="radio" name="iPurchaseItemList-sort" id="iPurchaseItemList-sort-8">
<i class="sort-desc fa fa-chevron-down"></i>
</label>
<label>
<i class="filter fa fa-filter"></i>
</label>
<td><?= $this->getHtml('Discount'); ?>
<label for="iPurchaseItemList-sort-11">
<input type="radio" name="iPurchaseItemList-sort" id="iPurchaseItemList-sort-11">
<i class="sort-asc fa fa-chevron-up"></i>
</label>
<label for="iPurchaseItemList-sort-12">
<input type="radio" name="iPurchaseItemList-sort" id="iPurchaseItemList-sort-12">
<i class="sort-desc fa fa-chevron-down"></i>
</label>
<label>
<i class="filter fa fa-filter"></i>
</label>
<td><?= $this->getHtml('Discount%'); ?>
<label for="iPurchaseItemList-sort-13">
<input type="radio" name="iPurchaseItemList-sort" id="iPurchaseItemList-sort-13">
<i class="sort-asc fa fa-chevron-up"></i>
</label>
<label for="iPurchaseItemList-sort-14">
<input type="radio" name="iPurchaseItemList-sort" id="iPurchaseItemList-sort-14">
<i class="sort-desc fa fa-chevron-down"></i>
</label>
<label>
<i class="filter fa fa-filter"></i>
</label>
<td><?= $this->getHtml('DiscountBonus'); ?>
<label for="iPurchaseItemList-sort-15">
<input type="radio" name="iPurchaseItemList-sort" id="iPurchaseItemList-sort-15">
<i class="sort-asc fa fa-chevron-up"></i>
</label>
<label for="iPurchaseItemList-sort-16">
<input type="radio" name="iPurchaseItemList-sort" id="iPurchaseItemList-sort-16">
<i class="sort-desc fa fa-chevron-down"></i>
</label>
<label>
<i class="filter fa fa-filter"></i>
</label>
<td><?= $this->getHtml('TotalPrice'); ?>
<label for="iPurchaseItemList-sort-9">
<input type="radio" name="iPurchaseItemList-sort" id="iPurchaseItemList-sort-9">
<i class="sort-asc fa fa-chevron-up"></i>
</label>
<label for="iPurchaseItemList-sort-10">
<input type="radio" name="iPurchaseItemList-sort" id="iPurchaseItemList-sort-10">
<i class="sort-desc fa fa-chevron-down"></i>
</label>
<label>
<i class="filter fa fa-filter"></i>
</label>
<tbody>
<?php
$count = 0;
foreach ($items as $key => $value) :
if ($value->itemNumber === '') {
continue;
}
++$count;
$url = UriFactory::build('{/base}/purchase/item/profile?{?}&id=' . $value->id);
?>
<tr data-href="<?= $url; ?>">
<td><label class="checkbox" for="iPurchaseItemSelect-<?= $key; ?>">
<input type="checkbox" id="iPurchaseItemSelect-<?= $key; ?>" name="itemselect">
<span class="checkmark"></span>
</label>
<td><a href="<?= $url; ?>"><?= $this->printHtml($value->itemNumber); ?></a>
<td><a href="<?= $url; ?>"><?= $this->printHtml($value->itemName); ?></a>
<td><a href="<?= $url; ?>"><?= $this->printHtml((string) $value->getQuantity()); ?></a>
<td><a href="<?= $url; ?>"><?= $this->getcurrency($value->singlePurchasePriceNet); ?></a>
<td>
<td>
<td>
<td><a href="<?= $url; ?>"><?= $this->getcurrency($value->totalPurchasePriceNet); ?></a>
<?php endforeach; ?>
<?php if ($count === 0) : ?>
<tr><td colspan="9" class="empty"><?= $this->getHtml('Empty', '0', '0'); ?>
<?php endif; ?>
</table>
</section>
</div>
</div>

View File

@ -12,7 +12,8 @@
*/
declare(strict_types=1);
use Modules\Profile\Models\ContactType;
use Modules\Admin\Models\ContactType;
use Modules\Media\Models\NullMedia;
use phpOMS\Uri\UriFactory;
$countryCodes = \phpOMS\Localization\ISO3166TwoEnum::getConstants();
@ -22,11 +23,13 @@ $countries = \phpOMS\Localization\ISO3166NameEnum::getConstants();
* @var \Modules\SupplierManagement\Models\Supplier $supplier
*/
$supplier = $this->data['supplier'];
$notes = $supplier->getNotes();
$files = $supplier->files;
$notes = $supplier->getNotes();
$files = $supplier->files;
$newestInvoices = $this->data['newestInvoices'] ?? [];
$monthlyPurchaseCosts = $this->data['monthlyPurchaseCosts'] ?? [];
$supplierImage = $this->getData('supplierImage') ?? new NullMedia();
$newestInvoices = $this->data['newestInvoices'] ?? [];
$monthlySalesCosts = $this->data['monthlySalesCosts'] ?? [];
/**
* @var \phpOMS\Views\View $this
@ -37,24 +40,20 @@ echo $this->data['nav']->render();
<div class="box">
<ul class="tab-links">
<li><label for="c-tab-1"><?= $this->getHtml('Profile'); ?></label></li>
<li><label for="c-tab-2"><?= $this->getHtml('Contact'); ?></label></li>
<li><label for="c-tab-3"><?= $this->getHtml('Addresses'); ?></label></li>
<li><label for="c-tab-4"><?= $this->getHtml('PaymentTerm'); ?></label></li>
<li><label for="c-tab-5"><?= $this->getHtml('Payment'); ?></label></li>
<li><label for="c-tab-6"><?= $this->getHtml('Prices'); ?></label></li>
<li><label for="c-tab-7"><?= $this->getHtml('AreaManager'); ?></label></li>
<li><label for="c-tab-7"><?= $this->getHtml('Attributes'); ?></label></li>
<li><label for="c-tab-8"><?= $this->getHtml('Files'); ?></label></li>
<li><label for="c-tab-10"><?= $this->getHtml('Invoices'); ?></label>
<li><label for="c-tab-9"><?= $this->getHtml('Invoices'); ?></label>
<li><label for="c-tab-10"><?= $this->getHtml('Articles'); ?></label>
<li><label for="c-tab-10"><?= $this->getHtml('Messages'); ?></label>
<li><label for="c-tab-10"><?= $this->getHtml('Support'); ?></label>
<li><label for="c-tab-10"><?= $this->getHtml('Modules'); ?></label>
<li><label for="c-tab-10"><?= $this->getHtml('Accounting'); ?></label>
<li><label for="c-tab-10"><?= $this->getHtml('Notes'); ?></label>
<li><label for="c-tab-10"><?= $this->getHtml('Tags'); ?></label>
<li><label for="c-tab-10"><?= $this->getHtml('Calendar'); ?></label>
<li><label for="c-tab-10"><?= $this->getHtml('Permission'); ?></label>
<li><label for="c-tab-9"><?= $this->getHtml('Logs'); ?></label>
<li><label for="c-tab-11"><?= $this->getHtml('Messages'); ?></label><!-- incl. support -->
<li><label for="c-tab-11"><?= $this->getHtml('Accounting'); ?></label>
<li><label for="c-tab-11"><?= $this->getHtml('Notes'); ?></label>
<li><label for="c-tab-11"><?= $this->getHtml('Tags'); ?></label>
<li><label for="c-tab-11"><?= $this->getHtml('Calendar'); ?></label>
<li><label for="c-tab-11"><?= $this->getHtml('Permission'); ?></label>
<li><label for="c-tab-12"><?= $this->getHtml('Logs'); ?></label>
</ul>
</div>
<div class="tab-content">
@ -62,7 +61,16 @@ echo $this->data['nav']->render();
<div class="tab">
<div class="row">
<div class="col-xs-12 col-lg-3 last-lg">
<section class="portlet">
<div class="box">
<?php if(true) : ?>
<a class="button" href="<?= UriFactory::build('{/base}/purchase/bill/create?supplier=' . $supplier->id); ?>"><?= $this->getHtml('CreateBill', 'Billing'); ?></a>
<?php endif; ?>
<?php if (false) : ?>
<a class="button"><?= $this->getHtml('ViewAccount', 'Accounting'); ?></a>
<?php endif; ?>
</div>
<section class="portlet">
<form>
<div class="portlet-body">
<table class="layout wf-100">
@ -85,7 +93,7 @@ echo $this->data['nav']->render();
<section class="portlet">
<div class="portlet-head">
<?= $this->getHtml('Contact'); ?>
<a class="floatRight" href=""><i class="fa fa-envelope-o btn"></i></a>
<a class="end-xs" href=""><i class="fa fa-envelope-o btn"></i></a>
</div>
<div class="portlet-body">
<table class="layout wf-100">
@ -99,10 +107,10 @@ echo $this->data['nav']->render();
</div>
</section>
<section class="portlet">
<section class="portlet map-small">
<div class="portlet-head">
<?= $this->getHtml('Address'); ?>
<span class="clickPopup floatRight">
<span class="clickPopup end-xs">
<label for="addressDropdown"><i class="fa fa-print btn"></i></label>
<input id="addressDropdown" name="addressDropdown" type="checkbox">
<div class="popup">
@ -135,43 +143,32 @@ echo $this->data['nav']->render();
<tr><td><input type="text" id="iName1" name="name1" value="<?= $this->printHtml($supplier->mainAddress->postal); ?>" required>
<tr><td><label for="iName1"><?= $this->getHtml('City'); ?></label>
<tr><td><input type="text" id="iName1" name="name1" value="<?= $this->printHtml($supplier->mainAddress->city); ?>" required>
<tr><td><label for="iCountry"><?= $this->getHtml('Country'); ?></label>
<tr><td><select id="iCountry" name="country">
<tr><td><label for="iName1"><?= $this->getHtml('Country'); ?></label>
<tr><td><select name="country">
<?php foreach ($countryCodes as $code3 => $code2) : ?>
<option value="<?= $this->printHtml($code2); ?>"<?= $this->printHtml($code2 === $supplier->mainAddress->getCountry() ? ' selected' : ''); ?>><?= $this->printHtml($countries[$code3]); ?>
<?php endforeach; ?>
</select>
<tr><td>
<?php if (\is_file(__DIR__ . '/../../../../phpOMS/Localization/Maps/svg/' . \strtolower($supplier->mainAddress->getCountry()) . '.svg')) : ?>
<img alt="<?= $this->getHtml('IMG_alt_map'); ?>" id="iMap" style="width: 100%;" src="<?= UriFactory::build('phpOMS/Localization/Maps/svg/' . \strtolower($supplier->mainAddress->getCountry()) . '.svg'); ?>">
<?php endif; ?>
<?php endforeach; ?>
</select>
<tr><td><label for="iName1"><?= $this->getHtml('Map'); ?></label>
<tr><td><div id="supplierMap" class="map" data-lat="<?= $supplier->mainAddress->lat; ?>" data-lon="<?= $supplier->mainAddress->lon; ?>"></div>
</table>
</div>
</section>
<section class="portlet">
<div class="portlet-body">
<img alt="<?= $this->printHtml($supplierImage->name); ?>" width="100%" loading="lazy" class="item-image"
src="<?= $supplierImage->id === 0
? 'Web/Backend/img/logo_grey.png'
: UriFactory::build($supplierImage->getPath()); ?>">
</div>
</section>
<section class="portlet highlight-4">
<div class="portlet-body">
<textarea class="undecorated"><?= $this->printHtml($supplier->info); ?></textarea>
</div>
</section>
<section class="portlet">
<div class="portlet-head"><?= $this->getHtml('Contact'); ?></div>
<div class="portlet-body">
<table>
<tr><td><?= $this->getHtml('Main'); ?>:
<tr><td><?= $this->getHtml('Phone'); ?>:
<td>
<tr><td><?= $this->getHtml('Email'); ?>:
<td>
<tr><td><?= $this->getHtml('Accounting'); ?>:
<tr><td><?= $this->getHtml('Phone'); ?>:
<td>
<tr><td><?= $this->getHtml('Email'); ?>:
<td>
</table>
</div>
</section>
</div>
<div class="col-xs-12 col-lg-9 plain-grid">
<div class="row">
@ -279,7 +276,6 @@ echo $this->data['nav']->render();
<div class="col-xs-12">
<section class="portlet">
<div class="portlet-head"><?= $this->getHtml('RecentInvoices'); ?></div>
<div class="slider">
<table id="iSalesItemList" class="default">
<thead>
<tr>
@ -298,11 +294,10 @@ echo $this->data['nav']->render();
<td><a href="<?= $url; ?>"><?= $invoice->getNumber(); ?></a>
<td><a href="<?= $url; ?>"><?= $invoice->type->getL11n(); ?></a>
<td><a href="<?= $url; ?>"><?= $invoice->billTo; ?></a>
<td><a href="<?= $url; ?>"><?= $invoice->netSales->getCurrency(); ?></a>
<td><a href="<?= $url; ?>"><?= $this->getCurrency($invoice->netSales); ?></a>
<td><a href="<?= $url; ?>"><?= $invoice->createdAt->format('Y-m-d'); ?></a>
<?php endforeach; ?>
</table>
</div>
</section>
</div>
</div>
@ -315,17 +310,17 @@ echo $this->data['nav']->render();
</section>
</div>
<div class="col-xs-12 col-md-6">
<div class="col-xs-12 col-lg-6">
<section class="portlet">
<div class="portlet-head"><?= $this->getHtml('Purchase'); ?></div>
<div class="portlet-head"><?= $this->getHtml('Sales'); ?></div>
<div class="portlet-body">
<canvas id="purchase-region" data-chart='{
<canvas id="sales-region" data-chart='{
"type": "bar",
"data": {
"labels": [
<?php
$temp = [];
foreach ($monthlyPurchaseCosts as $monthly) {
foreach ($monthlySalesCosts as $monthly) {
$temp[] = $monthly['month'] . '/' . \substr((string) $monthly['year'], -2);
}
?>
@ -338,61 +333,60 @@ echo $this->data['nav']->render();
"data": [
<?php
$temp = [];
foreach ($monthlyPurchaseCosts as $monthly) {
$temp[] = \round(((((int) $monthly['net_purchase']) - ((int) ($monthly['net_costs'] ?? 0))) / (((int) $monthly['net_purchase']) + 0.0001)) * 100, 2);
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",
"yAxisID": "axis2",
"fill": false,
"borderColor": "rgb(255, 99, 132)",
"backgroundColor": "rgb(255, 99, 132)"
},
{
"label": "<?= $this->getHtml('Purchase'); ?>",
"label": "<?= $this->getHtml('Sales'); ?>",
"type": "bar",
"data": [
<?php
$temp = [];
foreach ($monthlyPurchaseCosts as $monthly) {
$temp[] = ((int) $monthly['net_purchase']) / 1000;
foreach ($monthlySalesCosts as $monthly) {
$temp[] = (float) (((int) $monthly['net_sales']) / 1000);
}
?>
<?= \implode(',', $temp); ?>
],
"yAxisID": "axis-1",
"yAxisID": "axis1",
"backgroundColor": "rgb(54, 162, 235)"
}
]
},
"options": {
"responsive": true,
"scales": {
"yAxes": [
{
"id": "axis-1",
"axis1": {
"id": "axis1",
"display": true,
"position": "left"
},
"axis2": {
"id": "axis2",
"display": true,
"position": "right",
"title": {
"display": true,
"position": "left"
"text": "<?= $this->getHtml('Margin'); ?> %"
},
{
"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
}
"grid": {
"display": false
},
"beginAtZero": true,
"ticks": {
"min": 0,
"max": 100,
"stepSize": 10
}
]
}
}
}
}'></canvas>
@ -403,41 +397,6 @@ echo $this->data['nav']->render();
</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-md-6 col-lg-4">
<section class="box wf-100">
<header><h1><?= $this->getHtml('Contact'); ?></h1></header>
<div class="inner">
<form>
<table class="layout wf-100">
<tr><td><label for="iCType"><?= $this->getHtml('Type'); ?></label>
<tr><td><select id="iCType" name="actype">
<option><?= $this->getHtml('Email'); ?>
<option><?= $this->getHtml('Fax'); ?>
<option><?= $this->getHtml('Phone'); ?>
</select>
<tr><td><label for="iCStype"><?= $this->getHtml('Subtype'); ?></label>
<tr><td><select id="iCStype" name="acstype">
<option><?= $this->getHtml('Office'); ?>
<option><?= $this->getHtml('Sales'); ?>
<option><?= $this->getHtml('Purchase'); ?>
<option><?= $this->getHtml('Accounting'); ?>
<option><?= $this->getHtml('Support'); ?>
</select>
<tr><td><label for="iCInfo"><?= $this->getHtml('Info'); ?></label>
<tr><td><input type="text" id="iCInfo" name="cinfo">
<tr><td><label for="iCData"><?= $this->getHtml('Contact'); ?></label>
<tr><td><input type="text" id="iCData" name="cdata">
<tr><td colspan="2"><input type="submit" value="<?= $this->getHtml('Add', '0', '0'); ?>">
</table>
</form>
</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">
@ -469,9 +428,62 @@ echo $this->data['nav']->render();
</section>
</div>
</div>
<div class="row">
<div class="col-xs-12 col-md-6 col-lg-4">
<section class="box wf-100">
<header><h1><?= $this->getHtml('Contact'); ?></h1></header>
<div class="inner">
<form>
<table class="layout wf-100">
<tr><td><label for="iCType"><?= $this->getHtml('Type'); ?></label>
<tr><td><select id="iCType" name="actype">
<option><?= $this->getHtml('Email'); ?>
<option><?= $this->getHtml('Fax'); ?>
<option><?= $this->getHtml('Phone'); ?>
</select>
<tr><td><label for="iCStype"><?= $this->getHtml('Subtype'); ?></label>
<tr><td><select id="iCStype" name="acstype">
<option><?= $this->getHtml('Office'); ?>
<option><?= $this->getHtml('Sales'); ?>
<option><?= $this->getHtml('Purchase'); ?>
<option><?= $this->getHtml('Accounting'); ?>
<option><?= $this->getHtml('Support'); ?>
</select>
<tr><td><label for="iCInfo"><?= $this->getHtml('Info'); ?></label>
<tr><td><input type="text" id="iCInfo" name="cinfo">
<tr><td><label for="iCData"><?= $this->getHtml('Contact'); ?></label>
<tr><td><input type="text" id="iCData" name="cdata">
<tr><td colspan="2"><input type="submit" value="<?= $this->getHtml('Add', '0', '0'); ?>">
</table>
</form>
</div>
</section>
</div>
</div>
</div>
<input type="radio" id="c-tab-4" name="tabular-2"<?= $this->request->uri->fragment === 'c-tab-4' ? ' checked' : ''; ?>>
<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-md-6 col-lg-4">
<section class="box wf-100">
<header><h1><?= $this->getHtml('Payment'); ?></h1></header>
<div class="inner">
<form>
<table class="layout wf-100">
<tr><td><label for="iACType"><?= $this->getHtml('Type'); ?></label>
<tr><td><select id="iACType" name="actype">
<option><?= $this->getHtml('Wire'); ?>
<option><?= $this->getHtml('Creditcard'); ?>
</select>
<tr><td colspan="2"><input type="submit" value="<?= $this->getHtml('Add', '0', '0'); ?>">
</table>
</form>
</div>
</section>
</div>
</div>
<div class="row">
<div class="col-xs-12 col-md-6 col-lg-4">
<section class="box wf-100">
@ -502,28 +514,6 @@ echo $this->data['nav']->render();
</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-md-6 col-lg-4">
<section class="box wf-100">
<header><h1><?= $this->getHtml('Payment'); ?></h1></header>
<div class="inner">
<form>
<table class="layout wf-100">
<tr><td><label for="iACType"><?= $this->getHtml('Type'); ?></label>
<tr><td><select id="iACType" name="actype">
<option><?= $this->getHtml('Wire'); ?>
<option><?= $this->getHtml('Creditcard'); ?>
</select>
<tr><td colspan="2"><input type="submit" value="<?= $this->getHtml('Add', '0', '0'); ?>">
</table>
</form>
</div>
</section>
</div>
</div>
</div>
<input type="radio" id="c-tab-6" name="tabular-2"<?= $this->request->uri->fragment === 'c-tab-6' ? ' checked' : ''; ?>>
<div class="tab">
<div class="row">
@ -531,7 +521,7 @@ echo $this->data['nav']->render();
<section class="box wf-100">
<header><h1><?= $this->getHtml('Price'); ?></h1></header>
<div class="inner">
<form action="<?= \phpOMS\Uri\UriFactory::build('{/api}...'); ?>" method="post">
<form action="<?= UriFactory::build('{/api}...'); ?>" method="post">
<table class="layout wf-100">
<tbody>
<tr><td colspan="2"><label for="iPType"><?= $this->getHtml('Type'); ?></label>
@ -573,7 +563,7 @@ echo $this->data['nav']->render();
<section class="box wf-100">
<header><h1><?= $this->getHtml('AreaManager'); ?></h1></header>
<div class="inner">
<form action="<?= \phpOMS\Uri\UriFactory::build('{/api}...'); ?>" method="post">
<form action="<?= UriFactory::build('{/api}...'); ?>" method="post">
<table class="layout wf-100">
<tbody>
<tr><td><label for="iManager"><?= $this->getHtml('AreaManager'); ?></label>
@ -600,6 +590,14 @@ echo $this->data['nav']->render();
<div class="tab">
</div>
<input type="radio" id="c-tab-9" name="tabular-2"<?= $this->request->uri->fragment === 'c-tab-9' ? ' checked' : ''; ?>>
<div class="tab">
<?php include __DIR__ . '/supplier-profile-bills.tpl.php'; ?>
</div>
<input type="radio" id="c-tab-10" name="tabular-2"<?= $this->request->uri->fragment === 'c-tab-9' ? ' checked' : ''; ?>>
<div class="tab">
<?php include __DIR__ . '/supplier-profile-items.tpl.php'; ?>
</div>
<input type="radio" id="c-tab-11" name="tabular-2"<?= $this->request->uri->fragment === 'c-tab-10' ? ' checked' : ''; ?>>
<div class="tab">
<div class="row">
<div class="col-xs-12">