Adding a Custom Button to TakePOS

I recently added a custom button to the TakePOS interface in Dolibarr 21.0.0 to enhance my point-of-sale workflow. By editing /htdocs/takepos/index.php at lines betwen 1400–1500, I inserted these lines:


$menus[$r++] = array('title' => '<span class="fa fa-qrcode paddingrightonly"></span><div class="trunc">'.$langs->trans("QR Code(s)").'</div>', 'action' => 'AddedAction()();');

This adds a button labeled “QR code(s)” with a fa-qrcode icon,. To make it functional, you’ll need to define the AddedAction()() function in `/takepos/js/index.php. here’ the javascript for the function to open popup window displaying codes (QR,Barcode or Datamatrix)


function AddedAction() {
// Check if a line is selected
if (typeof selectedline === ‘undefined’ || !selectedline) {
alert(“Please select a product line first!”);
return;
}

  	  alert(selectedline);

// Extract product name, quantity, and price you must find the corresponding variables in httdocs/takepos/index.php

<?php $product = "Laptop"; $price = 1200; $customer = "Alice Smith"; ?>

// Open the popup with the QR code
// open popopup window
const product = “<?php echo urlencode($product); ?>”;
const price = “<?php echo urlencode($price); ?>”;
const customer = “<?php echo urlencode($customer); ?>”;
const url = qr.php?product=${product}&price=${price}&customer=${customer};
window.open(
url, // URL of the popup
“Imression des codes”, // Name of the popup window
“width=400,height=900” // Features
);

}

It’s a simple way to customize TakePOS—just ensure you back up your file before editing!
It will be helpful foe me if you can find the variables costumer, price,qte… in the file index.php. Thanks

Hello, i suggest you use the ActionButtons hook :wink:

	function ActionButtons() {
		global $conf,$user,$langs,$hookmanager;

		if (in_array('takeposfrontend',$hookmanager->contextarray)) {
			print '<script type="text/javascript">
				// your js code here
			</script>';
		}
	}
1 Like

This is the beginning of the project to build a module that produces and manages QR, Barcode and Datamatrix codes so any contribution, remark or suggestion will be very helpful. Thank you very much

1 Like

Ok, feel free to contact me if you need any help.
Christophe

1 Like