diff --git a/hesabixCore/src/Controller/PrintersController.php b/hesabixCore/src/Controller/PrintersController.php index e8b4aaa..6741f2d 100644 --- a/hesabixCore/src/Controller/PrintersController.php +++ b/hesabixCore/src/Controller/PrintersController.php @@ -4,7 +4,9 @@ namespace App\Controller; use App\Entity\Printer; use App\Entity\PrintItem; +use App\Entity\PrintOptions; use App\Service\Access; +use App\Service\Explore; use App\Service\Extractor; use App\Service\Log; use App\Service\Provider; @@ -28,7 +30,60 @@ class PrintersController extends AbstractController return substr(str_shuffle(str_repeat($x = '23456789ABCDEFGHJKLMNPQRSTUVWXYZ', ceil($length / strlen($x)))), 1, $length); } + #[Route('/api/printers/options/info', name: 'app_printers_options_info')] + public function app_printers_options_info(Provider $provider, Request $request, Access $access, Log $log, EntityManagerInterface $entityManager): JsonResponse + { + $acc = $access->hasRole('settings'); + if (!$acc) + throw $this->createAccessDeniedException(); + $settings = $entityManager->getRepository(PrintOptions::class)->findOneBy(['bid' => $acc['bid']]); + if (!$settings) { + $settings = new PrintOptions; + $settings->setBid($acc['bid']); + $entityManager->persist($settings); + $entityManager->flush(); + } + $temp = []; + $temp['sell']['id'] = $settings->getId(); + $temp['sell']['bidInfo'] = $settings->isSellBidInfo(); + $temp['sell']['taxInfo'] = $settings->isSellTaxInfo(); + $temp['sell']['discountInfo'] = $settings->isSellDiscountInfo(); + $temp['sell']['note'] = $settings->isSellNote(); + $temp['sell']['noteString'] = $settings->getSellNoteString(); + $temp['sell']['pays'] = $settings->isSellPays(); + return $this->json($temp); + } + + #[Route('/api/printers/options/save', name: 'app_printers_options_save')] + public function app_printers_options_save(Extractor $extractor, Provider $provider, Request $request, Access $access, Log $log, EntityManagerInterface $entityManager): JsonResponse + { + $acc = $access->hasRole('settings'); + if (!$acc) + throw $this->createAccessDeniedException(); + $settings = $entityManager->getRepository(PrintOptions::class)->findOneBy(['bid' => $acc['bid']]); + if (!$settings) { + $settings = new PrintOptions; + $settings->setBid($acc['bid']); + $entityManager->persist($settings); + $entityManager->flush(); + } + $params = []; + if ($content = $request->getContent()) { + $params = json_decode($content, true); + } + + $settings->setSellBidInfo($params['sell']['bidInfo']); + $settings->setSellTaxInfo($params['sell']['taxInfo']); + $settings->setSellDiscountInfo($params['sell']['discountInfo']); + $settings->setSellNote($params['sell']['note']); + $settings->setSellNoteString($params['sell']['noteString']); + $settings->setSellPays($params['sell']['pays']); + $entityManager->persist($settings); + $entityManager->flush(); + $log->insert('تنظیمات چاپ', 'تنظیمات چاپ به روز رسانی شد.', $this->getUser(), $acc['bid']->getId()); + return $this->json($extractor->operationSuccess()); + } #[Route('/api/printers/list', name: 'app_printers_list')] public function app_printers_list(Provider $provider, Request $request, Access $access, Log $log, EntityManagerInterface $entityManager): JsonResponse { diff --git a/hesabixCore/src/Controller/SellController.php b/hesabixCore/src/Controller/SellController.php index 32169ff..ed4dc0d 100644 --- a/hesabixCore/src/Controller/SellController.php +++ b/hesabixCore/src/Controller/SellController.php @@ -13,6 +13,7 @@ use App\Entity\HesabdariRow; use App\Entity\HesabdariTable; use App\Entity\InvoiceType; use App\Entity\Person; +use App\Entity\PrintOptions; use App\Entity\StoreroomTicket; use App\Service\Printers; use Doctrine\ORM\EntityManagerInterface; @@ -408,6 +409,33 @@ class SellController extends AbstractController } $pdfPid = 0; if ($params['pdf']) { + $printOptions = [ + 'bidInfo' => true, + 'pays' =>true, + 'taxInfo' =>true, + 'discountInfo' =>true, + 'note' =>true + ]; + if(array_key_exists('printOptions',$params)){ + if(array_key_exists('bidInfo',$params['printOptions'])){ + $printOptions['bidInfo'] = $params['printOptions']['bidInfo']; + } + if(array_key_exists('pays',$params['printOptions'])){ + $printOptions['pays'] = $params['printOptions']['pays']; + } + if(array_key_exists('taxInfo',$params['printOptions'])){ + $printOptions['taxInfo'] = $params['printOptions']['taxInfo']; + } + if(array_key_exists('discountInfo',$params['printOptions'])){ + $printOptions['discountInfo'] = $params['printOptions']['discountInfo']; + } + if(array_key_exists('note',$params['printOptions'])){ + $printOptions['note'] = $params['printOptions']['note']; + } + } + $note = ''; + $printSettings = $entityManager->getRepository(PrintOptions::class)->findOneBy(['bid'=>$acc['bid']]); + if($printSettings){$note = $printSettings->getSellNoteString();} $pdfPid = $provider->createPrint( $acc['bid'], $this->getUser(), @@ -418,7 +446,9 @@ class SellController extends AbstractController 'person' => $person, 'printInvoice' => $params['printers'], 'discount' => $discount, - 'transfer' => $transfer + 'transfer' => $transfer, + 'printOptions'=> $printOptions, + 'note'=> $note ]), false ); diff --git a/hesabixCore/src/Entity/Business.php b/hesabixCore/src/Entity/Business.php index 462ce60..e50e9bf 100644 --- a/hesabixCore/src/Entity/Business.php +++ b/hesabixCore/src/Entity/Business.php @@ -231,6 +231,9 @@ class Business #[ORM\OneToMany(mappedBy: 'bid', targetEntity: PriceList::class, orphanRemoval: true)] private Collection $priceLists; + #[ORM\OneToMany(mappedBy: 'bid', targetEntity: PrintOptions::class, orphanRemoval: true)] + private Collection $printOptions; + public function __construct() { $this->logs = new ArrayCollection(); @@ -264,6 +267,7 @@ class Business $this->printTemplates = new ArrayCollection(); $this->notes = new ArrayCollection(); $this->priceLists = new ArrayCollection(); + $this->printOptions = new ArrayCollection(); } public function getId(): ?int @@ -1656,4 +1660,34 @@ class Business return $this; } + + /** + * @return Collection + */ + public function getPrintOptions(): Collection + { + return $this->printOptions; + } + + public function addPrintOption(PrintOptions $printOption): static + { + if (!$this->printOptions->contains($printOption)) { + $this->printOptions->add($printOption); + $printOption->setBid($this); + } + + return $this; + } + + public function removePrintOption(PrintOptions $printOption): static + { + if ($this->printOptions->removeElement($printOption)) { + // set the owning side to null (unless already changed) + if ($printOption->getBid() === $this) { + $printOption->setBid(null); + } + } + + return $this; + } } diff --git a/hesabixCore/src/Entity/PrintOptions.php b/hesabixCore/src/Entity/PrintOptions.php new file mode 100644 index 0000000..74a6e6d --- /dev/null +++ b/hesabixCore/src/Entity/PrintOptions.php @@ -0,0 +1,127 @@ +id; + } + + public function getBid(): ?Business + { + return $this->bid; + } + + public function setBid(?Business $bid): static + { + $this->bid = $bid; + + return $this; + } + + public function isSellBidInfo(): ?bool + { + return $this->sellBidInfo; + } + + public function setSellBidInfo(?bool $sellBidInfo): static + { + $this->sellBidInfo = $sellBidInfo; + + return $this; + } + + public function isSellNote(): ?bool + { + return $this->sellNote; + } + + public function setSellNote(?bool $sellNote): static + { + $this->sellNote = $sellNote; + + return $this; + } + + public function isSellTaxInfo(): ?bool + { + return $this->sellTaxInfo; + } + + public function setSellTaxInfo(?bool $sellTaxInfo): static + { + $this->sellTaxInfo = $sellTaxInfo; + + return $this; + } + + public function isSellDiscountInfo(): ?bool + { + return $this->sellDiscountInfo; + } + + public function setSellDiscountInfo(?bool $sellDiscountInfo): static + { + $this->sellDiscountInfo = $sellDiscountInfo; + + return $this; + } + + public function isSellPays(): ?bool + { + return $this->sellPays; + } + + public function setSellPays(?bool $sellPays): static + { + $this->sellPays = $sellPays; + + return $this; + } + + public function getSellNoteString(): ?string + { + return $this->sellNoteString; + } + + public function setSellNoteString(?string $sellNoteString): static + { + $this->sellNoteString = $sellNoteString; + + return $this; + } +} diff --git a/hesabixCore/src/Repository/PrintOptionsRepository.php b/hesabixCore/src/Repository/PrintOptionsRepository.php new file mode 100644 index 0000000..1abcd00 --- /dev/null +++ b/hesabixCore/src/Repository/PrintOptionsRepository.php @@ -0,0 +1,48 @@ + + * + * @method PrintOptions|null find($id, $lockMode = null, $lockVersion = null) + * @method PrintOptions|null findOneBy(array $criteria, array $orderBy = null) + * @method PrintOptions[] findAll() + * @method PrintOptions[] findBy(array $criteria, array $orderBy = null, $limit = null, $offset = null) + */ +class PrintOptionsRepository extends ServiceEntityRepository +{ + public function __construct(ManagerRegistry $registry) + { + parent::__construct($registry, PrintOptions::class); + } + +// /** +// * @return PrintOptions[] Returns an array of PrintOptions objects +// */ +// public function findByExampleField($value): array +// { +// return $this->createQueryBuilder('p') +// ->andWhere('p.exampleField = :val') +// ->setParameter('val', $value) +// ->orderBy('p.id', 'ASC') +// ->setMaxResults(10) +// ->getQuery() +// ->getResult() +// ; +// } + +// public function findOneBySomeField($value): ?PrintOptions +// { +// return $this->createQueryBuilder('p') +// ->andWhere('p.exampleField = :val') +// ->setParameter('val', $value) +// ->getQuery() +// ->getOneOrNullResult() +// ; +// } +} diff --git a/hesabixCore/templates/pdf/printers/sell.html.twig b/hesabixCore/templates/pdf/printers/sell.html.twig index 5450ab2..2801518 100644 --- a/hesabixCore/templates/pdf/printers/sell.html.twig +++ b/hesabixCore/templates/pdf/printers/sell.html.twig @@ -14,7 +14,7 @@ border: 1px solid black; } .item { - height: 40px; + height: 30px; } @@ -45,69 +45,75 @@ -
-
- فروشنده -
- - - - - - - - - - - - - - -
-

- نام: - - {{ bid.legalName }} -

-
-

- شناسه ملی: - - {{ bid.shenasemeli }} -

-
-

- شماره ثبت: - - {{ bid.shomaresabt }} -

-
-

- شماره اقتصادی: - - {{ bid.codeeghtesadi }} -

-
-

- تلفن / نمابر: - {{ bid.tel }} -

-
-

- کد پستی: - {{ bid.postalcode }} -

-
-

- آدرس: - - استان - {{ bid.ostan }}، شهر - {{ bid.shahrestan }}، - {{ bid.address }} -

-
-
+{% if printOptions.bidInfo %} + +
+
+ فروشنده +
+ + + + + + + + + + + + + + +
+

+ نام: + + {{ bid.legalName }} +

+
+

+ + شناسه ملی: + + {{ bid.shenasemeli }} +

+
+

+ شماره ثبت: + + {{ bid.shomaresabt }} +

+
+

+ شماره اقتصادی: + + {{ bid.codeeghtesadi }} +

+
+

+ تلفن / نمابر: + {{ bid.tel }} +

+
+

+ کد پستی: + {{ bid.postalcode }} +

+
+

+ آدرس: + + استان + {{ bid.ostan }}، شهر + {{ bid.shahrestan }}، + {{ bid.address }} +

+
+
+ +{% endif %} +
خریدار @@ -180,8 +186,12 @@ شرح تعداد / مقدار مبلغ واحد - تخفیف - مالیات + {% if printOptions.discountInfo %} + تخفیف + {% endif %} + {% if printOptions.taxInfo %} + مالیات + {% endif %} مبلغ کل @@ -204,8 +214,12 @@ {{ item.commodity.unit.name }} {{ ((item.bs - item.tax + item.discount) / item.commdityCount) | number_format }} - {{ item.discount | number_format }} - {{ item.tax | number_format}} + {% if printOptions.discountInfo %} + {{ item.discount | number_format }} + {% endif %} + {% if printOptions.taxInfo %} + {{ item.tax | number_format}} + {% endif %} {{ item.bs| number_format }} {% endif %} @@ -217,81 +231,63 @@ - + - - - - - - -
+ +

+ توضیحات: + {{doc.des}} +
+ {% if (doc.relatedDocs | length != 0) and (printOptions.pays == true) %} +

+ پرداخت‌ها: +

+
    + {% for item in doc.relatedDocs%} +
  • + {{item.date}} - {{ item.amount | number_format }} - {{ item.des }} +
  • + {% endfor %} +
+ {% if printOptions.note == true %} +

+ یاداشت: +

+
    +
  • + {{note}} +
  • +
+ {% endif %} + + {% endif %} + +

تخفیف: {{discount | number_format}}

-

مالیات: {{taxAll | number_format}}

-

حمل و نقل: {{transfer | number_format}}

-

مبلغ کل بدون تخفیف: {{ (doc.amount + discount) | number_format}}

-

جمع کل قابل پرداخت: - {{doc.amount | number_format}} -

-
-

- توضیحات: - {{doc.des}} + {{ doc.amount | number_format }}

-
- {% if doc.relatedDocs | length != 0 %} -

- پرداخت‌ها: -

-
- - - - - - - - - - - - {% set rowIndex = 0 %} - {% for item in doc.relatedDocs%} - {% set rowIndex = rowIndex + 1 %} - - - - - - - {% endfor %} - - -
ردیفتاریخمبلغشرح
{{rowIndex}}{{item.date}}{{ item.amount | number_format }}{{ item.des }}
-
- {% endif %} - -
+
+