Skip to content

Commit

Permalink
Merge pull request #1948 from dpfaffenbauer/features/quote-state-machine
Browse files Browse the repository at this point in the history
[Quotes] introduce simple state machine
  • Loading branch information
dpfaffenbauer authored Apr 7, 2022
2 parents 26077b3 + 6210c5f commit a62f777
Show file tree
Hide file tree
Showing 30 changed files with 540 additions and 14 deletions.
2 changes: 0 additions & 2 deletions docker-compose.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,6 @@ services:
- MYSQL_DATABASE=pimcore
- MYSQL_USER=pimcore
- MYSQL_PASSWORD=pimcore
ports:
- "3306:3306"

nginx:
image: nginx:stable-alpine
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ public function applyOrderWorkflowRule(Event $event): void
'firstname' => $customer->getFirstname(),
'lastname' => $customer->getLastname(),
'orderNumber' => $order->getOrderNumber(),
'quoteNumber' => $order->getQuoteNumber(),
'transition' => $event->getTransition()->getName(),
]);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,6 @@ final class OrderSaleStateConfigurationType extends AbstractType
public function buildForm(FormBuilderInterface $builder, array $options): void
{
$builder
->add('saleState', TextType::class, [
]);
->add('saleState', TextType::class, []);
}

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
<?php
/**
* CoreShop.
*
* This source file is subject to the GNU General Public License version 3 (GPLv3)
* For the full copyright and license information, please view the LICENSE.md and gpl-3.0.txt
* files that are distributed with this source code.
*
* @copyright Copyright (c) CoreShop GmbH (https://www.coreshop.org)
* @license https://www.coreshop.org/license GNU General Public License version 3 (GPLv3)
*/

declare(strict_types=1);

namespace CoreShop\Bundle\CoreBundle\Form\Type\Notification\Condition;

use Symfony\Component\Form\AbstractType;
use Symfony\Component\Form\Extension\Core\Type\TextType;
use Symfony\Component\Form\FormBuilderInterface;

final class QuoteStateConfigurationType extends AbstractType
{
public function buildForm(FormBuilderInterface $builder, array $options): void
{
$builder->add('quoteState', TextType::class);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
<?php

declare(strict_types=1);

namespace CoreShop\Bundle\CoreBundle\Migrations;

use CoreShop\Component\Pimcore\DataObject\ClassUpdate;
use Doctrine\DBAL\Schema\Schema;
use Doctrine\Migrations\AbstractMigration;
use Symfony\Component\DependencyInjection\ContainerAwareInterface;
use Symfony\Component\DependencyInjection\ContainerAwareTrait;

final class Version20220330151612 extends AbstractMigration implements ContainerAwareInterface
{
use ContainerAwareTrait;

public function getDescription(): string
{
return '';
}

public function up(Schema $schema): void
{
$orderClassName = $this->container->getParameter('coreshop.model.order.pimcore_class_name');
$classUpdater = new ClassUpdate($orderClassName);

$fieldQuoteStatus = [
"fieldtype" => "input",
"width" => null,
"queryColumnType" => "varchar",
"columnType" => "varchar",
"columnLength" => 190,
"phpdocType" => "string",
"regex" => "",
"unique" => false,
"showCharCount" => null,
"name" => "quoteState",
"title" => "coreshop.order.quote_state",
"tooltip" => "",
"mandatory" => false,
"noteditable" => true,
"index" => false,
"locked" => false,
"style" => "",
"permissions" => null,
"datatype" => "data",
"relationType" => false,
"invisible" => false,
"visibleGridView" => false,
"visibleSearch" => false,
];

if (!$classUpdater->hasField('quoteState')) {
$classUpdater->insertFieldBefore('orderState', $fieldQuoteStatus);
}

$classUpdater->save();
}

public function down(Schema $schema): void
{
// this down() migration is auto-generated, please modify it to your needs

}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
<?php

declare(strict_types=1);

namespace CoreShop\Bundle\CoreBundle\Migrations;

use CoreShop\Component\Pimcore\DataObject\ClassUpdate;
use Doctrine\DBAL\Schema\Schema;
use Doctrine\Migrations\AbstractMigration;
use Symfony\Component\DependencyInjection\ContainerAwareInterface;
use Symfony\Component\DependencyInjection\ContainerAwareTrait;

final class Version20220330153600 extends AbstractMigration implements ContainerAwareInterface
{
use ContainerAwareTrait;

public function getDescription(): string
{
return '';
}

public function up(Schema $schema): void
{
$orderClassName = $this->container->getParameter('coreshop.model.order.pimcore_class_name');
$classUpdater = new ClassUpdate($orderClassName);

$fieldQuoteNumber = [
"fieldtype" => "input",
"width" => null,
"queryColumnType" => "varchar",
"columnType" => "varchar",
"columnLength" => 190,
"phpdocType" => "string",
"regex" => "",
"unique" => false,
"showCharCount" => null,
"name" => "quoteNumber",
"title" => "coreshop.order.quote_number",
"tooltip" => "",
"mandatory" => false,
"noteditable" => true,
"index" => false,
"locked" => false,
"style" => "",
"permissions" => null,
"datatype" => "data",
"relationType" => false,
"invisible" => false,
"visibleGridView" => false,
"visibleSearch" => false,
];

if (!$classUpdater->hasField('quoteNumber')) {
$classUpdater->insertFieldBefore('orderNumber', $fieldQuoteNumber);
}

$classUpdater->save();
}

public function down(Schema $schema): void
{
// this down() migration is auto-generated, please modify it to your needs

}
}
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,8 @@ core_shop_core:
notification_rule_condition_order_backend_created: '/bundles/coreshopcore/pimcore/js/notification/conditions/order/backendCreated.js'
notification_rule_condition_order_order_state: '/bundles/coreshopcore/pimcore/js/notification/conditions/order/orderState.js'
notification_rule_condition_order_order_state_transition: '/bundles/coreshopcore/pimcore/js/notification/conditions/order/orderTransition.js'
notification_rule_condition_order_quote_state: '/bundles/coreshopcore/pimcore/js/notification/conditions/quote/quoteState.js'
notification_rule_condition_order_quote_state_transition: '/bundles/coreshopcore/pimcore/js/notification/conditions/quote/quoteTransition.js'
notification_rule_condition_order_payment: '/bundles/coreshopcore/pimcore/js/notification/conditions/order/payment.js'
notification_rule_condition_order_payment_state: '/bundles/coreshopcore/pimcore/js/notification/conditions/order/orderPaymentState.js'
notification_rule_condition_order_payment_transition: '/bundles/coreshopcore/pimcore/js/notification/conditions/order/orderPaymentTransition.js'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,24 @@ services:
tags:
- { name: coreshop.notification_rule.condition, type: orderTransition, notification-type: order, form-type: CoreShop\Bundle\CoreBundle\Form\Type\Notification\Condition\StateTransitionConfigurationType }

##### Quote
coreshop.notification_rule.condition.quote.quote_state:
class: CoreShop\Component\Core\Notification\Rule\Condition\SimpleStateChecker
arguments:
- 'CoreShop\Component\Order\Model\OrderInterface'
- 'quoteState'
- 'quoteState'
tags:
- { name: coreshop.notification_rule.condition, type: quoteState, notification-type: quote, form-type: CoreShop\Bundle\CoreBundle\Form\Type\Notification\Condition\QuotetateConfigurationType }

coreshop.notification_rule.condition.quote.quote_transition:
class: CoreShop\Component\Core\Notification\Rule\Condition\StateTransitionChecker
arguments:
- 'CoreShop\Component\Order\Model\OrderInterface'
- !php/const CoreShop\Component\Order\QuoteTransitions::IDENTIFIER
tags:
- { name: coreshop.notification_rule.condition, type: quoteTransition, notification-type: quote, form-type: CoreShop\Bundle\CoreBundle\Form\Type\Notification\Condition\StateTransitionConfigurationType }

##### MISC
CoreShop\Component\Core\Notification\Rule\Condition\Order\CarriersChecker:
tags:
Expand Down Expand Up @@ -223,8 +241,8 @@ services:
- { name: kernel.event_listener, event: workflow.coreshop_order_invoice.completed, method: applyOrderWorkflowRule }
- { name: kernel.event_listener, event: workflow.coreshop_order_shipment.completed, method: applyOrderWorkflowRule }
- { name: kernel.event_listener, event: workflow.coreshop_order_payment.completed, method: applyOrderWorkflowRule }
- { name: kernel.event_listener, event: workflow.coreshop_quote.completed, method: applyOrderWorkflowRule }
- { name: kernel.event_listener, event: workflow.coreshop_order_sales_type.completed, method: applyOrderWorkflowRule }
- { name: kernel.event_listener, event: workflow.coreshop_quote.completed, method: applyOrderWorkflowRule }

CoreShop\Bundle\CoreBundle\EventListener\NotificationRules\OrderCommentsListener:
parent: CoreShop\Bundle\CoreBundle\EventListener\NotificationRules\AbstractNotificationRuleListener
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -118,3 +118,4 @@ services:
- '@CoreShop\Component\Resource\Service\FolderCreationServiceInterface'
- '@coreshop.quote.number_generator.default'
- '@CoreShop\Component\Pimcore\DataObject\ObjectClonerInterface'
- '@CoreShop\Bundle\WorkflowBundle\Applier\StateMachineApplier'
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,31 @@
"visibleGridView": false,
"visibleSearch": false
},
{
"fieldtype": "input",
"width": null,
"queryColumnType": "varchar",
"columnType": "varchar",
"columnLength": 190,
"phpdocType": "string",
"regex": "",
"unique": null,
"showCharCount": null,
"name": "quoteNumber",
"title": "coreshop.order.quote.number",
"tooltip": "",
"mandatory": false,
"noteditable": true,
"index": false,
"locked": false,
"style": "",
"permissions": null,
"datatype": "data",
"relationType": false,
"invisible": false,
"visibleGridView": false,
"visibleSearch": false
},
{
"fieldtype": "input",
"width": null,
Expand Down Expand Up @@ -3164,6 +3189,31 @@
"datatype": "layout",
"permissions": null,
"childs": [
{
"fieldtype": "input",
"width": null,
"queryColumnType": "varchar",
"columnType": "varchar",
"columnLength": 190,
"phpdocType": "string",
"regex": "",
"unique": false,
"showCharCount": null,
"name": "quoteState",
"title": "coreshop.order.quote_state",
"tooltip": "",
"mandatory": false,
"noteditable": true,
"index": false,
"locked": false,
"style": "",
"permissions": null,
"datatype": "data",
"relationType": false,
"invisible": false,
"visibleGridView": false,
"visibleSearch": false
},
{
"fieldtype": "input",
"width": null,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -148,11 +148,20 @@ body.pimcore_version_10 .coreshop_nav_icon_customer_to_company_assign_to_existin
background: url(../img/store-values.svg) center center no-repeat !important;
}

.coreshop_rule_icon_condition_saleState {
background: url(../img/sales.svg) center center no-repeat !important;
}

.coreshop_rule_icon_condition_orderState,
.coreshop_rule_icon_condition_orderTransition {
background: url(../img/orders.svg) center center no-repeat !important;
}

.coreshop_rule_icon_condition_quoteState,
.coreshop_rule_icon_condition_quoteTransition {
background: url(../img/quotes.svg) center center no-repeat !important;
}

.coreshop_rule_icon_condition_comment {
background: url(../img/comment.svg) center center no-repeat !important;
}
Expand Down
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
/*
* CoreShop.
*
* This source file is subject to the GNU General Public License version 3 (GPLv3)
* For the full copyright and license information, please view the LICENSE.md and gpl-3.0.txt
* files that are distributed with this source code.
*
* @copyright Copyright (c) CoreShop GmbH (https://www.coreshop.org)
* @license https://www.coreshop.org/license GNU General Public License version 3 (GPLv3)
*
*/

pimcore.registerNS('coreshop.notification.rule.conditions.quoteState');

coreshop.notification.rule.conditions.quoteState = Class.create(coreshop.rules.conditions.abstract, {
type: 'orderStaquoteStatete',

getForm: function () {
this.form = Ext.create('Ext.form.FieldSet', {
items: [
{
xtype: 'combo',
fieldLabel: t('coreshop_transition_direction_state'),
name: 'quoteState',
value: this.data ? this.data.quoteState : [],
width: 250,
store: pimcore.globalmanager.get('coreshop_states_quote'),
triggerAction: 'all',
typeAhead: false,
editable: false,
forceSelection: true,
queryMode: 'local',
displayField: 'label',
valueField: 'state'
}
]
});

return this.form;
}
});
Loading

0 comments on commit a62f777

Please sign in to comment.