forked from morrning/hesabixCore
merge upper in commodity cat with pos app
This commit is contained in:
parent
dddc648a1f
commit
ddbbf1f102
|
@ -143,7 +143,8 @@ class CommodityController extends AbstractController
|
|||
$count += $row->getCommdityCount();
|
||||
} else {
|
||||
$count -= $row->getCommdityCount();
|
||||
} }
|
||||
}
|
||||
}
|
||||
$temp['count'] = $count;
|
||||
}
|
||||
return $temp;
|
||||
|
@ -1071,17 +1072,41 @@ class CommodityController extends AbstractController
|
|||
if ($content = $request->getContent()) {
|
||||
$params = json_decode($content, true);
|
||||
}
|
||||
if (!array_key_exists('upper', $params) || !array_key_exists('text', $params))
|
||||
|
||||
if (!array_key_exists('text', $params))
|
||||
return $this->json(['result' => -1]);
|
||||
|
||||
|
||||
if ($this->isDefaultCategoryName($params['text'])) {
|
||||
return $this->json([
|
||||
'result' => 4,
|
||||
'result' => 4,
|
||||
'message' => 'این نام برای دستهبندی مجاز نیست',
|
||||
'errorCode' => 'DEFAULT_CATEGORY_NAME'
|
||||
]);
|
||||
}
|
||||
|
||||
if (!array_key_exists('upper', $params)) {
|
||||
$upper = $entityManager->getRepository(CommodityCat::class)->findOneBy([
|
||||
'upper' => null,
|
||||
'bid' => $acc['bid']
|
||||
]);
|
||||
if (!$upper) {
|
||||
$upper = new CommodityCat();
|
||||
$upper->setBid($acc['bid']);
|
||||
$upper->setUpper(null);
|
||||
$upper->setName('دسته بندی ها');
|
||||
$upper->setRoot(true);
|
||||
$entityManager->persist($upper);
|
||||
$entityManager->flush();
|
||||
}
|
||||
$cat = new CommodityCat();
|
||||
$cat->setBid($acc['bid']);
|
||||
$cat->setRoot(false);
|
||||
$cat->setName($params['text']);
|
||||
$cat->setUpper($upper->getId());
|
||||
$entityManager->persist($cat);
|
||||
$entityManager->flush();
|
||||
return $this->json(['result' => 1, 'id' => $cat->getId()]);
|
||||
}
|
||||
|
||||
$upper = $entityManager->getRepository(CommodityCat::class)->find($params['upper']);
|
||||
if ($upper) {
|
||||
if ($upper->getBid() == $acc['bid']) {
|
||||
|
@ -1109,22 +1134,22 @@ class CommodityController extends AbstractController
|
|||
}
|
||||
if (!array_key_exists('id', $params) || !array_key_exists('text', $params))
|
||||
return $this->json(['result' => -1]);
|
||||
|
||||
|
||||
if ($this->isDefaultCategoryName($params['text'])) {
|
||||
return $this->json([
|
||||
'result' => 4,
|
||||
'result' => 4,
|
||||
'message' => 'این نام برای دستهبندی مجاز نیست',
|
||||
'errorCode' => 'DEFAULT_CATEGORY_NAME'
|
||||
]);
|
||||
}
|
||||
|
||||
|
||||
$node = $entityManager->getRepository(CommodityCat::class)->find($params['id']);
|
||||
if ($node) {
|
||||
if ($node->getBid() == $acc['bid']) {
|
||||
// بررسی دستهبندی پیشفرض
|
||||
if ($this->isDefaultCategoryName($node->getName())) {
|
||||
return $this->json([
|
||||
'result' => 4,
|
||||
'result' => 4,
|
||||
'message' => 'ویرایش دستهبندی پیشفرض مجاز نیست',
|
||||
'errorCode' => 'DEFAULT_CATEGORY_EDIT'
|
||||
]);
|
||||
|
@ -1588,7 +1613,7 @@ class CommodityController extends AbstractController
|
|||
// بررسی دستهبندی پیشفرض
|
||||
if ($this->isDefaultCategoryName($category->getName())) {
|
||||
return $this->json([
|
||||
'Success' => false,
|
||||
'Success' => false,
|
||||
'message' => 'حذف دستهبندی پیشفرض مجاز نیست',
|
||||
'errorCode' => 'DEFAULT_CATEGORY_DELETE'
|
||||
], 400);
|
||||
|
|
Loading…
Reference in a new issue