almost complete import persons from hook

This commit is contained in:
Hesabix 2024-01-14 01:40:57 +00:00
parent 899724ceef
commit 031ef7ea7d

View file

@ -252,7 +252,8 @@ class HookController extends AbstractController
foreach($params['data'] as $item){
$data = $entityManager->getRepository(Commodity::class)->findOneBy([
'name'=>$item['post_title']
'name'=>$item['post_title'],
'bid'=>$acc['bid']
]);
//check exist before
if($data)
@ -297,76 +298,28 @@ class HookController extends AbstractController
if ($content = $request->getContent()) {
$params = json_decode($content, true);
}
if(!array_key_exists('nikename',$params))
return $this->json(['result'=>-1]);
if(count_chars(trim($params['nikename'])) == 0)
return $this->json(['result'=>3]);
if($code == 0){
foreach($params['data'] as $item){
$person = $entityManager->getRepository(Person::class)->findOneBy([
'nikename'=>$params['nikename'],
'bid' =>$acc['bid']
'nikename'=>$item['nickname'],
'bid'=>$acc['bid']
]);
//check exist before
if($person)
return $this->json(['result'=>2]);
continue;
$person = new Person();
$person->setCode($provider->getAccountingCode($request->headers->get('activeBid'),'person'));
}
else{
$person = $entityManager->getRepository(Person::class)->findOneBy([
'bid'=>$acc['bid'],
'code'=>$code
]);
if(!$person)
throw $this->createNotFoundException();
}
$person->setName($item['nickname']);
$person->setNikename($item['nickname']);
$person->setBid($acc['bid']);
$person->setNikename($params['nikename']);
if(array_key_exists('name',$params))
$person->setName($params['name']);
if(array_key_exists('birthday',$params))
$person->setBirthday($params['birthday']);
if(array_key_exists('tel',$params))
$person->setTel($params['tel']);
if(array_key_exists('speedAccess',$params))
$person->setSpeedAccess($params['speedAccess']);
if(array_key_exists('address',$params))
$person->setAddress($params['address']);
if(array_key_exists('des',$params))
$person->setDes($params['des']);
if(array_key_exists('mobile',$params))
$person->setMobile($params['mobile']);
if(array_key_exists('fax',$params))
$person->setFax($params['fax']);
if(array_key_exists('website',$params))
$person->setWebsite($params['website']);
if(array_key_exists('email',$params))
$person->setEmail($params['email']);
if(array_key_exists('postalcode',$params))
$person->setPostalcode($params['postalcode']);
if(array_key_exists('shahr',$params))
$person->setShahr($params['shahr']);
if(array_key_exists('ostan',$params))
$person->setOstan($params['ostan']);
if(array_key_exists('keshvar',$params))
$person->setKeshvar($params['keshvar']);
if(array_key_exists('sabt',$params))
$person->setSabt($params['sabt']);
if(array_key_exists('codeeghtesadi',$params))
$person->setCodeeghtesadi($params['codeeghtesadi']);
if(array_key_exists('shenasemeli',$params))
$person->setShenasemeli($params['shenasemeli']);
if(array_key_exists('company',$params))
$person->setCompany($params['company']);
$entityManager->persist($person);
$entityManager->flush();
$log->insert('اشخاص','شخص با نام مستعار ' . $params['nikename'] . ' افزوده/ویرایش شد.',$this->getUser(),$request->headers->get('activeBid'));
return $this->json(['result' => 1]);
$log->insert('اشخاص','شخص با نام مستعار ' . $item['nickname'] . ' از طریق hook افزوده/ویرایش شد.',$this->getUser(),$request->headers->get('activeBid'));
}
return $this->json([
'Success'=>true,
'ErrorCode' => 0,
'ErrorMessage' => '',
'Result' =>$response
'Result' =>'ok'
]);
}
}