-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[shopsys] added product inquiries (#3465)
- Loading branch information
Showing
51 changed files
with
1,991 additions
and
45 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,158 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace Shopsys\FrameworkBundle\Component\Money; | ||
|
||
class HiddenMoney extends Money | ||
{ | ||
public const string HIDDEN_FORMAT = '***'; | ||
|
||
public function __construct() | ||
{ | ||
} | ||
|
||
/** | ||
* {@inheritdoc} | ||
*/ | ||
public static function create($value): Money | ||
{ | ||
return new self(); | ||
} | ||
|
||
/** | ||
* {@inheritdoc} | ||
*/ | ||
public static function createFromFloat(float $float, int $scale): Money | ||
{ | ||
return new self(); | ||
} | ||
|
||
/** | ||
* {@inheritdoc} | ||
*/ | ||
public static function zero(): Money | ||
{ | ||
return new self(); | ||
} | ||
|
||
/** | ||
* {@inheritdoc} | ||
*/ | ||
public function getAmount(): string | ||
{ | ||
return self::HIDDEN_FORMAT; | ||
} | ||
|
||
/** | ||
* {@inheritdoc} | ||
*/ | ||
public function add(Money $money): Money | ||
{ | ||
return $this; | ||
} | ||
|
||
/** | ||
* {@inheritdoc} | ||
*/ | ||
public function subtract(Money $money): Money | ||
{ | ||
return $this; | ||
} | ||
|
||
/** | ||
* {@inheritdoc} | ||
*/ | ||
public function multiply($multiplier): Money | ||
{ | ||
return $this; | ||
} | ||
|
||
/** | ||
* {@inheritdoc} | ||
*/ | ||
public function divide($divisor, int $scale): Money | ||
{ | ||
return $this; | ||
} | ||
|
||
/** | ||
* {@inheritdoc} | ||
*/ | ||
public function round(int $scale): Money | ||
{ | ||
return $this; | ||
} | ||
|
||
/** | ||
* {@inheritdoc} | ||
*/ | ||
public function equals(Money $money): bool | ||
{ | ||
return false; | ||
} | ||
|
||
/** | ||
* {@inheritdoc} | ||
*/ | ||
public function compare(Money $money): int | ||
{ | ||
return -1; | ||
} | ||
|
||
/** | ||
* {@inheritdoc} | ||
*/ | ||
public function isGreaterThan(Money $money): bool | ||
{ | ||
return false; | ||
} | ||
|
||
/** | ||
* {@inheritdoc} | ||
*/ | ||
public function isGreaterThanOrEqualTo(Money $money): bool | ||
{ | ||
return false; | ||
} | ||
|
||
/** | ||
* {@inheritdoc} | ||
*/ | ||
public function isLessThan(Money $money): bool | ||
{ | ||
return false; | ||
} | ||
|
||
/** | ||
* {@inheritdoc} | ||
*/ | ||
public function isLessThanOrEqualTo(Money $money): bool | ||
{ | ||
return false; | ||
} | ||
|
||
/** | ||
* {@inheritdoc} | ||
*/ | ||
public function isNegative(): bool | ||
{ | ||
return false; | ||
} | ||
|
||
/** | ||
* {@inheritdoc} | ||
*/ | ||
public function isPositive(): bool | ||
{ | ||
return false; | ||
} | ||
|
||
/** | ||
* {@inheritdoc} | ||
*/ | ||
public function isZero(): bool | ||
{ | ||
return false; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,78 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace Shopsys\FrameworkBundle\Controller\Admin; | ||
|
||
use Shopsys\FrameworkBundle\Component\Domain\AdminDomainFilterTabsFacade; | ||
use Shopsys\FrameworkBundle\Form\Admin\QuickSearch\QuickSearchFormData; | ||
use Shopsys\FrameworkBundle\Form\Admin\QuickSearch\QuickSearchFormType; | ||
use Shopsys\FrameworkBundle\Model\Inquiry\InquiryFacade; | ||
use Shopsys\FrameworkBundle\Model\Inquiry\InquiryGridFactory; | ||
use Shopsys\FrameworkBundle\Model\Localization\Localization; | ||
use Symfony\Component\HttpFoundation\Request; | ||
use Symfony\Component\HttpFoundation\Response; | ||
use Symfony\Component\Routing\Annotation\Route; | ||
|
||
class InquiryController extends AdminBaseController | ||
{ | ||
/** | ||
* @param \Shopsys\FrameworkBundle\Model\Inquiry\InquiryGridFactory $inquiryGridFactory | ||
* @param \Shopsys\FrameworkBundle\Model\Inquiry\InquiryFacade $inquiryFacade | ||
* @param \Shopsys\FrameworkBundle\Model\Localization\Localization $localization | ||
* @param \Shopsys\FrameworkBundle\Component\Domain\AdminDomainFilterTabsFacade $adminDomainFilterTabsFacade | ||
*/ | ||
public function __construct( | ||
protected readonly InquiryGridFactory $inquiryGridFactory, | ||
protected readonly InquiryFacade $inquiryFacade, | ||
protected readonly Localization $localization, | ||
protected readonly AdminDomainFilterTabsFacade $adminDomainFilterTabsFacade, | ||
) { | ||
} | ||
|
||
/** | ||
* @param \Symfony\Component\HttpFoundation\Request $request | ||
* @return \Symfony\Component\HttpFoundation\Response | ||
*/ | ||
#[Route(path: '/inquiry/list/')] | ||
public function listAction(Request $request): Response | ||
{ | ||
$domainFilterNamespace = 'inquiries'; | ||
|
||
$quickSearchForm = $this->createForm(QuickSearchFormType::class, new QuickSearchFormData()); | ||
$quickSearchForm->handleRequest($request); | ||
|
||
$queryBuilder = $this->inquiryFacade->getInquiryListQueryBuilderByQuickSearchData( | ||
$quickSearchForm->getData(), | ||
$this->localization->getAdminLocale(), | ||
); | ||
|
||
$selectedDomainId = $this->adminDomainFilterTabsFacade->getSelectedDomainId($domainFilterNamespace); | ||
|
||
if ($selectedDomainId !== null) { | ||
$queryBuilder | ||
->andWhere('i.domainId = :selectedDomainId') | ||
->setParameter('selectedDomainId', $selectedDomainId); | ||
} | ||
|
||
return $this->render('@ShopsysFramework/Admin/Content/Inquiry/list.html.twig', [ | ||
'gridView' => $this->inquiryGridFactory->createView($queryBuilder, $this->getCurrentAdministrator()), | ||
'domainFilterNamespace' => $domainFilterNamespace, | ||
'quickSearchForm' => $quickSearchForm->createView(), | ||
]); | ||
} | ||
|
||
/** | ||
* @param int $id | ||
* @return \Symfony\Component\HttpFoundation\Response | ||
*/ | ||
#[Route(path: '/inquiry/detail/{id}', requirements: ['id' => '\d+'])] | ||
public function detailAction(int $id): Response | ||
{ | ||
$inquiry = $this->inquiryFacade->getById($id); | ||
|
||
return $this->render('@ShopsysFramework/Admin/Content/Inquiry/detail.html.twig', [ | ||
'inquiry' => $inquiry, | ||
]); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace Shopsys\FrameworkBundle\Migrations; | ||
|
||
use Doctrine\DBAL\Schema\Schema; | ||
use Shopsys\MigrationBundle\Component\Doctrine\Migrations\AbstractMigration; | ||
|
||
class Version20240924082209 extends AbstractMigration | ||
{ | ||
/** | ||
* @param \Doctrine\DBAL\Schema\Schema $schema | ||
*/ | ||
public function up(Schema $schema): void | ||
{ | ||
$this->sql('ALTER TABLE products ADD product_type VARCHAR(32) DEFAULT NULL'); | ||
$this->sql('UPDATE products SET product_type = \'basic\''); | ||
$this->sql('ALTER TABLE products ALTER product_type SET NOT NULL'); | ||
} | ||
|
||
/** | ||
* @param \Doctrine\DBAL\Schema\Schema $schema | ||
*/ | ||
public function down(Schema $schema): void | ||
{ | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,62 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace Shopsys\FrameworkBundle\Migrations; | ||
|
||
use Doctrine\DBAL\Schema\Schema; | ||
use Shopsys\MigrationBundle\Component\Doctrine\Migrations\AbstractMigration; | ||
|
||
class Version20240926162253 extends AbstractMigration | ||
{ | ||
/** | ||
* @param \Doctrine\DBAL\Schema\Schema $schema | ||
*/ | ||
public function up(Schema $schema): void | ||
{ | ||
$this->sql(' | ||
CREATE TABLE inquiries ( | ||
id SERIAL NOT NULL, | ||
domain_id INT NOT NULL, | ||
product_id INT DEFAULT NULL, | ||
product_catnum VARCHAR(100) NOT NULL, | ||
first_name VARCHAR(100) NOT NULL, | ||
last_name VARCHAR(100) NOT NULL, | ||
email VARCHAR(255) NOT NULL, | ||
telephone VARCHAR(30) NOT NULL, | ||
company_name VARCHAR(100) DEFAULT NULL, | ||
company_number VARCHAR(50) DEFAULT NULL, | ||
company_tax_number VARCHAR(50) DEFAULT NULL, | ||
note TEXT DEFAULT NULL, | ||
created_at TIMESTAMP(0) WITHOUT TIME ZONE NOT NULL, | ||
customer_user_id INT DEFAULT NULL, | ||
PRIMARY KEY(id) | ||
)'); | ||
$this->sql('CREATE INDEX IDX_1CCE4D54584665A ON inquiries (product_id)'); | ||
$this->sql(' | ||
ALTER TABLE | ||
inquiries | ||
ADD | ||
CONSTRAINT FK_1CCE4D54584665A FOREIGN KEY (product_id) REFERENCES products (id) ON DELETE | ||
SET | ||
NULL NOT DEFERRABLE INITIALLY IMMEDIATE'); | ||
|
||
$this->sql('COMMENT ON COLUMN inquiries.created_at IS \'(DC2Type:datetime_immutable)\''); | ||
|
||
$this->sql(' | ||
ALTER TABLE | ||
inquiries | ||
ADD | ||
CONSTRAINT FK_1CCE4D5BBB3772B FOREIGN KEY (customer_user_id) REFERENCES customer_users (id) ON DELETE | ||
SET | ||
NULL NOT DEFERRABLE INITIALLY IMMEDIATE'); | ||
$this->sql('CREATE INDEX IDX_1CCE4D5BBB3772B ON inquiries (customer_user_id)'); | ||
} | ||
|
||
/** | ||
* @param \Doctrine\DBAL\Schema\Schema $schema | ||
*/ | ||
public function down(Schema $schema): void | ||
{ | ||
} | ||
} |
Oops, something went wrong.