start whats
This commit is contained in:
parent
7f0abebf98
commit
733d1ecad7
|
@ -443,6 +443,7 @@ class CommodityController extends AbstractController
|
||||||
$sheet = $spreadsheet->getSheet($spreadsheet->getFirstSheetIndex());
|
$sheet = $spreadsheet->getSheet($spreadsheet->getFirstSheetIndex());
|
||||||
$data = $sheet->toArray();
|
$data = $sheet->toArray();
|
||||||
unset($data[0]);
|
unset($data[0]);
|
||||||
|
|
||||||
foreach($data as $item){
|
foreach($data as $item){
|
||||||
//load cat
|
//load cat
|
||||||
$unit = $entityManager->getRepository(commodity::class)->findOneBy([
|
$unit = $entityManager->getRepository(commodity::class)->findOneBy([
|
||||||
|
@ -456,17 +457,39 @@ class CommodityController extends AbstractController
|
||||||
'name'=>$item[2],
|
'name'=>$item[2],
|
||||||
'bid' =>$acc['bid']
|
'bid' =>$acc['bid']
|
||||||
]);
|
]);
|
||||||
|
$cat = $entityManager->getRepository(CommodityCat::class)->findOneBy([
|
||||||
|
'name'=>$item[8],
|
||||||
|
'bid' =>$acc['bid']
|
||||||
|
]);
|
||||||
|
|
||||||
|
$rootcat = $entityManager->getRepository(CommodityCat::class)->findOneBy([
|
||||||
|
'name'=>'دسته بندی ها',
|
||||||
|
'bid' =>$acc['bid'],
|
||||||
|
'root'=>'1',
|
||||||
|
'upper'=>null
|
||||||
|
]);
|
||||||
|
if(!$cat){
|
||||||
|
$cat = new CommodityCat();
|
||||||
|
$cat->setBid($acc['bid']);
|
||||||
|
$cat->setName($item[8]);
|
||||||
|
$cat->setUpper($rootcat->getId());
|
||||||
|
$cat->setRoot(1);
|
||||||
|
$entityManager->persist($cat);
|
||||||
|
$entityManager->flush();
|
||||||
|
}
|
||||||
//check exist before
|
//check exist before
|
||||||
if(!$commodity){
|
if(!$commodity){
|
||||||
|
|
||||||
$commodity = new commodity();
|
$commodity = new commodity();
|
||||||
|
|
||||||
|
}
|
||||||
$commodity->setCode($provider->getAccountingCode($request->headers->get('activeBid'),'commodity'));
|
$commodity->setCode($provider->getAccountingCode($request->headers->get('activeBid'),'commodity'));
|
||||||
$commodity->setName($item[2]);
|
$commodity->setName($item[2]);
|
||||||
$commodity->setBid($acc['bid']);
|
$commodity->setBid($acc['bid']);
|
||||||
$commodity->setUnit($unit);
|
$commodity->setUnit($unit);
|
||||||
|
$commodity->setCat($cat);
|
||||||
$commodity->setOrderPoint(0);
|
$commodity->setOrderPoint(0);
|
||||||
$commodity->setDayLoading(0);
|
$commodity->setDayLoading(0);
|
||||||
if(array_key_exists(1,$item))
|
|
||||||
$commodity->setName($item[1]);
|
|
||||||
if(array_key_exists(3,$item))
|
if(array_key_exists(3,$item))
|
||||||
$commodity->setPriceSell($item[3]);
|
$commodity->setPriceSell($item[3]);
|
||||||
if(array_key_exists(4,$item))
|
if(array_key_exists(4,$item))
|
||||||
|
@ -484,7 +507,6 @@ class CommodityController extends AbstractController
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
$entityManager->persist($commodity);
|
$entityManager->persist($commodity);
|
||||||
}
|
|
||||||
$entityManager->flush();
|
$entityManager->flush();
|
||||||
}
|
}
|
||||||
$log->insert('کالا/خدمات','تعداد '. count($data) . ' کالا یا خدمات به صورت گروهی وارد شد.',$this->getUser(),$request->headers->get('activeBid'));
|
$log->insert('کالا/خدمات','تعداد '. count($data) . ' کالا یا خدمات به صورت گروهی وارد شد.',$this->getUser(),$request->headers->get('activeBid'));
|
||||||
|
@ -517,3 +539,5 @@ class CommodityController extends AbstractController
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -26,7 +26,7 @@ class Explore{
|
||||||
$person = self::ExplorePerson($item->getPerson());
|
$person = self::ExplorePerson($item->getPerson());
|
||||||
}
|
}
|
||||||
elseif($item->getCommodity()){
|
elseif($item->getCommodity()){
|
||||||
$commodities[] = Explore::ExploreCommodity($item->getCommodity(),$item->getCommdityCount());
|
$commodities[] = Explore::ExploreCommodity($item->getCommodity(),$item->getCommdityCount(),$item->getDes());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
$result['person'] = $person;
|
$result['person'] = $person;
|
||||||
|
@ -42,7 +42,7 @@ class Explore{
|
||||||
$person = self::ExplorePerson($item->getPerson());
|
$person = self::ExplorePerson($item->getPerson());
|
||||||
}
|
}
|
||||||
elseif($item->getCommodity()){
|
elseif($item->getCommodity()){
|
||||||
$commodities[] = Explore::ExploreCommodity($item->getCommodity(),$item->getCommdityCount());
|
$commodities[] = Explore::ExploreCommodity($item->getCommodity(),$item->getCommdityCount(),$item->getDes());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
$result['person'] = $person;
|
$result['person'] = $person;
|
||||||
|
@ -63,7 +63,7 @@ class Explore{
|
||||||
'des' => $doc->getDes(),
|
'des' => $doc->getDes(),
|
||||||
'amount' => $doc->getAmount(),
|
'amount' => $doc->getAmount(),
|
||||||
'mdate' => '',
|
'mdate' => '',
|
||||||
'plugin' => $doc->getPlugin()
|
'plugin' => $doc->getPlugin(),
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -89,11 +89,11 @@ class Explore{
|
||||||
'des' => $row->getDes(),
|
'des' => $row->getDes(),
|
||||||
'plugin' => $row->getPlugin(),
|
'plugin' => $row->getPlugin(),
|
||||||
'commodity_count' => $row->getCommdityCount(),
|
'commodity_count' => $row->getCommdityCount(),
|
||||||
'commodity' => self::ExploreCommodity($row->getCommodity())
|
'commodity' => self::ExploreCommodity($row->getCommodity(),$row->getCommdityCount(),$row->getDes())
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|
||||||
public static function ExploreCommodity(Commodity | null $item, int $count = 0){
|
public static function ExploreCommodity(Commodity | null $item, int | null $count = 0,string $des = ''){
|
||||||
if($item)
|
if($item)
|
||||||
return [
|
return [
|
||||||
'id' => $item->getId(),
|
'id' => $item->getId(),
|
||||||
|
@ -105,7 +105,9 @@ class Explore{
|
||||||
'khadamat' => $item->isKhadamat(),
|
'khadamat' => $item->isKhadamat(),
|
||||||
'speed_access' => $item->isSpeedAccess(),
|
'speed_access' => $item->isSpeedAccess(),
|
||||||
//most be completed
|
//most be completed
|
||||||
'count' => $count
|
'count' => $count,
|
||||||
|
'unit' =>$item->getUnit()->getName(),
|
||||||
|
'des' =>$des
|
||||||
];
|
];
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue