This commit is contained in:
babak alizadeh 2024-08-02 14:33:47 +03:30
parent 0ff1611b2b
commit 27de3fccd4
8 changed files with 72 additions and 21 deletions

View file

@ -142,7 +142,7 @@ class BuyController extends AbstractController
$hesabdariRow->setBd(0); $hesabdariRow->setBd(0);
$hesabdariRow->setBs($params['discountAll']); $hesabdariRow->setBs($params['discountAll']);
$ref = $entityManager->getRepository(HesabdariTable::class)->findOneBy([ $ref = $entityManager->getRepository(HesabdariTable::class)->findOneBy([
'code' => '104' // سایر هزینه های پخش و خرید 'code' => '51' // تخفیفات نقدی خرید
]); ]);
$hesabdariRow->setRef($ref); $hesabdariRow->setRef($ref);
$entityManager->persist($hesabdariRow); $entityManager->persist($hesabdariRow);
@ -180,7 +180,7 @@ class BuyController extends AbstractController
} }
//set amount of document //set amount of document
$doc->setAmount($sumTax + $sumTotal - $params['discountAll'] + $params['transferCost']); $doc->setAmount($sumTax + $sumTotal - $params['discountAll'] + $params['transferCost']);
//set person buyer //set person person
$hesabdariRow = new HesabdariRow(); $hesabdariRow = new HesabdariRow();
$hesabdariRow->setDes('فاکتور خرید'); $hesabdariRow->setDes('فاکتور خرید');
$hesabdariRow->setBid($acc['bid']); $hesabdariRow->setBid($acc['bid']);
@ -189,12 +189,12 @@ class BuyController extends AbstractController
$hesabdariRow->setBd(0); $hesabdariRow->setBd(0);
$hesabdariRow->setBs($sumTax + $sumTotal + $params['transferCost'] - $params['discountAll']); $hesabdariRow->setBs($sumTax + $sumTotal + $params['transferCost'] - $params['discountAll']);
$ref = $entityManager->getRepository(HesabdariTable::class)->findOneBy([ $ref = $entityManager->getRepository(HesabdariTable::class)->findOneBy([
'code' => '3' // persons 'code' => '8' // persons
]); ]);
$hesabdariRow->setRef($ref); $hesabdariRow->setRef($ref);
$person = $entityManager->getRepository(Person::class)->findOneBy([ $person = $entityManager->getRepository(Person::class)->findOneBy([
'bid' => $acc['bid'], 'bid' => $acc['bid'],
'code' => $params['buyer']['code'] 'code' => $params['person']['code']
]); ]);
if (!$person) if (!$person)
return $this->json($extractor->paramsNotSend()); return $this->json($extractor->paramsNotSend());
@ -429,7 +429,8 @@ class BuyController extends AbstractController
'pays' =>true, 'pays' =>true,
'taxInfo' =>true, 'taxInfo' =>true,
'discountInfo' =>true, 'discountInfo' =>true,
'note' =>true 'note' =>true,
'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'])){
@ -447,6 +448,9 @@ class BuyController extends AbstractController
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'])){
$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']]);
@ -465,7 +469,8 @@ class BuyController extends AbstractController
'printOptions'=> $printOptions, 'printOptions'=> $printOptions,
'note'=> $note 'note'=> $note
]), ]),
false false,
$printOptions['paper']
); );
} }
if ($params['printers'] == true) { if ($params['printers'] == true) {

View file

@ -52,6 +52,8 @@ class PrintersController extends AbstractController
$temp['sell']['note'] = $settings->isSellNote(); $temp['sell']['note'] = $settings->isSellNote();
$temp['sell']['noteString'] = $settings->getSellNoteString(); $temp['sell']['noteString'] = $settings->getSellNoteString();
$temp['sell']['pays'] = $settings->isSellPays(); $temp['sell']['pays'] = $settings->isSellPays();
$temp['sell']['paper'] = $settings->getSellPaper();
if(!$temp['sell']['paper']) { $temp['sell']['paper'] = 'A4-L'; }
$temp['buy']['id'] = $settings->getId(); $temp['buy']['id'] = $settings->getId();
$temp['buy']['bidInfo'] = $settings->isBuyBidInfo(); $temp['buy']['bidInfo'] = $settings->isBuyBidInfo();
@ -60,6 +62,8 @@ class PrintersController extends AbstractController
$temp['buy']['note'] = $settings->isBuyNote(); $temp['buy']['note'] = $settings->isBuyNote();
$temp['buy']['noteString'] = $settings->getBuyNoteString(); $temp['buy']['noteString'] = $settings->getBuyNoteString();
$temp['buy']['pays'] = $settings->isBuyPays(); $temp['buy']['pays'] = $settings->isBuyPays();
$temp['buy']['paper'] = $settings->getBuyPaper();
if(!$temp['buy']['paper']) { $temp['buy']['paper'] = 'A4-L'; }
$temp['rfbuy']['id'] = $settings->getId(); $temp['rfbuy']['id'] = $settings->getId();
$temp['rfbuy']['bidInfo'] = $settings->isRfbuyBidInfo(); $temp['rfbuy']['bidInfo'] = $settings->isRfbuyBidInfo();
@ -68,6 +72,8 @@ class PrintersController extends AbstractController
$temp['rfbuy']['note'] = $settings->isRfbuyNote(); $temp['rfbuy']['note'] = $settings->isRfbuyNote();
$temp['rfbuy']['noteString'] = $settings->getRfbuyNoteString(); $temp['rfbuy']['noteString'] = $settings->getRfbuyNoteString();
$temp['rfbuy']['pays'] = $settings->isRfbuyPays(); $temp['rfbuy']['pays'] = $settings->isRfbuyPays();
$temp['rfbuy']['paper'] = $settings->getRfbuyPaper();
if(!$temp['rfbuy']['paper']) { $temp['rfbuy']['paper'] = 'A4-L'; }
$temp['rfsell']['id'] = $settings->getId(); $temp['rfsell']['id'] = $settings->getId();
$temp['rfsell']['bidInfo'] = $settings->isRfsellBidInfo(); $temp['rfsell']['bidInfo'] = $settings->isRfsellBidInfo();
@ -76,6 +82,9 @@ class PrintersController extends AbstractController
$temp['rfsell']['note'] = $settings->isRfsellNote(); $temp['rfsell']['note'] = $settings->isRfsellNote();
$temp['rfsell']['noteString'] = $settings->getRfsellNoteString(); $temp['rfsell']['noteString'] = $settings->getRfsellNoteString();
$temp['rfsell']['pays'] = $settings->isRfsellPays(); $temp['rfsell']['pays'] = $settings->isRfsellPays();
$temp['rfsell']['paper'] = $settings->getRfsellPaper();
if(!$temp['rfsell']['paper']) { $temp['rfsell']['paper'] = 'A4-L'; }
return $this->json($temp); return $this->json($temp);
} }
@ -103,13 +112,15 @@ class PrintersController extends AbstractController
$settings->setSellNote($params['sell']['note']); $settings->setSellNote($params['sell']['note']);
$settings->setSellNoteString($params['sell']['noteString']); $settings->setSellNoteString($params['sell']['noteString']);
$settings->setSellPays($params['sell']['pays']); $settings->setSellPays($params['sell']['pays']);
$settings->setSellPaper($params['sell']['paper']);
$settings->setBuyBidInfo($params['buy']['bidInfo']); $settings->setBuyBidInfo($params['buy']['bidInfo']);
$settings->setBuyTaxInfo($params['buy']['taxInfo']); $settings->setBuyTaxInfo($params['buy']['taxInfo']);
$settings->setBuyDiscountInfo($params['buy']['discountInfo']); $settings->setBuyDiscountInfo($params['buy']['discountInfo']);
$settings->setBuyNote($params['buy']['note']); $settings->setBuyNote($params['buy']['note']);
$settings->setBuyNoteString($params['buy']['noteString']); $settings->setBuyNoteString($params['buy']['noteString']);
$settings->setBuyPays($params['buy']['pays']); $settings->setBuyPays($params['buy']['pays']);
$settings->setBuyPaper($params['buy']['paper']);
$settings->setRfbuyBidInfo($params['rfbuy']['bidInfo']); $settings->setRfbuyBidInfo($params['rfbuy']['bidInfo']);
$settings->setRfbuyTaxInfo($params['rfbuy']['taxInfo']); $settings->setRfbuyTaxInfo($params['rfbuy']['taxInfo']);
@ -117,6 +128,7 @@ class PrintersController extends AbstractController
$settings->setRfbuyNote($params['rfbuy']['note']); $settings->setRfbuyNote($params['rfbuy']['note']);
$settings->setRfbuyNoteString($params['rfbuy']['noteString']); $settings->setRfbuyNoteString($params['rfbuy']['noteString']);
$settings->setRfbuyPays($params['rfbuy']['pays']); $settings->setRfbuyPays($params['rfbuy']['pays']);
$settings->setRfbuyPaper($params['rfbuy']['paper']);
$settings->setRfsellBidInfo($params['rfsell']['bidInfo']); $settings->setRfsellBidInfo($params['rfsell']['bidInfo']);
$settings->setRfsellTaxInfo($params['rfsell']['taxInfo']); $settings->setRfsellTaxInfo($params['rfsell']['taxInfo']);
@ -124,6 +136,7 @@ class PrintersController extends AbstractController
$settings->setRfsellNote($params['rfsell']['note']); $settings->setRfsellNote($params['rfsell']['note']);
$settings->setRfsellNoteString($params['rfsell']['noteString']); $settings->setRfsellNoteString($params['rfsell']['noteString']);
$settings->setRfsellPays($params['rfsell']['pays']); $settings->setRfsellPays($params['rfsell']['pays']);
$settings->setRfSellPaper($params['rfsell']['paper']);
$entityManager->persist($settings); $entityManager->persist($settings);
$entityManager->flush(); $entityManager->flush();

View file

@ -165,7 +165,7 @@ class RfbuyController extends AbstractController
} }
//set amount of document //set amount of document
$doc->setAmount($sumTax + $sumTotal - $params['discountAll'] + $params['transferCost']); $doc->setAmount($sumTax + $sumTotal - $params['discountAll'] + $params['transferCost']);
//set person buyer //set person person
$hesabdariRow = new HesabdariRow(); $hesabdariRow = new HesabdariRow();
$hesabdariRow->setDes('فاکتور برگشت از خرید'); $hesabdariRow->setDes('فاکتور برگشت از خرید');
$hesabdariRow->setBid($acc['bid']); $hesabdariRow->setBid($acc['bid']);
@ -179,7 +179,7 @@ class RfbuyController extends AbstractController
$hesabdariRow->setRef($ref); $hesabdariRow->setRef($ref);
$person = $entityManager->getRepository(Person::class)->findOneBy([ $person = $entityManager->getRepository(Person::class)->findOneBy([
'bid' => $acc['bid'], 'bid' => $acc['bid'],
'code' => $params['buyer']['code'] 'code' => $params['person']['code']
]); ]);
if (!$person) if (!$person)
return $this->json($extractor->paramsNotSend()); return $this->json($extractor->paramsNotSend());
@ -414,7 +414,8 @@ class RfbuyController extends AbstractController
'pays' =>true, 'pays' =>true,
'taxInfo' =>true, 'taxInfo' =>true,
'discountInfo' =>true, 'discountInfo' =>true,
'note' =>true 'note' =>true,
'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'])){
@ -432,6 +433,9 @@ class RfbuyController extends AbstractController
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'])){
$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']]);
@ -450,7 +454,8 @@ class RfbuyController extends AbstractController
'printOptions'=> $printOptions, 'printOptions'=> $printOptions,
'note'=> $note 'note'=> $note
]), ]),
false false,
$printOptions['paper']
); );
} }
if ($params['printers'] == true) { if ($params['printers'] == true) {

View file

@ -180,7 +180,7 @@ class RfsellController extends AbstractController
} }
//set amount of document //set amount of document
$doc->setAmount($sumTax + $sumTotal - $params['discountAll'] + $params['transferCost']); $doc->setAmount($sumTax + $sumTotal - $params['discountAll'] + $params['transferCost']);
//set person buyer //set person person
$hesabdariRow = new HesabdariRow(); $hesabdariRow = new HesabdariRow();
$hesabdariRow->setDes('فاکتور برگشت از فروش'); $hesabdariRow->setDes('فاکتور برگشت از فروش');
$hesabdariRow->setBid($acc['bid']); $hesabdariRow->setBid($acc['bid']);
@ -194,7 +194,7 @@ class RfsellController extends AbstractController
$hesabdariRow->setRef($ref); $hesabdariRow->setRef($ref);
$person = $entityManager->getRepository(Person::class)->findOneBy([ $person = $entityManager->getRepository(Person::class)->findOneBy([
'bid' => $acc['bid'], 'bid' => $acc['bid'],
'code' => $params['buyer']['code'] 'code' => $params['person']['code']
]); ]);
if (!$person) if (!$person)
return $this->json($extractor->paramsNotSend()); return $this->json($extractor->paramsNotSend());
@ -429,7 +429,8 @@ class RfsellController extends AbstractController
'pays' =>true, 'pays' =>true,
'taxInfo' =>true, 'taxInfo' =>true,
'discountInfo' =>true, 'discountInfo' =>true,
'note' =>true 'note' =>true,
'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'])){
@ -447,6 +448,9 @@ class RfsellController extends AbstractController
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'])){
$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']]);
@ -465,7 +469,8 @@ class RfsellController extends AbstractController
'printOptions'=> $printOptions, 'printOptions'=> $printOptions,
'note'=> $note 'note'=> $note
]), ]),
false false,
$printOptions['paper']
); );
} }
if ($params['printers'] == true) { if ($params['printers'] == true) {

View file

@ -165,7 +165,7 @@ class SellController extends AbstractController
} }
//set amount of document //set amount of document
$doc->setAmount($sumTax + $sumTotal - $params['discountAll'] + $params['transferCost']); $doc->setAmount($sumTax + $sumTotal - $params['discountAll'] + $params['transferCost']);
//set person buyer //set person person
$hesabdariRow = new HesabdariRow(); $hesabdariRow = new HesabdariRow();
$hesabdariRow->setDes('فاکتور فروش'); $hesabdariRow->setDes('فاکتور فروش');
$hesabdariRow->setBid($acc['bid']); $hesabdariRow->setBid($acc['bid']);
@ -179,7 +179,7 @@ class SellController extends AbstractController
$hesabdariRow->setRef($ref); $hesabdariRow->setRef($ref);
$person = $entityManager->getRepository(Person::class)->findOneBy([ $person = $entityManager->getRepository(Person::class)->findOneBy([
'bid' => $acc['bid'], 'bid' => $acc['bid'],
'code' => $params['buyer']['code'] 'code' => $params['person']['code']
]); ]);
if (!$person) if (!$person)
return $this->json($extractor->paramsNotSend()); return $this->json($extractor->paramsNotSend());
@ -414,7 +414,8 @@ class SellController extends AbstractController
'pays' =>true, 'pays' =>true,
'taxInfo' =>true, 'taxInfo' =>true,
'discountInfo' =>true, 'discountInfo' =>true,
'note' =>true 'note' =>true,
'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'])){
@ -432,6 +433,9 @@ class SellController extends AbstractController
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'])){
$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']]);
@ -450,7 +454,8 @@ class SellController extends AbstractController
'printOptions'=> $printOptions, 'printOptions'=> $printOptions,
'note'=> $note 'note'=> $note
]), ]),
false false,
$printOptions['paper']
); );
} }
if ($params['printers'] == true) { if ($params['printers'] == true) {

View file

@ -33,6 +33,9 @@ class PrinterQueue
#[ORM\Column(nullable: true)] #[ORM\Column(nullable: true)]
private ?bool $posprint = null; private ?bool $posprint = null;
#[ORM\Column(length: 50, nullable: true)]
private ?string $paperSize = null;
public function getId(): ?int public function getId(): ?int
{ {
return $this->id; return $this->id;
@ -109,4 +112,16 @@ class PrinterQueue
return $this; return $this;
} }
public function getPaperSize(): ?string
{
return $this->paperSize;
}
public function setPaperSize(?string $paperSize): static
{
$this->paperSize = $paperSize;
return $this;
}
} }

View file

@ -147,12 +147,13 @@ class Provider
return $result; return $result;
} }
public function createPrint(Business $bid, User $user, String $data,$posPrint = false) public function createPrint(Business $bid, User $user, String $data,$posPrint = false,$paperSize = 'A4-L')
{ {
$print = new PrinterQueue(); $print = new PrinterQueue();
$print->setDateSubmit(time()); $print->setDateSubmit(time());
$print->setSubmitter($user); $print->setSubmitter($user);
$print->setBid($bid); $print->setBid($bid);
$print->setPaperSize($paperSize);
$print->setView($data); $print->setView($data);
$print->setPosprint($posPrint); $print->setPosprint($posPrint);
$print->setPid($this->RandomString(128)); $print->setPid($this->RandomString(128));

View file

@ -24,10 +24,12 @@ class pdfMGR
$footer = $template->render([ $footer = $template->render([
]); ]);
$size = $printQueue->getPaperSize();
if(!$size){ $size = 'A4-L'; }
$defaultConfig = (new \Mpdf\Config\ConfigVariables())->getDefaults(); $defaultConfig = (new \Mpdf\Config\ConfigVariables())->getDefaults();
$fontDirs = $defaultConfig['fontDir']; $fontDirs = $defaultConfig['fontDir'];
$mpdf = new \Mpdf\Mpdf([ $mpdf = new \Mpdf\Mpdf([
'mode' => 'utf-8', 'format' => 'A4-L', 'mode' => 'utf-8', 'format' => $size,
'fontDir' => array_merge($fontDirs, [ 'fontDir' => array_merge($fontDirs, [
__DIR__ . '../Fonts', __DIR__ . '../Fonts',
]), ]),