Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Using multiple LAN thermal printer #36

Open
azizie94 opened this issue Nov 27, 2022 · 3 comments
Open

Using multiple LAN thermal printer #36

azizie94 opened this issue Nov 27, 2022 · 3 comments

Comments

@azizie94
Copy link

Hi everyone, I already test this package with my LAN thermal printer and everything working fine. The issue is when Im trying to send my data to multiple printer.

I have 2 LAN printer, when I send data to print for both printer:

  • 1st printer print fast.
  • 2nd printer print quite long but is still print just the timing I think its not normal.

Those anyone here have face this problem ? May I know what is the solution?

Thanks.

@azizie94
Copy link
Author

azizie94 commented Dec 8, 2022

@charlieuki any help?

@charlieuki
Copy link
Owner

Hi everyone, I already test this package with my LAN thermal printer and everything working fine. The issue is when Im trying to send my data to multiple printer.

I have 2 LAN printer, when I send data to print for both printer:

  • 1st printer print fast.
  • 2nd printer print quite long but is still print just the timing I think its not normal.

Those anyone here have face this problem ? May I know what is the solution?

Thanks.

Hi there @azizie94 sorry about the long delay on the reply.
Could you post how your setup along with the printer models?
Something like:

EPSON TM-T82 (printer1) <---> web server <---> EPSON TM T-58 (printer2)

And also what is your PHP version and Laravel version when you are testing this package.

@azizie94
Copy link
Author

azizie94 commented Feb 5, 2023

Hi @charlieuki,

I have 3 event which is OrderCreated, PrintOrderDetail, PrintDocketDetail.

The flow is, once I create an order I will publish OrderCreated Event.

Once the OrderCreated event published, the PrintOrderDetail and PrintDocketDetail event will run simultaneously.

event PrintOrderDetail - 1st printer
/**
* Handle the event.
*
* @param object $event
* @return void
*/
public function handle(OrderPrinter $event)
{
$setting = Setting::firstWhere('pos_id','POS1');
$branch = Branch::firstWhere('id',1);
$order = $event->order;
$mid = '30001001';
$store_name = 'KIDDYTOPIA';
$store_address = strtoupper('GYRO HOLDING SDN BHD'."\n".$branch->address.' '.$branch->postcode.' '.$branch->city_info->name.' ,'.$branch->state_info->state.'.');
$store_phone = $branch->contact;
$store_email = $branch->email;
$store_website = '';
$tax_percentage = 0;
$transaction_id = $order->code;

    // Init printer
    $printer = new ReceiptPrinter;
    $printer->init(
        'network',
        $setting->order_printer_ip,
    );

    // Set store info
    $printer->setStore($mid, $store_name, $store_address, $store_phone, $store_email, $store_website);

.....

event PrintDocketDetail - 2nd printer
/**
* Handle the event.
*
* @param object $event
* @return void
*/
public function handle(DocketPrinter $event)
{
$setting = Setting::firstWhere('id',1);
$branch = Branch::firstWhere('id',1);
$order = app('product')->session($event->tableId)->getContent();
$table = Table::firstWhere('id',$event->tableId);
$mid = '30001001';
$store_name = 'KIDDYTOPIA';
$store_address = strtoupper($branch->name."\n".$branch->address.' '.$branch->postcode.' '.$branch->city_info->name.' ,'.$branch->state_info->state.'.');
$store_phone = $branch->contact;
$store_email = $branch->email;
$store_website = '';
$tax_percentage = 0;

    // Init printer
    $printer = new ReceiptPrinter;
    $printer->init(
        'network',
        $setting->order_printer_ip,
    );

    // Set store info
    $printer->setStore($mid, $store_name, $store_address, $store_phone, $store_email, $store_website);

....

So when OrderCreated event publish, the PrintOrderDetail and PrintDocketDetail listen successfully but the 1st printer will print the result fast, the 2nd printer take 15-30 second to print.

I am using Laravel 9 and php 8.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants