almost finish fast sell
This commit is contained in:
parent
37b6fd077f
commit
b8ea6f054e
|
@ -70,6 +70,10 @@ class CommodityController extends AbstractController
|
|||
$temp['minOrderCount'] = $item->getMinOrderCount();
|
||||
$temp['dayLoading'] = $item->getDayLoading();
|
||||
$temp['orderPoint'] = $item->getOrderPoint();
|
||||
$temp['unitData'] = [
|
||||
'name' => $item->getUnit()->getName(),
|
||||
'floatNumber' => $item->getUnit()->getFloatNumber(),
|
||||
];
|
||||
//calculate count
|
||||
if ($item->isKhadamat()) {
|
||||
$temp['count'] = 0;
|
||||
|
|
|
@ -67,7 +67,13 @@ class GeneralController extends AbstractController
|
|||
$print = $entityManager->getRepository(PrinterQueue::class)->findOneBy(['pid'=>$id]);
|
||||
if(!$print)
|
||||
throw $this->createNotFoundException();
|
||||
if($print->isPosprint()){
|
||||
$pdfMGR->streamTwig2PDFInvoiceType($print);
|
||||
}
|
||||
else{
|
||||
$pdfMGR->streamTwig2PDF($print);
|
||||
}
|
||||
|
||||
return new Response('');
|
||||
}
|
||||
}
|
||||
|
|
|
@ -106,7 +106,7 @@ class PersonsController extends AbstractController
|
|||
if ($person)
|
||||
return $this->json(['result' => 2]);
|
||||
$person = new Person();
|
||||
$person->setCode($provider->getAccountingCode($request->headers->get('activeBid'), 'person'));
|
||||
$person->setCode($provider->getAccountingCode($acc['bid'], 'person'));
|
||||
} else {
|
||||
$person = $entityManager->getRepository(Person::class)->findOneBy([
|
||||
'bid' => $acc['bid'],
|
||||
|
@ -208,7 +208,7 @@ class PersonsController extends AbstractController
|
|||
}
|
||||
}
|
||||
$entityManager->flush();
|
||||
$log->insert('اشخاص', 'شخص با نام مستعار ' . $params['nikename'] . ' افزوده/ویرایش شد.', $this->getUser(), $request->headers->get('activeBid'));
|
||||
$log->insert('اشخاص', 'شخص با نام مستعار ' . $params['nikename'] . ' افزوده/ویرایش شد.', $this->getUser(), $acc['bid']);
|
||||
return $this->json(['result' => 1]);
|
||||
}
|
||||
|
||||
|
@ -254,7 +254,8 @@ class PersonsController extends AbstractController
|
|||
#[Route('/api/person/list/limit', name: 'app_persons_list_limit')]
|
||||
public function app_persons_list_limit(Provider $provider, Request $request, Access $access, Log $log, EntityManagerInterface $entityManager): JsonResponse
|
||||
{
|
||||
if (!$access->hasRole('person'))
|
||||
$acc = $access->hasRole('person');
|
||||
if (!$acc)
|
||||
throw $this->createAccessDeniedException();
|
||||
$params = [];
|
||||
if ($content = $request->getContent()) {
|
||||
|
@ -262,12 +263,12 @@ class PersonsController extends AbstractController
|
|||
}
|
||||
if (array_key_exists('speedAccess', $params)) {
|
||||
$persons = $entityManager->getRepository(Person::class)->findBy([
|
||||
'bid' => $request->headers->get('activeBid'),
|
||||
'bid' => $acc['bid'],
|
||||
'speedAccess' => true
|
||||
]);
|
||||
} else {
|
||||
$persons = $entityManager->getRepository(Person::class)->findBy([
|
||||
'bid' => $request->headers->get('activeBid')
|
||||
'bid' => $acc['bid']
|
||||
]);
|
||||
}
|
||||
$response = [];
|
||||
|
@ -298,7 +299,8 @@ class PersonsController extends AbstractController
|
|||
#[Route('/api/person/list', name: 'app_persons_list')]
|
||||
public function app_persons_list(Provider $provider, Request $request, Access $access, Log $log, EntityManagerInterface $entityManager): Response
|
||||
{
|
||||
if (!$access->hasRole('person'))
|
||||
$acc = $access->hasRole('person');
|
||||
if(!$acc)
|
||||
throw $this->createAccessDeniedException();
|
||||
$params = [];
|
||||
if ($content = $request->getContent()) {
|
||||
|
@ -306,12 +308,12 @@ class PersonsController extends AbstractController
|
|||
}
|
||||
if (array_key_exists('speedAccess', $params)) {
|
||||
$persons = $entityManager->getRepository(Person::class)->findBy([
|
||||
'bid' => $request->headers->get('activeBid'),
|
||||
'bid' => $acc['bid'],
|
||||
'speedAccess' => true
|
||||
]);
|
||||
} else {
|
||||
$persons = $entityManager->getRepository(Person::class)->findBy([
|
||||
'bid' => $request->headers->get('activeBid')
|
||||
'bid' => $acc['bid']
|
||||
]);
|
||||
}
|
||||
$response = Explore::ExplorePersons($persons, $entityManager->getRepository(PersonType::class)->findAll());
|
||||
|
@ -335,7 +337,8 @@ class PersonsController extends AbstractController
|
|||
#[Route('/api/person/list/debtors/{amount}', name: 'app_persons_list_debtors')]
|
||||
public function app_persons_list_debtors(string $amount, Provider $provider, Request $request, Access $access, Log $log, EntityManagerInterface $entityManager): JsonResponse
|
||||
{
|
||||
if (!$access->hasRole('person'))
|
||||
$acc = $access->hasRole('person');
|
||||
if (!$acc)
|
||||
throw $this->createAccessDeniedException();
|
||||
$params = [];
|
||||
if ($content = $request->getContent()) {
|
||||
|
@ -343,12 +346,12 @@ class PersonsController extends AbstractController
|
|||
}
|
||||
if (array_key_exists('speedAccess', $params)) {
|
||||
$persons = $entityManager->getRepository(Person::class)->findBy([
|
||||
'bid' => $request->headers->get('activeBid'),
|
||||
'bid' => $acc['bid'],
|
||||
'speedAccess' => true
|
||||
]);
|
||||
} else {
|
||||
$persons = $entityManager->getRepository(Person::class)->findBy([
|
||||
'bid' => $request->headers->get('activeBid')
|
||||
'bid' => $acc['bid']
|
||||
]);
|
||||
}
|
||||
|
||||
|
@ -383,7 +386,7 @@ class PersonsController extends AbstractController
|
|||
throw $this->createAccessDeniedException();
|
||||
|
||||
$persons = $entityManager->getRepository(Person::class)->findBy([
|
||||
'bid' => $request->headers->get('activeBid')
|
||||
'bid' => $acc['bid']
|
||||
]);
|
||||
$response = $provider->ArrayEntity2Array($persons, 0);
|
||||
foreach ($persons as $key => $person) {
|
||||
|
@ -421,7 +424,8 @@ class PersonsController extends AbstractController
|
|||
#[Route('/api/person/list/depositors/{amount}', name: 'app_persons_list_depoistors')]
|
||||
public function app_persons_list_depoistors(string $amount, Provider $provider, Request $request, Access $access, Log $log, EntityManagerInterface $entityManager): JsonResponse
|
||||
{
|
||||
if (!$access->hasRole('person'))
|
||||
$acc = $access->hasRole('person');
|
||||
if (!$acc)
|
||||
throw $this->createAccessDeniedException();
|
||||
$params = [];
|
||||
if ($content = $request->getContent()) {
|
||||
|
@ -429,12 +433,12 @@ class PersonsController extends AbstractController
|
|||
}
|
||||
if (array_key_exists('speedAccess', $params)) {
|
||||
$persons = $entityManager->getRepository(Person::class)->findBy([
|
||||
'bid' => $request->headers->get('activeBid'),
|
||||
'bid' => $acc['bid'],
|
||||
'speedAccess' => true
|
||||
]);
|
||||
} else {
|
||||
$persons = $entityManager->getRepository(Person::class)->findBy([
|
||||
'bid' => $request->headers->get('activeBid')
|
||||
'bid' => $acc['bid']
|
||||
]);
|
||||
}
|
||||
|
||||
|
@ -470,7 +474,7 @@ class PersonsController extends AbstractController
|
|||
throw $this->createAccessDeniedException();
|
||||
|
||||
$persons = $entityManager->getRepository(Person::class)->findBy([
|
||||
'bid' => $request->headers->get('activeBid')
|
||||
'bid' => $acc['bid']
|
||||
]);
|
||||
$response = $provider->ArrayEntity2Array($persons, 0);
|
||||
foreach ($persons as $key => $person) {
|
||||
|
@ -940,7 +944,7 @@ class PersonsController extends AbstractController
|
|||
//check exist before
|
||||
if (!$person) {
|
||||
$person = new Person();
|
||||
$person->setCode($provider->getAccountingCode($request->headers->get('activeBid'), 'person'));
|
||||
$person->setCode($provider->getAccountingCode($acc['bid'], 'person'));
|
||||
$person->setNikename($item[0]);
|
||||
$person->setBid($acc['bid']);
|
||||
|
||||
|
@ -984,7 +988,7 @@ class PersonsController extends AbstractController
|
|||
}
|
||||
$entityManager->flush();
|
||||
}
|
||||
$log->insert('اشخاص', 'تعداد ' . count($data) . ' شخص به صورت گروهی وارد شد.', $this->getUser(), $request->headers->get('activeBid'));
|
||||
$log->insert('اشخاص', 'تعداد ' . count($data) . ' شخص به صورت گروهی وارد شد.', $this->getUser(), $acc['bid']);
|
||||
return $this->json(['result' => 1]);
|
||||
}
|
||||
|
||||
|
|
|
@ -313,4 +313,35 @@ class SellController extends AbstractController
|
|||
}
|
||||
return $this->json($dataTemp);
|
||||
}
|
||||
|
||||
#[Route('/api/sell/posprinter/invoice', name: 'app_sell_posprinter_invoice')]
|
||||
public function app_sell_posprinter_invoice(Provider $provider, Request $request, Access $access, Log $log, EntityManagerInterface $entityManager): JsonResponse
|
||||
{
|
||||
$params = [];
|
||||
if ($content = $request->getContent()) {
|
||||
$params = json_decode($content, true);
|
||||
}
|
||||
|
||||
$acc = $access->hasRole('sell');
|
||||
if (!$acc) throw $this->createAccessDeniedException();
|
||||
|
||||
$doc = $entityManager->getRepository(HesabdariDoc::class)->findOneBy([
|
||||
'bid' => $acc['bid'],
|
||||
'code' => $params['code']
|
||||
]);
|
||||
if (!$doc) throw $this->createNotFoundException();
|
||||
$posPrint = false;
|
||||
if(array_key_exists('posprint',$params)) $posPrint = true;
|
||||
$pid = $provider->createPrint(
|
||||
$acc['bid'],
|
||||
$this->getUser(),
|
||||
$this->renderView('pdf/posPrinters/sell.html.twig', [
|
||||
'bid' => $acc['bid'],
|
||||
'doc'=>$doc,
|
||||
'rows'=>$doc->getHesabdariRows()
|
||||
]),
|
||||
$posPrint
|
||||
);
|
||||
return $this->json(['id' => $pid]);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -30,6 +30,9 @@ class PrinterQueue
|
|||
#[ORM\ManyToOne]
|
||||
private ?Business $bid = null;
|
||||
|
||||
#[ORM\Column(nullable: true)]
|
||||
private ?bool $posprint = null;
|
||||
|
||||
public function getId(): ?int
|
||||
{
|
||||
return $this->id;
|
||||
|
@ -94,4 +97,16 @@ class PrinterQueue
|
|||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function isPosprint(): ?bool
|
||||
{
|
||||
return $this->posprint;
|
||||
}
|
||||
|
||||
public function setPosprint(?bool $posprint): static
|
||||
{
|
||||
$this->posprint = $posprint;
|
||||
|
||||
return $this;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,8 +1,11 @@
|
|||
<?php
|
||||
|
||||
namespace App\Service;
|
||||
|
||||
use App\Entity\APIToken;
|
||||
use App\Entity\Business;
|
||||
use App\Entity\Permission;
|
||||
use App\Entity\UserToken;
|
||||
use App\Entity\Year;
|
||||
use Symfony\Component\Security\Core\User\UserInterface;
|
||||
use Doctrine\ORM\EntityManagerInterface;
|
||||
|
@ -16,6 +19,9 @@ class Access
|
|||
protected Request $request;
|
||||
protected RequestStack $requestStack;
|
||||
protected UserInterface | null $user;
|
||||
|
||||
protected Business | string $bid;
|
||||
|
||||
function __construct(
|
||||
EntityManagerInterface $entityManager,
|
||||
TokenStorageInterface $tokenStorage,
|
||||
|
@ -36,12 +42,33 @@ class Access
|
|||
{
|
||||
if(is_null($this->user))
|
||||
return false;
|
||||
if ($this->request->headers->get('activeBid')) {
|
||||
$bid = $this->em->getRepository(Business::class)->find($this->request->headers->get('activeBid'));
|
||||
if(is_null($bid))
|
||||
return false;
|
||||
$year = $this->em->getRepository(Year::class)->find($this->request->headers->get('activeYear'));
|
||||
if(is_null($year))
|
||||
if (is_null($bid)) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
elseif($this->request->headers->get('api-key')){
|
||||
$token = $this->em->getRepository(APIToken::class)->findOneBy([
|
||||
'token'=>$this->request->headers->get('api-key')
|
||||
]);
|
||||
if(!$token) { return false; }
|
||||
$bid = $token->getBid();
|
||||
}
|
||||
if ($this->request->headers->get('activeYear')) {
|
||||
$year = $this->em->getRepository(Year::class)->findOneBy([
|
||||
'id' => $this->request->headers->get('activeYear'),
|
||||
'bid'=>$bid
|
||||
]);
|
||||
if (!$year) { return false; }
|
||||
}
|
||||
elseif($this->request->headers->get('api-key')){
|
||||
$year = $this->em->getRepository(Year::class)->findOneBy([
|
||||
'head' => true,
|
||||
'bid'=>$bid
|
||||
]);
|
||||
}
|
||||
|
||||
$accessArray = [
|
||||
'bid'=>$bid,
|
||||
'user'=>$this->user,
|
||||
|
|
|
@ -172,7 +172,11 @@ class Explore
|
|||
'count' => $count,
|
||||
'unit' => $item->getUnit()->getName(),
|
||||
'des' => $des,
|
||||
'withoutTax' => $item->isWithoutTax()
|
||||
'withoutTax' => $item->isWithoutTax(),
|
||||
'unitData' => [
|
||||
'name' => $item->getUnit()->getName(),
|
||||
'floatNumber' => $item->getUnit()->getFloatNumber(),
|
||||
]
|
||||
];
|
||||
return null;
|
||||
}
|
||||
|
|
|
@ -147,13 +147,14 @@ class Provider
|
|||
return $result;
|
||||
}
|
||||
|
||||
public function createPrint(Business $bid, User $user, String $data)
|
||||
public function createPrint(Business $bid, User $user, String $data,$posPrint = false)
|
||||
{
|
||||
$print = new PrinterQueue();
|
||||
$print->setDateSubmit(time());
|
||||
$print->setSubmitter($user);
|
||||
$print->setBid($bid);
|
||||
$print->setView($data);
|
||||
$print->setPosprint($posPrint);
|
||||
$print->setPid($this->RandomString(128));
|
||||
$this->entityManager->persist($print);
|
||||
$this->entityManager->flush();
|
||||
|
|
|
@ -46,6 +46,37 @@ class pdfMGR
|
|||
$mpdf->Output();
|
||||
}
|
||||
|
||||
public function streamTwig2PDFInvoiceType(PrinterQueue $printQueue, $configs = [])
|
||||
{
|
||||
|
||||
$mpdf = new \Mpdf\Mpdf([
|
||||
'mode' => 'utf-8', 'format' => [80, 600],
|
||||
'fontdata' => [
|
||||
'vazirmatn' => [
|
||||
'R' => 'Vazir-Regular-FD.ttf',
|
||||
'I' => 'Vazir-Regular-FD.ttf',
|
||||
'useOTL' => 0xFF,
|
||||
'useKashida' => 75,
|
||||
]
|
||||
],
|
||||
'default_font' => 'vazirmatn',
|
||||
'tempDir' => sys_get_temp_dir() . DIRECTORY_SEPARATOR . 'mpdf',
|
||||
'setAutoTopMargin' => true,
|
||||
'autoArabic' => true,
|
||||
'margin-collapse' => 'collapse|none'
|
||||
]);
|
||||
$mpdf->AddPageByArray([
|
||||
'margin-left' => 0,
|
||||
'margin-right' => 0,
|
||||
'margin-top' => 0,
|
||||
'margin-bottom' => 0,
|
||||
]);
|
||||
$mpdf->AddFontDirectory(__DIR__ . '../Fonts');
|
||||
$mpdf->WriteHTML($printQueue->getView());
|
||||
|
||||
$mpdf->Output();
|
||||
}
|
||||
|
||||
private function imageToBase64($path) {
|
||||
$path = $path;
|
||||
$type = pathinfo($path, PATHINFO_EXTENSION);
|
||||
|
|
191
hesabixCore/templates/pdf/posPrinters/sell.html.twig
Normal file
191
hesabixCore/templates/pdf/posPrinters/sell.html.twig
Normal file
|
@ -0,0 +1,191 @@
|
|||
<!DOCTYPE html>
|
||||
<html lang="fa" direction="rtl">
|
||||
|
||||
<head>
|
||||
<style>
|
||||
body {
|
||||
margin: 0;
|
||||
padding: 0;
|
||||
font-size: 100%;
|
||||
}
|
||||
|
||||
table {
|
||||
width: 100%;
|
||||
}
|
||||
|
||||
tr {
|
||||
width: 100%;
|
||||
|
||||
}
|
||||
|
||||
h1 {
|
||||
text-align: center;
|
||||
vertical-align: middle;
|
||||
}
|
||||
|
||||
#logo {
|
||||
width: 60%;
|
||||
text-align: center;
|
||||
-webkit-align-content: center;
|
||||
align-content: center;
|
||||
padding: 5px;
|
||||
margin: 0 auto;
|
||||
display: block;
|
||||
}
|
||||
|
||||
header {
|
||||
width: 100%;
|
||||
text-align: center;
|
||||
-webkit-align-content: center;
|
||||
align-content: center;
|
||||
vertical-align: middle;
|
||||
}
|
||||
|
||||
.items thead {
|
||||
text-align: center;
|
||||
}
|
||||
|
||||
.center-align {
|
||||
text-align: center;
|
||||
}
|
||||
|
||||
.bill-details td {
|
||||
font-size: 12px;
|
||||
}
|
||||
|
||||
.receipt {
|
||||
font-size: medium;
|
||||
}
|
||||
|
||||
.items .heading {
|
||||
font-size: 12.5px;
|
||||
text-transform: uppercase;
|
||||
border-top: 1px solid black;
|
||||
margin-bottom: 4px;
|
||||
border-bottom: 1px solid black;
|
||||
vertical-align: middle;
|
||||
}
|
||||
|
||||
.items thead tr th:first-child,
|
||||
.items tbody tr td:first-child {
|
||||
word-break: break-all;
|
||||
text-align: center;
|
||||
}
|
||||
|
||||
.items td {
|
||||
font-size: 12px;
|
||||
text-align: center;
|
||||
vertical-align: bottom;
|
||||
}
|
||||
|
||||
.price::after {
|
||||
content: "";
|
||||
text-align: right;
|
||||
}
|
||||
|
||||
.sum-up {
|
||||
text-align: right !important;
|
||||
}
|
||||
.total {
|
||||
font-size: 13px;
|
||||
border-top: 1px dashed black !important;
|
||||
border-bottom: 1px dashed black !important;
|
||||
}
|
||||
.total.text,
|
||||
.total.price {
|
||||
text-align: right;
|
||||
}
|
||||
.total.price::after {
|
||||
content: " ریال ";
|
||||
}
|
||||
.line {
|
||||
border-top: 1px solid black !important;
|
||||
}
|
||||
|
||||
p {
|
||||
padding: 1px;
|
||||
margin: 0;
|
||||
}
|
||||
section,
|
||||
footer {
|
||||
font-size: 12px;
|
||||
}
|
||||
tbody,
|
||||
thead,
|
||||
th,
|
||||
td,
|
||||
tr {
|
||||
text-align: center;
|
||||
}
|
||||
</style>
|
||||
</head>
|
||||
|
||||
<body style="direction:rtl; text-align:right; width:100%">
|
||||
<header>
|
||||
<p style="text-align:center;">{{ bid.name }}</p>
|
||||
</header>
|
||||
<table class="bill-details">
|
||||
<tbody style="text-align:right">
|
||||
<tr>
|
||||
<td style="text-align:right">تاریخ :
|
||||
<span>{{doc.date}}</span>
|
||||
</td>
|
||||
<td style="text-align:right">شماره :
|
||||
<span>#
|
||||
{{doc.code | number_format}}</span>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td style="text-align:right"></td>
|
||||
<td></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th class="center-align" colspan="2">
|
||||
<span class="receipt">صورتحساب</span>
|
||||
</th>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
|
||||
<table class="items">
|
||||
<thead style="background:gray;text-color:white;">
|
||||
<tr>
|
||||
<th class="heading name">کالا</th>
|
||||
<th class="heading qty">تعداد</th>
|
||||
<th class="heading rate">فی</th>
|
||||
<th class="heading amount">جمع</th>
|
||||
</tr>
|
||||
</thead>
|
||||
|
||||
<tbody>
|
||||
{% for row in rows %}
|
||||
{% if row.commodity != null %}
|
||||
<tr>
|
||||
<td>{{row.commodity.name}}</td>
|
||||
<td>{{row.commdityCount}}</td>
|
||||
<td class="price">{{(row.bs / row.commdityCount) | number_format}}</td>
|
||||
<td class="price">{{row.bs | number_format}}</td>
|
||||
</tr>
|
||||
{% endif %}
|
||||
{% endfor %}
|
||||
<tr>
|
||||
<th colspan="3" class="total text">جمع فاکتور</th>
|
||||
<th class="total price">{{doc.amount | number_format}}</th>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
<section style="margin-bottom:10px;margin-top:10px;">
|
||||
<p style="text-align:center">
|
||||
از خرید شما متشکریم
|
||||
</p>
|
||||
</section>
|
||||
<footer style="text-align:center">
|
||||
<p>{{ bid.name }}</p>
|
||||
<p>{{ bid.address }}</p>
|
||||
<p>{{ bid.tel }}</p>
|
||||
<p>hesabix.ir</p>
|
||||
</footer>
|
||||
</body>
|
||||
|
||||
</html>
|
||||
|
|
@ -171,6 +171,10 @@
|
|||
</table>
|
||||
</div>
|
||||
<!-- END Table -->
|
||||
<div class="block block-rounded">
|
||||
توضیحات:
|
||||
{{ doc.des }}
|
||||
</div>
|
||||
<div class="block block-rounded">
|
||||
<div class="block-header block-header-default">
|
||||
<h3 class="block-title">سوابق پرداختها</h3>
|
||||
|
|
Loading…
Reference in a new issue