mirror of
https://github.com/Karaka-Management/oms-SupplierManagement.git
synced 2026-01-11 17:28:41 +00:00
bug fixes / dbmapper fixes
This commit is contained in:
parent
960c5219bf
commit
3cba69b447
|
|
@ -144,6 +144,7 @@ final class ApiController extends Controller
|
|||
*/
|
||||
public function apiContactElementCreate(RequestAbstract $request, ResponseAbstract $response, $data = null) : void
|
||||
{
|
||||
/** @var \Modules\Profile\Controller\ApiController $profileModule */
|
||||
$profileModule = $this->app->moduleManager->get('Profile');
|
||||
|
||||
if (!empty($val = $profileModule->validateContactElementCreate($request))) {
|
||||
|
|
|
|||
|
|
@ -14,11 +14,11 @@ declare(strict_types=1);
|
|||
|
||||
namespace Modules\SupplierManagement\Controller;
|
||||
|
||||
use Modules\Billing\Models\BillTypeL11n;
|
||||
use Modules\Billing\Models\PurchaseBillMapper;
|
||||
use Modules\SupplierManagement\Models\SupplierMapper;
|
||||
use phpOMS\Asset\AssetType;
|
||||
use phpOMS\Contract\RenderableInterface;
|
||||
use phpOMS\DataStorage\Database\Query\OrderType;
|
||||
use phpOMS\Localization\Money;
|
||||
use phpOMS\Message\RequestAbstract;
|
||||
use phpOMS\Message\ResponseAbstract;
|
||||
|
|
@ -54,10 +54,13 @@ final class BackendController extends Controller
|
|||
$view->setTemplate('/Modules/SupplierManagement/Theme/Backend/supplier-list');
|
||||
$view->addData('nav', $this->app->moduleManager->get('Navigation')->createNavigationMid(1003202001, $request, $response));
|
||||
|
||||
$supplier = SupplierMapper::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?
|
||||
::getAfterPivot(0, null, 25);
|
||||
$supplier = SupplierMapper::getAll()
|
||||
->with('profile')
|
||||
->with('profile/account')
|
||||
->with('profile/image')
|
||||
->with('mainAddress')
|
||||
->limit(25)
|
||||
->execute();
|
||||
|
||||
$view->addData('supplier', $supplier);
|
||||
|
||||
|
|
@ -108,10 +111,15 @@ final class BackendController extends Controller
|
|||
$view->setTemplate('/Modules/SupplierManagement/Theme/Backend/supplier-profile');
|
||||
$view->addData('nav', $this->app->moduleManager->get('Navigation')->createNavigationMid(1003202001, $request, $response));
|
||||
|
||||
$supplier = SupplierMapper
|
||||
::with('files', limit: 5)::orderBy('createdAt', 'ASC')
|
||||
::with('notes', limit: 5)::orderBy('id', 'ASC')
|
||||
::get((int) $request->getData('id'));
|
||||
$supplier = SupplierMapper::get()
|
||||
->with('profile')
|
||||
->with('profile/account')
|
||||
->with('contactElements')
|
||||
->with('mainAddress')
|
||||
->with('files')->limit(5, 'files')->sort('files/id', OrderType::DESC)
|
||||
->with('notes')->limit(5, 'files')->sort('notes/id', OrderType::DESC)
|
||||
->where('id', (int) $request->getData('id'))
|
||||
->execute();
|
||||
|
||||
$view->setData('supplier', $supplier);
|
||||
|
||||
|
|
@ -120,7 +128,7 @@ final class BackendController extends Controller
|
|||
$ytd = PurchaseBillMapper::getPurchaseBySupplierId($supplier->getId(), new SmartDateTime('Y-01-01'), new SmartDateTime('now'));
|
||||
$mtd = PurchaseBillMapper::getPurchaseBySupplierId($supplier->getId(), new SmartDateTime('Y-m-01'), new SmartDateTime('now'));
|
||||
$lastOrder = PurchaseBillMapper::getLastOrderDateBySupplierId($supplier->getId());
|
||||
$newestInvoices = PurchaseBillMapper::with('language', $response->getLanguage(), [BillTypeL11n::class])::getNewestSupplierInvoices($supplier->getId(), 5);
|
||||
$newestInvoices = PurchaseBillMapper::getAll()->with('supplier')->where('supplier', $supplier->getId())->sort('id', OrderType::DESC)->limit(5)->execute();
|
||||
$monthlyPurchaseCosts = PurchaseBillMapper::getSupplierMonthlyPurchaseCosts($supplier->getId(), (new SmartDateTime('now'))->createModify(-1), new SmartDateTime('now'));
|
||||
} else {
|
||||
$ytd = new Money();
|
||||
|
|
|
|||
|
|
@ -18,6 +18,7 @@ use Modules\Admin\Models\Address;
|
|||
use Modules\Admin\Models\NullAddress;
|
||||
use Modules\Editor\Models\EditorDoc;
|
||||
use Modules\Media\Models\Media;
|
||||
use Modules\Media\Models\NullMedia;
|
||||
use Modules\Profile\Models\ContactElement;
|
||||
use Modules\Profile\Models\NullContactElement;
|
||||
use Modules\Profile\Models\Profile;
|
||||
|
|
@ -304,6 +305,26 @@ class Supplier
|
|||
return $files;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get all media files by type
|
||||
*
|
||||
* @param int $type Media type
|
||||
*
|
||||
* @return Media
|
||||
*
|
||||
* @since 1.0.0
|
||||
*/
|
||||
public function getFileByType(int $type) : Media
|
||||
{
|
||||
foreach ($this->files as $file) {
|
||||
if ($file->type === $type) {
|
||||
return $file;
|
||||
}
|
||||
}
|
||||
|
||||
return new NullMedia();
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
|
|
|
|||
|
|
@ -8,7 +8,7 @@
|
|||
* @copyright Dennis Eichhorn
|
||||
* @license OMS License 1.0
|
||||
* @version 1.0.0
|
||||
* @link https: //orange-management.org
|
||||
* @link https://orange-management.org
|
||||
*/
|
||||
declare(strict_types=1);
|
||||
|
||||
|
|
@ -21,7 +21,7 @@ use phpOMS\DataStorage\Database\Mapper\DataMapperFactory;
|
|||
*
|
||||
* @package Modules\SupplierManagement\Models
|
||||
* @license OMS License 1.0
|
||||
* @link https: //orange-management.org
|
||||
* @link https://orange-management.org
|
||||
* @since 1.0.0
|
||||
*/
|
||||
final class SupplierAttributeValueMapper extends DataMapperFactory
|
||||
|
|
|
|||
|
|
@ -104,7 +104,7 @@ echo $this->getData('nav')->render(); ?>
|
|||
<tbody>
|
||||
<?php $count = 0; foreach ($suppliers as $key => $value) : ++$count;
|
||||
$url = UriFactory::build('{/prefix}purchase/supplier/profile?{?}&id=' . $value->getId());
|
||||
$image = $value->getFileByType('backend_image'); ?>
|
||||
$image = $value->getFileByType(0); ?>
|
||||
<tr data-href="<?= $url; ?>">
|
||||
<td><a href="<?= $url; ?>"><img width="30" loading="lazy" class="item-image"
|
||||
src="<?= $image instanceof NullMedia ?
|
||||
|
|
|
|||
|
|
@ -12,6 +12,7 @@
|
|||
*/
|
||||
declare(strict_types=1);
|
||||
|
||||
use Modules\Profile\Models\ContactType;
|
||||
use phpOMS\Uri\UriFactory;
|
||||
|
||||
$countryCodes = \phpOMS\Localization\ISO3166TwoEnum::getConstants();
|
||||
|
|
@ -73,7 +74,57 @@ echo $this->getData('nav')->render();
|
|||
<tr><td><input type="text" id="iName2" name="name2" value="<?= $this->printHtml($supplier->profile->account->name2); ?>">
|
||||
<tr><td><label for="iName3"><?= $this->getHtml('Name3'); ?></label>
|
||||
<tr><td><input type="text" id="iName3" name="name3" value="<?= $this->printHtml($supplier->profile->account->name3); ?>">
|
||||
<tr><td><h3><?= $this->getHtml('Address'); ?></h3>
|
||||
</table>
|
||||
</div>
|
||||
<div class="portlet-foot">
|
||||
<input type="submit" value="<?= $this->getHtml('Save', '0', '0'); ?>"> <input type="submit" value="<?= $this->getHtml('Delete', '0', '0'); ?>">
|
||||
</div>
|
||||
</form>
|
||||
</section>
|
||||
|
||||
<section class="portlet">
|
||||
<div class="portlet-head">
|
||||
<?= $this->getHtml('Contact'); ?>
|
||||
<a class="floatRight" href=""><i class="fa fa-envelope-o btn"></i></a>
|
||||
</div>
|
||||
<div class="portlet-body">
|
||||
<table class="layout wf-100">
|
||||
<tr><td><label for="iName1"><?= $this->getHtml('Phone'); ?></label>
|
||||
<tr><td><input type="text" id="iName1" name="name1" value="<?= $this->printHtml($supplier->getMainContactElement(ContactType::PHONE)->content); ?>">
|
||||
<tr><td><label for="iName1"><?= $this->getHtml('Email'); ?></label>
|
||||
<tr><td><input type="text" id="iName1" name="name1" value="<?= $this->printHtml($supplier->getMainContactElement(ContactType::EMAIL)->content); ?>">
|
||||
<tr><td><label for="iName1"><?= $this->getHtml('Website'); ?></label>
|
||||
<tr><td><input type="text" id="iName1" name="name1" value="<?= $this->printHtml($supplier->getMainContactElement(ContactType::WEBSITE)->content); ?>">
|
||||
</table>
|
||||
</div>
|
||||
</section>
|
||||
|
||||
<section class="portlet">
|
||||
<div class="portlet-head">
|
||||
<?= $this->getHtml('Address'); ?>
|
||||
<span class="clickPopup floatRight">
|
||||
<label for="addressDropdown"><i class="fa fa-print btn"></i></label>
|
||||
<input id="addressDropdown" name="addressDropdown" type="checkbox">
|
||||
<div class="popup">
|
||||
<ul>
|
||||
<li>
|
||||
<input id="id1" type="checkbox">
|
||||
<ul>
|
||||
<li>
|
||||
<label for="id1">
|
||||
<a href="" class="button">Word</a>
|
||||
<span></span>
|
||||
<i class="fa fa-chevron-right expand"></i>
|
||||
</label>
|
||||
<li>Letter
|
||||
</ul>
|
||||
<li><label class="button cancel" for="addressDropdown">Cancel</label>
|
||||
</ul>
|
||||
</div>
|
||||
</span>
|
||||
</div>
|
||||
<div class="portlet-body">
|
||||
<table class="layout wf-100">
|
||||
<?php if (!empty($supplier->mainAddress->addition)) : ?>
|
||||
<tr><td><label for="iName1"><?= $this->getHtml('Addition'); ?></label>
|
||||
<tr><td><input type="text" id="iName1" name="name1" value="<?= $this->printHtml($supplier->mainAddress->addition); ?>">
|
||||
|
|
@ -90,12 +141,12 @@ echo $this->getData('nav')->render();
|
|||
<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 id="iMap" style="width: 100%;" src="<?= UriFactory::build('phpOMS/Localization/Maps/svg/' . \strtolower($supplier->mainAddress->getCountry()) . '.svg'); ?>">
|
||||
<?php endif; ?>
|
||||
</table>
|
||||
</div>
|
||||
<div class="portlet-foot">
|
||||
<input type="submit" value="<?= $this->getHtml('Save', '0', '0'); ?>"> <input type="submit" value="<?= $this->getHtml('Delete', '0', '0'); ?>">
|
||||
</div>
|
||||
</form>
|
||||
</section>
|
||||
|
||||
<section class="portlet highlight-4">
|
||||
|
|
@ -233,14 +284,16 @@ echo $this->getData('nav')->render();
|
|||
<td><?= $this->getHtml('Net'); ?>
|
||||
<td><?= $this->getHtml('Date'); ?>
|
||||
<tbody>
|
||||
<?php foreach ($newestInvoices as $invoice) :
|
||||
<?php
|
||||
/** @var \Modules\Billing\Models\Bill $invoice */
|
||||
foreach ($newestInvoices as $invoice) :
|
||||
$url = UriFactory::build('{/prefix}purchase/bill?{?}&id=' . $invoice->getId());
|
||||
?>
|
||||
<tr data-href="<?= $url; ?>">
|
||||
<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->net->getCurrency(); ?></a>
|
||||
<td><a href="<?= $url; ?>"><?= $invoice->netSales->getCurrency(); ?></a>
|
||||
<td><a href="<?= $url; ?>"><?= $invoice->createdAt->format('Y-m-d'); ?></a>
|
||||
<?php endforeach; ?>
|
||||
</table>
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user