This commit is contained in:
Thomas Peterson 2024-12-17 15:56:11 +01:00
parent 748ff5802f
commit ec3bff09b2
12 changed files with 135 additions and 71 deletions

File diff suppressed because one or more lines are too long

View File

@ -1,26 +1,12 @@
<?php
/**
* PrintshopCreator Suite
*
* PHP Version 5.3
*
* @author Thomas Peterson <info@thomas-peterson.de>
* @copyright 2012-2013 PrintshopCreator GmbH
* @license Private
* @link http://www.printshopcreator.de
*/
namespace PSC\Shop\ContactBundle\Controller\Backend;
use Doctrine\ODM\MongoDB\DocumentManager;
use Doctrine\ORM\EntityManagerInterface;
use PSC\Shop\ContactBundle\Document\Address\History as PSCHistory;
use PSC\Shop\ContactBundle\Form\Backend\General\ContactAddressType;
use PSC\Shop\ContactBundle\Form\Backend\General\ContactType;
use PSC\Shop\ContactBundle\Form\Backend\General\AnonymType;
use PSC\Shop\ContactBundle\PSCShopContactBundle;
use PSC\Shop\EntityBundle\Document\Shop;
use PSC\Shop\EntityBundle\Entity\Contact;
use PSC\Shop\EntityBundle\Entity\ContactAddress;
use PSC\Shop\OrderBundle\Form\Backend\Upload\DeleteType;
@ -28,21 +14,11 @@ use PSC\System\SettingsBundle\Document\LogEntry;
use PSC\System\SettingsBundle\Service\History;
use PSC\System\SettingsBundle\Service\Log;
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
use Symfony\Component\HttpFoundation\File\UploadedFile;
use Symfony\Component\HttpFoundation\JsonResponse;
use Symfony\Component\HttpFoundation\Session\SessionInterface;
use Symfony\Component\Security\Core\SecurityContext;
use Symfony\Component\Routing\Annotation\Route;
use Sensio\Bundle\FrameworkExtraBundle\Configuration\Template;
use Sensio\Bundle\FrameworkExtraBundle\Configuration\Security;
use Symfony\Component\HttpFoundation\Request;
/**
* DetailController fürs Backend
*
* @package PSC\Shop\Contact\Backend
* @subpackage Controller
*/
class AddressDetailController extends AbstractController
{
/**
@ -81,32 +57,36 @@ class AddressDetailController extends AbstractController
$contactAddress = $entityManager
->getRepository('PSC\Shop\EntityBundle\Entity\ContactAddress')
->findOneBy(array('uuid' => $uuid));
/** @var \PSC\Shop\EntityBundle\Document\ContactAddress $contactDoc */
/** @var \PSC\Shop\EntityBundle\Document\ContactAddress $contactDoc */
$contactAddressDoc = $documentManager
->getRepository('PSC\Shop\EntityBundle\Document\ContactAddress')
->findOneBy(array('uid' => (string)$contactAddress->getUid()));
/** @var \PSC\Shop\EntityBundle\Entity\Shop $selectedShop */
/** @var \PSC\Shop\EntityBundle\Entity\Shop $selectedShop */
$selectedShop = $shopService->getSelectedShop();
/** @var Contact $contact */
/** @var Contact $contact */
$contact = $contactAddress->getContact();
/** @var \PSC\Shop\EntityBundle\Document\Contact $contactDoc */
/** @var \PSC\Shop\EntityBundle\Document\Contact $contactDoc */
$contactDoc = $documentManager
->getRepository('PSC\Shop\EntityBundle\Document\Contact')
->findOneBy(array('uid' => (string)$contact->getId()));
if (!$request->isMethod('POST') && $contactAddressDoc) {
$contactAddress->setKundenNr($contactAddressDoc->getKundenNr());
$contactAddress->setHomepage($contactAddressDoc->getHomepage());
$contactAddress->setSteuerId($contactAddressDoc->getSteuerId());
$contactAddress->setLId($contactAddressDoc->getLId());
} elseif (!$contactAddressDoc) {
if (!$contactDoc) {
$contactDoc = new \PSC\Shop\EntityBundle\Document\Contact();
$contactDoc->setKundenNr("");
$contactDoc->setUid($contact->getid());
$contactDoc->setUid($contact->getId());
$documentManager->persist($contactDoc);
}
$contactAddressDoc = new \PSC\Shop\EntityBundle\Document\ContactAddress();
$contactAddressDoc->setKundenNr($contactDoc->getKundenNr());
$contactAddressDoc->setUid($contactAddress->getUid());
$contactAddressDoc->setSteuerId($contactAddress->getSteuerId());
$contactAddressDoc->setLId($contactAddress->getLId());
$documentManager->persist($contactAddressDoc);
$documentManager->flush();
$contactAddress->setKundenNr($contactDoc->getKundenNr());
@ -117,6 +97,8 @@ class AddressDetailController extends AbstractController
if ($form->isSubmitted() && $form->isValid()) {
$contactAddressDoc->setKundenNr($contactAddress->getKundenNr());
$contactAddressDoc->setHomepage($contactAddress->getHomepage());
$contactAddressDoc->setSteuerId($contactAddress->getSteuerId());
$contactAddressDoc->setLId($contactAddress->getLId());
$this->historyService->createHistoryEntry(new PSCHistory((string)$contactAddress->getUid()), $contactAddress, $contactAddressDoc);
$entityManager->persist($contactAddress);
$entityManager->flush();
@ -161,15 +143,15 @@ class AddressDetailController extends AbstractController
$contact = $entityManager
->getRepository('PSC\Shop\EntityBundle\Entity\Contact')
->findOneBy(array('uuid' => $contactUUID));
/** @var \PSC\Shop\EntityBundle\Entity\Shop $selectedShop */
/** @var \PSC\Shop\EntityBundle\Entity\Shop $selectedShop */
$selectedShop = $shopService->getSelectedShop();
/** @var ContactAddress $contactAddress */
/** @var ContactAddress $contactAddress */
$contactAddress = new ContactAddress();
$contactAddress->setInstallId($contact->getInstallId());
$contactAddress->setContact($contact);
/** @var \PSC\Shop\EntityBundle\Document\ContactAddress $contactDoc */
/** @var \PSC\Shop\EntityBundle\Document\ContactAddress $contactDoc */
$contactAddressDoc = new \PSC\Shop\EntityBundle\Document\ContactAddress();
/** @var \PSC\Shop\EntityBundle\Document\Contact $contactDoc */
/** @var \PSC\Shop\EntityBundle\Document\Contact $contactDoc */
$contactDoc = $documentManager
->getRepository('PSC\Shop\EntityBundle\Document\Contact')
->findOneBy(array('uid' => (string)$contact->getId()));
@ -180,6 +162,8 @@ class AddressDetailController extends AbstractController
$entityManager->flush();
$contactAddressDoc->setKundenNr($contactAddress->getKundenNr());
$contactAddressDoc->setHomepage($contactAddress->getHomepage());
$contactAddressDoc->setSteuerId($contactAddress->getSteuerId());
$contactAddressDoc->setLId($contactAddress->getLId());
$contactAddressDoc->setUid($contactAddress->getUid());
$documentManager->persist($contactAddressDoc);
$documentManager->flush();
@ -222,11 +206,11 @@ class AddressDetailController extends AbstractController
$contactAddress = $entityManager
->getRepository('PSC\Shop\EntityBundle\Entity\ContactAddress')
->findOneBy(array('uuid' => $uuid));
/** @var \PSC\Shop\EntityBundle\Document\ContactAddress $contactDoc */
/** @var \PSC\Shop\EntityBundle\Document\ContactAddress $contactDoc */
$contactAddressDoc = $documentManager
->getRepository('PSC\Shop\EntityBundle\Document\ContactAddress')
->findOneBy(array('uid' => (string)$contactAddress->getUid()));
/** @var \PSC\Shop\EntityBundle\Entity\Shop $selectedShop */
/** @var \PSC\Shop\EntityBundle\Entity\Shop $selectedShop */
$selectedShop = $shopService->getSelectedShop();
$form = $this->createForm(DeleteType::class);
$form->handleRequest($request);

View File

@ -51,6 +51,8 @@ class ContactAddressType extends AbstractType
->add('country', CountryType::class, ['preferred_choices' => ['DE', 'CH', 'AT'], 'required' => false, 'label' => 'country'])
->add('fax', TextType::class, ['required' => false, 'label' => 'faxnumber'])
->add('ustid', TextType::class, ['required' => false, 'label' => 'vatid'])
->add('steuerid', TextType::class, ['required' => false, 'label' => 'steuerid'])
->add('lid', TextType::class, ['required' => false, 'label' => 'lid'])
->add('zusatz1', TextType::class, ['required' => false, 'label' => 'additiveone'])
->add('zusatz2', TextType::class, ['required' => false, 'label' => 'additivetwo'])
->add('pos', TextType::class, ['required' => false, 'label' => 'sort'])

View File

@ -1,6 +1,8 @@
general: Allgemein
art: Art
add: anlegen
steuerid: Steuer Nr
lid: Leitweg Id
detail: bearbeiten
customeraddress: Kunde
Company: Firma

View File

@ -233,9 +233,30 @@
{{ form_errors(form.ustid) }}
</div>
</div>
</div>
<div class="row">
<div class="col-md-6">
<div class="row mb-3">
<label class="col-md-3 form-control-label">
{{ form_label(form.steuerid) }}
</label>
<div class="col-md-9">
{{ form_widget(form.steuerid) }}
</div>
{{ form_errors(form.steuerid) }}
</div>
</div>
<div class="col-md-6">
<div class="row mb-3">
<label class="col-md-3 form-control-label">
{{ form_label(form.lid) }}
</label>
<div class="col-md-9">
{{ form_widget(form.lid) }}
</div>
{{ form_errors(form.lid) }}
</div>
</div>
</div>
<div class="row">

View File

@ -234,7 +234,30 @@
{{ form_errors(form.ustid) }}
</div>
</div>
</div>
<div class="row">
<div class="col-md-6">
<div class="row mb-3">
<label class="col-md-3 form-control-label">
{{ form_label(form.steuerid) }}
</label>
<div class="col-md-9">
{{ form_widget(form.steuerid) }}
</div>
{{ form_errors(form.steuerid) }}
</div>
</div>
<div class="col-md-6">
<div class="row mb-3">
<label class="col-md-3 form-control-label">
{{ form_label(form.lid) }}
</label>
<div class="col-md-9">
{{ form_widget(form.lid) }}
</div>
{{ form_errors(form.lid) }}
</div>
</div>
</div>
<div class="row">

View File

@ -20,29 +20,39 @@ use Doctrine\ODM\MongoDB\Mapping\Annotations\Document;
#[Document]
class ContactAddress
{
/**
* @var string $id
*/
#[Id]
protected $id;
/**
* @var string $uid
*/
#[Field(type: 'string')]
protected $uid;
/**
* @var string $kundenNr;
*/
#[Field(type: 'string')]
protected $kundenNr;
/**
* @var string $homepage;
*/
#[Field(type: 'string')]
protected $homepage;
/**
* @return string
*/
#[Field(type: 'string')]
protected $steuerid;
#[Field(type: 'string')]
protected $lid;
public function getLId(): string
{
return (string)$this->lid;
}
public function setLId(string $var): void
{
$this->lid = $var;
}
public function getSteuerId(): string
{
return (string)$this->steuerid;
}
public function setSteuerId(string $var): void
{
$this->steuerid = $var;
}
public function getHomepage()
{
return $this->homepage;

View File

@ -14,6 +14,8 @@ class ContactAddress
{
protected $kundenNr = '';
protected $homepage = '';
protected $lid = '';
protected $steuerid = '';
/**
* @var integer
*/
@ -771,4 +773,24 @@ class ContactAddress
{
$this->pos = $pos;
}
public function getSteuerId(): string
{
return (string)$this->steuerid;
}
public function setSteuerId(string $var): void
{
$this->steuerid = $var;
}
public function getLId(): string
{
return (string)$this->lid;
}
public function setLId(string $var): void
{
$this->lid = $var;
}
}

View File

@ -3,19 +3,14 @@
namespace PSC\System\SettingsBundle\Service;
use Doctrine\ODM\MongoDB\DocumentManager;
use PSC\Shop\EntityBundle\Entity\Contact;
use PSC\Shop\EntityBundle\Entity\Shop as BaseShop;
use Symfony\Component\Security\Core\Authentication\Token\Storage\TokenStorageInterface;
/**
* Shop
*
* @author Thomas Peterson
*/
class Instance
{
protected $mongoManager;
public function __construct(DocumentManager $mongoManager)
public function __construct(private DocumentManager $mongoManager, private TokenStorageInterface $tokenStorage, private Shop $shopService)
{
$this->mongoManager = $mongoManager;
}
/**
@ -39,4 +34,15 @@ class Instance
return $instance;
}
public function getUser(): Contact
{
return $this->tokenStorage->getToken()->getUser();
}
public function getShop(): BaseShop
{
return $this->shopService->getSelectedShop();
}
}

View File

@ -155,9 +155,6 @@ class Printing
'ShippingCoast'
);
}
dump($orderModel);
dump($document);
die();
return $document->getContent();
}

View File

@ -89,7 +89,7 @@
{% endblock %}
{% if instanceService.getInstance().supporttoken %}
<script>
$.post("{{ instanceService.getInstance().formatedSupportUrl }}/apilogin?X-AUTH-TOKEN={{ instanceService.getInstance().supporttoken }}&to=bridge", function(msg){
$.post("{{ instanceService.getInstance().formatedSupportUrl }}/apilogin?shop_uuid={{ instanceService.getShop().uuid|url_encode }}&shop_name={{ instanceService.getShop().title|url_encode }}&user_uuid={{ instanceService.getUser().uuid|url_encode }}&user_name={{ instanceService.getUser().username|url_encode }}&X-AUTH-TOKEN={{ instanceService.getInstance().supporttoken }}&to=bridge", function(msg){
if(msg != "") {
$(".swarm").html(msg);
}

View File

@ -23,7 +23,6 @@ class Position implements IPositionTransformer
$obj = new ProductSpecialObject();
$selectedShop = $posEntity->getOrder()->getShop();
if ($posEntity->hasCalcXml() || isset($posDoc->getSpecialProductTypeObject()['xml'])) {
$paperContainer = new PaperContainer();
$paperContainer->parse(simplexml_load_string($selectedShop->getInstall()->getPaperContainer()));
@ -45,7 +44,6 @@ class Position implements IPositionTransformer
if ($posDoc) {
$engine->setSavedCalcReferences($posDoc->getCalcReferences());
}
if (isset($posDoc->getSpecialProductTypeObject()['xml']) && $posDoc->getSpecialProductTypeObject()['xml'] != "") {
$engine->setVariables($posDoc->getSpecialProductTypeObject()['params']);
if (isset($posDoc->getSpecialProductTypeObject()['kalk_artikel'])) {
@ -87,7 +85,6 @@ class Position implements IPositionTransformer
* @var \PSC\Shop\EntityBundle\Entity\Product $product
*/
$product = $this->productRepository->findOneBy(['uuid' => $position->getProduct()->getUuid()]);
if ($posDoc->getSpecialProductTypeObject()['xml'] == '') {
$sp = $posDoc->getSpecialProductTypeObject();
$sp['xml'] = $product->getCalcXml();