add filters to commodity
This commit is contained in:
parent
90b2b8a06c
commit
cbb53524ae
|
@ -113,8 +113,10 @@ class CommodityController extends AbstractController
|
||||||
$temp['priceSell'] = $item->getPriceSell();
|
$temp['priceSell'] = $item->getPriceSell();
|
||||||
$temp['code'] = $item->getCode();
|
$temp['code'] = $item->getCode();
|
||||||
$temp['cat'] = null;
|
$temp['cat'] = null;
|
||||||
if ($item->getCat())
|
if ($item->getCat()){
|
||||||
$temp['cat'] = $item->getCat()->getName();
|
$temp['cat'] = $item->getCat()->getName();
|
||||||
|
$temp['catData'] = Explore::ExploreCommodityCat($item->getCat());
|
||||||
|
}
|
||||||
$temp['khadamat'] = false;
|
$temp['khadamat'] = false;
|
||||||
if ($item->isKhadamat())
|
if ($item->isKhadamat())
|
||||||
$temp['khadamat'] = true;
|
$temp['khadamat'] = true;
|
||||||
|
@ -814,22 +816,21 @@ class CommodityController extends AbstractController
|
||||||
return $this->json($provider->Entity2Array($data, 0));
|
return $this->json($provider->Entity2Array($data, 0));
|
||||||
}
|
}
|
||||||
#[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(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();
|
||||||
$temp = [];
|
|
||||||
$nodes = $entityManager->getRepository(CommodityCat::class)->findBy([
|
$nodes = $entityManager->getRepository(CommodityCat::class)->findBy([
|
||||||
'bid' => $acc['bid'],
|
'bid' => $acc['bid'],
|
||||||
]);
|
]);
|
||||||
if (count($nodes) == 0)
|
if (count($nodes) == 0)
|
||||||
$nodes = $this->createDefaultCat($acc['bid'], $entityManager);
|
$nodes = $this->createDefaultCat($acc['bid'], $entityManager);
|
||||||
return $this->json($provider->ArrayEntity2Array($nodes, 0));
|
return $this->json(Explore::ExploreCommodityCats($nodes));
|
||||||
}
|
}
|
||||||
|
|
||||||
#[Route('/api/commodity/cat/get', name: 'app_commodity_cat_get')]
|
#[Route('/api/commodity/cat/get', name: 'app_commodity_cat_get')]
|
||||||
public function app_commodity_cat_get(Jdate $jdate, Provider $provider, Request $request, Access $access, Log $log, EntityManagerInterface $entityManager): JsonResponse
|
public function app_commodity_cat_get(Provider $provider, Request $request, Access $access, Log $log, EntityManagerInterface $entityManager): JsonResponse
|
||||||
{
|
{
|
||||||
|
|
||||||
$acc = $access->hasRole('commodity');
|
$acc = $access->hasRole('commodity');
|
||||||
|
|
|
@ -3,6 +3,7 @@
|
||||||
namespace App\Service;
|
namespace App\Service;
|
||||||
|
|
||||||
use App\Entity\BankAccount;
|
use App\Entity\BankAccount;
|
||||||
|
use App\Entity\CommodityCat;
|
||||||
use App\Entity\DashboardSettings;
|
use App\Entity\DashboardSettings;
|
||||||
use App\Entity\Project;
|
use App\Entity\Project;
|
||||||
use App\Entity\Storeroom;
|
use App\Entity\Storeroom;
|
||||||
|
@ -606,4 +607,25 @@ class Explore
|
||||||
|
|
||||||
return $result;
|
return $result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static function ExploreCommodityCats(array $items): array
|
||||||
|
{
|
||||||
|
$res = [];
|
||||||
|
foreach ($items as $item) {
|
||||||
|
$res[] = self::ExploreCommodityCat($item);
|
||||||
|
}
|
||||||
|
return $res;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static function ExploreCommodityCat(CommodityCat $item): array
|
||||||
|
{
|
||||||
|
return [
|
||||||
|
'id' => $item->getId(),
|
||||||
|
'code' => $item->getId(),
|
||||||
|
'name' => $item->getName(),
|
||||||
|
'checked' => false,
|
||||||
|
'root' => $item->isRoot(),
|
||||||
|
'upper' => $item->getUpper()
|
||||||
|
];
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue