add bussiness avatar to shortlinks page for customer

This commit is contained in:
babak alizadeh 2024-09-01 19:02:06 +03:30
parent ca95ec48aa
commit 453eb73c79
3 changed files with 75 additions and 6 deletions

View file

@ -2,6 +2,7 @@
namespace App\Controller; namespace App\Controller;
use App\Entity\Business;
use App\Service\Access; use App\Service\Access;
use App\Service\Log; use App\Service\Log;
use Doctrine\ORM\EntityManagerInterface; use Doctrine\ORM\EntityManagerInterface;
@ -16,6 +17,18 @@ use Symfony\Component\String\Slugger\SluggerInterface;
class AvatarController extends AbstractController class AvatarController extends AbstractController
{ {
#[Route('/front/avatar/file/get/{id}', name: 'front_avatar_file_get')]
public function front_avatar_file_get(string $id,EntityManagerInterface $entityManager,$code = 0): BinaryFileResponse
{
$bid = $entityManager->getRepository(Business::class)->find($id);
if(! $bid)
throw $this->createNotFoundException();
$fileAdr = dirname(__DIR__,3) . '/hesabixArchive/avatars/'. $bid->getAvatar();
if(!$bid->getAvatar()) return new BinaryFileResponse(dirname(__DIR__,3) . '/hesabixArchive/avatars/default.png');
$response = new BinaryFileResponse($fileAdr);
return $response;
}
#[Route('/api/avatar/get', name: 'api_avatar_get')] #[Route('/api/avatar/get', name: 'api_avatar_get')]
public function api_avatar_get(Access $access): Response public function api_avatar_get(Access $access): Response
{ {

View file

@ -5,6 +5,8 @@ namespace App\Controller\Front;
use App\Entity\Business; use App\Entity\Business;
use App\Entity\HesabdariDoc; use App\Entity\HesabdariDoc;
use App\Entity\HesabdariRow; use App\Entity\HesabdariRow;
use App\Entity\PrintOptions;
use App\Service\Provider;
use Doctrine\ORM\EntityManagerInterface; use Doctrine\ORM\EntityManagerInterface;
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController; use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
use Symfony\Component\HttpFoundation\Response; use Symfony\Component\HttpFoundation\Response;
@ -52,10 +54,63 @@ class ShortlinksController extends AbstractController
return $this->render('shortlinks/sell.html.twig', [ return $this->render('shortlinks/sell.html.twig', [
'bid' => $doc->getBid(), 'bid' => $doc->getBid(),
'doc' => $doc, 'doc' => $doc,
'link'=>$link,
'rows' => $items, 'rows' => $items,
'person'=> $person, 'person'=> $person,
'totalPays'=>$totalPays, 'totalPays'=>$totalPays,
'msg'=>$msg 'msg'=>$msg
]); ]);
} }
#[Route('/slpdf/sell/{bid}/{link}', name: 'shortlinks_pdf')]
public function shortlinks_pdf(string $bid, string $link, EntityManagerInterface $entityManager, Provider $provider): Response
{
$doc = $entityManager->getRepository(HesabdariDoc::class)->findOneBy([
'type' => 'sell',
'id' => $link
]);
if (!$doc) throw $this->createNotFoundException();
$bid = $entityManager->getRepository(Business::class)->find($bid);
if (!$bid) throw $this->createNotFoundException();
$person = null;
$discount = 0;
$transfer = 0;
foreach ($doc->getHesabdariRows() as $item) {
if ($item->getPerson()) {
$person = $item->getPerson();
} elseif ($item->getRef()->getCode() == 104) {
$discount = $item->getBd();
} elseif ($item->getRef()->getCode() == 61) {
$transfer = $item->getBs();
}
}
$printOptions = [
'bidInfo' => true,
'pays' =>true,
'taxInfo' =>true,
'discountInfo' =>true,
'note' =>true,
'paper' =>'A4-L'
];
$note = '';
$printSettings = $entityManager->getRepository(PrintOptions::class)->findOneBy(['bid'=>$bid]);
if($printSettings){$note = $printSettings->getSellNoteString();}
$pdfPid = $provider->createPrint(
$bid,
$this->getUser(),
$this->renderView('pdf/printers/sell.html.twig', [
'bid' => $bid,
'doc' => $doc,
'rows' => $doc->getHesabdariRows(),
'person' => $person,
'discount' => $discount,
'transfer' => $transfer,
'printOptions'=> $printOptions,
'note'=> $note
]),
false,
$printOptions['paper']
);
return $this->redirectToRoute('app_front_print',['id'=>$pdfPid]);
}
} }

View file

@ -10,13 +10,10 @@
<div class="bg-body-light d-print-none"> <div class="bg-body-light d-print-none">
<div class="content content-full"> <div class="content content-full">
<div class="d-flex flex-column flex-sm-row justify-content-sm-between align-items-sm-center"> <div class="d-flex flex-column flex-sm-row justify-content-sm-between align-items-sm-center">
<img src="/front/avatar/file/get/{{bid.id}}" class="img-fluid" width="80">
<h2 class="flex-grow-1 fs-3 fw-semibold my-2 my-sm-3"> <h2 class="flex-grow-1 fs-3 fw-semibold my-2 my-sm-3">
مشاهده فاکتور مشاهده فاکتور
</h2> </h2>
<a class="btn btn-alt-primary my-2" href="https://hesabix.ir">
<i class="fa fa-fw fa-door-open me-1"></i>
ورود به حسابیکس
</a>
</div> </div>
</div> </div>
</div> </div>
@ -36,10 +33,10 @@
</h3> </h3>
<div class="block-options"> <div class="block-options">
<!-- Print Page functionality is initialized dmPrint() --> <!-- Print Page functionality is initialized dmPrint() -->
<button class="btn btn-sm btn-alt-secondary me-3" onclick="Dashmix.helpers('dm-print');" type="button"> <a class="btn btn-sm btn-alt-secondary me-3" type="button" target="_blank" href="{{path('shortlinks_pdf',{bid:bid.id,link:link})}}">
<i class="si si-printer me-1"></i> <i class="si si-printer me-1"></i>
چاپ فاکتور چاپ فاکتور
</button> </a>
{% if (totalPays < doc.amount) and bid.walletEnable %} {% if (totalPays < doc.amount) and bid.walletEnable %}
<a href="{{ path('pay_sell',{'id':doc.id}) }}" class="btn btn-sm btn-success"> <a href="{{ path('pay_sell',{'id':doc.id}) }}" class="btn btn-sm btn-success">
<i class="fa fa-credit-card"></i> <i class="fa fa-credit-card"></i>
@ -177,6 +174,10 @@
</div> </div>
<!-- END Table --> <!-- END Table -->
<div class="block block-rounded"> <div class="block block-rounded">
جمع کل فاکتور:
{{ doc.amount | number_format }}
</div>
<div class="block block-rounded">
توضیحات: توضیحات:
{{ doc.des }} {{ doc.des }}
</div> </div>