<?php
namespace App\Service\DTO;
use App\Service\Helper\RequestHelper;
use Symfony\Component\HttpFoundation\Request;
class OldCRMOrderRequest
{
private int $orderId;
private ?string $managerPhone;
private ?string $firstName;
private ?string $lastName;
private ?string $fatherName;
private ?string $phone;
/**
* @var OldCRMOrderElementRequest[]
*/
private array $elements;
private ?string $deliveryType;
private ?string $town;
private ?int $postcode;
private ?string $street;
private ?string $house;
private ?string $apartment;
private ?float $longitude;
private ?float $latitude;
private ?string $paymentType;
private ?string $transportCompanyName;
private ?string $comment;
private ?int $deprecatedUserId;
public function __construct(Request $request)
{
$this->orderId = $request->request->getInt('orderId');
$this->managerPhone = $request->request->get('managerPhone');
$this->firstName = $request->request->get('firstName');
$this->lastName = $request->request->get('lastName');
$this->fatherName = $request->request->get('fatherName');
$this->phone = $request->request->get('phone');
$this->deliveryType = $request->request->get('deliveryType');
$this->town = $request->request->get('town');
$postcode = $request->request->getInt('postcode');
$this->postcode = $postcode ?: null;
$this->street = $request->request->get('street');
$this->house = $request->request->get('house');
$this->apartment = $request->request->get('apartment');
$this->longitude = $request->request->get('longitude');
$this->latitude = $request->request->get('latitude');
$this->paymentType = $request->request->get('paymentType');
$this->transportCompanyName = $request->request->get('transportCompanyName');
$this->comment = $request->request->get('comment');
$this->deprecatedUserId = $request->request->getInt('user_id');
$elements = [];
foreach ($request->request->get('elements') as $element) {
$elements[] = new OldCRMOrderElementRequest(
(int)$element['id'],
$element['brand'],
$element['article'],
$element['description'],
$element['supplier_alias'],
(int)$element['quantity'],
(int)$element['price'],
(int)$element['searcherUserId'],
);
}
$this->elements = $elements;
}
public function getOrderId(): int
{
return $this->orderId;
}
public function getManagerPhone(): ?string
{
return $this->managerPhone;
}
public function getFirstName(): ?string
{
return $this->firstName;
}
public function getLastName(): ?string
{
return $this->lastName;
}
public function getFatherName(): ?string
{
return $this->fatherName;
}
public function getPhone(): ?string
{
return $this->phone;
}
public function getElements(): array
{
return $this->elements;
}
public function clearElements(): OldCRMOrderRequest
{
$this->elements = [];
return $this;
}
public function getDeliveryType(): ?string
{
return $this->deliveryType;
}
public function getTown(): ?string
{
return $this->town;
}
public function getPostcode(): ?int
{
return $this->postcode;
}
public function getStreet(): ?string
{
return $this->street;
}
public function getHouse(): ?string
{
return $this->house;
}
public function getApartment(): ?string
{
return $this->apartment;
}
public function getLongitude(): ?float
{
return $this->longitude;
}
public function getLatitude(): ?float
{
return $this->latitude;
}
public function getPaymentType(): ?string
{
return $this->paymentType;
}
public function getTransportCompanyName(): ?string
{
return $this->transportCompanyName;
}
public function getComment(): ?string
{
return $this->comment;
}
public function getDeprecatedUserId(): ?int
{
return $this->deprecatedUserId;
}
}