add footer note not admin area
This commit is contained in:
parent
5470b82951
commit
39c1deb5a0
|
@ -83,7 +83,7 @@ services:
|
||||||
|
|
||||||
twigFunctions:
|
twigFunctions:
|
||||||
class: App\Service\twigFunctions
|
class: App\Service\twigFunctions
|
||||||
arguments: [ '@doctrine.orm.entity_manager' ]
|
arguments: [ '@doctrine.orm.entity_manager', '@request_stack', '@registryMGR' ]
|
||||||
|
|
||||||
registryMGR:
|
registryMGR:
|
||||||
class: App\Service\registryMGR
|
class: App\Service\registryMGR
|
||||||
|
|
|
@ -9,6 +9,9 @@ use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
|
||||||
use Symfony\Component\HttpFoundation\JsonResponse;
|
use Symfony\Component\HttpFoundation\JsonResponse;
|
||||||
use Symfony\Component\HttpFoundation\Request;
|
use Symfony\Component\HttpFoundation\Request;
|
||||||
use Symfony\Component\Routing\Annotation\Route;
|
use Symfony\Component\Routing\Annotation\Route;
|
||||||
|
use Symfony\Component\HttpFoundation\BinaryFileResponse;
|
||||||
|
use App\Service\Provider;
|
||||||
|
use App\Entity\HesabdariDoc;
|
||||||
|
|
||||||
class CostController extends AbstractController
|
class CostController extends AbstractController
|
||||||
{
|
{
|
||||||
|
@ -311,4 +314,155 @@ class CostController extends AbstractController
|
||||||
'limit' => $limit
|
'limit' => $limit
|
||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[Route('/api/costs/list/print', name: 'app_costs_list_print')]
|
||||||
|
public function app_costs_list_print(
|
||||||
|
Provider $provider,
|
||||||
|
Request $request,
|
||||||
|
Access $access,
|
||||||
|
EntityManagerInterface $entityManager
|
||||||
|
): JsonResponse {
|
||||||
|
$acc = $access->hasRole('cost');
|
||||||
|
if (!$acc) {
|
||||||
|
throw $this->createAccessDeniedException();
|
||||||
|
}
|
||||||
|
|
||||||
|
$params = json_decode($request->getContent(), true) ?? [];
|
||||||
|
|
||||||
|
// دریافت آیتمهای انتخاب شده یا همه آیتمها
|
||||||
|
if (!isset($params['items'])) {
|
||||||
|
$items = $entityManager->getRepository(HesabdariDoc::class)->findBy([
|
||||||
|
'bid' => $acc['bid'],
|
||||||
|
'type' => 'cost',
|
||||||
|
'year' => $acc['year'],
|
||||||
|
'money' => $acc['money']
|
||||||
|
]);
|
||||||
|
} else {
|
||||||
|
$items = [];
|
||||||
|
foreach ($params['items'] as $param) {
|
||||||
|
$doc = $entityManager->getRepository(HesabdariDoc::class)->findOneBy([
|
||||||
|
'id' => $param['id'],
|
||||||
|
'bid' => $acc['bid'],
|
||||||
|
'type' => 'cost',
|
||||||
|
'year' => $acc['year'],
|
||||||
|
'money' => $acc['money']
|
||||||
|
]);
|
||||||
|
if ($doc) {
|
||||||
|
$items[] = $doc;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
$pid = $provider->createPrint(
|
||||||
|
$acc['bid'],
|
||||||
|
$this->getUser(),
|
||||||
|
$this->renderView('pdf/costs.html.twig', [
|
||||||
|
'page_title' => 'فهرست هزینهها',
|
||||||
|
'bid' => $acc['bid'],
|
||||||
|
'items' => $items
|
||||||
|
])
|
||||||
|
);
|
||||||
|
|
||||||
|
return $this->json(['id' => $pid]);
|
||||||
|
}
|
||||||
|
|
||||||
|
#[Route('/api/costs/list/excel', name: 'app_costs_list_excel')]
|
||||||
|
public function app_costs_list_excel(
|
||||||
|
Provider $provider,
|
||||||
|
Request $request,
|
||||||
|
Access $access,
|
||||||
|
EntityManagerInterface $entityManager
|
||||||
|
): BinaryFileResponse {
|
||||||
|
$acc = $access->hasRole('cost');
|
||||||
|
if (!$acc) {
|
||||||
|
throw $this->createAccessDeniedException();
|
||||||
|
}
|
||||||
|
|
||||||
|
$params = json_decode($request->getContent(), true) ?? [];
|
||||||
|
|
||||||
|
// دریافت آیتمهای انتخاب شده یا همه آیتمها
|
||||||
|
if (!isset($params['items'])) {
|
||||||
|
$items = $entityManager->getRepository(HesabdariDoc::class)->findBy([
|
||||||
|
'bid' => $acc['bid'],
|
||||||
|
'type' => 'cost',
|
||||||
|
'year' => $acc['year'],
|
||||||
|
'money' => $acc['money']
|
||||||
|
]);
|
||||||
|
} else {
|
||||||
|
$items = [];
|
||||||
|
foreach ($params['items'] as $param) {
|
||||||
|
$doc = $entityManager->getRepository(HesabdariDoc::class)->findOneBy([
|
||||||
|
'id' => $param['id'],
|
||||||
|
'bid' => $acc['bid'],
|
||||||
|
'type' => 'cost',
|
||||||
|
'year' => $acc['year'],
|
||||||
|
'money' => $acc['money']
|
||||||
|
]);
|
||||||
|
if ($doc) {
|
||||||
|
$items[] = $doc;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// ایجاد فایل اکسل
|
||||||
|
$spreadsheet = new \PhpOffice\PhpSpreadsheet\Spreadsheet();
|
||||||
|
$sheet = $spreadsheet->getActiveSheet();
|
||||||
|
$sheet->setRightToLeft(true);
|
||||||
|
|
||||||
|
// تنظیم هدرها
|
||||||
|
$sheet->setCellValue('A1', 'ردیف')
|
||||||
|
->setCellValue('B1', 'شماره سند')
|
||||||
|
->setCellValue('C1', 'تاریخ')
|
||||||
|
->setCellValue('D1', 'شرح')
|
||||||
|
->setCellValue('E1', 'مرکز هزینه')
|
||||||
|
->setCellValue('F1', 'مرکز پرداخت')
|
||||||
|
->setCellValue('G1', 'مبلغ (ریال)');
|
||||||
|
|
||||||
|
// پر کردن دادهها
|
||||||
|
$rowNumber = 2;
|
||||||
|
foreach ($items as $index => $item) {
|
||||||
|
// محاسبه مراکز هزینه
|
||||||
|
$costCenters = [];
|
||||||
|
foreach ($item->getHesabdariRows() as $row) {
|
||||||
|
if ($row->getRef()) {
|
||||||
|
$costCenters[] = $row->getRef()->getName();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
$costCenterNames = implode('، ', array_unique($costCenters));
|
||||||
|
|
||||||
|
// محاسبه مرکز پرداخت
|
||||||
|
$paymentCenter = null;
|
||||||
|
foreach ($item->getHesabdariRows() as $row) {
|
||||||
|
if (!$paymentCenter) {
|
||||||
|
if ($row->getBank()) {
|
||||||
|
$paymentCenter = $row->getBank()->getName();
|
||||||
|
} elseif ($row->getCashdesk()) {
|
||||||
|
$paymentCenter = $row->getCashdesk()->getName();
|
||||||
|
} elseif ($row->getSalary()) {
|
||||||
|
$paymentCenter = $row->getSalary()->getName();
|
||||||
|
} elseif ($row->getCommodity()) {
|
||||||
|
$paymentCenter = $row->getCommodity()->getName();
|
||||||
|
} elseif ($row->getPerson()) {
|
||||||
|
$paymentCenter = $row->getPerson()->getNikename();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
$sheet->setCellValue('A' . $rowNumber, $index + 1)
|
||||||
|
->setCellValue('B' . $rowNumber, $item->getCode())
|
||||||
|
->setCellValue('C' . $rowNumber, $item->getDate())
|
||||||
|
->setCellValue('D' . $rowNumber, $item->getDes())
|
||||||
|
->setCellValue('E' . $rowNumber, $costCenterNames)
|
||||||
|
->setCellValue('F' . $rowNumber, $paymentCenter)
|
||||||
|
->setCellValue('G' . $rowNumber, number_format($item->getAmount()));
|
||||||
|
$rowNumber++;
|
||||||
|
}
|
||||||
|
|
||||||
|
// ذخیره فایل اکسل
|
||||||
|
$writer = new \PhpOffice\PhpSpreadsheet\Writer\Xlsx($spreadsheet);
|
||||||
|
$filePath = __DIR__ . '/../../var/' . uniqid() . '.xlsx';
|
||||||
|
$writer->save($filePath);
|
||||||
|
|
||||||
|
return new BinaryFileResponse($filePath);
|
||||||
|
}
|
||||||
}
|
}
|
|
@ -51,6 +51,8 @@ final class RegistrySettingsController extends AbstractController
|
||||||
'smsAlertEnabled' => filter_var($registryMGR->get($rootSystem, 'sms_alert_enabled'), FILTER_VALIDATE_BOOLEAN),
|
'smsAlertEnabled' => filter_var($registryMGR->get($rootSystem, 'sms_alert_enabled'), FILTER_VALIDATE_BOOLEAN),
|
||||||
'smsAlertMobile' => $registryMGR->get($rootTicket, 'managerMobile'),
|
'smsAlertMobile' => $registryMGR->get($rootTicket, 'managerMobile'),
|
||||||
'sponsorMessage' => $registryMGR->get('system', 'sponsers'),
|
'sponsorMessage' => $registryMGR->get('system', 'sponsers'),
|
||||||
|
'footerLeft' => $registryMGR->get('system', 'footerLeft'),
|
||||||
|
'footerRight' => $registryMGR->get('system', 'footerRight'),
|
||||||
|
|
||||||
];
|
];
|
||||||
|
|
||||||
|
@ -78,7 +80,8 @@ final class RegistrySettingsController extends AbstractController
|
||||||
$registryMGR->update($rootSystem, 'sms_alert_enabled', $data['smsAlertEnabled'] ? '1' : '0');
|
$registryMGR->update($rootSystem, 'sms_alert_enabled', $data['smsAlertEnabled'] ? '1' : '0');
|
||||||
$registryMGR->update($rootTicket, 'managerMobile', $data['smsAlertMobile'] ?? '');
|
$registryMGR->update($rootTicket, 'managerMobile', $data['smsAlertMobile'] ?? '');
|
||||||
$registryMGR->update('system', 'sponsers', $data['sponsorMessage'] ?? '');
|
$registryMGR->update('system', 'sponsers', $data['sponsorMessage'] ?? '');
|
||||||
|
$registryMGR->update('system', 'footerLeft', $data['footerLeft'] ?? '');
|
||||||
|
$registryMGR->update('system', 'footerRight', $data['footerRight'] ?? '');
|
||||||
|
|
||||||
return new JsonResponse([
|
return new JsonResponse([
|
||||||
'result' => 1,
|
'result' => 1,
|
||||||
|
|
|
@ -18,15 +18,22 @@ class twigFunctions
|
||||||
|
|
||||||
protected $request;
|
protected $request;
|
||||||
protected RequestStack $requestStack;
|
protected RequestStack $requestStack;
|
||||||
|
protected registryMGR $registryMGR;
|
||||||
function __construct(
|
function __construct(
|
||||||
EntityManagerInterface $entityManager,
|
EntityManagerInterface $entityManager,
|
||||||
RequestStack $request
|
RequestStack $request,
|
||||||
|
registryMGR $registryMGR
|
||||||
) {
|
) {
|
||||||
$this->request = $request->getCurrentRequest();
|
$this->request = $request->getCurrentRequest();
|
||||||
$this->em = $entityManager;
|
$this->em = $entityManager;
|
||||||
|
$this->registryMGR = $registryMGR;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//get static data from registry
|
||||||
|
public function getStaticData($root,$key)
|
||||||
|
{
|
||||||
|
return $this->registryMGR->get($root, $key);
|
||||||
|
}
|
||||||
|
|
||||||
public function md5($val)
|
public function md5($val)
|
||||||
{
|
{
|
||||||
|
|
72
hesabixCore/templates/pdf/costs.html.twig
Normal file
72
hesabixCore/templates/pdf/costs.html.twig
Normal file
|
@ -0,0 +1,72 @@
|
||||||
|
{% extends 'pdf/base.html.twig' %}
|
||||||
|
|
||||||
|
{% block body %}
|
||||||
|
<table class="table" style="border:2px solid black; width:100%; border-collapse: collapse; margin-top: 20px;">
|
||||||
|
<tbody>
|
||||||
|
<tr style="text-align: center; background-color: #6B7280; color: #ffffff; height: 45px; font-weight: bold;">
|
||||||
|
<td style="width: 5%; border:1px solid black;">ردیف</td>
|
||||||
|
<th style="width: 10%; border:1px solid black;">شماره سند</th>
|
||||||
|
<th style="width: 10%; border:1px solid black;">تاریخ</th>
|
||||||
|
<th style="width: 25%; border:1px solid black;">شرح</th>
|
||||||
|
<th style="width: 20%; border:1px solid black;">مرکز هزینه</th>
|
||||||
|
<th style="width: 15%; border:1px solid black;">مرکز پرداخت</th>
|
||||||
|
<th style="width: 15%; border:1px solid black;">مبلغ (ریال)</th>
|
||||||
|
</tr>
|
||||||
|
{% for item in items %}
|
||||||
|
<tr style="border:1px solid black; height: 35px;" {% if loop.index is even %}style="background-color: #f8f9fa;"{% endif %}>
|
||||||
|
<td style="border:1px solid black; text-align: center;">{{ loop.index }}</td>
|
||||||
|
<td style="border:1px solid black; text-align: center;">{{ item.code }}</td>
|
||||||
|
<td style="border:1px solid black; text-align: center;">{{ item.date }}</td>
|
||||||
|
<td style="border:1px solid black; padding: 5px 10px;">{{ item.des }}</td>
|
||||||
|
<td style="border:1px solid black; padding: 5px 10px;">
|
||||||
|
{% set costCenters = [] %}
|
||||||
|
{% for row in item.hesabdariRows %}
|
||||||
|
{% if row.ref %}
|
||||||
|
{% if not row.bank and not row.commodity and not row.cheque and not row.salary and not row.cashdesk and not row.person %}
|
||||||
|
{% set costCenters = costCenters|merge([row.ref.name]) %}
|
||||||
|
{% endif %}
|
||||||
|
{% endif %}
|
||||||
|
{% endfor %}
|
||||||
|
{{ costCenters|join('، ') }}
|
||||||
|
</td>
|
||||||
|
<td style="border:1px solid black; padding: 5px 10px;">
|
||||||
|
{% set paymentCenter = null %}
|
||||||
|
{% for row in item.hesabdariRows %}
|
||||||
|
{% if not paymentCenter %}
|
||||||
|
{% if row.bank %}
|
||||||
|
{% set paymentCenter = row.bank.name %}
|
||||||
|
{% elseif row.cashdesk %}
|
||||||
|
{% set paymentCenter = row.cashdesk.name %}
|
||||||
|
{% elseif row.salary %}
|
||||||
|
{% set paymentCenter = row.salary.name %}
|
||||||
|
{% elseif row.commodity %}
|
||||||
|
{% set paymentCenter = row.commodity.name %}
|
||||||
|
{% elseif row.person %}
|
||||||
|
{% set paymentCenter = row.person.nikename %}
|
||||||
|
{% endif %}
|
||||||
|
{% endif %}
|
||||||
|
{% endfor %}
|
||||||
|
{{ paymentCenter }}
|
||||||
|
</td>
|
||||||
|
<td style="border:1px solid black; text-align: left; padding-left: 10px;">{{ item.amount|number_format }}</td>
|
||||||
|
</tr>
|
||||||
|
{% endfor %}
|
||||||
|
|
||||||
|
{# جمع کل #}
|
||||||
|
<tr style="background-color: #6B7280; color: #ffffff; height: 45px; font-weight: bold;">
|
||||||
|
<td colspan="6" style="border:1px solid black; text-align: left; padding-left: 15px;">جمع کل:</td>
|
||||||
|
<td style="border:1px solid black; text-align: left; padding-left: 10px;">
|
||||||
|
{{ items|reduce((sum, item) => sum + item.amount, 0)|number_format }}
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
|
</tbody>
|
||||||
|
</table>
|
||||||
|
|
||||||
|
{# اطلاعات تکمیلی #}
|
||||||
|
<div style="margin-top: 20px; font-size: 12px;">
|
||||||
|
<p>تعداد اسناد: {{ items|length }} مورد</p>
|
||||||
|
{% if items|length > 0 %}
|
||||||
|
<p>از تاریخ: {{ items|first.date }} تا تاریخ: {{ items|last.date }}</p>
|
||||||
|
{% endif %}
|
||||||
|
</div>
|
||||||
|
{% endblock %}
|
|
@ -12,7 +12,7 @@
|
||||||
<thead>
|
<thead>
|
||||||
<tr>
|
<tr>
|
||||||
<td style="width:30%;text-align:center;">
|
<td style="width:30%;text-align:center;">
|
||||||
حسابداری آنلاین حسابیکس
|
{{ twigFunctions.getStaticData('system', 'footerLeft') }}
|
||||||
</td>
|
</td>
|
||||||
<td style="width:40%; text-align:center">
|
<td style="width:40%; text-align:center">
|
||||||
صفحه:
|
صفحه:
|
||||||
|
@ -21,7 +21,7 @@
|
||||||
{nbpg}
|
{nbpg}
|
||||||
</td>
|
</td>
|
||||||
<td style="width:30%;text-align:center;">
|
<td style="width:30%;text-align:center;">
|
||||||
Hesabix.ir
|
{{ twigFunctions.getStaticData('system', 'footerRight') }}
|
||||||
</td>
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
</thead>
|
</thead>
|
||||||
|
|
Loading…
Reference in a new issue