This commit is contained in:
Thomas Peterson 2025-09-01 16:59:14 +02:00
parent 3f1d28b9da
commit 1199cc6901
90 changed files with 2807 additions and 1944 deletions

View File

@ -64,8 +64,8 @@ server {
try_files $uri @sfFront;
}
#location /w2p/ {
# proxy_pass http://tp:8080/w2p/;
# location /w2p/ {
#j proxy_pass http://tp:8080/w2p/;
# proxy_temp_path /tmp/proxy;
#}

View File

@ -85,6 +85,8 @@ RUN pecl install imagick \
RUN docker-php-ext-install -j$(nproc) pdo_mysql
# Install opcache
RUN docker-php-ext-install -j$(nproc) opcache
RUN apt-get install wget
RUN wget -qO - https://packages.sury.org/php/README.txt | bash -x
RUN apt-get update && apt-get install -y \
libc-client-dev libkrb5-dev libldap2-dev && \
rm -r /var/lib/apt/lists/*

View File

@ -8,9 +8,9 @@ use LogicException;
use Port\Csv\CsvWriter;
use Port\Reader\ArrayReader;
use PSC\Backend\ToolsBundle\Export\Writer\ExcelWriter;
use PSC\Backend\ToolsBundle\Interfaces\ConfigurableElementInterface;
use PSC\Backend\ToolsBundle\Interfaces\ExporterInterface;
use PSC\Backend\ToolsBundle\Service\ExporterRegistry;
use PSC\Backend\ToolsBundle\Interfaces\ConfigurableElementInterface;
use PSC\System\SettingsBundle\Service\Shop;
use Symfony\Component\Form\Extension\Core\Type\DateType;
use Symfony\Component\Form\Form;
@ -28,8 +28,9 @@ class OrderExporter implements ExporterInterface, ConfigurableElementInterface
private $_formFactory = null;
private $_entityManager = null;
private $_shopService = null;
/** @var Form */
/** @var Form */
private $_form = null;
function __construct(FormFactoryInterface $formFactory, EntityManagerInterface $entityManager, Shop $shopService)
{
$this->_formFactory = $formFactory;
@ -52,8 +53,8 @@ class OrderExporter implements ExporterInterface, ConfigurableElementInterface
public function getForm(FormBuilderInterface $builder, $form_options)
{
$builder->add("from", DateType::class, array('label' => 'Von', 'attr' => array('class' => 'form-element')));
$builder->add("to", DateType::class, array('label' => 'Bis', 'attr' => array('class' => 'form-element')));
$builder->add('from', DateType::class, ['label' => 'Von', 'attr' => ['class' => 'form-element']]);
$builder->add('to', DateType::class, ['label' => 'Bis', 'attr' => ['class' => 'form-element']]);
}
public function getGroup()
@ -73,32 +74,41 @@ class OrderExporter implements ExporterInterface, ConfigurableElementInterface
{
$formData = $this->_form->getData();
$orderRepository = $this->_entityManager->getRepository('PSC\Shop\EntityBundle\Entity\Order');
$qb = $orderRepository->createQueryBuilder('o')
$qb = $orderRepository
->createQueryBuilder('o')
->leftJoin('o.contact', 'c')
->where("o.created >= :from and o.created <= :to and o.shop = :shop")
->where('o.created >= :from and o.created <= :to and o.shop = :shop')
->setParameter('from', $formData['from'])
->setParameter('to', $formData['to'])
->setParameter('shop', $this->_shopService->getSelectedShop()->getId())
->getQuery();
$temp = array();
$temp = [];
$rows = $qb->getResult();
$temp[] = [
'uid',
'alias',
'created',
'status',
'brutto',
'package',
'contact',
];
foreach ($rows as $row) {
$temp[] = array(
$temp[] = [
$row->getUID(),
$row->getAlias(),
$row->getCreated()->format('Y-m-d H:i:s'),
$row->getStatus(),
$row->getBrutto(),
$row->getPackage(),
$row->getContact()->getUsername()
);
$row->getContact()->getUsername(),
];
}
$reader = new ArrayReader($temp);
$writer = new CsvWriter();
$writer->setStream(fopen('php://output', 'w'));
$response = new StreamedResponse(function () use ($reader, $writer) {
foreach ($reader as $row) {
$writer->writeItem($row);
}

View File

@ -6,9 +6,9 @@ use Doctrine\ORM\EntityManager;
use Doctrine\ORM\EntityManagerInterface;
use LogicException;
use PSC\Backend\ToolsBundle\Export\Writer\ExcelWriter;
use PSC\Backend\ToolsBundle\Interfaces\ConfigurableElementInterface;
use PSC\Backend\ToolsBundle\Interfaces\ExporterInterface;
use PSC\Backend\ToolsBundle\Service\ExporterRegistry;
use PSC\Backend\ToolsBundle\Interfaces\ConfigurableElementInterface;
use PSC\System\SettingsBundle\Service\Shop;
use Symfony\Component\Form\Extension\Core\Type\DateType;
use Symfony\Component\Form\Form;
@ -27,8 +27,12 @@ class OrderposExporter implements ExporterInterface, ConfigurableElementInterfac
private $_shopService = null;
/** @var Form */
private $_form = null;
public function __construct(FormFactoryInterface $formFactory, EntityManagerInterface $entityManager, Shop $shopService)
{
public function __construct(
FormFactoryInterface $formFactory,
EntityManagerInterface $entityManager,
Shop $shopService,
) {
$this->_formFactory = $formFactory;
$this->_entityManager = $entityManager;
$this->_shopService = $shopService;
@ -49,8 +53,8 @@ class OrderposExporter implements ExporterInterface, ConfigurableElementInterfac
public function getForm(FormBuilderInterface $builder, $form_options)
{
$builder->add("from", DateType::class, array('label' => 'Von', 'attr' => array('class' => 'form-element')));
$builder->add("to", DateType::class, array('label' => 'Bis', 'attr' => array('class' => 'form-element')));
$builder->add('from', DateType::class, ['label' => 'Von', 'attr' => ['class' => 'form-element']]);
$builder->add('to', DateType::class, ['label' => 'Bis', 'attr' => ['class' => 'form-element']]);
}
public function getGroup()
@ -71,19 +75,30 @@ class OrderposExporter implements ExporterInterface, ConfigurableElementInterfac
$em = $this->_entityManager;
$form = $this->_form;
$response = new StreamedResponse(function () use ($em, $form) {
$formData = $form->getData();
$orderRepository = $em->getRepository('PSC\Shop\EntityBundle\Entity\Orderpos');
$results = $orderRepository->createQueryBuilder('o')
->where("o.createdDate >= :from and o.createdDate <= :to and o.shop = :shop")
$results = $orderRepository
->createQueryBuilder('o')
->where('o.createdDate >= :from and o.createdDate <= :to and o.shop = :shop')
->setParameter('from', $formData['from'])
->setParameter('to', $formData['to'])
->setParameter('shop', $this->_shopService->getSelectedShop()->getId())
->getQuery()->iterate();
->getQuery()
->iterate();
$handle = fopen('php://output', 'r+');
fputcsv($handle, [
'uid',
'alias',
'created',
'status',
'brutto',
'package',
'contact',
'product_uid',
'product_title',
]);
while (false !== ($row = $results->next())) {
fputcsv($handle, array(
fputcsv($handle, [
$row[0]->getOrder()->getUID(),
$row[0]->getOrder()->getAlias(),
$row[0]->getOrder()->getCreated()->format('Y-m-d H:i:s'),
@ -92,8 +107,8 @@ class OrderposExporter implements ExporterInterface, ConfigurableElementInterfac
$row[0]->getOrder()->getPackage(),
$row[0]->getOrder()->getContact()->getUsername(),
$row[0]->getProduct()->getUid(),
$row[0]->getProduct()->getTitle()
));
$row[0]->getProduct()->getTitle(),
]);
$em->detach($row[0]);
}

View File

@ -44,6 +44,7 @@ class AccountType extends AbstractType
protected $general;
protected $shop = null;
protected $formFactory;
public function __construct(Shop $shop, Field $fields, FormFactoryInterface $formFactory, General $general)
{
$this->fields = $fields;
@ -61,39 +62,37 @@ class AccountType extends AbstractType
$builder
->add('title', TextType::class, ['label' => 'Name'])
->add(
'payments', EntityType::class, array(
->add('payments', EntityType::class, [
'class' => 'PSC\Shop\EntityBundle\Entity\Payment',
'choice_label' => 'title',
'choice_value' => 'uid',
'required' => false,
'multiple' => true,
'query_builder' => function (EntityRepository $er) {
return $er->createQueryBuilder('u')
->where('u.shop = :shop')->andWhere('u.private = 1')->setParameter('shop', $this->shop->getSelectedShop()->getId());
}
)
)
->add(
'shippings', EntityType::class, array(
return $er
->createQueryBuilder('u')
->where('u.shop = :shop')
->andWhere('u.private = 1')
->setParameter('shop', $this->shop->getSelectedShop()->getId());
},
])
->add('shippings', EntityType::class, [
'class' => 'PSC\Shop\EntityBundle\Entity\Shipping',
'choice_label' => 'title',
'choice_value' => 'uid',
'required' => false,
'multiple' => true,
'query_builder' => function (EntityRepository $er) {
return $er->createQueryBuilder('u')
->where('u.shop = :shop')->andWhere('u.private = 1')->setParameter('shop', $this->shop->getSelectedShop()->getId());
}
)
)
->add(
'productGroups', EntityType::class, array(
return $er
->createQueryBuilder('u')
->where('u.shop = :shop')
->andWhere('u.private = 1')
->setParameter('shop', $this->shop->getSelectedShop()->getId());
},
])
->add('productGroups', EntityType::class, [
'class' => 'PSC\Shop\EntityBundle\Entity\Productgroup',
'choice_label' => function (Productgroup $choice, $key, $value) {
if ($choice->isEnable()) {
return $choice->getTitle();
} else {
@ -104,71 +103,71 @@ class AccountType extends AbstractType
'required' => false,
'multiple' => true,
'query_builder' => function (EntityRepository $er) {
return $er->createQueryBuilder('u')
->where('u.shop = :shop')->andWhere('u.private = 1')->setParameter('shop', $this->shop->getSelectedShop()->getId());
}
)
)
->add(
'parent', EntityType::class, array(
return $er
->createQueryBuilder('u')
->where('u.shop = :shop')
->andWhere('u.private = 1')
->setParameter('shop', $this->shop->getSelectedShop()->getId());
},
])
->add('parent', EntityType::class, [
'class' => 'PSC\Shop\EntityBundle\Entity\Account',
'choice_label' => 'title',
'choice_value' => 'uid',
'multiple' => false,
'required' => false,
'query_builder' => function (EntityRepository $er) {
return $er->createQueryBuilder('u')
return $er
->createQueryBuilder('u')
->join('u.shops', 's')
->where('s.uid = :shop')->setParameter('shop', $this->shop->getSelectedShop()->getId());
}
)
)
->add(
'productsOrg', EntityType::class, array(
->where('s.uid = :shop')
->setParameter('shop', $this->shop->getSelectedShop()->getId());
},
])
->add('productsOrg', EntityType::class, [
'class' => 'PSC\Shop\EntityBundle\Entity\Product',
'choice_label' => 'nrTitle',
'multiple' => true,
'required' => false,
'query_builder' => function (EntityRepository $er) {
return $er->createQueryBuilder('u')
->where('u.shop = :shop')->andWhere('u.private = 1 AND u.originalProduct = 0')->setParameter('shop', $this->shop->getSelectedShop()->getId());
}
)
)
->add(
'productsSub', EntityType::class, array(
return $er
->createQueryBuilder('u')
->where('u.shop = :shop')
->andWhere('u.private = 1 AND u.originalProduct = 0')
->setParameter('shop', $this->shop->getSelectedShop()->getId());
},
])
->add('productsSub', EntityType::class, [
'class' => 'PSC\Shop\EntityBundle\Entity\Product',
'choice_label' => 'nrTitle',
'required' => false,
'multiple' => true,
'query_builder' => function (EntityRepository $er) {
return $er->createQueryBuilder('u')
->where('u.shop = :shop')->andWhere('u.private = 1 AND u.originalProduct != 0')->setParameter('shop', $this->shop->getSelectedShop()->getId());
}
)
)
->add(
'cms', EntityType::class, array(
return $er
->createQueryBuilder('u')
->where('u.shop = :shop')
->andWhere('u.private = 1 AND u.originalProduct != 0')
->setParameter('shop', $this->shop->getSelectedShop()->getId());
},
])
->add('cms', EntityType::class, [
'class' => 'PSC\Shop\EntityBundle\Entity\Cms',
'choice_label' => 'title',
'choice_value' => 'uid',
'multiple' => true,
'required' => false,
'query_builder' => function (EntityRepository $er) use ($tempCms) {
return $er->createQueryBuilder('u')
->where('(u.shop = :shop OR u.uid in (' . implode(",", $tempCms) . '))')->andWhere('u.private = 1')->setParameter('shop', $this->shop->getSelectedShop()->getId());
}
)
)
return $er
->createQueryBuilder('u')
->where('(u.shop = :shop OR u.uid in (' . implode(',', $tempCms) . '))')
->andWhere('u.private = 1')
->setParameter('shop', $this->shop->getSelectedShop()->getId());
},
])
->add('appendix', TextType::class, ['required' => false, 'label' => 'additive'])
->add('locked', CheckboxType::class, ['required' => false, 'label' => 'Locked'])
->add('street', TextType::class, ['required' => false, 'label' => 'street'])
->add('destrict', TextType::class, ['required' => false, 'label' => 'district'])
->add('district', TextType::class, ['required' => false, 'label' => 'district'])
->add('zip', TextType::class, ['required' => false, 'label' => 'zip'])
->add('city', TextType::class, ['required' => false, 'label' => 'city'])
->add('state', TextType::class, ['required' => false, 'label' => 'state'])
@ -176,50 +175,50 @@ class AccountType extends AbstractType
->add('email', TextType::class, ['required' => false, 'label' => 'Email'])
->add('houseNumber', TextType::class, ['required' => false, 'label' => 'housenumber'])
->add('homepage', TextType::class, ['required' => false, 'label' => 'Homepage'])
->add('extraSettings', TextareaType::class, array('required' => false, 'label' => 'extrasettings'))
->add('extraSettings', TextareaType::class, ['required' => false, 'label' => 'extrasettings'])
->add('phoneAreaCode', TextType::class, ['required' => false, 'label' => 'Countrycode'])
->add('phonePrefix', TextType::class, ['required' => false, 'label' => 'prefix'])
->add('phone', TextType::class, ['required' => false, 'label' => 'number'])
->add('phoneAppendix', TextType::class, ['required' => false, 'label' => 'extension'])
->add(
'priceFactor', NumberType::class, array('required' => false, 'label' => 'factor', 'scale' => 2, 'html5' => true,
'attr' => array(
->add('priceFactor', NumberType::class, [
'required' => false,
'label' => 'factor',
'scale' => 2,
'html5' => true,
'attr' => [
'min' => -0.01,
'max' => 2.00,
'step' => 0.01,
))
)
],
])
->add('mobileAreaCode', TextType::class, ['required' => false, 'label' => 'Countrycode'])
->add('mobilePrefix', TextType::class, ['required' => false, 'label' => 'prefix'])
->add('mobile', TextType::class, ['required' => false, 'label' => 'number'])
->add('mobileAppendix', TextType::class, ['required' => false, 'label' => 'extension'])
->add('faxAreaCode', TextType::class, ['required' => false, 'label' => 'Countrycode'])
->add('faxPrefix', TextType::class, ['required' => false, 'label' => 'prefix'])
->add('fax', TextType::class, ['required' => false, 'label' => 'number'])
->add('faxAppendix', TextType::class, ['required' => false, 'label' => 'extension'])
->add('alternativAreaCode', TextType::class, ['required' => false, 'label' => 'Countrycode'])
->add('alternativType', TextType::class, ['required' => false, 'label' => 'Typ'])
->add('alternativ', TextType::class, ['required' => false, 'label' => 'number'])
->add('alternativAppendix', TextType::class, ['required' => false, 'label' => 'extension'])
->add('bankKtoName', TextType::class, ['required' => false, 'label' => 'accountowner'])
->add('bankKTO', TextType::class, ['required' => false, 'label' => 'accountnumber'])
->add('bankBLZ', TextType::class, ['required' => false, 'label' => 'bankcode'])
->add('bankIban', TextType::class, ['required' => false, 'label' => 'Iban'])
->add('bankBic', TextType::class, ['required' => false, 'label' => 'BIC'])
->add('bankName', TextType::class, ['required' => false, 'label' => 'bankname'])
->add('ustid', TextType::class, ['required' => false, 'label' => 'VatId'])
->add('typ', ChoiceType::class, ['choices' => $this->general->getAccountTypes(),'translation_domain' => 'general', 'required' => false, 'label' => 'Typ'])
->add('typ', ChoiceType::class, [
'choices' => $this->general->getAccountTypes(),
'translation_domain' => 'general',
'required' => false,
'label' => 'Typ',
])
->add('image', MediaType::class, ['required' => false, 'label' => 'pic'])
->add('templateSwitch', TextType::class, ['required' => false, 'label' => 'Alternatetemplate'])
->add('information', TextareaType::class, ['required' => false, 'label' => 'information'])
->add('megaCode', TextType::class, ['required' => false, 'label' => 'MegaCode'])
->add('hotelName', TextType::class, ['required' => false, 'label' => 'Hotelname'])
->add('subHotelName', TextType::class, ['required' => false, 'label' => 'SubHotelname'])
@ -231,23 +230,32 @@ class AccountType extends AbstractType
->add('handelsRegister', TextType::class, ['required' => false, 'label' => 'commercialregister'])
->add('hrb', TextType::class, ['required' => false, 'label' => 'HRB'])
->add('vorsitz', TextType::class, ['required' => false, 'label' => 'ChairmanoftheBoard'])
->add('salutation1', ChoiceType::class, ['choices' => $this->general->getSalutation(),'translation_domain' => 'general', 'required' => false, 'label' => 'salutation1'])
->add('salutation1', ChoiceType::class, [
'choices' => $this->general->getSalutation(),
'translation_domain' => 'general',
'required' => false,
'label' => 'salutation1',
])
->add('firstname1', TextType::class, ['required' => false, 'label' => 'firsname1'])
->add('lastname1', TextType::class, ['required' => false, 'label' => 'lastname1'])
->add('salutation2', ChoiceType::class, ['choices' => $this->general->getSalutation(),'translation_domain' => 'general', 'required' => false, 'label' => 'salutation2'])
->add('salutation2', ChoiceType::class, [
'choices' => $this->general->getSalutation(),
'translation_domain' => 'general',
'required' => false,
'label' => 'salutation2',
])
->add('firstname2', TextType::class, ['required' => false, 'label' => 'firsname2'])
->add('lastname2', TextType::class, ['required' => false, 'label' => 'lastname2'])
->add('calcValue1', TextType::class, ['required' => false, 'label' => 'value1'])
->add('calcValue2', TextType::class, ['required' => false, 'label' => 'value2']);
/**
* @var \PSC\System\PluginBundle\Form\Interfaces\Field $field
*/
*/
foreach ($this->fields->getFields(\PSC\System\PluginBundle\Form\Interfaces\Field::Account) as $field) {
$builder->add($field->buildForm($this->formFactory->createNamedBuilder($field->getGroup()), $options));
}
$builder->add('save', SubmitType::class, array('label' => 'save'));
$builder->add('save', SubmitType::class, ['label' => 'save']);
}
public function getName()
@ -257,12 +265,10 @@ class AccountType extends AbstractType
public function configureOptions(OptionsResolver $resolver)
{
$resolver->setDefaults(
array(
$resolver->setDefaults([
'data_class' => 'PSC\Shop\EntityBundle\Entity\Account',
'cms' => [],
'translation_domain' => 'core_account_create_and_edit'
)
);
'translation_domain' => 'core_account_create_and_edit',
]);
}
}

View File

@ -145,11 +145,11 @@
</div>
<div class="col-md-3">
<div class="row mb-3">
{{ form_label(form.destrict) }}
{{ form_label(form.district) }}
<div class="col-md-8">
{{ form_widget(form.destrict) }}
{{ form_widget(form.district) }}
</div>
{{ form_errors(form.destrict) }}
{{ form_errors(form.district) }}
</div>
</div>
<div class="col-md-3">

View File

@ -145,11 +145,11 @@
<div class="row">
<div class="col-md-3">
<div class="row mb-3">
{{ form_label(form.destrict) }}
{{ form_label(form.district) }}
<div class="col-md-8">
{{ form_widget(form.destrict) }}
{{ form_widget(form.district) }}
</div>
{{ form_errors(form.destrict) }}
{{ form_errors(form.district) }}
</div>
</div>
<div class="col-md-3">

View File

@ -14,7 +14,7 @@ street: Straße
housenumber: Hausnummer
zip: PLZ
city: Ort
destrict: Bezirk
district: Bezirk
state: Bundesland
country: Land
Phonenumber: Telefonnummer

View File

@ -12,7 +12,7 @@ street: Street
housenumber: House number
zip: Zip/Postal Code
city: City
destrict: Destrict
district: District
state: State
country: Country
Phonenumber: Phone Number

View File

@ -12,7 +12,7 @@ housenumber: Hausnummer
zip: PLZ
city: Ort
vatid: USt-IdNr.
destrict: Bezirk
district: Bezirk
state: Bundesland
country: Land
homepage: Homepage

View File

@ -11,7 +11,7 @@ housenumber: House number
zip: Zip/Postal Code
city: City
vatid: VAT ID
destrict: Destrict
district: District
state: State
country: Country
homepage: Homepage

View File

@ -463,12 +463,12 @@
<div class="col-md-3">
<div class="row mb-3">
<div class="col-md-4">
{{ form_label(form.destrict) }}
{{ form_label(form.district) }}
</div>
<div class="col-md-8">
{{ form_widget(form.destrict) }}
{{ form_widget(form.district) }}
</div>
{{ form_errors(form.destrict) }}
{{ form_errors(form.district) }}
</div>
</div>
<div class="col-md-3">

View File

@ -435,12 +435,12 @@
<div class="col-md-3">
<div class="row mb-3">
<div class="col-md-4">
{{ form_label(form.destrict) }}
{{ form_label(form.district) }}
</div>
<div class="col-md-8">
{{ form_widget(form.destrict) }}
{{ form_widget(form.district) }}
</div>
{{ form_errors(form.destrict) }}
{{ form_errors(form.district) }}
</div>
</div>
<div class="col-md-3">

View File

@ -13,22 +13,32 @@ use PSC\Shop\MediaBundle\Service\MediaManager;
use PSC\Shop\MediaBundle\Transformer\Media as PSCMedia;
use PSC\System\SettingsBundle\Service\Shop;
class Contact
readonly class Contact
{
public function __construct(private readonly MediaManager $mediaManager, private readonly ContactRepository $contactRepository, private readonly Shop $shopService, private readonly EntityManagerInterface $entityManager, private readonly DocumentManager $documentManager, private readonly PSCMedia $mediaTransformer, private readonly Account $accountTransformer)
{
}
public function __construct(
private MediaManager $mediaManager,
private ContactRepository $contactRepository,
private Shop $shopService,
private EntityManagerInterface $entityManager,
private DocumentManager $documentManager,
private PSCMedia $mediaTransformer,
private Account $accountTransformer,
) {}
public function toDb(\PSC\Shop\ContactBundle\Model\Contact $contact): void
{
if ($contact->getUuid() !== "") {
if ($contact->getUuid() !== '') {
/** @var \PSC\Shop\EntityBundle\Entity\Contact $contactEntity */
$contactEntity = $this->contactRepository->findOneBy(['uuid' => $contact->getUuid()]);
$contactDoc = $this->documentManager->getRepository(\PSC\Shop\EntityBundle\Document\Contact::class)->findOneBy(['uid' => $contactEntity->getUid()]);
$contactDoc = $this->documentManager
->getRepository(\PSC\Shop\EntityBundle\Document\Contact::class)
->findOneBy(['uid' => $contactEntity->getUid()]);
} else {
if ($contact->getUid() !== 0) {
$contactEntity = $this->contactRepository->findOneBy(['uid' => $contact->getUuid()]);
$contactDoc = $this->documentManager->getRepository(\PSC\Shop\EntityBundle\Document\Contact::class)->findOneBy(['uid' => $contactEntity->getUid()]);
$contactDoc = $this->documentManager
->getRepository(\PSC\Shop\EntityBundle\Document\Contact::class)
->findOneBy(['uid' => $contactEntity->getUid()]);
} else {
$contactEntity = new \PSC\Shop\EntityBundle\Entity\Contact();
$contactDoc = new \PSC\Shop\EntityBundle\Document\Contact();
@ -46,55 +56,55 @@ class Contact
if (count($shops) > 0) {
$contactEntity->setShops($shops);
}
if ($contact->getEmail() != "") {
if ($contact->getEmail() != '') {
$contactEntity->setEmail($contact->getEmail());
}
$contactEntity->setEnable(true);
$contactEntity->setFirstname((string)$contact->getLayouterData()->getFirstname());
$contactEntity->setCompany((string)$contact->getLayouterData()->getCompany());
$contactEntity->setCompany2((string)$contact->getLayouterData()->getCompany2());
$contactEntity->setLastname((string)$contact->getLayouterData()->getLastname());
$contactEntity->setZip((string)$contact->getLayouterData()->getZip());
$contactEntity->setCity((string)$contact->getLayouterData()->getCity());
$contactEntity->setStreet((string)$contact->getLayouterData()->getStreet());
$contactEntity->setHouseNumber((string)$contact->getLayouterData()->getHouseNumber());
$contactEntity->setHomepage((string)$contact->getLayouterData()->getHomepage());
$contactEntity->setFirstname((string) $contact->getLayouterData()->getFirstname());
$contactEntity->setCompany((string) $contact->getLayouterData()->getCompany());
$contactEntity->setCompany2((string) $contact->getLayouterData()->getCompany2());
$contactEntity->setLastname((string) $contact->getLayouterData()->getLastname());
$contactEntity->setZip((string) $contact->getLayouterData()->getZip());
$contactEntity->setCity((string) $contact->getLayouterData()->getCity());
$contactEntity->setStreet((string) $contact->getLayouterData()->getStreet());
$contactEntity->setHouseNumber((string) $contact->getLayouterData()->getHouseNumber());
$contactEntity->setHomepage((string) $contact->getLayouterData()->getHomepage());
if ($contact->getLayouterData()->getImage1() != null) {
$contactEntity->setImage((string)$contact->getLayouterData()->getImage1()->getUuid());
$contactEntity->setImage((string) $contact->getLayouterData()->getImage1()->getUuid());
}
if ($contact->getLayouterData()->getImage2() != null) {
$contactEntity->setImage2((string)$contact->getLayouterData()->getImage2()->getUuid());
$contactEntity->setImage2((string) $contact->getLayouterData()->getImage2()->getUuid());
}
$contactEntity->setBirthday((string)$contact->getLayouterData()->getBirthday());
$contactEntity->setKostenstellung((string)$contact->getLayouterData()->getKst());
$contactEntity->setState((string)$contact->getLayouterData()->getState());
$contactEntity->setDestrict((string)$contact->getLayouterData()->getDistrict());
$contactEntity->setBirthday((string) $contact->getLayouterData()->getBirthday());
$contactEntity->setKostenstellung((string) $contact->getLayouterData()->getKst());
$contactEntity->setState((string) $contact->getLayouterData()->getState());
$contactEntity->setDistrict((string) $contact->getLayouterData()->getDistrict());
$contactEntity->setPhoneAreaCode((string)$contact->getLayouterData()->getPhoneAreaCode());
$contactEntity->setPhoneAppendix((string)$contact->getLayouterData()->getPhoneAppendix());
$contactEntity->setPhone((string)$contact->getLayouterData()->getPhone());
$contactEntity->setPhonePrefix((string)$contact->getLayouterData()->getPhonePrefix());
$contactEntity->setPhoneAreaCode((string) $contact->getLayouterData()->getPhoneAreaCode());
$contactEntity->setPhoneAppendix((string) $contact->getLayouterData()->getPhoneAppendix());
$contactEntity->setPhone((string) $contact->getLayouterData()->getPhone());
$contactEntity->setPhonePrefix((string) $contact->getLayouterData()->getPhonePrefix());
$contactEntity->setMobileAreaCode((string)$contact->getLayouterData()->getMobileAreaCode());
$contactEntity->setMobileAppendix((string)$contact->getLayouterData()->getMobileAppendix());
$contactEntity->setMobile((string)$contact->getLayouterData()->getMobile());
$contactEntity->setMobilePrefix((string)$contact->getLayouterData()->getMobilePrefix());
$contactEntity->setMobileAreaCode((string) $contact->getLayouterData()->getMobileAreaCode());
$contactEntity->setMobileAppendix((string) $contact->getLayouterData()->getMobileAppendix());
$contactEntity->setMobile((string) $contact->getLayouterData()->getMobile());
$contactEntity->setMobilePrefix((string) $contact->getLayouterData()->getMobilePrefix());
$contactEntity->setFaxAreaCode((string)$contact->getLayouterData()->getFaxAreaCode());
$contactEntity->setFaxPrefix((string)$contact->getLayouterData()->getFaxPrefix());
$contactEntity->setFax((string)$contact->getLayouterData()->getFax());
$contactEntity->setFaxAppendix((string)$contact->getLayouterData()->getFaxAppendix());
$contactEntity->setFaxAreaCode((string) $contact->getLayouterData()->getFaxAreaCode());
$contactEntity->setFaxPrefix((string) $contact->getLayouterData()->getFaxPrefix());
$contactEntity->setFax((string) $contact->getLayouterData()->getFax());
$contactEntity->setFaxAppendix((string) $contact->getLayouterData()->getFaxAppendix());
$contactEntity->setCountry((string)$contact->getCountryCode());
$contactEntity->setCountry((string) $contact->getCountryCode());
$contactEntity->setPosition((string)$contact->getLayouterData()->getPosition());
$contactEntity->setFunction((string)$contact->getLayouterData()->getFunction());
$contactEntity->setAbteilung((string)$contact->getLayouterData()->getAbteilung());
$contactEntity->setTitle((string)$contact->getLayouterData()->getTitle());
$contactEntity->setPosition((string) $contact->getLayouterData()->getPosition());
$contactEntity->setFunction((string) $contact->getLayouterData()->getFunction());
$contactEntity->setAbteilung((string) $contact->getLayouterData()->getAbteilung());
$contactEntity->setTitle((string) $contact->getLayouterData()->getTitle());
$contactEntity->setUstid((string)$contact->getLayouterData()->getUstid());
$contactEntity->setUstid((string) $contact->getLayouterData()->getUstid());
$contactEntity->setEnable($contact->isEnable());
$contactEntity->setLocked($contact->isLocked());
$contactEntity->setCollectingOrders($contact->isCollectingOrders());
@ -107,7 +117,7 @@ class Contact
for ($i = 1; $i <= 24; $i++) {
$setMethod = 'setCustom' . $i;
$getMethod = 'getCustom'. $i;
$getMethod = 'getCustom' . $i;
if (method_exists($contactDoc, $setMethod) && method_exists($contact, $getMethod)) {
$contactDoc->$setMethod($contact->$getMethod());
@ -118,7 +128,9 @@ class Contact
$roles = [];
/** @var Role $role */
foreach ($contact->getRoles() as $role) {
$role = $this->entityManager->getRepository('PSC\Shop\EntityBundle\Entity\Role')->findOneByUid($role->getId());
$role = $this->entityManager
->getRepository('PSC\Shop\EntityBundle\Entity\Role')
->findOneByUid($role->getId());
$roles[] = $role;
}
$contactEntity->setRolesForm($roles);
@ -133,9 +145,13 @@ class Contact
$contact->setUuid($contactEntity->getUuid());
}
public function fromDb(\PSC\Shop\ContactBundle\Model\Contact $contact, \PSC\Shop\EntityBundle\Entity\Contact $contactEntity): void
{
$contactDoc = $this->documentManager->getRepository(\PSC\Shop\EntityBundle\Document\Contact::class)->findOneBy(['uid' => $contactEntity->getUid()]);
public function fromDb(
\PSC\Shop\ContactBundle\Model\Contact $contact,
\PSC\Shop\EntityBundle\Entity\Contact $contactEntity,
): void {
$contactDoc = $this->documentManager
->getRepository(\PSC\Shop\EntityBundle\Document\Contact::class)
->findOneBy(['uid' => $contactEntity->getUid()]);
if (!$contactDoc) {
$contactDoc = new \PSC\Shop\EntityBundle\Document\Contact();
$contactDoc->setUid($contactEntity->getUid());
@ -147,91 +163,90 @@ class Contact
}
$contact->setAccount($account);
$contact->setUuid((string)$contactEntity->getUuid());
$contact->setEmail((string)$contactEntity->getEmail());
$contact->setUid((int)$contactEntity->getUid());
$contact->setUsername((string)$contactEntity->getEmail());
$contact->setUuid((string) $contactEntity->getUuid());
$contact->setEmail((string) $contactEntity->getEmail());
$contact->setUid((int) $contactEntity->getUid());
$contact->setUsername((string) $contactEntity->getEmail());
$contact->setCreated($contactEntity->getCreatedAt());
$contact->setUpdated($contactEntity->getUpdatedAt());
$contact->setCustomerNumber((string)$contactDoc->getKundenNr());
$contact->setCustomerNumber((string) $contactDoc->getKundenNr());
$contact->setLocked((bool)$contactEntity->isLocked());
$contact->setEnable((bool)$contactEntity->isEnabled());
$contact->setCollectingOrders((bool)$contactEntity->getCollectingOrders());
$contact->setLocked((bool) $contactEntity->isLocked());
$contact->setEnable((bool) $contactEntity->isEnabled());
$contact->setCollectingOrders((bool) $contactEntity->getCollectingOrders());
$contact->setAccountType($contactDoc->getAccountType());
$contact->setCustom1((string)$contactDoc->getCustom1());
$contact->setCustom2((string)$contactDoc->getCustom2());
$contact->setCustom3((string)$contactDoc->getCustom3());
$contact->setCustom4((string)$contactDoc->getCustom4());
$contact->setCustom5((string)$contactDoc->getCustom5());
$contact->setCustom6((string)$contactDoc->getCustom6());
$contact->setCustom7((string)$contactDoc->getCustom7());
$contact->setCustom8((string)$contactDoc->getCustom8());
$contact->setCustom9((string)$contactDoc->getCustom9());
$contact->setCustom10((string)$contactDoc->getCustom10());
$contact->setCustom11((string)$contactDoc->getCustom11());
$contact->setCustom12((string)$contactDoc->getCustom12());
$contact->setCustom13((string)$contactDoc->getCustom13());
$contact->setCustom14((string)$contactDoc->getCustom14());
$contact->setCustom15((string)$contactDoc->getCustom15());
$contact->setCustom16((string)$contactDoc->getCustom16());
$contact->setCustom17((string)$contactDoc->getCustom17());
$contact->setCustom18((string)$contactDoc->getCustom18());
$contact->setCustom19((string)$contactDoc->getCustom19());
$contact->setCustom20((string)$contactDoc->getCustom20());
$contact->setCustom21((string)$contactDoc->getCustom21());
$contact->setCustom22((string)$contactDoc->getCustom22());
$contact->setCustom23((string)$contactDoc->getCustom23());
$contact->setCustom24((string)$contactDoc->getCustom24());
$contact->setCountryCode((string)$contactEntity->getCountry());
$contact->setCustom1((string) $contactDoc->getCustom1());
$contact->setCustom2((string) $contactDoc->getCustom2());
$contact->setCustom3((string) $contactDoc->getCustom3());
$contact->setCustom4((string) $contactDoc->getCustom4());
$contact->setCustom5((string) $contactDoc->getCustom5());
$contact->setCustom6((string) $contactDoc->getCustom6());
$contact->setCustom7((string) $contactDoc->getCustom7());
$contact->setCustom8((string) $contactDoc->getCustom8());
$contact->setCustom9((string) $contactDoc->getCustom9());
$contact->setCustom10((string) $contactDoc->getCustom10());
$contact->setCustom11((string) $contactDoc->getCustom11());
$contact->setCustom12((string) $contactDoc->getCustom12());
$contact->setCustom13((string) $contactDoc->getCustom13());
$contact->setCustom14((string) $contactDoc->getCustom14());
$contact->setCustom15((string) $contactDoc->getCustom15());
$contact->setCustom16((string) $contactDoc->getCustom16());
$contact->setCustom17((string) $contactDoc->getCustom17());
$contact->setCustom18((string) $contactDoc->getCustom18());
$contact->setCustom19((string) $contactDoc->getCustom19());
$contact->setCustom20((string) $contactDoc->getCustom20());
$contact->setCustom21((string) $contactDoc->getCustom21());
$contact->setCustom22((string) $contactDoc->getCustom22());
$contact->setCustom23((string) $contactDoc->getCustom23());
$contact->setCustom24((string) $contactDoc->getCustom24());
$contact->setCountryCode((string) $contactEntity->getCountry());
$contact->getLayouterData()->setCompany((string)$contactEntity->getCompany());
$contact->getLayouterData()->setCompany2((string)$contactEntity->getCompany2());
$contact->getLayouterData()->setFirstname((string)$contactEntity->getFirstname());
$contact->getLayouterData()->setLastname((string)$contactEntity->getLastname());
$contact->getLayouterData()->setStreet((string)$contactEntity->getStreet());
$contact->getLayouterData()->setHouseNumber((string)$contactEntity->getHouseNumber());
$contact->getLayouterData()->setZip((string)$contactEntity->getZip());
$contact->getLayouterData()->setCity((string)$contactEntity->getCity());
$contact->getLayouterData()->setHomepage((string)$contactEntity->getHomepage());
$contact->getLayouterData()->setCompany((string) $contactEntity->getCompany());
$contact->getLayouterData()->setCompany2((string) $contactEntity->getCompany2());
$contact->getLayouterData()->setFirstname((string) $contactEntity->getFirstname());
$contact->getLayouterData()->setLastname((string) $contactEntity->getLastname());
$contact->getLayouterData()->setStreet((string) $contactEntity->getStreet());
$contact->getLayouterData()->setHouseNumber((string) $contactEntity->getHouseNumber());
$contact->getLayouterData()->setZip((string) $contactEntity->getZip());
$contact->getLayouterData()->setCity((string) $contactEntity->getCity());
$contact->getLayouterData()->setHomepage((string) $contactEntity->getHomepage());
$contact->getLayouterData()->setPhoneAppendix((string)$contactEntity->getPhoneAppendix());
$contact->getLayouterData()->setPhoneAreaCode((string)$contactEntity->getPhoneAreaCode());
$contact->getLayouterData()->setPhonePrefix((string)$contactEntity->getPhonePrefix());
$contact->getLayouterData()->setPhone((string)$contactEntity->getPhone());
$contact->getLayouterData()->setPhoneAppendix((string) $contactEntity->getPhoneAppendix());
$contact->getLayouterData()->setPhoneAreaCode((string) $contactEntity->getPhoneAreaCode());
$contact->getLayouterData()->setPhonePrefix((string) $contactEntity->getPhonePrefix());
$contact->getLayouterData()->setPhone((string) $contactEntity->getPhone());
$contact->getLayouterData()->setMobileAppendix((string)$contactEntity->getMobileAppendix());
$contact->getLayouterData()->setMobileAreaCode((string)$contactEntity->getMobileAreaCode());
$contact->getLayouterData()->setMobilePrefix((string)$contactEntity->getMobilePrefix());
$contact->getLayouterData()->setMobile((string)$contactEntity->getMobile());
$contact->getLayouterData()->setMobileAppendix((string) $contactEntity->getMobileAppendix());
$contact->getLayouterData()->setMobileAreaCode((string) $contactEntity->getMobileAreaCode());
$contact->getLayouterData()->setMobilePrefix((string) $contactEntity->getMobilePrefix());
$contact->getLayouterData()->setMobile((string) $contactEntity->getMobile());
$contact->getLayouterData()->setFaxAppendix((string)$contactEntity->getFaxAppendix());
$contact->getLayouterData()->setFaxAreaCode((string)$contactEntity->getFaxAreaCode());
$contact->getLayouterData()->setFaxPrefix((string)$contactEntity->getFaxPrefix());
$contact->getLayouterData()->setFax((string)$contactEntity->getFax());
$contact->getLayouterData()->setFaxAppendix((string) $contactEntity->getFaxAppendix());
$contact->getLayouterData()->setFaxAreaCode((string) $contactEntity->getFaxAreaCode());
$contact->getLayouterData()->setFaxPrefix((string) $contactEntity->getFaxPrefix());
$contact->getLayouterData()->setFax((string) $contactEntity->getFax());
$contact->getLayouterData()->setUstid((string)$contactEntity->getUstid());
$contact->getLayouterData()->setFunction((string)$contactEntity->getFunction());
$contact->getLayouterData()->setPosition((string)$contactEntity->getPosition());
$contact->getLayouterData()->setAbteilung((string)$contactEntity->getAbteilung());
$contact->getLayouterData()->setTitle((string)$contactEntity->getTitle());
$contact->getLayouterData()->setUstid((string) $contactEntity->getUstid());
$contact->getLayouterData()->setFunction((string) $contactEntity->getFunction());
$contact->getLayouterData()->setPosition((string) $contactEntity->getPosition());
$contact->getLayouterData()->setAbteilung((string) $contactEntity->getAbteilung());
$contact->getLayouterData()->setTitle((string) $contactEntity->getTitle());
$contact->getLayouterData()->setSettings($contactDoc->getLayouterSettings());
$contact->getLayouterData()->setCountryCode((string)$contactDoc->getLayouterCountryCode());
$contact->getLayouterData()->setCountryName((string)$contactDoc->getLayouterCountryName());
$contact->getLayouterData()->setCountryCode((string) $contactDoc->getLayouterCountryCode());
$contact->getLayouterData()->setCountryName((string) $contactDoc->getLayouterCountryName());
$contact->getLayouterData()->setBirthday((string)$contactEntity->getBirthday());
$contact->getLayouterData()->setKst((string)$contactEntity->getKostenstellung());
$contact->getLayouterData()->setUstid((string)$contactEntity->getUstid());
$contact->getLayouterData()->setDistrict((string)$contactEntity->getDestrict());
$contact->getLayouterData()->setState((string)$contactEntity->getState());
$contact->getLayouterData()->setBirthday((string) $contactEntity->getBirthday());
$contact->getLayouterData()->setKst((string) $contactEntity->getKostenstellung());
$contact->getLayouterData()->setUstid((string) $contactEntity->getUstid());
$contact->getLayouterData()->setDistrict((string) $contactEntity->getDistrict());
$contact->getLayouterData()->setState((string) $contactEntity->getState());
$contact->getLayouterData()->setEmail((string)$contactDoc->getLayouterEmail());
$contact->getLayouterData()->setEmail((string) $contactDoc->getLayouterEmail());
if ($contactEntity->getImage() != "") {
if ($contactEntity->getImage() != '') {
$media = $this->mediaManager->getMedia($contactEntity->getImage());
if ($media) {
$mediaModel = new Media();
@ -239,7 +254,7 @@ class Contact
$contact->getLayouterData()->setImage1($mediaModel);
}
}
if ($contactEntity->getImage2() != "") {
if ($contactEntity->getImage2() != '') {
$media = $this->mediaManager->getMedia($contactEntity->getImage2());
if ($media) {
$mediaModel = new Media();

View File

@ -13,9 +13,9 @@
namespace PSC\Shop\EntityBundle\Document;
use Doctrine\ODM\MongoDB\Mapping\Annotations\Document;
use Doctrine\ODM\MongoDB\Mapping\Annotations\Field;
use Doctrine\ODM\MongoDB\Mapping\Annotations\Id;
use Doctrine\ODM\MongoDB\Mapping\Annotations\Document;
#[Document]
class Product
@ -272,6 +272,11 @@ class Product
#[Field(type: 'bool')]
protected $uploadProvidedDownload = false;
#[Field(type: 'string')]
protected null|string $aribaUnitOfMeasure = '';
#[Field(type: 'string')]
protected null|string $aribaUNSPSC = '';
/**
* @var string $uploadProvidedFile;
@ -289,7 +294,7 @@ class Product
*/
public function getSalesUnit(): int
{
return (int)$this->salesUnit;
return (int) $this->salesUnit;
}
/**
@ -305,7 +310,7 @@ class Product
*/
public function getBaseUnit(): int
{
return (int)$this->baseUnit;
return (int) $this->baseUnit;
}
/**
@ -321,7 +326,7 @@ class Product
*/
public function getPackagingUnit(): int
{
return (int)$this->packagingUnit;
return (int) $this->packagingUnit;
}
/**
@ -763,14 +768,11 @@ class Product
return $this->collectingOrdersAccountFilter;
}
/**
* @return array
*/
public function getPluginSettings()
{
return $this->pluginSettings;
}
@ -790,16 +792,16 @@ class Product
*/
public function setPluginSettingModule($module, $key, $value)
{
$this->pluginSettings[$module ] [$key] = $value;
$this->pluginSettings[$module][$key] = $value;
}
public function getPluginSettingModule($module, $key)
{
if (!isset($this->pluginSettings[$module ]) || !isset($this->pluginSettings[$module ] [$key])) {
if (!isset($this->pluginSettings[$module]) || !isset($this->pluginSettings[$module][$key])) {
return null;
}
return $this->pluginSettings[$module ] [$key];
return $this->pluginSettings[$module][$key];
}
/**
@ -879,7 +881,7 @@ class Product
*/
public function getUploadFromLatestOrderInitalStatus(): int
{
return (int)$this->uploadFromLatestOrderInitalStatus;
return (int) $this->uploadFromLatestOrderInitalStatus;
}
/**
@ -895,7 +897,7 @@ class Product
*/
public function isUploadFromLatestOrder(): bool
{
return (bool)$this->uploadFromLatestOrder;
return (bool) $this->uploadFromLatestOrder;
}
/**
@ -911,7 +913,7 @@ class Product
*/
public function getUploadProvidedInitalStatus(): int
{
return (int)$this->uploadProvidedInitalStatus;
return (int) $this->uploadProvidedInitalStatus;
}
/**
@ -927,7 +929,7 @@ class Product
*/
public function isUploadProvided(): bool
{
return (bool)$this->uploadProvided;
return (bool) $this->uploadProvided;
}
/**
@ -943,7 +945,7 @@ class Product
*/
public function getUploadProvidedFile(): string
{
return (string)$this->uploadProvidedFile;
return (string) $this->uploadProvidedFile;
}
/**
@ -1024,11 +1026,31 @@ class Product
public function isRawText(): bool
{
return (bool)$this->rawText;
return (bool) $this->rawText;
}
public function setRawText(bool $var): void
{
$this->rawText = $var;
}
public function setAribaUNSPSC(null|string $aribaUNSPSC): void
{
$this->aribaUNSPSC = $aribaUNSPSC;
}
public function getAribaUNSPSC(): null|string
{
return $this->aribaUNSPSC;
}
public function setAribaUnitOfMeasure(null|string $aribaUnitOfMeasure): void
{
$this->aribaUnitOfMeasure = $aribaUnitOfMeasure;
}
public function getAribaUnitOfMeasure(): null|string
{
return $this->aribaUnitOfMeasure;
}
}

View File

@ -13,8 +13,8 @@
namespace PSC\Shop\EntityBundle\Entity;
use Doctrine\ORM\Mapping as ORM;
use Doctrine\Common\Collections\ArrayCollection;
use Doctrine\ORM\Mapping as ORM;
/**
* Account
@ -66,7 +66,7 @@ class Account
* @var string
*/
#[ORM\Column(name: 'destrict', type: 'string', length: 255)]
protected $destrict;
protected $district;
/**
*
* @var string
@ -450,7 +450,6 @@ class Account
#[ORM\ManyToMany(targetEntity: 'Cms', inversedBy: 'accounts')]
public $cms;
/**
* Constructor
* @param null $id
@ -530,9 +529,9 @@ class Account
*/
public function getArray()
{
return array(
'title' => $this->getTitle()
);
return [
'title' => $this->getTitle(),
];
}
/**
@ -671,20 +670,14 @@ class Account
$this->street = $street;
}
/**
* @return string
*/
public function getDestrict()
public function getDistrict(): string
{
return $this->destrict;
return (string) $this->district;
}
/**
* @param string $destrict
*/
public function setDestrict($destrict)
public function setDistrict($district): void
{
$this->destrict = $destrict;
$this->district = $district;
}
/**

View File

@ -187,12 +187,12 @@ class Contact implements UserInterface, PasswordAuthenticatedUserInterface, \Ser
*
* @param string $email Emailadresse
*/
public function __construct($email = "")
public function __construct($email = '')
{
$this->createdAt = new \DateTime();
$this->updatedAt = new \DateTime();
$this->uuid = Uuid::uuid4();
if ($email == "") {
if ($email == '') {
$this->setEmail($this->uuid);
} else {
$this->setEmail($email);
@ -251,7 +251,7 @@ class Contact implements UserInterface, PasswordAuthenticatedUserInterface, \Ser
$this->username = $username;
}
public function getPassword(): ?string
public function getPassword(): null|string
{
return $this->password;
}
@ -263,7 +263,7 @@ class Contact implements UserInterface, PasswordAuthenticatedUserInterface, \Ser
*/
public function setPassword($password)
{
if ($password != "") {
if ($password != '') {
$this->password = $password;
}
}
@ -280,13 +280,12 @@ class Contact implements UserInterface, PasswordAuthenticatedUserInterface, \Ser
public function asArray()
{
return array(
return [
'id' => $this->getId(),
'email' => $this->getUsername()
);
'email' => $this->getUsername(),
];
}
/**
* Returns the salt that was originally used to encode the password.
*
@ -339,6 +338,7 @@ class Contact implements UserInterface, PasswordAuthenticatedUserInterface, \Ser
*
* @return string
*/
#[\Override]
public function __toString()
{
return $this->getEmail();
@ -474,7 +474,7 @@ class Contact implements UserInterface, PasswordAuthenticatedUserInterface, \Ser
* @var string
*/
#[ORM\Column(name: 'self_destrict', type: 'string', length: 255, nullable: true)]
private $destrict;
private $district;
/**
* @var string
@ -508,7 +508,7 @@ class Contact implements UserInterface, PasswordAuthenticatedUserInterface, \Ser
#[ORM\Column(name: 'self_foto', type: 'string', length: 255, nullable: true)]
private $image;
#
#[ORM\Column(name: 'foto', type: 'string', length: 255, nullable: true)]
private $image2;
@ -922,7 +922,6 @@ class Contact implements UserInterface, PasswordAuthenticatedUserInterface, \Ser
$this->ustid = $ustid;
}
/**
* @return ContactAddress
*/
@ -1062,16 +1061,16 @@ class Contact implements UserInterface, PasswordAuthenticatedUserInterface, \Ser
public function anonymisieren()
{
$this->setFirstname("anonym");
$this->setLastname("anonym");
$this->setAbteilung("anonym");
$this->setStreet("anonym");
$this->setHouseNumber("anonym");
$this->setZip("anonym");
$this->setCity("anonym");
$this->setCountry("anonym");
$this->setPosition("anonym");
$this->setPhone("anonym");
$this->setFirstname('anonym');
$this->setLastname('anonym');
$this->setAbteilung('anonym');
$this->setStreet('anonym');
$this->setHouseNumber('anonym');
$this->setZip('anonym');
$this->setCity('anonym');
$this->setCountry('anonym');
$this->setPosition('anonym');
$this->setPhone('anonym');
$this->setPhoneAreaCode('');
$this->setPhonePrefix('');
$this->setPhoneAppendix('');
@ -1088,8 +1087,8 @@ class Contact implements UserInterface, PasswordAuthenticatedUserInterface, \Ser
$this->setName('anonym@anonym.de');
$this->setEnable(false);
$this->setPassword('anonym');
$this->setImage("");
$this->setImage2("");
$this->setImage('');
$this->setImage2('');
}
/**
@ -1627,17 +1626,14 @@ class Contact implements UserInterface, PasswordAuthenticatedUserInterface, \Ser
/**
* @return string
*/
public function getDestrict()
public function getDistrict()
{
return $this->destrict;
return $this->district;
}
/**
* @param string $destrict
*/
public function setDestrict($destrict)
public function setDistrict($district)
{
$this->destrict = $destrict;
$this->district = $district;
}
/**
@ -1783,6 +1779,7 @@ class Contact implements UserInterface, PasswordAuthenticatedUserInterface, \Ser
{
$this->abteilung = $abteilung;
}
/**
* @return string
*/
@ -2341,28 +2338,28 @@ class Contact implements UserInterface, PasswordAuthenticatedUserInterface, \Ser
public function getRolesAsString()
{
$temp = array();
$temp = [];
foreach ($this->roles as $row) {
if ($row->getLevel() == 10 || $row->getLevel() == 20) {
$temp[] = "ROLE_USER";
$temp[] = 'ROLE_USER';
}
if ($row->getLevel() == 25) {
$temp[] = "ROLE_PRODUCT_EDITOR";
$temp[] = 'ROLE_PRODUCT_EDITOR';
}
if ($row->getLevel() == 30) {
$temp[] = "ROLE_SHOP_OPERATOR";
$temp[] = 'ROLE_SHOP_OPERATOR';
}
if ($row->getLevel() == 35) {
$temp[] = "ROLE_PRODUCTION";
$temp[] = 'ROLE_PRODUCTION';
}
if ($row->getLevel() == 40) {
$temp[] = "ROLE_ADMIN";
$temp[] = 'ROLE_ADMIN';
}
if ($row->getLevel() == 50) {
$temp[] = "ROLE_SYSTEM_ADMIN";
$temp[] = 'ROLE_SYSTEM_ADMIN';
}
if (!in_array($row->getLevel(), [10,20,25,30,35,40,50,0])) {
if (!in_array($row->getLevel(), [10, 20, 25, 30, 35, 40, 50, 0])) {
$temp[] = $row->getTitle();
}
}
@ -2699,7 +2696,7 @@ class Contact implements UserInterface, PasswordAuthenticatedUserInterface, \Ser
'id' => $this->getId(),
'email' => $this->getEmail(),
'password' => $this->getPassword(),
'roles' => $this->getRolesForm()
'roles' => $this->getRolesForm(),
];
}
@ -2709,19 +2706,20 @@ class Contact implements UserInterface, PasswordAuthenticatedUserInterface, \Ser
$this->setEmail($data['email']);
$this->setPassword($data['password']);
$this->setRolesForm($data['roles']);
}
#[\Override]
public function serialize()
{
return serialize([
'id' => $this->getId(),
'email' => $this->getEmail(),
'password' => $this->getPassword(),
'roles' => $this->getRolesForm()
'roles' => $this->getRolesForm(),
]);
}
#[\Override]
public function unserialize($data)
{
$unserialized = unserialize($data);

View File

@ -54,6 +54,9 @@ class Product
protected $weight;
protected $rawText = false;
protected $text;
protected null|string $aribaUnitOfMeasure = '';
protected null|string $aribaUNSPSC = '';
/**
* @var integer
*/
@ -127,7 +130,7 @@ class Product
*/
public function isUploadProvidedDownload(): bool
{
return (bool)$this->uploadProvidedDownload;
return (bool) $this->uploadProvidedDownload;
}
/**
@ -213,7 +216,6 @@ class Product
#[ORM\Column(name: 'sub_title', type: 'string', length: 255)]
protected $subTitle;
/**
* Art des Product
*
@ -906,48 +908,45 @@ class Product
*/
public function getExportArray()
{
return array(
'id' => (string)$this->getId(),
'uid' => (string)$this->getUID(),
'uuid' => (string)$this->getUUID(),
'title' => (string)$this->getTitle(),
'subTitle' => (string)$this->getSubTitle(),
'textArt' => (string)$this->getTextArt(),
'textFormat' => (string)$this->getTextFormat(),
'nrExtern' => (string)$this->getNrExtern(),
'nrIntern' => (string)$this->getNrIntern(),
'ablaufDatum' => ($this->ablaufDatum == null) ? '' : $this->ablaufDatum->format("d.m.Y"),
'ansprechPartner' => (string)$this->ansprechPartner,
'preis' => (string)$this->getPrice(),
'enable' => (string)$this->isEnable(),
'shopId' => (string)$this->getShop()->getUid(),
'productType' => (string)$this->getType(),
'isStock' => $this->isStock() ? "1" : "0",
'stockCount' => (string)$this->getStockCount(),
'stockMinCount' => (string)$this->getStockMinCount(),
'stockPlace' => (string)$this->getStockPlace(),
'stockMaxBuy' => (string)$this->getStockMaxBuy(),
'buyed' => (string)$this->getBuyed(),
'printPartnerEmail' => (string)$this->getPrintPartnerEmail(),
'zusatzAbmessung' => (string)$this->getZusatzAbmessung(),
'zusatzDesigner' => (string)$this->getZusatzDesigner(),
'zusatzShipping' => (string)$this->getZusatzShipping(),
'custom1' => (string)$this->getCustom1(),
'custom2' => (string)$this->getCustom2(),
'custom3' => (string)$this->getCustom3(),
'custom4' => (string)$this->getCustom4(),
'custom5' => (string)$this->getCustom5(),
'custom6' => (string)$this->getCustom6(),
'custom7' => (string)$this->getCustom7(),
'custom8' => (string)$this->getCustom8(),
'custom9' => (string)$this->getCustom9(),
'custom10' => (string)$this->getCustom10(),
'custom11' => (string)$this->getCustom11(),
'custom12' => (string)$this->getCustom12(),
);
return [
'id' => (string) $this->getId(),
'uid' => (string) $this->getUID(),
'uuid' => (string) $this->getUUID(),
'title' => (string) $this->getTitle(),
'subTitle' => (string) $this->getSubTitle(),
'textArt' => (string) $this->getTextArt(),
'textFormat' => (string) $this->getTextFormat(),
'nrExtern' => (string) $this->getNrExtern(),
'nrIntern' => (string) $this->getNrIntern(),
'ablaufDatum' => $this->ablaufDatum == null ? '' : $this->ablaufDatum->format('d.m.Y'),
'ansprechPartner' => (string) $this->ansprechPartner,
'preis' => (string) $this->getPrice(),
'enable' => (string) $this->isEnable(),
'shopId' => (string) $this->getShop()->getUid(),
'productType' => (string) $this->getType(),
'isStock' => $this->isStock() ? '1' : '0',
'stockCount' => (string) $this->getStockCount(),
'stockMinCount' => (string) $this->getStockMinCount(),
'stockPlace' => (string) $this->getStockPlace(),
'stockMaxBuy' => (string) $this->getStockMaxBuy(),
'buyed' => (string) $this->getBuyed(),
'printPartnerEmail' => (string) $this->getPrintPartnerEmail(),
'zusatzAbmessung' => (string) $this->getZusatzAbmessung(),
'zusatzDesigner' => (string) $this->getZusatzDesigner(),
'zusatzShipping' => (string) $this->getZusatzShipping(),
'custom1' => (string) $this->getCustom1(),
'custom2' => (string) $this->getCustom2(),
'custom3' => (string) $this->getCustom3(),
'custom4' => (string) $this->getCustom4(),
'custom5' => (string) $this->getCustom5(),
'custom6' => (string) $this->getCustom6(),
'custom7' => (string) $this->getCustom7(),
'custom8' => (string) $this->getCustom8(),
'custom9' => (string) $this->getCustom9(),
'custom10' => (string) $this->getCustom10(),
'custom11' => (string) $this->getCustom11(),
'custom12' => (string) $this->getCustom12(),
];
}
/**
@ -975,33 +974,33 @@ class Product
*
* @return string
*/
#[\Override]
public function __toString()
{
return $this->getTitle();
}
public function getTitle(): ?string
public function getTitle(): null|string
{
return $this->title;
}
public function getTitleSubTitle(): ?string
public function getTitleSubTitle(): null|string
{
return $this->title . ' ' . $this->subTitle;
}
public function setTitle(?string $title): void
public function setTitle(null|string $title): void
{
$this->title = $title;
}
public function getSubTitle(): ?string
public function getSubTitle(): null|string
{
return $this->subTitle;
}
public function setSubTitle(?string $subTitle): void
public function setSubTitle(null|string $subTitle): void
{
$this->subTitle = $subTitle;
}
@ -1280,7 +1279,7 @@ class Product
public function hasCalcXml()
{
return ($this->calcXml != "" && strpos($this->calcXml, "artikel") !== false);
return $this->calcXml != '' && str_contains($this->calcXml, 'artikel');
}
/**
@ -1320,8 +1319,8 @@ class Product
*/
public function getLangData()
{
if ($this->langData == "") {
return array();
if ($this->langData == '') {
return [];
}
return json_decode($this->langData, true);
}
@ -1332,7 +1331,7 @@ class Product
public function setLangData($langData)
{
if (!is_array($langData)) {
$langData = array();
$langData = [];
}
$this->langData = json_encode($langData);
}
@ -1359,7 +1358,7 @@ class Product
public function getPackageFormat()
{
if ($this->packageFormat === null) {
return "";
return '';
}
return $this->packageFormat;
}
@ -2841,7 +2840,7 @@ class Product
*/
public function getSetConfig(bool $asArray = false)
{
if ($this->setConfig != "") {
if ($this->setConfig != '') {
$setConfig = json_decode($this->setConfig, $asArray);
if (is_array($setConfig) && count($setConfig) > 0) {
@ -2965,7 +2964,7 @@ class Product
*/
public function getBaseUnit(): int
{
return (int)$this->baseUnit;
return (int) $this->baseUnit;
}
/**
@ -2981,7 +2980,7 @@ class Product
*/
public function getSalesUnit(): int
{
return (int)$this->salesUnit;
return (int) $this->salesUnit;
}
/**
@ -2997,7 +2996,7 @@ class Product
*/
public function getPackagingUnit(): int
{
return (int)$this->packagingUnit;
return (int) $this->packagingUnit;
}
/**
@ -3013,7 +3012,7 @@ class Product
*/
public function isUploadFromLatestOrder(): bool
{
return (bool)$this->uploadFromLatestOrder;
return (bool) $this->uploadFromLatestOrder;
}
/**
@ -3029,7 +3028,7 @@ class Product
*/
public function getUploadFromLatestOrderInitalStatus(): int
{
return (int)$this->uploadFromLatestOrderInitalStatus;
return (int) $this->uploadFromLatestOrderInitalStatus;
}
/**
@ -3045,7 +3044,7 @@ class Product
*/
public function isUploadProvided(): bool
{
return (bool)$this->uploadProvided;
return (bool) $this->uploadProvided;
}
/**
@ -3061,7 +3060,7 @@ class Product
*/
public function getUploadProvidedFile(): string
{
return (string)$this->uploadProvidedFile;
return (string) $this->uploadProvidedFile;
}
/**
@ -3077,7 +3076,7 @@ class Product
*/
public function getUploadProvidedInitalStatus(): int
{
return (int)$this->uploadProvidedInitalStatus;
return (int) $this->uploadProvidedInitalStatus;
}
/**
@ -3139,13 +3138,34 @@ class Product
{
$this->noIndex = $noIndex;
}
public function isRawText(): bool
{
return (bool)$this->rawText;
return (bool) $this->rawText;
}
public function setRawText(bool $rawText): void
{
$this->rawText = $rawText;
}
public function setAribaUnitOfMeasure(null|string $aribaUnitOfMeasure): void
{
$this->aribaUnitOfMeasure = $aribaUnitOfMeasure;
}
public function getAribaUnitOfMeasure(): null|string
{
return $this->aribaUnitOfMeasure;
}
public function setAribaUNSPSC(null|string $aribaUNSPSC): void
{
$this->aribaUNSPSC = $aribaUNSPSC;
}
public function getAribaUNSPSC(): null|string
{
return $this->aribaUNSPSC;
}
}

View File

@ -27,7 +27,7 @@ class All extends AbstractController
description: 'get all media',
content: new JsonContent(ref: new Model(type: PSCAll::class)),
)]
#[Route(path: '/media/all{:uuid}', methods: ['GET'])]
#[Route(path: '/media/all', methods: ['GET'])]
#[Tag('Media')]
#[IsGranted('ROLE_ADMIN')]
#[Security(name: 'Bearer')]

View File

@ -51,6 +51,7 @@ class AllFolderPage extends AbstractController
$f = new PSCMedia();
$f->setTitle($media->getTitle());
$f->setUrl($media->getUrl());
$f->setUuid($media->getId());
$output->data[] = $f;
}
return $this->json($output);

View File

@ -0,0 +1,29 @@
<?php
namespace PSC\Shop\MediaBundle\Api;
use Doctrine\ODM\MongoDB\DocumentManager;
use Knp\Component\Pager\PaginatorInterface;
use Nelmio\ApiDocBundle\Attribute\Model;
use OpenApi\Attributes\JsonContent;
use OpenApi\Attributes\Response;
use OpenApi\Attributes\Tag;
use PSC\Shop\MediaBundle\Model\Media;
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
use Symfony\Component\Routing\Attribute\Route;
class One extends AbstractController
{
public function __construct(
private readonly DocumentManager $dm,
private readonly PaginatorInterface $paginator,
) {}
#[Response(response: 200, description: 'get media', content: new JsonContent(ref: new Model(type: Media::class)))]
#[Route(path: '/media/{uuid}', methods: ['GET'])]
#[Tag('Media')]
public function one(string $uuid): string
{
return $this->json(new Media());
}
}

View File

@ -3,22 +3,22 @@
namespace PSC\Shop\MediaBundle\Api;
use Doctrine\ODM\MongoDB\DocumentManager;
use Nelmio\ApiDocBundle\Annotation\Model;
use Nelmio\ApiDocBundle\Annotation\Security;
use OpenApi\Annotations as OA;
use PSC\Shop\MediaBundle\Document\Embed\Variant;
use PSC\Shop\MediaBundle\Document\Media;
use PSC\Shop\MediaBundle\Model\Media as MediaModel;
use PSC\Shop\MediaBundle\Helper\MediaManager;
use PSC\Shop\MediaBundle\Model\Media as MediaModel;
use PSC\Shop\MediaBundle\Service\MediaManager as PSCMediaManager;
use PSC\Shop\MediaBundle\Transformer\Media as PSCMedia;
use PSC\System\SettingsBundle\Service\Shop;
use Sensio\Bundle\FrameworkExtraBundle\Configuration\IsGranted;
use Sensio\Bundle\FrameworkExtraBundle\Configuration\ParamConverter;
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
use Symfony\Component\HttpFoundation\JsonResponse;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\Routing\Attribute\Route;
use OpenApi\Annotations as OA;
use Nelmio\ApiDocBundle\Annotation\Security;
use Sensio\Bundle\FrameworkExtraBundle\Configuration\IsGranted;
use Nelmio\ApiDocBundle\Annotation\Model;
class UploadVariant extends AbstractController
{
@ -28,7 +28,7 @@ class UploadVariant extends AbstractController
* @OA\Response(
* response=200,
* description="media",
* @OA\JsonContent(ref=@Model(type=\PSC\Shop\MediaBundle\Model\Media::class))
* @OA\JsonContent(ref=\PSC\Shop\MediaBundle\Model\Media::class)
* )
* @OA\RequestBody(
* description="This is a request body",
@ -61,8 +61,14 @@ class UploadVariant extends AbstractController
* @Security(name="Bearer")
*/
#[Route(path: '/variant/create', methods: ['POST'])]
public function create(PSCMediaManager $mediaService, PSCMedia $mediaTransformer, MediaManager $mediaManager, Shop $shopService, DocumentManager $documentManager, Request $req): JsonResponse
{
public function create(
PSCMediaManager $mediaService,
PSCMedia $mediaTransformer,
MediaManager $mediaManager,
Shop $shopService,
DocumentManager $documentManager,
Request $req,
): JsonResponse {
$mediaVariant = new Variant();
$media = $mediaService->getMedia($req->get('uuid'));
@ -79,5 +85,4 @@ class UploadVariant extends AbstractController
$mediaTransformer->fromDb($mediaModel, $media);
return $this->json($mediaModel);
}
}

View File

@ -3,17 +3,14 @@
namespace PSC\Shop\PaymentBundle\Api;
use Doctrine\ORM\EntityManagerInterface;
use Nelmio\ApiDocBundle\Attribute\Security;
use PSC\Shop\EntityBundle\Entity\Payment;
use PSC\Shop\PaymentBundle\Dto\All\Output;
use PSC\Shop\PaymentBundle\Model\Payment as PSCPayment;
use PSC\System\SettingsBundle\Service\Shop;
use Sensio\Bundle\FrameworkExtraBundle\Configuration\IsGranted;
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
use Symfony\Component\HttpFoundation\JsonResponse;
use Symfony\Component\Routing\Annotation\Route;
use OpenApi\Annotations as OA;
use Nelmio\ApiDocBundle\Annotation\Model;
use Nelmio\ApiDocBundle\Annotation\Security;
use Sensio\Bundle\FrameworkExtraBundle\Configuration\IsGranted;
use Symfony\Component\Security\Core\Authentication\Token\Storage\TokenStorageInterface;
class All extends AbstractController
@ -24,28 +21,29 @@ class All extends AbstractController
private TokenStorageInterface $tokenStorage;
public function __construct(EntityManagerInterface $entityManager, Shop $shopService, TokenStorageInterface $tokenStorage)
{
public function __construct(
EntityManagerInterface $entityManager,
Shop $shopService,
TokenStorageInterface $tokenStorage,
) {
$this->entityManager = $entityManager;
$this->shopService = $shopService;
$this->tokenStorage = $tokenStorage;
}
/**
* get all payments
*
* @OA\Response(
* response=200,
* description="payments",
* @OA\JsonContent(ref=@Model(type=\PSC\Shop\PaymentBundle\Dto\All\Output::class))
* )
* @OA\Tag(name="Payment")
*/
#[Response(
response: 200,
description: 'get payments',
content: new JsonContent(ref: new Model(type: Output::class)),
)]
#[Tag(name: 'Payment')]
#[Route(path: '/', methods: ['GET'])]
public function all(): JsonResponse
{
$output = [];
$result = $this->entityManager->getRepository(Payment::class)->findBy(['shop' => $this->shopService->getShopByDomain(), 'private' => 0]);
$result = $this->entityManager
->getRepository(Payment::class)
->findBy(['shop' => $this->shopService->getShopByDomain(), 'private' => 0]);
/** Payment $payment */
foreach ($result as $payment) {
@ -58,17 +56,13 @@ class All extends AbstractController
return $this->json(new Output($output));
}
/**
* get all payments by Shop Uuid
*
* @OA\Response(
* response=200,
* description="payments",
* @OA\JsonContent(ref=@Model(type=\PSC\Shop\PaymentBundle\Dto\All\Output::class))
* )
* @OA\Tag(name="Payment")
* @Security(name="Bearer")
*/
#[Response(
response: 200,
description: 'get payments by shops',
content: new JsonContent(ref: new Model(type: Output::class)),
)]
#[Tag(name: 'Payment')]
#[Security(name: 'Bearer')]
#[Route(path: '/by/shop/{shopUuid}', methods: ['GET'])]
#[IsGranted('ROLE_SHOP')]
public function byShops(string $shopUuid): JsonResponse
@ -89,23 +83,21 @@ class All extends AbstractController
return $this->json(new Output($output));
}
/**
* get all payments
*
* @OA\Response(
* response=200,
* description="get my payments",
* @OA\JsonContent(ref=@Model(type=\PSC\Shop\PaymentBundle\Dto\All\Output::class))
* )
* @OA\Tag(name="Payment")
* @Security(name="Bearer")
*/
#[Response(
response: 200,
description: 'get my payments ',
content: new JsonContent(ref: new Model(type: Output::class)),
)]
#[Tag(name: 'Payment')]
#[Security(name: 'Bearer')]
#[Route(path: '/my', methods: ['GET'])]
#[IsGranted('ROLE_USER')]
public function my(): JsonResponse
{
$output = [];
$result = $this->entityManager->getRepository(Payment::class)->findBy(['shop' => $this->shopService->getShopByDomain(), 'private' => 0]);
$result = $this->entityManager
->getRepository(Payment::class)
->findBy(['shop' => $this->shopService->getShopByDomain(), 'private' => 0]);
/** Payment $payment */
foreach ($result as $payment) {

View File

@ -3,39 +3,40 @@
namespace PSC\Shop\PaymentBundle\Api;
use Doctrine\ORM\EntityManagerInterface;
use Nelmio\ApiDocBundle\Attribute\Model;
use OpenApi\Attributes\JsonContent;
use OpenApi\Attributes\Response;
use OpenApi\Attributes\Tag;
use PSC\Component\ApiBundle\Dto\Error\NotFound;
use PSC\Shop\EntityBundle\Entity\Payment as PSCPayment;
use PSC\Shop\PaymentBundle\Model\Payment;
use PSC\System\SettingsBundle\Service\Shop;
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
use Symfony\Component\Routing\Annotation\Route;
use OpenApi\Annotations as OA;
use Nelmio\ApiDocBundle\Annotation\Model;
class One extends AbstractController
{
private EntityManagerInterface $entityManager;
private Shop $shopService;
public function __construct(EntityManagerInterface $entityManager, Shop $shopService)
{
$this->entityManager = $entityManager;
$this->shopService = $shopService;
}
/**
* get one payment
*
* @OA\Response(
* response=200,
* description="orders",
* @OA\JsonContent(ref=@Model(type=\PSC\Shop\PaymentBundle\Model\Payment::class))
* )
* @OA\Tag(name="Payment")
*/
#[Response(
response: 200,
description: 'get Payment',
content: new JsonContent(ref: new Model(type: Payment::class)),
)]
#[Tag(name: 'Payment')]
#[Route(path: '/{id}', methods: ['GET'])]
public function one(string $id)
{
$result = $this->entityManager->getRepository(PSCPayment::class)->findOneBy(['shop' => $this->shopService->getShopByDomain(), 'private' => 0, 'uid' => $id]);
$result = $this->entityManager
->getRepository(PSCPayment::class)
->findOneBy(['shop' => $this->shopService->getShopByDomain(), 'private' => 0, 'uid' => $id]);
if ($result) {
$output = new Payment();
$output->setTitle($result->getTitle());

View File

@ -1,23 +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\ProductBundle\Controller\Backend\Product;
use Doctrine\ODM\MongoDB\DocumentManager;
use Doctrine\ORM\EntityManager;
use Doctrine\ORM\EntityManagerInterface;
use Knp\Component\Pager\PaginatorInterface;
use Doctrine\ORM\Mapping\Entity;
use Knp\Component\Pager\PaginatorInterface;
use PSC\Shop\EntityBundle\Document\Queue;
use PSC\Shop\EntityBundle\Document\Shop;
use PSC\Shop\EntityBundle\Entity\Account;
@ -29,21 +18,22 @@ use PSC\Shop\ProductBundle\Document\Product\History as PSCHistory;
use PSC\Shop\ProductBundle\Form\Backend\Product\ProductType;
use PSC\Shop\ProductBundle\PSCShopProductBundle;
use PSC\System\PluginBundle\Form\Chain\Field;
use PSC\System\PluginBundle\Model\PluginButtonArea;
use PSC\System\SettingsBundle\Document\LogEntry;
use PSC\System\SettingsBundle\Form\Backend\CopyType;
use PSC\System\SettingsBundle\Service\History;
use PSC\System\SettingsBundle\Service\Log;
use PSC\System\SettingsBundle\Service\Status;
use Ramsey\Uuid\Uuid;
use Sensio\Bundle\FrameworkExtraBundle\Configuration\Security;
use Sensio\Bundle\FrameworkExtraBundle\Configuration\Template;
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;
use PSC\System\SettingsBundle\Service\Status;
use Symfony\Component\HttpFoundation\Session\SessionInterface;
use Symfony\Component\Routing\Annotation\Route;
use Symfony\Component\Security\Core\SecurityContext;
/**
* DashboardController fürs Backend
@ -68,20 +58,17 @@ class EditController extends AbstractController
#[Route(path: '/edit/save/lang/data/{uid}', name: 'backend_production_product_edit_save_lang_data')]
public function saveLangDataAction(Request $request, EntityManagerInterface $entityManager, $uid)
{
$product = $entityManager
->getRepository('PSC\Shop\EntityBundle\Entity\Product')->findOneBy(['uid' => $uid]);
$product = $entityManager->getRepository('PSC\Shop\EntityBundle\Entity\Product')->findOneBy(['uid' => $uid]);
if ($product) {
$tmp = $product->getLangData();
$tmp[$request->getPayload()->get('langcode')] = [
'title' => $request->getPayload()->get('title'),
'einleitung' => $request->getPayload()->get('einleitung'),
'text_art' => $request->getPayload()->get('text_art'),
'info' => $request->getPayload()->get('info'),
'uuid' => Uuid::uuid4()
'uuid' => Uuid::uuid4(),
];
$product->setLangData($tmp);
@ -103,14 +90,19 @@ class EditController extends AbstractController
#[Route(path: '/edit/add/lang/data/{uid}', name: 'backend_production_product_edit_add_lang_data')]
public function addLangDataAction(Request $request, EntityManagerInterface $entityManager, $uid)
{
$product = $entityManager
->getRepository('PSC\Shop\EntityBundle\Entity\Product')->findOneBy(['uid' => $uid]);
$product = $entityManager->getRepository('PSC\Shop\EntityBundle\Entity\Product')->findOneBy(['uid' => $uid]);
if ($product) {
$tmp = $product->getLangData();
if (!isset($tmp[$request->getPayload()->get('langcode')])) {
$tmp[$request->getPayload()->get('langcode')] = ['title' => $product->getTitle(), 'einleitung' => '', 'text_art' => '', 'info' => '', 'uuid' => Uuid::uuid4()];
$tmp[$request->getPayload()->get('langcode')] = [
'title' => $product->getTitle(),
'einleitung' => '',
'text_art' => '',
'info' => '',
'uuid' => Uuid::uuid4(),
];
$product->setLangData($tmp);
$entityManager->persist($product);
@ -132,11 +124,10 @@ class EditController extends AbstractController
#[Route(path: '/edit/fetch/lang/data/{uid}', name: 'backend_production_product_edit_fetch_lang_data')]
public function fetchLangDataAction(Request $request, EntityManagerInterface $entityManager, $uid)
{
$product = $entityManager
->getRepository('PSC\Shop\EntityBundle\Entity\Product')->findOneBy(['uid' => $uid]);
$product = $entityManager->getRepository('PSC\Shop\EntityBundle\Entity\Product')->findOneBy(['uid' => $uid]);
if ($product) {
$tmp = array();
$tmp = [];
foreach ($product->getLangData() as $key => $row) {
$tmp[] = [
@ -145,7 +136,7 @@ class EditController extends AbstractController
'einleitung' => $row['einleitung'],
'text_art' => $row['text_art'],
'info' => $row['info'],
'uuid' => $row['uuid']
'uuid' => $row['uuid'],
];
}
@ -166,25 +157,30 @@ class EditController extends AbstractController
* @throws \Doctrine\ORM\ORMException
*/
#[Route(path: '/edit/check/url/{url}', name: 'backend_production_product_check_url')]
public function checkUrlAction(Request $request, EntityManagerInterface $entityManager, \PSC\System\SettingsBundle\Service\Shop $shopService, $url)
{
public function checkUrlAction(
Request $request,
EntityManagerInterface $entityManager,
\PSC\System\SettingsBundle\Service\Shop $shopService,
$url,
) {
/**
* @var \PSC\Shop\EntityBundle\Entity\Shop $selectedShop
*/
*/
$selectedShop = $shopService->getSelectedShop();
$products = $entityManager
->getRepository('PSC\Shop\EntityBundle\Entity\Product')->findBy(array('enable' => 1, 'url' => $url, 'shop' => $selectedShop));
->getRepository('PSC\Shop\EntityBundle\Entity\Product')
->findBy(['enable' => 1, 'url' => $url, 'shop' => $selectedShop]);
if (count($products) > 0) {
$tmp = array();
$tmp = [];
/**
* @var Product $product
*/
*/
foreach ($products as $product) {
$tmp[] = $product->getTitle();
}
return new JsonResponse(['success' => true, 'found' => true, 'error' => implode(", ", $tmp)]);
return new JsonResponse(['success' => true, 'found' => true, 'error' => implode(', ', $tmp)]);
}
return new JsonResponse(['success' => true, 'found' => false]);
@ -214,34 +210,40 @@ class EditController extends AbstractController
\PSC\System\SettingsBundle\Service\Shop $shopService,
DocumentManager $documentManager,
SessionInterface $session,
$type
$type,
) {
$customFields = $fieldService->getFields(\PSC\System\PluginBundle\Form\Interfaces\Field::Product);
$customGroups = $fieldService->getGroups(\PSC\System\PluginBundle\Form\Interfaces\Field::Product);
/**
* @var \PSC\Shop\EntityBundle\Entity\Shop $selectedShop
*/
*/
$selectedShop = $shopService->getSelectedShop();
/**
* @var Shop $shop
*/
*/
$shop = $documentManager
->getRepository('PSC\Shop\EntityBundle\Document\Shop')
->findOneBy(array('uid' => (string) $selectedShop->getUid()));
->findOneBy(['uid' => (string) $selectedShop->getUid()]);
$articlegroups = $entityManager
->getRepository('PSC\Shop\EntityBundle\Entity\Productgroup')->findBy(array('parent' => 0, 'shop' => $selectedShop));
->getRepository('PSC\Shop\EntityBundle\Entity\Productgroup')
->findBy(['parent' => 0, 'shop' => $selectedShop]);
$customProductFields = $fieldService->getProductFields(\PSC\System\PluginBundle\Form\Interfaces\Field::Product, $type);
$customProductGroups = $fieldService->getProductGroups(\PSC\System\PluginBundle\Form\Interfaces\Field::Product, $type);
$customProductFields = $fieldService->getProductFields(
\PSC\System\PluginBundle\Form\Interfaces\Field::Product,
$type,
);
$customProductGroups = $fieldService->getProductGroups(
\PSC\System\PluginBundle\Form\Interfaces\Field::Product,
$type,
);
/**
* @var Domain[] $domains
*/
$domains = $entityManager
->getRepository('PSC\Shop\EntityBundle\Entity\Domain')->getAllByShopId($selectedShop);
*/
$domains = $entityManager->getRepository('PSC\Shop\EntityBundle\Entity\Domain')->getAllByShopId($selectedShop);
$product = new Product();
$product->setShop($selectedShop);
@ -292,28 +294,34 @@ class EditController extends AbstractController
$productDoc->setSalesUnit($product->getSalesUnit());
$productDoc->setBaseUnit($product->getBaseUnit());
$productDoc->setUploadFromLatestOrder($product->isUploadFromLatestOrder());
$productDoc->setUploadFromLatestOrderInitalStatus((int)$product->getUploadFromLatestOrderInitalStatus());
$productDoc->setUploadFromLatestOrderInitalStatus((int) $product->getUploadFromLatestOrderInitalStatus());
$productDoc->setUploadProvided($product->isUploadProvided());
$productDoc->setUploadProvidedDownload($product->isUploadProvidedDownload());
$productDoc->setUploadProvidedFile($product->getUploadProvidedFile());
$productDoc->setUploadProvidedInitalStatus((int)$product->getUploadProvidedInitalStatus());
$productDoc->setUploadProvidedInitalStatus((int) $product->getUploadProvidedInitalStatus());
$productDoc->setCustomTabEnable($product->isCustomTabEnable());
$productDoc->setHintEnable($product->isHintEnable());
$productDoc->setAsRequest($product->isAsRequest());
$productDoc->setRawText($product->isRawText());
$productDoc->setAribaUNSPSC($product->getAribaUNSPSC());
$productDoc->setAribaUnitOfMeasure($product->getAribaUnitOfMeasure());
$documentManager->persist($productDoc);
$documentManager->flush();
$session->getFlashBag()->add(
'success',
'Product \'' . $product->getTitle() . '\' has been created!'
$session->getFlashBag()->add('success', 'Product \'' . $product->getTitle() . '\' has been created!');
$this->logService->createLogEntry(
$selectedShop,
$this->getUser(),
LogEntry::INFO,
PSCShopProductBundle::class,
$product->getTitle(),
'Product has been created',
);
$this->logService->createLogEntry($selectedShop, $this->getUser(), LogEntry::INFO, PSCShopProductBundle::class, $product->getTitle(), "Product has been created");
return $this->redirectToRoute('backend_production_product_edit', ['uuid' => $product->getUUID()]);
}
return array(
return [
'domain' => $domains[0]->getHost(),
'form' => $form->createView(),
'product' => $product,
@ -323,8 +331,8 @@ class EditController extends AbstractController
'customProductFields' => $customProductFields,
'customProductGroups' => $customProductGroups,
'customGroups' => $customGroups,
'selectedShop' => $selectedShop
);
'selectedShop' => $selectedShop,
];
}
/**
@ -358,43 +366,59 @@ class EditController extends AbstractController
\PSC\System\SettingsBundle\Service\Shop $shopService,
Status $statusService,
\PSC\Shop\OrderBundle\Service\Order $orderService,
$uuid
$uuid,
) {
$customFields = $fieldService->getFields(\PSC\System\PluginBundle\Form\Interfaces\Field::Product);
$customGroups = $fieldService->getGroups(\PSC\System\PluginBundle\Form\Interfaces\Field::Product);
$customButtons = $fieldService->getButtons(
\PSC\System\PluginBundle\Form\Interfaces\Button::Product,
PluginButtonArea::Global,
);
/**
* @var \PSC\Shop\EntityBundle\Entity\Shop $selectedShop
*/
*/
$selectedShop = $shopService->getSelectedShop();
/**
* @var Shop $shop
*/
*/
$shop = $documentManager
->getRepository('PSC\Shop\EntityBundle\Document\Shop')
->findOneBy(array('uid' => (string) $selectedShop->getUid()));
->findOneBy(['uid' => (string) $selectedShop->getUid()]);
/**
* @var Product $product
*/
*/
$product = $entityManager
->getRepository('PSC\Shop\EntityBundle\Entity\Product')->findOneBy(array('uuid' => $uuid, 'shop' => $selectedShop));
->getRepository('PSC\Shop\EntityBundle\Entity\Product')
->findOneBy(['uuid' => $uuid, 'shop' => $selectedShop]);
/**
* @var \PSC\Shop\EntityBundle\Document\Product $productDoc
*/
*/
$productDoc = $documentManager
->getRepository('PSC\Shop\EntityBundle\Document\Product')
->findOneBy(array('uid' => (string) $product->getUid()));
->findOneBy(['uid' => (string) $product->getUid()]);
$articlegroups = $entityManager
->getRepository('PSC\Shop\EntityBundle\Entity\Productgroup')->findBy(array('parent' => 0, 'shop' => $selectedShop));
->getRepository('PSC\Shop\EntityBundle\Entity\Productgroup')
->findBy(['parent' => 0, 'shop' => $selectedShop]);
$customProductFields = $fieldService->getProductFields(
\PSC\System\PluginBundle\Form\Interfaces\Field::Product,
$product->getType(),
);
$customProductGroups = $fieldService->getProductGroups(
\PSC\System\PluginBundle\Form\Interfaces\Field::Product,
$product->getType(),
);
$customProductButtons = $fieldService->getProductButtons(
\PSC\System\PluginBundle\Form\Interfaces\Button::Product,
$product->getType(),
PluginButtonArea::Global,
);
$customProductFields = $fieldService->getProductFields(\PSC\System\PluginBundle\Form\Interfaces\Field::Product, $product->getType());
$customProductGroups = $fieldService->getProductGroups(\PSC\System\PluginBundle\Form\Interfaces\Field::Product, $product->getType());
$product->setUpdatedAt(new \DateTime());
if (!$request->isMethod('POST') && $productDoc) {
@ -433,8 +457,8 @@ class EditController extends AbstractController
$product->setBaseUnit($productDoc->getBaseUnit());
$product->setNoIndex($productDoc->isNoIndex());
$product->setUploadFromLatestOrder($productDoc->isUploadFromLatestOrder());
$product->setUploadFromLatestOrderInitalStatus((int)$productDoc->getUploadFromLatestOrderInitalStatus());
$product->setUploadProvidedInitalStatus((int)$productDoc->getUploadProvidedInitalStatus());
$product->setUploadFromLatestOrderInitalStatus((int) $productDoc->getUploadFromLatestOrderInitalStatus());
$product->setUploadProvidedInitalStatus((int) $productDoc->getUploadProvidedInitalStatus());
$product->setUploadProvided($productDoc->isUploadProvided());
$product->setUploadProvidedDownload($productDoc->isUploadProvidedDownload());
$product->setUploadProvidedFile($productDoc->getUploadProvidedFile());
@ -442,6 +466,8 @@ class EditController extends AbstractController
$product->setHintEnable($productDoc->isHintEnable());
$product->setAsRequest($productDoc->isAsRequest());
$product->setRawText($productDoc->isRawText());
$product->setAribaUNSPSC($productDoc->getAribaUNSPSC());
$product->setAribaUnitOfMeasure($productDoc->getAribaUnitOfMeasure());
} elseif (!$productDoc) {
$productDoc = new \PSC\Shop\EntityBundle\Document\Product();
$productDoc->setAblaufDatum($product->getAblaufDatum());
@ -479,16 +505,18 @@ class EditController extends AbstractController
$productDoc->setSalesUnit($product->getSalesUnit());
$productDoc->setBaseUnit($product->getBaseUnit());
$productDoc->setUploadFromLatestOrder($product->isUploadFromLatestOrder());
$productDoc->setUploadFromLatestOrderInitalStatus((int)$product->getUploadFromLatestOrderInitalStatus());
$productDoc->setUploadFromLatestOrderInitalStatus((int) $product->getUploadFromLatestOrderInitalStatus());
$productDoc->setUploadProvided($product->isUploadProvided());
$productDoc->setUploadProvidedDownload($product->isUploadProvidedDownload());
$productDoc->setUploadProvidedFile($product->getUploadProvidedFile());
$productDoc->setUploadProvidedInitalStatus((int)$product->getUploadProvidedInitalStatus());
$productDoc->setUploadProvidedInitalStatus((int) $product->getUploadProvidedInitalStatus());
$productDoc->setCustomTabEnable($product->isCustomTabEnable());
$productDoc->setHintEnable($product->isHintEnable());
$productDoc->setAsRequest($product->isAsRequest());
$productDoc->setNoIndex($product->isNoIndex());
$productDoc->setRawText($product->isRawText());
$productDoc->setAribaUNSPSC($product->getAribaUNSPSC());
$productDoc->setAribaUnitOfMeasure($product->getAribaUnitOfMeasure());
$documentManager->persist($productDoc);
$documentManager->flush();
@ -528,8 +556,8 @@ class EditController extends AbstractController
$product->setSalesUnit($productDoc->getSalesUnit());
$product->setBaseUnit($productDoc->getBaseUnit());
$product->setUploadFromLatestOrder($productDoc->isUploadFromLatestOrder());
$product->setUploadFromLatestOrderInitalStatus((int)$productDoc->getUploadFromLatestOrderInitalStatus());
$product->setUploadProvidedInitalStatus((int)$productDoc->getUploadProvidedInitalStatus());
$product->setUploadFromLatestOrderInitalStatus((int) $productDoc->getUploadFromLatestOrderInitalStatus());
$product->setUploadProvidedInitalStatus((int) $productDoc->getUploadProvidedInitalStatus());
$product->setUploadProvided($productDoc->isUploadProvided());
$product->setUploadProvidedDownload($productDoc->isUploadProvidedDownload());
$product->setUploadProvidedFile($productDoc->getUploadProvidedFile());
@ -537,16 +565,21 @@ class EditController extends AbstractController
$product->setHintEnable($productDoc->isHintEnable());
$product->setAsRequest($productDoc->isAsRequest());
$product->setRawText($productDoc->isRawText());
$product->setAribaUNSPSC($productDoc->getAribaUNSPSC());
$product->setAribaUnitOfMeasure($productDoc->getAribaUnitOfMeasure());
}
if ($request->isMethod('POST') && $productDoc) {
$product->setPluginSettings($productDoc->getPluginSettings());
}
$form = $this->createForm(ProductType::class, $product, ['productType' => intval($product->getType()), 'productDoc' => $productDoc, 'product' => $product]);
$form = $this->createForm(ProductType::class, $product, [
'productType' => intval($product->getType()),
'productDoc' => $productDoc,
'product' => $product,
]);
$form->handleRequest($request);
if ($form->isSubmitted() && $form->isValid()) {
$productDoc->setAnsprechPartner($product->getAnsprechPartner());
$productDoc->setAblaufDatum($product->getAblaufDatum());
$productDoc->setZusatzAbmessung($product->getZusatzAbmessung());
@ -582,75 +615,82 @@ class EditController extends AbstractController
$productDoc->setBaseUnit($product->getBaseUnit());
$productDoc->setSalesUnit($product->getSalesUnit());
$productDoc->setUploadFromLatestOrder($product->isUploadFromLatestOrder());
$productDoc->setUploadFromLatestOrderInitalStatus((int)$product->getUploadFromLatestOrderInitalStatus());
$productDoc->setUploadFromLatestOrderInitalStatus((int) $product->getUploadFromLatestOrderInitalStatus());
$productDoc->setUploadProvided($product->isUploadProvided());
$productDoc->setUploadProvidedDownload($product->isUploadProvidedDownload());
$productDoc->setUploadProvidedFile($product->getUploadProvidedFile());
$productDoc->setUploadProvidedInitalStatus((int)$product->getUploadProvidedInitalStatus());
$productDoc->setUploadProvidedInitalStatus((int) $product->getUploadProvidedInitalStatus());
$productDoc->setCustomTabEnable($product->isCustomTabEnable());
$productDoc->setHintEnable($product->isHintEnable());
$productDoc->setAsRequest($product->isAsRequest());
$productDoc->setRawText($product->isRawText());
$productDoc->setAribaUNSPSC($product->getAribaUNSPSC());
$productDoc->setAribaUnitOfMeasure($product->getAribaUnitOfMeasure());
$this->historyService->createHistoryEntry(new PSCHistory((string)$product->getUID()), $product, $productDoc);
$this->historyService->createHistoryEntry(
new PSCHistory((string) $product->getUID()),
$product,
$productDoc,
);
$entityManager->persist($product);
$entityManager->flush();
$documentManager->persist($productDoc);
$documentManager->flush();
$session->getFlashBag()->add(
'success',
'Product \'' . $product->getTitle() . '\' has been updated!'
$session->getFlashBag()->add('success', 'Product \'' . $product->getTitle() . '\' has been updated!');
$this->logService->createLogEntry(
$selectedShop,
$this->getUser(),
LogEntry::INFO,
PSCShopProductBundle::class,
$product->getTitle(),
'Product has been updated',
);
$this->logService->createLogEntry($selectedShop, $this->getUser(), LogEntry::INFO, PSCShopProductBundle::class, $product->getTitle(), "Product has been updated");
}
/**
* @var Domain[] $domains
*/
$domains = $entityManager
->getRepository('PSC\Shop\EntityBundle\Entity\Domain')->getAllByShopId($selectedShop);
*/
$domains = $entityManager->getRepository('PSC\Shop\EntityBundle\Entity\Domain')->getAllByShopId($selectedShop);
$userRepository = $entityManager->getRepository('PSC\Shop\EntityBundle\Entity\Order');
$qb = $userRepository->createQueryBuilder('orders')
$qb = $userRepository
->createQueryBuilder('orders')
->leftJoin('orders.positions', 'pos')
->leftJoin('pos.product', 'product')
->andwhere('(pos.product = :product_id OR product.originalProduct = :product_id)')->setParameter("product_id", $product->getUid())
->andwhere('(pos.product = :product_id OR product.originalProduct = :product_id)')
->setParameter('product_id', $product->getUid())
->orderBy('orders.uid', 'desc');
$qbCount = $userRepository->createQueryBuilder('orders')
$qbCount = $userRepository
->createQueryBuilder('orders')
->select('count(orders.uid)')
->leftJoin('orders.positions', 'pos')
->leftJoin('pos.product', 'product')
->andwhere('(pos.product = :product_id OR product.originalProduct = :product_id)')->setParameter("product_id", $product->getUid())
->andwhere('(pos.product = :product_id OR product.originalProduct = :product_id)')
->setParameter('product_id', $product->getUid())
->orderBy('orders.uid', 'desc');
$query = $qb->getQuery();
$count = $qbCount->getQuery()->getSingleScalarResult();
$query->setHint('knp_paginator.count', $count);
$pagination2 = $paginator->paginate(
$query,
$request->query->getInt('pages_order', 1),
15,
[
$pagination2 = $paginator->paginate($query, $request->query->getInt('pages_order', 1), 15, [
'distinct' => false,
'pageParameterName' => 'pages_order',
'sortFieldParameterName' => 'sorts'
]
);
'sortFieldParameterName' => 'sorts',
]);
$subProduct = false;
if ($product->getOriginalProduct() != 0) {
$subProduct = $entityManager->getRepository(Product::class)->find($product->getOriginalProduct());
}
return array(
return [
'domain' => $domains[0]->getHost(),
'form' => $form->createView(),
'product' => $product,
@ -658,15 +698,16 @@ class EditController extends AbstractController
'shopDoc' => $shop,
'customFields' => $customFields,
'customProductFields' => $customProductFields,
'customProductButtons' => $customProductButtons,
'customProductGroups' => $customProductGroups,
'customGroups' => $customGroups,
'selectedShop' => $selectedShop,
'changes' => $this->historyService->getHistory(new PSCHistory(), (string)$product->getUid()),
'changes' => $this->historyService->getHistory(new PSCHistory(), (string) $product->getUid()),
'pagination2' => $pagination2,
'orderStatuse' => $statusService,
'orderService' => $orderService,
'subProduct' => $subProduct
);
'subProduct' => $subProduct,
];
}
/**
@ -686,24 +727,25 @@ class EditController extends AbstractController
\PSC\System\SettingsBundle\Service\Shop $shopService,
EntityManagerInterface $entityManager,
SessionInterface $session,
$uuid
$uuid,
) {
/**
* @var \PSC\Shop\EntityBundle\Entity\Shop $selectedShop
*/
*/
$selectedShop = $shopService->getSelectedShop();
/**
* @var Product $product
*/
*/
$product = $entityManager
->getRepository('PSC\Shop\EntityBundle\Entity\Product')->findOneBy(array('uuid' => $uuid, 'shop' => $selectedShop));
->getRepository('PSC\Shop\EntityBundle\Entity\Product')
->findOneBy(['uuid' => $uuid, 'shop' => $selectedShop]);
$sql = 'select count(article_id) as sum from orderspos where article_id = :article_id';
$stmt = $entityManager->getConnection()->prepare($sql);
$result = $stmt->executeQuery(array('article_id' => $product->getUID()));
$count = (int)$result->fetchOne();
$result = $stmt->executeQuery(['article_id' => $product->getUID()]);
$count = (int) $result->fetchOne();
$form = $this->createForm(DeleteType::class);
@ -714,22 +756,25 @@ class EditController extends AbstractController
$title = $product->getTitle();
$entityManager->remove($product);
$entityManager->flush();
$session->getFlashBag()->add(
'success',
'Product \'' . $title . '\' has been deleted!'
$session->getFlashBag()->add('success', 'Product \'' . $title . '\' has been deleted!');
$this->logService->createLogEntry(
$selectedShop,
$this->getUser(),
LogEntry::INFO,
PSCShopProductBundle::class,
$product->getTitle(),
'Product has been deleted',
);
$this->logService->createLogEntry($selectedShop, $this->getUser(), LogEntry::INFO, PSCShopProductBundle::class, $product->getTitle(), "Product has been deleted");
return $this->redirectToRoute('psc_shop_product_backend_list');
}
return $this->redirectToRoute('psc_shop_product_backend_list');
}
return array(
return [
'product' => $product,
'count' => $count,
'form' => $form->createView()
);
'form' => $form->createView(),
];
}
/**
@ -746,21 +791,26 @@ class EditController extends AbstractController
*/
#[Route(path: '/{uuid}/copy', name: 'psc_shop_product_backend_edit_copy')]
#[Template]
public function copyAction(Request $request, \PSC\System\SettingsBundle\Service\Shop $shopService, \PSC\Shop\ProductBundle\Service\Product $productService, EntityManagerInterface $entityManager, $uuid)
{
public function copyAction(
Request $request,
\PSC\System\SettingsBundle\Service\Shop $shopService,
\PSC\Shop\ProductBundle\Service\Product $productService,
EntityManagerInterface $entityManager,
$uuid,
) {
$obj = ['which' => 1];
/**
* @var \PSC\Shop\EntityBundle\Entity\Shop $selectedShop
*/
*/
$selectedShop = $shopService->getSelectedShop();
/**
* @var Product $product
*/
*/
$product = $entityManager
->getRepository('PSC\Shop\EntityBundle\Entity\Product')->findOneBy(array('uuid' => $uuid, 'shop' => $selectedShop));
->getRepository('PSC\Shop\EntityBundle\Entity\Product')
->findOneBy(['uuid' => $uuid, 'shop' => $selectedShop]);
$form = $this->createForm(CopyType::class, $obj);
@ -779,6 +829,6 @@ class EditController extends AbstractController
}
}
return array('form' => $form->createView(), 'product' => $product);
return ['form' => $form->createView(), 'product' => $product];
}
}

View File

@ -96,6 +96,8 @@ class ProductType extends AbstractType
->add('notBuy', CheckboxType::class, ['required' => false, 'label' => 'notshoworderbtn'])
->add('notEdit', CheckboxType::class, ['required' => false, 'label' => 'Sellasproduct'])
->add('url', TextType::class, ['required' => true, 'label' => 'Url'])
->add('aribaUNSPSC', TextType::class, ['required' => false, 'label' => 'Ariba UNSPSC Identifikation'])
->add('aribaUnitOfMeasure', TextType::class, ['required' => false, 'label' => 'Ariba UnitOfMeasure'])
->add('title', TextType::class)
->add('subTitle', TextType::class, ['required' => false, 'label' => 'subTitle'])
->add('createdAt', DatePickerType::class, ['disabled' => true])

View File

@ -235,6 +235,25 @@
</div>
</div>
</div>
<div class="row">
<div class="col-md-4">
<div class="row mb-3">
{{ form_label(form.aribaUnitOfMeasure) }}
<div class="col-md-8">
{{ form_widget(form.aribaUnitOfMeasure) }}
</div>
</div>
</div>
<div class="col-md-4">
<div class="row mb-3">
{{ form_label(form.aribaUNSPSC) }}
<div class="col-md-8">
{{ form_widget(form.aribaUNSPSC) }}
</div>
</div>
</div>
</div>
</div>
<div class="tab-pane" id="groups" role="tabpanel">
<div class="row mb-3">

View File

@ -25,6 +25,10 @@ a[href^="#formlayouter"] {display:none;}
<a href="{{ path("backend_production_product_permission_index", {product: product.uuid}) }}" class="btn btn-default btn-sm"><i class="fa fa-lg fa-fw fa-key"></i> {{ 'opening'|trans }}</a>
<a href="{{ path("backend_production_product_stock_index", {product: product.uuid}) }}" class="btn btn-default btn-sm"><i class="fa fa-lg fa-fw fa-building"></i> {{ 'Warehousemanagement'|trans }}</a>
<a href="{{ path("backend_production_product_product_set", {product: product.uuid}) }}" class="btn btn-default btn-sm"><i class="fa fa-lg fa-fw fa-boxes"></i> {{ 'Product-Set'|trans }}</a>
{% for customButton in customProductButtons %}
{{ customButton.setProduct(product).render()|raw }}
{% endfor %}
</div>
</div>
</div>
@ -250,6 +254,24 @@ a[href^="#formlayouter"] {display:none;}
</div>
</div>
</div>
<div class="row">
<div class="col-md-4">
<div class="row mb-3">
{{ form_label(form.aribaUnitOfMeasure) }}
<div class="col-md-8">
{{ form_widget(form.aribaUnitOfMeasure) }}
</div>
</div>
</div>
<div class="col-md-4">
<div class="row mb-3">
{{ form_label(form.aribaUNSPSC) }}
<div class="col-md-8">
{{ form_widget(form.aribaUNSPSC) }}
</div>
</div>
</div>
</div>
</div>
<div class="tab-pane" id="groups" role="tabpanel">
<div class="row mb-3">

View File

@ -22,22 +22,40 @@ class FormPass implements CompilerPassInterface
$taggedServices = $container->findTaggedServiceIds('psc.backend.custom.fields');
foreach ($taggedServices as $id => $tags) {
if (isset($tags[0]['productType'])) {
$definition->addMethodCall('addProductField', array(new Reference($id), intval($tags[0]['productType'])));
$definition->addMethodCall('addProductField', [
new Reference($id),
intval($tags[0]['productType']),
]);
} elseif (isset($tags[0]['themeType'])) {
$definition->addMethodCall('addThemeField', array(new Reference($id), $tags[0]['themeType']));
$definition->addMethodCall('addThemeField', [new Reference($id), $tags[0]['themeType']]);
} else {
$definition->addMethodCall('addField', array(new Reference($id)));
$definition->addMethodCall('addField', [new Reference($id)]);
}
}
$taggedServices = $container->findTaggedServiceIds('psc.backend.custom.groups');
foreach ($taggedServices as $id => $tags) {
if (isset($tags[0]['productType'])) {
$definition->addMethodCall('addProductGroup', array(new Reference($id), intval($tags[0]['productType'])));
$definition->addMethodCall('addProductGroup', [
new Reference($id),
intval($tags[0]['productType']),
]);
} elseif (isset($tags[0]['themeType'])) {
$definition->addMethodCall('addThemeGroup', array(new Reference($id), $tags[0]['themeType']));
$definition->addMethodCall('addThemeGroup', [new Reference($id), $tags[0]['themeType']]);
} else {
$definition->addMethodCall('addGroup', array(new Reference($id)));
$definition->addMethodCall('addGroup', [new Reference($id)]);
}
}
$taggedServices = $container->findTaggedServiceIds('psc.backend.custom.buttons');
foreach ($taggedServices as $id => $tags) {
if (isset($tags[0]['productType'])) {
$definition->addMethodCall('addProductButton', [
new Reference($id),
intval($tags[0]['productType']),
]);
} else {
$definition->addMethodCall('addButton', [new Reference($id)]);
}
}
@ -50,7 +68,7 @@ class FormPass implements CompilerPassInterface
$taggedServices = $container->findTaggedServiceIds('psc.backend.custom.section');
foreach ($taggedServices as $id => $tags) {
$defSection->addMethodCall('add', array(new Reference($id)));
$defSection->addMethodCall('add', [new Reference($id)]);
}
}
}

View File

@ -3,12 +3,19 @@
namespace PSC\System\PluginBundle\Form\Chain;
use PSC\System\PluginBundle\Form\Interfaces\Group;
use PSC\System\PluginBundle\Model\PluginButtonArea;
class Field
{
/** @var \PSC\System\PluginBundle\Form\Interfaces\Field[] */
private $fields = [];
/** @var \PSC\System\PluginBundle\Form\Interfaces\Button[] */
private $buttons = [];
/** @var \PSC\System\PluginBundle\Form\Interfaces\Button[] */
private $specialProductButtons = [];
/** @var Group[] */
private $groups = [];
@ -24,14 +31,12 @@ class Field
/** @var Group[] */
private $specialThemeGroups = [];
public function __construct()
{
}
public function __construct() {}
public function addField(\PSC\System\PluginBundle\Form\Interfaces\Field $field)
{
if (!isset($this->fields[$field->getModule()])) {
$this->fields[$field->getModule()] = array();
$this->fields[$field->getModule()] = [];
}
$this->fields[$field->getModule()][] = $field;
@ -40,29 +45,48 @@ class Field
public function addGroup(\PSC\System\PluginBundle\Form\Interfaces\Group $group)
{
if (!isset($this->groups[$group->getModule()])) {
$this->groups[$group->getModule()] = array();
$this->groups[$group->getModule()] = [];
}
$this->groups[$group->getModule()][] = $group;
}
public function addButton(\PSC\System\PluginBundle\Form\Interfaces\Button $button)
{
if (!isset($this->buttons[$button->getModule()])) {
$this->buttons[$button->getModule()] = [];
}
$this->buttons[$button->getModule()][] = $button;
}
public function addProductField(\PSC\System\PluginBundle\Form\Interfaces\Field $field, $productType = 0)
{
if (!isset($this->specialProductFields[$field->getModule()])) {
$this->specialProductFields[$field->getModule()] = array();
$this->specialProductFields[$field->getModule()] = [];
}
if (!isset($this->specialProductFields[$field->getModule()][$productType])) {
$this->specialProductFields[$field->getModule()][$productType] = array();
$this->specialProductFields[$field->getModule()][$productType] = [];
}
$this->specialProductFields[$field->getModule()][$productType][] = $field;
}
public function addThemeField(\PSC\System\PluginBundle\Form\Interfaces\Field $field, $themeType = "")
public function addProductButton(\PSC\System\PluginBundle\Form\Interfaces\Button $button, $productType = 0)
{
if (!isset($this->specialProductButtons[$button->getModule()])) {
$this->specialProductButtons[$button->getModule()] = [];
}
if (!isset($this->specialProductButtons[$button->getModule()][$productType])) {
$this->specialProductButtons[$button->getModule()][$productType] = [];
}
$this->specialProductButtons[$button->getModule()][$productType][] = $button;
}
public function addThemeField(\PSC\System\PluginBundle\Form\Interfaces\Field $field, $themeType = '')
{
if (!isset($this->specialThemeFields[$field->getModule()])) {
$this->specialThemeFields[$field->getModule()] = array();
$this->specialThemeFields[$field->getModule()] = [];
}
if (!isset($this->specialThemeFields[$field->getModule()][$themeType])) {
$this->specialThemeFields[$field->getModule()][$themeType] = array();
$this->specialThemeFields[$field->getModule()][$themeType] = [];
}
$this->specialThemeFields[$field->getModule()][$themeType][] = $field;
}
@ -70,21 +94,21 @@ class Field
public function addProductGroup(\PSC\System\PluginBundle\Form\Interfaces\Group $group, $productType = 0)
{
if (!isset($this->specialProductGroups[$group->getModule()])) {
$this->specialProductGroups[$group->getModule()] = array();
$this->specialProductGroups[$group->getModule()] = [];
}
if (!isset($this->specialProductGroups[$group->getModule()][$productType])) {
$this->specialProductGroups[$group->getModule()][$productType] = array();
$this->specialProductGroups[$group->getModule()][$productType] = [];
}
$this->specialProductGroups[$group->getModule()][$productType][] = $group;
}
public function addThemeGroup(\PSC\System\PluginBundle\Form\Interfaces\Group $group, $themeType = "")
public function addThemeGroup(\PSC\System\PluginBundle\Form\Interfaces\Group $group, $themeType = '')
{
if (!isset($this->specialThemeGroups[$group->getModule()])) {
$this->specialThemeGroups[$group->getModule()] = array();
$this->specialThemeGroups[$group->getModule()] = [];
}
if (!isset($this->specialThemeGroups[$group->getModule()][$themeType])) {
$this->specialThemeGroups[$group->getModule()][$themeType] = array();
$this->specialThemeGroups[$group->getModule()][$themeType] = [];
}
$this->specialThemeGroups[$group->getModule()][$themeType][] = $group;
}
@ -101,10 +125,45 @@ class Field
return $this->groups;
}
public function getButtons($module = false, PluginButtonArea $area = PluginButtonArea::Global)
{
if ($module) {
if (!isset($this->buttons[$module])) {
return [];
}
return $this->buttons[$module];
}
return $this->buttons;
}
public function getProductButtons(
$module = false,
int $productType = 0,
PluginButtonArea $area = PluginButtonArea::Global,
) {
if ($module) {
if (
!isset($this->specialProductButtons[$module]) ||
!isset($this->specialProductButtons[$module][intval($productType)])
) {
return [];
}
return array_filter($this->specialProductButtons[$module][intval($productType)], function ($e) use ($area) {
return $e->getArea() == $area;
});
}
return $this->specialProductGroups;
}
public function getProductGroups($module = false, $productType = 0)
{
if ($module) {
if (!isset($this->specialProductGroups[$module]) || !isset($this->specialProductGroups[$module][intval($productType)])) {
if (
!isset($this->specialProductGroups[$module]) ||
!isset($this->specialProductGroups[$module][intval($productType)])
) {
return [];
}
return $this->specialProductGroups[$module][intval($productType)];
@ -113,7 +172,7 @@ class Field
return $this->specialProductGroups;
}
public function getThemeGroups($module = false, $themeType = "")
public function getThemeGroups($module = false, $themeType = '')
{
if ($module) {
if (!isset($this->specialThemeGroups[$module]) || !isset($this->specialThemeGroups[$module][$themeType])) {
@ -140,7 +199,10 @@ class Field
public function getProductFields($module = false, $productType = 0)
{
if ($module) {
if (!isset($this->specialProductFields[$module]) || !isset($this->specialProductFields[$module][intval($productType)])) {
if (
!isset($this->specialProductFields[$module]) ||
!isset($this->specialProductFields[$module][intval($productType)])
) {
return [];
}
return $this->specialProductFields[$module][$productType];
@ -149,7 +211,7 @@ class Field
return $this->specialProductFields;
}
public function getThemeFields($module = false, $themeType = "")
public function getThemeFields($module = false, $themeType = '')
{
if ($module) {
if (!isset($this->specialThemeFields[$module]) || !isset($this->specialThemeFields[$module][$themeType])) {

View File

@ -0,0 +1,28 @@
<?php
namespace PSC\System\PluginBundle\Form\Interfaces;
use PSC\System\PluginBundle\Model\PluginButtonArea;
interface Button
{
const Cms = 1;
const Product = 2;
const Shipping = 3;
const Payment = 4;
const Productgroup = 5;
const News = 6;
const Account = 7;
const Contact = 8;
const Shop = 9;
const Order = 10;
const Voucher = 11;
const Theme = 12;
const System = 13;
public function getModule(): int;
public function getArea(): PluginButtonArea;
public function render(): string;
}

View File

@ -0,0 +1,8 @@
<?php
namespace PSC\System\PluginBundle\Model;
enum PluginButtonArea
{
case Global;
}

View File

@ -47,5 +47,10 @@ class UploadTest extends WebTestCase
$media = json_decode($client->getResponse()->getContent(), true);
self::assertSame('kenney.jpg', $media['title']);
self::assertIsString($media['uuid']);
$client->request('GET', '/api/media/' . $media['uuid'], [], []);
$this->assertResponseIsSuccessful();
}
}

View File

@ -32,4 +32,25 @@ class PreviewTest extends WebTestCase
self::assertSame(1200, $data['netto']);
}
public function testRowPreview(): void
{
$client = static::createClient();
$client->jsonRequest(
'POST',
'/api/plugin/system/psc/xmlcalc/product/pd',
[
'shop' => '771a1176-d531-48ed-93b8-eec1fd4b917f',
'json' => json_decode(
'[ { "uuid": "2b6de5b2-4dac-4258-8a07-83c14552b7b8", "name": "40a3bdad-e4ae-4b3b-a9be-9c6d07b8ec43", "options": [ { "id": "03f105fe-a403-4b66-81b0-05e1e5b912e7", "type": 7, "dependencys": [], "columns": [ { "id": "c7ebdb8d-70ce-4aad-bfa6-2ee8433bc1a1", "type": 8, "dependencys": [], "options": [ { "id": "0f99f3db-43ec-48b2-809b-538ddb472fb3", "type": 6, "dependencys": [], "default": "Headline", "name": "", "variant": "1" } ] }, { "id": "66eac063-4c3a-4fc4-a5fb-eeaa78c32d06", "type": 8, "dependencys": [], "options": [ { "id": "b972c84c-1943-46a7-8e9d-09d7a4ad8fdb", "type": 6, "dependencys": [], "default": "Headline", "name": "", "variant": "1" } ] } ] } ] } ]',
),
'values' => [],
],
[],
);
$this->assertResponseIsSuccessful();
$data = json_decode($client->getResponse()->getContent(), true);
}
}

View File

@ -0,0 +1 @@
@jsr:registry=https://npm.jsr.io

View File

@ -7,6 +7,7 @@
"@codemirror/lang-json": "^6.0.2",
"@codemirror/lang-php": "^6.0.2",
"@codemirror/lang-xml": "^6.1.0",
"@std/async": "npm:@jsr/std__async",
"@tailwindcss/vite": "^4.1.10",
"@vueuse/core": "^13.6.0",
"class-variance-authority": "^0.7.1",
@ -274,6 +275,8 @@
"@sindresorhus/merge-streams": ["@sindresorhus/merge-streams@4.0.0", "", {}, "sha512-tlqY9xq5ukxTUZBmoOp+m61cqwQD5pHJtFY3Mn8CA8ps6yghLH/Hw8UPdqg4OLmFW3IFlcXnQNmo/dh8HzXYIQ=="],
"@std/async": ["@jsr/std__async@1.0.14", "https://npm.jsr.io/~/11/@jsr/std__async/1.0.14.tgz", {}, "sha512-aIG8W3TOmW+lKdAJA5w56qASu9EiUmBXbhW6eAlSEUBid+KVESGqQygFFg+awt/c8K+qobVM6M/u3SbIy0NyUQ=="],
"@swc/helpers": ["@swc/helpers@0.5.17", "", { "dependencies": { "tslib": "^2.8.0" } }, "sha512-5IKx/Y13RsYd+sauPb2x+U/xZikHjolzfuDgTAl/Tdf3Q8rslRvC19NKDLgAJQ6wsqADk10ntlv08nPFw/gO/A=="],
"@tailwindcss/node": ["@tailwindcss/node@4.1.10", "", { "dependencies": { "@ampproject/remapping": "^2.3.0", "enhanced-resolve": "^5.18.1", "jiti": "^2.4.2", "lightningcss": "1.30.1", "magic-string": "^0.30.17", "source-map-js": "^1.2.1", "tailwindcss": "4.1.10" } }, "sha512-2ACf1znY5fpRBwRhMgj9ZXvb2XZW8qs+oTfotJ2C5xR0/WNL7UHZ7zXl6s+rUqedL1mNi+0O+WQr5awGowS3PQ=="],

View File

@ -13,6 +13,7 @@
"@codemirror/lang-json": "^6.0.2",
"@codemirror/lang-php": "^6.0.2",
"@codemirror/lang-xml": "^6.1.0",
"@std/async": "npm:@jsr/std__async",
"@tailwindcss/vite": "^4.1.10",
"@vueuse/core": "^13.6.0",
"class-variance-authority": "^0.7.1",

View File

@ -3,16 +3,20 @@ import Gui from './components/Gui.vue'
import { onMounted } from 'vue'
import { useItemStore } from './stores/Items'
import { useGlobalStore } from './stores/Global'
import Mode from './model/Mode'
onMounted(() => {
const itemStore = useItemStore()
const globalStore = useGlobalStore()
const params = new URLSearchParams(window.location.search)
const uuid = params.get('uuid')
const shopUuid = params.get('shop')
const mode = params.get('mode')
globalStore.setShopUuid(shopUuid)
globalStore.setMode(mode)
const uuid: string|null = params.get('uuid')
const shopUuid: string|null = params.get('shop')
const mode: string|null = params.get('mode')
globalStore.setShopUuid(shopUuid!)
if(mode) {
let x: number = parseInt(mode!)
globalStore.setMode(x as Mode)
}
if (uuid) {
globalStore.setProductUuid(uuid)
globalStore.loadConfigFromProductApi(uuid).then(data => {
@ -21,23 +25,11 @@ onMounted(() => {
globalStore.loadFormulaAnalyserDataFromApi(uuid)
}
let debounceTimer: number;
const debounce = (func: Function, delay: number) => {
return function(this: any, ...args: any[]) {
clearTimeout(debounceTimer);
debounceTimer = setTimeout(() => func.apply(this, args), delay);
};
};
const debouncedLoadPreview = debounce((json: object[]) => {
globalStore.loadPreview(json);
}, 500);
itemStore.$subscribe((mutation, state) => {
const json = itemStore.loadJSON();
globalStore.saveDesign(json);
debouncedLoadPreview(json);
});
})
</script>

View File

@ -1,5 +1,5 @@
<script setup lang="ts">
import { ref, onMounted } from 'vue';
import { ref } from 'vue';
import { Button } from '../../ui/button';
import {
Dialog,

View File

@ -1,8 +1,8 @@
<script lang="ts" setup>
import { onMounted, ref } from 'vue';
import MediaElement from '../../../model/MediaElement';
import { computed } from 'vue';
import { computed, onMounted } from 'vue';
import { ImageOff } from 'lucide-vue-next'
import { fetchMediaUrl } from '../../../lib/api';
const props = defineProps<{
modelValue: MediaElement
@ -10,11 +10,20 @@ const props = defineProps<{
let emit = defineEmits(['update:modelValue']);
const theModel = computed<InputElement>({
const theModel = computed<MediaElement>({
get: () => props.modelValue,
set: (value) => emit('update:modelValue', value),
});
onMounted(async () => {
if (theModel.value.default && !theModel.value.url) {
try {
theModel.value.url = await fetchMediaUrl(theModel.value.default);
} catch (error) {
console.error('Failed to fetch media URL', error);
}
}
});
</script>
<template>

View File

@ -7,7 +7,7 @@ import { Button } from '../../../components/ui/button'
import { ref, watch, h } from 'vue'
import { useI18n } from 'vue-i18n'
const { locale, t } = useI18n()
const { locale } = useI18n()
const globalStore = useGlobalStore()
let previewMode = ref(false)

View File

@ -29,6 +29,7 @@ const emit = defineEmits(['select-media']);
const folders = ref<Folder[]>([]);
const selectMedia = (media: Media) => {
console.log(media)
emit('select-media', media);
};
const media = ref<Media[]>([]);

View File

@ -1,19 +1,37 @@
<script lang="ts" setup>
import { computed } from 'vue';
import { useGlobalStore } from '../../../stores/Global';
import RenderElements from './RenderElements.vue';
import PriceDisplay from './PriceDisplay.vue';
import type { PreviewResponse } from '../../../model/preview/types';
import { computed, onMounted } from 'vue'
import { useGlobalStore } from '../../../stores/Global'
import { useItemStore } from '../../../stores/Items'
import RenderElements from './RenderElements.vue'
import PriceDisplay from './PriceDisplay.vue'
import type { PreviewResponse } from '../../../model/preview/types'
import { debounce } from "@std/async/debounce"
const globalStore = useGlobalStore();
const globalStore = useGlobalStore()
const itemStore = useItemStore()
const previewData = computed<PreviewResponse | null>(() => globalStore.getPreviewData);
const error = computed(() => globalStore.previewError);
const isLoading = computed(() => globalStore.isPreviewLoading);
const previewData = computed<PreviewResponse | null>(() => globalStore.getPreviewData)
const error = computed(() => globalStore.previewError)
const isLoading = computed(() => globalStore.isPreviewLoading)
const items = computed(() => previewData.value?.elements || []);
const price = computed(() => previewData.value);
const items = computed(() => previewData.value?.elements || [])
const price = computed(() => previewData.value)
let previewValues: Record<string, any> = {}
const handleUpdate = (payload: { elementId: string, newValue: any }) => {
previewValues[payload.elementId] = payload.newValue;
debounce(() => globalStore.loadPreview(itemStore.loadJSON(), previewValues), 500);
};
onMounted(() => {
globalStore.loadPreview(itemStore.loadJSON()).then(() => {
globalStore.previewData!.elements.map((el) => {
previewValues[el.id] = el.rawValue;
});
});
})
</script>
<template>
@ -31,7 +49,7 @@ const price = computed(() => previewData.value);
<div class="overflow-auto h-full">
<div class="flex flex-row">
<div class="w-3/5 flex flex-col gap-2">
<RenderElements :items="items"/>
<RenderElements :items="items" @update:value="handleUpdate"/>
</div>
<div class="w-2/5 pl-6">
<PriceDisplay :price-data="price" />

View File

@ -10,9 +10,9 @@ const formatCurrency = (value: number) => {
return new Intl.NumberFormat('de-DE', { style: 'currency', currency: 'EUR' }).format(value);
};
const netPrice = computed(() => formatCurrency(props.priceData?.netto / 100 || 0));
const tax = computed(() => formatCurrency(props.priceData?.tax / 100 || 0));
const grossPrice = computed(() => formatCurrency(props.priceData?.brutto / 100 || 0));
const netPrice = computed(() => formatCurrency(props.priceData!.netto / 100 || 0));
const tax = computed(() => formatCurrency(props.priceData!.tax / 100 || 0));
const grossPrice = computed(() => formatCurrency(props.priceData!.brutto / 100 || 0));
</script>

View File

@ -1,6 +1,5 @@
<script lang="ts" setup>
import { shallowRef } from 'vue';
import type { Component } from 'vue';
import type { PreviewElement } from '../../../model/preview/types';
import TextElement from './elements/TextElement.vue';
@ -8,27 +7,53 @@ import InputElement from './elements/InputElement.vue';
import HiddenElement from './elements/HiddenElement.vue';
import HeadlineElement from './elements/HeadlineElement.vue';
import SelectElement from './elements/SelectElement.vue';
import RowElement from './elements/RowElement.vue';
const props = defineProps<{
items: PreviewElement[]
}>();
const componentMap: Record<string, Component> = shallowRef({
headline: HeadlineElement,
text: TextElement,
input: InputElement,
hidden: HiddenElement,
select: SelectElement,
});
const emit = defineEmits(['update:value']);
const handleUpdate = (payload: { elementId: string, newValue: any }) => {
emit('update:value', payload);
};
</script>
<template>
<div v-for="item in items" :key="item.id">
<component
v-if="item.valid && componentMap[item.htmlType]"
:is="componentMap[item.htmlType]"
<div v-for="item in props.items" :key="item.id">
<HeadlineElement
v-if="item.valid && item.htmlType === 'headline'"
:item="item"
@update:value="handleUpdate"
/>
<HiddenElement
v-if="item.valid && item.htmlType === 'hidden'"
:item="item"
@update:value="handleUpdate"
/>
<TextElement
v-if="item.valid && item.htmlType === 'text'"
:item="item"
@update:value="handleUpdate"
/>
<InputElement
v-if="item.valid && item.htmlType === 'input'"
:item="item"
@update:value="handleUpdate"
/>
<SelectElement
v-if="item.valid && item.htmlType === 'select'"
:item="item"
@update:value="handleUpdate"
/>
<RowElement
v-if="item.valid && item.htmlType === 'row'"
:item="item"
@update:value="handleUpdate"
/>
</div>
</template>

View File

@ -9,12 +9,12 @@ const props = defineProps<{
<template>
<div class="flex gap-2 flex-row">
<h1 v-if="item.variant == '1'" class="text-4xl">{{item.defaultValue}}</h1>
<h6 v-else-if="item.variant == '6'" class="text-base">{{item.defaultValue}}</h6>
<h5 v-else-if="item.variant == '5'" class="text-lg">{{item.defaultValue}}</h5>
<h4 v-else-if="item.variant == '4'" class="text-xl">{{item.defaultValue}}</h4>
<h3 v-else-if="item.variant == '3'" class="text-2xl">{{item.defaultValue}}</h3>
<h2 v-else-if="item.variant == '2'" class="text-3xl">{{item.defaultValue}}</h2>
<h1 v-else class="text-4xl">{{item.defaultValue}}</h1>
<h1 v-if="props.item.variant == '1'" class="text-4xl">{{props.item.defaultValue}}</h1>
<h6 v-else-if="props.item.variant == '6'" class="text-base">{{props.item.defaultValue}}</h6>
<h5 v-else-if="props.item.variant == '5'" class="text-lg">{{props.item.defaultValue}}</h5>
<h4 v-else-if="props.item.variant == '4'" class="text-xl">{{props.item.defaultValue}}</h4>
<h3 v-else-if="props.item.variant == '3'" class="text-2xl">{{props.item.defaultValue}}</h3>
<h2 v-else-if="props.item.variant == '2'" class="text-3xl">{{props.item.defaultValue}}</h2>
<h1 v-else class="text-4xl">{{props.item.defaultValue}}</h1>
</div>
</template>

View File

@ -11,6 +11,6 @@ const props = defineProps<{
<template>
<div class="flex gap-2 flex-row">
<Input type="hidden" name="item.name" id="item.id" value="item.value"/>
<Input type="hidden" :name="props.item.name" :id="props.item.id" :value="props.item.value"/>
</div>
</template>

View File

@ -1,10 +1,20 @@
<script lang="ts" setup>
import { computed } from 'vue';
import type { PreviewElement } from '../../../../model/preview/types';
import { Input } from '../../../../components/ui/input';
const props = defineProps<{
item: PreviewElement
}>()
}>();
const emit = defineEmits(['update:value']);
const value = computed({
get: () => props.item.rawValue,
set: (newValue) => {
emit('update:value', { elementId: props.item.id, newValue });
}
});
</script>
@ -12,6 +22,6 @@ const props = defineProps<{
<template>
<div class="flex gap-2 flex-row items-center">
<label class="w-60 flex-inital">{{item.name}}</label>
<Input v-model:placeholder="item.placeHolder" v-model="item.value" v-model:name="item.name" v-model:id="item.id" v-model:required="item.required"/>
<Input v-model="value" :placeholder="item.placeHolder" :name="item.name" :id="item.id" :required="item.required"/>
</div>
</template>

View File

@ -0,0 +1,23 @@
<script lang="ts" setup>
import type { PreviewElement } from '../../../../model/preview/types';
import RenderElements from '../RenderElements.vue'
const props = defineProps<{
item: PreviewElement
}>()
const emit = defineEmits(['update:value']);
const handleUpdate = (payload: { elementId: string, newValue: any }) => {
emit('update:value', payload);
};
</script>
<template>
<div class="flex gap-2 flex-row">
<div class="flex-row w-full h-auto" v-for="col in props.item.elements">
<RenderElements :items="col.elements" @update:value="handleUpdate"/>
</div>
</div>
</template>

View File

@ -1,4 +1,5 @@
<script lang="ts" setup>
import { computed } from 'vue';
import type { PreviewElement } from '../../../../model/preview/types';
import {
Select,
@ -11,7 +12,16 @@ import {
const props = defineProps<{
item: PreviewElement
}>()
}>();
const emit = defineEmits(['update:value']);
const value = computed({
get: () => props.item.rawValue,
set: (newValue) => {
emit('update:value', { elementId: props.item.id, newValue });
}
});
</script>
@ -19,13 +29,13 @@ const props = defineProps<{
<div class="flex gap-2 flex-row items-center">
<label class="w-60 flex-inital">{{item.name}}</label>
<div class="w-full">
<Select v-model="item.rawValue">
<Select v-model="value">
<SelectTrigger>
<SelectValue />
</SelectTrigger>
<SelectContent>
<SelectGroup>
<SelectItem v-for="option in item.options" :key="option.uuid" :value="option.id">
<SelectItem v-for="option in item.options" :key="option.id" v-show="option.valid" :value="option.id">
{{option.name}}
</SelectItem>
</SelectGroup>

View File

@ -9,6 +9,6 @@ const props = defineProps<{
<template>
<div class="flex gap-2 flex-row">
<p style="white-space: pre-line;">{{item.defaultValue}}</p>
<p style="white-space: pre-line;">{{props.item.defaultValue}}</p>
</div>
</template>

View File

@ -0,0 +1,15 @@
<script lang="ts" setup>
import type { PreviewElement } from '../../../../model/preview/types';
import { Textarea } from '../../../ui/textarea'
const props = defineProps<{
item: PreviewElement
}>()
</script>
<template>
<div class="flex gap-2 flex-row">
<Textarea style="white-space: pre-line;" v-value="props.item.defaultValue"></Textarea>
</div>
</template>

View File

@ -27,8 +27,8 @@ const dialogOpen = ref(false);
const uploadProgress = ref(0);
const handleMediaSelect = (media: any) => {
theModel.value.default = media.uuid;
theModel.value.url = media.url;
theModel.value!.default = media.uuid;
theModel.value!.url = media.url;
dialogOpen.value = false;
};
const isDragging = ref(false);
@ -75,11 +75,11 @@ const handleFile = async (file: File) => {
uploadProgress.value = 0;
if(selectedDirectory) {
try {
let response = await uploadFile(file, selectedDirectory.value, (progress) => {
let response: any = await uploadFile(file, selectedDirectory.value, (progress) => {
uploadProgress.value = progress;
});
theModel.value.url = response.url
theModel.value.default = response.uuid
theModel.value!.url = response.url
theModel.value!.default = response.uuid
// Handle successful upload
} catch (error) {
console.error('Upload failed', error);

View File

@ -2,7 +2,7 @@
import type { HTMLAttributes } from 'vue'
import { reactiveOmit } from '@vueuse/core'
import { PaginationRoot, type PaginationRootEmits, type PaginationRootProps, useForwardPropsEmits } from 'reka-ui'
import { cn } from '@/lib/utils'
import { cn } from '../../../lib/utils'
const props = defineProps<PaginationRootProps & {
class?: HTMLAttributes['class']

View File

@ -2,7 +2,7 @@
import type { HTMLAttributes } from 'vue'
import { reactiveOmit } from '@vueuse/core'
import { PaginationList, type PaginationListProps } from 'reka-ui'
import { cn } from '@/lib/utils'
import { cn } from '../../../lib/utils'
const props = defineProps<PaginationListProps & { class?: HTMLAttributes['class'] }>()

View File

@ -3,7 +3,7 @@ import type { HTMLAttributes } from 'vue'
import { reactiveOmit } from '@vueuse/core'
import { MoreHorizontal } from 'lucide-vue-next'
import { PaginationEllipsis, type PaginationEllipsisProps } from 'reka-ui'
import { cn } from '@/lib/utils'
import { cn } from '../../../lib/utils'
const props = defineProps<PaginationEllipsisProps & { class?: HTMLAttributes['class'] }>()

View File

@ -4,8 +4,8 @@ import type { HTMLAttributes } from 'vue'
import { reactiveOmit } from '@vueuse/core'
import { ChevronLeftIcon } from 'lucide-vue-next'
import { PaginationFirst, useForwardProps } from 'reka-ui'
import { cn } from '@/lib/utils'
import { buttonVariants, type ButtonVariants } from '@/components/ui/button'
import { cn } from '../../../lib/utils'
import { buttonVariants, type ButtonVariants } from '../button'
const props = withDefaults(defineProps<PaginationFirstProps & {
size?: ButtonVariants['size']

View File

@ -2,8 +2,8 @@
import type { HTMLAttributes } from 'vue'
import { reactiveOmit } from '@vueuse/core'
import { PaginationListItem, type PaginationListItemProps } from 'reka-ui'
import { cn } from '@/lib/utils'
import { buttonVariants, type ButtonVariants } from '@/components/ui/button'
import { cn } from '../../../lib/utils'
import { buttonVariants, type ButtonVariants } from '../button'
const props = withDefaults(defineProps<PaginationListItemProps & {
size?: ButtonVariants['size']

View File

@ -4,8 +4,8 @@ import type { HTMLAttributes } from 'vue'
import { reactiveOmit } from '@vueuse/core'
import { ChevronRightIcon } from 'lucide-vue-next'
import { PaginationLast, useForwardProps } from 'reka-ui'
import { cn } from '@/lib/utils'
import { buttonVariants, type ButtonVariants } from '@/components/ui/button'
import { cn } from '../../../lib/utils'
import { buttonVariants, type ButtonVariants } from '../button'
const props = withDefaults(defineProps<PaginationLastProps & {
size?: ButtonVariants['size']

View File

@ -4,8 +4,8 @@ import type { HTMLAttributes } from 'vue'
import { reactiveOmit } from '@vueuse/core'
import { ChevronRightIcon } from 'lucide-vue-next'
import { PaginationNext, useForwardProps } from 'reka-ui'
import { cn } from '@/lib/utils'
import { buttonVariants, type ButtonVariants } from '@/components/ui/button'
import { cn } from '../../../lib/utils'
import { buttonVariants, type ButtonVariants } from '../button'
const props = withDefaults(defineProps<PaginationNextProps & {
size?: ButtonVariants['size']

View File

@ -4,8 +4,8 @@ import type { HTMLAttributes } from 'vue'
import { reactiveOmit } from '@vueuse/core'
import { ChevronLeftIcon } from 'lucide-vue-next'
import { PaginationPrev, useForwardProps } from 'reka-ui'
import { cn } from '@/lib/utils'
import { buttonVariants, type ButtonVariants } from '@/components/ui/button'
import { buttonVariants, type ButtonVariants } from '../button'
import { cn } from '../../../lib/utils'
const props = withDefaults(defineProps<PaginationPrevProps & {
size?: ButtonVariants['size']

View File

@ -164,9 +164,9 @@ export const fetchLayouts = async (shop: string) => {
}
};
export const fetchPreview = async (shopUuid: string, json: object[]) => {
export const fetchPreview = async (shopUuid: string, json: object[], values?: Record<string, any>) => {
try {
const response = await api.post('api/plugin/system/psc/xmlcalc/product/pd', { json: { shop: shopUuid, json: json } });
const response = await api.post('api/plugin/system/psc/xmlcalc/product/pd', { json: { shop: shopUuid, json: json, values: values } });
return await response.json();
} catch (error) {
console.error('Error fetching preview:', error);
@ -174,4 +174,15 @@ export const fetchPreview = async (shopUuid: string, json: object[]) => {
}
};
export const fetchMediaUrl = async (uuid: string) => {
try {
const response = await api.get(`api/media/${uuid}`);
const data:any = await response.json();
return data.data.attributes.url;
} catch (error) {
console.error(`Error fetching media url for ${uuid}:`, error);
throw error;
}
};
export default api;

View File

@ -35,7 +35,7 @@ export default class BaseElement {
}, [])
}
}
getIdRecursiv(list: []) {
getIdRecursiv(list: string[]) {
}
fromJSON(obj: any) {

View File

@ -32,7 +32,7 @@ export default class Column extends BaseElement {
this.items.push(item)
})
}
getIdRecursiv(list: []) {
getIdRecursiv(list: string[]) {
this.items.forEach((item) => {
list.push(item.id);
item.getIdRecursiv(list)

View File

@ -34,7 +34,7 @@ export default class FieldsetElement extends BaseElement {
this.items.push(item)
})
}
getIdRecursiv(list: []) {
getIdRecursiv(list: string[]) {
this.items.forEach((item) => {
list.push(item.id);
item.getIdRecursiv(list)

View File

@ -16,7 +16,7 @@ export default class Row extends BaseElement {
addColumnAtTheBeginning(column: Column) {
this.columns.unshift(column)
}
getIdRecursiv(list: []) {
getIdRecursiv(list: string[]) {
this.columns.forEach((column) => {
column.getIdRecursiv(list)
})

View File

@ -3,6 +3,7 @@ export interface PreviewOption {
name: string;
valid: boolean;
selected: boolean;
elements: PreviewOption[];
}
export interface PreviewElement {
@ -21,7 +22,8 @@ export interface PreviewElement {
rawValue: string;
rawValues: any[];
options: PreviewOption[];
htmlType: 'headline' | 'text' | 'input' | 'hidden' | 'select';
elements: PreviewElement[];
htmlType: string;
validationErrors: any[];
variant?: string; // For headline
minValue?: number; // For input

View File

@ -60,7 +60,7 @@ export const useGlobalStore = defineStore('global', {
setParameter(value: string) {
this.parameter = value
},
setMode(value: Number) {
setMode(value: Mode) {
this.mode = value
},
setJson(value: string) {
@ -177,11 +177,10 @@ export const useGlobalStore = defineStore('global', {
setCurrentTab(tab: string | number) {
this.currentTab = tab
},
async loadPreview(json: object[]) {
this.isPreviewLoading = true;
async loadPreview(json: object[], values?: Record<string, any>) {
this.previewError = '';
try {
const response: any = await fetchPreview(this.shopUuid, json);
const response: any = await fetchPreview(this.shopUuid, json, values);
this.previewData = response;
} catch (e: any) {
this.previewError = `Failed to load preview data: ${e.message}`;
@ -189,6 +188,6 @@ export const useGlobalStore = defineStore('global', {
} finally {
this.isPreviewLoading = false;
}
}
},
}
})

View File

@ -12,7 +12,7 @@ export const useItemStore = defineStore('items', {
getters: {
getCount: (state) => state.items.length,
getIdRecursiv(state) {
let list = []
let list: string[] = []
state.items.forEach((item) => {
list.push(item.id);
item.getIdRecursiv(list)

View File

@ -33,7 +33,7 @@ export default defineConfig({
changeOrigin: true,
configure: (proxy) => {
proxy.on('proxyReq', (proxyReq) => {
proxyReq.setHeader('Authorization', 'Bearer eyJ0eXAiOiJKV1QiLCJhbGciOiJSUzI1NiJ9.eyJpYXQiOjE3NTQ1OTUxMjUsImV4cCI6MTc1NDU5ODcyNSwicm9sZXMiOlsiUk9MRV9BRE1JTiIsIlJPTEVfU0hPUF9PUEVSQVRPUiIsIlJPTEVfVVNFUiIsIlJPTEVfVVNFUiIsIlJPTEVfUFNDX0NvbGxlY3RfQ29udGFjdF9FZGl0IiwiUk9MRV9QU0NfQ29sbGVjdF9Db250YWN0X0FkZCIsIlJPTEVfUFNDX0NvbGxlY3RfQ29udGFjdF9EZWxldGUiLCJST0xFX1BTQ19Db2xsZWN0X0NvbnRhY3RfTG9jayIsIlJPTEVfUFNDX1IyX1NlbmRjbG91ZF9TaG93Il0sInVpZCI6MX0.C-_PO6C-uFj_6zOtJymfYRsMi0tn-Aq_-HAjpYIqh4rAvY5fTnf54kli1F1bqYogRTqWiTgzPh3EYkPuU7dC8UlCN1eMwXzLFzqtlI7IPPh2UhUvFv6EGix5XTWHnfO-I53vYhrd1qO5Kp--nqFyCCMSaXsRd9daJ7fkbPfGXrwIXPxUeFhhcbMYP4SsUHgS3ZGInM1J_txO62LJHBc91pAtzSliVpUhwJzHjHuiTeC8WTUhdRgVaQo2echLWPfPrMlWolh3cN6wk41wCNivpTIQ4h-a3WVEHvlRz61W9jehzWMiMoTZglmatn8cPsiFFb_nmUacYP5avazXAdpgjA');
proxyReq.setHeader('Authorization', 'Bearer eyJ0eXAiOiJKV1QiLCJhbGciOiJSUzI1NiJ9.eyJpYXQiOjE3NTY3MzE1MDEsImV4cCI6MTc1NjczNTEwMSwicm9sZXMiOlsiUk9MRV9BRE1JTiIsIlJPTEVfU0hPUF9PUEVSQVRPUiIsIlJPTEVfVVNFUiIsIlJPTEVfVVNFUiIsIlJPTEVfUFNDX0NvbGxlY3RfQ29udGFjdF9FZGl0IiwiUk9MRV9QU0NfQ29sbGVjdF9Db250YWN0X0FkZCIsIlJPTEVfUFNDX0NvbGxlY3RfQ29udGFjdF9EZWxldGUiLCJST0xFX1BTQ19Db2xsZWN0X0NvbnRhY3RfTG9jayIsIlJPTEVfUFNDX1IyX1NlbmRjbG91ZF9TaG93Il0sInVpZCI6MX0.Krs-TxmU9J3-p9Tt9cgFbm94wNz7wG9zRUe6yGMFG5USngDNzg4f3FL46JAWUx1liZBiU5K_Qnir5ol1--T6o2MNWIqxj3DTMgx6weWscv0Uw0eXOvhXhZp3wjaFnaqnqdN-vDqdEljs4V8ZA7RmbrL4SNgH-XoKrn0GEI9uVUYtd3wwR4SZFDEvZC1MTRi17zVMdpAxNaZ5KWTvcaARmUmDT5uKmgFOaM0z0mUT9mbL9KetqdId4aq_o6o6cPI--CDVmGNElvh4b3Ogf4yFe1hSuh9Yt1jM9rhqA7JDMpTRm3Ffx1nEdOyuA02hFFttuGICLc4NFTLbsY8qfp0H5A');
});
},
},

View File

@ -6,6 +6,6 @@ services:
Plugin\Custom\PSC\FormBuilder\:
resource: '../../*/*'
# Plugin\System\PSC\Invoice\Section\Invoice:
# tags:
# - { name: psc.backend.custom.section }
Plugin\Custom\PSC\FormBuilder\Ui\OpenButton:
tags:
- { name: psc.backend.custom.buttons, productType: 6 }

File diff suppressed because one or more lines are too long

View File

@ -0,0 +1,40 @@
<?php
namespace Plugin\Custom\PSC\FormBuilder\Ui;
use PSC\Shop\EntityBundle\Entity\Product;
use PSC\System\PluginBundle\Form\Interfaces\Button;
use PSC\System\PluginBundle\Model\PluginButtonArea;
class OpenButton implements Button
{
private Product $product;
public function getModule(): int
{
return Button::Product;
}
public function getArea(): PluginButtonArea
{
return PluginButtonArea::Global;
}
public function setProduct(Product $product): self
{
$this->product = $product;
return $this;
}
public function render(): string
{
return (
'<a target="_blank" href="/apps/backend/component/formbuilder/product/edit?mode=1&uuid=' .
$this->product->getUUID() .
'&shop=' .
$this->product->getShop()->getUuid() .
'" class="btn btn-default btn-sm"><i class="fa fa-lg fa-fw fa-boxes"></i> Konfigurator</a>
'
);
}
}

View File

@ -4,21 +4,20 @@ namespace Plugin\System\PSC\XmlCalc\Api\Product;
use Doctrine\ODM\MongoDB\DocumentManager;
use Doctrine\ORM\EntityManagerInterface;
use Nelmio\ApiDocBundle\Annotation\Model;
use Nelmio\ApiDocBundle\Annotation\Security;
use OpenApi\Annotations as OA;
use Nelmio\ApiDocBundle\Attribute\Model;
use OpenApi\Attributes\JsonContent;
use OpenApi\Attributes\RequestBody;
use OpenApi\Attributes\Response;
use OpenApi\Attributes\Tag;
use Plugin\System\PSC\XmlCalc\Dto\Input\PriceInput;
use Plugin\System\PSC\XmlCalc\Model\Product as PluginProduct;
use PSC\Component\ApiBundle\Dto\Error\NotFound;
use PSC\Library\Calc\Engine;
use PSC\Library\Calc\PaperContainer;
use PSC\Shop\ContactBundle\Model\Contact;
use PSC\Shop\ContactBundle\Transformer\Model\Contact as ContactTransformer;
use PSC\Shop\EntityBundle\Entity\Product;
use PSC\System\SettingsBundle\Service\PaperDB;
use Sensio\Bundle\FrameworkExtraBundle\Configuration\ParamConverter;
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
use Symfony\Component\HttpFoundation\JsonResponse;
use Symfony\Component\Routing\Attribute\Route;
use Symfony\Component\Security\Core\Authentication\Token\Storage\TokenStorageInterface;
@ -33,18 +32,13 @@ class Config extends AbstractController
private EntityManagerInterface $entityManager,
) {}
/**
* @OA\Response(
* response=200,
* description="get config for product",
* @OA\JsonContent(ref=@Model(type=\Plugin\System\PSC\XmlCalc\Model\Product::class))
* )
* @OA\RequestBody(
*
* @Model(type=\Plugin\System\PSC\XmlCalc\Dto\Input\PriceInput::class))
* )
* @OA\Tag(name="Plugin/System/psc/Xmlcalc/Product")
* */
#[Response(
response: 200,
description: 'get config for product',
content: new JsonContent(ref: new Model(type: PluginProduct::class)),
)]
#[RequestBody(ref: new Model(type: PriceInput::class))]
#[Tag(name: 'Plugin/System/psc/Xmlcalc/Product')]
#[Route(path: '/product/config', methods: ['POST'])]
#[ParamConverter(
'data',
@ -94,7 +88,7 @@ class Config extends AbstractController
'xml' => $engine->generateXML(true),
'parameter' => $engine->getParameters(),
'paperContainer' => $product->getShop()->getInstall()->getPaperContainer(),
'shopUuid' => $product->getShop()->getUid(),
'shopUuid' => $product->getShop()->getUuid(),
'formulas' => $engine->getFormulas(),
]);
}

View File

@ -4,9 +4,11 @@ namespace Plugin\System\PSC\XmlCalc\Api\Product;
use Doctrine\ODM\MongoDB\DocumentManager;
use Doctrine\ORM\EntityManagerInterface;
use Nelmio\ApiDocBundle\Annotation\Model;
use Nelmio\ApiDocBundle\Annotation\Security;
use OpenApi\Annotations as OA;
use Nelmio\ApiDocBundle\Attribute\Model;
use OpenApi\Attributes\JsonContent;
use OpenApi\Attributes\RequestBody;
use OpenApi\Attributes\Response;
use OpenApi\Attributes\Tag;
use Plugin\System\PSC\XmlCalc\Dto\Input\DesignInput;
use Plugin\System\PSC\XmlCalc\Model\Product as PluginProduct;
use PSC\Component\ApiBundle\Dto\Error\NotFound;
@ -33,18 +35,13 @@ class Design extends AbstractController
private EntityManagerInterface $entityManager,
) {}
/**
* @OA\Response(
* response=200,
* description="get config for product",
* @OA\JsonContent(ref=@Model(type=\Plugin\System\PSC\XmlCalc\Model\Product::class))
* )
* @OA\RequestBody(
*
* @Model(type=\Plugin\System\PSC\XmlCalc\Dto\Input\DesignInput::class))
* )
* @OA\Tag(name="Plugin/System/psc/Xmlcalc/Product")
* */
#[Response(
response: 200,
description: 'get config for product',
content: new JsonContent(ref: new Model(type: PluginProduct::class)),
)]
#[RequestBody(ref: new Model(type: DesignInput::class))]
#[Tag(name: 'Plugin/System/psc/Xmlcalc/Product')]
#[Route(path: '/product/design', methods: ['POST'])]
#[ParamConverter(
'data',

View File

@ -4,9 +4,11 @@ namespace Plugin\System\PSC\XmlCalc\Api\Product;
use Doctrine\ODM\MongoDB\DocumentManager;
use Doctrine\ORM\EntityManagerInterface;
use Nelmio\ApiDocBundle\Annotation\Model;
use Nelmio\ApiDocBundle\Annotation\Security;
use OpenApi\Annotations as OA;
use Nelmio\ApiDocBundle\Attribute\Model;
use OpenApi\Attributes\JsonContent;
use OpenApi\Attributes\RequestBody;
use OpenApi\Attributes\Response;
use OpenApi\Attributes\Tag;
use Plugin\System\PSC\XmlCalc\Dto\Input\JsonInput;
use Plugin\System\PSC\XmlCalc\Model\Product as PluginProduct;
use PSC\Component\ApiBundle\Dto\Error\NotFound;
@ -33,18 +35,13 @@ class Json extends AbstractController
private EntityManagerInterface $entityManager,
) {}
/**
* @OA\Response(
* response=200,
* description="get config for product",
* @OA\JsonContent(ref=@Model(type=\Plugin\System\PSC\XmlCalc\Model\Product::class))
* )
* @OA\RequestBody(
*
* @Model(type=\Plugin\System\PSC\XmlCalc\Dto\Input\JsonInput::class))
* )
* @OA\Tag(name="Plugin/System/psc/Xmlcalc/Product")
* */
#[Response(
response: 200,
description: 'get config for product',
content: new JsonContent(ref: new Model(type: PluginProduct::class)),
)]
#[RequestBody(ref: new Model(type: JsonInput::class))]
#[Tag(name: 'Plugin/System/psc/Xmlcalc/Product')]
#[Route(path: '/product/json', methods: ['POST'])]
#[ParamConverter(
'data',

View File

@ -4,8 +4,11 @@ namespace Plugin\System\PSC\XmlCalc\Api\Product;
use Doctrine\ODM\MongoDB\DocumentManager;
use Doctrine\ORM\EntityManagerInterface;
use Nelmio\ApiDocBundle\Annotation\Model;
use OpenApi\Annotations as OA;
use Nelmio\ApiDocBundle\Attribute\Model;
use OpenApi\Attributes\JsonContent;
use OpenApi\Attributes\RequestBody;
use OpenApi\Attributes\Response;
use OpenApi\Attributes\Tag;
use Plugin\System\PSC\XmlCalc\Dto\Input\PriceInput;
use Plugin\System\PSC\XmlCalc\Dto\Output\Display\Group as DisplayGroup;
use Plugin\System\PSC\XmlCalc\Dto\Output\PreCalc\Group;
@ -15,6 +18,7 @@ use Plugin\System\PSC\XmlCalc\Dto\Output\Price\Element;
use Plugin\System\PSC\XmlCalc\Dto\Output\Price\Option;
use Plugin\System\PSC\XmlCalc\Dto\Output\Price\Validation\Input\Max as PluginMax;
use Plugin\System\PSC\XmlCalc\Dto\Output\Price\Validation\Input\Min;
use Plugin\System\PSC\XmlCalc\Dto\Output\PriceOutput;
use PSC\Library\Calc\Engine;
use PSC\Library\Calc\Error\Validation\Input\Max;
use PSC\Library\Calc\Error\Validation\Input\Min as PSCMin;
@ -28,15 +32,10 @@ use PSC\Shop\ContactBundle\Transformer\Model\Contact as ContactTransformer;
use PSC\Shop\EntityBundle\Entity\Product;
use PSC\System\SettingsBundle\Service\Help;
use PSC\System\SettingsBundle\Service\PaperDB;
use Sensio\Bundle\FrameworkExtraBundle\Configuration\IsGranted;
use Sensio\Bundle\FrameworkExtraBundle\Configuration\ParamConverter;
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
use Symfony\Component\HttpFoundation\JsonResponse;
use Symfony\Component\HttpFoundation\Response;
use Symfony\Component\HttpKernel\KernelInterface;
use Symfony\Component\Routing\Annotation\Route;
use Symfony\Component\Routing\Attribute\Route;
use Symfony\Component\Security\Core\Authentication\Token\Storage\TokenStorageInterface;
use Symfony\Component\Yaml\Yaml;
class Preview extends AbstractController
{
@ -77,20 +76,13 @@ class Preview extends AbstractController
$this->helpService = $helpService;
}
/**
* get price
*
* @OA\Response(
* response=200,
* description="orders",
* @OA\JsonContent(ref=@Model(type=\Plugin\System\PSC\XmlCalc\Dto\Output\PriceOutput::class))
* )
* @OA\RequestBody(
*
* @Model(type=\Plugin\System\PSC\XmlCalc\Dto\Input\PriceInput::class))
* )
* @OA\Tag(name="Plugin/System/psc/Xmlcalc/Price")
*/
#[Response(
response: 200,
description: 'generate preview',
content: new JsonContent(ref: new Model(type: PriceOutput::class)),
)]
#[RequestBody(ref: new Model(type: PriceInput::class))]
#[Tag(name: 'Plugin/System/psc/Xmlcalc/Price')]
#[Route(path: '/product/preview', methods: ['POST'])]
#[ParamConverter(
'data',
@ -163,6 +155,43 @@ class Preview extends AbstractController
* @var Base $option
*/
foreach ($engine->getArticle()->getOptions() as $option) {
$output->elements[] = $this->parseOption($option);
}
foreach ($engine->getArticle()->getPreCalc()->getGroups() as $group) {
$groupObj = new Group();
$groupObj->name = $group->getName();
foreach ($group->getVariants() as $variant) {
$variantObj = new Variant();
$variantObj->name = $variant->getName();
$variantObj->text = $variant->getText();
$variantObj->data = $variant->getData();
foreach ($variant->getValues() as $value) {
$valueObj = new Value();
$valueObj->key = $value->getKey();
$valueObj->value = $value->getValue();
$variantObj->values[] = $valueObj;
}
$groupObj->variants[] = $variant;
}
$output->preCalc[] = $groupObj;
}
$output->displayValues = $engine->getDisplayVariables();
$output->exportValues = $engine->getAjaxVariables();
if ($this->isGranted('ROLE_SHOP')) {
$output->debug['formels'] = $engine->getDebugCalcFormel();
$output->debug['flatPrice'] = $engine->getDebugFlatPrice();
$output->debug['price'] = $engine->getDebugPrice();
$output->debug['calcValues'] = $engine->getDebugCalcVariables();
$output->debug['graphJson'] = $engine->getCalcGraph()->generateJsonGraph();
}
return $this->json($output);
}
private function parseOption($option): Element
{
$tmp = new Element();
$tmp->name = $option->getName();
$tmp->required = $option->isRequire();
@ -249,39 +278,16 @@ class Preview extends AbstractController
}
}
}
$output->elements[] = $tmp;
if ($option->type == 'row') {
foreach ($option->getColumns() as $column) {
$tmp->elements[] = $this->parseOption($column);
}
foreach ($engine->getArticle()->getPreCalc()->getGroups() as $group) {
$groupObj = new Group();
$groupObj->name = $group->getName();
foreach ($group->getVariants() as $variant) {
$variantObj = new Variant();
$variantObj->name = $variant->getName();
$variantObj->text = $variant->getText();
$variantObj->data = $variant->getData();
foreach ($variant->getValues() as $value) {
$valueObj = new Value();
$valueObj->key = $value->getKey();
$valueObj->value = $value->getValue();
$variantObj->values[] = $valueObj;
}
$groupObj->variants[] = $variant;
if ($option->type == 'column') {
foreach ($option->getOptions() as $option) {
$tmp->elements[] = $this->parseOption($option);
}
$output->preCalc[] = $groupObj;
}
$output->displayValues = $engine->getDisplayVariables();
$output->exportValues = $engine->getAjaxVariables();
if ($this->isGranted('ROLE_SHOP')) {
$output->debug['formels'] = $engine->getDebugCalcFormel();
$output->debug['flatPrice'] = $engine->getDebugFlatPrice();
$output->debug['price'] = $engine->getDebugPrice();
$output->debug['calcValues'] = $engine->getDebugCalcVariables();
$output->debug['graphJson'] = $engine->getCalcGraph()->generateJsonGraph();
}
return $this->json($output);
return $tmp;
}
}

View File

@ -104,16 +104,24 @@ class PreviewDesigner extends AbstractController
}
$engine->setTax(19);
$output->netto = $engine->getPrice() * 100;
$output->tax = $engine->getTaxPrice() * 100;
$output->brutto = $engine->getCompletePrice() * 100;
$output->netto = round($engine->getPrice() * 100);
$output->tax = round($engine->getTaxPrice() * 100);
$output->brutto = round($engine->getCompletePrice() * 100);
/**
* @var Base $option
*/
foreach ($engine->getArticle()->getOptions() as $option) {
$output->elements[] = $this->parseOption($option);
}
return $this->json($output);
}
private function parseOption($option): Element
{
$tmp = new Element();
if ($option->getName()) {
$tmp->name = $option->getName();
}
$tmp->required = $option->isRequire();
if (is_array($option->getRawValue())) {
$tmp->rawValues = $option->getRawValue();
@ -198,9 +206,16 @@ class PreviewDesigner extends AbstractController
}
}
}
$output->elements[] = $tmp;
if ($option->type == 'row') {
foreach ($option->getColumns() as $column) {
$tmp->elements[] = $this->parseOption($column);
}
return $this->json($output);
}
if ($option->type == 'column') {
foreach ($option->getOptions() as $option) {
$tmp->elements[] = $this->parseOption($option);
}
}
return $tmp;
}
}

View File

@ -2,22 +2,24 @@
namespace Plugin\System\PSC\XmlCalc\Api\Product;
use PSC\Shop\EntityBundle\Entity\Product as PSCProduct;
use Plugin\System\PSC\XmlCalc\Model\Product;
use Sensio\Bundle\FrameworkExtraBundle\Configuration\ParamConverter;
use Doctrine\ORM\EntityManagerInterface;
use Nelmio\ApiDocBundle\Attribute\Model;
use Nelmio\ApiDocBundle\Attribute\Security;
use OpenApi\Attributes\JsonContent;
use OpenApi\Attributes\RequestBody;
use OpenApi\Attributes\Response;
use OpenApi\Attributes\Tag;
use Plugin\System\PSC\XmlCalc\Model\Product;
use PSC\Component\ApiBundle\Dto\Error\NotFound;
use PSC\Shop\EntityBundle\Entity\Product as PSCProduct;
use Sensio\Bundle\FrameworkExtraBundle\Configuration\IsGranted;
use Sensio\Bundle\FrameworkExtraBundle\Configuration\ParamConverter;
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
use Symfony\Component\HttpFoundation\JsonResponse;
use Nelmio\ApiDocBundle\Annotation\Security;
use Sensio\Bundle\FrameworkExtraBundle\Configuration\IsGranted;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\Routing\Annotation\Route;
use OpenApi\Annotations as OA;
use Nelmio\ApiDocBundle\Annotation\Model;
class Update extends AbstractController {
use Symfony\Component\Routing\Attribute\Route;
class Update extends AbstractController
{
private EntityManagerInterface $entityManager;
public function __construct(EntityManagerInterface $entityManager)
@ -25,33 +27,30 @@ class Update extends AbstractController {
$this->entityManager = $entityManager;
}
/**
* change product
*
* @OA\Response(
* response=200,
* description="update product",
* @OA\JsonContent(ref=@Model(type=\Plugin\System\PSC\XmlCalc\Model\Product::class))
* )
* @OA\RequestBody(
* description="This is a request body",
* @Model(type=\Plugin\System\PSC\XmlCalc\Model\Product::class)
* )
* @OA\Tag(name="Plugin/System/psc/Xmlcalc/Product")
* @Security(name="Bearer")
*/
#[Response(
response: 200,
description: 'update product',
content: new JsonContent(ref: new Model(type: Product::class)),
)]
#[Security(name: 'Bearer')]
#[RequestBody(ref: new Model(type: Product::class))]
#[Tag(name: 'Plugin/System/psc/Xmlcalc/Product')]
#[Route(path: '/product/{uuid}', methods: ['PUT'])]
#[ParamConverter('productObj', class: '\Plugin\System\PSC\XmlCalc\Model\Product', converter: 'psc_rest.request_body')]
#[ParamConverter(
'productObj',
class: '\Plugin\System\PSC\XmlCalc\Model\Product',
converter: 'psc_rest.request_body',
)]
#[IsGranted('ROLE_USER')]
public function update(string $uuid, Product $productObj): JsonResponse
{
$product = $this->entityManager->getRepository(PSCProduct::class)->findOneBy(['uuid' => $uuid]);
if(!$product) {
if (!$product) {
return $this->json(new NotFound('paper not found'));
}
if($productObj->calcXml !== null) {
if ($productObj->calcXml !== null) {
$product->setCalcXml($productObj->calcXml);
}
@ -60,5 +59,4 @@ class Update extends AbstractController {
return $this->json($productObj);
}
}

View File

@ -4,9 +4,11 @@ namespace Plugin\System\PSC\XmlCalc\Api\Product;
use Doctrine\ODM\MongoDB\DocumentManager;
use Doctrine\ORM\EntityManagerInterface;
use Nelmio\ApiDocBundle\Annotation\Model;
use Nelmio\ApiDocBundle\Annotation\Security;
use OpenApi\Annotations as OA;
use Nelmio\ApiDocBundle\Attribute\Model;
use OpenApi\Attributes\JsonContent;
use OpenApi\Attributes\RequestBody;
use OpenApi\Attributes\Response;
use OpenApi\Attributes\Tag;
use Plugin\System\PSC\XmlCalc\Dto\Input\XMLInput;
use Plugin\System\PSC\XmlCalc\Model\Product as PluginProduct;
use PSC\Component\ApiBundle\Dto\Error\NotFound;
@ -33,18 +35,13 @@ class XML extends AbstractController
private EntityManagerInterface $entityManager,
) {}
/**
* @OA\Response(
* response=200,
* description="get config for product",
* @OA\JsonContent(ref=@Model(type=\Plugin\System\PSC\XmlCalc\Model\Product::class))
* )
* @OA\RequestBody(
*
* @Model(type=\Plugin\System\PSC\XmlCalc\Dto\Input\XML::class))
* )
* @OA\Tag(name="Plugin/System/psc/Xmlcalc/Product")
* */
#[Response(
response: 200,
description: 'get config for product',
content: new JsonContent(ref: new Model(type: PluginProduct::class)),
)]
#[RequestBody(ref: new Model(type: XMLInput::class))]
#[Tag(name: 'Plugin/System/psc/Xmlcalc/Product')]
#[Route(path: '/product/xml', methods: ['POST'])]
#[ParamConverter(
'data',

View File

@ -17,5 +17,5 @@ final class PDInput
public array $json = [];
#[Property(type: 'array', items: new Items(type: 'string'))]
public array $values = ['auflage' => 100];
public array $values = [];
}

View File

@ -33,6 +33,5 @@ final class PriceInput
*
* @OA\Property(type="array", @OA\Items(type="string"))
*/
public array $values = ['auflage' => 100];
public array $values = [];
}

View File

@ -32,5 +32,5 @@ final class XMLInput
*
* @OA\Property(type="array", @OA\Items(type="string"))
*/
public array $values = ['auflage' => 100];
public array $values = [];
}

View File

@ -4,6 +4,8 @@ namespace Plugin\System\PSC\XmlCalc\Dto\Output\Price;
use Nelmio\ApiDocBundle\Annotation\Model;
use OpenApi\Annotations as OA;
use OpenApi\Attributes\Items;
use OpenApi\Attributes\Property;
class Element
{
@ -26,35 +28,35 @@ class Element
*
* @OA\Property(type="string")
*/
public string $pattern = "";
public string $pattern = '';
/**
* @var string
*
* @OA\Property(type="string")
*/
public string $colorSystem = "";
public string $colorSystem = '';
/**
* @var string
*
* @OA\Property(type="string")
*/
public string $placeHolder = "";
public string $placeHolder = '';
/**
* @var string
*
* @OA\Property(type="string")
*/
public string $displayGroup = "";
public string $displayGroup = '';
/**
* @var string
*
* @OA\Property(type="string")
*/
public string $defaultValue = "";
public string $defaultValue = '';
/**
* @var string
@ -66,29 +68,21 @@ class Element
/**
* @OA\Property(type="integer")
*/
public ?int $minValue;
public null|int $minValue;
/**
* @OA\Property(type="integer")
*/
public ?int $maxValue;
public null|int $maxValue;
/**
* @OA\Property(type="string")
*/
public ?string $help;
#[Property(type: 'string')]
public null|string $help;
/**
* @OA\Property(type="string")
*/
public ?string $helpTitle;
/**
* @OA\Property(type="string")
*/
public ?string $helpLink;
#[Property(type: 'string')]
public null|string $helpTitle;
#[Property(type: 'string')]
public null|string $helpLink;
/**
* @var bool
@ -104,11 +98,7 @@ class Element
*/
public bool $required = false;
/**
* @var string
*
* @OA\Property(type="string")
*/
#[Property(type: 'string')]
public string $rawValue;
/**
@ -118,11 +108,7 @@ class Element
*/
public array $rawValues = [];
/**
* @var string
*
* @OA\Property(type="string")
*/
#[Property(type: 'string')]
public string $type;
/**
@ -132,11 +118,10 @@ class Element
*/
public array $options = [];
/**
* @var string
*
* @OA\Property(type="string")
*/
#[Property(type: 'array', items: new Items(ref: new Model(type: Element::class)))]
public array $elements = [];
#[Property(type: 'string')]
public string $htmlType = 'input';
/** @var Error[]
@ -144,5 +129,4 @@ class Element
* @OA\Property(type="array", @OA\Items(ref=@Model(type=\Plugin\System\PSC\XmlCalc\Dto\Output\Price\Validation\Error::class)))
*/
public array $validationErrors = [];
}

View File

@ -6,20 +6,20 @@ use Brick\Math\RoundingMode;
use Brick\Money\Money;
use Doctrine\ODM\MongoDB\DocumentManager;
use Doctrine\ORM\EntityManagerInterface;
use PSC\Shop\ContactBundle\Model\Contact;
use Plugin\System\PSC\XmlCalc\Model\ProductSpecialObject;
use PSC\Library\Calc\Engine;
use PSC\Library\Calc\Option\Type\Hidden;
use PSC\Library\Calc\Option\Type\Select;
use PSC\Library\Calc\PaperContainer;
use PSC\Shop\ContactBundle\Model\Contact;
use PSC\Shop\OrderBundle\Model\Order\Position;
use PSC\Shop\OrderBundle\Model\Order\Position\Price;
use PSC\Shop\OrderBundle\Model\Order\Tax;
use PSC\Shop\OrderBundle\Model\Order\TaxEnum;
use PSC\Shop\ProductBundle\Interfaces\ICalcNeedContact;
use PSC\Shop\ProductBundle\Interfaces\IProducerHydrateModel;
use PSC\Shop\ProductBundle\Interfaces\IProductTransformer;
use PSC\Shop\ProductBundle\Interfaces\IUiProducer;
use PSC\Shop\ProductBundle\Interfaces\ICalcNeedContact;
use PSC\Shop\ProductBundle\Model\Product;
use PSC\System\SettingsBundle\Service\PaperDB;
use PSC\System\SettingsBundle\Service\Shop;
@ -32,10 +32,14 @@ class Producer implements IUiProducer, IProducerHydrateModel, ICalcNeedContact
private Product $product;
private Engine $engine;
private EntityManagerInterface $entityManager;
private ?Contact $contact = null;
private null|Contact $contact = null;
public function __construct(Shop $shopService, PaperDB $paperService, DocumentManager $documentManager, EntityManagerInterface $entityManager)
{
public function __construct(
Shop $shopService,
PaperDB $paperService,
DocumentManager $documentManager,
EntityManagerInterface $entityManager,
) {
$this->shopService = $shopService;
$this->paperService = $paperService;
$this->mongoService = $documentManager;
@ -52,7 +56,7 @@ class Producer implements IUiProducer, IProducerHydrateModel, ICalcNeedContact
{
/**
* @var ProductSpecialObject $specProd
*/
*/
$specProd = $this->product->getSpecialProductTypeObject();
$specProd->setParams($params);
}
@ -64,18 +68,25 @@ class Producer implements IUiProducer, IProducerHydrateModel, ICalcNeedContact
public function getPrice(): Price
{
$this->setVariables();
/**
* @var ProductSpecialObject $specProd
*/
*/
$specProd = $this->product->getSpecialProductTypeObject();
$priceObj = Money::ofMinor($this->engine->getPrice() * 100, 'EUR');
$price = new Price();
$price->setNet($priceObj->getMinorAmount()->toInt());
$price->setVat($priceObj->toRational()->dividedBy(100)->multipliedBy($specProd->getTaxClass() / 100)->to($priceObj->getContext(), RoundingMode::UP)->getMinorAmount()->toInt());
$price->setVat(
$priceObj
->toRational()
->dividedBy(100)
->multipliedBy($specProd->getTaxClass() / 100)
->to($priceObj->getContext(), RoundingMode::UP)
->getMinorAmount()
->toInt(),
);
$price->setGross($price->getNet() + $price->getVat());
$price->setCount(1);
$price->setAllNet($price->getNet());
@ -91,7 +102,7 @@ class Producer implements IUiProducer, IProducerHydrateModel, ICalcNeedContact
if ($this->product->getSpecialProductTypeObject()) {
/**
* @var ProductSpecialObject $specProd
*/
*/
$specProd = $this->product->getSpecialProductTypeObject();
$this->engine->setVariables($specProd->getParams());
@ -115,7 +126,9 @@ class Producer implements IUiProducer, IProducerHydrateModel, ICalcNeedContact
$paperContainer = new PaperContainer();
if ($this->product->getSpecialProductTypeObject() && $this->product->getSpecialProductTypeObject()->getXml()) {
$shop = $this->shopService->getShopByUid($this->product->getShopUuid());
$engine = new Engine();
$paperContainer->parse(simplexml_load_string($shop->getInstall()->getPaperContainer()));
$engine->setPaperRepository($this->paperService);
$engine->setPaperContainer($paperContainer);
$engine->loadString($this->product->getSpecialProductTypeObject()->getXml());
if ($shop) {
$engine->setFormulas($shop->getFormel());
@ -124,15 +137,17 @@ class Producer implements IUiProducer, IProducerHydrateModel, ICalcNeedContact
} elseif ($this->product->getUid()) {
/**
* @var \PSC\Shop\EntityBundle\Entity\Product $product
*/
$product = $this->entityManager->getRepository(\PSC\Shop\EntityBundle\Entity\Product::class)->find($this->product->getUid());
*/
$product = $this->entityManager
->getRepository(\PSC\Shop\EntityBundle\Entity\Product::class)
->find($this->product->getUid());
$paperContainer->parse(simplexml_load_string($product->getShop()->getInstall()->getPaperContainer()));
$engine = new Engine();
$engine->setPaperRepository($this->paperService);
$engine->setPaperContainer($paperContainer);
if ($product->getShop()->getInstall()->getCalcTemplates()) {
$engine->setTemplates('<root>'.$product->getShop()->getInstall()->getCalcTemplates().'</root>');
$engine->setTemplates('<root>' . $product->getShop()->getInstall()->getCalcTemplates() . '</root>');
}
$engine->loadString($product->getCalcXml());
$engine->setFormulas($product->getShop()->getFormel());
@ -140,14 +155,16 @@ class Producer implements IUiProducer, IProducerHydrateModel, ICalcNeedContact
} elseif ($this->product->getUuid()) {
/**
* @var \PSC\Shop\EntityBundle\Entity\Product $product
*/
$product = $this->entityManager->getRepository(\PSC\Shop\EntityBundle\Entity\Product::class)->findOneBy(['uuid' => $this->product->getUuid()]);
*/
$product = $this->entityManager
->getRepository(\PSC\Shop\EntityBundle\Entity\Product::class)
->findOneBy(['uuid' => $this->product->getUuid()]);
$paperContainer->parse(simplexml_load_string($product->getShop()->getInstall()->getPaperContainer()));
$engine = new Engine();
$engine->setPaperRepository($this->paperService);
$engine->setPaperContainer($paperContainer);
if ($product->getShop()->getInstall()->getCalcTemplates()) {
$engine->setTemplates('<root>'.$product->getShop()->getInstall()->getCalcTemplates().'</root>');
$engine->setTemplates('<root>' . $product->getShop()->getInstall()->getCalcTemplates() . '</root>');
}
$engine->loadString($product->getCalcXml());
$engine->setFormulas($product->getShop()->getFormel());
@ -164,16 +181,14 @@ class Producer implements IUiProducer, IProducerHydrateModel, ICalcNeedContact
public function getJsonForm(): array
{
$this->setVariables();
$temp = [
'title' => $this->product->getTitle(),
'type' => 'object',
'properties' => [],
'required' => []
'required' => [],
];
foreach ($this->engine->getArticle()->getOptions() as $option) {
if (!$option->isValid()) {
continue;
@ -183,23 +198,25 @@ class Producer implements IUiProducer, IProducerHydrateModel, ICalcNeedContact
}
if ($option instanceof Select) {
$temp['properties'][$option->getId()] = [
'type' => 'string',
'title' => $option->getName(),
'oneOf' => [],
'default' => $option->getSelectedOption()->getId()
'default' => $option->getSelectedOption()->getId(),
];
foreach ($option->getValidOptions() as $opt) {
if ($opt->isValid()) {
$temp['properties'][$option->getId()]['oneOf'][] = ['title' => $opt->getLabel(), 'const' => $opt->getId()];
$temp['properties'][$option->getId()]['oneOf'][] = [
'title' => $opt->getLabel(),
'const' => $opt->getId(),
];
}
}
} else {
$temp['properties'][$option->getId()] = [
'type' => 'string',
'title' => $option->getName(),
'default' => $option->getRawValue()
'default' => $option->getRawValue(),
];
}
}
@ -210,21 +227,20 @@ class Producer implements IUiProducer, IProducerHydrateModel, ICalcNeedContact
public function getUiJsonForm(): array
{
$temp = [
"ui:submitButtonOptions" => [
"submitText" => "Save",
"norender" => true,
"props" => [
"disabled" => false,
"className" => "btn btn-info"
]
]
'ui:submitButtonOptions' => [
'submitText' => 'Save',
'norender' => true,
'props' => [
'disabled' => false,
'className' => 'btn btn-info',
],
],
];
foreach ($this->engine->getArticle()->getOptions() as $option) {
if ($option instanceof Hidden) {
$temp[$option->getId()] = [
'ui:widget' => 'hidden',
];
}
}
@ -232,7 +248,7 @@ class Producer implements IUiProducer, IProducerHydrateModel, ICalcNeedContact
return $temp;
}
public function setContact(?Contact $contact): void
public function setContact(null|Contact $contact): void
{
$this->contact = $contact;
}

File diff suppressed because it is too large Load Diff

View File

@ -4121,6 +4121,14 @@ class UserController extends TP_Controller_Action
$this->redirectSpeak('/basket/anfrage');
return;
}
if (file_exists($this->_templatePath . '/user/cregister.phtml')) {
if ($this->_getParam('mode') == 'basket') {
$this->_redirect('/user/cregister?mode=basket');
} else {
$this->_redirect('/user/cregister');
}
return;
}
if ($this->_request->getParam('mode') == 'basket') {
$this->view->priorityMessenger('Register successfull', 'success');
@ -4173,6 +4181,16 @@ class UserController extends TP_Controller_Action
{
if ($this->_request->getParam('contact', false)) {
$vars = explode('*', $this->_request->getParam('contact', false));
if (count($vars) == 1) {
if ('nsWXSoLmx8TNEjdE8fbn' != $this->_request->getParam('apikey', false)) {
die('Not allowed');
}
$_authAdapter = new TP_Plugin_AuthAdapter(); // put this in a constructor?
$_authAdapter->setApiLogin(true);
$_authAdapter->setIdentity($vars[0]);
$result = Zend_Auth::getInstance()->authenticate($_authAdapter);
} else {
if ('nsWXSoLmx8TNEjdE8fbn' != $vars[1]) {
die('Not allowed');
}
@ -4187,7 +4205,8 @@ class UserController extends TP_Controller_Action
$_SESSION['to_identity'] = urldecode($vars[4]);
$_SESSION['sender_domain'] = urldecode($vars[5]);
$_SESSION['sender_identity'] = urldecode($vars[6]);
$_SESSION['buyer_cookie'] = urldecode($vars[7]);
}
if ($result->isValid()) {
return $this->redirectSpeak('/');
}
@ -4244,6 +4263,8 @@ class UserController extends TP_Controller_Action
urlencode((string) $xml->Header->Sender->Credential['domain']) .
'*' .
urlencode((string) $xml->Header->Sender->Credential->Identity) .
'*' .
urlencode((string) $xml->Request->PunchOutSetupRequest->BuyerCookie) .
'</URL>' .
'</StartPage>' .
'</PunchOutSetupResponse>' .
@ -4860,6 +4881,14 @@ class UserController extends TP_Controller_Action
}
public function clogoutAction()
{
Zend_Auth::getInstance()->clearIdentity();
$basket = new TP_Basket();
$basket->clear();
}
public function cregisterAction()
{
}

View File

@ -23,7 +23,6 @@ class TP_Plugin_AuthAdapter implements Zend_Auth_Adapter_Interface
*/
protected $_apiLogin = false;
protected $_idLogin = false;
/**
@ -58,10 +57,11 @@ class TP_Plugin_AuthAdapter implements Zend_Auth_Adapter_Interface
if ($this->_idLogin !== false) {
$row = Doctrine_Query::create()
->from('Contact m')
->where('m.id= ?', array($this->_idLogin))
->execute()->getFirst();
->where('m.id= ?', [$this->_idLogin])
->execute()
->getFirst();
$_identity = $row->toArray(true);
return new Zend_Auth_Result(true, $_identity, array('Erfolgreich authentifiziert an der Datendank'));
return new Zend_Auth_Result(true, $_identity, ['Erfolgreich authentifiziert an der Datendank']);
}
$shop = Zend_Registry::get('shop');
@ -69,82 +69,102 @@ class TP_Plugin_AuthAdapter implements Zend_Auth_Adapter_Interface
if ($shop['install_id'] == 4999) {
$row = Doctrine_Query::create()
->from('Contact m')
->where('m.self_email = ? AND m.enable = 1 AND m.virtual = 0 AND m.install_id = ?', array($this->_identity, $shop['install_id']))
->execute()->getFirst();
->where('m.self_email = ? AND m.enable = 1 AND m.virtual = 0 AND m.install_id = ?', [
$this->_identity,
$shop['install_id'],
])
->execute()
->getFirst();
} elseif ($this->_apiLogin) {
$row = Doctrine_Query::create()
->from('Contact m')
->leftJoin('m.Shops as s')
->where('m.id = ? AND m.enable = 1 AND s.id = ?', array($this->_identity, $shop['id']))
->execute()->getFirst();
->where('(m.id = ? OR m.self_email = ?) AND m.enable = 1 AND s.id = ?', [
$this->_identity,
$this->_identity,
$shop['id'],
])
->execute()
->getFirst();
} else {
if ($shop['useemailaslogin'] == true) {
$row = Doctrine_Query::create()
->from('Contact m')
->leftJoin('m.Shops as s')
->where('m.self_email = ? AND m.enable = 1 AND m.virtual = 0 AND s.id = ?', array($this->_identity, $shop['id']))
->execute()->getFirst();
->where('m.self_email = ? AND m.enable = 1 AND m.virtual = 0 AND s.id = ?', [
$this->_identity,
$shop['id'],
])
->execute()
->getFirst();
} else {
$row = Doctrine_Query::create()
->from('Contact m')
->leftJoin('m.Shops as s')
->where('m.name = ? AND m.enable = 1 AND m.virtual = 0 AND s.id = ?', array($this->_identity, $shop['id']))
->execute()->getFirst();
->where('m.name = ? AND m.enable = 1 AND m.virtual = 0 AND s.id = ?', [
$this->_identity,
$shop['id'],
])
->execute()
->getFirst();
}
}
if ($row->password == "") {
return new Zend_Auth_Result(false, $_identity, array('empty password'));
if ($row->password == '') {
return new Zend_Auth_Result(false, $_identity, ['empty password']);
}
// Es darf diesen Benutzer nur genau 1x geben
if (!isset($row->id)) {
return new Zend_Auth_Result(false, $_identity, array('Login failure'));
return new Zend_Auth_Result(false, $_identity, ['Login failure']);
}
if ($row->locked || $row->Account->locked) {
return new Zend_Auth_Result(false, $_identity, array('Sie wurden gesperrt'));
return new Zend_Auth_Result(false, $_identity, ['Sie wurden gesperrt']);
}
if ($row->id != '' && $row->password == $this->_credential && !$this->_apiLogin) {
$row->password = password_hash($row->password, PASSWORD_DEFAULT);
$row->save();
$_identity = $row->toArray(true);
$_identity['name1'] = $_identity['self_firstname'].' '.$_identity['self_lastname'];
$_identity['name1'] = $_identity['self_firstname'] . ' ' . $_identity['self_lastname'];
$dbMongo = TP_Mongo::getInstance();
$dbMongo->Job->insertOne(array(
"shop" => $shop['id'],
"event" => "contact_login",
"data" => [ "contact" => $row->uuid ],
"created" => new MongoDB\BSON\UTCDateTime(),
"updated" => new MongoDB\BSON\UTCDateTime()
));
return new Zend_Auth_Result(true, $_identity, array('Erfolgreich authentifiziert an der Datendank'));
} elseif (function_exists('password_verify') && password_verify($this->_credential, $row->password) && !$this->_apiLogin) {
$dbMongo->Job->insertOne([
'shop' => $shop['id'],
'event' => 'contact_login',
'data' => ['contact' => $row->uuid],
'created' => new MongoDB\BSON\UTCDateTime(),
'updated' => new MongoDB\BSON\UTCDateTime(),
]);
return new Zend_Auth_Result(true, $_identity, ['Erfolgreich authentifiziert an der Datendank']);
} elseif (
function_exists('password_verify') &&
password_verify($this->_credential, $row->password) &&
!$this->_apiLogin
) {
$_identity = $row->toArray(true);
$_identity['name1'] = $_identity['self_firstname'].' '.$_identity['self_lastname'];
$_identity['name1'] = $_identity['self_firstname'] . ' ' . $_identity['self_lastname'];
$dbMongo = TP_Mongo::getInstance();
$dbMongo->Job->insertOne(array(
"shop" => $shop['id'],
"event" => "contact_login",
"data" => [ "contact" => $row->uuid ],
"created" => new MongoDB\BSON\UTCDateTime(),
"updated" => new MongoDB\BSON\UTCDateTime()
));
return new Zend_Auth_Result(true, $_identity, array('Erfolgreich authentifiziert an der Datendank'));
$dbMongo->Job->insertOne([
'shop' => $shop['id'],
'event' => 'contact_login',
'data' => ['contact' => $row->uuid],
'created' => new MongoDB\BSON\UTCDateTime(),
'updated' => new MongoDB\BSON\UTCDateTime(),
]);
return new Zend_Auth_Result(true, $_identity, ['Erfolgreich authentifiziert an der Datendank']);
} elseif ($this->_apiLogin) {
$_identity = $row->toArray(true);
$_identity['name1'] = $_identity['self_firstname'].' '.$_identity['self_lastname'];
$_identity['name1'] = $_identity['self_firstname'] . ' ' . $_identity['self_lastname'];
$dbMongo = TP_Mongo::getInstance();
$dbMongo->Job->insertOne(array(
"shop" => $shop['id'],
"event" => "contact_login",
"data" => [ "contact" => $row->uuid ],
"created" => new MongoDB\BSON\UTCDateTime(),
"updated" => new MongoDB\BSON\UTCDateTime()
));
return new Zend_Auth_Result(true, $_identity, array('Erfolgreich authentifiziert an der Datendank'));
$dbMongo->Job->insertOne([
'shop' => $shop['id'],
'event' => 'contact_login',
'data' => ['contact' => $row->uuid],
'created' => new MongoDB\BSON\UTCDateTime(),
'updated' => new MongoDB\BSON\UTCDateTime(),
]);
return new Zend_Auth_Result(true, $_identity, ['Erfolgreich authentifiziert an der Datendank']);
} else {
return new Zend_Auth_Result(false, $_identity, array('Passwort falsch!'));
return new Zend_Auth_Result(false, $_identity, ['Passwort falsch!']);
}
}