bug fix in ippanel sms service and sell invoice
This commit is contained in:
parent
87c081b387
commit
70b21f13a6
|
@ -27,57 +27,57 @@ use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
|
||||||
class BuyController extends AbstractController
|
class BuyController extends AbstractController
|
||||||
{
|
{
|
||||||
#[Route('/api/buy/edit/can/{code}', name: 'app_buy_can_edit')]
|
#[Route('/api/buy/edit/can/{code}', name: 'app_buy_can_edit')]
|
||||||
public function app_buy_can_edit(Request $request,Access $access,Log $log,EntityManagerInterface $entityManager, string $code): JsonResponse
|
public function app_buy_can_edit(Request $request, Access $access, Log $log, EntityManagerInterface $entityManager, string $code): JsonResponse
|
||||||
{
|
{
|
||||||
$canEdit = true;
|
$canEdit = true;
|
||||||
$acc = $access->hasRole('buy');
|
$acc = $access->hasRole('buy');
|
||||||
if(!$acc)
|
if (!$acc)
|
||||||
throw $this->createAccessDeniedException();
|
throw $this->createAccessDeniedException();
|
||||||
|
|
||||||
$doc = $entityManager->getRepository(HesabdariDoc::class)->findOneBy([
|
$doc = $entityManager->getRepository(HesabdariDoc::class)->findOneBy([
|
||||||
'bid'=>$acc['bid'],
|
'bid' => $acc['bid'],
|
||||||
'code'=>$code
|
'code' => $code
|
||||||
]);
|
]);
|
||||||
//check related documents
|
//check related documents
|
||||||
if(count($doc->getRelatedDocs()) != 0)
|
if (count($doc->getRelatedDocs()) != 0)
|
||||||
$canEdit = false;
|
$canEdit = false;
|
||||||
|
|
||||||
//check storeroom tickets
|
//check storeroom tickets
|
||||||
$tickets = $entityManager->getRepository(StoreroomTicket::class)->findBy(['doc'=>$doc]);
|
$tickets = $entityManager->getRepository(StoreroomTicket::class)->findBy(['doc' => $doc]);
|
||||||
if(count($tickets) != 0)
|
if (count($tickets) != 0)
|
||||||
$canEdit = false;
|
$canEdit = false;
|
||||||
return $this->json([
|
return $this->json([
|
||||||
'result'=> $canEdit
|
'result' => $canEdit
|
||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
|
|
||||||
#[Route('/api/buy/get/info/{code}', name: 'app_buy_get_info')]
|
#[Route('/api/buy/get/info/{code}', name: 'app_buy_get_info')]
|
||||||
public function app_buy_get_info(Request $request,Access $access,Log $log,EntityManagerInterface $entityManager, string $code): JsonResponse
|
public function app_buy_get_info(Request $request, Access $access, Log $log, EntityManagerInterface $entityManager, string $code): JsonResponse
|
||||||
{
|
{
|
||||||
$acc = $access->hasRole('buy');
|
$acc = $access->hasRole('buy');
|
||||||
if(!$acc)
|
if (!$acc)
|
||||||
throw $this->createAccessDeniedException();
|
throw $this->createAccessDeniedException();
|
||||||
$doc = $entityManager->getRepository(HesabdariDoc::class)->findOneBy([
|
$doc = $entityManager->getRepository(HesabdariDoc::class)->findOneBy([
|
||||||
'bid'=>$acc['bid'],
|
'bid' => $acc['bid'],
|
||||||
'code'=>$code
|
'code' => $code
|
||||||
]);
|
]);
|
||||||
if(!$doc)
|
if (!$doc)
|
||||||
throw $this->createNotFoundException();
|
throw $this->createNotFoundException();
|
||||||
|
|
||||||
return $this->json(Explore::ExploreBuyDoc($doc));
|
return $this->json(Explore::ExploreBuyDoc($doc));
|
||||||
}
|
}
|
||||||
|
|
||||||
#[Route('/api/buy/get/invoices/list', name: 'app_buy_get_invoices_list')]
|
#[Route('/api/buy/get/invoices/list', name: 'app_buy_get_invoices_list')]
|
||||||
public function app_buy_get_invoices_list(Request $request,Access $access,Log $log,EntityManagerInterface $entityManager, string $code): JsonResponse
|
public function app_buy_get_invoices_list(Request $request, Access $access, Log $log, EntityManagerInterface $entityManager, string $code): JsonResponse
|
||||||
{
|
{
|
||||||
$acc = $access->hasRole('buy');
|
$acc = $access->hasRole('buy');
|
||||||
if(!$acc)
|
if (!$acc)
|
||||||
throw $this->createAccessDeniedException();
|
throw $this->createAccessDeniedException();
|
||||||
$invoices = $entityManager->getRepository(HesabdariDoc::class)->findBy([
|
$invoices = $entityManager->getRepository(HesabdariDoc::class)->findBy([
|
||||||
'bid'=>$acc['bid'],
|
'bid' => $acc['bid'],
|
||||||
'year'=>$acc['year'],
|
'year' => $acc['year'],
|
||||||
'type'=>'buy',
|
'type' => 'buy',
|
||||||
'money'=> $acc['money']
|
'money' => $acc['money']
|
||||||
]);
|
]);
|
||||||
return $this->json(Explore::ExploreBuyDocsList($invoices));
|
return $this->json(Explore::ExploreBuyDocsList($invoices));
|
||||||
}
|
}
|
||||||
|
@ -102,9 +102,10 @@ class BuyController extends AbstractController
|
||||||
'bid' => $acc['bid'],
|
'bid' => $acc['bid'],
|
||||||
'year' => $acc['year'],
|
'year' => $acc['year'],
|
||||||
'code' => $params['update'],
|
'code' => $params['update'],
|
||||||
'money'=> $acc['money']
|
'money' => $acc['money']
|
||||||
]);
|
]);
|
||||||
if (!$doc) return $this->json($extractor->notFound());
|
if (!$doc)
|
||||||
|
return $this->json($extractor->notFound());
|
||||||
|
|
||||||
$rows = $entityManager->getRepository(HesabdariRow::class)->findBy([
|
$rows = $entityManager->getRepository(HesabdariRow::class)->findBy([
|
||||||
'doc' => $doc
|
'doc' => $doc
|
||||||
|
@ -121,7 +122,7 @@ class BuyController extends AbstractController
|
||||||
$doc->setMoney($acc['money']);
|
$doc->setMoney($acc['money']);
|
||||||
$doc->setCode($provider->getAccountingCode($acc['bid'], 'accounting'));
|
$doc->setCode($provider->getAccountingCode($acc['bid'], 'accounting'));
|
||||||
}
|
}
|
||||||
if($params['transferCost'] != 0){
|
if ($params['transferCost'] != 0) {
|
||||||
$hesabdariRow = new HesabdariRow();
|
$hesabdariRow = new HesabdariRow();
|
||||||
$hesabdariRow->setDes('حمل و نقل کالا');
|
$hesabdariRow->setDes('حمل و نقل کالا');
|
||||||
$hesabdariRow->setBid($acc['bid']);
|
$hesabdariRow->setBid($acc['bid']);
|
||||||
|
@ -135,7 +136,7 @@ class BuyController extends AbstractController
|
||||||
$hesabdariRow->setRef($ref);
|
$hesabdariRow->setRef($ref);
|
||||||
$entityManager->persist($hesabdariRow);
|
$entityManager->persist($hesabdariRow);
|
||||||
}
|
}
|
||||||
if($params['discountAll'] != 0){
|
if ($params['discountAll'] != 0) {
|
||||||
$hesabdariRow = new HesabdariRow();
|
$hesabdariRow = new HesabdariRow();
|
||||||
$hesabdariRow->setDes('تخفیف فاکتور');
|
$hesabdariRow->setDes('تخفیف فاکتور');
|
||||||
$hesabdariRow->setBid($acc['bid']);
|
$hesabdariRow->setBid($acc['bid']);
|
||||||
|
@ -181,7 +182,7 @@ class BuyController extends AbstractController
|
||||||
$entityManager->persist($hesabdariRow);
|
$entityManager->persist($hesabdariRow);
|
||||||
|
|
||||||
//update commodity price for auto update price option
|
//update commodity price for auto update price option
|
||||||
if($acc['bid']->isCommodityUpdateBuyPriceAuto() == true && $commodity->getPriceBuy() != $row['price']){
|
if ($acc['bid']->isCommodityUpdateBuyPriceAuto() == true && $commodity->getPriceBuy() != $row['price']) {
|
||||||
$commodity->setPriceBuy($row['price']);
|
$commodity->setPriceBuy($row['price']);
|
||||||
$entityManager->persist($commodity);
|
$entityManager->persist($commodity);
|
||||||
}
|
}
|
||||||
|
@ -239,16 +240,18 @@ class BuyController extends AbstractController
|
||||||
'code' => $params['label']['code'],
|
'code' => $params['label']['code'],
|
||||||
'type' => 'buy'
|
'type' => 'buy'
|
||||||
]);
|
]);
|
||||||
if (!$label) return $this->json($extractor->notFound());
|
if (!$label)
|
||||||
|
return $this->json($extractor->notFound());
|
||||||
}
|
}
|
||||||
foreach ($params['items'] as $item) {
|
foreach ($params['items'] as $item) {
|
||||||
$doc = $entityManager->getRepository(HesabdariDoc::class)->findOneBy([
|
$doc = $entityManager->getRepository(HesabdariDoc::class)->findOneBy([
|
||||||
'bid' => $acc['bid'],
|
'bid' => $acc['bid'],
|
||||||
'year' => $acc['year'],
|
'year' => $acc['year'],
|
||||||
'code' => $item['code'],
|
'code' => $item['code'],
|
||||||
'money'=> $acc['money']
|
'money' => $acc['money']
|
||||||
]);
|
]);
|
||||||
if (!$doc) return $this->json($extractor->notFound());
|
if (!$doc)
|
||||||
|
return $this->json($extractor->notFound());
|
||||||
if ($params['label'] != 'clear') {
|
if ($params['label'] != 'clear') {
|
||||||
$doc->setInvoiceLabel($label);
|
$doc->setInvoiceLabel($label);
|
||||||
$entityManager->persist($doc);
|
$entityManager->persist($doc);
|
||||||
|
@ -290,7 +293,7 @@ class BuyController extends AbstractController
|
||||||
'bid' => $acc['bid'],
|
'bid' => $acc['bid'],
|
||||||
'year' => $acc['year'],
|
'year' => $acc['year'],
|
||||||
'type' => 'buy',
|
'type' => 'buy',
|
||||||
'money'=> $acc['money']
|
'money' => $acc['money']
|
||||||
], [
|
], [
|
||||||
'id' => 'DESC'
|
'id' => 'DESC'
|
||||||
]);
|
]);
|
||||||
|
@ -327,15 +330,22 @@ class BuyController extends AbstractController
|
||||||
}
|
}
|
||||||
$temp['relatedDocsPays'] = $pays;
|
$temp['relatedDocsPays'] = $pays;
|
||||||
|
|
||||||
|
$temp['commodities'] = [];
|
||||||
foreach ($item->getHesabdariRows() as $item) {
|
foreach ($item->getHesabdariRows() as $item) {
|
||||||
if ($item->getRef()->getCode() == '104') {
|
if ($item->getRef()->getCode() == '104') {
|
||||||
$temp['discountAll'] = $item->getBd();
|
$temp['discountAll'] = $item->getBd();
|
||||||
} elseif ($item->getRef()->getCode() == '90') {
|
} elseif ($item->getRef()->getCode() == '90') {
|
||||||
$temp['transferCost'] = $item->getBs();
|
$temp['transferCost'] = $item->getBs();
|
||||||
}
|
}
|
||||||
|
if ($item->getCommodity()) {
|
||||||
|
$temp['commodities'][] = Explore::ExploreCommodity($item->getCommodity(), $item->getCommdityCount());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
if(!array_key_exists('discountAll',$temp)) $temp['discountAll'] = 0;
|
if (!array_key_exists('discountAll', $temp))
|
||||||
if(!array_key_exists('transferCost',$temp)) $temp['transferCost'] = 0;
|
$temp['discountAll'] = 0;
|
||||||
|
if (!array_key_exists('transferCost', $temp))
|
||||||
|
$temp['transferCost'] = 0;
|
||||||
|
|
||||||
$dataTemp[] = $temp;
|
$dataTemp[] = $temp;
|
||||||
}
|
}
|
||||||
return $this->json($dataTemp);
|
return $this->json($dataTemp);
|
||||||
|
@ -350,26 +360,28 @@ class BuyController extends AbstractController
|
||||||
}
|
}
|
||||||
|
|
||||||
$acc = $access->hasRole('buy');
|
$acc = $access->hasRole('buy');
|
||||||
if (!$acc) throw $this->createAccessDeniedException();
|
if (!$acc)
|
||||||
|
throw $this->createAccessDeniedException();
|
||||||
|
|
||||||
$doc = $entityManager->getRepository(HesabdariDoc::class)->findOneBy([
|
$doc = $entityManager->getRepository(HesabdariDoc::class)->findOneBy([
|
||||||
'bid' => $acc['bid'],
|
'bid' => $acc['bid'],
|
||||||
'code' => $params['code'],
|
'code' => $params['code'],
|
||||||
'money'=> $acc['money']
|
'money' => $acc['money']
|
||||||
]);
|
]);
|
||||||
if (!$doc) throw $this->createNotFoundException();
|
if (!$doc)
|
||||||
|
throw $this->createNotFoundException();
|
||||||
$pdfPid = 0;
|
$pdfPid = 0;
|
||||||
if ($params['pdf']) {
|
if ($params['pdf']) {
|
||||||
$pdfPid = $provider->createPrint(
|
$pdfPid = $provider->createPrint(
|
||||||
$acc['bid'],
|
$acc['bid'],
|
||||||
$this->getUser(),
|
$this->getUser(),
|
||||||
$this->renderView('pdf/posPrinters/buy.html.twig', [
|
$this->renderView('pdf/posPrinters/buy.html.twig', [
|
||||||
'bid' => $acc['bid'],
|
'bid' => $acc['bid'],
|
||||||
'doc'=>$doc,
|
'doc' => $doc,
|
||||||
'rows'=>$doc->getHesabdariRows(),
|
'rows' => $doc->getHesabdariRows(),
|
||||||
'printInvoice'=>$params['posPrint'],
|
'printInvoice' => $params['posPrint'],
|
||||||
'printcashdeskRecp'=>$params['posPrintRecp'],
|
'printcashdeskRecp' => $params['posPrintRecp'],
|
||||||
]),
|
]),
|
||||||
true
|
true
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
@ -414,14 +426,16 @@ class BuyController extends AbstractController
|
||||||
}
|
}
|
||||||
|
|
||||||
$acc = $access->hasRole('buy');
|
$acc = $access->hasRole('buy');
|
||||||
if (!$acc) throw $this->createAccessDeniedException();
|
if (!$acc)
|
||||||
|
throw $this->createAccessDeniedException();
|
||||||
|
|
||||||
$doc = $entityManager->getRepository(HesabdariDoc::class)->findOneBy([
|
$doc = $entityManager->getRepository(HesabdariDoc::class)->findOneBy([
|
||||||
'bid' => $acc['bid'],
|
'bid' => $acc['bid'],
|
||||||
'code' => $params['code'],
|
'code' => $params['code'],
|
||||||
'money'=> $acc['money']
|
'money' => $acc['money']
|
||||||
]);
|
]);
|
||||||
if (!$doc) throw $this->createNotFoundException();
|
if (!$doc)
|
||||||
|
throw $this->createNotFoundException();
|
||||||
$person = null;
|
$person = null;
|
||||||
$discount = 0;
|
$discount = 0;
|
||||||
$transfer = 0;
|
$transfer = 0;
|
||||||
|
@ -438,35 +452,37 @@ class BuyController extends AbstractController
|
||||||
if ($params['pdf']) {
|
if ($params['pdf']) {
|
||||||
$printOptions = [
|
$printOptions = [
|
||||||
'bidInfo' => true,
|
'bidInfo' => true,
|
||||||
'pays' =>true,
|
'pays' => true,
|
||||||
'taxInfo' =>true,
|
'taxInfo' => true,
|
||||||
'discountInfo' =>true,
|
'discountInfo' => true,
|
||||||
'note' =>true,
|
'note' => true,
|
||||||
'paper' =>'A4-L'
|
'paper' => 'A4-L'
|
||||||
];
|
];
|
||||||
if(array_key_exists('printOptions',$params)){
|
if (array_key_exists('printOptions', $params)) {
|
||||||
if(array_key_exists('bidInfo',$params['printOptions'])){
|
if (array_key_exists('bidInfo', $params['printOptions'])) {
|
||||||
$printOptions['bidInfo'] = $params['printOptions']['bidInfo'];
|
$printOptions['bidInfo'] = $params['printOptions']['bidInfo'];
|
||||||
}
|
}
|
||||||
if(array_key_exists('pays',$params['printOptions'])){
|
if (array_key_exists('pays', $params['printOptions'])) {
|
||||||
$printOptions['pays'] = $params['printOptions']['pays'];
|
$printOptions['pays'] = $params['printOptions']['pays'];
|
||||||
}
|
}
|
||||||
if(array_key_exists('taxInfo',$params['printOptions'])){
|
if (array_key_exists('taxInfo', $params['printOptions'])) {
|
||||||
$printOptions['taxInfo'] = $params['printOptions']['taxInfo'];
|
$printOptions['taxInfo'] = $params['printOptions']['taxInfo'];
|
||||||
}
|
}
|
||||||
if(array_key_exists('discountInfo',$params['printOptions'])){
|
if (array_key_exists('discountInfo', $params['printOptions'])) {
|
||||||
$printOptions['discountInfo'] = $params['printOptions']['discountInfo'];
|
$printOptions['discountInfo'] = $params['printOptions']['discountInfo'];
|
||||||
}
|
}
|
||||||
if(array_key_exists('note',$params['printOptions'])){
|
if (array_key_exists('note', $params['printOptions'])) {
|
||||||
$printOptions['note'] = $params['printOptions']['note'];
|
$printOptions['note'] = $params['printOptions']['note'];
|
||||||
}
|
}
|
||||||
if(array_key_exists('paper',$params['printOptions'])){
|
if (array_key_exists('paper', $params['printOptions'])) {
|
||||||
$printOptions['paper'] = $params['printOptions']['paper'];
|
$printOptions['paper'] = $params['printOptions']['paper'];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
$note = '';
|
$note = '';
|
||||||
$printSettings = $entityManager->getRepository(PrintOptions::class)->findOneBy(['bid'=>$acc['bid']]);
|
$printSettings = $entityManager->getRepository(PrintOptions::class)->findOneBy(['bid' => $acc['bid']]);
|
||||||
if($printSettings){$note = $printSettings->getBuyNoteString();}
|
if ($printSettings) {
|
||||||
|
$note = $printSettings->getBuyNoteString();
|
||||||
|
}
|
||||||
$pdfPid = $provider->createPrint(
|
$pdfPid = $provider->createPrint(
|
||||||
$acc['bid'],
|
$acc['bid'],
|
||||||
$this->getUser(),
|
$this->getUser(),
|
||||||
|
@ -478,8 +494,8 @@ class BuyController extends AbstractController
|
||||||
'printInvoice' => $params['printers'],
|
'printInvoice' => $params['printers'],
|
||||||
'discount' => $discount,
|
'discount' => $discount,
|
||||||
'transfer' => $transfer,
|
'transfer' => $transfer,
|
||||||
'printOptions'=> $printOptions,
|
'printOptions' => $printOptions,
|
||||||
'note'=> $note
|
'note' => $note
|
||||||
]),
|
]),
|
||||||
false,
|
false,
|
||||||
$printOptions['paper']
|
$printOptions['paper']
|
||||||
|
|
|
@ -35,7 +35,7 @@ class PrintersController extends AbstractController
|
||||||
#[Route('/api/printers/options/info', name: 'app_printers_options_info')]
|
#[Route('/api/printers/options/info', name: 'app_printers_options_info')]
|
||||||
public function app_printers_options_info(Provider $provider, Request $request, Access $access, Log $log, EntityManagerInterface $entityManager): JsonResponse
|
public function app_printers_options_info(Provider $provider, Request $request, Access $access, Log $log, EntityManagerInterface $entityManager): JsonResponse
|
||||||
{
|
{
|
||||||
$acc = $access->hasRole('settings');
|
$acc = $access->hasRole('join');
|
||||||
if (!$acc)
|
if (!$acc)
|
||||||
throw $this->createAccessDeniedException();
|
throw $this->createAccessDeniedException();
|
||||||
$settings = $entityManager->getRepository(PrintOptions::class)->findOneBy(['bid' => $acc['bid']]);
|
$settings = $entityManager->getRepository(PrintOptions::class)->findOneBy(['bid' => $acc['bid']]);
|
||||||
|
|
|
@ -65,8 +65,8 @@ class SMS
|
||||||
$password = $this->registryMGR->get('sms', 'password');
|
$password = $this->registryMGR->get('sms', 'password');
|
||||||
$from = $this->registryMGR->get('sms', 'fromNum');
|
$from = $this->registryMGR->get('sms', 'fromNum');
|
||||||
$input_data = [];
|
$input_data = [];
|
||||||
foreach ($params as $param) {
|
foreach ($params as $key=>$param) {
|
||||||
$input_data['%p' . strval(array_search($param, $params)) . '%'] = $param;
|
$input_data['p' . strval(array_search($param, $params))] = $param;
|
||||||
}
|
}
|
||||||
$url = "https://ippanel.com/patterns/pattern?username=" . $username . "&password=" . urlencode($password) . "&from=$from&to=" . json_encode($toArray) . "&input_data=" . urlencode(json_encode($input_data)) . "&pattern_code=$bodyID";
|
$url = "https://ippanel.com/patterns/pattern?username=" . $username . "&password=" . urlencode($password) . "&from=$from&to=" . json_encode($toArray) . "&input_data=" . urlencode(json_encode($input_data)) . "&pattern_code=$bodyID";
|
||||||
$handler = curl_init($url);
|
$handler = curl_init($url);
|
||||||
|
|
Loading…
Reference in a new issue