add year select to new business and some reports
This commit is contained in:
parent
267b28cf87
commit
5f7e68dfb1
|
@ -1,17 +0,0 @@
|
|||
<?php
|
||||
|
||||
namespace App\Controller;
|
||||
|
||||
use App\Service\pdfMGR;
|
||||
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
|
||||
use Symfony\Component\HttpFoundation\JsonResponse;
|
||||
use Symfony\Component\Routing\Annotation\Route;
|
||||
|
||||
class AdsBanController extends AbstractController
|
||||
{
|
||||
#[Route('/ads/ban', name: 'app_ads_ban')]
|
||||
public function index(pdfMGR $pdfMGR): JsonResponse
|
||||
{
|
||||
$pdfMGR->streamTwig2PDF('test.html.twig');
|
||||
}
|
||||
}
|
|
@ -179,8 +179,7 @@ class BusinessController extends AbstractController
|
|||
$business->setWalletMatchBank($bank);
|
||||
}
|
||||
}
|
||||
}
|
||||
else{
|
||||
} else {
|
||||
$business->setWalletEnable(false);
|
||||
}
|
||||
}
|
||||
|
@ -192,8 +191,7 @@ class BusinessController extends AbstractController
|
|||
$business->setMoney($Arzmain);
|
||||
else
|
||||
return $this->json(['result' => 2]);
|
||||
}
|
||||
else
|
||||
} else
|
||||
return $this->json(['result' => 2]);
|
||||
if (!$business->getDateSubmit()) $business->setDateSubmit(time());
|
||||
$entityManager->persist($business);
|
||||
|
@ -229,9 +227,11 @@ class BusinessController extends AbstractController
|
|||
$year = new Year();
|
||||
$year->setBid($business);
|
||||
$year->setHead(true);
|
||||
$year->setStart(time());
|
||||
$year->setEnd(time() + 31536000);
|
||||
$year->setLabel('سال مالی منتهی به ' . $jdate->jdate('Y/n/d',time() + 31536000));
|
||||
$startYearArray = explode('-', $params['year']['start']);
|
||||
$year->setStart($jdate->jmktime(0, 0, 0, $startYearArray[1], $startYearArray[2], $startYearArray[0]));
|
||||
$endYearArray = explode('-', $params['year']['end']);
|
||||
$year->setEnd($jdate->jmktime(0, 0, 0, $endYearArray[1], $endYearArray[2], $endYearArray[0]));
|
||||
$year->setLabel($params['year']['label']);
|
||||
$entityManager->persist($year);
|
||||
$entityManager->flush();
|
||||
}
|
||||
|
@ -290,7 +290,8 @@ class BusinessController extends AbstractController
|
|||
'name' => $user->getFullName(),
|
||||
'owner' => false
|
||||
]
|
||||
]);
|
||||
]
|
||||
);
|
||||
}
|
||||
return $this->json(['result' => -1]);
|
||||
}
|
||||
|
@ -410,8 +411,7 @@ class BusinessController extends AbstractController
|
|||
'active' => $perm->getUser()->isActive(),
|
||||
'shareholder' => true,
|
||||
];
|
||||
}
|
||||
elseif($perm){
|
||||
} elseif ($perm) {
|
||||
$result = [
|
||||
'id' => $perm->getUser()->getId(),
|
||||
'user' => $perm->getUser()->getFullName(),
|
||||
|
|
|
@ -23,6 +23,7 @@ use Symfony\Component\Serializer\SerializerInterface;
|
|||
use Symfony\Component\HttpFoundation\StreamedResponse;
|
||||
use Symfony\Component\HttpFoundation\BinaryFileResponse;
|
||||
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
|
||||
use Symfony\Component\HttpFoundation\Response;
|
||||
|
||||
class PersonsController extends AbstractController
|
||||
{
|
||||
|
@ -208,8 +209,8 @@ class PersonsController extends AbstractController
|
|||
return $this->json(['result' => 1]);
|
||||
}
|
||||
|
||||
#[Route('/api/person/list', name: 'app_persons_list')]
|
||||
public function app_persons_list(Provider $provider,Request $request,Access $access,Log $log,EntityManagerInterface $entityManager): JsonResponse
|
||||
#[Route('/api/person/list/limit', name: 'app_persons_list_limit')]
|
||||
public function app_persons_list_limit(Provider $provider,Request $request,Access $access,Log $log,EntityManagerInterface $entityManager): JsonResponse
|
||||
{
|
||||
if(!$access->hasRole('person'))
|
||||
throw $this->createAccessDeniedException();
|
||||
|
@ -228,7 +229,38 @@ class PersonsController extends AbstractController
|
|||
'bid'=>$request->headers->get('activeBid')
|
||||
]);
|
||||
}
|
||||
$response = $provider->ArrayEntity2Array($persons,0);
|
||||
$response = [];
|
||||
foreach ($persons as $key =>$person){
|
||||
$response[] = [
|
||||
'id' => $person->getId(),
|
||||
'nikename'=>$person->getNikename(),
|
||||
'code' =>$person->getCode(),
|
||||
];
|
||||
}
|
||||
return $this->json($response);
|
||||
}
|
||||
|
||||
#[Route('/api/person/list', name: 'app_persons_list')]
|
||||
public function app_persons_list(Provider $provider,Request $request,Access $access,Log $log,EntityManagerInterface $entityManager): Response
|
||||
{
|
||||
if(!$access->hasRole('person'))
|
||||
throw $this->createAccessDeniedException();
|
||||
$params = [];
|
||||
if ($content = $request->getContent()) {
|
||||
$params = json_decode($content, true);
|
||||
}
|
||||
if(array_key_exists('speedAccess',$params)){
|
||||
$persons = $entityManager->getRepository(Person::class)->findBy([
|
||||
'bid'=>$request->headers->get('activeBid'),
|
||||
'speedAccess'=>true
|
||||
]);
|
||||
}
|
||||
else{
|
||||
$persons = $entityManager->getRepository(Person::class)->findBy([
|
||||
'bid'=>$request->headers->get('activeBid')
|
||||
]);
|
||||
}
|
||||
$response = Explore::ExplorePersons($persons,$entityManager->getRepository(PersonType::class)->findAll());
|
||||
foreach ($persons as $key =>$person){
|
||||
$rows = $entityManager->getRepository(HesabdariRow::class)->findBy([
|
||||
'person'=>$person
|
||||
|
@ -243,7 +275,7 @@ class PersonsController extends AbstractController
|
|||
$response[$key]['bd'] = $bd;
|
||||
$response[$key]['balance'] = $bs - $bd;
|
||||
}
|
||||
return $this->json($response);
|
||||
return new Response(json_encode($response));
|
||||
}
|
||||
|
||||
#[Route('/api/person/list/debtors/{amount}', name: 'app_persons_list_debtors')]
|
||||
|
|
86
hesabixCore/src/Controller/ReportController.php
Normal file
86
hesabixCore/src/Controller/ReportController.php
Normal file
|
@ -0,0 +1,86 @@
|
|||
<?php
|
||||
|
||||
namespace App\Controller;
|
||||
|
||||
use App\Entity\HesabdariDoc;
|
||||
use App\Entity\HesabdariRow;
|
||||
use App\Entity\Person;
|
||||
use App\Service\Access;
|
||||
use App\Service\pdfMGR;
|
||||
use Doctrine\ORM\EntityManagerInterface;
|
||||
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
|
||||
use Symfony\Component\HttpFoundation\JsonResponse;
|
||||
use Symfony\Component\HttpFoundation\Request;
|
||||
use Symfony\Component\Routing\Annotation\Route;
|
||||
|
||||
class ReportController extends AbstractController
|
||||
{
|
||||
#[Route('/api/report/person/buysell', name: 'app_report_person_buysell')]
|
||||
public function app_report_person_buysell(Access $access, Request $request, EntityManagerInterface $entityManagerInterface): JsonResponse
|
||||
{
|
||||
$acc = $access->hasRole('reports');
|
||||
if (!$acc) {
|
||||
throw $this->createAccessDeniedException();
|
||||
}
|
||||
|
||||
$params = [];
|
||||
if ($content = $request->getContent()) {
|
||||
$params = json_decode($content, true);
|
||||
}
|
||||
$docs = $entityManagerInterface->getRepository(HesabdariDoc::class)->findBy([
|
||||
'year' => $acc['year'],
|
||||
'bid' => $acc['bid'],
|
||||
'type' => $params['type'],
|
||||
]);
|
||||
|
||||
$person = $entityManagerInterface->getRepository(Person::class)->findOneBy([
|
||||
'bid' => $acc['bid']->getId(),
|
||||
'code' => $params['person'],
|
||||
]);
|
||||
$result = [];
|
||||
foreach ($docs as $doc) {
|
||||
$rows = $doc->getHesabdariRows();
|
||||
foreach ($rows as $row) {
|
||||
if ($row->getPerson()) {
|
||||
if ($person->getId() == $row->getPerson()->getId()) {
|
||||
$result[] = $doc;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
$docs = $result;
|
||||
$result = [];
|
||||
foreach ($docs as $doc) {
|
||||
$rows = $doc->getHesabdariRows();
|
||||
foreach ($rows as $row) {
|
||||
if ($row->getCommodity()) {
|
||||
$result[] = $row;
|
||||
}
|
||||
}
|
||||
}
|
||||
$response = [];
|
||||
foreach ($result as $item) {
|
||||
$temp = [
|
||||
'id' => $item->getCommodity()->getId(),
|
||||
'code' => $item->getCommodity()->getCode(),
|
||||
'khadamat' => $item->getCommodity()->isKhadamat(),
|
||||
'name' => $item->getCommodity()->getName(),
|
||||
'unit' => $item->getCommodity()->getUnit()->getName(),
|
||||
'count' => $item->getCommdityCount(),
|
||||
];
|
||||
if ($params['type'] == 'buy') {
|
||||
$temp['priceAll'] = $item->getBd();
|
||||
} elseif ($params['type'] == 'sell') {
|
||||
$temp['priceAll'] = $item->getBs();
|
||||
}
|
||||
if ($temp['count'] != 0) {
|
||||
$temp['priceOne'] = $temp['priceAll'] / $temp['count'];
|
||||
$temp['priceAll'] = number_format($temp['priceAll']);
|
||||
$temp['priceOne'] = number_format($temp['priceOne']);
|
||||
$temp['count'] = number_format($temp['count']);
|
||||
$response[] = $temp;
|
||||
}
|
||||
}
|
||||
return $this->json($response);
|
||||
}
|
||||
}
|
|
@ -181,7 +181,6 @@ class Explore{
|
|||
'fax' => $person->getFax(),
|
||||
'birthday' => $person->getBirthday(),
|
||||
'speedAccess'=>$person->isSpeedAccess(),
|
||||
|
||||
];
|
||||
$res['accounts'] = self::ExplorePersonCards($person);
|
||||
$res['types'] = self::ExplorePersonTypes($typesAll);
|
||||
|
@ -196,12 +195,13 @@ class Explore{
|
|||
}
|
||||
return null;
|
||||
}
|
||||
public static function ExplorePersons($items){
|
||||
public static function ExplorePersons($items,$types){
|
||||
$result = [];
|
||||
foreach($items as $item)
|
||||
$result[] = self::ExplorePerson($item);
|
||||
$result[] = self::ExplorePerson($item,$types);
|
||||
return $result;
|
||||
}
|
||||
|
||||
public static function ExplorePersonCards(Person $person){
|
||||
$res = [];
|
||||
foreach($person->getPersonCards() as $item){
|
||||
|
|
Loading…
Reference in a new issue