some progress and bug fix
This commit is contained in:
parent
0d35ed9b7c
commit
49eb437fd7
|
@ -431,6 +431,10 @@ class BusinessController extends AbstractController
|
||||||
'archiveView' => true,
|
'archiveView' => true,
|
||||||
'active' => $perm->getUser()->isActive(),
|
'active' => $perm->getUser()->isActive(),
|
||||||
'shareholder' => true,
|
'shareholder' => true,
|
||||||
|
'plugAccproAccounting'=>true,
|
||||||
|
'plugAccproRfsell'=>true,
|
||||||
|
'plugAccproRfbuy'=>true,
|
||||||
|
'plugAccproCloseYear'=>true,
|
||||||
];
|
];
|
||||||
} elseif ($perm) {
|
} elseif ($perm) {
|
||||||
$result = [
|
$result = [
|
||||||
|
@ -466,6 +470,10 @@ class BusinessController extends AbstractController
|
||||||
'archiveView' => $perm->isArchiveView(),
|
'archiveView' => $perm->isArchiveView(),
|
||||||
'active' => $perm->getUser()->isActive(),
|
'active' => $perm->getUser()->isActive(),
|
||||||
'shareholder' => $perm->isShareholder(),
|
'shareholder' => $perm->isShareholder(),
|
||||||
|
'plugAccproAccounting'=>$perm->isPlugAccproAccounting(),
|
||||||
|
'plugAccproRfsell'=>$perm->isPlugAccproRfsell(),
|
||||||
|
'plugAccproRfbuy'=>$perm->isPlugAccproRfbuy(),
|
||||||
|
'plugAccproCloseYear'=>$perm->isPlugAccproCloseYear(),
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
return $this->json($result);
|
return $this->json($result);
|
||||||
|
@ -529,6 +537,10 @@ class BusinessController extends AbstractController
|
||||||
$perm->setArchiveUpload($params['archiveUpload']);
|
$perm->setArchiveUpload($params['archiveUpload']);
|
||||||
$perm->setArchiveView($params['archiveView']);
|
$perm->setArchiveView($params['archiveView']);
|
||||||
$perm->setShareholder($params['shareholder']);
|
$perm->setShareholder($params['shareholder']);
|
||||||
|
$perm->setPlugAccproCloseYear($params['plugAccproCloseYear']);
|
||||||
|
$perm->setPlugAccproRfbuy($params['plugAccproRfbuy']);
|
||||||
|
$perm->setPlugAccproRfsell($params['plugAccproRfsell']);
|
||||||
|
$perm->setPlugAccproAccounting($params['plugAccproAccounting']);
|
||||||
$entityManager->persist($perm);
|
$entityManager->persist($perm);
|
||||||
$entityManager->flush();
|
$entityManager->flush();
|
||||||
$log->insert('تنظیمات پایه', 'ویرایش دسترسیهای کاربر با پست الکترونیکی ' . $user->getEmail(), $this->getUser(), $business);
|
$log->insert('تنظیمات پایه', 'ویرایش دسترسیهای کاربر با پست الکترونیکی ' . $user->getEmail(), $this->getUser(), $business);
|
||||||
|
|
|
@ -405,7 +405,6 @@ class CommodityController extends AbstractController
|
||||||
#[Route('/api/commodity/cat/get/line', name: 'app_commodity_cat_get_line')]
|
#[Route('/api/commodity/cat/get/line', name: 'app_commodity_cat_get_line')]
|
||||||
public function app_commodity_cat_get_line(Jdate $jdate, Provider $provider, Request $request, Access $access, Log $log, EntityManagerInterface $entityManager): JsonResponse
|
public function app_commodity_cat_get_line(Jdate $jdate, Provider $provider, Request $request, Access $access, Log $log, EntityManagerInterface $entityManager): JsonResponse
|
||||||
{
|
{
|
||||||
|
|
||||||
$acc = $access->hasRole('commodity');
|
$acc = $access->hasRole('commodity');
|
||||||
if (!$acc)
|
if (!$acc)
|
||||||
throw $this->createAccessDeniedException();
|
throw $this->createAccessDeniedException();
|
||||||
|
|
|
@ -183,10 +183,10 @@ class HesabdariController extends AbstractController
|
||||||
elseif($params['type'] == 'cost') $roll='cost';
|
elseif($params['type'] == 'cost') $roll='cost';
|
||||||
elseif($params['type'] == 'income') $roll='income';
|
elseif($params['type'] == 'income') $roll='income';
|
||||||
elseif($params['type'] == 'buy') $roll='buy';
|
elseif($params['type'] == 'buy') $roll='buy';
|
||||||
elseif($params['type'] == 'buy_rfb') $roll='buy';
|
elseif($params['type'] == 'rfbuy') $roll='plugAccproRfbuy';
|
||||||
elseif($params['type'] == 'transfer') $roll='transfer';
|
elseif($params['type'] == 'transfer') $roll='transfer';
|
||||||
elseif($params['type'] == 'sell') $roll='sell';
|
elseif($params['type'] == 'sell') $roll='sell';
|
||||||
elseif($params['type'] == 'sell_rbs') $roll='buy';
|
elseif($params['type'] == 'rfsell') $roll='plugAccproRfsell';
|
||||||
elseif($params['type'] == 'all') $roll='accounting';
|
elseif($params['type'] == 'all') $roll='accounting';
|
||||||
else
|
else
|
||||||
$this->createNotFoundException();
|
$this->createNotFoundException();
|
||||||
|
@ -223,7 +223,7 @@ class HesabdariController extends AbstractController
|
||||||
'amount'=>$item->getAmount(),
|
'amount'=>$item->getAmount(),
|
||||||
'submitter'=> $item->getSubmitter()->getFullName(),
|
'submitter'=> $item->getSubmitter()->getFullName(),
|
||||||
];
|
];
|
||||||
if($params['type'] == 'sell_rbs' || $params['type'] == 'buy_rfb' || $params['type'] == 'buy' || $params['type'] == 'sell'){
|
if($params['type'] == 'rfsell' || $params['type'] == 'rfbuy' || $params['type'] == 'buy' || $params['type'] == 'sell'){
|
||||||
$mainRow = $entityManager->getRepository(HesabdariRow::class)->getNotEqual($item,'person');
|
$mainRow = $entityManager->getRepository(HesabdariRow::class)->getNotEqual($item,'person');
|
||||||
$temp['person'] = '';
|
$temp['person'] = '';
|
||||||
if($mainRow)
|
if($mainRow)
|
||||||
|
|
|
@ -10,6 +10,7 @@ use App\Service\Provider;
|
||||||
use App\Entity\HesabdariDoc;
|
use App\Entity\HesabdariDoc;
|
||||||
use App\Entity\HesabdariRow;
|
use App\Entity\HesabdariRow;
|
||||||
use App\Service\Explore;
|
use App\Service\Explore;
|
||||||
|
use App\Service\Jdate;
|
||||||
use Doctrine\ORM\EntityManagerInterface;
|
use Doctrine\ORM\EntityManagerInterface;
|
||||||
use Symfony\Component\HttpFoundation\Request;
|
use Symfony\Component\HttpFoundation\Request;
|
||||||
use Symfony\Component\Routing\Annotation\Route;
|
use Symfony\Component\Routing\Annotation\Route;
|
||||||
|
@ -21,7 +22,7 @@ use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
|
||||||
class ReportController extends AbstractController
|
class ReportController extends AbstractController
|
||||||
{
|
{
|
||||||
#[Route('/api/report/person/buysell', name: 'app_report_person_buysell')]
|
#[Route('/api/report/person/buysell', name: 'app_report_person_buysell')]
|
||||||
public function app_report_person_buysell(Access $access, Request $request, EntityManagerInterface $entityManagerInterface): JsonResponse
|
public function app_report_person_buysell(Provider $provider, Jdate $jdate, Access $access, Request $request, EntityManagerInterface $entityManagerInterface): JsonResponse
|
||||||
{
|
{
|
||||||
$acc = $access->hasRole('report');
|
$acc = $access->hasRole('report');
|
||||||
if (!$acc) {
|
if (!$acc) {
|
||||||
|
@ -32,11 +33,34 @@ class ReportController extends AbstractController
|
||||||
if ($content = $request->getContent()) {
|
if ($content = $request->getContent()) {
|
||||||
$params = json_decode($content, true);
|
$params = json_decode($content, true);
|
||||||
}
|
}
|
||||||
|
if ($params['type'] == 'all') {
|
||||||
|
$docs = $entityManagerInterface->getRepository(HesabdariDoc::class)->findBy([
|
||||||
|
'year' => $acc['year'],
|
||||||
|
'bid' => $acc['bid'],
|
||||||
|
]);
|
||||||
|
} else {
|
||||||
$docs = $entityManagerInterface->getRepository(HesabdariDoc::class)->findBy([
|
$docs = $entityManagerInterface->getRepository(HesabdariDoc::class)->findBy([
|
||||||
'year' => $acc['year'],
|
'year' => $acc['year'],
|
||||||
'bid' => $acc['bid'],
|
'bid' => $acc['bid'],
|
||||||
'type' => $params['type'],
|
'type' => $params['type'],
|
||||||
]);
|
]);
|
||||||
|
}
|
||||||
|
//filter docs by date
|
||||||
|
$result = [];
|
||||||
|
$dateStart = $provider->shamsiDateToTimestamp($params['dateStart']);
|
||||||
|
$dateEnd = $provider->shamsiDateToTimestamp($params['dateEnd']);
|
||||||
|
foreach ($docs as $doc) {
|
||||||
|
$canAdd = true;
|
||||||
|
if ($dateStart) {
|
||||||
|
if ($provider->shamsiDateToTimestamp($doc->getDate()) < $dateStart) $canAdd = false;
|
||||||
|
}
|
||||||
|
if ($dateEnd) {
|
||||||
|
if ($provider->shamsiDateToTimestamp($doc->getDate()) > $dateEnd) $canAdd = false;
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($canAdd) $result[] = $doc;
|
||||||
|
}
|
||||||
|
$docs = $result;
|
||||||
|
|
||||||
$person = $entityManagerInterface->getRepository(Person::class)->findOneBy([
|
$person = $entityManagerInterface->getRepository(Person::class)->findOneBy([
|
||||||
'bid' => $acc['bid']->getId(),
|
'bid' => $acc['bid']->getId(),
|
||||||
|
@ -77,11 +101,12 @@ class ReportController extends AbstractController
|
||||||
'docCode' => $item->getDoc()->getCode(),
|
'docCode' => $item->getDoc()->getCode(),
|
||||||
'type' => $item->getDoc()->getType()
|
'type' => $item->getDoc()->getType()
|
||||||
];
|
];
|
||||||
if ($params['type'] == 'buy') {
|
if ($item->getDoc()->getType() == 'buy' || $item->getDoc()->getType() == 'rfsell') {
|
||||||
$temp['priceAll'] = $item->getBd();
|
$temp['priceAll'] = $item->getBd();
|
||||||
} elseif ($params['type'] == 'sell') {
|
} elseif ($item->getDoc()->getType() == 'sell' || $item->getDoc()->getType() == 'rfbuy') {
|
||||||
$temp['priceAll'] = $item->getBs();
|
$temp['priceAll'] = $item->getBs();
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($temp['count'] != 0) {
|
if ($temp['count'] != 0) {
|
||||||
$temp['priceOne'] = $temp['priceAll'] / $temp['count'];
|
$temp['priceOne'] = $temp['priceAll'] / $temp['count'];
|
||||||
$temp['priceAll'] = number_format($temp['priceAll']);
|
$temp['priceAll'] = number_format($temp['priceAll']);
|
||||||
|
@ -147,7 +172,7 @@ class ReportController extends AbstractController
|
||||||
}
|
}
|
||||||
|
|
||||||
#[Route('/api/report/commodity/buysell', name: 'app_report_commodity_buysell')]
|
#[Route('/api/report/commodity/buysell', name: 'app_report_commodity_buysell')]
|
||||||
public function app_report_commodity_buysell(Access $access, Request $request, EntityManagerInterface $entityManagerInterface): JsonResponse
|
public function app_report_commodity_buysell(Provider $provider, Jdate $jdate, Access $access, Request $request, EntityManagerInterface $entityManagerInterface): JsonResponse
|
||||||
{
|
{
|
||||||
$acc = $access->hasRole('report');
|
$acc = $access->hasRole('report');
|
||||||
if (!$acc) {
|
if (!$acc) {
|
||||||
|
@ -176,11 +201,28 @@ class ReportController extends AbstractController
|
||||||
'bid' => $acc['bid']->getId(),
|
'bid' => $acc['bid']->getId(),
|
||||||
'code' => $params['commodity'],
|
'code' => $params['commodity'],
|
||||||
]);
|
]);
|
||||||
|
//filter docs by date
|
||||||
|
$result = [];
|
||||||
|
$dateStart = $provider->shamsiDateToTimestamp($params['dateStart']);
|
||||||
|
$dateEnd = $provider->shamsiDateToTimestamp($params['dateEnd']);
|
||||||
|
foreach ($docs as $doc) {
|
||||||
|
$canAdd = true;
|
||||||
|
if ($dateStart) {
|
||||||
|
if ($provider->shamsiDateToTimestamp($doc->getDate()) < $dateStart) $canAdd = false;
|
||||||
|
}
|
||||||
|
if ($dateEnd) {
|
||||||
|
if ($provider->shamsiDateToTimestamp($doc->getDate()) > $dateEnd) $canAdd = false;
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($canAdd) $result[] = $doc;
|
||||||
|
}
|
||||||
|
$docs = $result;
|
||||||
$result = [];
|
$result = [];
|
||||||
foreach ($docs as $doc) {
|
foreach ($docs as $doc) {
|
||||||
$rows = $doc->getHesabdariRows();
|
$rows = $doc->getHesabdariRows();
|
||||||
foreach ($rows as $row) {
|
foreach ($rows as $row) {
|
||||||
if ($row->getCommodity() && $row->getCommodity()->getId() == $commodity->getId()) {
|
if ($row->getCommodity())
|
||||||
|
if ($row->getCommodity()->getId() == $commodity->getId()) {
|
||||||
$result[] = $row;
|
$result[] = $row;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -200,9 +242,9 @@ class ReportController extends AbstractController
|
||||||
'docCode' => $item->getDoc()->getCode(),
|
'docCode' => $item->getDoc()->getCode(),
|
||||||
'type' => $item->getDoc()->getType(),
|
'type' => $item->getDoc()->getType(),
|
||||||
];
|
];
|
||||||
if ($item->getDoc()->getType() == 'buy') {
|
if ($item->getDoc()->getType() == 'buy' || $item->getDoc()->getType() == 'rfsell') {
|
||||||
$temp['priceAll'] = $item->getBd();
|
$temp['priceAll'] = $item->getBd();
|
||||||
} elseif ($item->getDoc()->getType() == 'sell') {
|
} elseif ($item->getDoc()->getType() == 'sell' || $item->getDoc()->getType() == 'rfbuy') {
|
||||||
$temp['priceAll'] = $item->getBs();
|
$temp['priceAll'] = $item->getBs();
|
||||||
}
|
}
|
||||||
if ($temp['count'] != 0) {
|
if ($temp['count'] != 0) {
|
||||||
|
|
59
hesabixCore/src/Controller/RfbuyController.php
Normal file
59
hesabixCore/src/Controller/RfbuyController.php
Normal file
|
@ -0,0 +1,59 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Controller;
|
||||||
|
|
||||||
|
use App\Service\Log;
|
||||||
|
use App\Service\Access;
|
||||||
|
use App\Service\Explore;
|
||||||
|
use App\Entity\HesabdariDoc;
|
||||||
|
use App\Entity\StoreroomTicket;
|
||||||
|
use Doctrine\ORM\EntityManagerInterface;
|
||||||
|
use Symfony\Component\HttpFoundation\Request;
|
||||||
|
use Symfony\Component\HttpFoundation\Response;
|
||||||
|
use Symfony\Component\Routing\Annotation\Route;
|
||||||
|
use Symfony\Component\HttpFoundation\JsonResponse;
|
||||||
|
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
|
||||||
|
|
||||||
|
class RfbuyController extends AbstractController
|
||||||
|
{
|
||||||
|
#[Route('/api/rfbuy/edit/can/{code}', name: 'app_rfbuy_can_edit')]
|
||||||
|
public function app_rfbuy_can_edit(Request $request,Access $access,Log $log,EntityManagerInterface $entityManager, string $code): JsonResponse
|
||||||
|
{
|
||||||
|
$canEdit = true;
|
||||||
|
$acc = $access->hasRole('plugAccproRfbuy');
|
||||||
|
if(!$acc)
|
||||||
|
throw $this->createAccessDeniedException();
|
||||||
|
|
||||||
|
$doc = $entityManager->getRepository(HesabdariDoc::class)->findOneBy([
|
||||||
|
'bid'=>$acc['bid'],
|
||||||
|
'code'=>$code
|
||||||
|
]);
|
||||||
|
//check related documents
|
||||||
|
if(count($doc->getRelatedDocs()) != 0)
|
||||||
|
$canEdit = false;
|
||||||
|
|
||||||
|
//check storeroom tickets
|
||||||
|
$tickets = $entityManager->getRepository(StoreroomTicket::class)->findBy(['doc'=>$doc]);
|
||||||
|
if(count($tickets) != 0)
|
||||||
|
$canEdit = false;
|
||||||
|
return $this->json([
|
||||||
|
'result'=> $canEdit
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
|
||||||
|
#[Route('/api/rfbuy/get/info/{code}', name: 'app_rfbuy_get_info')]
|
||||||
|
public function app_rfbuy_get_info(Request $request,Access $access,Log $log,EntityManagerInterface $entityManager, string $code): JsonResponse
|
||||||
|
{
|
||||||
|
$acc = $access->hasRole('plugAccproRfbuy');
|
||||||
|
if(!$acc)
|
||||||
|
throw $this->createAccessDeniedException();
|
||||||
|
$doc = $entityManager->getRepository(HesabdariDoc::class)->findOneBy([
|
||||||
|
'bid'=>$acc['bid'],
|
||||||
|
'code'=>$code
|
||||||
|
]);
|
||||||
|
if(!$doc)
|
||||||
|
throw $this->createNotFoundException();
|
||||||
|
|
||||||
|
return $this->json(Explore::ExploreSellDoc($doc));
|
||||||
|
}
|
||||||
|
}
|
18
hesabixCore/src/Controller/RfsellController.php
Normal file
18
hesabixCore/src/Controller/RfsellController.php
Normal file
|
@ -0,0 +1,18 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Controller;
|
||||||
|
|
||||||
|
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
|
||||||
|
use Symfony\Component\HttpFoundation\Response;
|
||||||
|
use Symfony\Component\Routing\Annotation\Route;
|
||||||
|
|
||||||
|
class RfsellController extends AbstractController
|
||||||
|
{
|
||||||
|
#[Route('/rfsell', name: 'app_rfsell')]
|
||||||
|
public function index(): Response
|
||||||
|
{
|
||||||
|
return $this->render('rfsell/index.html.twig', [
|
||||||
|
'controller_name' => 'RfsellController',
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
}
|
|
@ -105,6 +105,18 @@ class Permission
|
||||||
#[ORM\Column(nullable: true)]
|
#[ORM\Column(nullable: true)]
|
||||||
private ?bool $cheque = null;
|
private ?bool $cheque = null;
|
||||||
|
|
||||||
|
#[ORM\Column(nullable: true)]
|
||||||
|
private ?bool $plugAccproRfbuy = null;
|
||||||
|
|
||||||
|
#[ORM\Column(nullable: true)]
|
||||||
|
private ?bool $plugAccproRfsell = null;
|
||||||
|
|
||||||
|
#[ORM\Column(nullable: true)]
|
||||||
|
private ?bool $plugAccproAccounting = null;
|
||||||
|
|
||||||
|
#[ORM\Column(nullable: true)]
|
||||||
|
private ?bool $plugAccproCloseYear = null;
|
||||||
|
|
||||||
public function getId(): ?int
|
public function getId(): ?int
|
||||||
{
|
{
|
||||||
return $this->id;
|
return $this->id;
|
||||||
|
@ -469,4 +481,52 @@ class Permission
|
||||||
|
|
||||||
return $this;
|
return $this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function isPlugAccproRfbuy(): ?bool
|
||||||
|
{
|
||||||
|
return $this->plugAccproRfbuy;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function setPlugAccproRfbuy(?bool $plugAccproRfbuy): static
|
||||||
|
{
|
||||||
|
$this->plugAccproRfbuy = $plugAccproRfbuy;
|
||||||
|
|
||||||
|
return $this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function isPlugAccproRfsell(): ?bool
|
||||||
|
{
|
||||||
|
return $this->plugAccproRfsell;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function setPlugAccproRfsell(?bool $plugAccproRfsell): static
|
||||||
|
{
|
||||||
|
$this->plugAccproRfsell = $plugAccproRfsell;
|
||||||
|
|
||||||
|
return $this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function isPlugAccproAccounting(): ?bool
|
||||||
|
{
|
||||||
|
return $this->plugAccproAccounting;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function setPlugAccproAccounting(?bool $plugAccproAccounting): static
|
||||||
|
{
|
||||||
|
$this->plugAccproAccounting = $plugAccproAccounting;
|
||||||
|
|
||||||
|
return $this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function isPlugAccproCloseYear(): ?bool
|
||||||
|
{
|
||||||
|
return $this->plugAccproCloseYear;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function setPlugAccproCloseYear(?bool $plugAccproCloseYear): static
|
||||||
|
{
|
||||||
|
$this->plugAccproCloseYear = $plugAccproCloseYear;
|
||||||
|
|
||||||
|
return $this;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -46,8 +46,9 @@ class PersonRepository extends ServiceEntityRepository
|
||||||
public function searchByNikename(Business $bid,string $search,int $maxResults = 10): array
|
public function searchByNikename(Business $bid,string $search,int $maxResults = 10): array
|
||||||
{
|
{
|
||||||
return $this->createQueryBuilder('p')
|
return $this->createQueryBuilder('p')
|
||||||
->andWhere('p.bid = :val')
|
->andwhere('p.bid = :val')
|
||||||
->andWhere("p.nikename LIKE :search")
|
->andWhere("p.nikename LIKE :search")
|
||||||
|
->orWhere("p.mobile LIKE :search")
|
||||||
->setParameter('val', $bid)
|
->setParameter('val', $bid)
|
||||||
->setParameter('search', '%' . $search . '%')
|
->setParameter('search', '%' . $search . '%')
|
||||||
->setMaxResults($maxResults)
|
->setMaxResults($maxResults)
|
||||||
|
|
|
@ -29,7 +29,8 @@ class Provider
|
||||||
$this->entityManager = $entityManager;
|
$this->entityManager = $entityManager;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function createSearchParams(Request $request){
|
public function createSearchParams(Request $request)
|
||||||
|
{
|
||||||
$response = [];
|
$response = [];
|
||||||
$params = [];
|
$params = [];
|
||||||
if ($content = $request->getContent()) {
|
if ($content = $request->getContent()) {
|
||||||
|
@ -62,19 +63,23 @@ class Provider
|
||||||
return $response;
|
return $response;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function maxPages($params,$rowsAllCount){
|
public function maxPages($params, $rowsAllCount)
|
||||||
|
{
|
||||||
$res = $rowsAllCount / $params['count'];
|
$res = $rowsAllCount / $params['count'];
|
||||||
return is_float($res) ? (int)$res + 1 : $res;
|
return is_float($res) ? (int)$res + 1 : $res;
|
||||||
}
|
}
|
||||||
public function maxPagesWithPageCount($count,$rowsAllCount){
|
public function maxPagesWithPageCount($count, $rowsAllCount)
|
||||||
|
{
|
||||||
$res = $rowsAllCount / $count;
|
$res = $rowsAllCount / $count;
|
||||||
return is_float($res) ? (int)$res + 1 : $res;
|
return is_float($res) ? (int)$res + 1 : $res;
|
||||||
}
|
}
|
||||||
public function gravatarHash($email){
|
public function gravatarHash($email)
|
||||||
|
{
|
||||||
return md5(strtolower(trim($email)));
|
return md5(strtolower(trim($email)));
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getAccountingCode($bid,$part){
|
public function getAccountingCode($bid, $part)
|
||||||
|
{
|
||||||
$setter = 'set' . ucfirst($part) . 'Code';
|
$setter = 'set' . ucfirst($part) . 'Code';
|
||||||
$part = 'get' . ucfirst($part) . 'Code';
|
$part = 'get' . ucfirst($part) . 'Code';
|
||||||
|
|
||||||
|
@ -93,7 +98,8 @@ class Provider
|
||||||
/**
|
/**
|
||||||
* @throws ReflectionException
|
* @throws ReflectionException
|
||||||
*/
|
*/
|
||||||
public function Entity2Array($entity, int $deep = 1, array $ignores = []): null|array{
|
public function Entity2Array($entity, int $deep = 1, array $ignores = []): null|array
|
||||||
|
{
|
||||||
if (is_null($entity)) return [];
|
if (is_null($entity)) return [];
|
||||||
$result = [];
|
$result = [];
|
||||||
$methods = get_class_methods($entity);
|
$methods = get_class_methods($entity);
|
||||||
|
@ -102,8 +108,7 @@ class Provider
|
||||||
foreach ($methods as $method) {
|
foreach ($methods as $method) {
|
||||||
if (str_starts_with($method, 'get')) {
|
if (str_starts_with($method, 'get')) {
|
||||||
$getMethods[] = trim(trim($method));
|
$getMethods[] = trim(trim($method));
|
||||||
}
|
} elseif (str_starts_with($method, 'is')) {
|
||||||
elseif(str_starts_with($method, 'is')){
|
|
||||||
$getMethods[] = trim(trim($method));
|
$getMethods[] = trim(trim($method));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -126,14 +131,14 @@ class Provider
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return $result;
|
return $result;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function ArrayEntity2Array(array $entity, int $deep = 1, array $ignores = []): null|array{
|
public function ArrayEntity2Array(array $entity, int $deep = 1, array $ignores = []): null|array
|
||||||
|
{
|
||||||
if (count($entity) == 0) return [];
|
if (count($entity) == 0) return [];
|
||||||
$result = [];
|
$result = [];
|
||||||
foreach ($entity as $item) {
|
foreach ($entity as $item) {
|
||||||
|
@ -142,7 +147,8 @@ class Provider
|
||||||
return $result;
|
return $result;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function createPrint(Business $bid,User $user,String $data){
|
public function createPrint(Business $bid, User $user, String $data)
|
||||||
|
{
|
||||||
$print = new PrinterQueue();
|
$print = new PrinterQueue();
|
||||||
$print->setDateSubmit(time());
|
$print->setDateSubmit(time());
|
||||||
$print->setSubmitter($user);
|
$print->setSubmitter($user);
|
||||||
|
@ -157,7 +163,8 @@ class Provider
|
||||||
/**
|
/**
|
||||||
* @throws Exception
|
* @throws Exception
|
||||||
*/
|
*/
|
||||||
public function createExcell(array $entities, array $ignores = [],array $headers = null){
|
public function createExcell(array $entities, array $ignores = [], array $headers = null)
|
||||||
|
{
|
||||||
|
|
||||||
$spreadsheet = new Spreadsheet();
|
$spreadsheet = new Spreadsheet();
|
||||||
$activeWorksheet = $spreadsheet->getActiveSheet();
|
$activeWorksheet = $spreadsheet->getActiveSheet();
|
||||||
|
@ -174,7 +181,8 @@ class Provider
|
||||||
/**
|
/**
|
||||||
* @throws Exception
|
* @throws Exception
|
||||||
*/
|
*/
|
||||||
public function createExcellFromArray(array $entities,array $headers = null){
|
public function createExcellFromArray(array $entities, array $headers = null)
|
||||||
|
{
|
||||||
|
|
||||||
$spreadsheet = new Spreadsheet();
|
$spreadsheet = new Spreadsheet();
|
||||||
$activeWorksheet = $spreadsheet->getActiveSheet();
|
$activeWorksheet = $spreadsheet->getActiveSheet();
|
||||||
|
@ -192,14 +200,16 @@ class Provider
|
||||||
* @param int $length number of characters in the generated string
|
* @param int $length number of characters in the generated string
|
||||||
* @return string a new string is created with random characters of the desired length
|
* @return string a new string is created with random characters of the desired length
|
||||||
*/
|
*/
|
||||||
private function RandomString($length = 32) {
|
private function RandomString($length = 32)
|
||||||
|
{
|
||||||
return substr(str_shuffle(str_repeat($x = '23456789ABCDEFGHJKLMNPQRSTUVWXYZ', ceil($length / strlen($x)))), 1, $length);
|
return substr(str_shuffle(str_repeat($x = '23456789ABCDEFGHJKLMNPQRSTUVWXYZ', ceil($length / strlen($x)))), 1, $length);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @throws ReflectionException
|
* @throws ReflectionException
|
||||||
*/
|
*/
|
||||||
public function Entity2ArrayJustIncludes($entity, array $includes, int $deep = 1): null|array{
|
public function Entity2ArrayJustIncludes($entity, array $includes, int $deep = 1): null|array
|
||||||
|
{
|
||||||
if (is_null($entity)) return [];
|
if (is_null($entity)) return [];
|
||||||
$result = [];
|
$result = [];
|
||||||
foreach ($includes as $method) {
|
foreach ($includes as $method) {
|
||||||
|
@ -221,7 +231,8 @@ class Provider
|
||||||
/**
|
/**
|
||||||
* @throws ReflectionException
|
* @throws ReflectionException
|
||||||
*/
|
*/
|
||||||
public function ArrayEntity2ArrayJustIncludes(array $entity, array $includes, int $deep = 1): null|array{
|
public function ArrayEntity2ArrayJustIncludes(array $entity, array $includes, int $deep = 1): null|array
|
||||||
|
{
|
||||||
if (count($entity) == 0) return [];
|
if (count($entity) == 0) return [];
|
||||||
$result = [];
|
$result = [];
|
||||||
foreach ($entity as $item) {
|
foreach ($entity as $item) {
|
||||||
|
@ -229,4 +240,21 @@ class Provider
|
||||||
}
|
}
|
||||||
return $result;
|
return $result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function shamsiDateToTimestamp(string $stringDate): string | bool
|
||||||
|
{
|
||||||
|
$jdate = new Jdate();
|
||||||
|
$timeArray = explode('-', $stringDate);
|
||||||
|
if (count($timeArray) == 3)
|
||||||
|
$result = $jdate->jmktime(0, 0, 0, $timeArray[1], $timeArray[2], $timeArray[0]);
|
||||||
|
else {
|
||||||
|
$timeArray = explode('/', $stringDate);
|
||||||
|
if (count($timeArray) == 3)
|
||||||
|
$result = $jdate->jmktime(0, 0, 0, $timeArray[1], $timeArray[2], $timeArray[0]);
|
||||||
|
else
|
||||||
|
$result = false;
|
||||||
|
}
|
||||||
|
|
||||||
|
return $result;
|
||||||
|
}
|
||||||
}
|
}
|
Loading…
Reference in a new issue