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();
|
$count += $row->getCommdityCount();
|
||||||
} else {
|
} else {
|
||||||
$count -= $row->getCommdityCount();
|
$count -= $row->getCommdityCount();
|
||||||
} }
|
}
|
||||||
|
}
|
||||||
$temp['count'] = $count;
|
$temp['count'] = $count;
|
||||||
}
|
}
|
||||||
return $temp;
|
return $temp;
|
||||||
|
@ -1071,7 +1072,8 @@ class CommodityController extends AbstractController
|
||||||
if ($content = $request->getContent()) {
|
if ($content = $request->getContent()) {
|
||||||
$params = json_decode($content, true);
|
$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]);
|
return $this->json(['result' => -1]);
|
||||||
|
|
||||||
if ($this->isDefaultCategoryName($params['text'])) {
|
if ($this->isDefaultCategoryName($params['text'])) {
|
||||||
|
@ -1081,6 +1083,29 @@ class CommodityController extends AbstractController
|
||||||
'errorCode' => 'DEFAULT_CATEGORY_NAME'
|
'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']);
|
$upper = $entityManager->getRepository(CommodityCat::class)->find($params['upper']);
|
||||||
if ($upper) {
|
if ($upper) {
|
||||||
|
|
Loading…
Reference in a new issue