some progress in storeroom

This commit is contained in:
babak alizadeh 2024-07-26 22:29:06 +03:30
parent eb9dcf07cf
commit 0feef787be
2 changed files with 238 additions and 2 deletions

View file

@ -6,13 +6,14 @@ use App\Entity\Commodity;
use App\Entity\HesabdariDoc; use App\Entity\HesabdariDoc;
use App\Entity\HesabdariRow; use App\Entity\HesabdariRow;
use App\Entity\Person; use App\Entity\Person;
use App\Service\Printers;
use App\Service\Provider;
use App\Entity\Storeroom; use App\Entity\Storeroom;
use App\Entity\StoreroomItem; use App\Entity\StoreroomItem;
use App\Entity\StoreroomTicket; use App\Entity\StoreroomTicket;
use App\Entity\StoreroomTransferType; use App\Entity\StoreroomTransferType;
use App\Service\Access; use App\Service\Access;
use App\Service\Log; use App\Service\Log;
use App\Service\Provider;
use Doctrine\ORM\EntityManagerInterface; use Doctrine\ORM\EntityManagerInterface;
use ReflectionException; use ReflectionException;
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController; use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
@ -441,6 +442,8 @@ class StoreroomController extends AbstractController
'bid' => $acc['bid'], 'bid' => $acc['bid'],
'year' => $acc['year'], 'year' => $acc['year'],
'type' => $type 'type' => $type
],[
'date'=>'DESC'
]); ]);
return $this->json($provider->ArrayEntity2ArrayJustIncludes($tickets, [ return $this->json($provider->ArrayEntity2ArrayJustIncludes($tickets, [
'getDes', 'getDes',
@ -473,7 +476,7 @@ class StoreroomController extends AbstractController
$res['person'] = $provider->Entity2ArrayJustIncludes($ticket->getPerson(), ['getKeshvar', 'getOstan', 'getShahr', 'getAddress', 'getNikename', 'getCodeeghtesadi', 'getPostalcode', 'getName', 'getTel', 'getSabt'], 0); $res['person'] = $provider->Entity2ArrayJustIncludes($ticket->getPerson(), ['getKeshvar', 'getOstan', 'getShahr', 'getAddress', 'getNikename', 'getCodeeghtesadi', 'getPostalcode', 'getName', 'getTel', 'getSabt'], 0);
//get rows //get rows
$rows = $entityManager->getRepository(StoreroomItem::class)->findBy(['ticket' => $ticket]); $rows = $entityManager->getRepository(StoreroomItem::class)->findBy(['ticket' => $ticket]);
$res['commodities'] = $provider->ArrayEntity2ArrayJustIncludes($rows, ['getId', 'getDes', 'getCode', 'getName', 'getCommodity', 'getUnit', 'getCount'], 2); $res['commodities'] = $provider->ArrayEntity2ArrayJustIncludes($rows, ['getId', 'getDes', 'getCode', 'getName', 'getCommodity', 'getUnit', 'getCount','getReferal'], 2);
//calculate rows data //calculate rows data
$this->calcStoreRemaining($res, $ticket->getDoc(), $entityManager); $this->calcStoreRemaining($res, $ticket->getDoc(), $entityManager);
@ -561,4 +564,42 @@ class StoreroomController extends AbstractController
'result' => 0 'result' => 0
]); ]);
} }
#[Route('/api/storeroom/print/ticket', name: 'app_storeroom_print_ticket')]
public function app_storeroom_print_ticket(Printers $printers, Provider $provider, Request $request, Access $access, Log $log, EntityManagerInterface $entityManager): JsonResponse
{
$params = [];
if ($content = $request->getContent()) {
$params = json_decode($content, true);
}
$acc = $access->hasRole('store');
if (!$acc) throw $this->createAccessDeniedException();
$doc = $entityManager->getRepository(StoreroomTicket::class)->findOneBy([
'bid' => $acc['bid'],
'code' => $params['code']
]);
if (!$doc) throw $this->createNotFoundException();
if($params['type'] == 'input'){
$title = 'حواله ورود به انبار';
}
else{
$title = 'حواله خروج از انبار';
}
$pdfPid = 0;
$pdfPid = $provider->createPrint(
$acc['bid'],
$this->getUser(),
$this->renderView('pdf/printers/storeroom/input.html.twig', [
'title'=> $title,
'bid' => $acc['bid'],
'doc' => $doc,
'rows' => $doc->getStoreroomItems(),
'person' => $doc->getPerson()
]),
false
);
return $this->json(['id' => $pdfPid]);
}
} }

View file

@ -0,0 +1,195 @@
<!DOCTYPE html>
<html lang="fa" direction="rtl"></html>
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no">
<head>
<style>
.center {
text-align: center;
}
.text-white {
color: white;
}
.stimol td,
.stimol th {
border: 1px solid black;
}
.item {
height: 40px;
}
</style>
</head>
<body style="direction:rtl; width:100%">
<div class="block-content pt-1 pb-3 d-none d-sm-block">
<div class="c-print container-xl">
<div class="tg-wrap" style="width:100%; border:1px solid black;border-radius: 8px;">
<table class="rounded" style="width:100%;">
<thead>
<tr>
<td style="width:20%">
<img src="{{ "/api/avatar/get/file/" ~ bid.avatar}}" width="65"/>
</td>
<td style="width:60%; text-align:center">
<h3 class="">{{ bid.name }}</h3>
<br/>
<h4 class="">{{ title }}</h4>
</td>
<td style="width:20%">
<h4>
<b>تاریخ:</b>
{{ doc.date }}</h4>
<br/>
<h4>
<b>شماره:</b>
{{ doc.code }}</h4>
</td>
</tr>
</thead>
</table>
</div>
<div style="width:100%; border:1px solid black;border-radius: 8px;margin-top:5px;text-align:center;">
<div class="tg-wrap" style="width:100%;border-radius: 8px 8px 0px 0px;text-align:center;background-color:gray">
<b style="color:white;">طرف حساب</b>
</div>
<table style="width:100%;">
<tbody>
<tr style="text-align:center;">
<td class="">
<p>
<b>نام:
</b>
{{ person.nikename }}
</p>
</td>
<td class="center">
<p>
<b>
شناسه ملی:
</b>
{{ person.shenasemeli }}
</p>
</td>
<td class="center">
<p>
<b>شماره ثبت:
</b>
{{ person.sabt }}
</p>
</td>
<td class="center">
<p>
<b>شماره اقتصادی:
</b>
{{ person.codeeghtesadi }}
</p>
</td>
<td class="center">
<p>
<b>تلفن / نمابر:</b>
{{ person.tel }}
</p>
</td>
</tr>
<tr>
<td class="" colspan="1">
<p>
<b>کد پستی:</b>
{{ person.postalcode }}
</p>
</td>
<td class="" colspan="3">
<p>
<b>آدرس:
</b>
استان
{{ person.ostan }}، شهر
{{ person.shahr }}،
{{ person.address }}
</p>
</td>
</tr>
<tr style="text-align:center;">
<td class="">
<p>
<b>حمل و نقل:
</b>
{{ doc.transfer }}
</p>
</td>
<td class="center">
<p>
<b>
تحویل:
</b>
{{ doc.receiver }}
</p>
</td>
<td class="center">
<p>
<b>روش تحویل:
</b>
{{ doc.transferType.name }}
</p>
</td>
<td class="center" colspan="2">
<p>
<b>شماره پیگیری:
</b>
{{ doc.referral }}
</p>
</td>
</tr>
</tbody>
</table>
</div>
<div style="width:100%;margin-top:5px;text-align:center;">
<table style="width:100%;">
<thead>
<tr class="stimol" style="background-color:gray;">
<th class="text-white" style="width:80px">ردیف</th>
<th class="text-white">کالا/خدمات</th>
<th class="text-white">واحد</th>
<th class="text-white">تعداد</th>
<th class="text-white">ارجاع</th>
<th class="text-white">شرح</th>
</tr>
</thead>
<tbody>
{% set rowIndex = 0 %}
{% for row in rows %}
{% set rowIndex = rowIndex + 1 %}
<tr class="stimol">
<td class="center item">{{ rowIndex }}</td>
<td class="center item">{{ row.commodity.code }}
{{ row.commodity.name }}</td>
<td class="center item">{{ row.commodity.unit.name }}</td>
<td class="center item">{{ row.count }}</td>
<td class="center item">{{ row.referal }}</td>
<td class="center item">{{ row.des }}</td>
</tr>
{% endfor %}
</tbody>
</table>
</div>
<div style="width:40%;margin-top:20px;text-align:center;float:left;">
<table style="width:100%;">
<tbody>
<tr class="">
<td class="center" style="height:90px">
<h4>
مهر و امضا انباردار
{{ doc.storeroom.name }}
</h4>
<br/>
<h5>
{{doc.storeroom.manager}}
</h5>
</td>
</tr>
</tbody>
</table>
</div>
</div>
</body>
</body></div></body></html>