diff --git a/src/Controller/AdminPages/SupplierController.php b/src/Controller/AdminPages/SupplierController.php index 31be2776..82f371a3 100644 --- a/src/Controller/AdminPages/SupplierController.php +++ b/src/Controller/AdminPages/SupplierController.php @@ -37,6 +37,7 @@ use App\Entity\Attachments\AttachmentType; use App\Entity\Parts\Supplier; use App\Form\AdminPages\BaseEntityAdminForm; use App\Form\AdminPages\CompanyForm; +use App\Form\AdminPages\SupplierForm; use App\Services\EntityExporter; use App\Services\EntityImporter; use App\Services\StructuralElementRecursionHelper; @@ -55,7 +56,7 @@ class SupplierController extends BaseAdminController protected $entity_class = Supplier::class; protected $twig_template = 'AdminPages/SupplierAdmin.html.twig'; - protected $form_class = CompanyForm::class; + protected $form_class = SupplierForm::class; protected $route_base = "supplier"; /** diff --git a/src/Entity/Parts/Supplier.php b/src/Entity/Parts/Supplier.php index cbd8eefe..2a59fea0 100644 --- a/src/Entity/Parts/Supplier.php +++ b/src/Entity/Parts/Supplier.php @@ -102,7 +102,7 @@ class Supplier extends Company /** * @var float|null The shipping costs that have to be paid, when ordering via this supplier. - * @ORM\Column(name="shipping_costs", nullable=true, type="decimal") + * @ORM\Column(name="shipping_costs", nullable=true, type="decimal", precision=11, scale=5) * @Assert\PositiveOrZero() */ protected $shipping_costs; @@ -126,18 +126,19 @@ class Supplier extends Company } /** - * @return ?float + * @return ?string */ - public function getShippingCosts() : ?float + public function getShippingCosts() : ?string { + dump($this); return $this->shipping_costs; } /** - * @param ?float $shipping_costs + * @param ?string $shipping_costs * @return Supplier */ - public function setShippingCosts(?float $shipping_costs) : Supplier + public function setShippingCosts(?string $shipping_costs) : Supplier { $this->shipping_costs = $shipping_costs; return $this; diff --git a/src/Form/AdminPages/SupplierForm.php b/src/Form/AdminPages/SupplierForm.php new file mode 100644 index 00000000..07202dca --- /dev/null +++ b/src/Form/AdminPages/SupplierForm.php @@ -0,0 +1,102 @@ +getID() === null; + + $builder->add('address', TextareaType::class, ['label' => 'company.address.label', + 'disabled' => !$this->security->isGranted($is_new ? 'create' : 'edit', $entity), + 'attr' => ['placeholder' => 'company.address.placeholder'], 'required' => false, + 'empty_data' => '' + ]); + + $builder->add('phone_number', TelType::class, ['label' => 'company.phone_number.label', + 'disabled' => !$this->security->isGranted($is_new ? 'create' : 'edit', $entity), + 'attr' => ['placeholder' => 'company.phone_number.placeholder'], 'required' => false, + 'empty_data' => '' + ]); + + $builder->add('fax_number', TelType::class, ['label' => 'company.fax_number.label', + 'disabled' => !$this->security->isGranted($is_new ? 'create' : 'edit', $entity), + 'attr' => ['placeholder' => 'company.fax_number.placeholder'], 'required' => false, + 'empty_data' => '' + ]); + + $builder->add('email_address', EmailType::class, ['label' => 'company.email.label', + 'disabled' => !$this->security->isGranted($is_new ? 'create' : 'edit', $entity), + 'attr' => ['placeholder' => 'company.email.placeholder'], 'required' => false, + 'empty_data' => '' + ]); + + $builder->add('website', UrlType::class, ['label' => 'company.website.label', + 'disabled' => !$this->security->isGranted($is_new ? 'create' : 'edit', $entity), + 'attr' => ['placeholder' => 'company.website.placeholder'], 'required' => false, + 'empty_data' => '' + ]); + + $builder->add('auto_product_url', UrlType::class, ['label' => 'company.auto_product_url.label', + 'disabled' => !$this->security->isGranted($is_new ? 'create' : 'edit', $entity), + 'attr' => ['placeholder' => 'company.auto_product_url.placeholder'], 'required' => false, + 'empty_data' => '' + ]); + + $builder->add('default_currency', StructuralEntityType::class, ['class' => Currency::class, + 'required' => false, 'label' => 'supplier.default_currency.label', 'disable_not_selectable' => true, + 'disabled' => !$this->security->isGranted($is_new ? 'create' : 'move', $entity), ]); + + $builder->add('shipping_costs', MoneyType::class, [ 'required' => false, + 'currency' => $this->params->get('default_currency'), 'scale' => 3, + 'label' => 'supplier.shipping_costs.label', + 'disabled' => !$this->security->isGranted($is_new ? 'create' : 'move', $entity) + ]); + } +} \ No newline at end of file diff --git a/src/Migrations/Version20190812154222.php b/src/Migrations/Version20190812154222.php index 1337bd4a..5cc179f0 100644 --- a/src/Migrations/Version20190812154222.php +++ b/src/Migrations/Version20190812154222.php @@ -51,7 +51,7 @@ final class Version20190812154222 extends AbstractMigration $this->addSql('ALTER TABLE storelocations ADD storage_type_id INT DEFAULT NULL, ADD only_single_part TINYINT(1) NOT NULL, ADD limit_to_existing_parts TINYINT(1) NOT NULL, ADD not_selectable TINYINT(1) NOT NULL, CHANGE parent_id parent_id INT DEFAULT NULL, CHANGE datetime_added datetime_added DATETIME NOT NULL, CHANGE last_modified last_modified DATETIME NOT NULL'); $this->addSql('ALTER TABLE storelocations ADD CONSTRAINT FK_7517020B270BFF1 FOREIGN KEY (storage_type_id) REFERENCES `measurement_units` (id)'); $this->addSql('CREATE INDEX IDX_7517020B270BFF1 ON storelocations (storage_type_id)'); - $this->addSql('ALTER TABLE suppliers ADD default_currency_id INT DEFAULT NULL, ADD shipping_costs NUMERIC(10, 0) DEFAULT NULL, ADD not_selectable TINYINT(1) NOT NULL, CHANGE parent_id parent_id INT DEFAULT NULL, CHANGE datetime_added datetime_added DATETIME NOT NULL, CHANGE last_modified last_modified DATETIME NOT NULL'); + $this->addSql('ALTER TABLE suppliers ADD default_currency_id INT DEFAULT NULL, ADD shipping_costs NUMERIC(11, 5) DEFAULT NULL, ADD not_selectable TINYINT(1) NOT NULL, CHANGE parent_id parent_id INT DEFAULT NULL, CHANGE datetime_added datetime_added DATETIME NOT NULL, CHANGE last_modified last_modified DATETIME NOT NULL'); $this->addSql('ALTER TABLE suppliers ADD CONSTRAINT FK_AC28B95CECD792C0 FOREIGN KEY (default_currency_id) REFERENCES currencies (id)'); $this->addSql('CREATE INDEX IDX_AC28B95CECD792C0 ON suppliers (default_currency_id)'); $this->addSql('ALTER TABLE parts DROP FOREIGN KEY parts_id_storelocation_fk'); diff --git a/templates/AdminPages/CompanyAdminBase.html.twig b/templates/AdminPages/CompanyAdminBase.html.twig index 03547f9c..e809d509 100644 --- a/templates/AdminPages/CompanyAdminBase.html.twig +++ b/templates/AdminPages/CompanyAdminBase.html.twig @@ -12,11 +12,11 @@ {% block comment %}{% endblock %} {% block additional_pills %} -