some progress in printing system

This commit is contained in:
babak alizadeh 2024-06-27 18:20:46 +03:30
parent 6ad49b2d12
commit f43208578d
11 changed files with 551 additions and 11 deletions

View file

@ -46,4 +46,7 @@ services:
arguments: [ "@doctrine.orm.entity_manager" ] arguments: [ "@doctrine.orm.entity_manager" ]
registryMGR: registryMGR:
class: App\Service\registryMGR class: App\Service\registryMGR
arguments: [ "@doctrine.orm.entity_manager" ]
Printers:
class: App\Service\Printers
arguments: [ "@doctrine.orm.entity_manager" ] arguments: [ "@doctrine.orm.entity_manager" ]

View file

@ -142,4 +142,10 @@ class UiGeneralController extends AbstractController
return $this->render('general/repservice.html.twig',); return $this->render('general/repservice.html.twig',);
} }
#[Route('/front/apps/hesabixbox', name: 'general_apps_hesabixbox')]
public function general_apps_hesabixbox(EntityManagerInterface $entityManager): Response
{
return $this->render('general/hesabixbox.html.twig',);
}
} }

View file

@ -3,6 +3,7 @@
namespace App\Controller; namespace App\Controller;
use App\Entity\Printer; use App\Entity\Printer;
use App\Entity\PrintItem;
use App\Service\Access; use App\Service\Access;
use App\Service\Extractor; use App\Service\Extractor;
use App\Service\Log; use App\Service\Log;
@ -89,4 +90,25 @@ class PrintersController extends AbstractController
'result' => 1 'result' => 1
]); ]);
} }
#[Route('/api/print/last', name: 'app_print_last')]
public function app_print_last(Provider $provider, Request $request, Access $access, Log $log, EntityManagerInterface $entityManager): Response
{
$acc = $access->hasRole('owner');
if (!$acc)
throw $this->createAccessDeniedException();
$printer = $entityManager->getRepository(Printer::class)->findBy([
'bid' => $acc['bid'],
'token'=>$request->headers->get('printer-key')
]);
$items = $entityManager->getRepository(PrintItem::class)->findBy([
'printer' => $printer,
'printed' => false
]);
if(count($items) == 0) return new Response('');
$items[count($items) - 1]->setPrinted(true);
$entityManager->persist($items[count($items) - 1]);
$entityManager->flush();
return new Response($items[count($items) - 1]->getType() . ',' .$items[count($items) - 1]->getFile());
}
} }

View file

@ -14,6 +14,7 @@ use App\Entity\HesabdariTable;
use App\Entity\InvoiceType; use App\Entity\InvoiceType;
use App\Entity\Person; use App\Entity\Person;
use App\Entity\StoreroomTicket; use App\Entity\StoreroomTicket;
use App\Service\Printers;
use Doctrine\ORM\EntityManagerInterface; use Doctrine\ORM\EntityManagerInterface;
use Symfony\Component\HttpFoundation\Request; use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\HttpFoundation\Response; use Symfony\Component\HttpFoundation\Response;
@ -315,7 +316,7 @@ class SellController extends AbstractController
} }
#[Route('/api/sell/posprinter/invoice', name: 'app_sell_posprinter_invoice')] #[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 public function app_sell_posprinter_invoice(Printers $printers, Provider $provider, Request $request, Access $access, Log $log, EntityManagerInterface $entityManager): JsonResponse
{ {
$params = []; $params = [];
if ($content = $request->getContent()) { if ($content = $request->getContent()) {
@ -330,9 +331,9 @@ class SellController extends AbstractController
'code' => $params['code'] 'code' => $params['code']
]); ]);
if (!$doc) throw $this->createNotFoundException(); if (!$doc) throw $this->createNotFoundException();
$posPrint = false; $pdfPid = 0;
if(array_key_exists('posprint',$params)) $posPrint = true; if ($params['pdf']) {
$pid = $provider->createPrint( $pdfPid = $provider->createPrint(
$acc['bid'], $acc['bid'],
$this->getUser(), $this->getUser(),
$this->renderView('pdf/posPrinters/sell.html.twig', [ $this->renderView('pdf/posPrinters/sell.html.twig', [
@ -342,8 +343,38 @@ class SellController extends AbstractController
'printInvoice'=>$params['posPrint'], 'printInvoice'=>$params['posPrint'],
'printcashdeskRecp'=>$params['posPrintRecp'], 'printcashdeskRecp'=>$params['posPrintRecp'],
]), ]),
true true
); );
return $this->json(['id' => $pid]); }
if ($params['posPrint'] == true) {
$pid = $provider->createPrint(
$acc['bid'],
$this->getUser(),
$this->renderView('pdf/posPrinters/justSell.html.twig', [
'bid' => $acc['bid'],
'doc' => $doc,
'rows' => $doc->getHesabdariRows(),
]),
true
);
$printers->addFile($pid, $acc, "fastSellInvoice");
}
if ($params['posPrintRecp'] == true) {
$pid = $provider->createPrint(
$acc['bid'],
$this->getUser(),
$this->renderView('pdf/posPrinters/cashdesk.html.twig', [
'bid' => $acc['bid'],
'doc' => $doc,
'rows' => $doc->getHesabdariRows(),
]),
true
);
$printers->addFile($pid, $acc, "fastSellCashdesk");
}
return $this->json(['id' => $pdfPid]);
} }
} }

View file

@ -23,6 +23,9 @@ class PrintItem
#[ORM\Column(nullable: true)] #[ORM\Column(nullable: true)]
private ?bool $printed = null; private ?bool $printed = null;
#[ORM\Column(length: 255)]
private ?string $type = null;
public function getId(): ?int public function getId(): ?int
{ {
return $this->id; return $this->id;
@ -63,4 +66,16 @@ class PrintItem
return $this; return $this;
} }
public function getType(): ?string
{
return $this->type;
}
public function setType(string $type): static
{
$this->type = $type;
return $this;
}
} }

View file

@ -0,0 +1,40 @@
<?php
namespace App\Service;
use App\Entity\APIToken;
use App\Entity\Business;
use App\Entity\Permission;
use App\Entity\Printer;
use App\Entity\PrintItem;
use App\Entity\UserToken;
use App\Entity\Year;
use Symfony\Component\Security\Core\User\UserInterface;
use Doctrine\ORM\EntityManagerInterface;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\HttpFoundation\RequestStack;
use Symfony\Component\Security\Core\Authentication\Token\Storage\TokenStorageInterface;
class Printers
{
private $em;
function __construct(EntityManagerInterface $entityManager,){
$this->em = $entityManager;
}
public function addFile(string $filename,array $acc,string $type){
$printers = $this->em->getRepository(Printer::class)->findBy([
'bid'=>$acc['bid']
]);
foreach($printers as $printer){
$item = new PrintItem();
$item->setPrinted(false);
$item->setPrinter($printer);
$item->setType($type);
$item->setFile($filename);
$this->em->persist($item);
}
$this->em->flush();
}
}

View file

@ -257,6 +257,11 @@
<i class="fa fa-fw fa-shop text-primary-lighter me-1"></i> <i class="fa fa-fw fa-shop text-primary-lighter me-1"></i>
افزونه مدیریت تعمیرگاه</a> افزونه مدیریت تعمیرگاه</a>
</li> </li>
<li>
<a class="fw-semibold" href="{{path('general_apps_hesabixbox')}}">
<i class="fa fa-fw fa-shop text-primary-lighter me-1"></i>
حسابیکس باکس</a>
</li>
</ul> </ul>
</div> </div>
<div class="col-sm-6 col-md-3"> <div class="col-sm-6 col-md-3">

View file

@ -0,0 +1,66 @@
{% extends "base.html.twig" %}
{% block title %}
حسابیکس باکس رابط ویندوزی حسابیکس
{% endblock %}
{% block body %}
<main
id="main-container p-0 m-0">
<!-- Hero -->
<div class="bg-image">
<div class="bg-black-75">
<div class="content content-top content-full text-center">
<h1 class="text-white">
<i class="fa fa-shop"></i>
</h1>
<h1 class="fw-bold text-white mt-5 mb-3">حسابیکس باکس رابط ویندوزی حسابیکس</h1>
<h2 class="h3 fw-normal text-white-75 mb-5">
رابط تحت ویندوز حسابیکس با نام حسابیکس باکس جهت ارتباط با حسابیکس بر روی بستر ویندوز توسعه داده شده است و هماکنون در مرحله آزمایشی قرار دارد.
</h2>
<a to="#">
<a target="_blank" href="https://github.com/morrning/hesabixBox/releases" class="btn btn-primary rounded-pill fs-base px-3 py-2 me-2 m-1">
<i class="fa fa-user-circle me-1"></i>
دریافت حسابیکس باکس
</span>
</a>
<br>
<i class="fa fa-arrow-down text-white"></i>
</div>
</div>
</div>
<!-- END Hero -->
<!-- Page Content -->
<div class="container-fluid">
<div class="row justify-content-center">
<div
class="col-sm-11 py-2">
<!-- Story -->
<article class="story justify-content-between">
<div class="rounded-3 bg-white p-3 mb-3">
<div class="row">
<div class="col-sm-12 col-md-12">
<p>
برای اتصال پرینتر‌های ابری الزاما باید این نرم افزار بر روی رایانه مورد نظر نصب باشد.
</p>
</div>
</div>
<h2 class="text-primary">پیش نیاز‌ها:</h2>
<ul>
<li>
Dotnet framework 6 runtime
</li>
<li>
Adobe Acrobat Reader 2010 یا نسخه بالاتر
</li>
</ul>
</div>
</article>
<!-- END Story -->
</div>
</div>
</div>
<!-- END Page Content -->
</main>
{% endblock %}

View file

@ -0,0 +1,168 @@
<!DOCTYPE html>
<html lang="fa" direction="rtl">
<head>
<style>
body {
margin: 5px;
padding: 0;
font-size: 100%;
}
table {
width: 100%;
}
tr {
width: 100%;
}
th,
td {
border: 1px solid black !important;
}
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%">
<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>
<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>
</tr>
</thead>
<tbody>
{% for row in rows %}
{% if row.commodity != null %}
<tr>
<td>{{row.commodity.name}}</td>
<td>{{row.commdityCount}}</td>
</tr>
{% endif %}
{% endfor %}
</tbody>
</table>
<footer style="text-align:center">
<p>{{ bid.name }}</p>
</footer>
</body>
</html>

View file

@ -0,0 +1,186 @@
<!DOCTYPE html>
<html lang="fa" direction="rtl">
<head>
<style>
body {
margin: 5px;
padding: 0;
font-size: 100%;
}
table {
width: 100%;
}
tr {
width: 100%;
}
th,
td {
border: 1px solid black !important;
}
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>
<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;text-align:center;">
<b style="text-align:center">
از خرید شما متشکریم
</b>
</section>
<footer style="text-align:center">
<p>{{ bid.address }}</p>
<p>{{ bid.tel }}</p>
<p>hesabix.ir</p>
</footer>
</body>
</html>

View file

@ -1,6 +1,5 @@
<!DOCTYPE html> <!DOCTYPE html>
<html lang="fa" direction="rtl"></html> <html lang="fa" direction="rtl"></html>
<head> <head>
<style> <style>
body { body {
@ -185,7 +184,8 @@
{% if printcashdeskRecp%} {% if printcashdeskRecp%}
{% if printInvoice %} {% if printInvoice %}
<hr> <pagebreak>
{% endif %} {% endif %}
<table class="bill-details"> <table class="bill-details">
<tbody style="text-align:right"> <tbody style="text-align:right">
@ -229,8 +229,6 @@
<p>{{ bid.name }}</p> <p>{{ bid.name }}</p>
</footer> </footer>
{% endif %} {% endif %}
</body> </body>
</html> </html>